ESMF_CFIOFileOpen Subroutine

public subroutine ESMF_CFIOFileOpen(cfio, fmode, rc, expid, cyclic)

ESMF_CFIOFileOpen – open a CFIO file, and get CFIO meta data into a cfio Object.

Arguments

Type IntentOptional Attributes Name
type(ESMF_CFIO), intent(inout) :: cfio

a CFIO object

integer, intent(in) :: fmode

0 for READ-WRITE non-zero for READ-ONLY

integer, intent(out), optional :: rc

Error return code: 0 all is well -1 invalid count -2 type mismatch -12 error determining default precision -10 ngatts is incompatible with file -11 character string not long enough -19 unable to identify coordinate variable -36 error from NF90_PUT_ATT (global attribute) -39 error from NF90_OPEN (file open) -40 error from NF90_INQ_VARID -41 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon) -42 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev) -43 error from NF90_INQ_VARID (time variable) -47 error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (time) -48 error from NF90_INQUIRE -51 error from NF90_GET_ATT (global attribute) -52 error from NF90_INQUIRE_VARIABLE -53 error from NF90_GET_ATT -57 error from NF90_INQ_ATTNAME -58 error from NF90_INQUIRE_ATTRIBUTE

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

Experiment ID

logical, intent(in), optional :: cyclic

cyclic input file


Calls

proc~~esmf_cfiofileopen~~CallsGraph proc~esmf_cfiofileopen ESMF_CFIOFileOpen proc~esmf_cfioget ESMF_CFIOGet proc~esmf_cfiofileopen->proc~esmf_cfioget proc~esmf_cfiosdffileopen ESMF_CFIOSdfFileOpen proc~esmf_cfiofileopen->proc~esmf_cfiosdffileopen proc~esmf_cfioset ESMF_CFIOSet proc~esmf_cfiofileopen->proc~esmf_cfioset proc~err err proc~esmf_cfioget->proc~err nf90_get_att nf90_get_att proc~esmf_cfiosdffileopen->nf90_get_att nf90_get_var nf90_get_var proc~esmf_cfiosdffileopen->nf90_get_var nf90_inq_attname nf90_inq_attname proc~esmf_cfiosdffileopen->nf90_inq_attname nf90_inq_varid nf90_inq_varid proc~esmf_cfiosdffileopen->nf90_inq_varid nf90_inquire nf90_inquire proc~esmf_cfiosdffileopen->nf90_inquire nf90_inquire_attribute nf90_inquire_attribute proc~esmf_cfiosdffileopen->nf90_inquire_attribute nf90_inquire_dimension nf90_inquire_dimension proc~esmf_cfiosdffileopen->nf90_inquire_dimension nf90_inquire_variable nf90_inquire_variable proc~esmf_cfiosdffileopen->nf90_inquire_variable proc~cfio_attinquire CFIO_AttInquire proc~esmf_cfiosdffileopen->proc~cfio_attinquire proc~cfio_diminquire CFIO_DimInquire proc~esmf_cfiosdffileopen->proc~cfio_diminquire proc~cfio_getattnames CFIO_GetAttNames proc~esmf_cfiosdffileopen->proc~cfio_getattnames proc~cfio_getcharatt CFIO_GetCharAtt proc~esmf_cfiosdffileopen->proc~cfio_getcharatt proc~cfio_getintatt CFIO_GetIntAtt proc~esmf_cfiosdffileopen->proc~cfio_getintatt proc~cfio_getrealatt CFIO_GetRealAtt proc~esmf_cfiosdffileopen->proc~cfio_getrealatt proc~cfio_open CFIO_Open proc~esmf_cfiosdffileopen->proc~cfio_open proc~esmf_cfiosdffileopen->proc~err proc~esmf_cfiovarinfocreate ESMF_CFIOVarInfoCreate proc~esmf_cfiosdffileopen->proc~esmf_cfiovarinfocreate proc~getbegdatetime GetBegDateTime proc~esmf_cfiosdffileopen->proc~getbegdatetime proc~identifydim IdentifyDim proc~esmf_cfiosdffileopen->proc~identifydim proc~strtemplate_ strTemplate_ proc~esmf_cfiosdffileopen->proc~strtemplate_ proc~addlist addList proc~esmf_cfioset->proc~addlist proc~esmf_cfioset->proc~err proc~strtoint strToInt proc~esmf_cfioset->proc~strtoint proc~cfio_attinquire->nf90_inquire_attribute proc~cfio_attinquire->proc~err proc~cfio_diminquire->nf90_get_att proc~cfio_diminquire->nf90_inq_varid proc~cfio_diminquire->nf90_inquire proc~cfio_diminquire->nf90_inquire_dimension proc~cfio_diminquire->nf90_inquire_variable proc~cfio_diminquire->proc~err proc~cfio_diminquire->proc~identifydim proc~cfio_getattnames->nf90_inq_attname proc~cfio_getattnames->nf90_inquire proc~cfio_getattnames->proc~err proc~cfio_getcharatt->nf90_get_att proc~cfio_getcharatt->nf90_inquire_attribute proc~cfio_getcharatt->proc~err proc~cfio_getintatt->nf90_get_att proc~cfio_getintatt->nf90_inquire_attribute proc~cfio_getintatt->proc~err proc~cfio_getrealatt->nf90_get_att proc~cfio_getrealatt->nf90_inquire_attribute proc~cfio_getrealatt->proc~err proc~cfio_open->proc~err ncopn ncopn proc~cfio_open->ncopn proc~esmf_cfiogridcreate ESMF_CFIOGridCreate proc~esmf_cfiovarinfocreate->proc~esmf_cfiogridcreate proc~getbegdatetime->nf90_get_att proc~getbegdatetime->nf90_get_var proc~getbegdatetime->nf90_inq_varid proc~getbegdatetime->nf90_inquire proc~getbegdatetime->nf90_inquire_dimension proc~getbegdatetime->nf90_inquire_variable proc~getbegdatetime->proc~err proc~getbegdatetime->proc~identifydim interface~getdate GetDate proc~getbegdatetime->interface~getdate proc~cfio_parseinttime CFIO_parseIntTime proc~getbegdatetime->proc~cfio_parseinttime proc~parsetimeunits ParseTimeUnits proc~getbegdatetime->proc~parsetimeunits proc~gx_ GX_ proc~strtemplate_->proc~gx_

