subroutine user_init(comp, importState, exportState, clock, rc)
type(ESMF_CplComp) :: comp
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc
! Local variables
integer :: itemcount
type(ESMF_Field) :: humidity1, humidity2
type(ESMF_VM) :: vm
rc = ESMF_SUCCESS
print *, "User Coupler Init starting"
call ESMF_StateGet(importState, itemcount=itemcount, rc=rc)
if(rc/=ESMF_SUCCESS) return
print *, "Import State contains ", itemcount, " items."
! Get input data
call ESMF_StateGet(importState, "humidity", humidity1, rc=rc)
if(rc/=ESMF_SUCCESS) return
! call ESMF_FieldPrint(humidity1, rc=rc)
! Get location of output data
call ESMF_StateGet(exportState, "humidity", humidity2, rc=rc)
if(rc/=ESMF_SUCCESS) return
! call ESMF_FieldPrint(humidity2, rc=rc)
! Get VM from coupler component to send down to Regrid Store routine
call ESMF_CplCompGet(comp, vm=vm, rc=rc)
if(rc/=ESMF_SUCCESS) return
! These are fields on different Grids - call RegridStore to set
! up the Regrid structure
call ESMF_FieldRegridStore(srcField=humidity1, dstField=humidity2, &
routeHandle=routehandle, &
regridmethod=ESMF_REGRIDMETHOD_BILINEAR, &
rc=rc)
if(rc/=ESMF_SUCCESS) return
print *, "User Coupler Init returning"
end subroutine user_init