MyGridCreate_ Function

function MyGridCreate_(VM, rc) result(grid)

Arguments

Type IntentOptional Attributes Name
type(ESMF_VM), intent(in) :: VM
integer, intent(out), optional :: rc

Return Value type(ESMF_Grid)


Calls

proc~~mygridcreate_~5~~CallsGraph proc~mygridcreate_~5 MyGridCreate_ esmf_delayoutcreate esmf_delayoutcreate proc~mygridcreate_~5->esmf_delayoutcreate esmf_gridaddvertheight esmf_gridaddvertheight proc~mygridcreate_~5->esmf_gridaddvertheight esmf_gridcreatehorzlatlonuni esmf_gridcreatehorzlatlonuni proc~mygridcreate_~5->esmf_gridcreatehorzlatlonuni esmf_griddistribute esmf_griddistribute proc~mygridcreate_~5->esmf_griddistribute interface~mapl_am_i_root MAPL_Am_I_Root proc~mygridcreate_~5->interface~mapl_am_i_root mapl_get_local_dims mapl_get_local_dims proc~mygridcreate_~5->mapl_get_local_dims mapl_return mapl_return proc~mygridcreate_~5->mapl_return mapl_verify mapl_verify proc~mygridcreate_~5->mapl_verify

Called by

proc~~mygridcreate_~5~~CalledByGraph proc~mygridcreate_~5 MyGridCreate_ proc~test_main~5 test_main proc~test_main~5->proc~mygridcreate_~5 program~utcfio~3 utCFIO program~utcfio~3->proc~test_main~5

Source Code

  function MyGridCreate_ ( vm, rc) result(grid)

    type (ESMF_VM),    intent(IN   ) :: VM
    integer, optional, intent(OUT)   :: rc
    type (ESMF_Grid)                 :: grid

! Local vars
    integer                                 :: status
    character(len=ESMF_MAXSTR), parameter   :: IAm='MyGridCreate'

    integer                         :: LM
    integer                         :: L
    integer                         :: NX, NY
    integer, allocatable            :: IMXY(:), JMXY(:)
    character(len=ESMF_MAXSTR)      :: gridname
    real(ESMF_KIND_R8)              :: minCoord(3)
    real(ESMF_KIND_R8)              :: deltaX, deltaY, deltaZ
    real                            :: LON0, LAT0

    real :: pi, d2r

! grid create

    lm = KM_WORLD   ! no. vertical layers
    nx = 2
    ny = 2

     pi  = 4.0 * atan ( 1.0 ) 
    d2r  = pi / 180.
    LON0 = -180  * d2r
    LAT0 = -90.0 * d2r

! Get the IMXY vector
! -------------------
    allocate( imxy(0:nx-1) )  
    call MAPL_GET_LOCAL_DIMS ( IM_WORLD, imxy, nx )

! Get the JMXY vector
! -------------------
    allocate( jmxy(0:ny-1) )  
    call MAPL_GET_LOCAL_DIMS ( JM_WORLD, jmxy, ny )

    deltaX = 2.0*pi/IM_WORLD
    deltaY = pi/(JM_WORLD-1)
    deltaZ = 1.0

    if ( MAPL_Am_I_Root() ) then
       print *, 'nx : imxy = ', nx, ' : ', imxy
       print *, 'ny : jmxy = ', ny, ' : ', jmxy
    endif

! Define South-West Corner of First Grid-Box
! ------------------------------------------
    minCoord(1) = LON0 - deltaX/2 
    minCoord(2) = LAT0 - deltaY/2
    minCoord(3) = deltaZ/2.

    layout = ESMF_DELayoutCreate(vm, deCountList=(/NX, NY/), rc=status)
    _VERIFY(STATUS)

    grid = ESMF_GridCreateHorzLatLonUni(         &
         counts = (/IM_WORLD, JM_WORLD/),        &
         minGlobalCoordPerDim=minCoord(1:2),     &
         deltaPerDim=(/deltaX, deltaY /),        &
         horzStagger=ESMF_Grid_Horz_Stagger_A,   &
         periodic=(/ESMF_TRUE, ESMF_FALSE/),     &
         name='Beatrice', rc=status)
    _VERIFY(STATUS)

    call ESMF_GridAddVertHeight(grid,            &
         delta=(/(deltaZ, L=1,LM) /),            &
         rc=status)
    _VERIFY(STATUS)

    call ESMF_GridDistribute(grid,               &
         deLayout=layout,                        &
         countsPerDEDim1=imxy,                   &
         countsPerDEDim2=jmxy,                   &
         rc=status)
    _VERIFY(STATUS)

    deallocate(imxy)
    deallocate(jmxy)

    _RETURN(STATUS)

  end function MyGridCreate_