exists a
SCOTCHF
TYPEACTION
()
Fortran counterpart, in which the separating
underscore character is replaced by an “
F
”. In most cases, the Fortran routines
have exactly the same parameters as the C functions, save for an added trailing
INTEGER
argument to store the return value yielded by the function when the
return type of the C function is not
void
.
Since all the data structures used in
libScotch
are opaque, equivalent dec-
larations for these structures must be provided in Fortran. These structures must
therefore be defined as arrays of
DOUBLEPRECISION
s, of sizes given in file
scotchf.h
,
which must be included whenever necessary.
For routines which read or write data using a
FILE *
stream in C, the Fortran
counterpart uses an
INTEGER
parameter which is the numer of the Unix file descrip-
tor corresponding to the logical unit from which to read or write. In most Unix
implementations of Fortran, standard descriptors 0 for standard input (logical unit
5), 1 for standard output (logical unit 6) and 2 for standard error are opened by
default. However, for files which are opened using
OPEN
statements, an additional
function must be used to obtain the number of the Unix file descriptor from the
number of the logical unit. This function is called
PXFFILENO
in the normalized
POSIX Fortran API, and files which use it should include the
USE IFPOSIX
direc-
tive whenever necessary. An alternate, non normalized, function also exists in most
Unix implementations of Fortran, and is called
FNUM
.
For instance, the
SCOTCH graphInit
and
SCOTCH graphLoad
routines, described
in sections 7.5.1 and 7.5.4, respectively, can be called from Fortran by using the
following code.
INCLUDE "scotchf.h"
DOUBLEPRECISION GRAFDAT(SCOTCH_GRAPHDIM)
INTEGER RETVAL
...
CALL SCOTCHFGRAPHINIT (GRAFDAT (1), RETVAL)
IF (RETVAL .NE. 0) THEN
...
OPEN (10, FILE=’brol.grf’)
CALL SCOTCHFGRAPHLOAD (GRAFDAT (1), FNUM (10), 1, 0, RETVAL)
CLOSE (10)
IF (RETVAL .NE. 0) THEN
...
Although the “
scotchf.h
” and “
ptscotchf.h
” files may look very similar on
your system, never mistake them, and always use the “
scotchf.h
” file as the in-
clude file for compiling a program which uses only the sequential routines of the
libScotch
library.
7.1.3
Compiling and linking
The compilation of C or Fortran routines which use routines of the
libScotch
library requires that either
scotch.h
or
scotchf.h
be included, respectively.
The routines of the
libScotch
library are grouped in a library file called
libscotch.a
. Default error routines that print an error message and exit are pro-
vided in library file
libscotcherr.a
.
Therefore, the linking of applications that make use of the
libScotch
li-
brary with standard error handling is carried out by using the following options:
48