[cig-commits] [commit] pluggable: Changed Fortran code to use generic model data broadcasting routine. (ed172c5)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Apr 9 08:54:46 PDT 2014


Repository : ssh://geoshell/specfem3d_globe

On branch  : pluggable
Link       : https://github.com/geodynamics/specfem3d_globe/compare/64e1b38f0c5ebb4056cce0b15d41c0b9f94ab6e5...099a4d330d5b173b21e51ad441f9f429e5d37842

>---------------------------------------------------------------

commit ed172c54121b3440a159c8abef7d1f07efb31adc
Author: Leif Strand <leif at geodynamics.org>
Date:   Mon Nov 24 23:14:32 2008 +0000

    Changed Fortran code to use generic model data broadcasting routine.


>---------------------------------------------------------------

ed172c54121b3440a159c8abef7d1f07efb31adc
 Makefile.in   |  4 ++++
 bcast_model.c | 14 +++++++++-----
 meshfem3D.f90 |  8 ++++++--
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index bef1666..481e14c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -61,6 +61,7 @@ libspecfem_a_OBJECTS = \
 	$O/assemble_MPI_vector.o \
 	$O/attenuation_model.o \
 	$O/auto_ner.o \
+	$O/bcast_model.o \
 	$O/calc_jacobian.o \
 	$O/calendar.o \
 	$O/comp_source_spectrum.o \
@@ -552,6 +553,9 @@ $O/combine_surf_data.o: constants.h $S/combine_surf_data.f90
 $O/write_c_binary.o: $S/write_c_binary.c config.h
 	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $O/write_c_binary.o $S/write_c_binary.c
 
+$O/bcast_model.o: $S/bcast_model.c config.h
+	mpicc $(CPPFLAGS) $(CFLAGS) -c -o $O/bcast_model.o $S/bcast_model.c
+
 $O/add_missing_nodes.o: constants.h $S/add_missing_nodes.f90
 	${FCCOMPILE_CHECK} -c -o $O/add_missing_nodes.o ${FCFLAGS_f90} $S/add_missing_nodes.f90
 
diff --git a/bcast_model.c b/bcast_model.c
index 7b4fb0c..001b07a 100644
--- a/bcast_model.c
+++ b/bcast_model.c
@@ -10,17 +10,21 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#include "config.h"
+
 
 static char wd[150], modelDir[150];
 
 
-void bcast_model(int rank, char *scratchDir) {
-    int fd;
+void FC_FUNC_(bcast_model, BCAST_MODEL)(int *pRank, char *scratchDir, int *scratchDirLen) {
+    int fd, rank;
     struct stat statBuf;
     int size;
     char *data;
     int status;
     
+    rank = *pRank;
+    
     /* Save the working directory (which is on the shared filesystem)
        for future reference. */
     if (!getcwd(wd, sizeof(wd))) {
@@ -66,7 +70,7 @@ void bcast_model(int rank, char *scratchDir) {
     }
     
     /* Create and enter the model directory. */
-    sprintf(modelDir, "%s/model-%d", scratchDir, rank);
+    sprintf(modelDir, "%.*s/model-%d", *scratchDirLen, scratchDir, rank);
     if (mkdir(modelDir, 0777) == -1) {
         perror("mkdir");
         MPI_Abort(MPI_COMM_WORLD, 1);
@@ -104,14 +108,14 @@ void bcast_model(int rank, char *scratchDir) {
     /* Stay in the model directory, ready to read files. */
 }
 
-void enter_model_dir() {
+void FC_FUNC_(enter_model_dir, ENTER_MODEL_DIR)() {
     if (chdir(modelDir) == -1) {
         perror("chdir");
         MPI_Abort(MPI_COMM_WORLD, 1);
     }
 }
 
-void leave_model_dir() {
+void FC_FUNC_(leave_model_dir, LEAVE_MODEL_DIR)() {
     if (chdir(wd) == -1) {
         perror("chdir");
         MPI_Abort(MPI_COMM_WORLD, 1);
diff --git a/meshfem3D.f90 b/meshfem3D.f90
index 473916d..30318fb 100644
--- a/meshfem3D.f90
+++ b/meshfem3D.f90
@@ -857,12 +857,16 @@
   endif
   if(ELLIPTICITY) call make_ellipticity(nspl,rspl,espl,espl2,ONE_CRUST)
 
-  call read_3d_mantle_model(myrank)
+  call bcast_model(myrank, LOCAL_PATH)
+
+  call read_3d_mantle_model()
 
   if(CRUSTAL) then
-    call read_crust(myrank)
+    call read_crust()
   endif
 
+  call leave_model_dir()
+
   if(ANISOTROPIC_INNER_CORE) then
     if(myrank == 0) call read_aniso_inner_core_model
 !   one should add an MPI_BCAST here if one adds a read_aniso_inner_core_model subroutine



More information about the CIG-COMMITS mailing list