[cig-commits] [commit] devel: Modifies OUTPUT_FILES and CMTSOLUTION for simultaneous runs (df37363)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri Dec 5 07:23:11 PST 2014


Repository : https://github.com/geodynamics/specfem3d_globe

On branch  : devel
Link       : https://github.com/geodynamics/specfem3d_globe/compare/b9fb1aa33196d161098710455fadbb4ed91c5e47...897de40783bd1a4630c2aacd3fa5f8b016d4c189

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

commit df373638865e75b4d0cbe3141867484042221692
Author: Matthieu Lefebvre <ml15 at princeton.edu>
Date:   Tue Dec 2 14:33:57 2014 -0500

    Modifies OUTPUT_FILES and CMTSOLUTION for simultaneous runs


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

df373638865e75b4d0cbe3141867484042221692
 src/shared/count_number_of_sources.f90  | 12 ++++++++++--
 src/shared/parallel.f90                 |  8 ++++++--
 src/shared/read_parameter_file.f90      |  2 +-
 src/specfem3D/get_cmt.f90               | 18 +++++++++++++-----
 src/specfem3D/get_event_info.f90        | 10 +++++++++-
 src/specfem3D/initialize_simulation.f90 |  3 ++-
 src/specfem3D/locate_receivers.f90      | 10 ++++++----
 src/specfem3D/locate_sources.f90        | 10 +++++++---
 src/specfem3D/read_mesh_databases.F90   | 22 ++++++++++++----------
 9 files changed, 66 insertions(+), 29 deletions(-)

diff --git a/src/shared/count_number_of_sources.f90 b/src/shared/count_number_of_sources.f90
index 3d2072a..b8d2af6 100644
--- a/src/shared/count_number_of_sources.f90
+++ b/src/shared/count_number_of_sources.f90
@@ -38,10 +38,18 @@
 
   integer :: ios,icounter
 
+  character(len=MAX_STRING_LEN) :: CMTSOLUTION, path_to_add
   character(len=MAX_STRING_LEN) :: dummystring
 
-  open(unit=IIN,file='DATA/CMTSOLUTION',status='old',action='read',iostat=ios)
-  if (ios /= 0) stop 'Error opening DATA/CMTSOLUTION file'
+  CMTSOLUTION = 'DATA/CMTSOLUTION'
+
+  if (NUMBER_OF_SIMULTANEOUS_RUNS > 1 .and. mygroup >= 0) then
+    write(path_to_add,"('run',i4.4,'/')") mygroup + 1
+    CMTSOLUTION=path_to_add(1:len_trim(path_to_add))//CMTSOLUTION(1:len_trim(CMTSOLUTION))
+  endif
+
+  open(unit=IIN,file=trim(CMTSOLUTION),status='old',action='read',iostat=ios)
+  if (ios /= 0) stop 'Error opening CMTSOLUTION file'
 
   icounter = 0
   do while(ios == 0)
diff --git a/src/shared/parallel.f90 b/src/shared/parallel.f90
index 8146500..2de4094 100644
--- a/src/shared/parallel.f90
+++ b/src/shared/parallel.f90
@@ -579,7 +579,7 @@ end module my_mpi
 
   integer :: ier
 
-  call MPI_BCAST(buffer,countval,MPI_INTEGER,0,MPI_COMM_WORLD,ier)
+  call MPI_BCAST(buffer,countval,MPI_INTEGER,0,my_local_mpi_comm_world,ier)
 
   end subroutine bcast_all_i
 
@@ -1502,6 +1502,7 @@ end module my_mpi
   use my_mpi
   use constants,only: MAX_STRING_LEN,NUMBER_OF_SIMULTANEOUS_RUNS,OUTPUT_FILES_PATH, &
     IMAIN,ISTANDARD_OUTPUT,mygroup,BROADCAST_SAME_MESH_AND_MODEL,I_should_read_the_database
+  use shared_input_parameters
 
   implicit none
 
@@ -1520,6 +1521,8 @@ end module my_mpi
   if (NUMBER_OF_SIMULTANEOUS_RUNS > 1 .and. IMAIN == ISTANDARD_OUTPUT) &
     stop 'must not have IMAIN == ISTANDARD_OUTPUT when NUMBER_OF_SIMULTANEOUS_RUNS > 1 otherwise output to screen is mingled'
 
