Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rocstar_driver.C File Reference
#include <fstream>
#include <limits>
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "rocman.h"
#include "builtin_couplings.h"
#include "derived_couplings.h"
Include dependency graph for rocstar_driver.C:

Go to the source code of this file.

Macros

#define COM_DOUBLE_ATTRIBUTE(attrname, varname)
 
#define COM_INT_ATTRIBUTE(attrname, varname)
 
#define COM_STRING_ATTRIBUTE(attrname, varname)
 
#define COM_BOOL_ATTRIBUTE(attrname, varname)
 

Functions

 COM_EXTERN_MODULE (Rocin)
 
 COM_EXTERN_MODULE (Rocout)
 
void init_profiling (Control_parameters &param, int comm_rank)
 
void RocstarShutdown (int=0)
 
double get_restart_time (const string &restart_file)
 
Couplingcreate_coupling (Control_parameters &param, const RocmanControl_parameters &rocman_param)
 
bool reached_simulation_time (const Control_parameters &param)
 
bool reached_restartdump_time (Control_parameters &param)
 
bool reached_visdump_time (const Control_parameters &param)
 
int check_for_interrupt (Coupling *coup, const Control_parameters &param)
 
void rocstar_driver (int verb, int remeshed, bool debug)
 
void debug_print (const std::string str, int pane, int pe, MPI_Comm comm, const char *memo)
 
void debug_int_print (const std::string str, int pane, int pe, MPI_Comm comm, const char *memo)
 

Variables

int man_verbose = 1
 

Detailed Description

Definition in file rocstar_driver.C.

Macro Definition Documentation

#define COM_BOOL_ATTRIBUTE (   attrname,
  varname 
)
Value:
attr = winname+"."+attrname; \
COM_new_attribute( attr.c_str(),'w',COM_BOOL,1,""); \
COM_set_size( attr.c_str(),0,1); \
COM_set_array( attr.c_str(),0,&varname);
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118

Definition at line 159 of file rocstar_driver.C.

Referenced by Control_parameters::read(), and RocmanControl_parameters::read().

#define COM_DOUBLE_ATTRIBUTE (   attrname,
  varname 
)
Value:
attr = winname+"."+attrname; \
COM_new_attribute( attr.c_str(),'w',COM_DOUBLE,1,""); \
COM_set_size( attr.c_str(),0,1); \
COM_set_array( attr.c_str(),0, &varname);
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118

Definition at line 141 of file rocstar_driver.C.

Referenced by Control_parameters::read(), and RocmanControl_parameters::read().

#define COM_INT_ATTRIBUTE (   attrname,
  varname 
)
Value:
attr = winname+"."+attrname; \
COM_new_attribute( attr.c_str(),'w',COM_INT,1,""); \
COM_set_size( attr.c_str(),0,1); \
COM_set_array( attr.c_str(),0, &varname);
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118

Definition at line 147 of file rocstar_driver.C.

Referenced by Control_parameters::read(), and RocmanControl_parameters::read().

#define COM_STRING_ATTRIBUTE (   attrname,
  varname 
)
Value:
attr = winname+"."+attrname; \
COM_new_attribute( attr.c_str(),'w',COM_CHAR,1,""); \
COM_set_size( attr.c_str(),0,MAXLEN); \
COM_set_array( attr.c_str(),0,varname,MAXLEN);
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
#define MAXLEN
Definition: Coupling.h:41
C/C++ Data types.
Definition: roccom_basic.h:129
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118

Definition at line 153 of file rocstar_driver.C.

Referenced by Control_parameters::read().

Function Documentation

int check_for_interrupt ( Coupling coup,
const Control_parameters param 
)

Definition at line 534 of file rocstar_driver.C.

References Control_parameters::communicator, Coupling::Interrupt(), and Control_parameters::myRank.

Referenced by rocstar_driver().

