void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event ) { if( m_RegulatorListChanged ) { if( GetDataFilename().IsEmpty() ) { int opt = wxMessageBox( _("Data modified, and no data filename to save modifications\n"\ "Do you want to exit and abandon your change?"), _("Regulator list change"), wxYES_NO | wxICON_QUESTION ); if( opt == wxNO ) return; } else { if( !WriteDataFile() ) { wxString msg; msg.Printf( _("Unable to write file<%s>\n"\ "Do you want to exit and abandon your change?"), GetDataFilename().c_str() ); int opt = wxMessageBox( msg, _("Write Data File Errror"), wxYES_NO | wxICON_QUESTION ); if( opt == wxNO ) return; } } } Destroy(); }
void Pedigree::WriteDataFile(const char * output) { FILE * f = fopen(output, "wt"); if (f == NULL) error("Couldn't open data file %s", output); WriteDataFile(f); fclose(f); }
int main(void){ int i=0; person_t student[NUM_OF_PERSON]; printf("起動オプションを選択してください。\n1:ランダムデータファイルの生成\n2:データ読み込み・ソート\n3:ランダムデータ作成+ソート結果を表示(ファイル出力しない)\n"); scanf("%d",&i); if(i==1){ printf("作成したデータは同階層のdata.csvに保存されます。\n"); DataRandomize(student); if(WriteDataFile(student) == 0){ NumberAssign(student); ScoreAverage(student); printf("作成データ\n"); DataDisplay(student); } }else if(i==2){ if(ReadDataFile(student) == 0){ NumberAssign(student); ScoreAverage(student); printf("読込データ\n"); DataDisplay(student); DataBubbleSort(student); printf("ソート結果\n"); DataDisplay(student); printf("番号・平均を含んだソート結果をresult.csvに保存しますか?"); if(YesOrNo() == 1) WriteSortFile(student); } }else if(i==3){ NumberAssign(student); DataRandomize(student); ScoreAverage(student); printf("作成データ\n"); DataDisplay(student); DataBubbleSort(student); printf("ソート結果\n"); DataDisplay(student); }else{ printf("1、2、3のいずれかを入力してください。\n"); } return 0; }
int main (int argc, char *argv[]) { int n,i,found_sep; const char *frc_dir_name = NULL; const char *frc_file_name = NULL; pflag = 1; iflag = 0; forcefield = FF_TYPE_CLASS1 | FF_TYPE_COMMON; shift[0] = shift[1] = shift[2] = 0.0; frc_dir_name = getenv("MSI2LMP_LIBRARY"); if (argc < 2) { printf("usage: %s <rootname> [-class <I|1|II|2>] [-frc <path to frc file>] [-print #] [-ignore] [-nocenter] [-oldstyle]\n",argv[0]); return 1; } else { /* rootname was supplied as first argument, copy to rootname */ int len = strlen(argv[1]) + 1; rootname = (char *)malloc(len); strcpy(rootname,argv[1]); } n = 2; while (n < argc) { if (strncmp(argv[n],"-c",2) == 0) { n++; if (check_arg(argv,"-class",n,argc)) return 2; if ((strcmp(argv[n],"I") == 0) || (strcmp(argv[n],"1") == 0)) { forcefield = FF_TYPE_CLASS1 | FF_TYPE_COMMON; } else if ((strcmp(argv[n],"II") == 0) || (strcmp(argv[n],"2") == 0)) { forcefield = FF_TYPE_CLASS2 | FF_TYPE_COMMON; } else if ((strcmp(argv[n],"O") == 0) || (strcmp(argv[n],"0") == 0)) { forcefield = FF_TYPE_OPLSAA | FF_TYPE_COMMON; } else { printf("Unrecognized Forcefield class: %s\n",argv[n]); return 3; } } else if (strncmp(argv[n],"-f",2) == 0) { n++; if (check_arg(argv,"-frc",n,argc)) return 4; frc_file_name = argv[n]; } else if (strncmp(argv[n],"-s",2) == 0) { if (n+3 > argc) { printf("Missing argument(s) to \"-shift\" flag\n"); return 1; } shift[0] = atof(argv[++n]); shift[1] = atof(argv[++n]); shift[2] = atof(argv[++n]); } else if (strncmp(argv[n],"-i",2) == 0 ) { iflag = 1; } else if (strncmp(argv[n],"-n",4) == 0 ) { centerflag = 0; } else if (strncmp(argv[n],"-o",4) == 0 ) { hintflag = 0; } else if (strncmp(argv[n],"-p",2) == 0) { n++; if (check_arg(argv,"-print",n,argc)) return 5; pflag = atoi(argv[n]); } else { printf("Unrecognized option: %s\n",argv[n]); return 6; } n++; } /* set defaults, if nothing else was given */ if (frc_dir_name == NULL) #if (_WIN32) frc_dir_name = "..\\frc_files"; #else frc_dir_name = "../frc_files"; #endif if (frc_file_name == NULL) frc_file_name = "cvff.frc"; found_sep=0; #ifdef _WIN32 if (isalpha(frc_file_name[0]) && (frc_file_name[1] == ':')) found_sep=1; /* windows drive letter => full path. */ #endif n = strlen(frc_file_name); for (i=0; i < n; ++i) { #ifdef _WIN32 if ((frc_file_name[i] == '/') || (frc_file_name[i] == '\\')) found_sep=1+i; #else if (frc_file_name[i] == '/') found_sep=1+i; #endif } /* full pathname given */ if (found_sep) { i = 0; /* need to append extension? */ if ((n < 5) || (strcmp(frc_file_name+n-4,".frc") !=0)) i=1; FrcFileName = (char *)malloc(n+1+i*4); strcpy(FrcFileName,frc_file_name); if (i) strcat(FrcFileName,".frc"); } else { i = 0; /* need to append extension? */ if ((n < 5) || (strcmp(frc_file_name+n-4,".frc") !=0)) i=1; FrcFileName = (char *)malloc(n+2+i*4+strlen(frc_dir_name)); strcpy(FrcFileName,frc_dir_name); #ifdef _WIN32 strcat(FrcFileName,"\\"); #else strcat(FrcFileName,"/"); #endif strcat(FrcFileName,frc_file_name); if (i) strcat(FrcFileName,".frc"); } if (pflag > 0) { puts("\nRunning msi2lmp " MSI2LMP_VERSION "\n"); if (forcefield & FF_TYPE_CLASS1) puts(" Forcefield: Class I"); if (forcefield & FF_TYPE_CLASS2) puts(" Forcefield: Class II"); if (forcefield & FF_TYPE_OPLSAA) puts(" Forcefield: OPLS-AA"); printf(" Forcefield file name: %s\n",FrcFileName); if (centerflag) puts(" Output is recentered around geometrical center"); if (hintflag) puts(" Output contains style flag hints"); else puts(" Style flag hints disabled"); printf(" System translated by: %g %g %g\n",shift[0],shift[1],shift[2]); } n = 0; if (forcefield & FF_TYPE_CLASS1) { if (strstr(FrcFileName,"cvff") != NULL) ++n; if (strstr(FrcFileName,"clayff") != NULL) ++n; } else if (forcefield & FF_TYPE_OPLSAA) { if (strstr(FrcFileName,"oplsaa") != NULL) ++n; } else if (forcefield & FF_TYPE_CLASS2) { if (strstr(FrcFileName,"pcff") != NULL) ++n; if (strstr(FrcFileName,"cff91") != NULL) ++n; if (strstr(FrcFileName,"compass") != NULL) ++n; } if (n == 0) { if (iflag > 0) fputs(" WARNING",stderr); else fputs(" Error ",stderr); fputs("- forcefield name and class appear to be inconsistent\n\n",stderr); if (iflag == 0) return 7; } /* Read in .car file */ ReadCarFile(); /*Read in .mdf file */ ReadMdfFile(); /* Define bonds, angles, etc...*/ if (pflag > 0) printf("\n Building internal coordinate lists \n"); MakeLists(); /* Read .frc file into memory */ if (pflag > 0) printf("\n Reading forcefield file \n"); ReadFrcFile(); /* Get forcefield parameters */ if (pflag > 0) printf("\n Get force field parameters for this system\n"); GetParameters(); /* Do internal check of internal coordinate lists */ if (pflag > 0) printf("\n Check parameters for internal consistency\n"); CheckLists(); /* Write out the final data */ WriteDataFile(rootname); /* free up memory to detect possible memory corruption */ free(rootname); free(FrcFileName); ClearFrcData(); for (n=0; n < no_molecules; n++) { free(molecule[n].residue); } free(no_atoms); free(molecule); free(atoms); free(atomtypes); if (bonds) free(bonds); if (bondtypes) free(bondtypes); if (angles) free(angles); if (angletypes) free(angletypes); if (dihedrals) free(dihedrals); if (dihedraltypes) free(dihedraltypes); if (oops) free(oops); if (ooptypes) free(ooptypes); if (angleangles) free(angleangles); if (angleangletypes) free(angleangletypes); if (pflag > 0) printf("\nNormal program termination\n"); return 0; }
SlimServerInfo::~SlimServerInfo() { DEBUGF(""); WriteDataFile(); }