Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp in rpointer name #1147

Open
wants to merge 6 commits into
base: cam_development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cime_config/SystemTests/plb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files
from CIME.utils import append_testlog
from CIME.status import append_testlog

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion cime_config/SystemTests/sct.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files
from CIME.test_status import *
from CIME.utils import append_testlog
from CIME.status import append_testlog


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion cime_config/SystemTests/sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files
from CIME.utils import append_testlog
from CIME.status import append_testlog


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion cime_config/SystemTests/tmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.system_tests_common import SystemTestsCommon
from CIME.test_status import *
from CIME.utils import append_testlog
from CIME.status import append_testlog
from CIME.baselines.performance import get_latest_cpl_logs
import glob, gzip

Expand Down
28 changes: 18 additions & 10 deletions src/control/cam_initfiles.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ module cam_initfiles

real(r8), public, protected :: scale_dry_air_mass = 0.0_r8 ! Toggle and target avg air mass for MPAS dycore

! The restart pointer file contains name of most recently written primary restart file.
! The contents of this file are updated by cam_write_restart as new restart files are written.
character(len=cl), public, protected :: rest_pfile

! Filename for initial restart file.
character(len=cl) :: restart_file = ' '

Expand All @@ -68,16 +64,20 @@ subroutine cam_initfiles_readnl(nlfile)
use spmd_utils, only: mpicom, mstrid=>masterprocid, mpir8=>mpi_real8, &
mpichar=>mpi_character, mpi_logical
use cam_instance, only: inst_suffix

use filenames, only: interpret_filename_spec

character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input

! Local variables
integer :: unitn, ierr

character(len=cl) :: locfn
logical :: filefound
integer :: xtype
integer(pio_offset_kind) :: slen
logical :: found

! The restart pointer file contains name of most recently written primary restart file.
character(len=cl) :: rest_pfile

character(len=*), parameter :: sub = 'cam_initfiles_readnl'

Expand Down Expand Up @@ -112,18 +112,26 @@ subroutine cam_initfiles_readnl(nlfile)
call mpi_bcast(scale_dry_air_mass, 1, mpir8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": ERROR: mpi_bcast: scale_dry_air_mass")

! Set pointer file name based on instance suffix
rest_pfile = './rpointer.atm' // trim(inst_suffix)

