int main(int argc, const char* argv[]) { NBodyFlags nbf = EMPTY_NBODY_FLAGS; int rc = 0; specialSetup(); if (readParameters(argc, argv, &nbf)) exit(EXIT_FAILURE); free(argvCopy); if (nbodyInit(&nbf)) { exit(EXIT_FAILURE); } nbodyPrintVersion(); setDefaultFlags(&nbf); setNumThreads(nbf.numThreads); if (nbf.verifyOnly) { rc = verifyFile(&nbf); } else { rc = runNBodySimulation(&nbf); if (nbf.cleanCheckpoint) { mw_report("Removing checkpoint file '%s'\n", nbf.checkpointFileName); mw_remove(nbf.checkpointFileName); } } freeNBodyFlags(&nbf); mw_finish(rc); return rc; }
int main(int argc, const char* argv[]) { NBodyFlags nbf; int rc = 0; const char** argvCopy = mwFixArgv(argc, argv); nbSpecialSetup(); if (nbReadParameters(argc, argvCopy ? argvCopy : argv, &nbf)) { if (BOINC_APPLICATION) { mwBoincInit(MW_PLAIN); nbReadParameters(argc, argvCopy ? argvCopy : argv, &nbf); nbPrintVersion(TRUE, FALSE); } mw_finish(EXIT_FAILURE); } if (nbInit(&nbf)) { exit(EXIT_FAILURE); } if (BOINC_APPLICATION && mwIsFirstRun()) { nbPrintVersion(TRUE, FALSE); } nbSetDefaultFlags(&nbf); if (nbSetNumThreads(nbf.numThreads)) { mw_finish(EXIT_FAILURE); } if (nbf.verifyOnly) { rc = nbVerifyFile(&nbf); } else if (nbf.matchHistogram) { double emd; emd = nbMatchHistogramFiles(nbf.histogramFileName, nbf.matchHistogram); mw_printf("%.15f\n", emd); rc = isnan(emd); } else { rc = nbMain(&nbf); rc = nbStatusToRC(rc); if (!nbf.noCleanCheckpoint) { mw_report("Removing checkpoint file '%s'\n", nbf.checkpointFileName); mw_remove(nbf.checkpointFileName); } } fflush(stderr); fflush(stdout); /* Odd things happen with the OpenCL one where stdout starts disappearing */ freeNBodyFlags(&nbf); if (BOINC_APPLICATION) { mw_finish(rc); } return rc; }