int main(int argc, char *argv[]) { char outFileName[64],datFileName[64],moldyName[128]; char *str; // atom *atomPtr; int g,nstart,j,ak,count; FILE *fp; double charge; int moldyFlag = 0; // suppress creation of ..._moldy.in file int distPlotFlag = 0; // suppress creation of disList.dat /* Let's set the radii of certain elements by hand: */ // atRad = (double *)realloc(atRadf, 109*sizeof(double)); // covRad = (double *)realloc(covRadf,109*sizeof(double)); atRad = (double *)malloc(109*sizeof(double)); covRad = (double *)malloc(109*sizeof(double)); memcpy(atRad, atRadf,36*sizeof(double)); memcpy(covRad,covRadf,36*sizeof(double)); atRad[39-1]=2.27; covRad[39-1]=2.62; // Y atRad[57-1]=2.74; covRad[57-1]=1.69; // La atRad[71-1]=2.25; covRad[71-1]=1.56; // Lu if (argc < 2) sprintf(datFileName,"gb.gbm"); else strcpy(datFileName,argv[1]); // read a flag: if (argc > 2) { if (strncmp(argv[2],"-m",2) == 0) { moldyFlag = 1; // also write a moldy file! printf("Saving moldy input file!\n"); } } muls->nCellX = 1; muls->nCellY = 1; muls->nCellZ = 1; muls->ctiltx = 0; muls->ctilty = 0; muls->ctiltz = 0; superCell.atoms = NULL; superCell.natoms = 0; if (!readParams(datFileName)) exit(0); if (nGrains > 0) { // loop, until we find crystalline grains: for (g=0; g<nGrains; g++) if (grains[g].amorphFlag == CRYSTALLINE) break; /* make the crystalline part of the super cell */ if (g<nGrains) makeSuperCell(); /* if there is also an amorphous part, then add it now, and also write a * MD input file, so that the amorphous phase atoms can be relaxed */ for (g=0; g<nGrains; g++) if (grains[g].amorphFlag != CRYSTALLINE) break; if (g<nGrains) { if (moldyFlag) { sprintf(moldyName,"%s",datFileName); moldyName[strlen(datFileName)-4] = '\0'; strcat(moldyName,"_moldy.in"); if ((fp=fopen(moldyName,"w")) == NULL) { printf("Could not open moldy input file %s!\n",moldyName); exit(0); } } else { fp = NULL; } if (nGrains > 1) { writeFrameWork(fp,superCell); computeCenterofMass(); nstart = superCell.natoms; switch (grains[g].amorphFlag) { case 1: makeAmorphous(); break; case 2: makeSpecial(distPlotFlag); break; } writeAmorphous(fp,superCell,nstart,superCell.natoms); } else { switch (grains[g].amorphFlag) { case 1: makeAmorphous(); break; case 2: makeSpecial(distPlotFlag); break; } writeAmorphous(fp,superCell,0,superCell.natoms); } if (moldyFlag) fclose(fp); } } if (0) { // (moldyFlag) { /////////////////////////////////////////////////////////////// // write Moldy input file, without presence of amorphous phase: sprintf(moldyName,"%s",datFileName); moldyName[strlen(datFileName)-4] = '\0'; strcat(moldyName,"_moldy.in"); if ((fp=fopen(moldyName,"w")) == NULL) { printf("Could not open moldy input file %s!\n",moldyName); exit(0); } // writeFrameWork(fp,superCell); // computeCenterofMass(); // superCell2Moldy(fp,superCell); fclose(fp); } // end of: if moldyFlag ... strcpy(outFileName,datFileName); // atomPtr = readUnitCell(&natoms,fileName,&muls); // writePDB(atomPtr,nat /* reset the input file and advance to the next crystal row */ str = strchr(outFileName,'.'); if (str == NULL) str=outFileName+strlen(outFileName); sprintf(str,".cfg"); muls->ax = (float)superCell.ax; muls->by = (float)superCell.by; muls->c = (float)superCell.cz; superCell.natoms = removeVacancies(superCell.atoms,superCell.natoms); printf("will write cfg file to %s\n",outFileName); writeCFG(superCell.atoms, superCell.natoms, outFileName, muls); printf("wrote cfg file to %s\n",outFileName); /************************************************************** * find the charge for the Y-atoms, in order to remain neutral: */ charge = 0.0; if (0) { for (ak=0;ak<muls->atomKinds;ak++) { count =0; for (j=0;j<superCell.natoms;j++) { if (muls->Znums[ak] == superCell.atoms[j].Znum) count++; } printf("Z=%3d: %d\n",muls->Znums[ak],count); switch (muls->Znums[ak]) { case 7: charge += count*(-3.0); break; case 8: charge += count*(-2.0); break; case 38: charge += count*(2.0); break; case 22: charge += count*(4.0); break; case 14: charge += count* 4.0; break; } } } else { for (j=0;j<superCell.natoms;j++) { charge += superCell.atoms[j].q*superCell.atoms[j].occ; } } // printf("Total charge: %g, i.e. %g %s\n",charge,charge,(charge > 0) ? "holes" : "electrons"); printf("Total charge: %g",charge); if (charge > 0) printf(", i.e. %g holes\n",charge); if (charge < 0) printf(", i.e. %g electrons\n",-charge); delete(muls); return 0; }
void write_htmlFnctPages::writePage(void) { // most of the informations can be write only if the function has a body ! dataDrawerListIterator p; // browse the list string fnctName; // name of the function // Browse list one function for time p = dataBL->begin(); while (p != dataBL->end()) { dataB = *p; p++; fData = dataB->getFnctData(); cout << "Generating html page for function " << (fnctName = fData->getName()) << "...\n"; htmlpage.open((HTMLfilesRegister::htmlFile(*fData)).c_str()); // begin of the page pageTitle = fnctName ; writeHead(); writeIndex(); htmlpage << "<br><br>\n"; if (fnctName != "") htmlpage << "This is the page of the function " << fnctName << ".<br><br>\n"; htmlpage << *fData << "<br><l><br>\n\n"; if (fData->hasBody()) { writePageIndex(); // write body graph if (!noBodyGraph) { htmlpage << "<A name=\"bodyGraph\">\n"; writeSectionTitle("Graph of the body"); writeBodyGraph(); } // write CFG if (!noCFG) { htmlpage << "<A name=\"CFG\">\n"; writeSectionTitle("Control flow graph"); writeCFG(); } // write stmt stat if (!noStmtStat) { htmlpage << "<A name=\"stmtStatistics\">\n"; writeSectionTitle("Statements statistics"); htmlpage << *(dataB->getStmtNumData()); } // write decl list if ( (!noDeclsList) && (dataB->hasDeclsList()) ) { htmlpage << "<A name=\"declsList\">\n"; writeSectionTitle("Declarations into the function"); htmlpage << *(dataB->getDeclsList()); } // write var used if ( (!noVarUsed) && (dataB->hasVarUsedList()) ) { htmlpage << "<A name=\"varUsedList\">\n"; writeSectionTitle("Variables used by the function"); htmlpage << *(dataB->getVarUsedList()); } // write exprs list if ( (!noExprsList) && (dataB->hasExprsList()) ) { htmlpage << "<A name=\"exprsList\">\n"; writeSectionTitle("List of the expressions"); htmlpage << *(dataB->getExprsList()); } // write expr stat if (!noExprStat) { htmlpage << "<A name=\"exprStatistics\">\n"; writeSectionTitle("Expression statistics"); htmlpage << *(dataB->getExprNumData()); } // write call graph if (!noCallGraph) { htmlpage << "<A name=\"callGraph\">\n"; writeSectionTitle("Call graph"); writeCallGraph(); } } // end of the page writeIndex(); writeFoot(); htmlpage.close(); } return; }