! $Id$ ! !------------------------------------------------------------------------- !BOP ! ! !MODULE: esmfarrays.F90 - Source file for Data for esmf coupler ! ! !DESCRIPTION: ! Allocate and deallocate ESMF objects which handle data arrays ! including ESMF\_Fields, ESMF\_Grids, and ESMF\_Arrays. ! !EOP ! module esmfarrays_module ! ! ESMF modules ! use esmf implicit none ! ! arrays ! public :: zb real(kind=ESMF_KIND_R4), dimension(:,:), pointer, save :: zb type(ESMF_Array), pointer, save :: array_zb ! Fields ! public :: field_zb type(ESMF_Field), save :: field_zb type(ESMF_TimeInterval), save :: time_step real(kind=ESMF_KIND_R8) :: dt contains !------------------------------------------------------------------------- subroutine ArraysAlloc(grid, rc) type(ESMF_Grid) :: grid integer, intent(out), optional :: rc ! Local variables ! integer :: status type(ESMF_ArraySpec) :: arrayspec ! ! Set initial values ! status = ESMF_FAILURE ! ! Initialize return code ! if(present(rc)) then rc = ESMF_FAILURE endif ! grid = ESMF_GridCreateShapeTile(rc=rc) ! ! !DESCRIPTION: ! \subsubsection{Example of Field Creation and Array Usage:} ! ! The following piece of code provides an example of Field creation used in ! the demo. In this example we create a Field from an ArraySpec, which ! designates the rank, type, and kind of the data. First initialize the ! ArraySpec with rank 2 for a two-dimensional array ! and kind ESMF\_KIND\_R4: !\begin{verbatim} call ESMF_ArraySpecSet(arrayspec, rank=2, typekind=ESMF_TYPEKIND_R4) !\end{verbatim} ! Next, create a Field named "zb" using the ArraySpec with a relative ! location (relloc) at the cell centers: !\begin{verbatim} field_zb = ESMF_FieldCreate(grid, arrayspec, staggerloc=ESMF_STAGGERLOC_CENTER, name="zb", rc=status) !\end{verbatim} ! Once the Field has been created, we get a pointer to the Array ! data (the Fortran 90 array), and call it "array_zb". ! Inside the Component "sie" can be used like an array made by an ! F90 allocation but will reference the data inside "field\_sie." !\begin{verbatim} call ESMF_FieldGet(field_zb, array=array_zb, rc=status) !\end{verbatim} !EOP if(status .NE. ESMF_SUCCESS) then print *, "ERROR in allocation of arrays" return endif if(present(rc)) rc = ESMF_SUCCESS end subroutine ArraysAlloc !------------------------------------------------------------------------- subroutine ArraysDealloc(rc) integer, intent(out), optional :: rc ! Local variables ! integer :: status logical :: rcpresent ! ! Set initial values ! status = ESMF_FAILURE rcpresent = .FALSE. ! ! Initialize return code ! if(present(rc)) then rcpresent = .TRUE. rc = ESMF_FAILURE endif ! ! deallocate global arrays - destroy the Fields ! call ESMF_FieldDestroy(field_zb , rc=status) if(status .NE. ESMF_SUCCESS) then print *, "ERROR in FlowArraysDealloc" return endif if(rcpresent) rc = ESMF_SUCCESS end subroutine ArraysDealloc !------------------------------------------------------------------------------ end module Esmfarrays_module