ESMF_GridspecQueryTileGlobal Subroutine

public subroutine ESMF_GridspecQueryTileGlobal(filename, isGlobal, rc)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
logical, intent(out) :: isGlobal
integer, intent(out), optional :: rc

Calls

proc~~esmf_gridspecquerytileglobal~~CallsGraph proc~esmf_gridspecquerytileglobal ESMF_GridspecQueryTileGlobal proc~esmf_logseterror ESMF_LogSetError proc~esmf_gridspecquerytileglobal->proc~esmf_logseterror esmf_breakpoint esmf_breakpoint proc~esmf_logseterror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logseterror->proc~esmf_logwrite c_esmc_loggeterrormsg c_esmc_loggeterrormsg proc~esmf_logrc2msg->c_esmc_loggeterrormsg c_esmc_vmwtime c_esmc_vmwtime proc~esmf_logwrite->c_esmc_vmwtime proc~esmf_logclose ESMF_LogClose proc~esmf_logwrite->proc~esmf_logclose proc~esmf_logflush ESMF_LogFlush proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logwrite->proc~esmf_utiliounitflush proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array proc~esmf_logclose->proc~esmf_logflush proc~esmf_logflush->proc~esmf_utiliounitflush proc~esmf_utilarray2string ESMF_UtilArray2String proc~esmf_logflush->proc~esmf_utilarray2string proc~esmf_logopenfile->proc~esmf_utiliounitflush proc~esmf_utiliounitget ESMF_UtilIOUnitGet proc~esmf_logopenfile->proc~esmf_utiliounitget

Called by

proc~~esmf_gridspecquerytileglobal~~CalledByGraph proc~esmf_gridspecquerytileglobal ESMF_GridspecQueryTileGlobal proc~esmf_gridcreatemosaicireg ESMF_GridCreateMosaicIReg proc~esmf_gridcreatemosaicireg->proc~esmf_gridspecquerytileglobal proc~esmf_gridcreatemosaicreg ESMF_GridCreateMosaicReg proc~esmf_gridcreatemosaicreg->proc~esmf_gridspecquerytileglobal interface~esmf_gridcreatemosaic ESMF_GridCreateMosaic interface~esmf_gridcreatemosaic->proc~esmf_gridcreatemosaicireg interface~esmf_gridcreatemosaic->proc~esmf_gridcreatemosaicreg proc~test_bilinear_regrid_csmosaic test_bilinear_regrid_csmosaic proc~test_bilinear_regrid_csmosaic->interface~esmf_gridcreatemosaic proc~test_conserve_regrid_csmosaic test_conserve_regrid_csmosaic proc~test_conserve_regrid_csmosaic->interface~esmf_gridcreatemosaic program~esmf_gridcreateutest ESMF_GridCreateUTest program~esmf_gridcreateutest->interface~esmf_gridcreatemosaic

Source Code

subroutine ESMF_GridspecQueryTileGlobal(filename, isGlobal, rc)

    character(len=*), intent(in)     :: filename
    logical, intent(out)             :: isGlobal
    integer, intent(out), optional   :: rc

#ifdef ESMF_NETCDF
    integer :: ncid, nvars, attlen, i
    integer :: ncStatus
    integer :: nx, ny
    integer :: ndims, dimids(2)
    real(ESMF_KIND_R8), allocatable :: supergrid(:,:)
    real(ESMF_KIND_R8) :: minlon, maxlon
    character(len=128) :: attstr

    if (present(rc)) rc=ESMF_SUCCESS

    ncStatus = nf90_open(path=filename, mode=nf90_nowrite, ncid=ncid)
    if (CDFCheckError (ncStatus, &
        ESMF_METHOD,  &
        ESMF_SRCLINE, &
        trim(filename), &
        rc)) return
    ncStatus = nf90_inquire(ncid, nVariables=nvars)
    if (CDFCheckError (ncStatus, &
        ESMF_METHOD,  &
        ESMF_SRCLINE, &
        trim(filename), &
        rc)) return
    do i=1,nvars
       ! Check its standard_name attribute
       ncStatus = nf90_inquire_attribute(ncid, i, 'standard_name', len=attlen)
       if (ncStatus == nf90_noerr) then
          ncStatus = nf90_get_att(ncid, i, 'standard_name', values=attstr)
          if (attstr(1:attlen) .eq. 'geographic_longitude') then
            ! read the longitude variable
            ! First find the dimension of this variable
            ncStatus = nf90_inquire_variable(ncid, i, ndims=ndims, dimids=dimids)
            if (ndims /= 2) then
              call ESMF_LogSetError(rcToCheck=ESMF_FAILURE, & 
                 msg="- The longitude variable should have dimension 2", & 
                 ESMF_CONTEXT, rcToReturn=rc) 
              return
            endif
            ! find out the dimenison size
            ncStatus = nf90_inquire_dimension(ncid, dimids(1), len=nx)
            if (CDFCheckError (ncStatus, &
               ESMF_METHOD,  &
               ESMF_SRCLINE, &
               "contact dimension inquire", &
               rc)) return
            ncStatus = nf90_inquire_dimension(ncid, dimids(2), len=ny)
            if (CDFCheckError (ncStatus, &
               ESMF_METHOD,  &
               ESMF_SRCLINE, &
               "contact dimension inquire", &
               rc)) return
            allocate(supergrid(nx,ny))
            ncStatus = nf90_get_var(ncid, i, supergrid)
            if (CDFCheckError (ncStatus, &
               ESMF_METHOD,  &
               ESMF_SRCLINE, &
               "contact dimension inquire", &
               rc)) return
            minlon = minval(supergrid)
            maxlon = maxval(supergrid)
            if (maxlon-minlon == 360.0) then
              isGlobal = .true.
            else
              isGlobal = .false.
            endif
            deallocate(supergrid)
            goto 20
         endif
       endif
     enddo
     
20   continue
     ncStatus = nf90_close(ncid)
     if (CDFCheckError (ncStatus, &
               ESMF_METHOD,  &
               ESMF_SRCLINE, &
               "close tile file", &
               rc)) return
     return
#else       

    call ESMF_LogSetError(ESMF_RC_LIB_NOT_PRESENT, & 
                 msg="- ESMF_NETCDF not defined when lib was compiled", & 
                 ESMF_CONTEXT, rcToReturn=rc) 
    return
#endif

end subroutine ESMF_GridSpecQueryTileGlobal