user_init Subroutine

public subroutine user_init(comp, importState, exportState, clock, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_CplComp) :: comp
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
type(ESMF_Clock) :: clock
integer :: rc

Source Code

    subroutine user_init(comp, importState, exportState, clock, rc)
      type(ESMF_CplComp) :: comp
      type(ESMF_State) :: importState, exportState
      type(ESMF_Clock) :: clock
      integer :: rc

      ! Local variables
      integer :: itemcount
      type(ESMF_Field) :: humidity1, humidity2
      type(ESMF_VM) :: vm


      print *, "User Coupler Init starting"

      call ESMF_StateGet(importState, itemcount=itemcount, rc=rc)
      print *, "Import State contains ", itemcount, " items."
       
      ! Get input data
      call ESMF_StateGetField(importState, "humidity", humidity1, rc=rc)
      if (rc .ne. ESMF_SUCCESS) goto 10
      ! call ESMF_FieldPrint(humidity1, rc=rc)

      ! Get location of output data
      call ESMF_StateGetField(exportState, "humidity", humidity2, rc=rc)
      if (rc .ne. ESMF_SUCCESS) goto 10
      ! call ESMF_FieldPrint(humidity2, rc=rc)

      ! Query component for VM and pass into Regrid Store
      call ESMF_CplCompGet(comp, vm=vm, rc=rc)
      if (rc .ne. ESMF_SUCCESS) goto 10

      ! These are fields on different IGrids - call RegridStore to set
      ! up the precomputed Regrid communication calls.

      call ESMF_FieldRegridStore(humidity1, humidity2, vm, &
                                 routehandle, &
                                 regridmethod=ESMF_REGRIDMETHOD_BILINEAR, &
                                 rc=rc)
      if (rc .ne. ESMF_SUCCESS) goto 10


      print *, "User Coupler Init returning"
   
      rc = ESMF_SUCCESS
      return

      ! only get here on error
10 continue
      rc = ESMF_FAILURE
  


    end subroutine user_init