+  OUTPUT_FILES = OUTPUT_FILES_PATH(1:len_trim(OUTPUT_FILES))
+
   if (NUMBER_OF_SIMULTANEOUS_RUNS == 1) then
 
     my_local_mpi_comm_world = MPI_COMM_WORLD
@@ -1545,7 +1548,8 @@ end module my_mpi
 
 !   add the right directory for that run (group numbers start at zero, but directory names start at run0001, thus we add one)
     write(path_to_add,"('run',i4.4,'/')") mygroup + 1
-    OUTPUT_FILES_PATH = path_to_add(1:len_trim(path_to_add))//OUTPUT_FILES_PATH(1:len_trim(OUTPUT_FILES_PATH))
+    !OUTPUT_FILES_PATH = path_to_add(1:len_trim(path_to_add))//OUTPUT_FILES_PATH(1:len_trim(OUTPUT_FILES_PATH))
+    OUTPUT_FILES = path_to_add(1:len_trim(path_to_add))//OUTPUT_FILES(1:len_trim(OUTPUT_FILES))
 
 !--- create a subcommunicator to broadcast the identical mesh and model databases if needed
     if (BROADCAST_SAME_MESH_AND_MODEL) then
diff --git a/src/shared/read_parameter_file.f90 b/src/shared/read_parameter_file.f90
index 7d93c29..43f47de 100644
--- a/src/shared/read_parameter_file.f90
+++ b/src/shared/read_parameter_file.f90
@@ -44,7 +44,7 @@
   integer :: ierr
 
   ! sets the base pathname for output files
-  OUTPUT_FILES = 'OUTPUT_FILES'
+  ! OUTPUT_FILES = 'OUTPUT_FILES' -- set in shared/parallel.f90
 
   ! opens the parameter file: DATA/Par_file
   call open_parameter_file(ierr)
diff --git a/src/specfem3D/get_cmt.f90 b/src/specfem3D/get_cmt.f90
index cba331d..18d5848 100644
--- a/src/specfem3D/get_cmt.f90
+++ b/src/specfem3D/get_cmt.f90
@@ -29,7 +29,7 @@
                      DT,NSOURCES,min_tshift_cmt_original)
 
   use constants,only: IIN,IMAIN,USE_FORCE_POINT_SOURCE,EXTERNAL_SOURCE_TIME_FUNCTION, &
-    RHOAV,R_EARTH,PI,GRAV,TINYVAL
+    RHOAV,R_EARTH,PI,GRAV,TINYVAL, MAX_STRING_LEN,NUMBER_OF_SIMULTANEOUS_RUNS,mygroup
 
   implicit none
 
@@ -45,11 +45,12 @@
 
   ! local variables below
   integer :: mo,da,julian_day,isource
-  integer :: i,itype,istart,iend,ier
+  integer :: i,itype,istart,iend,ier, ios
   double precision :: scaleM
   double precision :: t_shift(NSOURCES)
   !character(len=5) :: datasource
   character(len=256) :: string
+  character(len=MAX_STRING_LEN) :: CMTSOLUTION, path_to_add
 
   ! initializes
   lat(:) = 0.d0
@@ -63,8 +64,14 @@
 !
 !---- read hypocenter info
 !
-  open(unit = IIN,file='DATA/CMTSOLUTION',status='old',action='read',iostat=ier)
-  if (ier /= 0) stop 'Error opening DATA/CMTSOLUTION file'
+  CMTSOLUTION = 'DATA/CMTSOLUTION'
+  if (NUMBER_OF_SIMULTANEOUS_RUNS > 1 .and. mygroup >= 0) then
+    write(path_to_add,"('run',i4.4,'/')") mygroup + 1
+    CMTSOLUTION=path_to_add(1:len_trim(path_to_add))//CMTSOLUTION(1:len_trim(CMTSOLUTION))
+  endif
+
+  open(unit=IIN,file=trim(CMTSOLUTION),status='old',action='read',iostat=ios)
+  if (ios /= 0) stop 'Error opening CMTSOLUTION file (get_cmt)'
 
 ! read source number isource
   do isource = 1,NSOURCES
