CFIO_Open Subroutine

public subroutine CFIO_Open(fname, fmode, fid, rc)

CFIO_Open – Opens an existing DAO gridded file

This routine opens an existing DAO gridded file. The file mode will be read/write. If the application already knows the contents of the file, it may begin interaction with the file using the returned file handle. Otherwise, the file handle can be used with the “inquire” routines to gather information about the contents. A negative return code indicates there were problems opening the file.

History

  • 1998.07.02 Lucchesi Initial interface design.
  • 1998.07.07 Lucchesi Initial coding.
  • 1998.12.09 Lucchesi Corrected for ncopn bug.

Arguments

Type IntentOptional Attributes Name
character(len=*) :: fname

File name

integer :: fmode

File mode: 0 for READ-WRITE non-zero for READ-ONLY

integer :: fid

File handle

integer :: rc

Error return code: rc = 0 All is well rc = -39 error from ncopn (file open)


Calls

proc~~cfio_open~~CallsGraph proc~cfio_open CFIO_Open ncopn ncopn proc~cfio_open->ncopn proc~err err proc~cfio_open->proc~err

Called by

proc~~cfio_open~~CalledByGraph proc~cfio_open CFIO_Open proc~esmf_cfiosdffileopen ESMF_CFIOSdfFileOpen proc~esmf_cfiosdffileopen->proc~cfio_open proc~esmf_cfiofileopen ESMF_CFIOFileOpen proc~esmf_cfiofileopen->proc~esmf_cfiosdffileopen 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 CFIO_Open ( fname, fmode, fid, rc )
!
! !USES:
!

      Implicit NONE

!
! !INPUT PARAMETERS:
!

      character(len=*)   fname         !! File name
      integer         fmode         !! File mode:
                                    !!   0 for READ-WRITE
                                    !!   non-zero for READ-ONLY

!
! !OUTPUT PARAMETERS:
!

      integer        fid            !! File handle
      integer        rc             !! Error return code:
                                    !!   rc = 0    All is well
                                    !!   rc = -39  error from ncopn (file open)
!
!-------------------------------------------------------------------------


       if ( fmode .EQ. 0) then
         fid = ncopn (fname, NCWRITE, rc)
       else
         fid = ncopn (fname, NCNOWRIT, rc)
       endif
       if (fid .LT. 0) then   ! ncopn has a bug.  error codes should
         rc = fid             ! be returned in rc, but in reality they
       endif                  ! are returned in fid.

       if (err("Open: error opening file",rc,-39) .NE. 0) return

       rc = 0
       return
       end subroutine CFIO_Open