2.17: TQOPEN

TOCGroup 1TQRCSTTQWSTRGroup 2A-ZGroup 1

OPEN-FILE

Use TQOPEN to open a file for reading or writing by ChemApp.

TQOPEN has been partially superceded by TQOPNA and TQOPNB in ChemApp versions V3.3.0 and later, see the note below.

Synopsis

FORTRAN: CALL TQOPEN(NAME,UNIT,NOERR)

C: tqopen(name,unit,&noerr);

Pascal: tqopen(name,unit,noerr);

Basic: Call tqopen(name,unit,noerr)


Name Type Value set on call or returned
NAME CHARACTER Set to the filename of the data-file to open
UNIT CHARACTER Set to the unit number under which it should be opened
NOERR INTEGER Returns an error number

This routine is used to open files under a specific FORTRAN unit number. Starting with ChemApp V3.3.0, it should only be used to open files for writing. FORTRAN programmers may use the standard OPEN statement instead, if ChemApp is used as a static library.

There are three standard cases where ChemApp application programs need to open files using TQOPEN:

  1. TQRFIL and TQRBIN, which read a thermochemical data-file, expect this file to be opened under a specific unit number (10 by default, see Table 6). If you are using ChemApp V3.3.0 or later, you should use TQOPNA and TQOPNB instead to open ASCII and binary thermochemical data-files.

  2. TQCEL, TQMAPL, and TQSHOW write by default to standard output. If the output from these subroutines should be written to a file instead, the file has to be opened using TQOPEN with the proper unit number (see TQCIO and Table 6).

  3. Error messages from ChemApp are by default written to standard output as the errors occur. If this is not desired (for instance when the application program has a graphical user interface), the error messages can be redirected to a file, and/or retrieved individually using TQERR. The file to which the error messages would be written in such a case needs to be opened using TQOPEN.

Note that TQOPEN does not check whether the file to be opened already exists or not, since TQOPEN can be used both for opening existing files for reading, and new files for writing. Whether the file to be opened already exists should be checked prior to a call to TQOPEN.

If you receive an error 102 or 103 when reading the data-file with TQRFIL, and you find a file of zero bytes length under the name you passed to TQOPEN, this means that this file has just been created with the call to TQOPEN. It didn't exist before, and didn't get shortened, but created instead. It usually means that either the wrong filename was passed to TQOPEN, or the file was not located in the directory where the program expected it. The reason for this behaviour is that TQOPEN can both be used to open existing files for reading, as well as new files for writing.

Both problems mentioned above are resolved if TQOPNA is used instead of TQOPEN to open thermochemical data-files in ASCII format, TQOPNB to open binary data-files, and TQOPNT to open transparent data-files.

A file that has been opened using TQOPEN should subsequently be closed only with TQCLOS.

See also

See TQOPNA, TQOPNB, TQOPNT

Examples

See TQWSTR


ChemApp Programmer's Manual, Edition 3.6© GTT-Technologies, 2003