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_parent
    type(ESMF_VM)               :: vm
    integer                     :: petCount, myPet
    character(ESMF_MAXSTR)      :: name,value,convESMF,purpGen, outVal
    type(ESMF_Field)            :: field2,field3,field6,field7,&
                                   field8,field9,field10
    type(ESMF_FieldBundle)      :: fieldbundle2
    type(ESMF_Grid)             :: grid

    rc = ESMF_SUCCESS

#if 0
here we should have fieldbundle2 and field10 on the state and fieldbundle2
should include field2, 3, 6, 7, 8, 9.

we will pull fieldbundle2 out of the state, and all of the fields out of fieldbundle2.
then for each of the fields we will make different run time modifications:
- field2: remove the attribute package
- field3: add an attribute to the attribute package
- field6: remove an attribute from the package and add a new attribute to the package
- field7: add an attribute package
- field8: add a nested attribute package to the already existing one
- field9: remove the attribute package, add it back, remove all attributes, add one back and then modify the value
#endif

    convESMF = 'ESMF'
    purpGen = 'General'
    name = 'ShortName'
    value = 'fieldAttribute'

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

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

    call ESMF_FieldBundleGet(fieldbundle2, fieldname="field2", field=field2, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_FieldBundleGet(fieldbundle2, fieldname="field3", field=field3, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_FieldBundleGet(fieldbundle2, fieldname="field6", field=field6, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_FieldBundleGet(fieldbundle2, fieldname="field7", field=field7, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_FieldBundleGet(fieldbundle2, fieldname="field8", field=field8, rc=rc)
    if (rc/=ESMF_SUCCESS) return
    call ESMF_FieldBundleGet(fieldbundle2, fieldname="field9", field=field9, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    ! field2: add an attribute to the package and then set it
    call ESMF_AttributeGetAttPack(field2, convESMF, purpGen, attpack=attpack, rc=rc)
    call ESMF_AttributeAdd(field2, convESMF, purpGen, attrList=(/"att1"/), &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field2, "att1", "val1", attpack=attpack, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    ! field3: add an attribute to a package and set it, then delete it, readd it and set it to a different value
    call ESMF_AttributeGetAttPack(field3, convESMF, purpGen, attpack=attpack, rc=rc)
    call ESMF_AttributeAdd(field3, convESMF, purpGen, attrList=(/"att1"/), &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field3, "att1", "val1", attpack=attpack, rc=rc)
    call ESMF_AttributeRemove(field3, name="att1", attpack=attpack, rc=rc)
    call ESMF_AttributeAdd(field3, convESMF, purpGen, attrList=(/"att1"/), &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field3, "att1", "val2", attpack=attpack, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    ! field6: add a nested attribute package and set a value
    call ESMF_AttributeAdd(field6, "newConvention", "newPurpose", &
                           attrList=(/"att1","att2"/), &
                           nestConvention=convESMF, nestPurpose=purpGen, &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field6, "att1", "val1", attpack=attpack, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    ! field7: add a nested attribute package (around old package), set a value,
    ! remove the whole nested package structure, then readd the outside part
    ! of the nested package and set a value
    call ESMF_AttributeAdd(field7, "newConvention", "newPurpose", &
                           attrList=(/"att1","att2"/), &
                           nestConvention=convESMF, nestPurpose=purpGen, &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field7, "att1", "val1", attpack=attpack, rc=rc)
    call ESMF_AttributeRemove(field7, attpack=attpack, rc=rc)
    call ESMF_AttributeAdd(field7, "newConvention", "newPurpose", &
                           attrList=(/"att1","att2"/), &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field7, "att1", "val2", attpack=attpack, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    ! field8: add a nested package, then remove all attributes from parent package and the nested package,
    ! then add it all back, and modify a value
    call ESMF_AttributeGetAttPack(field8, convESMF, purpGen, &
                                  attpack=attpack_parent, rc=rc)
    call ESMF_AttributeAdd(field8, "newConvention", "newPurpose", &
                           attrList=(/"att1","att2"/), &
                           nestConvention=convESMF, nestPurpose=purpGen, &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field8, "att1", "val1", attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field8, "att2", "val2", attpack=attpack, rc=rc)
    call ESMF_AttributeRemove(field8, name="ShortName", &
                              attpack=attpack_parent, rc=rc)
    call ESMF_AttributeRemove(field8, name="StandardName", &
                              attpack=attpack_parent, rc=rc)
    call ESMF_AttributeRemove(field8, name="LongName", &
                              attpack=attpack_parent, rc=rc)
    call ESMF_AttributeRemove(field8, name="Units", &
                              attpack=attpack_parent, rc=rc)
    call ESMF_AttributeRemove(field8, attpack=attpack_parent, rc=rc)
    call ESMF_AttributeRemove(field8, attpack=attpack, rc=rc)

    call ESMF_AttributeAdd(field8, convention=convESMF, purpose=purpGen, rc=rc)
    call ESMF_AttributeAdd(field8, "newConvention", "newPurpose", &
                           attrList=(/"att1","att2"/), &
                           nestConvention=convESMF, nestPurpose=purpGen, &
                           attpack=attpack, rc=rc)
    call ESMF_AttributeSet(field8, "att1", "val1.2", attpack=attpack, rc=rc)
    if (rc/=ESMF_SUCCESS) return

    ! field9: open for a new test

    ! field10: open for a new test



  end subroutine userm1_run