FORTRAN - notes about Fortran and Pascal programs.

(Single Segment Pascal only)

Fortran~66 subroutines (or functions) can be called by and executed from a Pascal mainline. To do this, the Fortran subroutines should be compiled into a random library or included as object decks on the Pascal command line when loading the program. In batch, of course, an object deck may simply be included on the R* by the use of a $SELECT card or compiled in a $FORTRAN activity.

Fortran procedures are invoked in Pascal by declaring the procedure to be an external Fortran procedure. See the Pascal manual for details of the declaration syntax. A Fortran procedure cannot call a Pascal procedure unless the user writes a special interface procedure in B or GMAP. (Such an interface routine is easy to write in B, and would be invoked by the CALLB routine -- see "expl b lib callb".)

Input/Output:

With few exceptions, Fortran subroutines need not know whether or not they are being called by a Pascal program; however, there are restrictions and special procedures for Fortran subroutines that do I/O. The B/Pascal run-time library must be told which B I/O unit to associate with which Fortran unit number. The B function LGU.AT (logical-unit-attach) is used to attach a Fortran unit number to one of B's I/O units (see "expl b lib lgu.at"). The Pascal routine IOUNIT must be used to find the B unit number associated with an open Pascal file variable. By default, Fortran units 6, 42, and 43 are attached to the Pascal file variable "output", and Fortran units 5 and 41 are attached to the Pascal file variable "input". Calls to IOUNIT and LGU.AT may be used to change these default attachments if desired. Using these routines, it is possible to attach a Fortran unit to any open Pascal file variable.

There is a problem with input. In order to satisfy the Pascal lookahead requirements, the Pascal program may have read one character ahead and thus that character will not be available for Fortran input.

Restrictions on I/O:

Not all Fortran I/O features may be used within a Pascal environment. There will be attempts to relax some of these restrictions in future releases of the Pascal compiler. For the time being however, such restricted Fortran features must be avoided. The run-time package will detect some of these features and inform the user.

Fortran normally uses the first character of each output line as carriage control, whereas Pascal uses the ASCII slew characters. These two methods conflict, and as a result it is impossible to handle Fortran's "+" and "&" carriage control characters properly.

The Fortran statements

BACKSPACE u
ENDFILE   u
REWIND    u

cannot be supported in the Pascal environment. Thus they may not be used in any Fortran routine called by a Pascal program.

There are several supplied subroutines described in the GCOS-8 Fortran manual that are not supported. Most of these are either infrequently used or obsolete. They are

FILBSP  FLGEOF  FLGERR  FLGFRC
SETBUF  SETFCB  SETLGU

In addition, RANSIZE is not currently supported, although it may be in the future.

There are a number of name conflicts with Fortran library routines and routines in the Pascal/B libraries. Attempts to call these routines from Fortran will usually result in the B function being called instead because the Fortran library is searched last. Naturally, getting the wrong routine will cause errors. There is no single easy way around this problem. In some cases, equivalent functionality can be found in the B library and so it is possible to define a B routine to accomplish the desired result. For example,

EXIT    use the Fortran STOP statement instead
CONCAT  use B's MOVELR instead
ATTACH  use B's OPEN instead
CREATE  use B's OPEN instead
DEFIL   use B's OPEN instead

Alternatively, extracting an object deck of the desired routine from the system library and including it with the Pascal load will work in some cases. The object deck can either be extracted from the L* library using RANE or from the R* tapes of the GCOS release. Consult a system guru or the consultants for details of this procedure. Note that if you do this you must ensure that none of the B and Pascal code calls the B routine of the same name.

The Fortran Debugging System (FDS) is not supported. The BOFF debugger may be of help in some cases. The following FDS routines cannot be called.

FDEBUG FDUMP FTIMER NOCALL NTCALL

Copyright © 1996, Thinkage Ltd.