535 {
536  int interrupt_code = 0;
537  std::string message("Interrupted by file");
538  // std::string therest;
539  if(param.myRank == 0) {
540  std::ifstream InterruptFile;
541  InterruptFile.open("RocstarInterrupt.txt");
542  if(InterruptFile){
543  std::cout << "Rocstar: Processing interrupt from file." << std::endl;
544  InterruptFile >> interrupt_code;
545  std::getline(InterruptFile,message);
546  InterruptFile.close();
547  unlink("RocstarInterrupt.txt");
548  std::ofstream InterruptOut;
549  InterruptOut.open("RocstarInterrupt.txt.processed");
550  InterruptOut << interrupt_code << " " << message << std::endl;
551  InterruptOut.close();
552  }
553  }
554  MPI_Bcast(&interrupt_code,1,MPI_INTEGER,0,param.communicator);
555  if(interrupt_code > 0){
556  coup->Interrupt(&interrupt_code,message.c_str());
557  return(interrupt_code);
558  }
559  return(0);
560 }
MPI_Comm communicator
Definition: Coupling.h:51
void Interrupt(int *, const char *)
Definition: Coupling.C:480

Here is the call graph for this function:

Here is the caller graph for this function:

COM_EXTERN_MODULE ( Rocin  )
COM_EXTERN_MODULE ( Rocout  )
Coupling* create_coupling ( Control_parameters param,
const RocmanControl_parameters rocman_param 
)

Definition at line 95 of file rocstar_driver.C.

References Control_parameters::burn_module, COM_assertion_msg, COM_LOAD_MODULE_STATIC_DYNAMIC, Control_parameters::communicator, Control_parameters::coupling_scheme, Control_parameters::fluid_module, and Control_parameters::solid_module.

Referenced by rocstar_driver().

95  {
96  const std::string &name = param.coupling_scheme;
97 
98  if ( name == "FluidAlone")
99  return new FluidAlone( param.fluid_module, param.communicator, &param, &rocman_param);
100  else if ( name == "FluidBurnAlone")
101  return new FluidBurnAlone( param.fluid_module, param.burn_module, param.communicator, &param, &rocman_param);
102  else if ( name == "SolidAlone")
103  return new SolidAlone( param.solid_module, param.communicator, &param, &rocman_param);
104  else if ( name == "SolidBurn")
105  return new SolidBurn( param.solid_module, param.burn_module, param.communicator, &param, &rocman_param);
106  else if ( name == "SolidFluidSPC")
107  return new SolidFluidSPC( param.fluid_module, param.solid_module, param.communicator, &param, &rocman_param);
108  else if ( name == "FluidSolidISS")
109  return new FluidSolidISS( param.fluid_module, param.solid_module, param.communicator, &param, &rocman_param);
110  else if ( name == "SolidFluidBurnSPC")
111  return new SolidFluidBurnSPC( param.fluid_module, param.solid_module, param.burn_module, param.communicator, &param, &rocman_param);
112  else if ( name == "SolidFluidBurnEnergySPC")
113  return new SolidFluidBurnEnergySPC( param.fluid_module, param.solid_module, param.burn_module, param.communicator, &param, &rocman_param);
114  else if ( name == "Test" || name.empty()){
117  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocface,"FACETEST");
118  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocon,"PROPCONTEST");
120  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocflu,"FLUTEST");
121  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocflo,"FLOTEST");
123  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocfrac,"FRACTEST");
124  }
125  else {
126  std::cerr << "Rocstar: ERROR: Unknown coupling scheme: " << name << std::endl;
127  std::cerr << std::endl;
128  std::cerr << "Rocstar: Rocstar Supported coupling schemes: " << std::endl;
129  std::cerr << "Rocstar: FluidAlone: Fluid alone with no burn" << std::endl;
130  std::cerr << "Rocstar: FluidBurnAlone: Fluid alone with burn" << std::endl;
131  std::cerr << "Rocstar: SolidAlone: Solid alone with no burn" << std::endl;
132  std::cerr << "Rocstar: SolidFluidBurnSPC: FullyCoupled simple staggered scheme with P-C" << std::endl;
133  std::cerr << "Rocstar: SolidFluidSPC: FullyCoupled no burn" << std::endl;
134  std::cerr << "Rocstar: FluidSolidISS: FullyCoupled no burn with improved staggered scheme" << std::endl;
135  std::cerr << "Rocstar: SolidFluidBurnEnergySPC: FullyCoupled with burn energy" << std::endl;
136  COM_assertion_msg(0, "ERROR: Unknown coupling scheme!");
137  }
138  return NULL;
139 }
char burn_module[MAXLEN]
Definition: Coupling.h:48
#define COM_assertion_msg(EX, msg)
A Roccom mesh optimization module.
Definition: Rocmop.h:41
char coupling_scheme[MAXLEN]
Definition: Coupling.h:45
MPI_Comm communicator
Definition: Coupling.h:51
Definition: Rocin.h:64
Definition: Rocout.h:81
Definition: Rocon.H:61
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
char fluid_module[MAXLEN]
Definition: Coupling.h:46
char solid_module[MAXLEN]
Definition: Coupling.h:47

