[cig-commits] r14003 - seismo/3D/SPECFEM3D_GLOBE/trunk/version41_beta/src

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Sun Feb 1 16:17:13 PST 2009


Author: dkomati1
Date: 2009-02-01 16:17:12 -0800 (Sun, 01 Feb 2009)
New Revision: 14003

Modified:
   seismo/3D/SPECFEM3D_GLOBE/trunk/version41_beta/src/specfem3D.F90
Log:
modified restart file code to move current restart files to an "*_old" directory
to backup them just in case the new run crashes or is killed while creating the new
restart files (or if something goes wrong while writing them); in which case the user can still use the older restart files


Modified: seismo/3D/SPECFEM3D_GLOBE/trunk/version41_beta/src/specfem3D.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/trunk/version41_beta/src/specfem3D.F90	2009-02-01 21:53:46 UTC (rev 14002)
+++ seismo/3D/SPECFEM3D_GLOBE/trunk/version41_beta/src/specfem3D.F90	2009-02-02 00:17:12 UTC (rev 14003)
@@ -514,6 +514,7 @@
           SAVE_ALL_SEISMOS_IN_ONE_FILE,USE_BINARY_FOR_LARGE_FILE
 
   character(len=150) OUTPUT_FILES,MODEL
+  character(len=400) system_command
 
 ! parameters deduced from parameters read from file
   integer NPROC,NPROCTOT,NEX_PER_PROC_XI,NEX_PER_PROC_ETA,ratio_divide_central_cube
@@ -2899,6 +2900,19 @@
 ! if this is not the last part of the run, write all the files to disk
   if(USE_RESTART_FILES .and. mod(it,INTERVAL_DUMP_FILES) == 0 .and. it /= NSTEP) then
 
+! move the current restart files (if any) to a backup directory in order to save
+! them just in case the current run crashes while writing the new restart files
+    if(myrank == 0) then
+      system_command = 'rm -f -r '//trim(PATH_RESTART_FILES)//'_old'
+      call system(system_command)
+      system_command = 'mv -f '//trim(PATH_RESTART_FILES)//' '//trim(PATH_RESTART_FILES)//'_old'
+      call system(system_command)
+      system_command = 'mkdir -p '//trim(PATH_RESTART_FILES)
+      call system(system_command)
+    endif
+! synchronize all the processes to make sure everybody has finished
+    call MPI_BARRIER(MPI_COMM_WORLD,ier)
+
     write(outputname,"('/dump_all_arrays',i6.6)") myrank
     open(unit=55,file=trim(PATH_RESTART_FILES)//outputname,status='unknown',form='unformatted',action='write')
 



More information about the CIG-COMMITS mailing list