! Set name of primary restart file
if (restart_run) then
! Read name of restart file from pointer file
if (masterproc) then
rest_pfile = interpret_filename_spec("rpointer.cam"//trim(inst_suffix)//".%y-%m-%d-%s", prev=.true.)
inquire(file=trim(rest_pfile),exist=found)
if(.not. found) then
write(iulog, "INFO : rpointer file "//trim(rest_pfile)//" not found.")
rest_pfile = "rpointer.cam"//trim(inst_suffix)
write(iulog, " Try looking for "//trim(rest_pfile)//" ...")
inquire(file=trim(rest_pfile),exist=found)
if(.not. found) then
call endrun(sub // ': ERROR: rpointer file: '//trim(rest_pfile) // ' not found')
endif
endif
unitn = getunit()
call opnfil(rest_pfile, unitn, 'f', status="old")
read (unitn, '(a)', iostat=ierr) restart_file
if (ierr /= 0) then
call endrun(sub // ': ERROR: reading rpointer file')
call endrun(sub // ': ERROR: reading rpointer file: '//trim(rest_pfile))
end if
close(unitn)
call freeunit(unitn)
Expand Down
35 changes: 16 additions & 19 deletions src/control/cam_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,8 @@ subroutine cam_write_restart(cam_in, cam_out, dyn_out, pbuf2d, &
! (%c = caseid, $y = year, $m = month, $d = day, $s = seconds in day, %t = number)
rfilename_spec = '%c.cam' // trim(inst_suffix) //'.r.%y-%m-%d-%s.nc'

if (present(yr_spec).and.present(mon_spec).and.present(day_spec).and.present(sec_spec)) then
fname = interpret_filename_spec( rfilename_spec, &
yr_spec=yr_spec, mon_spec=mon_spec, day_spec=day_spec, sec_spec= sec_spec )
else
fname = interpret_filename_spec( rfilename_spec )
end if
fname = interpret_filename_spec( rfilename_spec, &
yr_spec=yr_spec, mon_spec=mon_spec, day_spec=day_spec, sec_spec= sec_spec )

call cam_pio_createfile(fh, trim(fname), 0)
ierr = cam_pio_set_fill(fh)
Expand All @@ -132,38 +128,39 @@ subroutine cam_write_restart(cam_in, cam_out, dyn_out, pbuf2d, &
call ionosphere_write_restart(fh)
call write_restart_physics(fh, cam_in, cam_out, pbuf2d)

if (present(yr_spec).and.present(mon_spec).and.&
present(day_spec).and.present(sec_spec)) then
call write_restart_history(fh, yr_spec=yr_spec, mon_spec=mon_spec, &
day_spec=day_spec, sec_spec= sec_spec )
else
call write_restart_history(fh)
end if
call write_restart_history(fh, yr_spec=yr_spec, mon_spec=mon_spec, &
day_spec=day_spec, sec_spec= sec_spec )

! Close the primary restart file
call pio_closefile(fh)

! Update the restart pointer file
call write_rest_pfile(fname)
call write_rest_pfile(fname, yr_spec=yr_spec, mon_spec=mon_spec, &
day_spec=day_spec, sec_spec= sec_spec )

end subroutine cam_write_restart

!========================================================================================

subroutine write_rest_pfile(restart_file)
subroutine write_rest_pfile(restart_file, yr_spec, mon_spec, day_spec, sec_spec)

! Write the restart pointer file

use cam_initfiles, only: rest_pfile

use cam_instance, only: inst_suffix
use filenames, only: interpret_filename_spec
character(len=*), intent(in) :: restart_file
integer, optional, intent(in) :: yr_spec ! Simulation year
integer, optional, intent(in) :: mon_spec ! Simulation month
integer, optional, intent(in) :: day_spec ! Simulation day
integer, optional, intent(in) :: sec_spec ! Seconds into current simulation day

integer :: nsds, ierr
character(len=CL) :: rest_pfile
character(len=*), parameter :: sub='write_rest_pfile'
!---------------------------------------------------------------------------

if (masterproc) then

rest_pfile = interpret_filename_spec('rpointer.cam'//trim(inst_suffix)//'.'//'%y-%m-%d-%s',&
yr_spec=yr_spec, mon_spec=mon_spec, day_spec=day_spec, sec_spec= sec_spec )
nsds = getunit()
call opnfil(rest_pfile, nsds, 'f')
rewind nsds
Expand Down
7 changes: 5 additions & 2 deletions src/cpl/nuopc/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1967,22 +1967,25 @@ subroutine cam_write_clockrest( clock, yr_spec, mon_spec, day_spec, sec_spec, rc
call shr_cal_ymd2date(yy,mm,dd,start_ymd)

call ESMF_TimeGet( nextTime, yy=yy, mm=mm, dd=dd, s=curr_tod, rc=rc )
!call ESMF_TimeGet( currTime, yy=yy, mm=mm, dd=dd, s=curr_tod, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_cal_ymd2date(yy,mm,dd,curr_ymd)

! Open clock info restart dataset
restart_file = interpret_filename_spec( '%c.cpl.r.%y-%m-%d-%s.nc', &
yr_spec=yr_spec, mon_spec=mon_spec, day_spec=day_spec, sec_spec= sec_spec )

if (masterproc) then
restart_pfile = interpret_filename_spec('rpointer.cpl.%y-%m-%d-%s',&
yr_spec=yr_spec, mon_spec=mon_spec, day_spec=day_spec, sec_spec= sec_spec )
Comment on lines +1979 to +1980
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restart_pfile is set but not used. Is this for a future need when the coupler external is updated?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out this bug, it should replace 'rpointer.cpl' below


write(iulog,*) " In this configuration, there is no mediator"
write(iulog,*) " Normally, the mediator restart file provides the restart time info"
write(iulog,*) " In this case, CAM will create the rpointer.cpl and cpl restart file"
write(iulog,*) " containing this information"
write(iulog,*) " writing rpointer file for driver clock info, rpointer.cpl"
write(iulog,*) " writing restart clock info for driver= "//trim(restart_file)
open(newunit=unitn, file='rpointer.cpl', form='FORMATTED')
open(newunit=unitn, file=trim(restart_pfile), form='FORMATTED')
write(unitn,'(a)') trim(restart_file)
close(unitn)
endif
Expand Down
Loading