ADF_Database_Open (filename,status,format,root_ID,error_return) | ||
---|---|---|
Language | C | Fortran |
Routine Name | ADF_Database_Open | ADFDOPN |
Input | const char *filename const char *status const char *format | character*(*) filename character*(*) status character*(*) format |
Output | double *root_ID int *error_return | real*8 root_ID integer error_return |
filename | A legal file name that may include a relative or absolute path where it is directly usable by the C fopen() system routine (no environment expansion is done). | ||||||||||||||||||||||
status | Similar to a Fortran OPEN() status.
Input is required: there is no default.
Allowable values are:
| ||||||||||||||||||||||
format | Specifies the numeric format for the file.
This field is used only when a file is created and is ignored
when status = OLD.
Allowable values are:
| ||||||||||||||||||||||
root_ID | The root identity of the database. | ||||||||||||||||||||||
error_return | Error return code. |
This routine, ADF_Database_Open, opens a new or existing database. If links to other ADF files exist in the current file, they will be opened only as required. Using this routine is similar to opening a file in Fortran with the corresponding clarifiers, such as whether it is READ_ONLY, OLD, NEW, or named as SCRATCH file.
The format of the file, which is ignored when the status of the file is OLD, is used when the file is first created. Big endian is a binary format in which the most significant byte or bit comes first, whereas in little endian, the most significant byte or bit comes last. To specify the format more explicitly, you can use the following formats:
IEEE_BIG_32 IEEE_BIG_64 IEEE_LITTLE_32 IEEE_LITTLE_64for IEEE big or little endian formats.
This example opens a new database using the native format of the host computer. Note that the default format is specified by using the empty string. In the C programming language, a null string could have been used.
PROGRAM TEST CHARACTER*(80) MSG REAL*8 RID INTEGER IERR CALL ADFDOPN('db.adf','NEW',' ',RID,IERR) IF (IERR .GT. 0) THEN CALL ADFERR(IERR,MSG) PRINT *,MSG STOP ENDIF STOP END
ADF_Database_Close (root_ID,error_return) | ||
---|---|---|
Language | C | Fortran |
Routine Name | ADF_Database_Close | ADFDCLO |
Input | const double *root_ID | real*8 root_ID |
Output | int *error_return | integer error_return |
root_ID | The root identification of the database. This can be a valid node ID for this database. | ||
error_return | Error return code. |
This routine, ADF_Database_Close, closes an existing database,
as well as the other ADF files that may be attached through links.
For example, if there is another ADF file that is opened and linked to
this database, only the file stream associated with this database will
be closed.
This routine is similar to the close of a file in Fortran.
Example
This example closes a database. Note that while the root ID is used in the call to ADFDCLO, any valid node ID for this file will work. Also, in general, it is not necessary to close open ADF files when the program exits normally. The standard shutdown procedures will flush all buffers and bring files up to date. The primary use of ADFDCLO is to clean up file tables or to release unused files.
PROGRAM TEST CHARACTER*(80) MSG REAL*8 RID INTEGER IERR CALL ADFDOPN('db.adf','NEW',' ',RID,IERR) IF (IERR .GT. 0) THEN CALL ADFERR(IERR,MSG) PRINT *,MSG STOP ENDIF . ...do useful stuff (hopefully) . CALL ADFDCLO(RID,IERR) STOP END
ADF_Database_Delete (filename,error_return) | ||
---|---|---|
Language | C | Fortran |
Routine Name | ADF_Database_Delete | ADFDDEL |
Input | const char *filename | character*(*) filename |
Output | int *error_return | integer error_return |
filename | A legal file name of an existing ADF database. The filename may include a relative or absolute path where it is directly usable by the C fopen() system routine (no environment expansion is done). | ||
error_return | Error return code. |
This routine, ADF_Database_Delete, deletes an existing database
file.
It does not delete links referenced in the database.
This routine is similar to the deletion of a file in Fortran.
Note: This routine will be implemented in a future release.
ADF_Database_Get_Format (root_ID,format,error_return) | ||
---|---|---|
Language | C | Fortran |
Routine Name | ADF_Database_Get_Format | ADFDGF |
Input | const double *root_ID | real*8 root_ID |
Output | char *format int *error_return | character*(*) format integer error_return |
root_ID | Any valid node ID for the given ADF file. | ||
format | The format for the file. | ||
error_return | Error return code. |
This routine, ADF_Database_Get_Format, gets the data format for
an existing database.
Example
This example opens an existing ADF database, creates a new node, and then uses the node ID for the new node to ask what the file type is. Note that the file format is ignored because the database already exists.
PROGRAM TEST CHARACTER*(80) MSG CHARACTER*(32) FORM REAL*8 RID,CID INTEGER IERR CALL ADFDOPN('db.adf','OLD',' ',RID,IERR) IF (IERR .GT. 0) THEN CALL ADFERR(IERR,MSG) PRINT *,MSG STOP ENDIF CALL ADFCRE(RID,'junk_node',CID,IERR) CALL ADFDGF(CID,FORM,IERR) PRINT *,'FILE FORMAT = ',FORM STOP END
ADF_Database_Set_Format (root_ID,format,error_return) | ||
---|---|---|
Language | C | Fortran |
Routine Name | ADF_Database_Set_Format | ADFDSF |
Input | const double *root_ID | real*8 root_ID |
Output | const char *format int *error_return | character*(*) format integer error_return |
root_ID | The root identity of the database. | ||
format | The numeric format for the file. | ||
error_return | Error return code. |
This routine, ADF_Database_Set_Format, sets the data format in
an existing database.
Note: Use with extreme caution. This routine is needed only for the
data conversion utilities and not intended for the general user.