Skip to content

Commit

Permalink
separate RestartInPath and RestartOutPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Beyer committed Sep 24, 2024
1 parent 754a6b4 commit 9abad7d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/gen_model_setup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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


! ==========
Expand Down
4 changes: 2 additions & 2 deletions src/gen_modules_clock.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/gen_modules_config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***
Expand Down
4 changes: 2 additions & 2 deletions src/icepack_drivers/icedrv_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
33 changes: 17 additions & 16 deletions src/io_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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...
Expand All @@ -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...
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9abad7d

Please sign in to comment.