function MyGridCreate_ ( vm, rc) result(grid)
type (ESMF_VM), intent(INOUT) :: VM
integer, optional, intent(OUT) :: rc
type (ESMF_Grid) :: grid
! Local vars
integer :: status
character(len=ESMF_MAXSTR), parameter :: IAm='MyGridCreate'
type(MAPL_MetaComp) :: mapl
type(ESMF_Config) :: config
! type(ESMF_VM) :: vm
character(len=ESMF_MAXSTR) :: gridname
integer :: ndes, nx, ny
! fake MAPL
config = ESMF_ConfigCreate (rc=STATUS )
_VERIFY(STATUS)
call ESMF_ConfigLoadFile(config, 'tmp_CAP.rc', rc=STATUS )
_VERIFY(STATUS)
! We will set-up a somewhat realistic resource "file"
call ESMF_VmGetCurrent(VM, rc=status)
_VERIFY(STATUS)
call ESMF_VmGet(VM, petCount=ndes, rc=status)
_VERIFY(STATUS)
nx = ndes
ny = 1
call ESMF_ConfigSetAttribute(config, value=nx, Label='NX:', rc=status)
_VERIFY(STATUS)
call ESMF_ConfigSetAttribute(config, value=ny, Label='NY:', rc=status)
_VERIFY(STATUS)
!C$ call ESMF_ConfigSetAttribute(config, value=gridname, Label='GRIDNAME:', rc = status )
call ESMF_ConfigGetAttribute(config, value=gridname, Label='GRIDNAME:', rc = status )
_VERIFY(STATUS)
call ESMF_ConfigSetAttribute(config, value=KM_WORLD, Label='LM:', rc = status )
! _VERIFY(STATUS)
call ESMF_ConfigGetAttribute(config, value=nx, Label='NX:', rc=status)
_VERIFY(STATUS)
call ESMF_ConfigGetAttribute(config, value=ny, Label='NY:', rc=status)
_VERIFY(STATUS)
print *,'GRIDNAME=',trim(gridname)
print *,'NX=',nx
print *,'NX=',nY
! CAP's MAPL MetaComp
!---------------------
call MAPL_Set (mapl, name='CAP', cf=CONFIG, rc=STATUS )
_VERIFY(STATUS)
! grid create
call MAPL_GridCreate(MAPLOBJ=mapl, ESMFGRID=grid, rc=status)
_RETURN(STATUS)
end function MyGridCreate_