@@ -78,6 +85,7 @@
 
     ! gets header line
     read(IIN,"(a256)",iostat=ier) string
+    print *, isource, trim(CMTSOLUTION)
     if (ier /= 0) then
       write(IMAIN,*) 'Error reading header line in source ',isource
       stop 'Error reading header line in station in CMTSOLUTION file'
@@ -88,7 +96,7 @@
       read(IIN,"(a256)",iostat=ier) string
       if (ier /= 0) then
         write(IMAIN,*) 'Error reading header line in source ',isource
-        stop 'Error reading header line in station in CMTSOLUTION file'
+        stop 'Error reading header blank lines in station in CMTSOLUTION file'
       endif
     enddo
 
diff --git a/src/specfem3D/get_event_info.f90 b/src/specfem3D/get_event_info.f90
index b377377..6e1858f 100644
--- a/src/specfem3D/get_event_info.f90
+++ b/src/specfem3D/get_event_info.f90
@@ -141,10 +141,18 @@
   character(len=5) :: datasource
   character(len=256) :: string
 
+  character(len=MAX_STRING_LEN) :: CMTSOLUTION, path_to_add
+
 !
 !---- read hypocenter info
+  CMTSOLUTION = 'DATA/CMTSOLUTION'
+
+  if (NUMBER_OF_SIMULTANEOUS_RUNS > 1 .and. mygroup >= 0) then
+    write(path_to_add,"('run',i4.4,'/')") mygroup + 1
+    CMTSOLUTION=path_to_add(1:len_trim(path_to_add))//CMTSOLUTION(1:len_trim(CMTSOLUTION))
+  endif
 !
-  open(unit=IIN,file='DATA/CMTSOLUTION',status='old',action='read',iostat=ios)
+  open(unit=IIN,file=trim(CMTSOLUTION),status='old',action='read',iostat=ios)
   if (ios /= 0) stop 'Error opening DATA/CMTSOLUTION file (in get_event_info_serial)'
 
   ! example header line of CMTSOLUTION file
diff --git a/src/specfem3D/initialize_simulation.f90 b/src/specfem3D/initialize_simulation.f90
index d7a59b9..74a6b18 100644
--- a/src/specfem3D/initialize_simulation.f90
+++ b/src/specfem3D/initialize_simulation.f90
@@ -74,7 +74,8 @@
   call synchronize_all()
 
   ! set the base pathname for output files
-  OUTPUT_FILES = 'OUTPUT_FILES'
+  ! See world split -> parallel.f90
+  ! OUTPUT_FILES = 'OUTPUT_FILES'
 
   ! open main output file, only written to by process 0
   if (myrank == 0 .and. IMAIN /= ISTANDARD_OUTPUT) then
diff --git a/src/specfem3D/locate_receivers.f90 b/src/specfem3D/locate_receivers.f90
index 34d4f27..abe59b1 100644
--- a/src/specfem3D/locate_receivers.f90
+++ b/src/specfem3D/locate_receivers.f90
@@ -43,6 +43,8 @@
     HUGEVAL,IMAIN,IIN,IOUT,IOUT_VTK,MIDX,MIDY,MIDZ, &
     DEGREES_TO_RADIANS,RADIANS_TO_DEGREES,TWO_PI,R_UNIT_SPHERE,R_EARTH,R_EARTH_KM
 
+  use shared_input_parameters, only: OUTPUT_FILES
+
   use specfem_par,only: &
     myrank,DT,NSTEP, &
     xigll,yigll,zigll, &
@@ -543,7 +545,7 @@
     ! Harvard format does not support the network name
     ! therefore only the station name is included below
     ! compute total number of samples for normal modes with 1 sample per second
