Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_State), | intent(in) | :: | State | |||
character(len=*), | intent(in) | :: | FieldName(:) | |||
type(ESMF_FieldBundle), | intent(inout) | :: | Bundle | |||
character(len=*), | intent(in), | optional | :: | FieldAlias(:) | ||
integer, | intent(out), | optional | :: | rc |
subroutine ESMFL_StateGetField(State, FieldName, Bundle, FieldAlias, RC) type(ESMF_State), intent(IN ) :: State character(len=*), intent(IN ) :: FieldName(:) type(ESMF_FieldBundle), intent(INOUT) :: Bundle character(len=*), optional, intent(IN ) :: FieldAlias(:) integer, optional, intent(OUT) :: rc integer :: status character(len=ESMF_MAXSTR) :: NameInBundle character(len=ESMF_MAXSTR) :: NameInState type(ESMF_Field) :: Bundlefield type(ESMF_Field) :: Statefield integer :: I logical :: NotInState logical :: NeedNewField type(ESMF_StateItem_Flag) :: itemType logical :: isPresent ! integer :: gridRank ! Adds fields from a state to a bundle. If a field ! is not in the state, it adds a dummy field. It fails ! if it tries to add a dummy field to an empty bundle, ! since it does not know what grid to use in the dummy. ! The name of the field in the bundle can be reset with ! FieldAlias RequestedFields: do i=1,size(FIELDNAME) NameInState = FieldName (I) if(present(FieldAlias)) then NameInBundle = FieldAlias(I) else NameInBundle = NameInState end if ! Make sure field is not in bundle call ESMF_FieldBundleGet(BUNDLE, FIELDNAME=NameInBundle, isPresent=isPresent, rc=STATUS) _VERIFY(STATUS) _ASSERT(.not. isPresent, trim(NameInBundle) // ' found in bundle.') ! Get Field from State call ESMF_StateGet (STATE, NameInState, itemType=itemType, RC=STATUS) _VERIFY(STATUS) if (itemType /= ESMF_STATEITEM_FIELD) then NotInState = .TRUE. else NotInState = .FALSE. call ESMF_StateGet (STATE, NameInState, StateFIELD, RC=STATUS) _VERIFY(STATUS) end if NeedNewField = NotInState .or. (NameInState/=NameInBundle) if (.not. NotInState) then call MAPL_AllocateCoupling(stateField, rc=status) _VERIFY(STATUS) end if if(NeedNewField) then ! Define Grid and Array for new field if(NotInState) then ! Create a new empty field BundleField = ESMF_FieldEmptyCreate(name=NameInBundle, rc=status) _VERIFY(STATUS) else ! Use the grid and array in the State Field, just rename it BundleField = MAPL_FieldCreate(stateField, name=NameInBundle, RC=STATUS) _VERIFY(STATUS) end if else BundleField = StateField end if call MAPL_FieldBundleAdd(BUNDLE, bundleField, rc=STATUS) _VERIFY(STATUS) end do RequestedFields _RETURN(ESMF_SUCCESS) end subroutine ESMFL_StateGetField