Sun Studio 12: Fortran Programming Guide

11.2 Fortran Initialization Routines

Main programs compiled by f95 call dummy initialization routine f90_init in the library at program start up. The routines in the library are dummies that do nothing. The calls the compilers generate pass pointers to the program’s arguments and environment. These calls provide software hooks you can use to supply your own routines, in C, to initialize a program in any customized manner before the program starts up.

One possible use of these initialization routines to call setlocale for an internationalized Fortran program. Because setlocale does not work if libc is statically linked, only Fortran programs that are dynamically linked with libc should be internationalized.

The source code for the init routines in the library is


void f90_init(int *argc_ptr, char ***argv_ptr, Char ***envp_ptr) {}

f90_init is called by f95 main programs. The arguments are set to the address of argc, the address of argv, and the address of envp.