Io_control

io_control.txt 17-Oct-1996

Input/output group of command sentences are used to access data files on disk in order to read or write data or redirect command input. READ and WRITE command sentences are described separately.

Syntax



CLOSE UNIT int

INQUIRE variable "PROMPT"

OPEN UNIT int FILE file_name READONLY


                             WRITE_ENABLE
REWIND UNIT int

       FILE

RETURN

STREAM UNIT int

@ file_name < file_name

CLOSE

CLOSE UNIT int

CLOSES the currently OPENED file on FORTRAN UNIT int.

OPEN

OPEN UNIT int

      FILE file_name
      READONLY
      WRITE_ENABLE
      OVER_WRITE
      APPEND
      FORMATTED
      UNFORMATTED
      RECORD_LENGTH int

OPENS access to the FILE name file_name on FORTRAN UNIT int. Default options are FORMATTED, READONLY files with variable record length (0). To create a new FILE and write into it, the FILE must be OPENED using the WRITE_ENABLE command word. OVER_WRITE means that a file will be overwritten if it exist. Otehrwise a new file will be opened. RECORD_LENGTH int defines fixed records (when greater than 0). FORMATTED and UNFORMATTED file attributes need no explanation.

You can use your own environments under UNIX to shorten file names or to make your command files the same throughout various computers, even UNIX and VMS environments. An environment string must end with a colon as 'MAIN:' and should be defined as '/metka/dus/main/'. There is no translation of environment strings under VMS, whre you should use the assign or define VMS commands.

INQUIRE

INQUIRE VARIABLE string

        REAL
        INTEGER
        CHARACTER
TEXT "SOME PROMPT WITH AN EXPLANATION"
        GLOBAL
        LOCAL

INQUIRES a value for a variable directly form the terminal, regardless from where the current command input comes from. VARIABLE string gives the variable name. INTEGER, REAL or CHARACTER variables can be inquired. There is no default type recognition, so you have to specify the variable type you want. The specified variables can be LOCAL or GLOBAL. The TEXT inside "" appears at the beginning of a line as a prompt.

An INQUIRE sentence is used for example when PLOT has been activated from the IMAGE menu asking for the name of the output file. The command is also quite often used to obtain some input from the menu macros.

REWIND

REWIND UNIT int

       FILE

REWINDS file OPENED under FORTRAN UNIT int or REWINDS the current command input file. The later is utilized in loops.

RETURN

RETURN

RETURNS the command input to the calling input level. It can be used in the command files entered with the '@' or STREAM command sentence. RETURN from the default command input level has no effect.

It deletes all local variables.

STREAM

STREAM UNIT int

Transfers the command input to the file accessed under FORTRAN UNIT int. 10 levels of command STREAMING are allowed. After RETURN command the input file is not closed as by the @ or<.

@

@ file_name integer < file_name real

                strings

Transfers the command input to the file file_name. 10 levels of @ command are allowed (the stack for input files has 10 places). When command interpreter reaches RETURN or end of file the file is closed. The default file_name extension is '.com', so that it doesn't have to be specified.

Arguments of integer, real or character type can be passed to a command file macro via the 'by value' mechanism. On the lower level they are interpreted with the SUBROUTINE command, which assignes variable types to each particular arguments. This way created variables exist only locally within the current command macro procedure. They are deleted when the RETURN command is invoked.

SUBROUTINE

SUBROUTINE INTEGER int

           REAL    real
           CHARACTER string

Creates local variables transferred through the macro calling command @ and assigns them local names. ANy combination and number of variable names and types can be applied. Naturally, the transffered variables must match by their type and number.


> subroutine real r1 integer GG ...

Examples


MAIN> open unit 1 file gly.dat write


MAIN> close unit 2


> return


MAIN> stream unit 99


MAIN> @>utils/protein.bond


> @some_macro int II real r1 real r2 ...