subroutine userm1_init(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
type(ESMF_VM) :: vm
integer :: petCount, status, myPet
character(ESMF_MAXSTR) :: name1,name2,name3,name4,value1,value2, &
value3,value4,convESMF,purpGen,convCC
type(ESMF_ArraySpec) :: arrayspec
type(ESMF_Grid) :: grid
type(ESMF_Field) :: field
type(ESMF_FieldBundle) :: fieldbundle
character(ESMF_MAXSTR),dimension(2) :: attrList
rc = ESMF_SUCCESS
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_ArraySpecSet(arrayspec, typekind=ESMF_TYPEKIND_R8, rank=2, rc=rc)
if (rc/=ESMF_SUCCESS) return
grid = ESMF_GridCreateNoPeriDim(minIndex=(/1,1/), maxIndex=(/100,150/), &
regDecomp=(/1,petCount/), &
gridEdgeLWidth=(/0,0/), gridEdgeUWidth=(/0,0/), &
indexflag=ESMF_INDEX_GLOBAL, rc=rc)
if (rc/=ESMF_SUCCESS) return
convCC = 'CustomConvention'
convESMF = 'ESMF'
purpGen = 'General'
name1 = 'ShortName'
name2 = 'StandardName'
name3 = 'LongName'
name4 = 'Units'
value1 = 'field'
value2 = 'tendency_of_air_pressure'
value3 = 'Edge pressure tendency'
value4 = 'Pa s-1'
field = ESMF_FieldCreate(grid, arrayspec=arrayspec, &
staggerloc=ESMF_STAGGERLOC_CENTER, name="field", rc=status)
call ESMF_AttributeAdd(field, convention=convESMF, purpose=purpGen, &
rc=status)
call ESMF_AttributeSet(field, name1, value1, convention=convESMF, &
purpose=purpGen, rc=status)
call ESMF_AttributeSet(field, name2, value2, convention=convESMF, &
purpose=purpGen, rc=status)
call ESMF_AttributeSet(field, name3, value3, convention=convESMF, &
purpose=purpGen, rc=status)
call ESMF_AttributeSet(field, name4, value4, convention=convESMF, &
purpose=purpGen, rc=status)
if (status .ne. ESMF_SUCCESS) return
! Create the Grid Attribute Package
call ESMF_AttributeAdd(grid,convention=convESMF, purpose=purpGen, rc=status)
call ESMF_AttributeSet(grid,'RegDecompX', 96, &
convention=convESMF, purpose=purpGen, rc=status)
call ESMF_AttributeSet(grid,'RegDecompY', 84, &
convention=convESMF, purpose=purpGen, rc=status)
if (status .ne. ESMF_SUCCESS) return
fieldbundle = ESMF_FieldBundleCreate(name="fieldbundle", rc=status)
if (status .ne. ESMF_SUCCESS) return
call ESMF_FieldBundleSet(fieldbundle, grid=grid, rc=status)
if (status .ne. ESMF_SUCCESS) return
call ESMF_FieldBundleAdd(fieldbundle, (/ field /), rc=status)
if (status .ne. ESMF_SUCCESS) return
call ESMF_StateAdd(exportState, fieldbundleList=(/fieldbundle/), rc=status)
if (status .ne. ESMF_SUCCESS) return
end subroutine userm1_init