Called by

proc~~esmf_cfiofileopen~~CalledByGraph proc~esmf_cfiofileopen ESMF_CFIOFileOpen none~find~33 CFIOCollection%find none~find~33->proc~esmf_cfiofileopen proc~mapl_cfioopenwrite MAPL_CFIOOpenWrite proc~mapl_cfioopenwrite->proc~esmf_cfiofileopen program~test test program~test->proc~esmf_cfiofileopen program~test~10 test program~test~10->proc~esmf_cfiofileopen program~test~2 test program~test~2->proc~esmf_cfiofileopen program~test~4 test program~test~4->proc~esmf_cfiofileopen proc~mapl_cfiocreatefromfile MAPL_CFIOCreateFromFile proc~mapl_cfiocreatefromfile->none~find~33 proc~mapl_cfioreadbundleread MAPL_CFIOReadBundleRead proc~mapl_cfioreadbundleread->none~find~33

Source Code

      subroutine ESMF_CFIOFileOpen (cfio, fmode, rc, expid, cyclic)
!
! !INPUT PARAMETERS:
!
      integer, intent(in) :: fmode              !! 0 for READ-WRITE
                                                !! non-zero for READ-ONLY
      character(len=*), intent(in), OPTIONAL :: expid   !! Experiment ID
      logical, intent(in), OPTIONAL :: cyclic           !! cyclic input file
!
! !OUTPUT PARAMETERS:
!
      integer, intent(out), OPTIONAL :: rc      !! Error return code:
                                                !! 0   all is well
                         !! -1   invalid count
                         !! -2   type mismatch
                         !! -12  error determining default precision
                         !! -10  ngatts is incompatible with file
                         !! -11  character string not long enough
                         !! -19  unable to identify coordinate variable
                         !! -36  error from NF90_PUT_ATT (global attribute)
                         !! -39  error from NF90_OPEN (file open)
                         !! -40  error from NF90_INQ_VARID
                         !! -41  error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lat or lon)
                         !! -42  error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (lev)
                         !! -43  error from NF90_INQ_VARID (time variable)
                         !! -47  error from NF90_INQ_DIMID or NF90_INQUIRE_DIMENSION (time)
                         !! -48  error from NF90_INQUIRE
                         !! -51  error from NF90_GET_ATT (global attribute)
                         !! -52  error from NF90_INQUIRE_VARIABLE
                         !! -53  error from NF90_GET_ATT
                         !! -57  error from NF90_INQ_ATTNAME
                         !! -58  error from NF90_INQUIRE_ATTRIBUTE

!
! !INPUT/OUTPUT PARAMETERS:
!
      type(ESMF_CFIO), intent(inout) :: cfio    !! a CFIO object
!
!------------------------------------------------------------------------------
      integer :: rtcode
      character(len=16) :: dset
      character(len=16) :: format
      logical :: ex
      character(len=MLEN) :: fileName
      logical :: myCyclic


      if (present(expid)) call ESMF_CFIOSet(cfio, expid = expid)
      myCyclic = .false.
      if (present(cyclic)) then
         call ESMF_CFIOSet(cfio, isCyclic = cyclic)
         myCyclic = cyclic
      end if

      call ESMF_CFIOGet(cfio, fName=fileName)
      inquire(file=fileName, EXIST=ex)
      if ( .not. ex ) then
         print *, trim(fileName), "doesn't exist"
         return
      end if
      open(11, file=fileName)
      read(11, '(a)') dset
      close(11)
      format = 'SDF'
      if (index(dset,'DSET') .ge. 1 .or. index(dset,'dset') .ge. 1  &
          .or. index(dset,'Dset') .ge. 1 ) then
         call ESMF_CFIOSet(cfio, format='GRADS')
         format = 'GRADS'
      end if

      select case (format)
      case ('SDF')
         if ( present(expid) ) then
            call ESMF_CFIOSdfFileOpen (cfio, fmode, rc=rtcode, expid=expid, cyclic=myCyclic)
         else
            call ESMF_CFIOSdfFileOpen (cfio, fmode, rc=rtcode, cyclic=myCyclic)
         end if
         if (rtcode .ne. 0) print *, "Error in ESMF_CFIOSdfFileOpen"
         if ( present(rc) ) rc = rtcode
         return
      end select

      end subroutine ESMF_CFIOFileOpen