HTML-IMAGE.nr 0C 0 HTML-IMAGE-END.lf 1 -

System Dependent Routines

HTML-IMAGE.nr 3c 0

      DREAD


An unbuffered direct access read routine

DRITE


An unbuffered direct access write routine

IFORK


Create a new process

IEXEC


Execute new program

IWAIT


Wait for a process to complete

SETFIL


A routine to assign a UNIX filename to a fortran logical unit

ARGFIL


A routine to use an argument to the main routine as a UNIX filename and assign the UNIX file to a fortran logical unit

SETMOD


A routine to set the file status word

IARGC


A function to get the number of arguments to the main progran

T2P


A routine to convert from TI-980b floating point format to LSI-11 floating point format

P2T


A routine to convert from LSI-11 floating point format to TI-980b floating point format

REWIND


A routine to rewind a magnetic tape unit

FRDREC


A routine to forward space a magnetic tape unit by physical records

BKREC


A routine to backward space a magnetic tape unit by physical records

ABSBIN


Converts integers to HP2648A or HP2623A display absolute binary coordinates

HTML-IMAGE-END.bp

SUBROUTINE DREAD

This subroutine does a direct access read from a fortran logical unit.

Calling sequence: CALL DREAD(LUN,IREC,LRECL,BUF,IER)

Arguments: HTML-IMAGE.nr 3c 0

      LUN:


The fortran logical unit to be read.

IREC:


The number of the record to be read. (The first record is record number 0)

LRECL:


The logical record length in bytes of each record.

BUF:


The array to which the data will be read.

IER:


An error flag. Set to zero if the read completes normally. Set to -1 if an end of file is encountered. Set to UNIX error number if any I/O error occurs.

HTML-IMAGE-END.bp

SUBROUTINE DRITE

This subroutine does a direct access write to a fortran logical unit.

Calling sequence: CALL DRITE(LUN,IREC,LRECL,BUF,IER)

Arguments: HTML-IMAGE.nr 3c 0

      LUN:


The fortran logical unit to be written.

IREC:


The number of the record to be written. (The first record is record number 0)

LRECL:


The logical record length in bytes of each record.

BUF:


The array to which the data will be written.

IER:


An error flag. Set to zero if the write completes normally. Set to UNIX error number if any I/O error occurs.

HTML-IMAGE-END.bp

FUNCTION IFORK()

This function executes the UNIX fork system call which creates a child process.

Calling sequence: I = IFORK()

Function value: The value returned is 0 in the child process and is the process id number of the child process in the parent process.

See IWAIT for an example of the use of this function.

FUNCTION IEXEC(PROGNAME,ARG0,ARG1,...)

This function executes another program.

Arguments: HTML-IMAGE.nr 3c 0

     PROGNAME:


The file name of the file to be executed.

ARGi:


A variable number of character string arguments to be passed to the executed program. By convention ARG0 should be the name of the program.

HTML-IMAGE-END Function value: This function normally never returns. If it returns the program could not be executed.

See IWAIT for an example of the use of IEXEC.

FUNCTION IWAIT(ISTAT)

This function causes the program to wait for the termination of a child process.

Arguments: HTML-IMAGE.nr 3c 0

      ISTAT:


ISTAT is set to the termination status of the child process.

HTML-IMAGE-END Function value: The returned value is the process id of the terminating child or -1 if no child exists.

Example: To execute another program and wait for its completion a combination of IFORK, IEXEC and IWAIT must be used. For example, to get a long listing of the contents of the current working directory one could use the following sequence.

        .
        .
        .

       ipid = ifork()
        if ( ipid.ne.0) goto 100
            ii = iexec(’/bin/ls’,’ls’,’-l’)
            write(6,10)
10          format(’ exec failed on /bin/ls’)
            stop
100     ii = iwait(istat)
        if (ii.ne.ipid .and. ipid.ne.-1) goto 100
        if (istat.ne.0) write(6,20) istat
20      format(’ /bin/ls returned status=’,i7)

       .
        .
        .

SUBROUTINE SETFIL

SETFIL allows any unix filename to be associated with a fortran unit number. The channel must not be open.

Calling sequence: CALL SETFIL(N,H[,M] )

e.g., call setfil(2,’../turner/somefile’)

Arguments: HTML-IMAGE.nr 3c 0

      N:


N is the fortran logical unit.

H:


H must be a null-terminated string of characters comprising the file-name. It should be noted that the compiler automatically null-terminates any text enclosed in single quotes as a subroutine argument.

M:


if present, is used as the status word for the channel.

HTML-IMAGE-END.PP The status word determines various file I/O parameters as follows:

        Bit    Name        Meaning

       15(MSB) input   sequential files -
                                set: file is input
                                reset: file is output
                        random files -
                                set: file is read-only
                                reset: file is read-write

       14      random  all -
                                set: file is random access
                                reset: file sequential access

       13      create  random -
                                set: force creation of file
                                reset: open existing file,
                                        if possible

       12      append  sequential -
                                set: if files exists on output,
                                        append to it.
                                reset: create output file

       11      carctl  sequential, ascii -
                                set: first byte of record is
                                        carriage control
                                reset: terminate record with
                                        new-line

       10      ascspc  sequential -
                                set: ascii special mode
                                reset: ascii normal mode

       9       binspc  sequential -
                                set: binary special mode
                                reset: binary normal mode

       8       lstbin  sequential -
                                set: last i/o access binary
                                reset: last i/o access ascii

       7       flush   sequential -
                                set: purge buffer on output
                                        after each i/o op.
                                reset: buffer output to 512 bytes

       6       delete  all -
                                set: delete file on endfile

       5       open    all -
                                set: file is open

       4       rgood   sequential -
                                backspace is possible on file

