JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.2: Fortran User's Guide
search filter icon
search icon

Document Information

Preface

1.  Introduction

2.  Using Solaris Studio Fortran

3.  Fortran Compiler Options

4.  Solaris Studio Fortran Features and Differences

4.1 Source Language Features

4.1.1 Continuation Line Limits

4.1.2 Fixed-Form Source Lines

4.1.3 Tab Form

4.1.4 Source Form Assumed

4.1.4.1 Mixing Forms

4.1.4.2 Case

4.1.5 Limits and Defaults

4.2 Data Types

4.2.1 Boolean Type

4.2.1.1 Rules Governing Boolean Type

4.2.1.2 Alternate Forms of Boolean Constants

Octal

Hexadecimal

Hollerith

4.2.1.3 Alternate Contexts of Boolean Constants

4.2.2 Abbreviated Size Notation for Numeric Data Types

4.2.3 Size and Alignment of Data Types

4.3 Cray Pointers

4.3.1 Syntax

4.3.2 Purpose of Cray Pointers

4.3.3 Declaring Cray Pointers and Fortran 95 Pointers

4.3.4 Features of Cray Pointers

4.3.5 Restrictions on Cray Pointers

4.3.6 Restrictions on Cray Pointees

4.3.7 Usage of Cray Pointers

4.4 STRUCTURE and UNION (VAX Fortran)

4.5 Unsigned Integers

4.5.1 Arithmetic Expressions

4.5.2 Relational Expressions

4.5.3 Control Constructs

4.5.4 Input/Output Constructs

4.5.5 Intrinsic Functions

4.6 Fortran 200x Features

4.6.1 Interoperability with C Functions

4.6.2 IEEE Floating-Point Exception Handling

4.6.3 Command-Line Argument Intrinsics

4.6.4 PROTECTED Attribute

4.6.5 Fortran 2003 Asynchronous I/O

4.6.6 Extended ALLOCATABLE Attribute

4.6.7 VALUE Attribute

4.6.8 Fortran 2003 Stream I/O

4.6.9 Fortran 2003 Formatted I/O Features

4.6.10 Fortran 2003 IMPORT Statement

4.6.11 Fortran 2003 FLUSH I/O Statement

4.6.12 Fortran 2003 POINTER INTENT Feature

4.6.13 Fortran 2003 Enhanced Array Constructor

4.6.14 Miscellaneous Fortran 2003 and Fortran 2008 Features

4.7 Additional I/O Extensions

4.7.1 I/O Error Handling Routines

4.7.2 Variable Format Expressions

4.7.3 NAMELIST Input Format

4.7.4 Binary Unformatted I/O

4.7.5 Miscellaneous I/O Extensions

4.8 Directives

4.8.1 Form of Special f95 Directive Lines

4.8.1.1 Fixed-Form Source

4.8.1.2 Free-Form Source

4.8.2 FIXED and FREE Directives

4.8.2.1 Scope

4.8.2.2 Uses

4.8.2.3 Restrictions

4.8.3 Parallelization Directives

4.9 Module Files

4.9.1 Searching for Modules

4.9.2 The -use=list Option Flag

4.9.3 The fdumpmod Command

4.10 Intrinsics

4.11 Forward Compatibility

4.12 Mixing Languages

5.  FORTRAN 77 Compatibility: Migrating to Solaris Studio Fortran

A.  Runtime Error Messages

B.  Features Release History

C.  Fortran Directives Summary

Index

4.9 Module Files

Compiling a file containing a Fortran 95 MODULE generates a module interface file (.mod file) for every MODULE encountered in the source. The file name is derived from the name of the MODULE; file xyz.mod (all lowercase) will be created for MODULE xyz.

Compilation also generates a .o module implementation object file for the source file containing the MODULE statements. Link with the module implementation object file along with the all other object files to create an executable.

The compiler creates module interface files and implementation object files in the directory specified by the -moddir=dir flag or the MODDIR evironment variable. If not specified, the compiler writes .mod files in the current working directory.

The compiler looks in the current working directory for the interface files when compiling USE modulename statements. The- Mpath option allows you to give the compiler an additional path to search. Module implementation object files must be listed explicitly on the command line for the link step.

Typically, programmers define one MODULE per file and assign the same name to the MODULE and the source file containing it. However, this is not a requirement.

In this example, all the files are compiled at once. The module source files appear first before their use in the main program.

demo% cat mod_one.f90
 MODULE one
    ...
 END MODULE
demo% cat mod_two.f90
 MODULE two
    ...
 END MODULE
demo% cat main.f90
 USE one
 USE two
   ...
 END
demo% f95 -o main mod_one.f90 mod_two.f90 main.f90

Compilation creates the files:

mainmain.oone.modmod_one.otwo.modmod_two.o

The next example compiles each unit separately and links them together.

demo% f95 -c mod_one.f90 mod_two.f90
demo% f95 -c main.f90
demo% f95 -o main main.o mod_one.o mod_two.o

When compiling main.f90, the compiler searches the current directory for one.mod and two.mod. These must be compiled before compiling any files that reference the modules on USE statements. The link step requires the module implementation object files mod_one.o and mod_two.o appear along with all other object files to create the executable.

4.9.1 Searching for Modules

With the release of the version 7.0 of the Fortran compiler, .mod files can be stored into an archive (.a) file. An archive must be explicitly specified in a -Mpath flag on the command line for it to be searched for modules. The compiler does not search archive files by default.

Only .mod files with the same names that appear on USE statements will be searched. For example, the Fortran statement USE mymod causes the compiler to search for the module file mymod.mod by default.

While searching, the compiler gives higher priority to the directory where the module files are being written. This can be controlled by the -moddir=dir option flag and the MODDIR environment variable. This implies that if only the -Mpath option is specified, the current directory will be searched for modules first, before the directories and files listed on the -M flag.

4.9.2 The -use=list Option Flag

The -use=list flag forces one or more implicit USE statements into each subprogram or module subprogram compiled with this flag. By using the flag, it is not necessary to modify source programs when a module or module file is required for some feature of a library or application.

Compiling with -use=module_name has the effect of adding a USE module_name to each subprogram or module being compiled. Compiling with -use=module_file_name has the effect of adding a USE module_name for each of the modules contained in the module_file_name file.

4.9.3 The fdumpmod Command

Use the fdumpmod(1) command to display information about the contents of a compiled module information file.

demo% fdumpmod x.mod group.mod
x 1.0 v8,i4,r4,d8,n16,a4 x.mod
group 1.0 v8,i4,r4,d8,n16,a4 group.mod

The fdumpmod command will display information about modules in a single .mod file, files formed by concatenating .mod files, and in .a archives of .mod files. The display includes the name of the module, a version number, the target architecture, and flags indicating compilation options with which the module is compatible. See the fdumpmod(1) man page for details.