Here is the caller graph for this function:

void debug_int_print ( const std::string  str,
int  pane,
int  pe,
MPI_Comm  comm,
const char *  memo 
)

Definition at line 918 of file rocstar_driver.C.

References COM_get_array(), COMMPI_Comm_rank(), and i.

919 {
920  int comm_rank = COMMPI_Comm_rank(comm);
921  if (comm_rank == pe) {
922  int *vm;
923  int strid, cap;
924  printf("%s %s: before %p\n", str.c_str(), memo?memo:"", vm);
925  COM_get_array(str.c_str(), pane, &vm, &strid, &cap);
926  printf("%s %s: after %p \n", str.c_str(), memo?memo:"", vm);
927  for (int i=0; i<strid*cap; i++) printf("%d ", vm[i]);
928  printf("\n");
929  }
930 }
int COMMPI_Comm_rank(MPI_Comm c)
Definition: commpi.h:162
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

void debug_print ( const std::string  str,
int  pane,
int  pe,
MPI_Comm  comm,
const char *  memo 
)

Definition at line 904 of file rocstar_driver.C.

References COM_get_array(), COMMPI_Comm_rank(), and i.

905 {
906  int comm_rank = COMMPI_Comm_rank(comm);
907  if (comm_rank == pe) {
908  double *vm;
909  int strid, cap;
910  printf("%s %s: before %p\n", str.c_str(), memo?memo:"", vm);
911  COM_get_array(str.c_str(), pane, &vm, &strid, &cap);
912  printf("%s %s: after %p \n", str.c_str(), memo?memo:"", vm);
913  for (int i=0; i<strid*cap; i++) printf("%.17e ", vm[i]);
914  printf("\n");
915  }
916 }
int COMMPI_Comm_rank(MPI_Comm c)
Definition: commpi.h:162
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

double get_restart_time ( const string &  restart_file)

Definition at line 72 of file rocstar_driver.C.

References cimg_library::cimg::fclose(), and cimg_library::cimg::fopen().

Referenced by Control_parameters::read().

73 {
74  int curStep = 0;
75  double curTime = 0.0;
76 #if 0
77  std::ifstream Inf;
78  Inf.open(restart_file.c_str());
79  if(!Inf)
80  return(0.0);
81  while(Inf)
82  Inf >> curStep >> curTime;
83  Inf.close();
84 #else
85  FILE *fp = fopen(restart_file.c_str(), "r");
86  if (fp == NULL) return 0.0;
87  while (!feof(fp)) {
88  fscanf(fp, "%d %le", &curStep, &curTime);
89  }
90  fclose(fp);
91 #endif
92  return(curTime);
93 }
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

void init_profiling ( Control_parameters param,
int  comm_rank 
)

Definition at line 835 of file rocstar_driver.C.

References COMMPI_Comm_size(), Control_parameters::communicator, Control_parameters::controlVerb, Control_parameters::current_time, d, cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), i, MPI_COMM_WORLD, Control_parameters::timingDataDir, and Control_parameters::timingDataFile.

Referenced by Control_parameters::read().

