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 :: localPET, petCount
type(ESMF_Field) :: srcField,dstField
type(ESMF_VM) :: vm
rc = ESMF_SUCCESS
! Need to reconcile import and export states
call ESMF_CplCompGet(comp, vm=vm, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_VMGet(vm, localPet=localPet, petCount=petCount, rc=rc)
if(rc/=ESMF_SUCCESS) return
write(*,*) localPET,"User Coupler Init Start"
call ESMF_StateReconcile(importState, vm=vm, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
write(*,*) localPET,"User Coupler After Import Reconcile"
call ESMF_StateReconcile(exportState, vm=vm, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
write(*,*) localPET,"User Coupler After Export Reconcile"
! Get input data
call ESMF_StateGet(importState, "src", srcField, rc=rc)
if(rc/=ESMF_SUCCESS) return
! Get location of output data
call ESMF_StateGet(exportState, "dst", dstField, 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=srcField, dstField=dstField, &
routeHandle=routehandle, &
regridmethod=ESMF_REGRIDMETHOD_BILINEAR, &
rc=rc)
if(rc/=ESMF_SUCCESS) return
write(*,*) localPET,"User Coupler Init End"
end subroutine user_init