Paramotopy
parallel parameter homotopy through bertini
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
menu_cases.cpp
Go to the documentation of this file.
1 #include "menu_cases.hpp"
2 
3 
4 
6 //
7 //
8 // SERIAL CASE
9 //
10 //
12 
13 void serial_case(ProgSettings paramotopy_settings, runinfo paramotopy_info_original){
14 
15  std::cout << "the serial mode has been removed. \nif serial mode is something you really really need,\nplease contact the authors for support.\nwww.paramotopy.com\n";
16 
17  return;
18 }//re: serial_case()
19 
20 
21 
22 
23 
24 
25 
26 
27 
29 //
30 // PARALLEL STEP 2 CASE
31 //
32 // STANDARD
33 //
35 
36 void parallel_case(ProgSettings paramotopy_settings, runinfo paramotopy_info){
37 
38 
39 
40  std::stringstream mpicommand;
41 
42  mpicommand << paramotopy_settings.settings["parallelism"]["architecture"].value() << " -n ";
43  mpicommand << paramotopy_settings.settings["parallelism"]["numprocs"].value() << " ";
44  std::stringstream addmachinecommand;
45  addmachinecommand << "-machinefile " << paramotopy_settings.settings["parallelism"]["machinefile"].value() << " ";
46  mpicommand << (paramotopy_settings.settings["parallelism"]["usemachine"].intvalue==1 ? addmachinecommand.str() : "");
47 
48 
49  boost::filesystem::path steptwopath = paramotopy_settings.settings["system"]["step2location"].pathvalue;
50  steptwopath /= "step2";
51 
52  mpicommand << convert_spaces_to_escaped(steptwopath.string()) << " ";
53 
54  mpicommand << convert_spaces_to_escaped(paramotopy_info.inputfilename.string()) << " ";
55  mpicommand << convert_spaces_to_escaped(paramotopy_info.location.string()) << " ";
56  mpicommand << paramotopy_info.steptwomode << " ";
57 
58  if (paramotopy_settings.settings["system"]["stifle"].intvalue==1){
59  mpicommand << " > /dev/null ";
60  }
61 
62 
63  std::cout << "\n\n\n\n\n\n\n\n" << mpicommand.str() << "\n\n\n\n\n\n\n\n\n";
64 
65  system(mpicommand.str().c_str()); //make the system call to bertini
66 
67 }//re: parallel_case()
68 
69 
70 
71 
72 
73 
75 //
76 //
77 // MAIN STEP 2, CALLED FROM PARAMOTOPY
78 //
79 //
81 
82 
83 void steptwo_case(ProgSettings paramotopy_settings,
84  runinfo paramotopy_info){
85 
86 
87 
88  boost::filesystem::path settings_filename = paramotopy_info.location;
89  settings_filename /= "prefs.xml";
90  paramotopy_settings.save(settings_filename);
91 
92  //check if folder exists already. if it does, prompt user
93  boost::filesystem::path step2path = paramotopy_info.location;
94  step2path /= "step2"; //concatenation in boost
95 
96  if (boost::filesystem::exists(step2path)){ // if it can see the current run's step2 folder
97  if (get_int_choice("found previous step2 folder. remove, or bail out?\n0) bail out\n1) remove and continue\n: ",0,1)==1){
98  boost::filesystem::remove_all( step2path );
99 
100  step2path += "finished"; // remove the step2finished file if it exists.
101  if (boost::filesystem::exists(step2path)) {
102  boost::filesystem::remove( step2path );
103  }
104  }
105  else{
106  std::cout << "returning to paramotopy main menu without running step2" << std::endl;
107  return;
108  }
109  }
110 
111 
112  paramotopy_info.CopyUserDefinedFile();
113 
114 
115 
116  //write a file containing the random values.
117  boost::filesystem::path randpointfilename = paramotopy_info.location;
118  randpointfilename /= "randstart";
119  std::ofstream fout;
120  fout.open(randpointfilename.c_str());
121  fout.precision(16);
122  for (int ii = 0; ii < paramotopy_info.numparam; ++ii){
123  fout << paramotopy_info.RandomValues[ii].first << " "
124  << paramotopy_info.RandomValues[ii].second << "\n";
125 
126  }
127  fout.close();
128 
129 
130 
131 
132  //actually run the case
133 
134  if (paramotopy_settings.settings["parallelism"]["parallel"].intvalue == 0) {
135  serial_case(paramotopy_settings, paramotopy_info);
136  }// end not parallel
137 
138  else{//parallel case...
139  parallel_case(paramotopy_settings, paramotopy_info);
140  } // end parallel case
141 
142 
143 
144 }//re: step2case()
145 
146 
147 
148 
149 
int steptwomode
Definition: runinfo.hpp:95
std::vector< std::pair< double, double > > RandomValues
Definition: runinfo.hpp:130
std::string convert_spaces_to_escaped(std::string workwithme)
int numparam
Definition: runinfo.hpp:64
int get_int_choice(std::string display_string, int min_value, int max_value)
boost::filesystem::path inputfilename
Definition: runinfo.hpp:90
boost::filesystem::path location
Definition: runinfo.hpp:71
categorymap settings
A class that stores the general program settings of Paramotopy.
void CopyUserDefinedFile()
Definition: runinfo.cpp:579
A class for the input file parser.
Definition: runinfo.hpp:41