myFinalInFortran Subroutine

public subroutine myFinalInFortran(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 myFinalInFortran(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_Array)    :: array
    type(ESMF_DistGrid) :: distgrid

    ! Initialize return code
    rc = ESMF_SUCCESS

    print *, "In myFinalInFortran routine"
    
    ! get Array object from export State    
    call ESMF_StateGet(exportState,"array1", array=array, rc=rc)

    ! Destroy Array and DistGrid
    call ESMF_ArrayGet(array, distgrid=distgrid, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_ArrayDestroy(array, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_DistGridDestroy(distgrid, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! deallocate Fortran memory allocation
    deallocate (farray)
 
  end subroutine myFinalInFortran