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