user_final Subroutine

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

Arguments

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

Source Code

    subroutine user_final(comp, importState, exportState, clock, rc)
      type(ESMF_GridComp), intent(inout) :: comp
      type(ESMF_State), intent(inout) :: importState, exportState
      type(ESMF_Clock), intent(in) :: clock
      integer, intent(out) :: rc

      ! Local variables
      integer :: status
      type(ESMF_Field) :: field
      integer :: localrc, finalrc
      type(mylocaldata), pointer :: mydatablock
      type(wrapper) :: wrap

      print *, "User Comp Final starting"  

      ! set this up to run the validate code on all fields
      ! so we can see and compare the output.  but if any of
      ! the verify routines return error, return error at the end.
      finalrc = ESMF_SUCCESS

      ! Get our local info
      nullify(wrap%ptr)
      mydatablock => wrap%ptr
        
      call ESMF_GridCompGetInternalState(comp, wrap, status)

      mydatablock => wrap%ptr
      print *, "before deallocate, dataoffset = ", mydatablock%dataoffset

      ! check validity of results
      ! Get Fields from import state
      call ESMF_StateGetField(importState, "humidity", field, rc=rc)
      if (rc .ne. ESMF_SUCCESS) then
        finalrc = ESMF_FAILURE
        goto 30
      endif
      call verifyResults(field, localrc)
      if (localrc .ne. ESMF_SUCCESS) finalrc = ESMF_FAILURE

      deallocate(mydatablock, stat=status)
      print *, "deallocate returned ", status
      nullify(wrap%ptr)

30 continue
      ! come straight here if you cannot get the data from the state.
      ! otherwise error codes are accumulated but ignored until the
      ! end so we can see the output from all the cases to help track
      ! down errors.

      print *, "User Comp Final returning"
      rc = finalrc
   
    end subroutine user_final