FUNCTION IARGC

IARGC returns the number of arguments the main program was invoked with.

Calling sequence: N = IARGC(X)

Arguments: HTML-IMAGE.nr 3c 0

      X:


A dummy argument. Not used.

HTML-IMAGE-ENDFunction value: The number of arguments.

See Subroutine ARGFIL for example

SUBROUTINE ARGFIL

ARGFIL is like SETFIL except that the K’th argument to the main program is used as the file name. Remember that the 1st argument, by convention, is the name of the program being run. Therefore, K should almost always be ≥2.

Calling sequence: CALL ARGFIL(N, K [,M] )

Arguments: HTML-IMAGE.nr 3c 0

      N:


The fortran logical unit number.

K:


The argument number.

M:


if present, is used as the status word for the channel. (see SETFIL)

HTML-IMAGE-END EXAMPLE: Fortran program:

c    variables lun = logical unit number of a file device
c              append = append mode (see subroutine setfil)
c
        integer n,lun,append
        lun = 4
        append = 20480
c   see function iargc
        n = iargc(x)
        if ( n .eq. 2 ) call argfil (lun,2,append)
        if ( n .ne. 2 ) call setfil (lun,’../turner/somefile’)
                        .
                        .
                        .

SUBROUTINE SETMOD

SETMOD sets the status word of channel n to m.

Calling sequence: CALL SETMOD(N,M)

Arguments: HTML-IMAGE.nr 3c 0

      N:


The fortran logical unit number.

M:


The new status word. (see SETFIL)

HTML-IMAGE-END.bp

FUNCTION T2P

This function translates one TI-980b format floating point number to a LSI-11 format floating point number.

Calling sequence: F = T2P(FTI)

Arguments: HTML-IMAGE.nr 3c 0

      FTI:


A 4-byte (real*4 or integer*4) input value which actually contains a TI-980b format floating point value.

HTML-IMAGE-ENDFunction value: The value returned is the LSI-11 format floating point value.

FUNCTION P2T

This function translates one LSI-11 format floating point number to a TI-980b format floating point number.

Calling sequence: F = P2T(FLSI)

Arguments: HTML-IMAGE.nr 3c 0

      FLSI:


A real*4 input value

HTML-IMAGE-ENDFunction value: The value returned is the TI-980b format floating point value.

SUBROUTINE REWIND

REWIND rewinds a magnetic tape unit.

Calling sequence: CALL REWIND(LUN,IER)

Arguments HTML-IMAGE.nr 3c 0

      LUN:


Fortran logical unit to be rewound.

IER:


Error flag. IER is set equal to zero if no error occurs. If an error occurs then IER is set to the UNIX error number.

HTML-IMAGE-END.bp

SUBROUTINE FRDREC

This routine forward spaces a magnetic tape unit.

Calling sequence: CALL FRDREC(LUN,NUM,IER)

Arguments: HTML-IMAGE.nr 3c 0

      LUN:


The fortran logical unit.

NUM:


The number of records to space forward.

IER:


Error flag. IER is set equal to zero if no error occurs. If an error occurs then IER is set to the UNIX error number.

HTML-IMAGE-END.bp

SUBROUTINE BKREC

This routine backward spaces a magnetic tape unit.

Calling sequence: CALL BKREC(LUN,NUM,IER)

Arguments: HTML-IMAGE.nr 3c 0

      LUN:


The fortran logical unit.

NUM:


The number of records to space backwards.

IER:


Error flag. IER is set equal to zero if no error occurs. If an error occurs then IER is set to the UNIX error number.

HTML-IMAGE-END.bp

SUBROUTINE ABSBIN

This subroutine converts the integers INX and INY to binary absolute HP2648A format in the variables IOUTX, IOUTY.

Calling sequence: CALL ABSBIN (INX, INY, INOUTX, IOUTY)

Arguments: HTML-IMAGE.nr 3c 0

   INX,INY:


x and y coordinates of a point to be displayed on the HP2648A graphics terminal

INOUTX,INOUTY:


x and y coordinates in A2 format to be sent to HP2648A

HTML-IMAGE-END BINARY ABSOLUTE FORMAT is plotted with respect to an origin at 0,0. Four bytes are required to specify a single end point. A ten(10) bit coordinate in the range 0-1023, is sent for both x and y.

The bytes are ordered as follows: HTML-IMAGE.nr 3c 0

            Bit   7   6    5    4    3    2    1





         BYTE 1   0   1   X9   X8   X7   X6   X5    HI X





         BYTE 2   0   1   X4   X3   X2   X1   X0   LOW X





         BYTE 3   0   1   Y9   Y8   Y7   Y6   Y5    HI Y





         BYTE 4   0   1   Y4   Y3   Y2   Y1   Y0   LOW Y



HTML-IMAGE-END EXAMPLE:

x = 360 = 01011 01000           y = 180 = 00101 10100
          HI X  LOW X                     HI Y  LOW Y

       BYTE 1 = 01 01011 = +  HI X
        BYTE 2 = 01 01000 = (  LOW X
        BYTE 3 = 01 00101 = %  HI Y
        BYTE 4 = 01 10100 = 4  LOW Y