iwave.h

Go to the documentation of this file.
00001 /* 
00002    iwave.h
00003    Igor Terentyev.
00004 
00005    thoroughly mangled by WWS 01/09
00006    even further mangled by WWS & XW 11/10
00007    mashed by WWS 10/13-01/14
00008 */
00009 /*============================================================================*/
00016 #ifndef __IWAVE_H_
00017 #define __IWAVE_H_
00018 /*----------------------------------------------------------------------------*/
00019 
00020 #include "utils.h"
00021 #include "usempi.h"
00022 #include "exchangeinfo.h"
00023 #include "parser.h"
00024 #include "fd.h"
00025 
00026 /*----------------------------------------------------------------------------*/
00027 /*
00028   Parallel information (MPI, MPI Cartesian grid, OpenMP).
00029   Cartesian grid for 1D/2D/3D.
00030 */
00036 typedef struct s_PARALLELINFO {
00037   int ndim;                
00038   int nnei;                
00039   int wsize;               
00040   int wrank;               
00041   int threadsupp;          
00042   MPI_Comm ccomm;          
00043   IPNT cdims;              
00044   IPNT crank;              
00045   int lrank;               
00046   int sranks[IWAVE_NNEI];  
00047   int rranks[IWAVE_NNEI];  
00048   EXCHANGEINFO seinfo[RDOM_MAX_NARR][IWAVE_NNEI]; 
00049   EXCHANGEINFO reinfo[RDOM_MAX_NARR][IWAVE_NNEI]; 
00058 } PARALLELINFO;
00059 
00060 
00061 /*----------------------------------------------------------------------------*/
00067 int initparallel(int ts);
00068 
00069 /*----------------------------------------------------------------------------*/
00075 void initparallel_global(int);
00076 
00077 /*----------------------------------------------------------------------------*/
00085 int initparallel_local(PARARRAY, FILE *);
00086 
00096 int initpinfo(PARALLELINFO *pinfo, FILE *stream);
00097 /*----------------------------------------------------------------------------*/
00098 /*
00099   Creates MPI Cartesian grid and computes neighbor processor ranks.
00100   Exits quitely if process is out of Cartesian grid.
00101   Sets OMP threads.
00102 */
00103 /*
00104  * Determines the number of processes in each dimension, i.e.\ cdims and asgnrk 
00105  * in \ref PARALLELINFO. 
00106  */
00107 /* 10.04.11: deprecated WWS
00108    int readparallel(PARALLELINFO *pinfo, PARARRAY *pars, FILE *stream);
00109 */
00110 /*----------------------------------------------------------------------------*/
00111 /*
00112  * Computes and stores neighbor processor ranks for correct physical grid dimn
00113  * Exits quietly if process is out of Cartesian grid and sets OMP threads.
00114  *
00115  * @param [out] pinfo - (PARALLELINFO *) parallel info pointer
00116  * @param [in] ndim - (int) physical grid dimension (as opposed to MPI cart comm dim)
00117  * @param [in] stream - (FILE *) file pointer where to dump run-time message
00118  * @return 0 on successful completion, else error code as in 
00119  * base/include/utils.h.
00120  */
00121 int initexch(PARALLELINFO *pinfo, int ndim, FILE *stream);
00122 
00123 /*----------------------------------------------------------------------------*/
00124 /*
00125  * Destroy Cartesian grid and MPI-related.
00126  *
00127  * int fabort :  flag to abort.
00128  *
00129  * Destroy the parallel info.
00130  *
00131  * Frees the communicator and destroys the send and recv info. No STORAGE 
00132  * DEALLOCATION occurs at this point.
00133  */
00134 /* renamed 10.04.11 WWS
00135    int destroyparallel(PARALLELINFO *pinfo, int fabort);
00136 */
00142 int destroypinfo(PARALLELINFO *pinfo, int fabort);
00143 /*----------------------------------------------------------------------------*/
00144 
00150 typedef struct s_IWAVE {
00152   PARALLELINFO pinfo; 
00154   IMODEL model;
00160   int stats;
00169   int nopts;
00181   int printact;
00182 #ifdef IWAVE_USE_MPI
00183   /* ALL OF THIS STUFF REMOVED TEMP 13.03.12 WWS */
00189   /*    double wt0; */
00196   /*    double stat_times[RDOM_MAX_NARR][MODEL_MAX_NACTION][3];  min, max, ave */
00202   /*    int stat_calls[RDOM_MAX_NARR][MODEL_MAX_NACTION][3]; */
00203 #endif
00204 } IWAVE;
00205 
00206 /* MAJOR IWAVE INTERFACES */
00250 int iwave_construct(IWAVE * state, PARARRAY * pars, FILE * stream, IWaveInfo const & ic);
00251 
00257 void iwave_printf(IWAVE * state, PARARRAY * pars, FILE * stream, IWaveInfo const & ic);
00258 
00266 void iwave_dynamic_init(IWAVE * state,
00267             int it, IWaveInfo const & ic);
00268 
00275 void iwave_destroy(IWAVE * state, FD_MODELDEST d);
00276 
00277 /* MORE IWAVE/PARALLELINFO HELPER FUNCTIONS */
00283 void quietexit(PARARRAY * pars,FILE ** stream);
00284 
00288 void abortexit(int err,PARARRAY * pars,FILE ** stream);
00289 
00300 int initoutstream(FILE ** stream, int rk, int sz);
00306 int readinput(PARARRAY ** pars, FILE * stream, int argc, char **argv);
00312 void readparpars(PARARRAY * pars,
00313          int * stats,
00314          int * nopts,
00315          int * printact,
00316          FILE * out);
00317 
00321 void storeparallel(PARALLELINFO *pinfo);
00322 
00328 int setrecvexchange(IMODEL * model, PARALLELINFO * pinfo, FILE * stream, IWaveInfo const & ic);
00329 
00333 int dump_pi(PARARRAY * pars, PARALLELINFO *pinfo, FILE *stream);  
00334 
00339 void dump_ac(PARARRAY * pars, IMODEL * model, FILE * stream);
00340 
00344 void dump_rs(PARARRAY * pars, IMODEL * model, FILE * stream, int sends, IWaveInfo const & ic, PARALLELINFO * pinfo);
00345 
00346 #ifdef IWAVE_USE_MPI
00347 
00350 void prepexch(PARALLELINFO * pinfo, IMODEL * model, IWaveInfo const & ic);
00351 /* REMOVED TEMP 13.03.12 WWS
00352 //      int stats, 
00353 //      double * wt0); */
00354 
00358 /* REMOVED TEMP 13.03.12 WWS
00359 //  void preptime(double stat_times[RDOM_MAX_NARR][MODEL_MAX_NACTION][3],
00360 //      int stat_calls[RDOM_MAX_NARR][MODEL_MAX_NACTION][3],
00361 //                IWAVE * state); */
00362 
00367 /* REMOVED TEMP 13.03.12 WWS
00368 //  void printtime(double stat_times[RDOM_MAX_NARR][MODEL_MAX_NACTION][3],
00369 //                 int stat_calls[RDOM_MAX_NARR][MODEL_MAX_NACTION][3],
00370 //                 IWAVE * state, FILE * stream); */
00371 
00372 #endif
00373 
00374 #endif /*__IWAVE_H_*/
00375 

Generated on 5 Jan 2017 for IWAVECORE by  doxygen 1.4.7