00001 00006 #include <string.h> 00007 #include <cstdlib> 00008 #include <iostream> 00009 using namespace std; 00010 #include <libxml/xmlmemory.h> 00011 #include <libxml/parser.h> 00012 #include <math.h> 00013 #include "def.h" 00014 #include "io.h" 00015 #include "run.h" 00016 #include "list.h" 00017 #include "collection.h" 00018 #include "model.h" 00019 #include "species.h" 00020 using namespace Species; 00021 #include "domain.h" 00022 00023 void usage() { 00024 cout <<"Usage:\n\tFirst run:\n"<<Run::programname<<"\nSubsequent runs:\n"<<Run::programname<<" restart_file\n"; 00025 } 00030 void parsename(char *name, char *filename) { 00031 char *period=strchr(filename, '.'); 00032 int len=period==NULL?strlen(filename):period-filename; 00033 strncpy(name, filename, len); 00034 name[len]='\0'; 00035 } 00041 int main(int argc, char *argv[]) { 00042 00043 Run::init(argc,argv); 00044 Domain domain(Run::inputfile); 00045 if(Run::option.xterm)printf("%c[2J",ESC); 00046 int niter=IO::getIter(Run::configfile); 00047 if(niter<=0) { 00048 cout<<"Number of iterations "<<niter<<" should be > 0\nAborting\n"; 00049 exit(0); 00050 } 00051 domain.run(IO::getIter(Run::configfile)); 00052 char taskname[WORDLENGTH]; 00053 if(Run::option.restart) parsename(taskname, Run::inputfile); 00054 else parsename(taskname, Run::programname); 00055 domain.save(taskname); 00056 cout<<"RUN FINISHED\n";cout.flush(); 00057 return 0; 00058 }