MosaicReadCoords Subroutine

public subroutine MosaicReadCoords(mosaic, lonarray, latarray, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Mosaic) :: mosaic
real(kind=ESMF_KIND_R8), TARGET :: lonarray(:,:)
real(kind=ESMF_KIND_R8), TARGET :: latarray(:,:)
integer :: rc

Source Code

  subroutine MosaicReadCoords(mosaic, lonarray, latarray, rc)

  type(ESMF_Mosaic)            :: mosaic
  real(ESMF_KIND_R8), TARGET  :: lonarray(:,:)
  real(ESMF_KIND_R8), TARGET  :: latarray(:,:)
  integer                      :: rc

    character(len=128) :: errmsg
    integer, parameter :: nf90_noerror = 0
    integer :: ncStatus
    integer ::  gridid, varid, tempids(1), varids(2), meshid, len
    character(len=128) :: attvalue, locallocstr, varnames(2)
    integer :: ndims, dimids(2)
    integer :: i, nvars, pos
    integer :: localrc
    integer :: ntiles, nsize
    real(ESMF_KIND_R8), pointer  :: lontemp(:,:), lattemp(:,:)
    character(ESMF_MAXPATHLEN)   :: filename
    real(ESMF_KIND_R8), parameter :: d2r = 3.141592653589793238/180

#ifdef ESMF_NETCDF
    ntiles = mosaic%ntiles
    nsize = mosaic%ny
    do i=1,ntiles
      filename = trim(mosaic%tileDirectory)//trim(mosaic%filenames(i))
      call ESMF_GridspecReadStagger(filename, mosaic%nx, mosaic%ny, &
           lonarray(:,nsize*(i-1)+1:nsize*i), latarray(:,nsize*(i-1)+1:nsize*i), &
           ESMF_STAGGERLOC_CENTER, rc=localrc)
      if (ESMF_LogFoundError(localrc, &
           ESMF_ERR_PASSTHRU, &
           ESMF_CONTEXT, rcToReturn=rc)) return
    enddo  
    latarray = latarray*d2r
    lonarray = lonarray*d2r
    rc = ESMF_SUCCESS
    return
#else
    call ESMF_LogSetError(rcToCheck=ESMF_RC_LIB_NOT_PRESENT, &
      msg="- ESMF_NETCDF not defined when lib was compiled", &
      ESMF_CONTEXT, rcToReturn=rc)
    return
#endif
  end subroutine MosaicReadCoords