Skip to content

Commit

Permalink
Merge pull request #1516 from GEOS-ESM/feature/bmauer/auto_rstskip_ex…
Browse files Browse the repository at this point in the history
…tdata

Automatic restart skip
  • Loading branch information
tclune authored May 18, 2022
2 parents 65f5cd6 + bfc585f commit b153dbd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Updated MAPL_CapGridComp to mark fields going to ExtData to not be checkpointed by components
- Add debug loggers for start/stop during stages in MAPL_Generic
- Handling for double precision input when retrieving single precision attributes
- Enable GCM run test in CircleCI (1-hour, no ExtData)
Expand Down
42 changes: 42 additions & 0 deletions generic/MAPL_Generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ module MAPL_GenericMod
public MAPL_GenericStateSave
public MAPL_GenericStateRestore
public MAPL_RootGcRetrieve
public MAPL_AddAttributeToFields

!BOP
! !PUBLIC TYPES:
Expand Down Expand Up @@ -341,6 +342,10 @@ module MAPL_GenericMod
module procedure MAPL_GetLogger_meta
end interface MAPL_GetLogger

interface MAPL_AddAttributeToFields
module procedure MAPL_AddAttributeToFields_I4
end interface


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

Expand Down Expand Up @@ -11334,4 +11339,41 @@ subroutine warn_empty(string, MPL, rc)
_RETURN(ESMF_SUCCESS)
end subroutine warn_empty

recursive subroutine MAPL_AddAttributeToFields_I4(gc,field_name,att_name,att_val,rc)
type(ESMF_GridComp), pointer, intent(inout) :: gc
character(len=*), intent(in) :: field_name
character(len=*), intent(in) :: att_name
integer(int32), intent(in) :: att_val
integer, optional, intent(out) :: rc

integer :: nc,i,status
type(MAPL_MetaComp), pointer :: state
type(ESMF_GridComp), pointer :: child_gc
type(ESMF_Field) :: field
type(ESMF_StateItem_Flag) :: item_type
type(ESMF_TypeKind_Flag) :: item_kind
integer :: item_count
logical :: is_present

call MAPL_GetObjectFromGC(gc,state,_RC)
call ESMF_StateGet(state%import_state,field_name,item_type,_RC)
if (item_type == ESMF_STATEITEM_FIELD) then
call ESMF_StateGet(state%import_state,field_name,field,_RC)
call ESMF_AttributeGet(field,name=att_name,isPresent=is_Present,_RC)
if (is_present) then
call ESMF_AttributeGet(field,name=att_name,typekind=item_kind,itemCount=item_count,_RC)
_ASSERT(item_kind == ESMF_TYPEKIND_I4,"attribute "//att_name//" in "//field_name//" is not I4")
_ASSERT(item_count==1,"attribute "//att_name//" in "//field_name//" is not a scalar")
end if
call ESMF_AttributeSet(field,name=att_name,value=att_val,_RC)
end if
nc = state%get_num_children()
do i=1,nc
child_gc => state%get_child_gridcomp(i)
call MAPL_AddAttributeToFields_I4(child_gc,field_name,att_name,att_val,_RC)
enddo

_RETURN(_SUCCESS)
end subroutine MAPL_AddAttributeToFields_I4

end module MAPL_GenericMod
6 changes: 4 additions & 2 deletions gridcomps/Cap/MAPL_CapGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)
call cap%initialize_history(rc=status)
_VERIFY(status)

call cap%initialize_extdata(rc=status)
call cap%initialize_extdata(root_gc,rc=status)
_VERIFY(status)

! Finally check is this is a regular replay
Expand Down Expand Up @@ -690,8 +690,9 @@ subroutine initialize_history(cap, rc)
end subroutine initialize_history


subroutine initialize_extdata(cap , rc)
subroutine initialize_extdata(cap , root_gc, rc)
class(MAPL_CapGridComp), intent(inout) :: cap
type (ESMF_GridComp), intent(inout), pointer :: root_gc
integer, optional, intent(out) :: rc
integer :: item_count, status
type (ESMF_StateItem_Flag), pointer :: item_types(:)
Expand Down Expand Up @@ -758,6 +759,7 @@ subroutine initialize_extdata(cap , rc)
if (item_types(i) == ESMF_StateItem_Field) then
call ESMF_StateGet(root_imports, item_names(i), field, rc = status)
_VERIFY(status)
call MAPL_AddAttributeToFields(root_gc,trim(item_names(i)),'RESTART',MAPL_RestartSkip,_RC)
call MAPL_StateAdd(state, field, rc = status)
_VERIFY(status)
else if (item_types(i) == ESMF_StateItem_FieldBundle) then
Expand Down

0 comments on commit b153dbd

Please sign in to comment.