Skip to content

Commit

Permalink
Merge pull request #1 from jedwards4b/jedwards/neon_wrapper_cime
Browse files Browse the repository at this point in the history
add cime capabilities
  • Loading branch information
negin513 authored Aug 6, 2021
2 parents 4435920 + fae52e9 commit 8d57f29
Show file tree
Hide file tree
Showing 4 changed files with 341 additions and 514 deletions.
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local_path = components/cmeps
required = True

[cdeps]
tag = cdeps0.12.14
tag = cdeps0.12.18
protocol = git
repo_url = https://github.com/ESCOMP/CDEPS.git
local_path = components/cdeps
Expand Down
3 changes: 3 additions & 0 deletions python/ctsm/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def add_cime_lib_to_path(standalone_only=False):
cime_lib_path = os.path.join(cime_path,
'scripts', 'lib')
prepend_to_python_path(cime_lib_path)
cime_lib_path = os.path.join(cime_path,
'scripts', 'Tools')
prepend_to_python_path(cime_lib_path)
return cime_path

# ========================================================================
Expand Down
60 changes: 32 additions & 28 deletions src/cpl/nuopc/lnd_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ module lnd_comp_nuopc
character(len=*) , parameter :: continue_run = 'continue'
character(len=*) , parameter :: branch_run = 'branch'

logical :: write_restart_at_endofrun = .false.

character(len=*) , parameter :: u_FILE_u = &
__FILE__

Expand Down Expand Up @@ -356,7 +358,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: nsrest ! ctsm restart type
integer :: lbnum ! input to memory diagnostic
integer :: shrlogunit ! original log unit
type(bounds_type) :: bounds ! bounds
integer :: n, ni, nj ! Indices
character(len=CL) :: cvalue ! config data
character(len=CL) :: meshfile_mask ! filename of mesh file with land mask
Expand All @@ -369,12 +370,14 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
integer :: scol_mask ! single-column mask
real(r8) :: scol_spval ! single-column special value to indicate it isn't set
character(len=CL) :: single_column_lnd_domainfile ! domain filename to use for single-column mode (i.e. SCAM)
type(bounds_type) :: bounds ! bounds
type(ESMF_Field) :: lfield ! Land field read in
character(CL) ,pointer :: lfieldnamelist(:) => null() ! Land field namelist item sent with land field
integer :: fieldCount ! Number of fields on export state
integer :: rank ! Rank of field (1D or 2D)
real(r8), pointer :: fldptr1d(:) ! 1D field pointer
real(r8), pointer :: fldptr2d(:,:) ! 2D field pointer
logical :: isPresent, isSet
character(len=CL) :: model_version ! Model version
character(len=CL) :: hostname ! hostname of machine running on
character(len=CL) :: username ! user running the model
Expand Down Expand Up @@ -563,6 +566,12 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! Set model clock in lnd_comp_shr
model_clock = clock

call NUOPC_CompAttributeGet(gcomp, name="write_restart_at_endofrun", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
if (trim(cvalue) .eq. '.true.') write_restart_at_endofrun = .true.
end if
print *,__FILE__,__LINE__,write_restart_at_endofrun
! ---------------------
! Initialize first phase of ctsm
! ---------------------
Expand Down Expand Up @@ -814,22 +823,6 @@ subroutine ModelAdvance(gcomp, rc)
end if
call update_rad_dtime(doalb)

!--------------------------------
! Determine if time to write restart
!--------------------------------

call ESMF_ClockGetAlarm(clock, alarmname='alarm_restart', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
rstwr = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
rstwr = .false.
endif

!--------------------------------
! Determine if time to stop
!--------------------------------
Expand All @@ -846,6 +839,25 @@ subroutine ModelAdvance(gcomp, rc)
nlend = .false.
endif

!--------------------------------
! Determine if time to write restart
!--------------------------------
rstwr = .false.
if (nlend .and. write_restart_at_endofrun) then
rstwr = .true.
else
call ESMF_ClockGetAlarm(clock, alarmname='alarm_restart', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (ESMF_AlarmIsCreated(alarm, rc=rc)) then
if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
rstwr = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif
endif
end if

!--------------------------------
! Run CTSM
!--------------------------------
Expand Down Expand Up @@ -966,7 +978,6 @@ subroutine ModelSetRunClock(gcomp, rc)
character(len=256) :: stop_option ! Stop option units
integer :: stop_n ! Number until stop interval
integer :: stop_ymd ! Stop date (YYYYMMDD)
integer :: stop_tod ! Stop time of day (seconds)
type(ESMF_ALARM) :: stop_alarm
character(len=128) :: name
integer :: alarmcount
Expand Down Expand Up @@ -1005,7 +1016,7 @@ subroutine ModelSetRunClock(gcomp, rc)

call ESMF_GridCompGet(gcomp, name=name, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_LogWrite(subname//'setting alarms for ' // trim(name), ESMF_LOGMSG_INFO)
call ESMF_LogWrite(subname//'setting alarms for' // trim(name), ESMF_LOGMSG_INFO)

!----------------
! Restart alarm
Expand Down Expand Up @@ -1045,17 +1056,10 @@ subroutine ModelSetRunClock(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) stop_ymd

call NUOPC_CompAttributeGet(gcomp, name="stop_tod", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) stop_tod

call alarmInit(mclock, &
alarm = stop_alarm, &
option = stop_option, &
call alarmInit(mclock, stop_alarm, stop_option, &
opt_n = stop_n, &
opt_ymd = stop_ymd, &
opt_tod = stop_tod, &
RefTime = mcurrTime, &
RefTime = mcurrTime, &
alarmname = 'alarm_stop', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
Loading

0 comments on commit 8d57f29

Please sign in to comment.