836 {
837  std::string fname = "RocstarProfile";
838  int data = comm_rank;
839  int u = 10; // <0, 99>
840  int c = 2;
841  int numProcs = COMMPI_Comm_size( param.communicator);
842  while (numProcs >= u*10) {
843  u *= 10;
844  c ++;
845  }
846  for (int i=0; i<c; i++) {
847  int d = data / u;
848  data %= u;
849  u /= 10;
850  fname += ('0'+d);
851  }
852  fname += ".txt";
853  param.timingDataFile = param.timingDataDir;
854  param.timingDataFile += fname;
855 
856  int status = 1; // new
857  FILE *fd;
858  if (param.current_time == 0.0) {
859  fd = fopen( param.timingDataFile.c_str(), "w");
860  }
861  else {
862  fd = fopen( param.timingDataFile.c_str(), "r");
863  if (fd == NULL)
864  fd = fopen( param.timingDataFile.c_str(), "w");
865  else
866  status = 0; // old
867  }
868  if (fd == NULL) {
869  param.timingDataFile = "./";
870  param.timingDataFile += fname;
871  if (param.current_time == 0) {
872  fd = fopen( param.timingDataFile.c_str(), "w");
873  }
874  else {
875  fd = fopen( param.timingDataFile.c_str(), "r");
876  if (fd == NULL)
877  fd = fopen( param.timingDataFile.c_str(), "w");
878  else
879  status = 0;
880  }
881  if (fd == NULL) {
882  std::cerr << "Rocstar: Rank " << comm_rank << " could not open "
883  << param.timingDataFile.c_str() << "!" << std::endl;
884  MPI_Abort( MPI_COMM_WORLD, -1);
885  }
886  else if(param.controlVerb > 1)
887  printf("Rocstar: Rank %d using %s instead for timing data!\n", comm_rank, param.timingDataFile.c_str());
888  }
889 
890  int NumProcs;
891  NumProcs = COMMPI_Comm_size( param.communicator);
892 
893  if (param.current_time == 0.0 || status == 1) {
894  fprintf(fd, "\n");
895  fprintf(fd, "Number of processors = %d\n", NumProcs);
896  fprintf(fd, "\n");
897  fprintf(fd, "MyId = %d\n", comm_rank);
898  fprintf(fd, "\n");
899  }
900  fclose(fd);
901 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
const NT & d
MPI_Comm communicator
Definition: Coupling.h:51
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
int COMMPI_Comm_size(MPI_Comm c)
Definition: commpi.h:165
char timingDataDir[MAXLEN]
Definition: Coupling.h:71
blockLoc i
Definition: read.cpp:79
std::string timingDataFile
Definition: Coupling.h:72
double current_time
Definition: Coupling.h:54
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

bool reached_restartdump_time ( Control_parameters param)

Definition at line 519 of file rocstar_driver.C.

References Control_parameters::current_time, Control_parameters::iOutput, MAN_DEBUG, Control_parameters::myRank, Control_parameters::outputIntervalTime, and Control_parameters::time_step.

Referenced by rocstar_driver().

519  {
520  bool result = param.current_time + param.time_step*0.4 >=
521  param.iOutput*param.outputIntervalTime;
522  if (result == true) {
523  param.iOutput++;
524  if(param.myRank == 0)
525  MAN_DEBUG(1, ("\nRocstar: reached_restartdump_time with current_time: %e time_step: %e iOutput: %d outputIntervalTime: %e\n", param.current_time, param.time_step, param.iOutput, param.outputIntervalTime));
526  }
527  return result;
528 }
double time_step
Definition: Coupling.h:55
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
double current_time
Definition: Coupling.h:54
double outputIntervalTime
Definition: Coupling.h:63

Here is the caller graph for this function:

bool reached_simulation_time ( const Control_parameters param)

Definition at line 477 of file rocstar_driver.C.

References Control_parameters::communicator, Control_parameters::controlVerb, Control_parameters::cur_step, Control_parameters::current_dump, Control_parameters::current_time, MAN_DEBUG, Control_parameters::maxNumDumps, Control_parameters::maxNumTimeSteps, Control_parameters::maxwalltime, Control_parameters::myRank, Control_parameters::simue_time, and Control_parameters::startTime.

Referenced by rocstar_driver().

477  {
478  // if exceed max num of steps
479  if (param.cur_step>=param.maxNumTimeSteps) {
480  MAN_DEBUG(2, ("\nRocstar: reached_simulation_time returns TRUE with cur_step: %d\n", param.cur_step));
481  return true;
482  }
483 
484  int verb = param.controlVerb;
485 
486  // if exceed max wall time
487  double startTimeLoopTime;
488  if (param.myRank == 0) startTimeLoopTime = MPI_Wtime();
489  MPI_Bcast( &startTimeLoopTime, 1, MPI_DOUBLE, 0, param.communicator);
490  const double elaped_time = startTimeLoopTime - param.startTime;
491  if (elaped_time >= param.maxwalltime ) {
492  if (param.myRank == 0 && verb > 1)
493  printf("Rocstar: Quitting; elapsed wall clock time = %f\n", elaped_time);
494  return true;
495  }
496  else {
497  if (param.myRank == 0) {
498  MAN_DEBUG(2, ("\nRocstar: reached_simulation_time: elapsed wall time = %f \n", elaped_time));
499  }
500  }
501 
502  // if exceed MaximumTime the simulation time
503  if (param.current_time >= param.simue_time) { // MaximumTime
504  if (param.myRank == 0 && verb > 0)
505  printf("Rocstar: Quitting; CurrentTime = %e, MaximumTime = %e\n", param.current_time, param.simue_time);
506  return true;
507  }
508 
509  // if exceed the Maximum Number of dumps
510  if( (param.maxNumDumps > 0 ) && (param.current_dump >= param.maxNumDumps)){
511  if(param.myRank == 0 && verb > 0)
512  printf("Rocstar: Quitting; Reached the maximum number of dumps for this run. (%d)\n",param.current_dump);
513  return true;
514  }
515 
516  return false;
517 }
double simue_time
Definition: Coupling.h:52
double maxwalltime
Definition: Coupling.h:56
MPI_Comm communicator
Definition: Coupling.h:51
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
double current_time
Definition: Coupling.h:54
double startTime
Definition: Coupling.h:87

Here is the caller graph for this function:

bool reached_visdump_time ( const Control_parameters param)

Definition at line 530 of file rocstar_driver.C.

Referenced by rocstar_driver().

530  {
531  // TODO: Implement this
532  return false;
533 }

Here is the caller graph for this function:

void rocstar_driver ( int  verb,
int  remeshed,
bool  debug 
)

Definition at line 562 of file rocstar_driver.C.

References Coupling::check_convergence(), check_for_interrupt(), COM_print_profile(), COM_set_debug(), COM_set_profiling(), COM_set_verbose(), COM_UNLOAD_MODULE_STATIC_DYNAMIC, Control_parameters::communicator, Control_parameters::controlDebug, Control_parameters::controlVerb, create_coupling(), Control_parameters::cur_step, Control_parameters::current_dump, Control_parameters::current_time, Coupling::finalize(), RocBlas::init(), Coupling::init_convergence(), Coupling::initialize(), Control_parameters::LastOutputStep, Control_parameters::LastOutputTime, MAN_DEBUG, Control_parameters::maxNumPredCorrCycles, Control_parameters::maxNumTimeSteps, min(), MPI_COMM_WORLD, Control_parameters::myRank, Control_parameters::output_module, Coupling::output_restart_files(), Coupling::output_visualization_files(), Control_parameters::print(), RocmanControl_parameters::print(), Coupling::ProcessInterrupt(), reached_restartdump_time(), reached_simulation_time(), reached_visdump_time(), Control_parameters::read(), RocmanControl_parameters::read(), Coupling::read_restart_info(), RocmanControl_parameters::remeshed, Coupling::restart_at_time(), Coupling::run(), Coupling::schedule(), cimg_library::cimg::strcasecmp(), Control_parameters::time_step, Control_parameters::timingDataFile, Coupling::update_distances(), Coupling::update_integrals(), Coupling::write_restart_info(), and Control_parameters::zoomFactor.

562  {
563  // Read in config files to initialize param
564  Control_parameters *param_ptr = new Control_parameters;
565  Control_parameters &param = *param_ptr;
566  param.read();
567 
568  int comm_rank = param.myRank;
569 
570 
571  param.controlVerb = verb;
572  param.controlDebug = debug;
573 
574  // Read in rocman config files to initialize param
575  RocmanControl_parameters *rocman_param_ptr = new RocmanControl_parameters;
576  RocmanControl_parameters &rocman_param = *rocman_param_ptr;
577  rocman_param.read( param.communicator, comm_rank);
578  rocman_param.remeshed = remeshed;
579 
580  if ( comm_rank == 0 ) {
581  if(debug)
582  printf("Rocstar: Call CouplingInitialize\n");
583  if(verb > 1){
584  param.print();
585  rocman_param.print();
586  }
587  COM_set_verbose( verb); // shift by 2 to depress first level printing
588  COM_set_debug( debug);
589  }
590 
591  MPI_Barrier(MPI_COMM_WORLD);
592  // if(!comm_rank)
593  // std::cout << "Rocstar: creating coupling." << std::endl;
594 
595  // Construct coupling object and schedule the actions
596  Coupling *coup = create_coupling( param, rocman_param);
597  if(!coup){
598  if(comm_rank == 0)
599  std::cerr << "Rocstar: Error: No coupling created. Exiting." << std::endl;
600  return;
601  }
602  coup->schedule();
603 
604  // std::cout << "Rocstar(" << comm_rank << "): coupling created." << std::endl;
605  MPI_Barrier(MPI_COMM_WORLD);
606  // if(!comm_rank)
607  // std::cout << "Rocstar: All couplings created." << std::endl;
608  // visualization
609  // std::string fname = std::string(param.coupling_scheme) + ".gdl";
610  // coup->print(fname.c_str());
611 
612  // Load other service modules
613  RocBlas::init();
614  MPI_Barrier(MPI_COMM_WORLD);
615  // if(!comm_rank)
616  // std::cout << "Rocstar: Rocblas initd." << std::endl;
617 
618  // Have Roccom profile all the calls to COM_call_function.
619  COM_set_profiling( 1);
620  MPI_Barrier(MPI_COMM_WORLD);
621  // if(!comm_rank)
622  // std::cout << "Rocstar: profiling set." << std::endl;
623 
624  int with_pciter = (param.maxNumPredCorrCycles > 1);
625  if ( comm_rank == 0 && verb > 1) {
626  std::cout << "Rocstar: The maximum number of PC-iterations is " << param.maxNumPredCorrCycles << std::endl;
627  }
628 
629  // in case of restarting, reset cur_step and current_time from Restart.txt
630  coup->read_restart_info();
631 
632  MPI_Barrier(MPI_COMM_WORLD);
633  if(!comm_rank && debug)
634  std::cout << "Rocstar: Read restart information, initializing" << std::endl;
635 
636  // call input, init and run_initactions
637  coup->initialize();
638 
639  // std::cout << "Rocstar(" << comm_rank << "): Coupling initialized." << std::endl;
640  MPI_Barrier(MPI_COMM_WORLD);
641  // if(!comm_rank)
642  // std::cout << "Rocstar: All couplings initd" << std::endl;
643 
644  if ( param.current_time == 0.0) {
645  MPI_Barrier(param.communicator);
646  if(comm_rank == 0 && verb > 0)
647  std::cout << "Rocstar: Performing time 0 dump..." << std::endl;
648  coup->update_integrals( param.current_time);
649  coup->update_distances( param.current_time);
650  coup->output_restart_files( param.current_time);
651  MPI_Barrier(param.communicator);
652  if(comm_rank == 0 && debug)
653  std::cout << "Rocstar: done." << std::endl;
654  }
655 
656  MPI_Barrier(param.communicator);
657  param.LastOutputTime = param.current_time;
658  param.LastOutputStep = param.cur_step;
659 
660  if (comm_rank == 0 && verb > 0) {
661  std::cout << "Rocstar: Starting with step " << param.cur_step+1 << ", at time " << param.current_time << std::endl;
662  }
663 
664  char header[100];
665  sprintf(header, "************** Initialization times at time step %d *****************\n", param.cur_step);
666  COM_print_profile( param.timingDataFile.c_str(), header);
667  COM_set_profiling( 1); // Reset profiler;
668 
669  if (param.current_time == 0.0)
670  coup->write_restart_info( param.current_time, 1);
671 
672  // March through time until either the specified maximum time or the maximum
673  // number of time steps have been exceeded (whichever comes first).
674  int InterfaceConverged;
675  MPI_Barrier(param.communicator);
676  // if(comm_rank == 0)
677  // std::cout << "Rocstar: Preparig to step..." << std::endl;
678  while ( !reached_simulation_time(param) ) {
679  param.cur_step ++;
680 
681  for (int iPredCorr = 1; iPredCorr <= param.maxNumPredCorrCycles; iPredCorr++)
682  {
683  if ( comm_rank == 0 && verb > 0) {
684  std::cout << "Rocstar:" << std::endl
685  << "Rocstar: ================================================================" << std::endl
686  << "Rocstar: System Time Step : " << param.cur_step << " PC(" << iPredCorr << ")" << std::endl
687  << "Rocstar: ================================================================" << std::endl
688  << "Rocstar:" << std::endl
689  << "Rocstar: CurrentTime, CurrentTimeStep";
690  if(verb > 1)
691  std::cout << ", ZoomFactor";
692  std::cout << ": "
693  << param.current_time << " "
694  << param.time_step << " ";
695  if(verb > 1)
696  std::cout << param.zoomFactor;
697  std::cout << std::endl << "Rocstar:" << std::endl;
698  }
699 
700  MPI_Barrier(param.communicator);
701  // if(comm_rank == 0)
702  // std::cout << "Rocstar: initializing convergence checking" << std::endl;
703  if ( with_pciter)
704  coup->init_convergence( iPredCorr);
705  MPI_Barrier(param.communicator);
706  // if(comm_rank == 0)
707  // std::cout << "Rocstar: convergence checking initialized" << std::endl;
708 
709  // invoke time integration of coupling scheme by passing in
710  // current time and desired time step and obtaining new time
711  MPI_Barrier(param.communicator);
712  // if(comm_rank == 0)
713  // std::cout << "Rocstar: Running coupling.." << std::endl;
714  double new_current_time = coup->run( param.current_time, param.time_step,
715  iPredCorr, param.zoomFactor);
716 
717  // Check for interrupt
718  check_for_interrupt(coup,param);
719 
720  // std::cout << comm_rank << ": solver done on this rank." << std::endl;
721  MPI_Barrier(param.communicator);
722  // if(comm_rank == 0)
723  // std::cout << "Rocstar: coupling done." << std::endl;
724 
725  InterfaceConverged = 1;
726  if ( with_pciter)
727  InterfaceConverged = coup->check_convergence();
728 
729  if ( comm_rank == 0 && debug )
730  std::cout << "Rocstar:" << std::endl
731  << "Rocstar: iPredCorr = " << iPredCorr << " is done" << std::endl;
732  if ( InterfaceConverged ) {
733  param.current_time = new_current_time;
734  if ( comm_rank == 0 && verb > 1)
735  std::cout << "Rocstar: Success: predictor-corrector converged at time " << param.current_time << std::endl;
736  break;
737  }
738  else {
739  if ( comm_rank == 0 && debug ) {
740  std::cout << "Rocstar:" << std::endl
741  << "Rocstar: Interface has -NOT- converged!" << std::endl
742  << "Rocstar: iPredCorr = " << iPredCorr << " is done" << std::endl;
743  }
744  }
745  } // end of iPredCorr
746 
747  // New function to parse flags set by interrupt returns false if no action
748  if(coup->ProcessInterrupt())
749  continue;
750 
751  if ( !InterfaceConverged) {
752  if (comm_rank == 0)
753  std::cerr << "Rocstar: Disaster: predictor-corrector did not converge" << std::endl;
754  MPI_Abort( MPI_COMM_WORLD, -1);
755  }
756 
757 #if 0
758  // warm restart at step 3
759  if (param.cur_step == 320) {
760  static int didit = 0; // do it only once
761  if (!didit) {
762  coup->restart_at_time(param.LastOutputTime, param.LastOutputStep);
763  didit = 1;
764  continue; // skip the rest !
765  }
766  }
767 #endif
768 
769  // if reached time for restart dump
770  if ( reached_restartdump_time( param) ) {
771  MPI_Barrier(param.communicator);
772  // Compute integrals and write them into files for conservation-check
773  coup->update_integrals( param.current_time);
774  coup->update_distances( param.current_time);
775 
776  // invoke restart output (as well as visualization data)
777  if(comm_rank == 0 && verb > 0)
778  std::cout << "Rocstar: Dumping restart files... " << std::endl;
779  coup->output_restart_files( param.current_time);
780  coup->write_restart_info( param.current_time, param.cur_step+1);
781  param.LastOutputTime = param.current_time;
782  param.LastOutputStep = param.cur_step;
783  param.current_dump++;
784  MPI_Barrier(param.communicator);
785  //if(comm_rank == 0)
786  //std::cout << "done." << std::endl;
787  }
788  else if ( reached_visdump_time( param)) {
789  if(comm_rank == 0 && verb > 0)
790  std::cout << "Rocstar: Dumping coupling viz files." << std::endl;
791  // output visualization files
793  }
794 
795  // Write out profile data
796  if ( param.cur_step <= 100 || param.LastOutputTime == param.current_time) {
797  sprintf(header, "************** Solver times up to time step %d since last output *********\n", param.cur_step);
798  COM_print_profile( param.timingDataFile.c_str(), header);
799  COM_set_profiling( 1); // Reset profiler;
800  }
801  //if(comm_rank == 0)
802  //std::cout << "Rocstar:" << std::endl;
803  } // end time step
804 
805  // Write final solution.
806  if (param.current_time != param.LastOutputTime) {
807  MPI_Barrier(param.communicator);
808  if(comm_rank == 0 && verb > 0)
809  std::cout << "Rocstar: Performing final dump..." << std::endl;
810  coup->output_restart_files( param.current_time);
811  coup->write_restart_info( param.current_time, std::min(param.cur_step, param.maxNumTimeSteps)+1);
812  MPI_Barrier(param.communicator);
813  if(comm_rank == 0 && debug)
814  std::cout << "Rocstar: done." << std::endl;
815  }
816 
817  // Finalize coupling
818  coup->finalize();
819 
820 #ifdef WITH_PANDA
821  // unload Rocpanda to exit gracefully
822  if ( strcasecmp(param.output_module, "Rocpanda") == 0) {
823  MAN_DEBUG(3, ("[%d] Rocstar: unload_module Rocpanda.\n", param.myRank));
824  COM_UNLOAD_MODULE_STATIC_DYNAMIC( Rocpanda, "OUT");
825  }
826 #endif
827 
828  // Write out the final profile data
829  sprintf(header, "************** Finalization times after time step %d *****************\n", param.cur_step);
830  COM_print_profile( param.timingDataFile.c_str(), header);
831 
832  delete coup;
833 }
virtual void update_integrals(double currentTime)
Definition: Coupling.h:174
void COM_set_debug(bool debug)
Definition: roccom_c++.h:546
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
void write_restart_info(double CurrentTime, int iStep)
Definition: Coupling.C:337
double time_step
Definition: Coupling.h:55
int check_convergence()
Definition: Coupling.C:284
static void init()
Definition: Coupling.C:87
MPI_Comm communicator
Definition: Coupling.h:51
int maxNumPredCorrCycles
Definition: Coupling.h:60
void COM_set_verbose(int i)
Definition: roccom_c++.h:543
void output_visualization_files(double t)
Definition: Coupling.C:306
void restart_at_time(double t, int step)
Definition: Coupling.C:372
void schedule()
Schedule the top-level actions of the coupling scheme and the actions of the agents.
Definition: Coupling.C:181
bool reached_visdump_time(const Control_parameters &param)
int ProcessInterrupt()
Definition: Coupling.C:572
void init_convergence(int iPredCorr)
Definition: Coupling.C:275
void read(MPI_Comm comm, int commrank)
char output_module[MAXLEN]
Definition: Coupling.h:49
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:113
double LastOutputTime
Definition: Coupling.h:76
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
virtual void update_distances(double currentTime)
Definition: Coupling.h:175
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
bool reached_restartdump_time(Control_parameters &param)
double zoomFactor
Definition: Coupling.h:64
Coupling * create_coupling(Control_parameters &param, const RocmanControl_parameters &rocman_param)
bool reached_simulation_time(const Control_parameters &param)
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
std::string timingDataFile
Definition: Coupling.h:72
double run(double t, double dt, int iPredCorr, double zoom)
Invoke the scheduler.
Definition: Coupling.C:238
void output_restart_files(double t)
Definition: Coupling.C:299
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
double current_time
Definition: Coupling.h:54
void finalize()
Invoke finalization of the actions in the scheduler and the agents.
Definition: Coupling.C:230
void initialize(int reinit=0)
Definition: Coupling.C:355
void read_restart_info()
Definition: Coupling.C:313
int check_for_interrupt(Coupling *coup, const Control_parameters &param)

Here is the call graph for this function:

void RocstarShutdown ( int  status = 0)

Definition at line 59 of file rocstar_driver.C.

References COM_finalize().

Referenced by Coupling::Interrupt(), and Coupling::ProcessInterrupt().

60 {
61  /* Finalize Roccom. */
62  COM_finalize();
63 #ifdef ROCPROF
64  Rocprof_Finalize(true);
65 #endif
66  /* Close down MPI. */
67  MPI_Finalize();
68  exit(status);
69 }
void COM_finalize()
Definition: roccom_c++.h:59

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation