2.18: TQWSTR

TOCGroup 1TQOPENTQOPNAGroup 2A-ZGroup 1

WRITE-STRING

Use TQWSTR to write a character string to the Fortran units associated with 'LIST' and 'ERROR'.

Synopsis

FORTRAN: CALL TQWSTR(OPTION,TEXT,NOERR)

C: tqwstr(option,text,&noerr);

Pascal: tqwstr(option,text,noerr);

Basic: Call tqwstr(option,text,noerr)


Name Type Value set on call or returned
OPTION CHARACTER Set to either 'LIST' or 'ERROR'
TEXT CHARACTER Set to a character string
NOERR INTEGER Returns an error number

This subroutine can be used to write user-defined textual output to the Fortran units associated with 'LIST' and 'ERROR'.

The output of subroutines such as TQCEL, TQMAPL, and TQSHOW, as well as ChemApp error messages can be redirected to files, using TQCIO. Unless the application program is written in Fortran and ChemApp is used as a static library, it is difficult or even impossible to write arbitrary user-defined text to the same file, since it needs to be addressed under a specific Fortran unit number.

For this purpose, TQWSTR may be used, which allows a character string to be written to the Fortran units associated with 'LIST' and 'ERROR'.

The maximum length of the string is determined by the character length conventions of the language in which the application program is written. A length of 255 characters should pose no problem for any application language.

See also

See TQOPEN, TQCIO, TQGIO

Examples

FORTRAN:View plain source code



C Redirecting ChemApp output and user-defined text to the same file
PROGRAM CAF32 IMPLICIT NONE
INTEGER NOERR, FUNIT, LUNIT, IPC, NUMCON CHARACTER LOGTXT*80 DOUBLE PRECISION CO2AMT, DARR2(2)
C Initialise ChemApp CALL TQINI(NOERR)
C Get the unit number from which the thermochemical data-file C will be read CALL TQGIO('FILE ', FUNIT, NOERR)
C Open the thermochemical data-file cosi.dat (system C-O-Si) C for reading CALL TQOPNA('cosi.dat', FUNIT, NOERR)
C Read data-file CALL TQRFIL(NOERR)
C Close data-file CALL TQCLOS(FUNIT, NOERR)
C Input 3 mol of CO2/GAS/ CO2AMT = 3.D0 CALL TQINPC('CO2', 1, IPC, NOERR) CALL TQSETC('IA ', 1, IPC, CO2AMT, NUMCON, NOERR)
C Redirect 'LIST' output (e.g. output from TQCEL) to a different C unit number LUNIT = 21 CALL TQCIO('LIST ', LUNIT, NOERR)
C Open a file under this unit number CALL TQOPEN('caf32.rst', LUNIT, NOERR)
C Write a descriptive text to file 'result' CALL TQWSTR('LIST ', 'Output from TQCEL (ChemSage result table)', * NOERR)
100 FORMAT(A,G8.3) WRITE(LOGTXT, FMT=100) 'Incoming amount of CO2 in mol: ', CO2AMT
CALL TQWSTR('LIST ', LOGTXT, NOERR)
C Write ChemSage result table to file 'result' CALL TQCEL(' ',0,0,DARR2,NOERR)
C Direct 'LIST' output back to the standard output unit CALL TQCIO('LIST ', 6, NOERR)
C Close the file 'result' CALL TQCLOS(LUNIT, NOERR)
END








C:View plain source code




/* Program cac32 */ /* Redirecting ChemApp output and user-defined text to the same file */
#include "cacint.h"
int main() { LI noerr, funit, lunit, ipc, numcon; char logtxt[80]; DB co2amt, darray2[2];

/* Initialise ChemApp */ tqini(&noerr);
/* Get the unit number from which the thermochemical data-file will be read */ tqgio("file", &funit, &noerr);
/* Open the thermochemical data-file cosi.dat (system C-O-Si) for reading */ tqopna("cosi.dat", funit, &noerr);
/* Read data-file */ tqrfil(&noerr);
/* Close data-file */ tqclos(funit,&noerr);
/* Input 3 mol of CO2/GAS/ */ co2amt = 3.0; tqinpc("CO2", 1, &ipc, &noerr); tqsetc("ia ", 1, ipc, co2amt, &numcon, &noerr);
/* Redirect "list" output (e.g. output from tqcel) to a different unit number */ lunit = 21; tqcio("list", lunit, &noerr);
/* Open a file under this unit number */ tqopen("cac32.rst", lunit, &noerr);
/* Write a descriptive text to file "result" */ tqwstr("list", "Output from tqcel (ChemSage result table)", &noerr);
sprintf(logtxt, "Incoming amount of CO2 in mol: %li", co2amt);
tqwstr("list", logtxt, &noerr);
/* Write ChemSage result table to file "result" */ tqcel(" ", 0, 0, darray2, &noerr);
/* Direct "list" output back to the standard output unit */ tqcio("list", 6, &noerr);
/* Close the file "result" */ tqclos(lunit, &noerr);
return 0;
}


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