-    open(unit=IOUT,file='OUTPUT_FILES/RECORDHEADERS', &
+    open(unit=IOUT,file=trim(OUTPUT_FILES)//'/RECORDHEADERS', &
           status='unknown',iostat=ier)
     if (ier /= 0 ) call exit_MPI(myrank,'Error opening file RECORDHEADERS')
 
@@ -845,7 +847,7 @@
   if (myrank == 0) then
 
     ! appends receiver locations to sr.vtk file
-    open(IOUT_VTK,file='OUTPUT_FILES/sr_tmp.vtk',position='append',status='old',iostat=ier)
+    open(IOUT_VTK,file=trim(OUTPUT_FILES)//'/sr_tmp.vtk',position='append',status='old',iostat=ier)
     if (ier /= 0 ) call exit_MPI(myrank,'Error opening and appending receivers to file sr_tmp.vtk')
 
     ! chooses best receivers locations
@@ -938,7 +940,7 @@
     epidist(1:nrec) = epidist_found(1:nrec)
 
     ! write the list of stations and associated epicentral distance
-    open(unit=IOUT,file='OUTPUT_FILES/output_list_stations.txt', &
+    open(unit=IOUT,file=trim(OUTPUT_FILES)//'/output_list_stations.txt', &
           status='unknown',iostat=ier)
     if (ier /= 0 ) call exit_MPI(myrank,'Error opening file output_list_stations.txt')
     write(IOUT,*)
@@ -953,7 +955,7 @@
 
     ! write out a filtered station list
     if (NCHUNKS_VAL /= 6) then
-      open(unit=IOUT,file='OUTPUT_FILES/STATIONS_FILTERED', &
+      open(unit=IOUT,file=trim(OUTPUT_FILES)//'/STATIONS_FILTERED', &
             status='unknown',iostat=ier)
       if (ier /= 0 ) call exit_MPI(myrank,'Error opening file STATIONS_FILTERED')
       ! loop on all the stations to read station information
diff --git a/src/specfem3D/locate_sources.f90 b/src/specfem3D/locate_sources.f90
index 9cc9a9f..47d83ac 100644
--- a/src/specfem3D/locate_sources.f90
+++ b/src/specfem3D/locate_sources.f90
@@ -35,6 +35,8 @@
 
   use constants_solver
 
+  use shared_input_parameters, only: OUTPUT_FILES
+
   use specfem_par,only: &
     NSOURCES,myrank, &
     tshift_cmt,theta_source,phi_source, &
@@ -178,9 +180,10 @@
     mask_source(:,:,:,:) = 1.0_CUSTOM_REAL
   endif
 
+  print *, "yo---------> ", trim(OUTPUT_FILES)
   ! appends receiver locations to sr.vtk file
   if (myrank == 0) then
-    open(IOUT_VTK,file='OUTPUT_FILES/sr_tmp.vtk', &
+    open(IOUT_VTK,file=trim(OUTPUT_FILES)//'/sr_tmp.vtk', &
           position='append',status='old',iostat=ier)
     if (ier /= 0 ) call exit_MPI(myrank,'Error opening and appending sources to file sr_tmp.vtk')
   endif
@@ -886,6 +889,7 @@
 ! prints source time function
 
   use constants
+  use shared_input_parameters
 
   implicit none
 
@@ -935,7 +939,7 @@
   endif
 
   ! output file
-  open(unit=IOUT,file='OUTPUT_FILES'//plot_file, &
+  open(unit=IOUT,file=trim(OUTPUT_FILES)//plot_file, &
         status='unknown',iostat=ier)
   if (ier /= 0 ) call exit_mpi(0,'Error opening plot_source_time_function file')
 
@@ -993,7 +997,7 @@
     endif
   endif
 
-  open(unit=IOUT,file='OUTPUT_FILES'//plot_file, &
+  open(unit=IOUT,file=trim(OUTPUT_FILES)//plot_file, &
         status='unknown',iostat=ier)
   if (ier /= 0 ) call exit_mpi(0,'Error opening plot_source_spectrum file')
 
diff --git a/src/specfem3D/read_mesh_databases.F90 b/src/specfem3D/read_mesh_databases.F90
index 2f3daa4..65ed58d 100644
--- a/src/specfem3D/read_mesh_databases.F90
+++ b/src/specfem3D/read_mesh_databases.F90
@@ -791,6 +791,8 @@
 
   subroutine read_mesh_databases_addressing()
 
+  use constants
+
   use specfem_par
   use specfem_par_crustmantle
   use specfem_par_innercore
@@ -805,7 +807,7 @@
   if (I_should_read_the_database) then
     ! open file with global slice number addressing
     if (myrank == 0) then
-      open(unit=IIN,file=trim(OUTPUT_FILES)//'/addressing.txt',status='old',action='read',iostat=ier)
+      open(unit=IIN,file=trim(OUTPUT_FILES_PATH_BASE)//'/addressing.txt',status='old',action='read',iostat=ier)
       if (ier /= 0 ) call exit_mpi(myrank,'Error opening addressing.txt')
 
       do iproc = 0,NPROCTOT_VAL-1
@@ -1434,9 +1436,9 @@
   use specfem_par_crustmantle
   implicit none
     
-  call bcast_all_i_for_database(NSPEC_CRUST_MANTLE, 1)
-  call bcast_all_i_for_database(NGLOB_CRUST_MANTLE, 1)
-  call bcast_all_i_for_database(NGLOB_XY_CM, 1)
+  !call bcast_all_i_for_database(NSPEC_CRUST_MANTLE, 1)
+  !call bcast_all_i_for_database(NGLOB_CRUST_MANTLE, 1)
+  !call bcast_all_i_for_database(NGLOB_XY_CM, 1)
   call bcast_all_cr_for_database(rho_vp_crust_mantle(1,1,1,1), size(rho_vp_crust_mantle))
   call bcast_all_cr_for_database(rho_vs_crust_mantle(1,1,1,1), size(rho_vs_crust_mantle))
 
@@ -1484,7 +1486,7 @@
   call bcast_all_cr_for_database(rmassx_crust_mantle(1), size(rmassx_crust_mantle))
   call bcast_all_cr_for_database(rmassy_crust_mantle(1), size(rmassy_crust_mantle))
   call bcast_all_cr_for_database(rmassz_crust_mantle(1), size(rmassz_crust_mantle))
-  call bcast_all_i_for_database(NGLOB_CRUST_MANTLE_OCEANS, 1)
+  !call bcast_all_i_for_database(NGLOB_CRUST_MANTLE_OCEANS, 1)
   call bcast_all_cr_for_database(rmass_ocean_load(1), size(rmass_ocean_load))
   call bcast_all_cr_for_database(b_rmassx_crust_mantle(1), size(b_rmassx_crust_mantle))
   call bcast_all_cr_for_database(b_rmassy_crust_mantle(1), size(b_rmassy_crust_mantle))
@@ -1501,8 +1503,8 @@
   use specfem_par_outercore
   implicit none
 
-  call bcast_all_i_for_database(NSPEC_OUTER_CORE, 1)
-  call bcast_all_i_for_database(NGLOB_OUTER_CORE, 1)
+  !call bcast_all_i_for_database(NSPEC_OUTER_CORE, 1)
+  !call bcast_all_i_for_database(NGLOB_OUTER_CORE, 1)
   call bcast_all_cr_for_database(vp_outer_core(1,1,1,1), size(vp_outer_core))
   call bcast_all_cr_for_database(xstore_outer_core(1), size(xstore_outer_core))
   call bcast_all_cr_for_database(ystore_outer_core(1), size(ystore_outer_core))
@@ -1533,9 +1535,9 @@
   use specfem_par_innercore
   implicit none
 
-  call bcast_all_i_for_database(NSPEC_INNER_CORE, 1)
-  call bcast_all_i_for_database(NGLOB_INNER_CORE, 1)
-  call bcast_all_i_for_database(NGLOB_XY_IC, 1)
+  !call bcast_all_i_for_database(NSPEC_INNER_CORE, 1)
+  !call bcast_all_i_for_database(NGLOB_INNER_CORE, 1)
+  !call bcast_all_i_for_database(NGLOB_XY_IC, 1)
   call bcast_all_cr_for_database(xstore_inner_core(1), size(xstore_inner_core))
   call bcast_all_cr_for_database(ystore_inner_core(1), size(ystore_inner_core))
   call bcast_all_cr_for_database(zstore_inner_core(1), size(zstore_inner_core))



More information about the CIG-COMMITS mailing list