Skip to content

Commit

Permalink
merge to main, add timestamp to rpointer file name
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Jun 26, 2024
1 parent 94928de commit 57290e2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions mediator/med_phases_restart_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module med_phases_restart_mod
!-----------------------------------------------------------------------------

use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8
use med_constants_mod , only : dbug_flag => med_constants_dbug_flag
! use med_constants_mod , only : dbug_flag => med_constants_dbug_flag
use med_utils_mod , only : chkerr => med_utils_ChkErr
use med_internalstate_mod , only : maintask, logunit, InternalState
use med_internalstate_mod , only : ncomps, compname, compocn, complnd, compwav
Expand All @@ -25,7 +25,7 @@ module med_phases_restart_mod
logical :: write_restart_at_endofrun = .false.
logical :: whead(2) = (/.true. , .false./)
logical :: wdata(2) = (/.false., .true. /)

integer, parameter:: dbug_flag = 2
character(*), parameter :: u_FILE_u = &
__FILE__

Expand Down Expand Up @@ -302,7 +302,7 @@ subroutine med_phases_restart_write(gcomp, rc)
trim(nexttimestr),'.nc'

if (maintask) then
restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag)
restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag)//'.'//trim(nexttimestr)
call ESMF_LogWrite(trim(subname)//" write rpointer file = "//trim(restart_pfile), ESMF_LOGMSG_INFO)
open(newunit=unitn, file=restart_pfile, form='FORMATTED')
write(unitn,'(a)') trim(restart_file)
Expand Down Expand Up @@ -547,14 +547,21 @@ subroutine med_phases_restart_read(gcomp, rc)
endif

! Get the restart file name from the pointer file
restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag)
restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag)//'.'//trim(currtimestr)
if (maintask) then
call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), ESMF_LOGMSG_INFO)
open(newunit=unitn, file=restart_pfile, form='FORMATTED', status='old', iostat=ierr)

if (ierr < 0) then
call ESMF_LogWrite(trim(subname)//' rpointer file open returns error', ESMF_LOGMSG_INFO)
rc=ESMF_Failure
return
! try without currtimestr
restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag)
call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), ESMF_LOGMSG_INFO)
open(newunit=unitn, file=restart_pfile, form='FORMATTED', status='old', iostat=ierr)
if(ierr < 0) then
call ESMF_LogWrite(trim(subname)//' rpointer file open returns error', ESMF_LOGMSG_INFO)
rc=ESMF_Failure
return
end if
end if
read (unitn,'(a)', iostat=ierr) restart_file
if (ierr < 0) then
Expand Down

0 comments on commit 57290e2

Please sign in to comment.