From 251ff337972ce0c21c52d0af2f7c324350f6e7e2 Mon Sep 17 00:00:00 2001 From: Sebastian Beyer Date: Sun, 22 Sep 2024 15:29:38 +0200 Subject: [PATCH] separate RestartInPath and RestartOutPath --- src/gen_model_setup.F90 | 5 +++-- src/gen_modules_clock.F90 | 4 ++-- src/gen_modules_config.F90 | 5 +++-- src/icepack_drivers/icedrv_io.F90 | 4 ++-- src/io_restart.F90 | 33 ++++++++++++++++--------------- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/gen_model_setup.F90 b/src/gen_model_setup.F90 index 770323ec5..3bc0ee775 100755 --- a/src/gen_model_setup.F90 +++ b/src/gen_model_setup.F90 @@ -38,8 +38,9 @@ subroutine setup_model(partit) !!$ read (fileunit, NML=machine) close (fileunit) - ! by default use ResultPath for RestartPath - if (RestartPath == 'same-as-result') RestartPath = ResultPath + ! by default use ResultPath for RestartInPath and RestartOutPath + if (RestartInPath == 'same-as-result') RestartInPath = ResultPath + if (RestartOutPath == 'same-as-result') RestartOutPath = ResultPath ! ========== diff --git a/src/gen_modules_clock.F90 b/src/gen_modules_clock.F90 index 3f529f482..f3c118268 100755 --- a/src/gen_modules_clock.F90 +++ b/src/gen_modules_clock.F90 @@ -83,7 +83,7 @@ subroutine clock_init(partit) yearstart=yearnew ! init clock for this run - open(99,file=trim(RestartPath)//trim(runid)//'.clock',status='old') + open(99,file=trim(RestartInPath)//trim(runid)//'.clock',status='old') read(99,*) timeold, dayold, yearold read(99,*) timenew, daynew, yearnew close(99) @@ -167,7 +167,7 @@ subroutine clock_finish dum_yearnew=yearold+1 endif - open(99,file=trim(ResultPath)//trim(runid)//'.clock',status='unknown') + open(99,file=trim(RestartOutPath)//trim(runid)//'.clock',status='unknown') write(99,*) timeold, dayold, yearold write(99,*) dum_timenew, dum_daynew, dum_yearnew close(99) diff --git a/src/gen_modules_config.F90 b/src/gen_modules_config.F90 index dee26ef89..d53df3847 100755 --- a/src/gen_modules_config.F90 +++ b/src/gen_modules_config.F90 @@ -28,10 +28,11 @@ module g_config character(MAX_PATH) :: ClimateDataPath='./hydrography/' character(MAX_PATH) :: TideForcingPath='./tide_forcing/' character(MAX_PATH) :: ResultPath='./result/' - character(MAX_PATH) :: RestartPath='same-as-result' + character(MAX_PATH) :: RestartInPath='same-as-result' + character(MAX_PATH) :: RestartOutPath='same-as-result' character(20) :: MeshId='NONE' namelist /paths/ MeshPath, ClimateDataPath, & - TideForcingPath, ResultPath, RestartPath, MeshId + TideForcingPath, ResultPath, RestartInPath, RestartOutPath, MeshId !_____________________________________________________________________________ ! *** restart_log *** diff --git a/src/icepack_drivers/icedrv_io.F90 b/src/icepack_drivers/icedrv_io.F90 index 7d8bb7c4d..d84a1007d 100644 --- a/src/icepack_drivers/icedrv_io.F90 +++ b/src/icepack_drivers/icedrv_io.F90 @@ -278,7 +278,7 @@ end subroutine init_io_icepack module subroutine init_restart_icepack(year, mesh) use mod_mesh - use g_config, only: runid, ResultPath + use g_config, only: runid, RestartOutPath use io_restart, only: ip_id, def_variable_2d, def_dim implicit none @@ -341,7 +341,7 @@ module subroutine init_restart_icepack(year, mesh) write(cyear,'(i4)') year ! Create an icepack restart file ! Only serial output implemented so far - ip_id%filename=trim(ResultPath)//trim(runid)//'.'//cyear//'.icepack.restart.nc' + ip_id%filename=trim(RestartOutPath)//trim(runid)//'.'//cyear//'.icepack.restart.nc' if (ip_id%is_in_use) return ip_id%is_in_use=.true. diff --git a/src/io_restart.F90 b/src/io_restart.F90 index de78d1f89..acd8f7d5a 100644 --- a/src/io_restart.F90 +++ b/src/io_restart.F90 @@ -250,16 +250,16 @@ subroutine read_initial_conditions(istep, nstart, ntotal, which_readr, ice, dyna ! compute current time based on what is written in fesom.clock file ctime=timeold+(dayold-1.)*86400 - raw_restart_dirpath = trim(RestartPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes) - raw_restart_infopath = trim(RestartPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes)//".info" - bin_restart_dirpath = trim(RestartPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes) - bin_restart_infopath = trim(RestartPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes)//".info" + raw_restart_dirpath = trim(RestartInPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes) + raw_restart_infopath = trim(RestartInPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes)//".info" + bin_restart_dirpath = trim(RestartInPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes) + bin_restart_infopath = trim(RestartInPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes)//".info" write(cyear,'(i4)') yearold - oce_path = trim(RestartPath)//trim(runid)//'.'//cyear//'.oce.restart.nc' - ice_path = trim(RestartPath)//trim(runid)//'.'//cyear//'.ice.restart.nc' + oce_path = trim(RestartInPath)//trim(runid)//'.'//cyear//'.oce.restart.nc' + ice_path = trim(RestartInPath)//trim(runid)//'.'//cyear//'.ice.restart.nc' #if defined(__recom) - bio_path = trim(RestartPath)//trim(runid)//'.'//cyear//'.bio.restart.nc' + bio_path = trim(RestartInPath)//trim(runid)//'.'//cyear//'.bio.restart.nc' #endif call ini_ocean_io(dynamics, tracers, partit, mesh) @@ -351,10 +351,10 @@ subroutine write_initial_conditions(istep, nstart, ntotal, ice, dynamics, tracer ! now for writing we need to change the paths for the restart files write(cyear,'(i4)') yearnew - oce_path = trim(ResultPath)//trim(runid)//'.'//cyear//'.oce.restart.nc' - ice_path = trim(ResultPath)//trim(runid)//'.'//cyear//'.ice.restart.nc' + oce_path = trim(RestartOutPath)//trim(runid)//'.'//cyear//'.oce.restart.nc' + ice_path = trim(RestartOutPath)//trim(runid)//'.'//cyear//'.ice.restart.nc' #if defined(__recom) - bio_path = trim(ResultPath)//trim(runid)//'.'//cyear//'.bio.restart.nc' + bio_path = trim(RestartOutPath)//trim(runid)//'.'//cyear//'.bio.restart.nc' #endif call ini_ocean_io(dynamics, tracers, partit, mesh) @@ -367,12 +367,12 @@ subroutine write_initial_conditions(istep, nstart, ntotal, ice, dynamics, tracer ! initialize directory for core dump restart if(.not. initialized_raw) then initialized_raw = .true. - raw_restart_dirpath = trim(ResultPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes) - raw_restart_infopath = trim(ResultPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes)//".info" + raw_restart_dirpath = trim(RestartOutPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes) + raw_restart_infopath = trim(RestartOutPath)//"fesom_raw_restart/np"//int_to_txt(partit%npes)//".info" if(raw_restart_length_unit /= "off") then if(partit%mype == RAW_RESTART_METADATA_RANK) then ! execute_command_line with mkdir sometimes fails, use a custom implementation around mkdir from C instead - call mkdir(trim(ResultPath)//"fesom_raw_restart") ! we have no mkdir -p, create the intermediate dirs separately + call mkdir(trim(RestartOutPath)//"fesom_raw_restart") ! we have no mkdir -p, create the intermediate dirs separately call mkdir(raw_restart_dirpath) end if call MPI_Barrier(partit%MPI_COMM_FESOM, mpierr) ! make sure the dir has been created before we continue... @@ -383,12 +383,12 @@ subroutine write_initial_conditions(istep, nstart, ntotal, ice, dynamics, tracer ! initialize directory for derived type binary restart if(.not. initialized_bin) then initialized_bin = .true. - bin_restart_dirpath = trim(ResultPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes) - bin_restart_infopath = trim(ResultPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes)//".info" + bin_restart_dirpath = trim(RestartOutPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes) + bin_restart_infopath = trim(RestartOutPath)//"fesom_bin_restart/np"//int_to_txt(partit%npes)//".info" if(bin_restart_length_unit /= "off") then if(partit%mype == RAW_RESTART_METADATA_RANK) then ! execute_command_line with mkdir sometimes fails, use a custom implementation around mkdir from C instead - call mkdir(trim(ResultPath)//"fesom_bin_restart") ! we have no mkdir -p, create the intermediate dirs separately + call mkdir(trim(RestartOutPath)//"fesom_bin_restart") ! we have no mkdir -p, create the intermediate dirs separately call mkdir(bin_restart_dirpath) end if call MPI_Barrier(partit%MPI_COMM_FESOM, mpierr) ! make sure the dir has been created before we continue... @@ -800,6 +800,7 @@ subroutine read_all_raw_restarts(mpicomm, mype) call MPI_Bcast(globalstep, 1, MPI_INTEGER, RAW_RESTART_METADATA_RANK, mpicomm, mpierr) open(newunit = fileunit, status = 'old', iostat = status, file = raw_restart_dirpath//'/'//mpirank_to_txt(mpicomm)//'.dump', form = 'unformatted') + if(status == 0) then call read_raw_restart_group(oce_files, fileunit) if(use_ice) call read_raw_restart_group(ice_files, fileunit)