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.
Type | Intent | Optional | 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) |
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