00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mpi.h"
00019 #include "fem.h"
00020 #include "converse.h"
00021 #include "charm-api.h"
00022
00023 CLINKAGE void fem_impl_call_init(void);
00024
00025 FLINKAGE void FTN_NAME(INIT,init)(void);
00026 FLINKAGE void FTN_NAME(DRIVER,driver)(void);
00027
00028 int main(int argc,char **argv) {
00029 MPI_Comm comm=MPI_COMM_WORLD;
00030 int myPart, nPart;
00031 int parallelMesh=0, serialMesh=0;
00032 MPI_Init(&argc,&argv);
00033 FEM_Init((FEM_Comm_t)comm);
00034 MPI_Comm_rank(comm,&myPart); MPI_Comm_size(comm,&nPart);
00035 if (CmiGetArgFlagDesc(argv,"-read","Skip init()--read mesh from files"))
00036 {
00037 parallelMesh=FEM_Mesh_read("fem_mesh",myPart,nPart);
00038 }
00039 else
00040 {
00041 if (myPart==0)
00042 {
00043 serialMesh=FEM_Mesh_allocate();
00044 FEM_Mesh_set_default_write(serialMesh);
00045 #ifndef FEM_ALONE
00046 fem_impl_call_init();
00047 #ifndef CMK_FORTRAN_USES_NOSCORE
00048 FTN_NAME(INIT,init)();
00049 #endif
00050 #else
00051 FTN_NAME(INIT,init)();
00052 #endif
00053 serialMesh=FEM_Mesh_default_write();
00054 }
00055 parallelMesh=FEM_Mesh_broadcast(serialMesh,0,(FEM_Comm_t)comm);
00056 if (myPart==0) FEM_Mesh_deallocate(serialMesh);
00057 }
00058
00059 if (CmiGetArgFlagDesc(argv,"-write","Skip driver()--write mesh to files"))
00060 {
00061 FEM_Mesh_write(parallelMesh,"fem_mesh",myPart,nPart);
00062 FEM_Mesh_deallocate(parallelMesh);
00063 }
00064 else
00065 {
00066 FEM_Mesh_set_default_read(parallelMesh);
00067 FEM_Mesh_set_default_write(FEM_Mesh_allocate());
00068 #ifndef FEM_ALONE
00069 driver();
00070 #ifndef CMK_FORTRAN_USES_NOSCORE
00071 FTN_NAME(DRIVER,driver)();
00072 #endif
00073 #else
00074 FTN_NAME(DRIVER,driver)();
00075 #endif
00076 FEM_Mesh_deallocate(FEM_Mesh_default_write());
00077 FEM_Mesh_deallocate(FEM_Mesh_default_read());
00078 }
00079 MPI_Finalize();
00080 return 0;
00081 }
00082