Skip to content

Commit 00a87c9

Browse files
authored
Merge pull request #66 from samsrabin/standardize-time-metadata
Standardize time metadata
2 parents 330574f + c023afe commit 00a87c9

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

docs/ChangeLog.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
<hr>
2+
# Tag name: mosart1.1.08
3+
### Originator(s): samrabin
4+
### Date: Jan 14, 2025
5+
### One-line Summary: Standardize time metadata
6+
7+
Standardizes a dimension name of output variable time_bounds, as well as attributes for that plus mcdate, mcsec, mdcur, and mscur.
8+
9+
Contributors: Adam Phillips, Erik Kluzek
10+
11+
Fixes ESCOMP/MOSART#53
12+
Contributes to https://github.com/ESCOMP/CTSM/issues/1693
13+
14+
Testing: standard testing (ekluzek)
15+
izumi ---- OK
16+
derecho -- OK
17+
18+
See https://github.com/ESCOMP/MOSART/pull/66 for more details
19+
Contributes to https://github.com/ESCOMP/CTSM/pull/2052
20+
121
<hr>
222
# Tag name: mosart1.1.07
323
### Originator(s): erik

src/cpl/nuopc/rof_import_export.F90

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc)
113113
call fldlist_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub')
114114
call fldlist_add(fldsToRof_num, fldsToRof, 'Flrl_rofi')
115115
call fldlist_add(fldsToRof_num, fldsToRof, 'Flrl_irrig')
116-
if ( ctl%rof_from_glc ) then
117-
call fldlist_add(fldsToRof_num, fldsToRof, 'Fgrg_rofl') ! liq runoff from glc
118-
call fldlist_add(fldsToRof_num, fldsToRof, 'Fgrg_rofi') ! ice runoff from glc
119-
end if
116+
call fldlist_add(fldsToRof_num, fldsToRof, 'Fgrg_rofl') ! liq runoff from glc
117+
call fldlist_add(fldsToRof_num, fldsToRof, 'Fgrg_rofi') ! ice runoff from glc
120118

121119
do n = 1,fldsToRof_num
122120
call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, &

src/riverroute/mosart_histfile.F90

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module mosart_histfile
151151
type(file_desc_t), target :: nfid(max_tapes) ! file ids
152152
type(file_desc_t), target :: ncid_hist(max_tapes) ! file ids for history restart files
153153
integer :: time_dimid ! time dimension id
154-
integer :: hist_interval_dimid ! time bounds dimension id
154+
integer :: nbnd_dimid ! time bounds dimension id
155155
integer :: strlen_dimid ! string dimension id
156156
!-----------------------------------------------------------------------
157157

@@ -697,7 +697,7 @@ subroutine htape_create (t, histrest)
697697
call ncd_defdim(lnfid, 'string_length', 8, strlen_dimid)
698698

699699
if ( .not. lhistrest )then
700-
call ncd_defdim(lnfid, 'hist_interval', 2, hist_interval_dimid)
700+
call ncd_defdim(lnfid, 'nbnd', 2, nbnd_dimid)
701701
call ncd_defdim(lnfid, 'time', ncd_unlimited, time_dimid)
702702
if (mainproc)then
703703
write(iulog,*) trim(subname),' : Successfully defined netcdf history file ',t
@@ -766,7 +766,7 @@ subroutine htape_timeconst(t, mode)
766766

767767
dim1id(1) = time_dimid
768768
str = 'days since ' // basedate // " " // basesec
769-
if (tape(t)%hlist(1)%avgflag /= 'I') then ! NOT instantaneous fields tape
769+
if (avgflag_pertape(t) /= 'I') then ! NOT instantaneous fields tape
770770
step_or_bounds = 'time_bounds'
771771
long_name = 'time at exact middle of ' // step_or_bounds
772772
call ncd_defvar(nfid(t), 'time', tape(t)%ncprec, 1, dim1id, varid, &
@@ -790,22 +790,28 @@ subroutine htape_timeconst(t, mode)
790790
long_name = 'current date (YYYYMMDD) at end of ' // step_or_bounds
791791
call ncd_defvar(nfid(t) , 'mcdate', ncd_int, 1, dim1id , varid, &
792792
long_name = long_name)
793+
call ncd_putatt(nfid(t), varid, 'calendar', caldesc)
793794
long_name = 'current seconds of current date at end of ' // step_or_bounds
794795
call ncd_defvar(nfid(t) , 'mcsec' , ncd_int, 1, dim1id , varid, &
795796
long_name = long_name, units='s')
797+
call ncd_putatt(nfid(t), varid, 'calendar', caldesc)
796798
long_name = 'current day (from base day) at end of ' // step_or_bounds
797799
call ncd_defvar(nfid(t) , 'mdcur' , ncd_int, 1, dim1id , varid, &
798800
long_name = long_name)
801+
call ncd_putatt(nfid(t), varid, 'calendar', caldesc)
799802
long_name = 'current seconds of current day at end of ' // step_or_bounds
800803
call ncd_defvar(nfid(t) , 'mscur' , ncd_int, 1, dim1id , varid, &
801804
long_name = long_name)
805+
call ncd_putatt(nfid(t), varid, 'calendar', caldesc)
802806
call ncd_defvar(nfid(t) , 'nstep' , ncd_int, 1, dim1id , varid, &
803807
long_name = 'time step')
804808

805-
dim2id(1) = hist_interval_dimid; dim2id(2) = time_dimid
806-
if (tape(t)%hlist(1)%avgflag /= 'I') then ! NOT instantaneous fields tape
809+
dim2id(1) = nbnd_dimid; dim2id(2) = time_dimid
810+
if (avgflag_pertape(t) /= 'I') then ! NOT instantaneous fields tape
807811
call ncd_defvar(nfid(t), 'time_bounds', ncd_double, 2, dim2id, varid, &
808-
long_name = 'history time interval endpoints')
812+
long_name = 'time interval endpoints', &
813+
units=str)
814+
call ncd_putatt(nfid(t), varid, 'calendar', caldesc)
809815
end if
810816

811817
dim2id(1) = strlen_dimid; dim2id(2) = time_dimid
@@ -840,7 +846,7 @@ subroutine htape_timeconst(t, mode)
840846

841847
timedata(1) = tape(t)%begtime ! beginning time
842848
timedata(2) = mdcur + mscur / secspday ! end time
843-
if (tape(t)%hlist(1)%avgflag /= 'I') then ! NOT instantaneous fields tape
849+
if (avgflag_pertape(t) /= 'I') then ! NOT instantaneous fields tape
844850
time = (timedata(1) + timedata(2)) * 0.5_r8
845851
call ncd_io('time_bounds', timedata, 'write', nfid(t), nt=tape(t)%ntimes)
846852
else

0 commit comments

Comments
 (0)