Validate* initValidate(SimFlat* sim) { sumAtoms(sim); Validate* val = comdMalloc(sizeof(Validate)); val->eTot0 = (sim->ePotential + sim->eKinetic) / sim->atoms->nGlobal; val->nAtoms0 = sim->atoms->nGlobal; if (printRank()) { fprintf(screenOut, "\n"); printSeparator(screenOut); fprintf(screenOut, "Initial energy : %14.12f, atom count : %d \n", val->eTot0, val->nAtoms0); fprintf(screenOut, "\n"); } return val; }
CoMD_return CoMD_lib(CoMD_input *inputStruct) { // Prolog //profileStart(totalTimer); //initSubsystems(); //Command cmd = parseCommandLine(argc, argv); Command cmd = parseInputStruct(inputStruct); //Ignore stressSuffix for now SimFlat* sim = initSimulation(cmd); Validate* validate = initValidate(sim); // atom counts, energy // This is the CoMD main loop const int nSteps = sim->nSteps; const int printRate = sim->printRate; double avgStress[9]; int stressi; int iStep; for(stressi=0;stressi<9;stressi++) avgStress[stressi]=0; for (iStep=0; iStep<nSteps;iStep++) { sumAtoms(sim); //Find and intercept these to write to the struct //printThings(sim, iStep, getElapsedTime(timestepTimer)); printTensor(iStep, sim->defInfo->stress); timestep(sim, 1, sim->dt); if(iStep>500){ for(stressi=0;stressi<9;stressi++) avgStress[stressi]+=sim->defInfo->stress[stressi]/(nSteps-500); } } sumAtoms(sim); //Find and intercept //printThings(sim, iStep, getElapsedTime(timestepTimer)); CoMD_return retVal = printStuff(iStep, sim, avgStress); // Epilog //validateResult(validate, sim); //profileStop(totalTimer); /* if (sim->pot->dfEmbed!=NULL) { free(sim->pot->dfEmbed); sim->pot->dfEmbed=NULL; } if (sim->pot->rhobar!=NULL) { free(sim->pot->rhobar); sim->pot->rhobar=NULL; } if (sim->pot->forceExchangeData!=NULL) { free(sim->pot->forceExchangeData); sim->pot->forceExchangeData=NULL; }*/ destroySimulation(&sim); comdFree(validate); //finalizeSubsystems();//??? //destroyParallel(); //??? return retVal; }
int main(int argc, char** argv) { // Prolog initParallel(&argc, &argv); profileStart(totalTimer); initSubsystems(); timestampBarrier("Starting Initialization\n"); yamlAppInfo(yamlFile); yamlAppInfo(screenOut); Command cmd = parseCommandLine(argc, argv); printCmdYaml(yamlFile, &cmd); printCmdYaml(screenOut, &cmd); SimFlat* sim = initSimulation(cmd); printSimulationDataYaml(yamlFile, sim); printSimulationDataYaml(screenOut, sim); Validate* validate = initValidate(sim); // atom counts, energy timestampBarrier("Initialization Finished\n"); timestampBarrier("Starting simulation\n"); // This is the CoMD main loop const int nSteps = sim->nSteps; const int printRate = sim->printRate; int iStep = 0; profileStart(loopTimer); for (; iStep<nSteps;) { startTimer(commReduceTimer); sumAtoms(sim); stopTimer(commReduceTimer); printThings(sim, iStep, getElapsedTime(timestepTimer)); startTimer(timestepTimer); timestep(sim, printRate, sim->dt); stopTimer(timestepTimer); iStep += printRate; } profileStop(loopTimer); sumAtoms(sim); printThings(sim, iStep, getElapsedTime(timestepTimer)); timestampBarrier("Ending simulation\n"); // Epilog validateResult(validate, sim); profileStop(totalTimer); printPerformanceResults(sim->atoms->nGlobal); printPerformanceResultsYaml(yamlFile); destroySimulation(&sim); comdFree(validate); finalizeSubsystems(); timestampBarrier("CoMD Ending\n"); destroyParallel(); return 0; }