user_initP2 Subroutine

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

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp) :: comp
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc

Source Code

  subroutine user_initP2(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_Field)      :: field
    type(ESMF_Grid)       :: grid
    type(ESMF_DistGrid)   :: distgrid
    
    ! Initialize return code
    rc = ESMF_SUCCESS

    print *, "User Comp2 Init phase=2 starting"
    call ESMF_LogWrite (msg='User Comp2 Init phase=2 starting', &
      logmsgFlag=ESMF_LOGMSG_TRACE)

    ! Access Field with shared Grid that is available in the importState
    call ESMF_StateGet(importState, "dstField", field, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! Get the shared Grid
    call ESMF_FieldGet(field, grid=grid, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
 
    ! Get the DistGrid
    call ESMF_GridGet(grid, distgrid=distgrid, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out

    ! Print the DistGrid of the shared Grid
    call ESMF_DistGridPrint(distgrid, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! TODO: If there were changes made to the DistGrid, then the Grid will need
    ! TODO: to be re-created on the changed DistGrid, and swapped out in the 
    ! TODO: Field.
   
    call ESMF_LogWrite (msg='User Comp2 Init phase=2 complete', &
      logmsgFlag=ESMF_LOGMSG_TRACE)
    print *, "User Comp2 Init phase=2 returning"

  end subroutine user_initP2