Previous: Calling Sequences Up: SUBLIB Subroutine Library Next: Other-Language Bridges

Fortran vs. C

When porting a SUBLIB subroutine, an important consideration is what language to write it in. Many of the old SUBLIB routines are written in Fortran. You should consider rewriting some of them in C.

Many of these Fortran subroutines do system calls to perform some function (for example, ostime, datfmt, and daydat all use VMS system services to obtain the date in various ways). The VMS system services do not exist in Unix, so the code will have to be changed to make Unix system calls. However, Unix system calls from Fortran are not well standardized, whereas they are much more so when called from C. Also, VMS and Unix code will have to be separate, and machine-specific code may have to be used to get around differences in different variants of Unix. It is very difficult to do machine-specific code in Fortran due to the lack of a preprocessor, while it is easy in C. Therefore, any code that calls the operating system directly should be written in C.

For subroutines that do not call the operating system, the case is less clear, and Fortran is acceptable. However, writing a C bridge for a Fortran routine is much more difficult than writing a Fortran bridge for a C routine, especially if there are strings in the argument list. Any routine that accepts strings in the argument list could definitely benefit from being written in C.