subroutine user_init(comp, importState, exportState, clock, rc)
type(ESMF_GridComp) :: comp
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc
! Local variables
type(ESMF_ArraySpec) :: arrayspec
type(ESMF_Grid) :: grid
type(ESMF_Field) :: field
type(ESMF_VM) :: vm
integer :: petCount
! Initialize return code
rc = ESMF_SUCCESS
print *, "User Comp2 Init starting"
! Determine petCount
call ESMF_GridCompGet(comp, vm=vm, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_VMGet(vm, petCount=petCount, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
! Create the destination Field and add it to the import State
call ESMF_ArraySpecSet(arrayspec, typekind=ESMF_TYPEKIND_R8, rank=2, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
grid = ESMF_GridCreateNoPeriDim(minIndex=(/1,1/), maxIndex=(/100,150/), &
regDecomp=(/1,petCount/), &
gridEdgeLWidth=(/0,0/), gridEdgeUWidth=(/0,0/), & ! no stagger padding
indexflag=ESMF_INDEX_GLOBAL, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
field = ESMF_FieldCreate(grid, arrayspec=arrayspec, &
staggerloc=ESMF_STAGGERLOC_CENTER, name="field data", rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_StateAdd(importState, fieldList=(/field/), rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
print *, "User Comp2 Init returning"
end subroutine user_init