void interface_list(disk_t *disk, const int verbose, const int saveheader, const int backup) { list_part_t *list_part; list_part_t *parts; log_info("\nAnalyse "); log_info("%s\n", disk->description(disk)); printf("%s\n", disk->description(disk)); printf(msg_PART_HEADER_LONG); list_part=disk->arch->read_part(disk,verbose,saveheader); for(parts=list_part; parts!=NULL; parts=parts->next) { const char *msg; const partition_t *partition=parts->part; msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk, partition); printf("%s\n", msg); if(partition->info[0]!='\0') printf(" %s\n", partition->info); } if(backup>0) { partition_save(disk, list_part, verbose); } part_free_list(list_part); }
// --------------------------------------------------------------------------- /// Saves meshes for tecplot.out. // --------------------------------------------------------------------------- void tecIO_saveFields (double time, meshVec_RO_p E, meshVec_RO_p H) { parameter_save (); int fileMap = fileMap_save (); // Saving region. reg_t reg = {{cpu_min[0], cpu_min[1], cpu_min[2]}, {cpu_max[0], cpu_max[1], cpu_max[2]}, 0}; // Saves interpolated vector fields. tecIO_saveVec (IO_nameCpuRec (name_E_full, cpu_here, tecplotNum), E, ®, tecIO_interpE); tecIO_saveVec (IO_nameCpuRec (name_H_full, cpu_here, tecplotNum), H, ®, tecIO_interpH); if (cpu_here) return; // Saves header and descriptor. FILE *fp = cfg_open (IO_nameRec (name_info, tecplotNum), "wb", __func__); fwrite (&time, sizeof (double), 1, fp); fwrite (&cpu_total, sizeof (int), 1, fp); fwrite (&fileMap, sizeof (int), 1, fp); fclose (fp); // Saves partition. partition_save (IO_nameRec (name_prtn_full, tecplotNum)); }
// --------------------------------------------------------------------------- /// Reads <b>run_mandor.cfg</b> file and sets all global static parameters (called from main()). // --------------------------------------------------------------------------- static void main_startUp (void) { // Loading time is a first estimate of a saving time. timeTick_t startUpStart; time_get (&startUpStart); main_allocateMeshes (); FILE *fp; int buffer[6]; if (!cpu_here) { fp = cfg_open ("run_mandor.cfg", "rt", __func__); // Reads checkpointing steps and startup flags. buffer[0] = cfg_readInt (fp); // - totalSteps. buffer[1] = cfg_readInt (fp); // - chPoint_full. buffer[2] = cfg_readInt (fp); // - chPoint_tecplot. buffer[3] = (1 == cfg_readInt (fp)); // - continueRun. buffer[4] = cfg_readInt (fp); // - chPoint_stopRequest buffer[5] = cfg_readInt (fp); // - chPoint_spectr fclose (fp); } // Broadcasts parameters. MPI_Bcast (buffer, 6, MPI_INT, 0, MPI_COMM_WORLD); totalSteps = buffer[0]; chPoint_full = buffer[1]; chPoint_tecplot = buffer[2]; int continueRun = buffer[3]; chPoint_stopRequest = buffer[4]; chPoint_spectr = buffer[5]; // Checks if sizes can be divided by. ENSURE (totalSteps*chPoint_full*chPoint_tecplot *chPoint_stopRequest*chPoint_spectr, "'run_mandor.cfg' contains zero step(s)"); // Sets time barrier. if (!(fp = fopen ("tmp/stop.flag", "rt"))) { fp = cfg_open ("tmp/stop.flag", "wt", __func__); // Sets timeout. SAY_DEBUG ("Setting timeout to 23h30m."); fprintf (fp, "0\n%d\n", 23*60*60 + 30*60); fclose (fp); } // Record are numbered as 0, .., N - 1. int point = sysIO_recordsTotal () - 1; MPI_Bcast (&point, 1, MPI_INT, 0, MPI_COMM_WORLD); // Chooses start-up mode. ENSURE (point >= 0, "initial checkpoint is not prepared"); if (continueRun && point != 0) { fileMap_init (mc_fileMap_contn); sysIO_setRecordNum (-1); // Continues check-pointing. tecIO_setRecordNum (-1); // Continues tecplot output. spectr_continueDump (); // Continues spectr output. } else { fileMap_init (mc_fileMap_start); sysIO_setRecordNum (1); // Starts to write just after setup record. tecIO_setRecordNum (1); // Starts to write just after setup record. spectr_startDump (); // Starts new spectr output sequence. point = 0; } // Initializes total energy diagnostic. wDensity_prepare (!(continueRun && point != 0)); /// \todo Partitioning options outside. SAY_WARNING("Explicit partitioning is blocked."); if (/*continueRun && point != 0 &&*/ 0) { partition_load ("output/partition_onStart.cfg"); // Loads old partitioning. } else { partition_init (); // Initializes partitioning. partition_save ("output/partition_onStart.cfg"); // Saves partitioning used. } // Sets the size of meshes using the partitioning. main_reconfigureMeshes (); double time; const reg_t to_load = {{cpu_min[0], cpu_min[1], cpu_min[2]}, {cpu_max[0], cpu_max[1], cpu_max[2]}, 0}; sysIO_loadEM (point, &time, &to_load, &E, &H); plasma_load (point); mf_mesh_clean (&J); mf_mesh_clean (&rho); parameter_setTime (time); parameter_dump (); // Prints parameters loaded. partition_show (); // Tecplot visualization of partititon. // Allocates probes and opens associated files. probe_allocate (continueRun && point > 0); say ("main_startUp: config file is imported. Parameters of the run are:"); say (" - %d total steps", totalSteps); say (" - %d steps between check-points", chPoint_full); if (chPoint_tecplot > 0) { say (" - %d steps between tecplot shots", chPoint_tecplot); } else { say (" - tecplot shots are off"); } if (chPoint_spectr > 0) { say (" - %d steps between spectral data dumps", chPoint_spectr); } else { say (" - EM spectral energy distribution diagnostic is off"); } say (" - %d steps between updating a stop request", chPoint_stopRequest); say (" - simulation is %s from check-point #%03d.", (continueRun && point != 0) ? "continued" : "started", point); // Loading time is a good estimate of saving time. timeTick_t startUpFinish; time_get (&startUpFinish); stopFlag_saveTime = time_elapsed (&startUpStart, &startUpFinish); // Configures convolutioner. double VSP_weight = 1.0; if (cl_findDouble ("VSP:weight", &VSP_weight)) VSP_weight = (VSP_weight > 0.5 && VSP_weight < 1.00001) ? VSP_weight : 1.00; VSP_configure (VSP_weight); }
static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd) { int offset=0; int pos_num=0; list_part_t *pos=list_part; int rewrite=1; int old_LINES=LINES; while(1) { int i; int command; list_part_t *parts; int structure_status; if(old_LINES!=LINES) { rewrite=1; old_LINES=LINES; } if(rewrite) { aff_copy(stdscr); wmove(stdscr,4,0); wprintw(stdscr,"%s",disk_car->description(disk_car)); mvwaddstr(stdscr,5,0,msg_PART_HEADER); rewrite=0; } structure_status=disk_car->arch->test_structure(list_part); for(i=0,parts=list_part; parts!=NULL && i<offset+INTER_STRUCTURE; i++, parts=parts->next) { if(i<offset) continue; wmove(stdscr,6+i-offset,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(parts==pos) wattrset(stdscr, A_REVERSE); if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(2)); if(parts==pos) waddstr(stdscr, ">"); else waddstr(stdscr, " "); aff_part(stdscr, AFF_PART_STATUS, disk_car, parts->part); if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); if(parts==pos) { char buffer_part_size[100]; wattroff(stdscr, A_REVERSE); wmove(stdscr,LINES-1,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(parts->part->info[0]!='\0') { wprintw(stdscr,"%s, ",parts->part->info); } size_to_unit(parts->part->part_size, buffer_part_size); wprintw(stdscr,"%s", buffer_part_size); } } if(structure_status==0) { if(list_part!=NULL) mvwaddstr(stdscr,LINES-6,0,msg_STRUCT_OK); } else { if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(1)); mvwaddstr(stdscr,LINES-6,0,msg_STRUCT_BAD); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); } if(list_part!=NULL && disk_car->arch->msg_part_type!=NULL) { mvwaddstr(stdscr,LINES-6,16,"Use "); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Up"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,"/"); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Down"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr," Arrow keys to select partition."); mvwaddstr(stdscr,LINES-5,0,"Use "); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Left"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,"/"); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Right"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr," Arrow keys to CHANGE partition characteristics:"); mvwaddstr(stdscr,LINES-4,0,disk_car->arch->msg_part_type); } wmove(stdscr,LINES-3,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ waddstr(stdscr,"Keys "); /* If the disk can't be partionned, there is no partition to add and no partition to save */ if(disk_car->arch != &arch_none) { if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"A"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": add partition, "); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"L"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": load backup, "); } if(list_part==NULL) { waddstr(stdscr,"Enter: to continue"); } else { if(pos->part->arch==NULL || pos->part->arch==disk_car->arch) { if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"T"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": change type, "); } switch(pos->part->upart_type) { case UP_EXFAT: case UP_EXT2: case UP_EXT3: case UP_EXT4: case UP_RFS: case UP_RFS2: case UP_RFS3: case UP_FAT12: case UP_FAT16: case UP_FAT32: case UP_NTFS: if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"P"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": list files, "); break; default: break; } if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); mvwaddstr(stdscr,LINES-2,5, "Enter"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": to continue"); } wrefresh(stdscr); command=wgetch(stdscr); switch(command) { case KEY_UP: if(list_part!=NULL) { only_one_bootable(list_part,pos); if(pos->prev!=NULL) { pos=pos->prev; pos_num--; } } break; case KEY_DOWN: if(list_part!=NULL) { only_one_bootable(list_part,pos); if(pos->next!=NULL) { pos=pos->next; pos_num++; } } break; case KEY_PPAGE: if(list_part!=NULL) { only_one_bootable(list_part,pos); for(i=0; i<INTER_STRUCTURE && pos->prev!=NULL; i++) { pos=pos->prev; pos_num--; } } break; case KEY_NPAGE: if(list_part!=NULL) { only_one_bootable(list_part,pos); for(i=0; i<INTER_STRUCTURE && pos->next!=NULL; i++) { pos=pos->next; pos_num++; } } break; case KEY_RIGHT: case '+': case ' ': if(list_part!=NULL) { if(pos->part->arch==NULL || pos->part->arch==disk_car->arch) disk_car->arch->set_next_status(disk_car,pos->part); } break; case KEY_LEFT: case '-': if(list_part!=NULL) { if(pos->part->arch==NULL || pos->part->arch==disk_car->arch) disk_car->arch->set_prev_status(disk_car,pos->part); } break; case 'a': case 'A': if(disk_car->arch != &arch_none) { list_part=add_partition_ncurses(disk_car, list_part); rewrite=1; offset=0; pos_num=0; pos=list_part; } break; case 't': case 'T': if(list_part!=NULL) { rewrite=1; change_part_type_ncurses(disk_car, pos->part); } break; case 'p': case 'P': if(list_part!=NULL) { const partition_t *partition=pos->part; if(partition->sb_offset==0 || partition->sb_size==0) dir_partition(disk_car,partition,verbose, current_cmd); else { io_redir_add_redir(disk_car, partition->part_offset+partition->sborg_offset, partition->sb_size, partition->part_offset+partition->sb_offset, NULL); dir_partition(disk_car,partition,verbose, current_cmd); io_redir_del_redir(disk_car, partition->part_offset+partition->sborg_offset); } rewrite=1; } break; case 'b': case 'B': if(partition_save(disk_car,list_part,verbose)<0) display_message("Can't create backup.log.\n"); else display_message("Results saved in backup.log.\n"); rewrite=1; break; case 'l': case 'L': if(disk_car->arch != &arch_none) { list_part=interface_load(disk_car,list_part,verbose); rewrite=1; offset=0; pos_num=0; pos=list_part; } break; case 'q': case '\r': case '\n': case KEY_ENTER: #ifdef PADENTER case PADENTER: #endif case 'M': return list_part; default: /* log_trace("ask_structure command=%x\n",command); */ break; } if(pos_num<offset) offset=pos_num; if(pos_num>=offset+INTER_STRUCTURE) offset=pos_num-INTER_STRUCTURE+1; } }
static list_part_t *interface_analyse_ncurses(disk_t *disk_car, const int verbose, const int saveheader, char**current_cmd) { list_part_t *list_part; int command; #ifdef HAVE_NCURSES const struct MenuItem menuAnalyse[]= { { 'P', "Previous",""}, { 'N', "Next","" }, { 'Q',"Quick Search","Try to locate partition"}, { 'B', "Backup","Save current partition list to backup.log file and proceed"}, { 0, NULL, NULL } }; #endif screen_buffer_reset(); /* ncurses interface */ #ifdef HAVE_NCURSES aff_copy(stdscr); wmove(stdscr,4,0); wprintw(stdscr,"%s\n",disk_car->description(disk_car)); mvwaddstr(stdscr,5,0,"Checking current partition structure"); wrefresh(stdscr); #endif list_part=disk_car->arch->read_part(disk_car,verbose,saveheader); log_info("Current partition structure:\n"); screen_buffer_to_log(); #ifdef HAVE_NCURSES wmove(stdscr,5,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ waddstr(stdscr,"Current partition structure:"); wmove(stdscr,6,0); wprintw(stdscr,msg_PART_HEADER_LONG); if(disk_car->arch->msg_part_type!=NULL) mvwaddstr(stdscr,LINES-3,0,disk_car->arch->msg_part_type); #endif command='Q'; if(*current_cmd!=NULL) { while(*current_cmd[0]==',') (*current_cmd)++; if(strncmp(*current_cmd,"backup",6)==0) { (*current_cmd)+=6; if(list_part!=NULL) command='B'; } } else { log_flush(); #ifdef HAVE_NCURSES command=screen_buffer_display(stdscr, (list_part!=NULL && disk_car->arch != &arch_none?"QB":"Q"), menuAnalyse); #endif } if(command=='B') { log_info("Backup partition structure\n"); if(partition_save(disk_car,list_part,verbose)<0) { display_message("Can't create backup.log.\n"); } } return list_part; }