userm1_run Subroutine

private subroutine userm1_run(comp, importState, exportState, clock, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp) :: comp
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc

Source Code

  subroutine userm1_run(comp, importState, exportState, clock, rc)
    type(ESMF_GridComp) :: comp
    type(ESMF_State) :: importState, exportState
    type(ESMF_Clock) :: clock
    integer, intent(out) :: rc

    type(ESMF_AttPack)        :: attpack, attpack_nested  
    type(ESMF_VM)               :: vm
    integer                     :: petCount, status, myPet
    character(ESMF_MAXSTR)      :: name2,value2,convESMF,purpGen,purp2,name3
    character(ESMF_MAXSTR),dimension(2) :: attrList, valueList
    type(ESMF_Field)            :: field
    type(ESMF_FieldBundle)      :: fieldbundle
    type(ESMF_Grid)             :: grid

    rc = ESMF_SUCCESS

    convESMF = 'ESMF'
    purpGen = 'General'
    name2 = 'StandardName'
    value2 = 'default_standard_name'
    name3 = 'LongName'

    purp2 = 'Extended'
    attrList(1) = 'Coordinates'
    attrList(2) = 'Mask'
    valueList(1) = "Latlon"
    valueList(2) = "Yes"

    call ESMF_GridCompGet(comp, vm=vm, rc=status)
    if (status .ne. ESMF_SUCCESS) return
    call ESMF_VMGet(vm, petCount=petCount, localPet=myPet, rc=status)
    if (status .ne. ESMF_SUCCESS) return

    call ESMF_StateGet(exportState, "fieldbundle", fieldbundle, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_FieldBundleGet(fieldbundle, grid=grid, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    call ESMF_FieldBundleGet(fieldbundle, fieldname="field", field=field, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_AttributeGetAttPack(field, convESMF, purpGen, attpack=attpack, rc=status)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_AttributeSet(field, name2, value2, attpack=attpack, rc=status)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_AttributeAdd(field, convention=convESMF, purpose=purp2, &
      attrList=attrList, nestConvention=convESMF, nestPurpose=purpGen, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_AttributeSet(field, attrList(1), valueList(1), &
      convention=convESMF, purpose=purp2, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_AttributeSet(field, attrList(2), valueList(2), &
      convention=convESMF, purpose=purp2, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_AttributeRemove(field, name=name3, convention=convESMF, &
      purpose=purpGen, rc=status)
    if (rc/=ESMF_SUCCESS) return

    ! add a single Attribute alongside the Attribute packages
    call ESMF_AttributeSet(field, "Lone Attribute", value="Lone Attribute", &
                           rc=status)

  end subroutine userm1_run