FORTRAN - mixing Fortran 66 and B routines.

Description:

Fortran 66 Subroutines (or functions) can be called and executed from B programs. To do this, the Fortran subroutines should be compiled into a random library (see "expl ranedit") so that they can be loaded by the B command.

Fortran subroutines are invoked from B by using CALLF or CALLFF (see "expl b lib callf" and "expl b lib callff"). A Fortran subroutine may in turn call a B function by using CALLB (see "expl b lib callb").

Input/Output:

With few exceptions, Fortran subroutines need not know whether or not they are being called by a B program; however, there are restrictions and special procedures required for Fortran subroutines that do I/O. The B run-time library must be told which B I/O unit is to be associated 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"). By default, Fortran output units 6, 42, and 43 are attached to B unit 1, and Fortran input units 5 and 41 are attached to B unit 0. Calls to LGU.AT can be used to change these default attachments if desired.

A Fortran unit number can be attached to any B I/O unit, including B unit -1 (CALLSS, or system output).

Restrictions on I/O:

Not all Fortran I/O features may be used within B. There will be attempts to remedy this in future releases. Fortran binary and random I/O are not currently supported. The B run-time library will inform the user if attempts are made to use these features.

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

The Fortran statements

BACKSPACE f
ENDFILE   f
REWIND    f

are not yet supported in B.

There are several subroutines described in the GCOS-8 Fortran manual that are not supported. Most of these are either infrequently used or obsolete. The complete list of unsupported subroutines is

FILBSP  FLGEOF  FLGERR  FLGFRC
SETBUF  SETFCB  SETLGU

In addition, the following three subroutines are not currently supported but should be in the near future:

FCLOSE  FMEDIA  RANSIZE

There are five subroutines which have names that conflict with names in the B run-time library. Attempts to call these routines from Fortran will invariably result in the B function being loaded instead of the Fortran one. There is currently no easy way around this problem. The inaccessible Fortran routines are

EXIT    use Fortran's STOP 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

The Fortran Debugging System (FDS) is not supported, but B's debugger BOFF can be used in its place. Note however that the following FDS routines cannot be called:

FDEBUG  FDUMP  FTIMER  NOCALL  NTCALL

Known Bugs:

It often happens that a B program invokes a Fortran subroutine that just does a calculation and returns. The Fortran program does no I/O. To avoid the overhead of the Fortran run-time library, B's run-time library has been set up to avoid loading the Fortran library unless a Fortran subroutine explicitly calls for it.

This procedure does not work if the Fortran subroutine that requires the Fortran library is found in the system library and not in a user's library. This idiosyncrasy occurs because the system library is searched after the B run-time library has already decided that the Fortran run-time library is not necessary. It is possible to force the use of the Fortran run-time library by specifying

extrn ftn.io;

within your B program.

See Also:

expl b lib externals

Copyright © 1996, Thinkage Ltd.