Skip to content

Commit a6d5ead

Browse files
darianboggstclune
andauthored
Add TimeAccumulate with unit tests. (#4869)
* Add TimeAccumulate with unit tests. * Add TimeAccumulate with unit tests. * Remove period calculation; fix update procedures * Move FileIOSharedMod, NCIOMod, MAPL_LocStreamMod to base3g/; re-export through MAPL umbrella (#4882) * Extend mapl3g_FileIO WRITE_PARALLEL with scalar/1d integer and real overloads (refs #4879) * Move FileIOSharedMod and NCIOMod to base3g/, re-export through MAPL umbrella (refs #4874, #4879) - Move FileIOShared.F90 and NCIO.F90 from base/ to base3g/ with temporary internal module names (mapl_FileIOShared, mapl_NCIO) - Leave thin compatibility wrappers in base/ under original module names (FileIOSharedMod, NCIOMod) so existing callers are unaffected - Copy write_parallel.H and read_parallel.H to base3g/include/ - Update base3g/CMakeLists.txt with new sources and dependencies - Re-export ArrDescr, ArrDescrInit, ArrDescrSet, MAPL_VarRead, MAPL_VarWrite, MAPL_NCIOGetFileType, MAPL_IOGetNonDimVars, MAPL_IOCountNonDimVars, MAPL_IOChangeRes, MAPL_IOCountLevels through mapl_base3g so they are available via 'use MAPL' * Move MAPL_LocStreamMod to base3g/ (module mapl_LocStreamMod_impl); leave thin wrapper in base/ (refs #4874) * Remove base/ thin wrappers for FileIOSharedMod, NCIOMod, MAPL_LocStreamMod (closes #4874) (#4883) * Remove base/ thin wrappers for FileIOSharedMod, NCIOMod, MAPL_LocStreamMod; move c_mapl_locstream_F.c to base3g/ (closes #4874) * Drop NCIOMod and MAPL_LocStreamMod from MAPL2 — symbols no longer needed there (refs #4874) * Add mapl2-migration skill documenting iterative PR process for base/ to base3g/ migrations * Update mapl2-migration skill: always rebase onto target branch before pushing/opening a PR * Remove orphaned write_parallel.H and read_parallel.H from base/ (now live in base3g/include/) (refs #4874) * Remove orphaned GetPointer.H from base/ — no longer used (refs #4874) * Remove orphaned GetFieldArray.H from base/ — no longer used (refs #4874) * Add TimeAccumulate with unit tests. * Remove period calculation; fix update procedures * Add TimeAccumulate with unit tests. * Fix two bugs with gfortran in pfunit tests. * Delete stale conflict markers. --------- Co-authored-by: Tom Clune <thomas.l.clune@nasa.gov>
1 parent d6eaecd commit a6d5ead

5 files changed

Lines changed: 939 additions & 5 deletions

File tree

gridcomps/StatisticsGridComp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(srcs
55
StatisticsVector.F90
66
NullStatistic.F90
77
TimeAverage.F90
8+
TimeAccumulate.F90
89
TimeMin.F90
910
TimeMax.F90
1011
StatisticsGridComp.F90
@@ -16,5 +17,5 @@ esma_add_library(${this}
1617
SRCS ${srcs}
1718
DEPENDENCIES MAPL MAPL.utilities TYPE SHARED)
1819

19-
#add_subdirectory(tests EXCLUDE_FROM_ALL)
20+
add_subdirectory(tests)
2021

gridcomps/StatisticsGridComp/StatisticsGridComp.F90

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module mapl3g_StatisticsGridComp
1313
use mapl3g_TimeAverage
1414
use mapl3g_TimeMin
1515
use mapl3g_TimeMax
16+
use mapl3g_TimeAccumulate
1617
use mapl3g_State_API
1718
use pflogger, only: Logger
1819
use mapl_OS
@@ -79,7 +80,6 @@ subroutine advertise_item(gridcomp, iter, rc)
7980
type(esmf_HConfigIter), intent(in) :: iter
8081
integer, optional, intent(out) :: rc
8182

82-
type(esmf_TimeInterval) :: period
8383
character(:), allocatable :: action, name
8484
type(esmf_StateItem_Flag) :: itemtype
8585
integer :: status
@@ -94,23 +94,25 @@ subroutine advertise_item(gridcomp, iter, rc)
9494
call MAPL_GridCompAddVarSpec(gridcomp, varspec, _RC)
9595
select case (action)
9696
case ('average')
97-
period = mapl_HConfigAsTimeInterval(hconfig, keystring='period', _RC)
9897
varspec = make_VariableSpec(ESMF_STATEINTENT_EXPORT, name, &
9998
has_deferred_aspects=.true., _RC)
10099
call MAPL_GridCompAddVarSpec(gridcomp, varspec, _RC)
101100
call advertise_time_average_internal_fields(gridcomp, name, _RC)
102101
case ('min')
103-
period = mapl_HConfigAsTimeInterval(hconfig, keystring='period', _RC)
104102
varspec = make_VariableSpec(ESMF_STATEINTENT_EXPORT, name, &
105103
has_deferred_aspects=.true., _RC)
106104
call MAPL_GridCompAddVarSpec(gridcomp, varspec, _RC)
107105
call advertise_time_min_internal_fields(gridcomp, name, _RC)
108106
case ('max')
109-
period = mapl_HConfigAsTimeInterval(hconfig, keystring='period', _RC)
110107
varspec = make_VariableSpec(ESMF_STATEINTENT_EXPORT, name, &
111108
has_deferred_aspects=.true., _RC)
112109
call MAPL_GridCompAddVarSpec(gridcomp, varspec, _RC)
113110
call advertise_time_max_internal_fields(gridcomp, name, _RC)
111+
case ('accumulate')
112+
varspec = make_VariableSpec(ESMF_STATEINTENT_EXPORT, name, &
113+
has_deferred_aspects=.true., _RC)
114+
call MAPL_GridCompAddVarSpec(gridcomp, varspec, _RC)
115+
call advertise_time_accumulate_internal_fields(gridcomp, name, _RC)
114116
case default
115117
_FAIL('unsupported action: '//action)
116118
end select
@@ -201,6 +203,9 @@ function make_item(name, iter, clock, rc) result(stat)
201203
case ('max')
202204
deallocate(stat) ! gfortran workaround
203205
stat = make_max_stat(name, iter, alarm, _RC)
206+
case ('accumulate')
207+
deallocate(stat) ! gfortran workaround
208+
stat = make_accumulate_stat(name, iter, alarm, _RC)
204209
case default
205210
_FAIL('unsupported statistics class: '//action)
206211
end select
@@ -263,6 +268,25 @@ function make_max_stat(name, iter, alarm, rc) result(max_stat)
263268
end function make_max_stat
264269

265270

271+
function make_accumulate_stat(name, iter, alarm, rc) result(accum_stat)
272+
type(TimeAccumulate) :: accum_stat
273+
character(*), intent(in) :: name
274+
type(esmf_HConfigIter), intent(in) :: iter
275+
type(SimpleAlarm), intent(in) :: alarm
276+
integer, optional, intent(out) :: rc
277+
278+
integer :: status
279+
type(esmf_Field) :: f_in, f_out
280+
281+
call esmf_StateGet(importState, itemName=name, field=f_in, _RC)
282+
call esmf_StateGet(exportState, itemName=name, field=f_out, _RC)
283+
284+
accum_stat = TimeAccumulate(gridcomp=gridcomp, f=f_in, accum_f=f_out, alarm=alarm, _RC)
285+
286+
_RETURN(_SUCCESS)
287+
_UNUSED_DUMMY(iter)
288+
end function make_accumulate_stat
289+
266290
function make_alarm(clock, iter, rc) result(alarm)
267291
type(SimpleAlarm) :: alarm
268292
type(esmf_Clock), intent(in) :: clock

0 commit comments

Comments
 (0)