Skip to content

Commit

Permalink
Merge pull request ESCOMP#249 from mvertens/feature/hist_bugfix
Browse files Browse the repository at this point in the history
bugfix for ESCOMP#247 and ESCOMP#243 
### Description of changes
This fixes the bug for ERI tests.
### Specific notes
This makes `hist_option` and `hist_n` for instantaneous history files for all components module variables with the name `hist_option_all_inst` and `hist_n_all_inst`.
Contributors other than yourself, if any: None
CMEPS Issues Fixed: ESCOMP#247 ESCOMP#243 
Are changes expected to change answers? No (bit-for-bit)
Any User Interface Changes (namelist or namelist defaults changes)? No
Testing performed:
Verified that failed test ERI.T62_g16.C1850ECO.cheyenne_intel.pop-ecosys now passes.
Hashes used for testing: CESM: cesm2_3_alpha07a (pre tag)
  • Loading branch information
mvertens authored Nov 3, 2021
2 parents 568f6c7 + 769825f commit 5dc55a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@
currently v0 refers to budgets using POP and v1 refers to budgets using MOM6
</desc>
<values>
<value>v0</value>
<value comp_ocn="mom">v1</value>
<value comp_ocn="pop">v0</value>
</values>
Expand Down
26 changes: 15 additions & 11 deletions mediator/med_phases_history_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ module med_phases_history_mod
private :: med_phases_history_fldbun_average

! ----------------------------
! Instantaneous history files datatypes/variables
! Instantaneous history files all components
! ----------------------------
character(CL) :: hist_option_all_inst ! freq_option setting (ndays, nsteps, etc)
integer :: hist_n_all_inst ! freq_n setting relative to freq_option

! ----------------------------
! Instantaneous history files datatypes/variables per component
! ----------------------------
type, public :: instfile_type
logical :: write_inst
Expand Down Expand Up @@ -144,8 +150,6 @@ subroutine med_phases_history_write(gcomp, rc)
type(ESMF_Clock) :: mclock
type(ESMF_Alarm) :: alarm
character(CS) :: alarmname
character(CL) :: hist_option ! freq_option setting (ndays, nsteps, etc)
integer :: hist_n ! freq_n setting relative to freq_option
character(CL) :: cvalue ! attribute string
logical :: isPresent
logical :: isSet
Expand Down Expand Up @@ -185,27 +189,27 @@ subroutine med_phases_history_write(gcomp, rc)
call NUOPC_CompAttributeGet(gcomp, name='history_option', isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
call NUOPC_CompAttributeGet(gcomp, name='history_option', value=hist_option, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name='history_option', value=hist_option_all_inst, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeGet(gcomp, name='history_n', value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) hist_n
read(cvalue,*) hist_n_all_inst
else
! If attribute is not present - don't write history output
hist_option = 'none'
hist_n = -999
hist_option_all_inst = 'none'
hist_n_all_inst = -999
end if

! Set alarm name and initialize clock and alarm for instantaneous history output
! The alarm for the full history write is set on the mediator clock not as a separate alarm
if (hist_option /= 'none' .and. hist_option /= 'never') then
if (hist_option_all_inst /= 'none' .and. hist_option_all_inst /= 'never') then

! Initialize alarm on mediator clock for instantaneous mediator history output for all variables
call NUOPC_ModelGet(gcomp, modelClock=mclock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_ClockGet(mclock, startTime=starttime, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call med_time_alarmInit(mclock, alarm, option=hist_option, opt_n=hist_n, &
call med_time_alarmInit(mclock, alarm, option=hist_option_all_inst, opt_n=hist_n_all_inst, &
reftime=starttime, alarmname=alarmname, rc=rc)
call ESMF_AlarmSet(alarm, clock=mclock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -221,14 +225,14 @@ subroutine med_phases_history_write(gcomp, rc)
! Write diagnostic info
if (mastertask) then
write(logunit,'(a,2x,i8)') trim(subname) // " initialized history alarm "//&
trim(alarmname)//" with option "//trim(hist_option)//" and frequency ",hist_n
trim(alarmname)//" with option "//trim(hist_option_all_inst)//" and frequency ",hist_n_all_inst
end if
end if
first_time = .false.
end if

write_now = .false.
if (hist_option /= 'none' .and. hist_option /= 'never') then
if (hist_option_all_inst /= 'none' .and. hist_option_all_inst /= 'never') then
call NUOPC_ModelGet(gcomp, modelClock=mclock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_ClockGetAlarm(mclock, alarmname=trim(alarmname), alarm=alarm, rc=rc)
Expand Down

0 comments on commit 5dc55a8

Please sign in to comment.