The following sections describe in detail the subroutine calls that define the common file library. All of the subroutine calls (with the exception of CFERMS and CFINIT) have the following format using the Fortran interface:
CALL CFxxxx (STATUS, STATE, ...)where STATUS is an integer value returned by the routine to indicate success or failure of the request and STATE is an integer variable corresponding to the file state to which the request is to be applied. A file state represents a particular file and node to which a common file request is applied. The application must initialize the STATE variable to zero before the first call to CFSTFP or CFRECL for a specific file. Thereafter the library routines maintain the STATE variable. Note that the application must not modify the STATE variable.
By default, all of the common file routines abort the program if an error is detected except CFINIT, CFERMS, CFVINF, and CFNINF. The program may prevent this action by calling CFSTFP to set the ABORT flag to zero. This will cause the library routines to return a non-zero status value if an error is detected.
The common file library now supports a C interface. The C interface has the same arguments, with the same meanings, as the Fortran interface, and the C routine names are the same as the Fortran routine names with the leading "CF" replaced by "CF_C". The type definitions and defines for the C interface are in the cfbind_c_2_f.h include file.
The following sections show the calling statement for each subroutine, with the Fortran version listed first, followed by the C version in italics. The arguments are then defined, and classified as Input, Output, or Temporary. In a few cases, an argument has two definitions, one for input and another for output. The argument names include the data type (i.e., integer, character, etc.), and again the Fortran name is listed first, followed by the C name in italics.
CALL CFINIT () void CF_Cinit () |
CFINIT initializes various internal tables used by the common file library routines. It must be called at least once in a program and must be called before any other common file library routine. Multiple calls to this subroutine will have no effect on the common file tables or operation.
CALL CFSTFP (STATUS, STATE, PARNAM, PARVAL) Fint CF_Cstfp (status, state, parnam, parval) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file or the state variable initialized to zero if no previous calls to CFSTFP, CFGTFP, or CFRECL have been made to this file. | |||
Output | The root state if STATE was zero. | ||||
CHARACTER*(*) PARNAM Fchar *parnam | Input | The name of the parameter to be set. | |||
INTEGER PARVAL Fint parval | Input | The value to be assigned to the parameter specified in PARNAM. |
CFSTFP is used to set the file parameters for use by a subsequent
CFOPEN request.
The following parameters can be set:
UNIT | No default, must be set except for version 3 | ||
CIO | Use C I/O interface, limited support, not used for version 3 | ||
ABORT | 1 (abort if error occurs) | ||
FILE_CPU | File CPU type | ||
FILE_OS | File operating system type | ||
RECORD_LENGTH | Depends on host CPU and operating system | ||
MAX_NODES | Maximum number of nodes per subnode | ||
MAX_VARIABLES | Maximum number of variables per node | ||
MAX_INTEGERS | Number of INTEGER elements in a node header | ||
MAX_REALS | Number of REAL elements in a node header | ||
MAX_CHARACTERS | Number of CHARACTER*80 elements in a node header | ||
FILE_VERSION | Version of the file to create must equal 2 or 3 (default) |
The values of RECORD_LENGTH, MAX_NODES, MAX_VARIABLES, MAX_INTEGERS, MAX_REALS, and MAX_CHARACTERS must be a multiple of two to allow for portability between machines and are subject to limitations described in the section "Default Library Values and Limits." For version 3 files the unit number is not used since the open is done in C.
If a file is opened and a specific parameter has not been set by CFSTFP then a default value will be assigned for the parameter. The default values are also defined in the section "Default Library Values and Limits."
Only the ABORT, FILE_CPU, and FILE_OS parameters may be set after the file is opened. For version 3 files the MAX_NODES and MAX_VARIABLES parameters may be changed after open to redefine the maximum that is allowed to be created in the file.
CALL CFGTFP (STATUS, STATE, PARNAM, PARVAL) Fint CF_Cgtfp (status, state, parnam, parval) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file or the state variable initialized to zero if no previous calls to CFSTFP, CFGTFP or CFRECL have been made to this file. | |||
Output | The root state if STATE was zero. | ||||
CHARACTER*(*) PARNAM Fchar *parnam | Input | Name of the parameter whose value is to be returned. | |||
INTEGER PARVAL Fint *parval | Output | Value of the requested parameter. |
CFGTFP retrieves the value of a file parameter. If called prior to opening a file then the value returned will be either the default value for the parameter or the value set by CFSTFP. If called after the file is opened then the value will be that contained in the file header.
The parameter name may be any one of the following names:
UNIT OPEN HOST_CPU HOST_OS ABORT FILE_CPU FILE_OS RECORD_LENGTH MAX_NODES MAX_VARIABLES MAX_INTEGERS MAX_REALS MAX_CHARACTERS LAST_RECORD VERSIONNote that FILE_CPU, FILE_OS and LAST_RECORD are not known until the file is opened.
CALL CFRECL (STATUS, STATE, MAXPTS, PRECSN) Fint CF_Crecl (status, state, maxpts, precsn) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file or the state variable initialized to zero if no previous calls to CFSTFP, CFGTFP, or CFRECL have been made to this file. | |||
Output | The root state if STATE was zero. | ||||
INTEGER MAXPTS Fint maxpts | Input | Maximum variable size. | |||
INTEGER PRECSN Fint precsn | Input | Precision of the proposed record. 1 = Real or Integer. 2 = Double precision. |
CFRECL sets the record length to be used when creating a common file with a subsequent CFOPEN request. The routine uses MAXPTS and PRECSN to calculate a record length acceptable to the operating system. This works fine for simple one size variable files but not very well for files containing variables of many different sizes. Thus the CFOREC routine should be used to calculate record lengths for an arbitrary sized file. For version 3 files there is no record length although the record length parameter stored in the file is still used to determine the size of the conversion buffers used in the CFRVxx subroutines.
For example, assume you are going to be writing single precision records dimensioned IDIM × JDIM × KDIM. The following call will set the record length:
RSTATE = 0 CALL CFRECL (STATUS, RSTATE, IDIM*JDIM*KDIM, 1)
CALL CFOPEN (STATUS, STATE, FILNAM, MODE) Fint CF_Copen (status, state, filnam, mode) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state from a previous CFSTFP or CFRECL call for the file. | |||
Output | The state for the root node of the file. | ||||
CHARACTER*(*) FILNAM Fchar *filnam | Input | The name of the file to be opened. Any extension must be included (.cgd, .cfl, etc.). FILNAM is ignored if MODE is specified as SCRATCH. If FILNAM is all blanks, a file name of FOR0uu (where uu is the unit number set by CFSTFP) will be used. | |||
CHARACTER*(*) MODE Fchar *mode | Input | How the file is to be opened. MODE must be OLD, NEW, or SCRATCH. |
CFOPEN allocates internal tables for the common file library and opens the file for processing.
A CFOPEN call must be preceded, at minimum, by a call to CFSTFP to set the unit number. For version 3 files the unit number is not used, thus the CFSTFP call is unnecessary in the following example of a minimal opening sequence for a common file:
INTEGER STATE, STATUS STATE = 0 CALL CFINIT () CALL CFSTFP (STATUS, STATE, 'UNIT', 11) CALL CFOPEN (STATUS, STATE, 'TEST.CGD', 'NEW')
When CFOPEN is called with a mode of NEW or SCRATCH, the attributes of the file are set from either default values or from the values set by calls to CFSTFP. The default values are listed in the section "Default Library Values and Limits."
When CFOPEN is called with a mode of OLD, the default values or the values specified by CFSTFP are used to verify that the calling program can accomodate the file being opened and are subsequently overwritten by the actual values from the file. Thus if the program let everything default and tried to open a file with MAX_INTEGERS set to 128, the request to open the file would be rejected.
The only routines that can be called prior to CFOPEN for a given file are CFSTFP, CFRECL, CFOREC, CFUNIT, and CFERMS.
CALL CFCLOS (STATUS, STATE) Fint CF_Cclos (status, state) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state (from CFOPEN) of the file to be closed. | |||
Output | Zero. |
CFCLOS closes a common file. Any internal table space within the common file library is released and made available for use for other files.
CALL CFCNOD (STATUS, STATE, NODNAM, NSTATE) Fint CF_Ccnod (status, state, nodnam, nstate) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state of the node that will be the parent node of the subnode that is being created. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the subnode to be created. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER NSTATE Fint *nstate | Output | The state of the newly created subnode. |
CFCNOD is used to create a subnode under another node. The following code fragment creates a subnode under the root node using the name stored in ZNAME (RSTATE is the root state returned by CFOPEN):
CHARACTER*32 ZNAME INTEGER ZONE,ZSTATE,RSTATE ZNAME = subnode_name CALL CFCNOD (STATUS, RSTATE, ZNAME, ZSTATE)
Once the request has been successfully completed, the program may read and write the node header information and variables of the subnode by using the the new state (ZSTATE) as the state for subsequent calls to CFR/WNOD and CFR/WVxNOD.
The integer and real elements in the node header will be initialized to zero and the character elements will be initialized to blank.
CALL CFCLNK (STATUS, STATE, NODNAM, FILNAM, LNKNAM, NSTATE) Fint CF_Clnk (status, state, nodnam, filnam, lnknam, nstate) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state of the node that will be the parent node of the subnode that is being created. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the subnode to be created. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
CHARACTER*(*) FILNAM Fchar *filnam | Input | The name of the file to link to; if blank, the link will be to a node in the current file. | |||
CHARACTER*(*) LNKNAM Fchar *lnknam | Input | The name of the node to link to. | |||
INTEGER NSTATE Fint *nstate | Output | The state of the newly created subnode. |
CFCLNK is used to create a subnode which points to another node. The node may be in the current file or another file. The FILNAM can contain a path, but it is not recommended since the user does not know what the path is, and so does not know where the file should be located so the library can open it. The following code fragment creates a link under the root node called ZNAME which points to node "Zone 1" in file ZONE1.cgd (RSTATE is the root state returned by CFOPEN):
CHARACTER*32 ZNAME,LNKNAM,FILNAM INTEGER ZONE,ZSTATE,RSTATE ZNAME = 'Node 1' FILNAM = 'ZONE1.cgd' LNKNAM = '/ZONE 1' CALL CFCLNK (STATUS, RSTATE, ZNAME, FILNAM, LNKNAM, ZSTATE)
CALL CFNDEL (STATUS, STATE, NODNAM) Fint CF_Cndel (status, state, nodnam) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state of the node that is the parent node of the subnode that is being deleted. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the subnode to be deleted. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). |
CFNDEL is used to delete a subnode under another node. The following code fragment deletes a subnode under the root node using the name stored in ZNAME (RSTATE is the root state returned by CFOPEN):
CHARACTER*32 ZNAME INTEGER ZONE,RSTATE ZNAME = subnode_name CALL CFNDEL (STATUS, RSTATE, ZNAME)
Once the request has been successfully completed, all data for the node and all subnodes under that node will be inaccessible. For version 1 and 2 files the data is not removed and the space becomes dead space in the file. For version 3 files the ADF core puts the space into a free chunk table to be reallocated to a new node or variable. The actual size of the file does not change.
CALL CFNMOV (STATUS, STATE, NODNAM, TSTATE) Fint CF_Cnmov (status, state, nodnam, tstate) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state of the node that is the parent node of the subnode that is being moved. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the subnode to be moved. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER TSTATE Fint *tstate | Input | The state of the new parent node for NODNAM. |
CFNMOV is used to move a subnode from one node to another in the same file. All subnodes of the moved node move with it. No data in the file is actually moved; only the node pointers are moved.
CALL CFNREN (STATUS, STATE, NODNAM, NEWNAM) Fint CF_Cnren (status, state, nodnam, newnam) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state of the node that is the parent node of the subnode that is being renamed. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the subnode to be renamed. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
CHARACTER*(*) NEWNAM Fchar *newnam | Input | The new name of the node. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). |
CFNREN is used to rename a subnode of a node. The new name must be unique under the parent node.
CALL CFSNOD (STATUS, STATE, NODNAM, NSTATE) Fint CF_Csnod (status, state, nodnam, nstate) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | State of the node containing the specified subnode. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the subnode to be accessed. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER NSTATE Fint *nstate | Output | The node state of the requested subnode. |
CFSNOD is used access a subnode under another node. The following code fragment accesses a subnode under the root node using the name stored in ZNAME (RSTATE is the root state returned by CFOPEN):
CHARACTER*32 ZNAME INTEGER ZONE,ZSTATE,RSTATE ZNAME = subnode_name CALL CFSNOD (STATUS, RSTATE, ZNAME, ZSTATE)
Once the request has been successfully completed, the program may read and write the node header information and variables of the subnode by using the the new state (ZSTATE) as the state for subsequent calls to CFR/WNOD and CFR/WVxNOD.
CALL CFRNOD (STATUS, STATE, IPAR, FPAR, CPAR) Fint CF_Crnod (status, state, ipar, fpar, cpar) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node whose header information is to be read. | |||
INTEGER IPAR(*) Fint *ipar | Output | The integer elements from the node header. The size of the array must be at least MAX_INTEGERS long (default 64, see CFSTFP). | |||
REAL FPAR(*) Freal *fpar | Output | The real elements from the node header. The size of the array must be at least MAX_REALS long (default 64, see CFSTFP). | |||
CHARACTER*80 CPAR(*) Fchar **cpar | Output | The character elements from the node header. The size of the array must be at least MAX_CHARACTERS long (default 2, see CFSTFP). |
CFRNOD reads the application dependent node header information for the specified node.
CALL CFWNOD (STATUS, STATE, IPAR, FPAR, CPAR) Fint CF_Cwnod (status, state, ipar, fpar, cpar) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node whose header information is to be written. | |||
INTEGER IPAR(*) Fint *ipar | Input | The integer elements from the node header. The size of the array must be at least MAX_INTEGERS long (default 64, see CFSTFP). | |||
REAL FPAR(*) Freal *fpar | Input | The real elements from the node header. The size of the array must be at least MAX_REALS long (default 64, see CFSTFP). | |||
CHARACTER*80 CPAR(*) Fchar **cpar | Input | The character elements from the node header. The size of the array must be at least MAX_CHARACTERS long (default 2, see CFSTFP). |
CFWNOD writes the application dependent node header information for the specified node.
CALL CFNINF (STATUS, STATE, NODNAM, NNODES, NVARS) Fint CF_Cninf (status, state, nodnam, nnodes, nvars) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | State of the node. | |||
CHARACTER*(*) NODNAM Fchar *nodnam | Input | Name of the node. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER NNODES Fint *nnodes | Output | Number of subnodes under the node. | |||
INTEGER NVARS Fint *nvars | Output | Number of variables under the node. |
CFNINF returns information about a node. Note that if the requested node is not present, CFNINF will not abort even if the ABORT flag is set.
CALL CFRVI (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT) Fint CF_Crvi (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node which contains the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be read. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements read. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data to the output array. | |||
INTEGER VARDAT(*) Fint *vardat | Output | The data read from the file. |
CFRVI reads an integer variable located under the specified node.
CALL CFRVR (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT) Fint CF_Crvr (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node which contains the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be read. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements read. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data to the output array. | |||
REAL VARDAT(*) Freal *vardat | Output | The data read from the file. |
CFRVR reads a real variable located under the specified node.
CALL CFRVD (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT) Fint CF_Crvd (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node which contains the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be read. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements read. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data to the output array. | |||
DOUBLE PRECISION VARDAT(*) Fdouble *vardat | Output | The data read from the file. |
CFRVD reads a double precision precision variable located under the specified node.
CALL CFRVRX (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT, TMPBUF) Fint CF_Crvrx (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be read. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements read. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data to the output array. | |||
REAL VARDAT(*) Freal *vardat | Output | The data read from the file. | |||
DOUBLE PRECISION TMPBUF(*) | Temporary | A temporary buffer capable of containing a record length of real numbers. The record length can be obtained from CFGTFP. |
CFRVRX reads either a real or double precision value located under the specified node into a single precision array. If the requested variable is a single precision variable then the call is equivalent to a call to CFRVR. If the requested variable is double precision then the data is read in and converted to single precision in the output array.
CALL CFRVDX (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT, TMPBUF) Fint CF_Crvdx (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be read. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements read. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data to the output array. | |||
DOUBLE PRECISION VARDAT(*) Fdouble *vardat | Output | The data read from the file. | |||
REAL TMPBUF(*) | Temporary | A temporary buffer capable of containing a record length of real numbers. The record length can be obtained from CFGTFP. |
CFRVDX reads either a real or double precision value located under the specified node into a double precision array. If the requested variable is a double precision variable then the call is equivalent to a call to CFRVD. If the requested variable is single precision then the data is read in and converted to double precision in the output array.
CALL CFRVC (STATUS, STATE, VARNAM, VARLEN, CHRSIZ, INCR, VARDAT) Fint CF_Crvc (status, state, varnam, varlen, chrsiz, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be read. It will be truncated or padded with blanks to 32 characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements read. | |||
INTEGER CHRSIZ Fint *chrsiz | Input | The size of the character elements. CHRSIZ is used to increment through the data elements for Fortran character arrays. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data to the output array. | |||
CHARACTER*(*) VARDAT(*) Fchar *vardat | Output | The data read from the file. |
CFRVC reads a character variable located under the specified node. This function is only available in version 3 or greater.
CALL CFWVI (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT) Fint CF_Cwvi (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be written. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint varlen | Input | Number of elements to write. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when writing the data to the file. | |||
INTEGER VARDAT(*) Fint *vardat | Input | The data to be written. |
CFWVI writes an integer variable under the specified node. The variable will be created if it does not already exist. If the variable already exists, the new contents will replace the old contents. The old length and the new length do not have to be equal.
CALL CFWVR (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT) Fint CF_Cwvr (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be written. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint varlen | Input | Number of elements to write. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when writing the data to the file. | |||
REAL VARDAT(*) Freal *vardat | Input | The data to be written. |
CFWVR writes a real variable under the specified node. The variable will be created if it does not already exist. If the variable already exists, the new contents will replace the old contents. The old length and new length do not have to be equal.
If the variable already exists and is double precision, the data will be written as double precision. The input data will be unaffected.
CALL CFWVD (STATUS, STATE, VARNAM, VARLEN, INCR, VARDAT) Fint CF_Cwvd (status, state, varnam, varlen, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be written. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint varlen | Input | Number of elements to write. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when writing the data to the file. | |||
DOUBLE PRECISION VARDAT(*) Fdouble *vardat | Input | The data to be written. |
CFWVD writes a double precision variable under the specified node. The variable will be created if it does not already exist. If the variable already exists, the new contents will replace the old contents. The old length and new length do not have to be equal.
If the variable exists and is single precision, the data will be written as single precision. The input data will be unaffected.
CALL CFWVC (STATUS, STATE, VARNAM, VARLEN, CHRSIZ, INCR, VARDAT) Fint CF_Cwvc (status, state, varnam, varlen, chrsiz, incr, vardat) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node containing the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be written. It will be truncated or padded with blanks to 32 characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARLEN Fint varlen | Output | Number of elements of size CHRSIZ to write. | |||
INTEGER CHRSIZ Fint *chrsiz | Input | The size of the character elements. The total length written will be VARLEN*CHRSIZ. CHRSIZ is also used to increment through the data elements for Fortran character arrays. | |||
INTEGER INCR Fint incr | Input | Increment between elements to be applied when moving data from the output array. | |||
CHARACTER*(*) VARDAT(*) Fchar *vardat | Input | The data written to the file. |
CFWVC writes a character variable located under the specified node. This function is only available in version 3 or greater.
CALL CFVDEL (STATUS, STATE, VARNAM) Fint CF_Cvdel (status, state, varnam) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The state of the node that contains the variable that is being deleted. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to be deleted. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). |
CFVDEL is used to delete a variable under a node. Once the request has been successfully completed, all data for the variable will be inaccessible. For version 1 and 2 files the data is not removed and the space becomes dead space in the file. For version 3 files the ADF core puts the space into a free chunk table to be reallocated to a new node or variable. The actual size of the file does not change.
CALL CFERMS (ERRNUM, ERRTXT) Fint CF_Cerms (errnum, errtxt) |
INTEGER ERRNUM Fint *errnum | Input | Error number for which text is being requested. | |||
CHARACTER*(*) ERRTXT Fchar *errtxt | Output | Text for specified error number. |
CFERMS returns a textual error message corresponding to an error number returned by a call to a common file library routine. See the section "Status Codes" for the error numbers and their associated text. For version 3 files the ADF core errors are returned as a negative number to distinguish them from the common file error numbers. The ADF error message routine is automatically called to return the proper error string.
CALL CFRREF (STATUS, STATE, VARNAM, UCOFST, UCSCAL, NDOFST, NDSCAL) Fint CF_Crref (status, state, varnam, ucofst, ucscal, ndofst, ndscal) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to obtain reference data. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
REAL UCOFST Freal *ucofst | Output | Unit conversion offset. | |||
REAL UCSCAL Freal *ucscal | Output | Unit conversion scale factor. | |||
REAL NDOFST Freal *ndofst | Output | Non-dimensionalization offset. | |||
REAL NDSCAL Freal *ndscal | Output | Non-dimensionalization scale factor. |
CFRREF reads the reference and scaling data for the specified variable. If no reference and scaling data has been written for the specified variable then the following values are returned:
UCOFST = 0.0 UCSCAL = 1.0 NDOFST = 0.0 NDSCAL = 1.0
CALL CFWREF (STATUS, STATE, VARNAM, UCOFST, UCSCAL, NDOFST, NDSCAL) Fint CF_Cwref (status, state, varnam, ucofst, ucscal, ndofst, ndscal) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to write reference data. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
REAL UCOFST Freal ucofst | Input | Unit conversion offset. | |||
REAL UCSCAL Freal ucscal | Input | Unit conversion scale factor. | |||
REAL NDOFST Freal ndofst | Input | Non-dimensionalization offset. | |||
REAL NDSCAL Freal ndscal | Input | Non-dimensionalization scale factor. |
CFWREF writes the reference and scaling data for the specified variable.
Note: To obtain conversion numbers, use the CFUNIT subroutine, or see the section "Conversion Factors."
CALL CFVINF (STATUS, STATE, VARNAM, VARTYP, VARLEN) Fint CF_Cvinf (status, state, varnam, vartyp, varlen) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Node state of the node that contains the requested variable. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | Name of the variable to obtain information. It will be truncated or padded with blanks to 8 (for versions 1 and 2) or 32 (for version 3) characters as required. The name is case-sensitive (i.e., x is not equal to X). | |||
INTEGER VARTYP Fint *vartyp | Output | The type of the requested variable. 1 = Integer 2 = Real 3 = Double precision 4 = Character | |||
INTEGER VARLEN Fint *varlen | Output | Number of elements in the specified variable. |
CFVINF returns the type and length of the specified variable. Note that if the requested variable is not present, CFVINF will not abort even if the ABORT flag is set. For character variables the length returned will be the element length times the character size.
CALL CFVLST (STATUS, STATE, VARLST, VARTYP, NUMVAR) Fint CF_Cvlst (status, state, varlst, vartyp, numvar) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The node state for the list of variables to be returned. | |||
CHARACTER*(*) VARLST(*) Fchar **varlst | Output | The variables associated with the specified node. | |||
INTEGER VARTYP(*) Fint *vartyp | Output | The types of the variables in VARLST. 1 = Integer 2 = Real 3 = Double precision 4 = Character | |||
INTEGER NUMVAR Fint *numvar | Input | If equal to −1 then only return NUMVAR, otherwise return lists also. | |||
Output | The number of variables returned. |
CFVLST returns the list of variables associated with the specified node.
CALL CFNLST (STATUS, STATE, NODLST, NUMNOD) Fint CF_Cnlst (status, state, nodlst, numnod) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The node state for the subnode list to be returned. | |||
CHARACTER*(*) NODLST Fchar **nodlst | Output | List of subnodes under the specified node. | |||
INTEGER NUMNOD Fint *numnod | Input | If equal to −1 then only return NUMNOD, otherwise return lists also. | |||
Output | The number of subnodes returned. |
CFNLST returns a list of subnodes of the specified node.
CALL CFSLST (STATUS, STATE, VARLST, NUMVAR) Fint CF_Cslst (status, state, varlst, numvar) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file. | |||
CHARACTER*(*) VARLST Fchar **varlst | Output | List of variables that have reference and scaling data. | |||
INTEGER NUMVAR Fint *numvar | Input | If equal to −1 then only return NUMVAR, otherwise return lists also. | |||
Output | The number of variable names returned. |
CFSLST returns a list of variables that have reference and scaling data.
CALL CFUNIT (STATUS, STATE, VARNAM, MODE, CUNITS, DUNITS, CNVOFF, CNVSCL) Fint CF_Cunit (status, state, varnam, mode, cunits, dunits, cnvoff, cnvscl) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | The root state of the file. | |||
CHARACTER*(*) VARNAM Fchar *varnam | Input | The name of the variable or unit quantity for which unit/conversion data is derived. | |||
CHARACTER*(*) MODE Fchar *mode | Input | CURRENT - get current units NEW - get conversion factors from CUNITS to DUNITS. | |||
CHARACTER*(*) CUNITS Fchar *cunits | Input | When mode is NEW it is the current(from) units. If blank and VARNAM is a CFD variable it will be derived from reference and scaling data. | |||
Output | When mode is CURRENT it contains the current system of units the variable is determined to be in using the reference and scaling data for the variable. | ||||
CHARACTER*(*) DUNITS Fchar *dunits | Input | When mode is NEW it is the desired units that you wish to convert to. | |||
Output | When mode is CURRENT it contains the current units the variable is determined to be in using the reference and scaling data for the variable. | ||||
REAL CNVOFF Freal *cnvoff | Output | Current/new conversion offset. | |||
REAL CNVSCL Freal *cnvscl | Output | Current/new conversion scale factor. |
CFUNIT returns the current system of units and the units for any CFD variable when the mode is CURRENT. When then mode is NEW, CFUNIT returns conversion data from CUNITS to DUNITS where the input CUNITS and DUNITS can be a system of units or the actual units. If actual units are used they must conform to the format used in the section "Conversion Factors." Valid systems of units are MKS = SI = METRIC, CGS, ENGLISH = BRITISH = FSS (Foot-Slug-Second), and FPP (Foot-Pound-Second). VARNAM may be any CFD variable name or a unit type. Valid unit types are LENGTH, MASS, TIME, FORCE, DENSITY, TEMPERATURE, ENERGY, ENTROPY, VELOCITY, PRESSURE, GAS CONSTANT and VISCOSITY. If VARNAM is a CFD variable and either CUNITS is blank or mode is CURRENT then the current units will be derived from the reference and scaling data. If no reference and scaling data have been stored for the variable the default will be the MKS system. For readability the following aliases have been set up for use in the CUNITS and DUNITS variables.
m = meter = meters cm = centimeter = centimeters mm = millimeter = millimeters ft = feet in = inch = inches kg = kilogram = kilograms g = gram = grams slug = slugs lbf = lb = pounds K = KELVIN C = CENTIGRADE = CELSIUS R = RANKINE F = FAHRENHEIT J = N-m erg = dyn-cmNote: These aliases can not be combined.
For consistency this subroutine should be used in all CFD applications.
The following examples illustrate the use of this subroutine.
Example 1
When the variable is old and is being read into an application, the application wants the variable to be in certain units. The following reads the variable 'x' and places it in the units of inches. This example uses the fact that MSCALE and MOFF factors are stored to convert 'x' to the MKS system of units.
CALL CFRVR (STATUS, STATE, 'x', VARLEN, 1, X) CALL CFRREF (STATUS, STATE, 'x', MOFF, MSCALE, DOFF, DSCALE) CALL CFUNIT (STATUS, STATE, 'x', 'NEW', 'MKS', 'in', CNVOFF, CNVSCL) DO I = 1,VARLEN X(I) = ((X(I)*DSCALE + DOFF)*MSCLE + MOFF)*CNVSCL + CNVOFF END DONote: If the data is modified and is to be stored back into the file then the inverse conversion must be performed.
When the variable is old and is being read into an application the units that the variable is stored in may need to be known (e.g. for display). The following writes the variable 'p' to a file and includes the units as part of the output.
CALL CFRVR (STATUS, STATE, 'p', VARLEN, 1, P) CALL CFRREF (STATUS, STATE, 'p', MOFF, MSCALE, DOFF, DSCALE) CALL CFUNIT (STATUS, STATE, 'p', 'CURRENT', CUNITS, DUNITS, CNVOFF, CNVSCL) CALL UTSLEN (DUNITS, LEN) WRITE (6, 210) 'I', 'J', 'K', 'PRESSURE' DO K = 1,KMAX DO J = 1,JMAX DO I = 1,IMAX P(I,J,K) = P(I,J,K)*DSCALE + DOFF WRITE (6,200) I, J , K, P(I,J,K), DUNITS(1:LEN) END DO END DO END DO 200 FORMAT (3I5, F12.5, A) 210 FORMAT (A, 5X, A, 5X, A, 7X, A)Example 3
When the variable is first being stored, four factors must be saved for the variable using the subroutine CFWREF. The dimensional factors and units are known, CFUNIT is used to get the factors to convert those units to the MKS system of units. In the following the pressure is known to be in the 'FSS' system of units.
CALL CFUNIT (STATUS, STATE, 'p', 'NEW', 'FSS', 'MKS', MOFF, MSCALE) CALL CFWREF (STATUS, STATE, 'p', MOFF, MSCALE, DOFF, DSCALE) CALL CFWVR (STATUS, STATE, 'p', VARLEN, 1, P)
CALL CFOREC (STATUS, STATE, DIMLST, NUMDIM, TYPE, PRECIS, RECLEN) Fint CF_Corec (status, state, dimlst, numdim, type, precis, reclen) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Global state of common file to search with FULL type. | |||
INTEGER DIMLST(4,NUMDIM) Fint *dimlst | Input | List of zone dimensions and number of fringe points. | |||
INTEGER NUMDIM Fint *numdim | Input | Number of dimensions in DIMLST. | |||
CHARACTER*(*) TYPE Fchar *type | Input | Type of common file to compute record length (CGD, CFL, CGF, ZDF, FULL). For FULL, all variables in the CF file STATE are used and DIMLST is not used. | |||
INTEGER PRECIS Fint precis | Input | Precision of the output variables (1=single, 2=double). | |||
INTEGER RECLEN Fint *reclen | Output | Optimal record length. |
CFOREC calculates the optimal record length for a common file. There are five modes 'FULL', 'CGD', 'CFL', 'CGF', or 'ZDF'. Mode 'FULL' works on existing common files and uses the actual variable sizes stored in the file to calulate the optimal record length. The other modes make a guess at the optimal record length based on the zone dimensions input. The 'CGD' mode is similar to the 'CFL' mode except that it takes into account the variable sizes of boundary conditions. If you are not storing boundary conditions then the 'CFL' mode should be used. For version 3 files there is no record length although the record length parameter stored in the file is still used to determine the size of the conversion buffers used in the CFRVxx subroutines.
CALL CFVSIZ (STATUS, STATE, MAXI, MAXR, MAXD) Fint CF_Cvsiz (status, state, maxi, maxr, maxd) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Global state of common file to search. | |||
INTEGER MAXI Fint *maxi | Output | The size of the largest integer variable in the file. | |||
INTEGER MAXR Fint *maxr | Output | The size of the largest real variable in the file. | |||
INTEGER MAXD Fint *maxd | Output | The size of the largest double precision variable in the file. |
CFVSIZ searches the entire file and locates the largest variable of the given type. This is useful for check and/or allocating memory for reading file variables.
CALL CFGTRT (STATUS, STATE, ROOTSTATE) Fint CF_Cgtrt (status, state, rootstate) |
INTEGER STATUS Fint *status | Output | Return status; for C it is also the function return. | |||
INTEGER STATE Fint *state | Input | Any state of common file. | |||
INTEGER ROOTSTATE Fint *rootstate | Output | Root state of common file. |
CFGTRT returns the root state of a common file, given any state in the file.
CALL CFHOST (CPU, OS) void CF_Chost (cpu, os) |
INTEGER CPU Fint *cpu | Output | Output cpu binary type, where: 0 = Unknown 1 = Cray (1, 2, X-MP, Y-MP, C90) 2 = AX, F_FLOATING and D_FLOATING (non-AXP native) 3 = IBM (360/370) 4 = CONVEX (C1, C2 native mode) 5 = IEEE big endian (IRIS 2000/3000/4D) 6 = IEEE little endian 7 = VAX, F_FLOATING and G_FLOATING (AXP native) 8 = Unused 9 = Unused | |||
INTEGER OS Fint *os | Output | Output operating system type, where: 0 = Unknown 1 = Cray Unix 2 = Vax VMS 3 = ALPHA Unix 4 = SUN Unix 5 = RS6K Unix 6 = CONVEX Unix 7 = SGI Unix 8 = HP Unix 9 = PARAGON Unix |
Last updated 6 Mar 2006