⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmdssequence.cc

📁 XMDS is a code generator that integrates equations. You write them down in human readable form in a
💻 CC
📖 第 1 页 / 共 3 页
字号:
      }      printf("argvStruct()->shortOptionList = \n");      for (unsigned long int i=0; i<simulation()->argStruct()->shortOptionList.size(); i++) { 	printf("\t%s\n",ishortOptionList->c_str()); 	ishortOptionList++;      }      printf("argvStruct()->typeConversionList = \n");      for (unsigned long int i=0; i<simulation()->argStruct()->typeConversionList.size(); i++) {	printf("\t%s\n",itypeConversionList->c_str());	itypeConversionList++;      }    }    if(simulation()->parameters()->usempi) {      fprintf(outfile,"int main(int argc, char *argv[]) {\n");         }    else if (simulation()->argStruct()->nameList.size() != 0) {      fprintf(outfile,	      "int main(int argc, char **argv) {\n"	      "int resp;\n"	      "while (1) {\n"	      "\tstatic struct option long_options[] = \n"	      "\t\t{\n");      list<string>::const_iterator inameList = simulation()->argStruct()->nameList.begin();      //     list<string>::const_iterator itypeList = simulation()->argStruct()->typeList.begin();      //     list<string>::const_iterator idefaultValueList = simulation()->argStruct()->defaultValueList.begin();      list<string>::const_iterator ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      list<string>::const_iterator itypeConversionList = simulation()->argStruct()->typeConversionList.begin();      fprintf(outfile,"\t\t\t{\"help\", no_argument, 0, 'h'},\n");      for (unsigned long int i=0; i<simulation()->argStruct()->nameList.size(); i++) {	fprintf(outfile,"\t\t\t{\"%s\", required_argument, 0,'%s'},\n",inameList->c_str(),ishortOptionList->c_str());	inameList++;	ishortOptionList++;      }      fprintf(outfile,	      "\t\t\t{0, 0, 0, 0}\n"	      "\t\t};\n"	      "\tint option_index = 0;\n"	      "\tresp = getopt_xmds_long(argc, argv, \"");      ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      for (unsigned long int i=0; i<simulation()->argStruct()->shortOptionList.size(); i++) {	fprintf(outfile,"%s:",ishortOptionList->c_str());	ishortOptionList++;      }      fprintf(outfile,	      "\", long_options, &option_index);\n"	      "\tif (resp == -1) {\n"	      "\t\tbreak;\n"	      "\t}\n"	      "\tswitch (resp) {\n"	      "\t\tcase 'h':\n"	      "\t\t\tprintf(\"Usage: %s",	      simulation()->parameters()->simulationName.c_str());      ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      list<string>::const_iterator itypeList = simulation()->argStruct()->typeList.begin();      for (unsigned long int i=0; i<simulation()->argStruct()->nameList.size(); i++) {	fprintf(outfile," -%s < %s>",ishortOptionList->c_str(),itypeList->c_str());	ishortOptionList++;	itypeList++;      }      fprintf(outfile,	      "\\n\\n\");\n"	      "\t\t\tprintf(\"Details:\\n\");\n"	      "\t\t\tprintf(\"Option\\t\\tType\\t\\tDefault value\\n\");\n");      inameList = simulation()->argStruct()->nameList.begin();      ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      itypeList = simulation()->argStruct()->typeList.begin();      list<string>::const_iterator idefaultValueList = simulation()->argStruct()->defaultValueList.begin();      for (unsigned long int i=0; i<simulation()->argStruct()->nameList.size(); i++) {	fprintf(outfile,"\t\t\tprintf(\"-%s, --%s\\t%s\\t\\t%s\\n\");\n",ishortOptionList->c_str(),inameList->c_str(),itypeList->c_str(),idefaultValueList->c_str());	inameList++;	ishortOptionList++;	itypeList++;	idefaultValueList++;      }      fprintf(outfile,"\t\t\texit(0);\n");      inameList = simulation()->argStruct()->nameList.begin();      ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      itypeConversionList = simulation()->argStruct()->typeConversionList.begin();      for (unsigned long int i=0; i<simulation()->argStruct()->nameList.size(); i++) {	fprintf(outfile,"\t\tcase '%s':\n",ishortOptionList->c_str());	if (*itypeConversionList == "atof") {	  fprintf(outfile,"\t\t\t%s = atof(optarg);\n",inameList->c_str());	  fprintf(outfile,"\t\t\tbreak;\n");	}	else if (*itypeConversionList == "atoi") {	  fprintf(outfile,"\t\t\t%s = atoi(optarg);\n",inameList->c_str());	  fprintf(outfile,"\t\t\tbreak;\n");	}	else if (*itypeConversionList == "") {	  fprintf(outfile,"\t\t\t%s = optarg;\n",inameList->c_str());	  fprintf(outfile,"\t\t\tbreak;\n");	}	inameList++;	ishortOptionList++;	itypeConversionList++;      }      fprintf(outfile,	      "\t\tdefault:\n"	      "\t\t\texit(10);\n"	      "\t\t}\n"	      "\t}\n"	      "\tif (optind_xmds < argc) {\n"	      "\t\tprintf(\"Sorry, I didn't understand some (or all) of your arguments\\n\");\n"	      "\t\t\tprintf(\"Usage: %s",simulation()->parameters()->simulationName.c_str());      ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      itypeList = simulation()->argStruct()->typeList.begin();      for (unsigned long int i=0; i<simulation()->argStruct()->nameList.size(); i++) {	fprintf(outfile," -%s < %s>",ishortOptionList->c_str(),itypeList->c_str());	ishortOptionList++;	itypeList++;      }      fprintf(outfile,"\\n\\n\");\n"	      "\t\t\tprintf(\"Details:\\n\");\n"	      "\t\t\tprintf(\"Option\\t\\tType\\t\\tDefault value\\n\");\n");      inameList = simulation()->argStruct()->nameList.begin();      ishortOptionList = simulation()->argStruct()->shortOptionList.begin();      itypeList = simulation()->argStruct()->typeList.begin();      idefaultValueList = simulation()->argStruct()->defaultValueList.begin();      for (unsigned long int i=0; i<simulation()->argStruct()->nameList.size(); i++) {	fprintf(outfile,"\t\t\tprintf(\"-%s, --%s\\t%s\\t\\t%s\\n\");\n",ishortOptionList->c_str(),inameList->c_str(),itypeList->c_str(),idefaultValueList->c_str());	inameList++;	ishortOptionList++;	itypeList++;	idefaultValueList++;      }      fprintf(outfile,	      "\t\t\texit(0);\n"	      "\t}\n\n");    }          else {      fprintf(outfile,"int main() {\n");    }        fprintf(outfile,"\n");    if (simulation()->parameters()->binaryOutput) {      fprintf(outfile,	      "#ifndef CPU_IS_BIG_ENDIAN\n"	      "   #ifndef CPU_IS_LITTLE_ENDIAN\n"	      "   cout << \"Byte ordering isn't defined for this system!\\n\";\n"	      "   cout << \"Please define CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in config.h\\n\";\n"	      "   exit(255);\n"	      "   #endif\n"	      "#endif\n");    }    if(simulation()->parameters()->usempi) {      fprintf(outfile,	      "MPI_Init(&argc, &argv);\n"	      "MPI_Comm_size(MPI_COMM_WORLD, &size);\n"	      "MPI_Comm_rank(MPI_COMM_WORLD, &rank);\n"	      "\n");    }    // if(simulation()->field()->needsFFTWPlans()) {    //  It's possible to need FFTW plans in output but not the main field through post-propagation    fprintf(outfile,"/* set up fftw plans */\n");    if(simulation()->parameters()->nThreads>1) {      fprintf(outfile,"int fftw_threads_init(void);\n");        }    fprintf(outfile,"int _fftw_lattice[64];\n");    fprintf(outfile,"\n");    simulation()->field()->writePlanCreationCalls(outfile,1,simulation()->parameters()->useWisdom);    simulation()->output()->writePlanCreationCalls(outfile,0,simulation()->parameters()->useWisdom);    //	}    if(simulation()->parameters()->benchmark) {      fprintf(outfile,"clock_t startTime = clock();\n");    }    if((simulation()->parameters()->usempi)&!(simulation()->parameters()->stochastic)) {      fprintf(outfile,"fftwnd_mpi_local_sizes(_main_forward_plan, &local_nx, &local_x_start, &local_ny_after_transpose, &local_y_start_after_transpose, &total_local_size);\n\n");      list<XMLString> vectorNamesList;      const xmdsVector* tempVector;      const char *typeName;      simulation()->field()->vectorNames(vectorNamesList);      for(list<XMLString>::const_iterator pXMLString = vectorNamesList.begin(); pXMLString != vectorNamesList.end(); pXMLString++) {	if(!simulation()->field()->getVector(*pXMLString,tempVector))  {	  throw xmdsException("Lost one of the vectors in xmdssequence::writeRoutines.  Bad!  Bad dog!\n\n");	}	if(tempVector->vectorType()==DOUBLE) {	  typeName="double";	}	else {	  typeName="complex";	}	fprintf(outfile,"_%s_%s = new %s[total_local_size*_%s_%s_ncomponents];\n",		simulation()->field()->name()->c_str(),tempVector->name()->c_str(),typeName,		simulation()->field()->name()->c_str(),tempVector->name()->c_str());	fprintf(outfile,"_%s_%s_work = new %s[total_local_size*_%s_%s_ncomponents];\n",		simulation()->field()->name()->c_str(),tempVector->name()->c_str(),typeName,		simulation()->field()->name()->c_str(),tempVector->name()->c_str());      }      fprintf(outfile,"\n");      for(unsigned long i=0; i<simulation()->output()->nMomentGroups(); i++) {	  if(!simulation()->output()->momentGroup(i)->needscomplexRawVector()) {	    typeName="double";	  }	  else {	    typeName="complex";	  }	  fprintf(outfile,"_mg%li_raw = new %s[_mg%li_size*_mg%li_raw_ncomponents];\n",i,typeName,i,i);	  fprintf(outfile,"_mg%li_fullstep = new double[_mg%li_size*_mg%li_fullstep_ncomponents];\n",i,i,i);	  if(simulation()->parameters()->errorCheck) {	    fprintf(outfile,"_mg%li_halfstep = new double[_mg%li_size*_mg%li_halfstep_ncomponents];\n",i,i,i);	  }	}      fprintf(outfile,"\n");    }    simulation()->field()->assignActiveVectorPointers(outfile,"");    simulation()->output()->assignActiveVectorPointers(outfile,"");    if(simulation()->parameters()->stochastic) {      for(unsigned long i=0;i<simulation()->output()->nMomentGroups();i++) {	fprintf(outfile,"_mg%li_fullstep_initialise();\n",i);	fprintf(outfile,"_mg%li_fullstep_sd_initialise();\n",i);	if(simulation()->parameters()->errorCheck) {	  fprintf(outfile,"_mg%li_halfstep_initialise();\n",i);	  fprintf(outfile,"_mg%li_halfstep_sd_initialise();\n",i);	}	fprintf(outfile,"\n");      }    }    if(simulation()->parameters()->errorCheck) {      if(simulation()->parameters()->nPaths>1) {	if(simulation()->parameters()->usempi) {	  fprintf(outfile,"printf(\"Rank[%%i] beginning full step paths\\n\",rank);\n");	}	else {	  fprintf(outfile,"printf(\"Beginning full step paths\\n\");\n");	}      }      else {	if(simulation()->parameters()->usempi&!simulation()->parameters()->stochastic) {	  fprintf(outfile,"printf(\"Rank[%%i] beginning full step integration ...\\n\",rank);\n");	}	else {	  fprintf(outfile,"printf(\"Beginning full step integration ...\\n\");\n");	}      }      fprintf(outfile,"\n");      fprintf(outfile,"_half_step=0;\n");      fprintf(outfile,"\n");    }    else {      if(simulation()->parameters()->nPaths>1) {	if(simulation()->parameters()->usempi) {	  fprintf(outfile,"printf(\"Rank[%%i] beginning paths\\n\",rank);\n");	}	else {	  fprintf(outfile,"printf(\"Beginning paths\\n\");\n");	}      }      else {	if(simulation()->parameters()->usempi&!simulation()->parameters()->stochastic) {	  fprintf(outfile,"printf(\"Rank[%%i] beginning integration ...\\n\",rank);\n");	}	else {	  fprintf(outfile,"printf(\"Beginning integration ...\\n\");\n");	}      }      fprintf(outfile,"\n");    }    if(simulation()->parameters()->usempi) {      fprintf(outfile,"_segment0(size);\n");    }    else {      fprintf(outfile,"_segment0();\n");    }    fprintf(outfile,"\n");	    if(simulation()->parameters()->errorCheck) {      if(simulation()->parameters()->nPaths>1) {	if(simulation()->parameters()->usempi) {	  fprintf(outfile,"printf(\"Rank[%%i] beginning half step paths\\n\",rank);\n");	}	else {	  fprintf(outfile,"printf(\"Beginning half step paths\\n\");\n");	}      }      else {	if(simulation()->parameters()->usempi&!simulation()->parameters()->stochastic) {	  fprintf(outfile,"printf(\"Rank[%%i] beginning half step integration ...\\n\",rank);\n");	}	else {	  fprintf(outfile,"printf(\"Beginning half step integration ...\\n\");\n");	}      }      fprintf(outfile,"\n");      fprintf(outfile,"_half_step=1;\n");      fprintf(outfile,"\n");      if(simulation()->parameters()->usempi) {	fprintf(outfile,"_segment0(size);\n");      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -