ESMF_CFIOGridSet Subroutine

public subroutine ESMF_CFIOGridSet(grid, gName, im, jm, km, tm, lat, lon, lev, coordinate, standardName, formulaTerm, levUnit, ak, bk, sigma, ptop, ptopUnit, lat2, lon2, twoDimLat, reduceGrid, stnGrid, rc)

ESMF_CFIOGridSet – set up a grid

Arguments

Type IntentOptional Attributes Name
type(ESMF_CFIOGrid), intent(inout) :: grid
character(len=*), intent(in), optional :: gName

grid name

integer, intent(in), optional :: im

size of longitudinal dimension

integer, intent(in), optional :: jm

size of latitudinal dimension

integer, intent(in), optional :: km

size of vertical dimension

integer, intent(in), optional :: tm

size of time dimension

real, intent(in), optional :: lat(:)

latitude

real, intent(in), optional :: lon(:)

longitude

real, intent(in), optional :: lev(:)

Level

character(len=*), intent(in), optional :: coordinate

string to indicate vertical coord (pressure, sigma, pressure_sigma)

character(len=*), intent(in), optional :: standardName

string for standard name

character(len=*), intent(in), optional :: formulaTerm

formula terms

character(len=*), intent(in), optional :: levUnit

units of level dimension, e.g., “hPa”.

real, intent(in), optional :: ak(:)

parameter for hybrid sigma prs coord.

real, intent(in), optional :: bk(:)

parameter for hybrid sigma prs coord.

real, intent(in), optional :: sigma(:)

parameter for sigma coordinate

real, intent(in), optional :: ptop

parameter for sigma coordinate

character(len=*), intent(in), optional :: ptopUnit

unit of ptop

real(kind=REAL64), optional, pointer :: lat2(:)

latitude 2d

real(kind=REAL64), optional, pointer :: lon2(:)

longitude 2d

logical, intent(in), optional :: twoDimLat

support 2D lat/lon or not

logical, intent(in), optional :: reduceGrid

support for reduced grid

logical, intent(in), optional :: stnGrid

support for statio grid

integer, intent(out), optional :: rc

Error return code:
0 all is well
-1 Problem in setting lon
-2 Problem in setting lat
-3 Problem in setting lev


Called by

proc~~esmf_cfiogridset~~CalledByGraph proc~esmf_cfiogridset ESMF_CFIOGridSet program~test~10 test program~test~10->proc~esmf_cfiogridset program~test~11 test program~test~11->proc~esmf_cfiogridset program~test~13 test program~test~13->proc~esmf_cfiogridset program~test~14 test program~test~14->proc~esmf_cfiogridset program~test~2 test program~test~2->proc~esmf_cfiogridset program~test~3 test program~test~3->proc~esmf_cfiogridset program~test~6 test program~test~6->proc~esmf_cfiogridset program~test~7 test program~test~7->proc~esmf_cfiogridset program~test~9 test program~test~9->proc~esmf_cfiogridset

Source Code

      subroutine ESMF_CFIOGridSet (grid, gName, im, jm, km, tm, lat, lon, lev,&
                                   coordinate, standardName, formulaTerm,   &
                                   levUnit, ak, bk, sigma, ptop, ptopUnit,  &
                                   lat2, lon2, & 
                                   twoDimLat, reduceGrid, stnGrid, rc)
!
! !INPUT PARAMETERS:
!
      character(len=*), intent(in), OPTIONAL :: gName  !! grid name
      integer, intent(in), OPTIONAL :: im  !! size of longitudinal dimension
      integer, intent(in), OPTIONAL :: jm  !! size of latitudinal  dimension
      integer, intent(in), OPTIONAL :: km  !! size of vertical dimension
      integer, intent(in), OPTIONAL :: tm  !! size of time dimension
      real, intent(in), OPTIONAL :: lon(:) !! longitude 
      real, intent(in), OPTIONAL :: lat(:) !! latitude 
      real, intent(in), OPTIONAL :: lev(:) !! Level   
      real(KIND=REAL64), pointer, OPTIONAL :: lon2(:) !! longitude 2d 
      real(KIND=REAL64), pointer, OPTIONAL :: lat2(:) !! latitude 2d
      character(len=*), intent(in), OPTIONAL :: levUnit   !! units of level dimension, e.g., "hPa".
      character(len=*), intent(in), OPTIONAL :: coordinate !! string to indicate vertical coord
                                 !! (pressure, sigma, pressure_sigma)
      character(len=*), intent(in), OPTIONAL :: standardName !! string for standard name
      character(len=*), intent(in), OPTIONAL :: formulaTerm  !! formula terms
      real, intent(in), OPTIONAL :: ak(:)     !! parameter for hybrid sigma prs coord.
      real, intent(in), OPTIONAL :: bk(:)     !! parameter for hybrid sigma prs coord.
      real, intent(in), OPTIONAL :: sigma(:)  !! parameter for sigma coordinate
      real, intent(in), OPTIONAL :: ptop              !! parameter for sigma coordinate
      character(len=*), intent(in), OPTIONAL :: ptopUnit   !! unit of ptop
      logical, intent(in), OPTIONAL :: twoDimLat       !! support 2D lat/lon or not
      logical, intent(in), OPTIONAL :: reduceGrid      !! support for reduced grid 
      logical, intent(in), OPTIONAL :: stnGrid      !! support for statio grid 

! !OUTPUT PARAMETERS:
!
      integer, intent(out), OPTIONAL :: rc !! Error return code:       
                                           !! 0   all is well       
                                           !! -1  Problem in setting lon       
                                           !! -2  Problem in setting lat       
                                           !! -3  Problem in setting lev  
! !INPUT/OUTPUT PARAMETERS:
!
      type(ESMF_CFIOGrid), intent(inout) :: grid   ! CFIO grid   
!
!------------------------------------------------------------------------------
       integer :: rtcode  = 0
       integer :: i, j
       !integer :: sz

       _UNUSED_DUMMY(sigma)
       _UNUSED_DUMMY(reduceGrid)

       if ( present(gName) ) grid%gName = gName
       if ( present(im) ) grid%im = im
       if ( present(jm) ) grid%jm = jm
       if ( present(km) ) grid%km = km
       if ( present(tm) ) grid%tm = tm

       if (present(twoDimLat)) then
          grid%twoDimLat = twoDimLat
          if (.not. (present(im) .and. present(jm) .and. &
                     present(lon2) .and. present(lat2))) then
             rtcode = -1
          else
             !sz = im*jm
             ! ALT: for "true" 2d coordinates we save memory
             ! and just point to the original coordinate arrays
             !allocate(grid%lon(sz), grid%lat(sz), stat = rtcode)
             grid%lon => lon2
             grid%lat => lat2
          end if
          !if (rtcode .ne. 0) then 
          !   print *, "problem in setting ESMF_CFIOGridSet:lat"
          !   rtcode = -2
          !   if ( present(rc) ) rc = rtcode
          !   return
          !end if
       else
          if ( present(lon) ) then
             grid%im = size(lon)
             allocate(grid%lon(grid%im), stat = rtcode)
             grid%lon = lon
          else if ( present(im) ) then
             allocate(grid%lon(im), stat = rtcode)
             do i = 1, im
                grid%lon(i) = 360./im * (i-1)
             end do
          end if
          if (rtcode .ne. 0) then 
             print *, "problem in setting ESMF_CFIOGridSet:lon"
             rtcode = -1
             if ( present(rc) ) rc = rtcode
             return
          end if

          if ( present(lat) ) then
             grid%jm = size(lat)
             allocate(grid%lat(grid%jm), stat = rtcode)
             grid%lat = lat
          else if ( present(jm) ) then
             allocate(grid%lat(jm), stat = rtcode)
             do j = 1, jm
                grid%lat(j) = 180./(jm-1) * (j-1) - 90
             end do
          end if
          if (rtcode .ne. 0) then 
             print *, "problem in setting ESMF_CFIOGridSet:lat"
             rtcode = -2
             if ( present(rc) ) rc = rtcode
             return
          end if
       end if ! if (usableTwoDimLat)...

        if ( present(lev) ) then
           grid%km = size(lev)
           allocate(grid%lev(grid%km), stat = rtcode)
           grid%lev = lev
           if (rtcode .ne. 0) then 
           print *, "problem in setting ESMF_CFIOGridSet:lev"
              rtcode = -3
              if ( present(rc) ) rc = rtcode
              return
           end if
        end if    

        if ( present(levUnit) ) grid%levUnits = levUnit

       if ( present(coordinate) ) grid%coordinate = coordinate
       if ( present(standardName) ) grid%standardName = standardName
       if ( present(formulaTerm) ) grid%formulaTerm = formulaTerm
       if ( present(ak) ) then
          allocate(grid%ak(size(ak)), stat=rtcode)
          grid%ak = ak 
       end if
       if ( present(bk) ) then
          allocate(grid%bk(size(bk)), stat=rtcode)
          grid%bk = bk 
       end if
       if ( present(ptop) ) then
          grid%ptop = ptop
       end if
       if ( present(ptopUnit) ) grid%ptopUnit = ptopUnit

       if ( present(stnGrid) ) then
          grid%stnGrid = stnGrid
       end if

       if ( present(rc) ) rc = rtcode

      end subroutine ESMF_CFIOGridSet