0 G Using SunCGI with Fortran Programs All functions provided in SunCGI may be called from FORTRAN programs by linking them with the libcgi 77. a library. This is done by using the f17 com- piler with a command line like: % f77 -o box box.f -lcgi77 -lcgi -lsunwindow -lpixrect -lrn where box. f is the FORTRAN source program. Note that libcgi. a must be linked with the program (the -lcgi option), and libcgi 77. a must precede it (the -lcgi 77 option). 0 Defined constants may be referenced in source programs by including cgidefs77. h. In a FORTRAN program, this must be done via a source state- ment like:
include 'cgidefs77.h' This include statement must be in each FORTRAN program unit which uses the defined constants, not just once in each source program file. In the Sun release of FORTRAN, names are restricted to sixteen characters in length and may not contain the underline character. For this reason, FORTRAN programs must use abbreviated names to call the corresponding SunCGI func- tions. The correspondence between the full SunCGI names and the FORTRAN names appears later in this appendix. In addition, FORTRAN declarations for all SunCGI functions appear at the end of this appendix. G.1.
Programming Tips The abbreviated names of the SunCGI functions are less readable than the full length names because the underline character cannot be used in the FORTRAN names. However, since FORTRAN doesn't distinguish between upper-case and lower-case letters in names, upper-case characters can be used to improve rea- dability. There is an example of this later in this appendix. • Char.lcter strings passed from FORTRAN programs to SunCGI cannot be longer than 256 characters. 0 • Pointers returned by C functions are handled in FORTRAN as integer*4 values, and exist solely to be passed to other Sun graphics functions. FORTRAN passes all arguments by reference.
Although some SunCGI func- tions receive arguments by value, the FORTRAN programmer need not wony 151 Version C of 17 March 1986