Compiling IBM Open XL Fortran programs

This section explains how to compile a source program using the invocation commands.

To compile a source program, use one of the xlf, xlf_r, f77, fort77, xlf90, xlf90_r, f90, xlf95, xlf95_r, f95, xlf2003, xlf2003_r, f2003, xlf2008, xlf2008_r, and f2008 commands, which have the form:
Read syntax diagramSkip visual syntax diagramxlfxlf_rf77fort77xlf90xlf90_rf90xlf95xlf95_rf95xlf2003xlf2003_rf2003xlf2008xlf2008_rf2008cmd_line_optinput_file

These commands all accept essentially the same Fortran language. The main difference is that they use different default options (which you can see by reading the configuration file /opt/IBM/openxlf/17.1.0/etc/xlf.cfg.nn where .nn represents the operating system level).

The invocation command performs the necessary steps to compile the Fortran source files, assemble any .s files, and link the object files and libraries into an executable program. In particular, the xlf_r, xlf90_r, xlf95_r, xlf2003_r, and xlf2008_r commands use the components for multithreading (libraries, crt0_r.o, and so on) to link and bind object files.

The following table summarizes the invocation commands that you can use:
Table 1. IBM Open XL Fortran Invocation commands
Driver Invocation 1 Chief Functionality Linked Libraries
xlf Selected Fortran language level 2 libxlf90.a
xlf_r The threadsafe version of the selected language level, operating system default POSIX pthreads API. 2 libxlf90.a
f77, fort77 FORTRAN 77 libxlf90.a
xlf90, f90 Fortran 90 libxlf90.a
xlf90_r Threadsafe Fortran 90, operating system default POSIX pthreads API libxlf90.a
xlf95, f95 Fortran 95 libxlf90.a
xlf95_r Threadsafe Fortran 95, operating system default POSIX pthreads API libxlf90.a
xlf2003 Fortran 2003 libxlf90.a
xlf2003_r Threadsafe Fortran 2003, operating system default POSIX pthreads API libxlf90.a
f2003 Fortran 2003 libxlf90.a
xlf2008 Fortran 2008 libxlf90.a
xlf2008_r Threadsafe Fortran 2008, operating system default POSIX pthreads API libxlf90.a
f2008 Fortran 2008 libxlf90.a
Notes:
  1. These invocation commands are contained in the /opt/IBM/openxlf/17.1.0/bin directory.
  2. The xlf and xlf_r invocation commands select the appropriate language level according to the suffix of the source file names. The other invocation commands behave consistently no matter what the Fortran source file name suffix is. See the following example:

    xlf program1.f program2.f90 program3.f95 program4.f03 program5.f08
    
    The behavior is as follows:
    • The program1.f file is compiled as if the invocation command was f77.
    • The program2.f90 file is compiled as if the invocation command was xlf90.
    • The program3.f95 file is compiled as if the invocation command was xlf95.
    • The program4.f03 file is compiled as if the invocation command was xlf2003.
    • The program5.f08 file is compiled as if the invocation command was xlf2008.

libxlf90.a is provided for both threaded and non-threaded applications. XL Fortran determines at run time whether your application is threaded.

IBM® Open XL Fortran provides the library libxlf90_t.a, in addition to libxlf90.a. libxlf90_t.a exports the same entry points as libxlf90.a does. Unlike libxlf90.a, libxlf90_t.a does not provide thread synchronization or thread-reentrant routines. Therefore, only one Fortran thread at a time can perform I/O operations or invoke Fortran intrinsics. You can use libxlf90_t.a instead of libxlf90.a in multithread applications where there is only one Fortran thread, to avoid the thread synchronization overhead in libxlf90.a.

When you bind a multithreaded executable with multiple Fortran threads, -lxlf90 should appear instead of -lxlf90_t in the command line. Note that using the xlf_r, xlf90_r, xlf95_r, xlf2003_r, or xlf2008_r invocation command ensures the proper linking.

The directive triggers that are implied by invocation commands or options are listed as follows:
  • For f77, fort77, f90, f95, f2003, xlf, xlf90, xlf95, xlf2003, and xlf2008 invocation commands, the directive trigger is IBM* by default.
  • For all other invocation commands, the directive triggers are IBM* and IBMT by default.
  • When -qthreaded is in effect, the compiler also recognizes the IBMT directive trigger.