Traditional FORTRAN environments usually assume carriage control on all logical units. They usually interpret blank spaces on input as zeroes, and often provide attachment of global file names to logical units at runtime. The routine IOINIT(3F) can be called to specify these I/O control parameters. This routine:
Recognizes carriage control for all formatted files.
Ignores trailing and embedded blanks in input files.
Positions files at the beginning or end upon opening.
Preattaches file names of a specified pattern with logical units.
CALL IOINIT ( .TRUE., .FALSE., .FALSE., 'FORT', .FALSE.)
For the above call, the FORTRAN runtime system looks in the environment for names of the form FORTnn, and then opens the corresponding logical unit for sequential formatted I/O.
OPEN( UNIT=07, FORM='FORMATTED' )
The FORTRAN runtime system looks in the environment for the FORT07 file, and connects it to unit 7.
In general, names must be of the form PREFIXnn, where the particular PREFIX is specified in the call to IOINIT, and nn is the logical unit to be opened. Unit numbers less than 10 must include the leading 0. For details, see IOINIT(3F) and the Sun Fortran Library Reference.
Example: Attach external files ini1.inp and ini1.out to units 1 and 2:
demo$ TST01=ini1.inp demo$ TST02=ini1.out demo$ export TST01 TST02
demo% setenv TST01 ini1.inp demo% setenv TST02 ini1.out
demo% cat ini1.f CHARACTER PRFX*8 LOGICAL CCTL, BZRO, APND, VRBOSE DATA CCTL, BZRO, APND, PRFX, VRBOSE & /.TRUE., .FALSE., .FALSE., 'TST', .FALSE. / C CALL IOINIT( CCTL, BZRO, APND, PRFX, VRBOSE ) READ( 1, *) I, B, N WRITE( *, *) 'I = ', I, ' B = ', B, ' N = ', N WRITE( 2, *) I, B, N END demo% cat $TST01 12 3.14159012 6 demo% f77 ini1.f ini1.f: MAIN: demo% a.out I = 12 B = 3.14159 N = 6 demo% cat $TST02 12 3.14159 6
demo% cp /opt/SUNWspro/SC5.0/src/ioinit.f .