NVIDIA HPC Fortran Compiler Reference Guide
Preface
This guide is part of a set of manuals that describe how to use the NVIDIA HPC Fortran compiler, NVFORTRAN. The compiler works in conjunction with an assembler, linker, libraries and header files on your target system, and includes a CUDA toolchain, libraries and header files for GPU computing. You can use the NVIDIA HPC Fortran compiler to develop, optimize and parallelize applications for NVIDIA GPUs and x86-64 and Arm Server multicore CPUs. The front end of Beta NVFORTRAN is based on the upstream LLVM Flang project, and its Fortran language support follows Flang.
The NVIDIA HPC Fortran Compiler User’s Guide provides operating instructions for the Beta NVFORTRAN command-line development environment. The NVIDIA HPC Fortran Compiler Reference Guide contains details concerning the Beta NVFORTRAN compiler’s interpretation of the Fortran language standards, implementation of language extensions, and command-level compilation. Users are expected to have previous experience with or knowledge of the Fortran programming language. These guides do not teach the Fortran programming language.
The NVIDIA HPC C and C++ compilers, NVC and NVC++, are described in a separate pair of manuals, the NVIDIA HPC C and C++ Compilers User’s Guide and the NVIDIA HPC C and C++ Compilers Reference Guide.
Audience Description
This manual is intended for scientists and engineers using the NVIDIA HPC Fortran compiler. To use this compiler, you should be aware of the role of high-level languages, such as Fortran, as well as parallel programming models such as CUDA, OpenACC and OpenMP in the software development process, and you should have some level of understanding of programming. The NVIDIA HPC Fortran compiler is available on a variety of NVIDIA GPUs and x86-64 and Arm CPU-based Linux platforms. You need to be familiar with the basic commands available on your system.
Compatibility and Conformance to Standards
Your system needs to be running a properly installed and configured version of the NVIDIA HPC Fortran compiler. For information on installing the NVIDIA HPC SDK, refer to the Release Notes and Installation Guide included with your software.
For further information, refer to the following:
American National Standard Programming Language FORTRAN, ANSI X3.9-1978 (1978).
ISO/IEC 1539-1 : 1991, Information technology – Programming Languages – Fortran, Geneva, 1991 (Fortran 90).
ISO/IEC 1539-1 : 1997, Information technology – Programming Languages – Fortran, Geneva, 1997 (Fortran 95).
ISO/IEC 1539-1 : 2004, Information technology – Programming Languages – Fortran, Geneva, 2004 (Fortran 2003).
ISO/IEC 1539-1 : 2010, Information technology – Programming Languages – Fortran, Geneva, 2010 (Fortran 2008).
ISO/IEC 1539-1 : 2018, Information technology – Programming Languages – Fortran, Geneva, 2018 (Fortran 2018).
ISO/IEC 1539-1 : 2023, Information technology – Programming Languages – Fortran, Geneva, 2023 (Fortran 2023).
OpenACC Application Programming Interface, Version 3.3, https://www.openacc.org.
OpenMP Application Program Interface, Version 5.0, November 2018, https://www.openmp.org.
Exceptions to Standards
Beta NVFORTRAN supports Fortran 2018 except for the features related to multi-image execution (coarrays). Support for Fortran 2023 is partial.
Beta NVFORTRAN supports OpenACC version 3.3, with the exceptions described in OpenACC in Flang. For the extensions to OpenACC that Beta NVFORTRAN supports, see OpenACC Extensions in Flang.
Organization
This manual contains detailed reference information about specific aspects of the compiler, such as the details of compiler options, directives, data types supported, and more. It contains these chapters:
Fortran Data Types describes the intrinsic types and kinds that the NVIDIA HPC Fortran compiler supports, the default kinds, the representation of LOGICAL values, the aggregate data types, and CHARACTER types, with the format, alignment and range of each type.
Language Extensions describes the legacy features and extensions to the Fortran standard that the compiler accepts, the features it deliberately does not support, and how it behaves where the standard is ambiguous.
Command-Line Options Reference provides a detailed description of command-line options.
Preprocessing describes how the Fortran preprocessor behaves and the built-in macros it implements.
Pre-defined Compiler Macros lists the macros that the compiler pre-defines when Fortran source files are preprocessed.
Runtime Environment describes details related to compiler code generation, including register conventions and calling conventions for Linux/x86-64 and Linux/Arm processor-based systems, the Linux Fortran supplement to these conventions, and the environment variables that affect the execution of Fortran programs.
Compiler Directives lists the compiler directives that Beta NVFORTRAN supports.
Module Hashes explains how module hashes detect mismatched module files and how to create hermetic modules.
Messages describes the diagnostic messages that the compiler and the runtime library issue, and how to control them.
Hardware and Software Constraints
This guide describes versions of the NVIDIA HPC Fortran compiler that target NVIDIA GPUs and x86-64 and Arm CPUs. Details concerning environment-specific values and defaults and system-specific features or limitations are presented in the release notes delivered with the NVIDIA HPC SDK.
Conventions
This guide uses the following conventions:
- italic
is used for emphasis.
Constant Widthis used for filenames, directories, arguments, options, examples, and for language statements in the text, including assembly language statements.
- Bold
is used for commands.
- [ item1 ]
in general, square brackets indicate optional items. In this case item1 is optional.
- { item2 | item3 }
braces indicate that a selection is required. In this case, you must select either item2 or item3.
- filename …
ellipsis indicates a repetition. Zero or more of the preceding item may occur. In this example, multiple filenames are allowed.
Terms
The following table lists the NVIDIA HPC Fortran compiler and its corresponding command:
Compiler or Tool |
Language or Function |
Command |
|---|---|---|
NVFORTRAN |
ISO/IEC Fortran 2018 |
nvfortran |
In general, the designation NVFORTRAN is used to refer to the NVIDIA Fortran compiler, and nvfortran is used to refer to the command that invokes the compiler. This guide describes Beta NVFORTRAN, the new compiler. For the differences from classic NVFORTRAN, the earlier compiler, see the Porting Guide. Examples of command-line invocation of the compiler reference the nvfortran command, and source code examples are written in Fortran.
There are a wide variety of x86-64 CPUs in use. Most of these CPUs are forward-compatible, but not backward-compatible, meaning that code compiled to target a given processor will not necessarily execute correctly on a previous-generation processor.
For the processor options that the NVIDIA HPC Fortran compiler supports, see the Release Notes.
In this manual, the convention is to use “x86-64” to specify the group of CPUs that are x86-compatible, 64-bit enabled, and run a 64-bit operating system. x86-64 processors can differ in terms of their support for various prefetch, SSE and AVX instructions. Where such distinctions are important with respect to a given compiler option or feature, it is explicitly noted in this manual.
1. Fortran Data Types
This chapter describes the data types of the NVIDIA HPC Fortran compiler: the intrinsic types and the kinds that each type supports, the default kinds and how to change them, the representation of LOGICAL values, half-precision real data, and the aggregate data types. It gives the format and alignment of each type in memory and the range of values each type can have on 64-bit operating systems.
1.1. Intrinsic Types and Kinds
Intrinsic types are integer, real, complex, character, and logical. All intrinsic types have a kind type parameter called KIND, which determines the representation method for the specified type. The intrinsic type character also has a length type parameter called LEN, which determines the length of the character string. The CHARACTER type is described in CHARACTER types, later in this chapter.
1.1.1. Supported Types and Kinds
A scalar data type holds a single value, such as the integer value 42 or the real value 112.6. The next table lists the type and kind combinations that Beta NVFORTRAN supports, with their format, size and alignment. The alignments apply to all scalars, whether they are independent or contained in an array or a structure. Table 3 and Table 4 show the range of the integer and real types.
Type and Kind |
Also Written As |
Format |
Size (bytes) |
Alignment (bytes) |
|---|---|---|---|---|
INTEGER(KIND=1) |
INTEGER*1, BYTE |
8-bit two’s-complement integer |
1 |
1 |
INTEGER(KIND=2) |
INTEGER*2 |
16-bit two’s-complement integer |
2 |
2 |
INTEGER(KIND=4) |
INTEGER*4, INTEGER (default) |
32-bit two’s-complement integer |
4 |
4 |
INTEGER(KIND=8) |
INTEGER*8 |
64-bit two’s-complement integer |
8 |
8 |
INTEGER(KIND=16) |
— |
128-bit two’s-complement integer |
16 |
16 |
LOGICAL(KIND=1) |
LOGICAL*1 |
8-bit integer |
1 |
1 |
LOGICAL(KIND=2) |
LOGICAL*2 |
16-bit integer |
2 |
2 |
LOGICAL(KIND=4) |
LOGICAL*4, LOGICAL (default) |
32-bit integer |
4 |
4 |
LOGICAL(KIND=8) |
LOGICAL*8 |
64-bit integer |
8 |
8 |
REAL(KIND=2) |
REAL*2 |
16-bit IEEE 754 binary16 |
2 |
2 |
REAL(KIND=3) |
— |
16-bit upper half of 32-bit IEEE 754 binary32 |
2 |
2 |
REAL(KIND=4) |
REAL*4, REAL (default) |
32-bit IEEE 754 binary32 |
4 |
4 |
REAL(KIND=8) |
REAL*8, DOUBLE PRECISION |
64-bit IEEE 754 binary64 |
8 |
8 |
REAL(KIND=10) |
— |
80-bit extended precision with explicit normalization bit, stored in 16 bytes |
16 |
16 |
REAL(KIND=16) |
— |
128-bit IEEE 754 binary128 |
16 |
16 |
COMPLEX(KIND=2) |
— |
Two 16-bit IEEE 754 binary16 values |
4 |
2 |
COMPLEX(KIND=3) |
— |
Two 16-bit upper halves of 32-bit IEEE 754 binary32 values |
4 |
2 |
COMPLEX(KIND=4) |
COMPLEX*8, COMPLEX (default) |
Two 32-bit IEEE 754 binary32 values |
8 |
4 |
COMPLEX(KIND=8) |
COMPLEX*16, DOUBLE COMPLEX |
Two 64-bit IEEE 754 binary64 values |
16 |
8 |
COMPLEX(KIND=10) |
— |
Two 80-bit extended precision values, each stored in 16 bytes |
32 |
16 |
COMPLEX(KIND=16) |
— |
Two 128-bit IEEE 754 binary128 values |
32 |
16 |
CHARACTER(LEN=n) |
CHARACTER*n |
Sequence of n bytes |
n |
1 |
There is no double-double quad-precision type, and there is no 128-bit LOGICAL type. The extension forms such as INTEGER*4 and REAL*8 name the kind that the second column shows, and BYTE is the same as INTEGER(KIND=1). A dash means that no extension form is documented for that kind. Write these kinds with the KIND= syntax, as in REAL(KIND=10), which is clearer and also works in other Fortran compilers.
Type |
Range |
|---|---|
INTEGER(KIND=1) |
-128 to 127 |
INTEGER(KIND=2) |
-32768 to 32767 |
INTEGER(KIND=4) |
-231 to 231-1 |
INTEGER(KIND=8) |
-263 to 263-1 |
INTEGER(KIND=16) |
-2127 to 2127-1 |
Type |
Format |
Smallest Normal to Largest Value |
Decimal Digits of Precision |
|---|---|---|---|
REAL(KIND=2) |
5e11m |
6.10x10-5 to 6.55x104 |
3 |
REAL(KIND=3) |
8e8m |
1.18x10-38 to 3.39x1038 |
2 |
REAL(KIND=4) |
8e24m |
1.18x10-38 to 3.40x1038 |
6 |
REAL(KIND=8) |
11e53m |
2.23x10-308 to 1.80x10308 |
15 |
REAL(KIND=10) |
15e64m |
3.36x10-4932 to 1.19x104932 |
18 |
REAL(KIND=16) |
15e113m |
3.36x10-4932 to 1.19x104932 |
33 |
In the Format column, the number before e is the number of exponent bits, and the number before m is the number of significand bits, including the leading bit. The decimal digits of precision are the value of the PRECISION intrinsic function. A COMPLEX type has the range and precision of its component type.
1.1.2. Default Kinds
The default kinds are INTEGER 4, REAL 4, COMPLEX 4, DOUBLE PRECISION 8, and LOGICAL 4. The -fdefault-real-8 and -fdefault-integer-8 options change them as the next table shows. The -r8 and -i8 options are equivalent. Other options in the -fdefault- family, such as -fdefault-double-8, -fdefault-integer-2 and -fdefault-logical-8, set the default kind of a single type.
Option |
REAL |
DOUBLE PRECISION |
COMPLEX |
INTEGER |
LOGICAL |
|---|---|---|---|---|---|
(none) |
4 |
8 |
4 |
4 |
4 |
-fdefault-real-8 (or -r8) |
8 |
8 |
8 |
4 |
4 |
-fdefault-integer-8 (or -i8) |
4 |
8 |
4 |
8 |
8 |
Modules compiled with different default-real and default-integer kinds may be freely mixed. Module files encode the kind value for every entity.
1.1.3. LOGICAL Values
The default logical is LOGICAL(KIND=4). For kinds 1, 2, 4 and 8, the logical constant .TRUE. is represented as 1_kind and .FALSE. as 0_kind. A logical value is true when its integer value is not zero. This matches gfortran.
A logical value cannot be an operand of an arithmetic operator. Programs should not use integer values in LOGICAL contexts, or use LOGICAL values to interface with other languages.
For a comparison of the representation of LOGICAL values in different compilers, including classic NVFORTRAN, see the Porting Guide.
1.1.4. Half-Precision Real Data: REAL(2)
Beta NVFORTRAN supports the real(2) data type, which makes it possible to declare and use data in half precision floating point. It is explicitly required to use the kind attribute with value of 2 on real data type to take advantage of this support. The following operators are supported for this data type: + , -, *, /, .lt., .le., .gt., .ge., .eq.,.ne..
There are several ways to create real(2) constants:
! Using kind attribute of 2 by appending _2 to the floating point value:
real(2) :: val1 = 2.0_2
! Using a hexadecimal constant:
real(2) :: val2 = z'4000'
! Explicitly calling real() intrinsic with the value to be converted:
real(2) :: val3 = real(2, kind=2)
! Implicitly relying on compiler to convert value to real(2):
real(2) :: val4 = 2d0
Half precision native support is not available on all of the architecture targets that Beta NVFORTRAN supports. It is still possible to use this type, but be aware that implementation relies on conversion to real(4), handling operation in real(4), and then converting back to real(2). NVIDIA GPUs which support CUDA Compute Capability 6.0 and above implement operations natively and do not rely on conversion.
Half precision is represented as IEEE 754 binary16. Out of the 16-bits available to represent the floating point value, one bit is used for sign, five bits are used for exponent, and ten bits are used for significand. When encountering values that cannot be precisely represented in the format, such as when adding two real(2) numbers, IEEE 754 defines rounding rules. In the case of real(2), the default rule is round-to-nearest with ties-to-even property which is described in detail in the IEEE 754-2008 standard in section 4.3.1. This format has a small dynamic range, and thus values of 65520 or greater are rounded to infinity.
1.2. Aggregate Data Types
An aggregate data type consists of one or more scalar data type objects. Beta NVFORTRAN supports these aggregate data types:
An array consists of one or more elements of a single data type placed in contiguous locations from first to last.
A structure can contain different data types. The members are allocated in the order they appear in the definition but may not occupy contiguous locations. Beta NVFORTRAN supports the de facto standard
STRUCTUREandRECORDextensions to FORTRAN 77, and the derived types of Fortran 90 and later.
Note
The UNION extension, and the MAP statements it contains, are not yet supported. A UNION statement is reported as not implemented.
1.2.1. Alignment and Padding of Aggregates
The alignment of an array or a structure (an aggregate) affects how much space the object occupies and how efficiently the processor can address members. Each scalar member is aligned as the Supported Types and Kinds table shows.
- Array types
align according to the alignment of the array elements. For example, an array of
INTEGER(KIND=2)data aligns on a 2-byte boundary.- Structures
align according to the alignment of the most restricted data type of the structure. In the next example, the structure aligns on a 4-byte boundary since the alignment of c, the most restrictive member, is four.
STRUCTURE /s1/
INTEGER*2 a ! 2 bytes, offset 0
BYTE b ! 1 byte, offset 2
INTEGER*4 c ! 4 bytes, offset 4
END STRUCTURE
The structure occupies 8 bytes. One byte of padding separates b from c.
Structure alignment can result in unused space called padding. Padding between members of the structure is called internal padding. Padding between the last member and the end of the space is called tail padding.
The offset of a structure member from the beginning of the structure is a multiple of the member’s alignment. For example, since an INTEGER*2 aligns on a 2-byte boundary, the offset of an INTEGER*2 member from the beginning of a structure is a multiple of two bytes.
1.2.2. Fortran 90 Aggregate Data Types (Derived Types)
The Fortran 90 standard added formal support for aggregate data types. The TYPE statement begins a derived type data specification or declares variables of a specified user-defined type. For example, the following would define a derived type ATTENDEE:
TYPE ATTENDEE
CHARACTER(LEN=30) NAME
CHARACTER(LEN=30) ORGANIZATION
CHARACTER (LEN=30) EMAIL
END TYPE ATTENDEE
In order to declare a variable of type ATTENDEE and access the contents of such a variable, code such as the following would be used:
TYPE (ATTENDEE) ATTLIST(100)
! ...
ATTLIST(1)%NAME = 'JOHN DOE'
The members of a derived type are aligned and padded in the same way as the members of a STRUCTURE.
1.3. CHARACTER types
This section describes the kinds of the intrinsic CHARACTER type that Beta NVFORTRAN supports, how they are converted and written to files, and how lengths and concatenation work.
1.3.1. Kinds and Character Sets
Beta NVFORTRAN supports three kinds of the intrinsic CHARACTER type of Fortran 2018:
Kind |
Size of a code |
Assumed character set |
|---|---|---|
|
8 bits |
ISO-8859-1 (Latin-1). This is the default kind |
|
16 bits |
UCS-2 (16-bit Unicode) |
|
32 bits |
UCS-4 (full Unicode in a 32-bit word) |
In every kind, the code values 0 through 127 correspond to the 7-bit ASCII character set (ISO-646). This is also true for Unicode (UCS, ISO/IEC 10646), for ISO-8859, and for many other character sets and interchange formats.
In memory and in unformatted files, CHARACTER data is not in an interchange representation such as UTF-8, Shift-JIS, EUC-JP or JIS X. The code of each character occupies one 1-, 2- or 4-byte word, so you can index substrings with simple arithmetic.
CHARACTER(KIND=1) literal constants in Fortran source files and Hollerith constants are not translated. The compiler stores the bytes of the source as they are. For example, the letter é in a UTF-8 source file occupies two bytes of a KIND=1 string.
1.3.2. Selecting a Kind
Select a kind with the KIND= type parameter of a declaration, and with a kind prefix on a literal constant, such as 2_'abc' or 4_'abc'. The prefix can also be the name of a constant:
integer, parameter :: k2 = 2, k4 = 4
character(kind=k2, len=5) :: s2
character(kind=k4, len=5) :: s4
s2 = k2_'abc'
s4 = k4_'abc'
The intrinsic function SELECTED_CHAR_KIND returns the kind for a character set name:
Name |
Result |
|---|---|
|
1 |
|
1 |
|
4 |
any other name |
-1 |
For example, to declare a string of full Unicode characters:
integer, parameter :: ucs4 = selected_char_kind('ISO_10646')
character(kind=ucs4, len=5) :: s
s = ucs4_'abc'
1.3.3. Conversions Between Kinds
The conversions between kinds of CHARACTER are simple zero-extension or truncation of the code, not table look-ups:
A conversion to a larger kind zero-extends the code. For example, when a
KIND=1character with the code 233 is assigned to aKIND=4character, the result has the code 233.A conversion to a smaller kind truncates the code. For example, when a
KIND=4character with the code 955 (λ) is assigned to aKIND=1character, the result has the code 187, which is 955 modulo 256.
This is correct for the ASCII characters in all kinds, and for KIND=1 Latin-1 characters in the other kinds.
1.3.4. Encoding in Formatted I/O
The ENCODING= specifier of the OPEN statement selects how formatted I/O represents CHARACTER data in the file:
With
ENCODING='DEFAULT', the characters are not translated. AKIND=1character with the code 233 is written to the file as the byte 233.With
ENCODING='UTF-8', formatted I/O uses the UTF-8 variable-length encoding. The characters of a non-default kind are assumed to be UCS-2 or UCS-4, and the characters ofKIND=1are assumed to be Latin-1. For example, aKIND=1character with the code 233 is written as the two bytes 195 and 169, and aKIND=4character with the code 955 (λ) is written as the two bytes 206 and 187.
1.3.5. Lengths
An allocatable CHARACTER object can defer the specification of its length until it is allocated or assigned as a whole (not as a substring). A CHARACTER object that is not an allocatable with a deferred length has a length that is fixed, or that is assumed from an actual argument. The length of an assumed-length CHARACTER function comes from its declaration in the calling scope.
All the elements of a CHARACTER array have the same length.
An assignment to a target that is not a deferred-length allocatable truncates or pads the assigned value to the length of the left-hand side.
Lengths and offsets in a Fortran program, such as the lengths in declarations, the bounds of substrings and the result of the LEN intrinsic function, are always in characters, not bytes. The difference matters only for the kinds other than the default. For example, a CHARACTER(KIND=2, LEN=5) variable has LEN equal to 5 and occupies 10 bytes.
A substring is like a subscript triplet in a hidden dimension of a scalar CHARACTER value, but a substring cannot have a stride.
1.3.6. Concatenation
The only CHARACTER operator of Fortran is //, which concatenates its operands. These rules apply:
The operands must have the same kind type parameter. A concatenation of operands of different kinds is an error.
One or both operands can be arrays. If both are arrays, their shapes must be identical.
The length of the result is the sum of the lengths of the operands.
You can use the result of // wherever a CHARACTER expression is allowed. If the left-hand side of an assignment is a deferred-length allocatable, it takes the length of the result.
For the difference from classic NVFORTRAN, which supports only the default kind of CHARACTER, see the Porting Guide.
2. Language Extensions
As a general principle, this compiler will accept by default and without complaint many legacy features, extensions to the standard language, and features that have been deleted from the standard, so long as the recognition of those features would not cause a standard-conforming program to be rejected or misinterpreted.
Other non-standard features, which do conflict with the current standard specification of the Fortran programming language, are accepted if enabled by command-line options.
2.1. Intentional violations of the standard
Scalar
INTEGERactual argument expressions (not variables!) are converted to the kinds of scalarINTEGERdummy arguments when the interface is explicit and the kinds differ. This conversion allows the results of the intrinsics likeSIZEthat (as mentioned below) may return non-defaultINTEGERresults by default to be passed. A warning is emitted when truncation is possible. These conversions are not applied in calls to non-intrinsic generic procedures.Beta NVFORTRAN is not strict on the contents of
BLOCK DATAsubprograms so long as they contain no executable code, no internal subprograms, and allocate no storage outside a namedCOMMONblock. (C1415)Delimited list-directed (and NAMELIST) character output is required to emit contiguous doubled instances of the delimiter character when it appears in the output value. When fixed-size records are being emitted, as is the case with internal output, this is not possible when the problematic character falls on the last position of a record. No two other Fortran compilers do the same thing in this situation so there is no good precedent to follow. Because it seems least wrong, Beta NVFORTRAN emits one copy of the delimiter as the last character of the current record and another as the first character of the next record. (The second-least-wrong alternative might be to flag a runtime error, but that seems harsh since it’s not an explicit error in the standard, and the output may not have to be usable later as input anyway.) Consequently, the output is not suitable for use as list-directed or NAMELIST input. If a later standard were to clarify this case, this behavior will change as needed to conform.
character(11) :: buffer(3)
character(10) :: quotes = '""""""""""'
write(buffer,*,delim="QUOTE") quotes
print "('>',a10,'<')", buffer
end
The name of the control variable in an implied DO loop in an array constructor or DATA statement has a scope over the value-list only, not the bounds of the implied DO loop. It is not advisable to use an object of the same name as the index variable in a bounds expression, but it will work, instead of being needlessly undefined.
If both the
COUNT=and theCOUNT_MAX=optional arguments are present on the same call to the intrinsic subroutineSYSTEM_CLOCK, Beta NVFORTRAN requires that their types have the same integer kind, since the kind of these arguments is used to select the clock rate. In common with some other compilers, the clock rate varies from tenths of a second to nanoseconds depending on argument kind and platform support.If a dimension of a descriptor has zero extent in a call to
CFI_section,CFI_setpointerorCFI_allocate, the lower bound on that dimension will be set to 1 for consistency with theLBOUND()intrinsic function.-2147483648_4is, strictly speaking, a non-conforming literal constant on a machine with 32-bit two’s-complement integers as kind 4, because the grammar of Fortran expressions parses it as a negation of a literal constant, not a negative literal constant. This compiler accepts it with a portability warning.Construct names like
loopinloop: do j=1,nare defined to be “local identifiers” and should be distinct in the “inclusive scope” – i.e., not scoped byBLOCKconstructs. As most (but not all) compilers implementBLOCKscoping of construct names, so does Beta NVFORTRAN, with a portability warning.15.6.4 paragraph 2 prohibits an implicitly typed statement function from sharing the same name as a symbol in its scope’s host, if it has one. Beta NVFORTRAN accepts this usage with a portability warning.
A module name from a
USEstatement can also be used as a non-global name in the same scope. This is not conforming, but it is useful and unambiguous.The argument to
RANDOM_NUMBERmay not be an assumed-size array.NULL()withoutMOLD=is not allowed to be associated as an actual argument corresponding to an assumed-rank dummy argument; its rank in the called procedure would not be well-defined.When an index variable of a
FORALLorDO CONCURRENTis present in the enclosing scope, and the construct does not have an explicit type specification for its index variables, some weird restrictions in F’2023 subclause 19.4 paragraphs 6 & 8 should apply. Since this compiler properly scopes these names, violations of these restrictions elicit only portability warnings by default.The standard defines the intrinsic functions
MODandMODULOfor real arguments using expressions in terms ofAINTandFLOOR. These definitions yield fairly poor results due to floating-point cancellation, and every Fortran compiler (including this one) uses better algorithms.The rules for pairwise distinguishing the specific procedures of a generic interface are inadequate, as admitted in note C.11.6 of F’2023. Generic interfaces whose specific procedures can be easily proven by hand to be pairwise distinct (i.e., no ambiguous reference is possible) appear in real applications, but are still non-conforming under the incomplete tests in F’2023 15.4.3.4.5. These cases are compiled with optional portability warnings.
PROCEDURE(), BIND(C) :: PROCis not conforming, as there is no procedure interface. This compiler accepts it, since there is otherwise no way to declare an interoperable dummy procedure with an arbitrary interface likevoid (*)().PUREfunctions are allowed to have dummy arguments that are neitherINTENT(IN)norVALUE, similar toPUREsubroutines, with a warning. This enables atomic memory operations to be naturally represented asPUREfunctions, which allows their use in parallel constructs andDO CONCURRENT.A non-definable actual argument, including the case of a vector subscript, may be associated with an
ASYNCHRONOUSorVOLATILEdummy argument, F’2023 15.5.2.5 p21 notwithstanding. The effects of these attributes are scoped over the lifetime of the procedure reference, and they can by added by internal subprograms andBLOCKconstructs within the procedure. Further, a dummy argument can acquire theASYNCHRONOUSattribute implicitly simply appearing in an asynchronous data transfer statement, without the attribute being visible in the procedure’s explicit interface.When the name of an extended derived type’s base type is the result of
USEassociation with renaming, the name of the extended derived type’s parent component is the new name by which the base is known in the scope of the extended derived type, not the original. This interpretation has usability advantages and is what six other Fortran compilers do, but is not conforming now that J3 approved an “interp” in June 2024 to the contrary.When an Arm processor raises an
ieee_overfloworieee_underflowexception, theieee_inexactexception is also raised. This happens for a call toieee_set_flagas well as for floating point expression evaluation.Arm has processors that allow a user to control what happens when an arithmetic exception is signaled, as well as processors that do not have this capability. An Arm executable will run on either type of processor, so it is effectively unknown at compile time whether or not this support will be available at runtime. The standard requires that a call to intrinsic module procedure
ieee_support_haltingwith a constant argument has a compile time constant result inconstant expressionandspecification expressioncontexts. In compilations where this information is not known at compile time, Beta NVFORTRAN generates code to determine the absence or presence of this capability at runtime. A call toieee_support_haltingin contexts that the standard requires to be constant will generate a compilation error.ieee_support_standarddepends in part onieee_support_halting, so this also applies toieee_support_standardcalls.Some intrinsic functions (
COUNT,LBOUND,LCOBOUND,TRANSFER,UBOUND, andUCOBOUND) have arguments (usuallyDIM=) that are documented as not allowingOPTIONALdummy arguments to appear as their values. No compiler seems to enforce this requirement. Beta NVFORTRAN interprets it to mean that anOPTIONALdummy argument may appear but must be present during execution, just as a pointer argument must be associated or an allocatable argument must be allocated.F’2023 constraint C7108 prohibits the use of a structure constructor that could also be interpreted as a generic function reference. No other Fortran compiler enforces C7108; they all resolve the ambiguity by interpreting the call as a function reference. Beta NVFORTRAN does the same, with a portability warning.
An override for an inaccessible procedure binding works only within the same module; other apparent overrides of inaccessible bindings are actually new bindings of the same name. In the case of
DEFERREDbindings in anABSTRACTderived type, however, overrides are necessary, so they are permitted for inaccessible bindings with an optional warning.Main program name is allowed to be the same as the other symbols used in the main program, for example:
module m
end
program m
use m
end
Note that internally the main program symbol name is all uppercase, unlike the names of all other symbols, which are usually all lowercase. This may make a difference in testing/debugging.
A
PROCEDURE()with no interface name or type may be called as an subroutine with an implicit interface, F’2023 15.4.3.6 paragraph 4 and C1525 notwithstanding. This is a universally portable feature, and it also applies toPROCEDURE(), POINTER, NOPASSderived type components. Such procedures may not be referenced as implicitly typed functions without first being associated with a function pointer.
2.2. Extensions, deletions, and legacy features supported by default
Tabs in source
<>as synonym for.NE.and/=$and@as legal characters in namesInitialization in type declaration statements using
/values/Saved variables without explicit or default initializers are zero initialized, except for scalar variables from the main program that are not explicitly initialized or marked with an explicit SAVE attribute (these variables may be placed on the stack by nvfortran and not zero initialized). It is not advised to rely on this extension in new code.
In a saved entity of a type with a default initializer, components without default values are zero initialized.
Kind specification with
*, e.g.REAL*4DOUBLE COMPLEXas a synonym forCOMPLEX(KIND(0.D0))– but not when spelledTYPE(DOUBLECOMPLEX).Signed complex literal constants
DEC
STRUCTURE,RECORD, with ‘%FILL’; butUNION, andMAPare not yet supported throughout compilation, and elicit a “not yet implemented” message.Structure field access with
.fieldBYTEas synonym forINTEGER(KIND=1); but not when spelledTYPE(BYTE).When kind-param is used for REAL literals, allow a matching exponent letter
Quad precision REAL literals with
QXprefix/suffix as synonym forZon hexadecimal literalsB,O,Z, andXaccepted as suffixes as well as prefixesSupport for using bare
Lin FORMAT statementTriplets allowed in array constructors
%LOC,%VAL, and%REFLeading comma allowed before I/O item list
Empty parentheses allowed in
PROGRAM P()Missing parentheses allowed in
FUNCTION FCray based
POINTER(p,x)andLOC()intrinsic (with%LOC()as an alias)Arithmetic
IF. (Which branch should NaN take? Fall through?)ASSIGNstatement, assignedGO TO, and assigned formatPAUSEstatementHollerith literals and edit descriptors
NAMELISTallowed in the execution partOmitted colons on type declaration statements with attributes
COMPLEX constructor expression, e.g.
(x+y,z)+and-before all primary expressions, e.g.x*-y.NOT. .NOT.acceptedNAME=as synonym forFILE=Data edit descriptors without width or other details
Dlines in fixed form as comments or debug codeCARRIAGECONTROL=on the OPEN and INQUIRE statementsCONVERT=on the OPEN and INQUIRE statementsDISPOSE=on the OPEN and INQUIRE statementsLeading semicolons are ignored before any statement that could have a label
The character
&in column 1 in fixed form source is a variant form of continuation line.Character literals as elements of an array constructor without an explicit type specifier need not have the same length; the longest literal determines the length parameter of the implicit type, not the first.
Outside a character literal, a comment after a continuation marker (&) need not begin with a comment marker (!).
Classic C-style
/*comments*/are skipped, so multi-language header files are easier to write and use.$ and \ edit descriptors are supported in FORMAT to suppress newline output on user prompts.
Tabs in format strings (not
FORMATstatements) are allowed on output.REAL and DOUBLE PRECISION variable and bounds in DO loops
Integer literals without explicit kind specifiers that are out of range for the default kind of INTEGER are assumed to have the least larger kind that can hold them, if one exists.
BOZ literals can be used as INTEGER values in contexts where the type is unambiguous: the right hand sides of assignments and initializations of INTEGER entities, as actual arguments to a few intrinsic functions (ACHAR, BTEST, CHAR), and as actual arguments of references to procedures with explicit interfaces whose corresponding dummy argument has a numeric type to which the BOZ literal may be converted. BOZ literals are interpreted as default INTEGER only when they appear as the first items of array constructors with no explicit type. Otherwise, they generally cannot be used if the type would not be known (e.g.,
IAND(X'1',X'2'), or as arguments ofDIM,MOD,MODULO, andSIGN. Note that while other compilers may accept such usages, the type resolution of such BOZ literals usages is highly non portable).BOZ literals can also be used as REAL values in some contexts where the type is unambiguous, such as initializations of REAL parameters.
TRANSFER(boz, MOLD=integer or real scalar)is accepted as an alternate spelling ofINT(boz, KIND=kind(mold))orREAL(boz, KIND=kind(mold)).EQUIVALENCE of numeric and character sequences (a ubiquitous extension), as well as of sequences of non-default kinds of numeric types with each other.
Values for whole anonymous parent components in structure constructors (e.g.,
EXTENDEDTYPE(PARENTTYPE(1,2,3))rather thanEXTENDEDTYPE(1,2,3)orEXTENDEDTYPE(PARENTTYPE=PARENTTYPE(1,2,3))).Some intrinsic functions are specified in the standard as requiring the same type and kind for their arguments (viz., ATAN with two arguments, ATAN2, DIM, HYPOT, IAND, IEOR, IOR, MAX, MIN, MOD, and MODULO); Beta NVFORTRAN allows distinct types to be used, promoting the arguments as if they were operands to an intrinsic
+operator, and defining the result type accordingly.DOUBLE COMPLEX intrinsics DREAL, DCMPLX, DCONJG, and DIMAG.
The DFLOAT intrinsic function.
INT_PTR_KIND intrinsic returns the kind of c_intptr_t.
Restricted specific conversion intrinsics FLOAT, SNGL, IDINT, IFIX, DREAL, and DCMPLX accept arguments of any kind instead of only the default kind or double precision kind. Their result kinds remain as specified.
Specific intrinsics AMAX0, AMAX1, AMIN0, AMIN1, DMAX1, DMIN1, MAX0, MAX1, MIN0, and MIN1 accept more argument types than specified. They are replaced by the related generics followed by conversions to the specified result types.
When a scalar CHARACTER actual argument of the same kind is known to have a length shorter than the associated dummy argument, it is extended on the right with blanks, similar to assignment.
When a dummy argument is
POINTERorALLOCATABLEand isINTENT(IN), Beta NVFORTRAN relaxes enforcement of some requirements on actual arguments that must otherwise hold true for definable arguments.Beta NVFORTRAN allows a limited polymorphic
POINTERorALLOCATABLEactual argument to be associated with a compatible monomorphic dummy argument, because its implementation, like others, supports a reallocation that would change the dynamic type.Assignment of
LOGICALtoINTEGERand vice versa (but not other types) is allowed. The values are normalized to canonical.TRUE./.FALSE.. The values are also normalized for assignments ofLOGICAL(KIND=K1)toLOGICAL(KIND=K2), whenK1 != K2.Static initialization of
LOGICALwithINTEGERis allowed inDATAstatements and object initializers. The results are not normalized to canonical.TRUE./.FALSE.. Static initialization ofINTEGERwithLOGICALis also permitted.An effectively empty source file (no program unit) is accepted and produces an empty relocatable output file.
A
RETURNstatement may appear in a main program.DATA statement initialization is allowed for procedure pointers outside structure constructors.
Nonstandard intrinsic functions: ISNAN, SIZEOF
A forward reference to an INTEGER dummy argument is permitted to appear in a specification expression, such as an array bound, in a scope with IMPLICIT NONE(TYPE).
A forward reference to a default INTEGER scalar
COMMONblock variable is permitted to appear in a specification expression, such as an array bound, in a scope with IMPLICIT NONE(TYPE) if the name of the variable would have caused it to be implicitly typed as default INTEGER if IMPLICIT NONE(TYPE) were absent.OPEN(ACCESS=’APPEND’) is interpreted as OPEN(POSITION=’APPEND’) to ease porting from Sun Fortran.
Intrinsic subroutines EXIT([status]) and ABORT()
The definition of simple contiguity in 9.5.4 applies only to arrays; Beta NVFORTRAN also treats scalars as being trivially contiguous, so that they can be used in contexts like data targets in pointer assignments with bounds remapping.
The
CONTIGUOUSattribute can be redundantly applied to simply contiguous objects, including scalars, with a portability warning.Beta NVFORTRAN supports some combinations of specific procedures in generic interfaces that a strict reading of the standard would preclude when their calls must nonetheless be distinguishable. Specifically,
ALLOCATABLEdummy arguments are distinguishing if an actual argument acceptable to one could not be passed to the other & vice versa because exactly one is polymorphic or exactly one is unlimited polymorphic).External unit 0 is predefined and connected to the standard error output, and defined as
ERROR_UNITin the intrinsicISO_FORTRAN_ENVmodule.Objects in blank COMMON may be initialized.
Initialization of COMMON blocks outside of BLOCK DATA subprograms.
Multiple specifications of the SAVE attribute on the same object are allowed, with a warning.
Specific intrinsic functions BABS, IIABS, JIABS, KIABS, ZABS, and CDABS.
A
POINTERcomponent’s type need not be a sequence type when the component appears in a derived type withSEQUENCE. (This case should probably be an exception to constraint C740 in the standard.)Format expressions that have type but are not character and not integer scalars are accepted so long as they are simply contiguous. This legacy extension supports pre-Fortran’77 usage in which variables initialized in DATA statements with Hollerith literals as modifiable formats.
At runtime,
NAMELISTinput will skip overNAMELISTgroups with other names, and will treat text before and between groups as if they were comment lines, even if not begun with!.Commas are required in FORMAT statements and character variables only when they prevent ambiguity.
Legacy names
AND,OR, andXORare accepted as aliases for the standard intrinsic functionsIAND,IOR, andIEORrespectively.A digit count of d=0 is accepted in Ew.0, Dw.0, and Gw.0 output editing if no nonzero scale factor (kP) is in effect.
The name
IMAGis accepted as an alias for the generic intrinsic functionAIMAG.The legacy extension intrinsic functions
IZEXTandJZEXTare supported;ZEXThas different behavior with various older compilers, so it is not supported.Beta NVFORTRAN doesn’t impose a limit on the number of continuation lines allowed for a single statement.
When a type-bound procedure declaration statement has neither interface nor attributes, the “::” before the bindings is optional, even if a binding has renaming with “=> proc”. The colons are not necessary for an unambiguous parse, C768 notwithstanding.
A type-bound procedure binding can be passed as an actual argument corresponding to a dummy procedure and can be used as the target of a procedure pointer assignment statement.
An explicit
INTERFACEcan declare the interface of a procedure pointer even if it is not a dummy argument.A
NOPASStype-bound procedure binding is required by C1529 to apply only to a scalar data-ref, but most compilers don’t enforce it and the constraint is not necessary for a correct implementation.A label may follow a semicolon in fixed form source.
A logical dummy argument to a
BIND(C)procedure, or a logical component to aBIND(C)derived type does not have to haveKIND=C_BOOLsince it can be converted to/from_Boolwithout loss of information.The character length of the
SOURCE=orMOLD=inALLOCATEmay be distinct from the constant character length, if any, of an allocated object.When a name is brought into a scope by multiple ways, such as USE-association as well as an
IMPORTfrom its host, it’s an error only if the resolution is ambiguous.An entity may appear in a
DATAstatement before its explicit type declaration underIMPLICIT NONE(TYPE).INCLUDElines can start in any column, can be preceded in fixed form source by a ‘0’ in column 6, can contain spaces between the letters of the word INCLUDE, and can have a numeric character literal kind prefix on the file name.Intrinsic procedures SIND, COSD, TAND and ATAND. Constant folding is currently not supported for these procedures but this is planned.
When a pair of quotation marks in a character literal are split by a line continuation in free form, the second quotation mark may appear at the beginning of the continuation line without an ampersand, although one is required by the standard.
Unrestricted
INTRINSICfunctions are accepted for use inPROCEDUREstatements in generic interfaces, as in some other compilers.A
NULL()pointer is treated as an unallocated allocatable when associated with anINTENT(IN)allocatable dummy argument.READ(..., SIZE=n)is accepted withNML=andFMT=*with a portability warning. The Fortran standard doesn’t allowSIZE=with formatted input modes that might require look-ahead, perhaps to ease implementations.When a file included via an
INCLUDEline or#includedirective has a continuation marker at the end of its last line in free form, Fortran line continuation works.A
NAMELISTinput group may omit its trailing/character if it is followed by anotherNAMELISTinput group.A
NAMELISTinput group may begin with either&or$.A comma (or semicolon in
DECIMAL='COMMA'orDCmode) in a fixed-width numeric input field terminates the field rather than signaling an invalid character error.Arguments to the intrinsic functions
MAXandMINare converted when necessary to the type of the result. AnOPTIONAL,POINTER, orALLOCATABLEargument after the first two cannot be converted, as it may not be present.A derived type that meets (most of) the requirements of an interoperable derived type can be used as such where an interoperable type is required, with warnings, even if it lacks the BIND(C) attribute.
A “mult-operand” in an expression can be preceded by a unary
+or-operator.BIND(C, NAME="...", CDEFINED)signifies that the storage for an interoperable variable will be allocated outside of Fortran, probably by a C or C++ external definition.An automatic data object may be declared in the specification part of the main program.
A local data object may appear in a specification expression, even when it is not a dummy argument or in COMMON, so long as it has the SAVE attribute and was initialized.
PRINT namelistnameis accepted and interpreted asWRITE(*,NML=namelistname), a near-universal extension.A character length specifier in a component or entity declaration is accepted before an array specification (
ch*3(2)) as well as afterwards.A zero field width is allowed for logical formatted output (
L0).The binary edit descriptor
Bcan be used forLOGICALitems; the value is written as 1 or 0.OPEN(..., FORM='BINARY')is accepted as a legacy synonym for the standardOPEN(..., FORM='UNFORMATTED', ACCESS='STREAM').A character string edit descriptor is allowed in an input format with an optional compilation-time warning. When executed, it is treated as an ‘nX’ positioning control descriptor that skips over the same number of characters, without comparison.
A bare carriage return (CR, 0x0d) in the interior of a source line, for example from a file with Windows line endings that has been mishandled, is treated as a blank, except within a character or Hollerith literal where it is retained.
The
ISO_C_BINDINGmodule exports the named constantsc_float128andc_float128_complex(both with the value 16), the kind parameter for 128-bit (quad precision) real and complex C interoperable types, and the named constantsc_float16andc_float16_complex(both with the value 2), the kind parameter for 16-bit (half precision) real and complex C interoperable types. These extensions are gfortran-compatible.In
NAMELISTinput, an assignment to a scalar item may omit its value (for examplel=, immediately followed by the next name-value pair, the group terminator, or end-of-record). The standard requires one or more values to follow the=. The item keeps its current value. For example, with aLOGICALscalarl, anINTEGERscalari_countand aREALscalarr_valuein a namelist groupnml, the input record&nml l= i_count=7 r_value=2.72/leaveslunchanged and assigns 7 and 2.72 toi_countandr_value.In
NAMELISTinput, a!character is accepted as terminating the current value and introducing a comment even when it is not preceded by a value separator. For example,name=0.01!commentis accepted as if it had been writtenname=0.01 !comment. Inside a character literal constant the!is taken literally, as the standard requires.An assumed-rank entity is an acceptable
NAMELISTgroup item.A named constant (
PARAMETER) may appear as anamelist-group-objectin aNAMELISTstatement, although the standard requires namelist group objects to be variables.A nonallocatable nonpointer function result may be declared with a rank-1 integer array as its bounds (
explicit-shape-bounds-spec), for examplereal :: res(shape_of_input). The standard permits only anexplicit-shape-spec-listthere.A passed-object dummy argument for a procedure binding is allowed to be a pointer so long as it is
INTENT(IN).A pointer component that has no default initialization or explicit value in a structure constructor is defaulted to
NULL().Multiple specifications of a prefix-spec (for example
PURE) on the same procedure are allowed, with a warning.When the argument to the intrinsic
ALLOCATED(p)is a pointer rather than an allocatable, it is interpreted asASSOCIATED(p), with a warning.IS_CONTIGUOUSis always true when its argument is a named constant (PARAMETER) or a subobject of a named constant, even when the rules of the standard would classify a subobject, such as a strided sectiona(::2), as non-contiguous.
2.3. Extensions supported when enabled by options
C-style backslash escape sequences in quoted CHARACTER literals (but not Hollerith) [-fbackslash], including Unicode escapes with
\U.Logical abbreviations
.T.,.F.,.N.,.A.,.O., and.X.[-flogical-abbreviations].XOR.as a synonym for.NEQV.[-fxor-operator]The default
INTEGERtype is required by the standard to occupy the same amount of storage as the defaultREALtype. DefaultREALis of course 32-bit IEEE-754 floating-point today. This legacy rule imposes an artificially small constraint in some cases where Fortran mandates that something have the defaultINTEGERtype: specifically, the results of references to the intrinsic functionsSIZE,STORAGE_SIZE,LBOUND,UBOUND,SHAPE, and the location reductionsFINDLOC,MAXLOC, andMINLOCin the absence of an explicitKIND=actual argument. Beta NVFORTRAN returnsINTEGER(KIND=8)by default in these cases when the-flarge-sizesoption is enabled.SIZEOFandC_SIZEOFalways returnINTEGER(KIND=8).Treat each specification-part as if it had
IMPLICIT NONE[-fimplicit-none-type-always; this option is not yet accepted by Beta NVFORTRAN]Ignore occurrences of
IMPLICIT NONEandIMPLICIT NONE(TYPE)[-fimplicit-none-type-never; this option is not yet accepted by Beta NVFORTRAN]Old-style
PARAMETER pi=3.14statement without parentheses [-falternative-parameter-statement; this option is accepted but not yet implemented, and Beta NVFORTRAN issues a warning]UNSIGNEDtype (-funsigned)Default exponent of zero, e.g.
3.14159E, on a READ from a fixed-width input field. Includes the case with only an exponent letter for compatibility with other compilers.
2.4. Extensions and legacy features deliberately not supported
.LG.as synonym for.NE.REDIMENSIONAllocatable
COMMONExpressions in formats
ACCEPTas synonym forREAD *TYPEas synonym forPRINTARRAYas synonym forDIMENSIONVIRTUALas synonym forDIMENSIONENCODEandDECODEas synonyms for internal I/OIMPLICIT AUTOMATIC,IMPLICIT STATICDefault exponent of zero, e.g.
3.14159E, on a literal constantCharacters in defined operators that are neither letters nor digits
Bsuffix on unquoted octal constantsZprefix on unquoted hexadecimal constants (dangerous)TandFas abbreviations for.TRUE.and.FALSE.in DATAUse of host FORMAT labels in internal subprograms
ALLOCATE(TYPE(derived)::…) as variant of correct ALLOCATE(derived::…)
Defining an explicit interface for a subprogram within itself
USE association of a procedure interface within that same procedure’s definition
NULL() as a structure constructor expression for an ALLOCATABLE component.
Conversion of LOGICAL to INTEGER in expressions.
Use of INTEGER data with the intrinsic logical operators
.NOT.,.AND.,.OR., and.XOR..IF (integer expression) THEN … END IF
Comparison of LOGICAL with ==/.EQ. rather than .EQV. (also .NEQV.)
Procedure pointers in COMMON blocks
Underindexing multi-dimensional arrays (e.g., A(1) rather than A(1,1))
Legacy
NCHARACTERtype andNCKanji character literalsUsing non-integer expressions for array bounds (e.g., REAL A(3.14159))
Mixing INTEGER types as operands to bit intrinsics (e.g., IAND); only two compilers support it, and they disagree on sign extension.
Module & program names that conflict with an object inside the unit.
When the same name is brought into scope via USE association from multiple modules, the name must refer to a generic interface. A name cannot be a procedure from one module and a generic interface from another.
Type parameter declarations must come first in a derived type definition; some compilers allow them to follow
PRIVATE, or be intermixed with the component declarations.Wrong argument types in calls to specific intrinsics that have different names than the related generics. Some accepted exceptions are listed above in the allowed extensions. Other compilers support this in ways that are not numerically equivalent: some convert the arguments, while others replace the specific by the related generic.
VMS listing control directives (
%LIST,%NOLIST,%EJECT)Continuation lines on
INCLUDElinesNULL()actual argument corresponding to anALLOCATABLEdummy data objectUser (non-intrinsic)
ELEMENTALprocedures may not be passed as actual arguments, in accordance with the standard; some Fortran compilers permit such usage.Constraint C1406, which prohibits the same module name from being used in a scope for both an intrinsic and a non-intrinsic module, is implemented as a portability warning only, not a hard error.
IBM @PROCESS directive is accepted but ignored.
2.5. Preprocessing behavior
The preprocessor is always run, whatever the filename extension may be.
Beta NVFORTRAN respects Fortran comments in macro actual arguments (like GNU, Intel and NAG) on the principle that macro calls should be treated like function references. Fortran’s line continuation methods also work.
Beta NVFORTRAN implements the
__COUNTER__preprocessing extension, see Non-standard Extensions
2.6. Standard features not silently accepted
Fortran explicitly ignores type declaration statements when they attempt to type the name of a generic intrinsic function (8.2 p3). One can declare
CHARACTER::COSand still get a real result fromCOS(3.14159), for example. Beta NVFORTRAN will complain when a generic intrinsic function’s inferred result type does not match an explicit declaration. This message is a warning.There is no restriction in the standard against assigning to a whole polymorphic allocatable under control of a
WHEREconstruct or statement, but there is no good portable behavior to implement and the standard isn’t entirely clear what it should mean. (Other compilers allow it, but the results are never meaningful; some never change the type, some change the type according to the value of the last mask element, some treat these assignment statements as no-ops, and the rest crash during compilation.) The compiler flags this case as an error.
2.7. Standard features that might as well not be
Beta NVFORTRAN supports designators with constant expressions, properly constrained, as initial data targets for data pointers in initializers of variable and component declarations and in
DATAstatements; e.g.,REAL, POINTER :: P => T(1:10:2). This Fortran 2008 feature might as well be viewed like an extension; no other compiler that has been tested can handle it yet.According to 11.1.3.3p1, if a selector of an
ASSOCIATEor related construct is defined by a variable, it has theTARGETattribute if the variable was aPOINTERorTARGET. Beta NVFORTRAN reads this to include the case of the variable being a pointer-valued function reference. No other Fortran compiler seems to handle this correctly forASSOCIATE, though NAG gets it right forSELECT TYPE.The standard doesn’t explicitly require that a named constant that appears as part of a complex-literal-constant be a scalar, but most compilers emit an error when an array appears. Beta NVFORTRAN supports them with a portability warning.
Beta NVFORTRAN does not enforce a blanket prohibition against generic interfaces containing a mixture of functions and subroutines. Beta NVFORTRAN allows both to appear, unlike several other Fortran compilers. This is especially desirable when two generics of the same name are combined due to USE association and the mixture may be inadvertent.
Since Fortran 90,
INCLUDElines have been allowed to have a numeric kind parameter prefix on the file name. No other Fortran compiler supports them.A
SEQUENCEderived type is required (F’2023 C745) to have at least one component. No compiler enforces this constraint; this compiler emits a warning.Many compilers disallow a
VALUEassumed-length character dummy argument, which has been standard since F’2008. Beta NVFORTRAN accepts this usage with an optional portability warning.The
ASYNCHRONOUSattribute can be implied by usage in data transfer I/O statements. Only one other compiler supports this correctly. This compiler does, apart from objects in asynchronous NAMELIST I/O, for which an actual asynchronous runtime implementation seems unlikely.
2.8. Behavior in cases where the standard is ambiguous or indefinite
When an inner procedure of a subprogram uses the value or an attribute of an undeclared name in a specification expression and that name does not appear in the host, it is not clear in the standard whether that name is an implicitly typed local variable of the inner procedure or a host association with an implicitly typed local variable of the host. For example:
module module
contains
subroutine host(j)
! Although "m" never appears in the specification or executable
! parts of this subroutine, both of its contained subroutines
! might be accessing it via host association.
integer, intent(in out) :: j
call inner1(j)
call inner2(j)
contains
subroutine inner1(n)
integer(kind(m)), intent(in) :: n
m = n + 1
end subroutine
subroutine inner2(n)
integer(kind(m)), intent(out) :: n
n = m + 2
end subroutine
end subroutine
end module
program demo
use module
integer :: k
k = 0
call host(k)
print *, k, " should be 3"
end
Other Fortran compilers disagree in their interpretations of this
example; some seem to treat the references to m as if they were host
associations to an implicitly typed variable (and print 3), while
others seem to treat them as references to implicitly typed local
variables, and load uninitialized values.
Beta NVFORTRAN emits an error message for this case since the standard is unclear, the usage is not portable, and the issue can be easily resolved by adding a declaration.
In subclause 7.5.6.2 of Fortran 2018 the standard defines a partial ordering of the final subroutine calls for finalizable objects, their non-parent components, and then their parent components. (The object is finalized, then the non-parent components of each element, and then the parent component.) Some have argued that the standard permits an implementation to finalize the parent component before finalizing an allocatable component in the context of deallocation, and the next revision of the language may codify this option. In the interest of avoiding needless confusion, this compiler implements what is believed to be the least surprising order of finalization. Specifically: all non-parent components are finalized before the parent, allocatable or not; all finalization takes place before any deallocation; and no object or subobject will be finalized more than once.
When
RECL=is set via theOPENstatement for a sequential formatted input file, it functions as an effective maximum record length. Longer records, if any, will appear as if they had been truncated to the value ofRECL=. (Other compilers ignoreRECL=, signal an error, or apply effective truncation to some forms of input in this situation.) For sequential formatted output, RECL= serves as a limit on record lengths that raises an error when it is exceeded.When a
DATAstatement in aBLOCKconstruct could be construed as either initializing a host-associated object or declaring a new local initialized object, Beta NVFORTRAN interprets the standard’s classification of aDATAstatement as being a “declaration” rather than a “specification” construct, and notes that theBLOCKconstruct is defined as localizing names that have specifications in theBLOCKconstruct. So this example will elicit an error about multiple initialization:
subroutine subr
integer n = 1
block
data n/2/
end block
end subroutine
Other Fortran compilers disagree with each other in their
interpretations of this example. The precedent among the most commonly
used compilers agrees with Beta NVFORTRAN’s interpretation: a DATA statement
without any other specification of the name refers to the
host-associated object.
Many Fortran compilers allow a non-generic procedure to be
USE-associated into a scope that also contains a generic interface of the same name but does not have theUSE-associated non-generic procedure as a specific procedure.
module m1
contains
subroutine foo(n)
integer, intent(in) :: n
end subroutine
end module
module m2
use m1, only: foo
interface foo
module procedure noargs
end interface
contains
subroutine noargs
end subroutine
end module
This case elicits a warning from Beta NVFORTRAN, as it should not be treated any
differently than the same case with the non-generic procedure of the
same name being defined in the same scope rather than being
USE-associated into it, which is explicitly non-conforming in the
standard and not allowed by most other compilers. If the
USE-associated entity of the same name is not a procedure, most
compilers disallow it as well.
Fortran 2018 19.3.4p1: “A component name has the scope of its derived-type definition. Outside the type definition, it may also appear …” which seems to imply that within its derived-type definition, a component name is in its scope, and at least shadows any entity of the same name in the enclosing scope and might be read, thanks to the “also”, to mean that a “bare” reference to the name could be used in a specification inquiry. However, most other compilers do not allow a component to shadow exterior symbols, much less appear in specification inquiries, and there are application codes that expect exterior symbols whose names match components to be visible in a derived-type definition’s default initialization expressions, and so Beta NVFORTRAN follows that precedent.
19.3.1p1 “Within its scope, a local identifier of an entity of class (1) or class (4) shall not be the same as a global identifier used in that scope…” is read so as to allow the name of a module, submodule, main program, or
BLOCK DATAsubprogram to also be the name of an local entity in its scope, with a portability warning, since that global name is not actually capable of being “used” in its scope.In the definition of the
ASSOCIATEDintrinsic function (16.9.16), its optional second argumentTARGET=is required to be “allowable as the data-target or proc-target in a pointer assignment statement (10.2.2) in which POINTER is data-pointer-object or proc-pointer-object.” Some Fortran compilers interpret this to require that the first argument (POINTER=) be a valid left-hand side for a pointer assignment statement – in particular, it cannot beNULL(), but also it is required to be modifiable. As there is no good reason to disallow (say) anINTENT(IN)pointer here, or evenNULL()as a well-defined case that is always.FALSE., this compiler doesn’t require thePOINTER=argument to be a valid left-hand side for a pointer assignment statement, and it emits a portability warning when it is not.Beta NVFORTRAN allows a
USEstatement to reference a module that is defined later in the same compilation unit, so long as mutual dependencies do not form a cycle. This feature forestalls any risk of such aUSEstatement reading an obsolete module file from a previous compilation and then overwriting that file later.Beta NVFORTRAN allows
OPTIONALdummy arguments to interoperable procedures unless they areVALUE(C865).Beta NVFORTRAN processes the
NAMELISTgroup declarations in a scope after it has resolved all of the names in that scope. This means that names that appear before their local declarations do not resolve to host associated objects and do not elicit errors about improper redeclarations of implicitly typed entities.Standard Fortran allows forward references to derived types, which can lead to ambiguity when combined with host association. Some Fortran compilers resolve the type name to the host type, others to the forward-referenced local type; this compiler diagnoses an error.
module m
type ambiguous; integer n; end type
contains
subroutine s
type(ambiguous), pointer :: ptr
type ambiguous; real a; end type
end
end
When an intrinsic procedure appears in the specification part of a module only in function references, but not an explicit
INTRINSICstatement, its name is not brought into other scopes by aUSEstatement.The subclause on rounding in formatted I/O (13.7.2.3.8 in F’2023) only discusses rounding for decimal-to/from-binary conversions, omitting any mention of rounding for hexadecimal conversions. As other compilers do apply rounding, so does this one.
For real
MAXVAL,MINVAL,MAXLOC, andMINLOC, NaN values are essentially ignored unless there are some unmasked array entries and all of them are NaNs.When
INDEXis used as an unrestricted specific intrinsic function in the context of an actual procedure, as the explicit interface in aPROCEDUREdeclaration statement, or as the target of a procedure pointer assignment, its interface has exactly two dummy arguments (STRING=andSUBSTRING=), and includes neitherBACK=norKIND=. This is howINDEXas an unrestricted specific intrinsic function was documented in FORTRAN ‘77 and Fortran ‘90; later revisions of the standard deleted the argument information from the section on unrestricted specific intrinsic functions. At least one other compiler (XLF) seems to expect that the interface forINDEXinclude an optionalBACK=argument, but it doesn’t actually work.Allocatable components of array and structure constructors are deallocated after use without calling final subroutines. The standard does not specify when and how deallocation of array and structure constructors allocatable components should happen. All compilers free the memory after use, but the behavior when the allocatable component is a derived type with finalization differ, especially when dealing with nested array and structure constructors expressions. Some compilers call final routine for the allocatable components of each constructor sub-expressions, some call it only for the allocatable component of the top level constructor, and some only deallocate the memory. Deallocating only the memory offers the most flexibility when lowering such expressions, and it is not clear finalization is desirable in such context (Fortran interop 1.6.2 in F2018 standards require array and structure constructors not to be finalized, so it also makes sense not to finalize their allocatable components when releasing their storage).
F’2023 19.4 paragraph 5: “If integer-type-spec appears in data-implied-do or ac-implied-do-control it has the specified type and type parameters; otherwise it has the type and type parameters that it would have if it were the name of a variable in the innermost executable construct or scoping unit that includes the DATA statement or array constructor, and this type shall be integer type.” Reading “would have if it were” as being the subjunctive, this would mean that an untyped implied DO index variable should be implicitly typed according to the rules active in the enclosing scope. But all other Fortran compilers interpret the “would have if it were” as meaning “has if it is” – i.e., if the name is visible in the enclosing scope, the type of that name is used as the type of the implied DO index. So this is an error, not a simple application of the default implicit typing rule:
character j
print *, [(j,j=1,10)]
The Fortran standard doesn’t mention integer overflow explicitly. In many cases, however, integer overflow makes programs non-conforming. Beta NVFORTRAN follows other widely-used Fortran compilers. Specifically, Beta NVFORTRAN assumes integer overflow never occurs in address calculations and increment of do-variable unless the option
-fwrapvis enabled.Two new ieee_round_type values were added in Beta NVFORTRAN beyond the four values defined in f03 and f08: ieee_away and ieee_other. Contemporary hardware typically does not have support for these rounding modes; ieee_support_rounding calls for these values return false. ieee_set_rounding_mode calls that attempt to set the rounding mode to one of these values in violation of the restriction in f23 clause 17.11.42 set the mode to ieee_nearest.
A reference with a constant subscript that is out of range is accepted with a warning rather than rejected with an error. A subscript value is required to be within its bounds only when the reference is executed (F’2023 9.5.3.1 paragraph 2), so a reference that never runs does not render a program nonconforming; that case cannot be recognized in general. For example, consider a procedure whose only call site is in dead code, or one that is never called at all. The warning, not an error, is also what appears when the reference is executed. The endpoints of array sections get the same treatment. Use
-Wno-out-of-bounds-subscriptsto silence the warning.Some compilers allow an
INTENT(OUT)dummy argument’s value to appear via host association in a specification expression. A non-host-associated use is an error because anINTENT(OUT)dummy argument’s value is not defined. The argument put forth to accept this usage in aBLOCKconstruct or inner procedure is that the language in 10.1.11 (specification expressions) allows any host-associated object to appear, but that’s unconvincing because it would also allow a host-associatedOPTIONALdummy argument to be used in a nested scope, and that doesn’t make sense. This compiler accepts anINTENT(OUT)non-OPTIONALhost-associated value to appear in a specification expression via host association with a portability warning since such values may have become defined by the time the nested expression’s value is required.Intrinsic assignment of arrays is defined elementally, and intrinsic assignment of derived type components is defined componentwise. However, when intrinsic assignment takes place for an array of derived type, the order of the loop nesting is not defined. Some compilers will loop over the elements, assigning all of the components of each element before proceeding to the next element. This compiler loops over all of the components, and assigns all of the elements for each component before proceeding to the next component. A program using defined assignment might be able to detect the difference.
The standard forbids instances of derived types with defined unformatted WRITE subroutines from appearing in the I/O list of an
INQUIRE(IOLENGTH=...)statement. It then also says that these defined I/O procedures should be ignored for that statement. So Beta NVFORTRAN allows them to appear (like most compilers) and doesn’t use any defined unformatted WRITE that might have been defined.Forward references to target objects are allowed to appear in the initializers of data pointer declarations. Forward references to target objects are not accepted in the default initializers of derived type component declarations, however, since these default values need to be available to process incomplete structure constructors.
When an
ALLOCATEorDEALLOCATEstatement with multiple variables has aSTAT=specifier that allows the program to continue execution after an error, the variables after the one with the error are left deallocated (or allocated). This interpretation allows the program to identify the variable that encountered the problem while avoiding any ambiguity in the case of multiple errors with distinct status codes. Some compilers work differently; for maximum portability, avoidALLOCATEandDEALLOCATEstatements with error recovery for multiple variables.When a “null” value is encountered in list-directed input, the corresponding effective item in the data list is left unchanged, even when it has a derived type with a defined
READ(FORMATTED)subroutine. This is the most literal reading of F’2023 13.10.3.2p2 and the portable interpretation across the most common Fortran compilers.NAMELISTchild input statements are allowed to advance to further input records. Further, advancement is allowed when the parent input statement is a non-child (top level) list-directed input statement, or, recursively, an intermediate child list-directed input statement that can advance. This means that non-NAMELISTlist-directed child input statements are not allowed to advance when they have an ancestor formatted input statement that is not list-directed and there is no interveningNAMELIST. This design allows format-driven input withDTediting to retain control over advancement in child input, while otherwise allowing it.When output takes place to a file under
ACCESS="STREAM"after repositioning it to an earlier position, some compilers will truncate the file; this behavior is similar to the implicitENDFILEthat takes place under sequential output after aBACKSPACEorREWINDstatement. Truncation of streams is not specified in the standard, however, and it does not take place with all compilers. In this one, truncation is optional; it occurs by default, but it can be disabled viaFORT_TRUNCATE_STREAM=0in the environment at execution time.
2.9. De Facto Standard Features
EXTENDS_TYPE_OF()returns.TRUE.if both of its arguments have the same type, a case that is technically implementation-defined.ENCODING=is not in the list of changeable modes on an I/O unit, but every Fortran compiler allows the encoding to be changed on an open unit.A
NAMELISTinput item that references a scalar element of a vector or contiguous array can be used as the initial element of a storage sequence. For example, “&GRP A(1)=1. 2. 3./” is treated as if had been “&GRP A(1:)=1. 2. 3./”. This extension is necessarily disabled when the type of the array has an accessible defined formatted READ subroutine.
3. Command-Line Options Reference
A command-line option allows you to specify specific behavior when a program is compiled and linked. Compiler options perform a variety of functions, such as setting compiler characteristics, describing the object code to be produced, controlling the diagnostic messages emitted, and performing some preprocessor functions. Most options that are not explicitly set take the default settings. This reference section describes the syntax and operation of each Beta NVFORTRAN compiler option. For easy reference, the options are arranged in alphabetical order.
For an overview and tips on options usage and which options are best for which tasks, refer to the ‘Using Command-line Options’ section of the HPC Fortran Compiler User’s Guide, which also provides summary tables of the different options.
This section uses the following notation:
- [item]
Square brackets indicate that the enclosed item is optional.
- {item | item}
Braces indicate that you must select one and only one of the enclosed items. A vertical bar (|) separates the choices.
- ...
Horizontal ellipses indicate that zero or more instances of the preceding item are valid.
Some of the options in this section are not yet implemented in Beta NVFORTRAN. Beta NVFORTRAN accepts a not yet implemented option, issues the warning not yet implemented and ignores the option. It rejects an option that it does not support with the error Unknown switch. For the options of classic NVFORTRAN that Beta NVFORTRAN does not accept, and for the other differences in how the options behave, see the Porting Guide.
3.1. HPC Fortran Compiler Option Summary
The following tables include the NVIDIA HPC Fortran compiler (NVFORTRAN) options. The options are separated by category for easier reference.
For a complete description of each option, refer to the detailed information later in this section.
3.2. Generic Compiler Options
The following descriptions are for the generic options of the NVIDIA HPC Fortran compiler (NVFORTRAN). For easy reference, the options are arranged in alphabetical order. For a list of options by tasks, refer to the tables in the beginning of this section.
3.2.1. -#
Displays the invocations of the compiler, assembler and linker.
Default
The compiler does not display individual phase invocations.
Usage
The following command-line requests verbose invocation information.
$ nvfortran -# prog.f
Description
The -# option displays the invocations of the compiler, assembler and linker. These invocations are command-lines created by the driver from your command-line input and the default value.
Related options
3.2.2. -[no]acc
Enable [disable] OpenACC directives. The following suboptions may be used following an equals sign (“=”), with multiple sub-options separated by commas:
gpuOpenACC directives are compiled for GPU execution only.
hostCompile for serial execution on the host CPU. Not yet implemented.
multicoreCompile for parallel execution on the host CPU. Not yet implemented.
[no]routineseqCompile every routine for the device. The default behavior is to not treat every routine as a seq directive. The
routineseqsuboption is not yet implemented, andnoroutineseqis not accepted.strictInstructs the compiler to issue warnings for non-standard OpenACC directives.
verystrictInstructs the compiler to fail with an error for non-standard OpenACC directives.
nowaitNot yet implemented.
Default
By default OpenACC directives are compiled for GPU execution (-acc=gpu).
Usage
The following command-line requests that OpenACC directives be enabled and that an error be issued for any non-standard OpenACC directive.
$ nvfortran -acc=verystrict prog.f
Predefined Macros
The macro __NVCOMPILER_OPENACC_GPU is added implicitly when the OpenACC directives are compiled for GPU. Beta NVFORTRAN does not define __NVCOMPILER_OPENACC_MULTICORE or __NVCOMPILER_OPENACC_HOST, because the targets that they describe are not yet implemented.
Beta NVFORTRAN
Beta NVFORTRAN does not accept the NVIDIA accelerator directives such as
!$acc region. It reports the errorexpected OpenACC directivein every mode.Beta NVFORTRAN does not support compute capabilities below 7.5. When no
-gpuoption selects one, the compiler uses the capability of the installed GPU, and it stops with the errorCompute capabilities less than 75 are not supportedif that capability is lower.
3.2.3. -Bdynamic
Compiles for and links to the shared object version of the NVIDIA HPC Compilers runtime libraries.
Default
Dynamic linking is the default behavior for Linux.
Usage
% nvfortran -Bdynamic myprogram.f
When you use the nvfortran flag -Bdynamic to create an executable that links to the shared object form of the runtime, the executable built is smaller than one built without -Bdynamic. The NVIDIA HPC Compilers runtime shared object(s), however, must be available on the system where the executable is run. The -Bdynamic flag must be used when an executable is linked against a shared object built by the NVIDIA HPC compilers.
Related options
3.2.4. -byteswapio
Swaps the byte-order of data in unformatted Fortran data files on input/output.
Default
The compiler does not byte-swap data on input/output.
Usage
The following command-line requests that byte-swapping be performed on input/output.
$ nvfortran -byteswapio myprog.f
Description
Use the -byteswapio option to swap the byte-order of data in unformatted Fortran data files on input/output. When this option is used, the order of bytes is swapped in both the data and record control words; the latter occurs in unformatted sequential files.
You can use this option to convert big-endian format data files produced by most legacy RISC workstations to the little-endian format used on modern Linux systems on the fly during file reads/writes.
This option assumes that the record layouts of unformatted sequential access and direct access files are the same on the systems. It further assumes that the IEEE representation is used for floating-point numbers. In particular, the format of unformatted data files produced by NVIDIA HPC Fortran compilers is identical to the format used on Sun and SGI workstations; this format allows you to read and write unformatted Fortran data files produced on those platforms from a program compiled for modern Linux platform using the -byteswapio option.
Related options
The FORT_CONVERT_UNIT runtime environment variable can be used to control
the byte ordering of individual unformatted I/O files.
See HPC Fortran Compiler User’s Guide
3.2.5. -C
Generates code to check array bounds.
Beta NVFORTRAN: not yet implemented. The compiler issues the warning not yet implemented: -C and the program runs without checking. Beta NVFORTRAN has no other option that checks array bounds at run time.
Default
The compiler does not enable array bounds checking.
Usage
In this example, the compiler instruments the executable produced from myprog.f to perform array bounds checking at runtime:
$ nvfortran -C myprog.f
Description
Use this option to enable array bounds checking. If an array is an assumed size array, the bounds checking only applies to the lower bound. If an array bounds violation occurs during execution, an error message describing the error is printed and the program terminates. The text of the error message includes the name of the array, the location where the error occurred (the source file and the line number in the source), and information about the out of bounds subscript (its value, its lower and upper bounds, and its dimension).
Related options
3.2.6. -c
Halts the compilation process after the assembling phase and writes the object code to a file.
Default
The compiler produces an executable file and does not use the -c option.
Usage
In this example, the compiler produces the object file myprog.o in the current directory.
$ nvfortran -c myprog.f
Description
Use the -c option to halt the compilation process after the assembling phase and write the object code to a file. If the input file is filename.f, the output file is filename.o.
Related options
3.2.7. -c++libs
Instructs the compiler to append C++ runtime libraries to the link line for programs built using NVFORTRAN.
Default
The NVFORTRAN compiler does not append the C++ runtime libraries to the link line.
Usage
In the following example the C++ runtime libraries are linked with an object file compiled with NVFORTRAN
$ nvfortran main.f90 mycpp.o -c++libs
Description
Use this option to instruct the NVIDIA Fortran compiler to append C++ runtime libraries to the link line.
Related options
3.2.8. -cuda
Enable CUDA; please refer to -gpu for target-specific options. The following suboptions may be used following an equals sign (“=”), with multiple sub-options separated by commas:
charstringEnable limited support for character strings in GPU kernels.
madconstPut Module Array Descriptors in CUDA Constant Memory
Usage
The following command-line requests that CUDA interoperability be enabled and CUDA Fortran syntax be recognized and processed in all Fortran files.
$ nvfortran -cuda myprog.f
3.2.9. -cudalib
Add CUDA-optimized libraries to the link line. When no sub-option is specified the compiler will link all necessary CUDA-optimized libraries. -cudalib will use the version of the library appropriate to the CUDA version being used. The following libraries may be specified following an equals sign (“=”), with multiple libraries separated by commas:
cublasLink in the cuBLAS library.
cufftLink in the cuFFT library.
cufftwLink in the cuFFTW library.
curandLink in the cuRAND library.
cusolverLink in the cuSOLVER library.
cusparseLink in the cuSPARSE library.
cutensorLink in the cuTENSOR library.
nvblasLink in the NVBLAS library.
ncclLink in the NCCL library.
nvlamathLink in the NVLAmath library.
nvshmemLink in the NVSHMEM library.
Usage
The following command-line links in all necessary CUDA libraries.
$ nvfortran -acc -cudalib myprog.f
3.2.10. -D
Creates a preprocessor macro with a given value.
Note
You can use the -D option more than once on a compiler command line. The number of active macro definitions is limited only by available memory.
Syntax
-Dname[=value]
Where name is the symbolic name and value is either an integer value or a character string.
Default
If you define a macro name without specifying a value, the preprocessor assigns the string 1 to the macro name.
Usage
In the following example, the macro PATHLENGTH has the value 256 until a subsequent compilation. If the -D option is not used, PATHLENGTH is set to 128.
$ nvfortran -DPATHLENGTH=256 myprog.F
The source text in myprog.F is this:
#ifndef PATHLENGTH
#define PATHLENGTH 128
#endif
SUBROUTINE SUB
CHARACTER*PATHLENGTH path
...
END
Description
Use the -D option to create a preprocessor macro with a given value. The value must be either an integer or a character string.
You can use macros with conditional compilation to select source text during preprocessing. A macro defined in the compiler invocation remains in effect for each module on the command line, unless you remove the macro with an #undef preprocessor directive or with the -U option. The compiler processes all of the -U options in a command line after processing the -D options.
Related options
3.2.11. -dryrun
Displays the invocations of the compiler, assembler, and linker but does not execute them.
Default
The compiler does not display individual phase invocations.
Usage
The following command line requests verbose invocation information.
$ nvfortran -dryrun myprog.f
Description
Use the -dryrun option to display the invocations of the compiler, assembler, and linker but not have them executed. These invocations are command lines created by the compiler driver from the rc files and the command-line supplied with -dryrun.
Related options
3.2.12. -E
Halts the compilation process after the preprocessing phase and displays the preprocessed output on the standard output.
Default
The compiler produces an executable file.
Usage
In the following example the compiler displays the preprocessed myprog.f on the standard output.
$ nvfortran -E myprog.f
Description
Use the -E option to halt the compilation process after the preprocessing phase and display the preprocessed output on the standard output.
Related options
3.2.13. -F
Stops compilation after the preprocessing phase.
Default
The compiler produces an executable file.
Usage
In the following example the compiler produces the preprocessed file myprog.f in the current directory.
$ nvfortran -F myprog.F
Description
Use the -F option to halt the compilation process after preprocessing and write the preprocessed output to a file. If the input file is filename.F, then the output file is filename.f. If the input file is filename.F90, then the output file is filename.f90.
Related options
3.2.14. -fast
Selects a generally optimal set of options for the host processor.
Default
The compiler uses the default optimization level of -O1.
Usage
In the following example the compiler compiles vadd.f95 with the options that -fast selects.
$ nvfortran -fast vadd.f95
Description
In Beta NVFORTRAN, -fast is equivalent to -O3. Beta NVFORTRAN generates code for the host processor with or without -fast, so programs built on a given system are not necessarily backward-compatible with older systems.
Related options
-O<level>, -Munroll[=option [,option…]], -Mnoframe, -M[no]vect[=option [,option,…]], -Mcache_align, -tp <target>
3.2.15. -fortranlibs
Used on the link line of the NVC++ or NVC compiler, instructs the C++ or C compiler to append NVFORTRAN runtime libraries to the link line. Use this option when you link object files compiled with nvfortran into a C++ or C main program.
Default
The C++ and C compilers do not append the NVFORTRAN runtime libraries to the link line.
Usage
In the following example a .c main program is linked with an object file compiled with nvfortran.
$ nvc main.c myfort.o -fortranlibs
Description
Use this option to instruct the C++ or C compiler to append NVFORTRAN runtime libraries to the link line.
Related options
3.2.16. -ferror-limit=<n>
Sets the maximum number of errors that the compiler reports to <n>, and then stops the compilation.
Default
There is no error limit (-ferror-limit=0).
Usage
In the following example the compiler error limit is set to 5.
$ nvfortran -ferror-limit=5 myprog.f
Use the -ferror-limit option to decrease the number of errors that the compiler reports. -ferror-limit=0 removes the limit.
Related options
3.2.17. -fpic
Generates position-independent code suitable for inclusion in shared object (dynamically linked library) files.
Default
The compiler does not generate position-independent code.
Usage
In the following example the resulting object file, myprog.o, can be used to generate a shared object.
$ nvfortran -fpic myprog.f
Use the -fpic option to generate position-independent code suitable for inclusion in shared object (dynamically linked library) files.
Related options
3.2.18. -fPIC
Equivalent to -fpic. Provided for compatibility with other compilers.
3.2.19. -g
Instructs the compiler to include symbolic debugging information in the object module; sets the optimization level to zero unless a -O option is present on the command line.
Default
The compiler does not put debugging information into the object module.
Usage
In the following example, the object file myprog.o contains symbolic debugging information.
$ nvfortran -c -g myprog.f
Description
Use the -g option to instruct the compiler to include symbolic debugging information in the object module. Debuggers require symbolic debugging information in the object module to display and manipulate program variables and source code.
If you specify the -g option on the command-line, the compiler sets the optimization level to -O0 (zero), unless you specify the -O option. For more information on the interaction between the -g and -O options, refer to the -O entry. Symbolic debugging may give confusing results if an optimization level other than zero is selected.
Note
Note: Including symbolic debugging information increases the size of the object module.
Related options
3.2.20. -gopt
Instructs the compiler to include symbolic debugging information in the object file, and to generate optimized code identical to that generated when -g is not specified.
Default
The compiler does not put debugging information into the object module.
Usage
In the following example, the object file myprog.o contains symbolic debugging information.
$ nvfortran -c -gopt myprog.f
Description
Using -g alters how optimized code is generated in ways that are intended to enable or improve debugging of optimized code. The -gopt option instructs the compiler to include symbolic debugging information in the object file, and to generate optimized code identical to that generated when -g is not specified.
Related options
3.2.21. -gpu
Used in combination with the -acc, -cuda, -mp, and -stdpar flags to specify options for GPU code generation. The following sub-options may be used following an equals sign (“=”), with multiple sub-options separated by commas:
autocompareAutomatically compare CPU vs GPU results at execution time: implies redundant
ccXYGenerate code for a device with compute capability X.Y. Multiple compute capabilities can be specified, and one version will be generated for each. By default, the compiler will detect the compute capability for each installed GPU. Use -help -gpu to see the valid compute capabilities for your installation.
ccallGenerate code for all compute capabilities supported by this platform and by the selected or default CUDA Toolkit.
ccall-majorCompile for all major supported compute capabilities.
ccall:preblackwellCompile for all supported compute capabilities that are older than Blackwell.
ccnativeDetects the visible GPUs on the system and generates codes for them. If no device is available, the compute capability matching NVCC’s default will be used.
cudaX.YUse CUDA X.Y Toolkit compatibility, where installed
cuda:{newest|oldest}Use the newest or the oldest CUDA Toolkit that is installed.
[no]debugEnable [disable] debug information generation in device code
deepcopyEnable full deep copy of aggregate data structures in OpenACC
fastmathUse routines from the fast math library
[no]flushzEnable [disable] flush-to-zero mode for floating point computations on the GPU
[no]fmaGenerate [do not generate] fused multiply-add instructions; default at
-O1. This is an alias of -M[no]fma.[no]implicitsectionsChange [do not change] array element references in a data clause into an array section. For example, the
implicitsectionsoption will changeenter data copyin(a(n))toenter data copyin(a(:n)). The default behavior,noimplicitsections, can also be changed using rcfiles; for example, one could addset IMPLICITSECTIONS=0;to siterc or another rcfile.[no]interceptdeallocationsBeta NVFORTRAN also accepts the spelling
[no]interceptdealloc. Intercept [do not intercept] calls to standard library memory deallocations (e.g.free) and call the corresponding CUDA memory deallocation version if address is in pinned or managed memory, regular version otherwise.keepKeep the kernel files (.cubin, .ptx, source)
[no]lineinfoEnable [disable] GPU line information generation
loadcache:{L1|L2}Choose what hardware level cache to use for global memory loads; options include the default,
L1, orL2maxregcount:nSpecify the maximum number of registers to use on the GPU; leaving this blank indicates no limit
mem:{separate[:pinnedalloc|nopinnedalloc]|managed|unified[:managedalloc|nomanagedalloc]}Select GPU memory mode for the generated binary. This controls CUDA memory capability to be utilised such as separate GPU memory only (
separate), GPU Managed Memory for the dynamically allocated data (managed), or system memory aka full CUDA Unified Memory (unified). Use of Managed or Unified Memory facilitates simpler programming by eliminating the need to detect all data to be copied into and outside of the code region executing on the GPU.ptxinfoPrint PTX info
[no]rdcGenerate [do not generate] relocatable device code.
redundantRedundant CPU/GPU execution
safecacheAllow variable-sized array sections in cache directives; compiler assumes they fit into CUDA shared memory
sm_XYGenerate code for a device with compute capability X.Y. Multiple compute capabilities can be specified, and one version will be generated for each. By default, the compiler will detect the compute capability for each installed GPU. Use -help -gpu to see the valid compute capabilities for your installation.
[no]unrollEnable [disable] automatic inner loop unrolling; default at
-O3zeroinitInitialize allocated device memory with zero
Usage
In the following example, the compiler generates code for NVIDIA GPUs with compute capabilities 8.0 and 9.0.
$ nvfortran -acc -gpu=cc80,cc90 myprog.f
The compiler automatically invokes the necessary software tools to create the kernel code and embeds the kernels in the object file.
To link in the appropriate GPU libraries, you must link an OpenACC program with the -acc flag, and similarly for -cuda, -mp, or -stdpar.
DWARF Debugging Formats
Use the -g option to enable generation of full DWARF information on both the host and device; in the absence of other optimization flags, -g sets the optimization level to zero. If a -O option raises the optimization level to one or higher, only GPU line information is generated in device code even when -g is specified. To enforce full DWARF generation for device code at optimization levels above zero, use the debug sub-option to -gpu. Conversely, to prevent the generation of dwarf information for device code, use the nodebug sub-option to -gpu. Both debug and nodebug can be used independently of -g.
3.2.22. -help
Used with no other options, -help displays options recognized by the driver on the standard output. When used in combination with one or more additional options, usage information for those options is displayed to standard output.
Default
The compiler does not display usage information.
Usage
In the following example, usage information for -Minline is printed to standard output.
$ nvfortran -help -Minline
-M[no]inline[=lib:<inlib>||<maxsize>|<func>|except:<func>|name:<func>|maxsize:<n>|totalsize:<n>|smallsize:<n>|reshape|exclude:<sdir>]
Automatically inline functions
<maxsize> Set maximum function size to inline
<func> Inline function func
except:<func> Do not inline function func
name:<func> Inline function func
maxsize:<n> Inline only functions smaller than n
totalsize:<n> Limit inlining to total size of n
smallsize:<n> Always inline functions smaller than n
reshape Allow inlining in Fortran even when array shapes do not
match
-Minline Inline all functions that were extracted
In the following example, usage information for -help shows how groups of options can be listed or examined according to function.
$ nvfortran -help -help
-help[=asm|debug|flang|groups|language|linker|opt|other|overall|phase|prepro|suffix|switch|target|variable]
Display available options
Description
Use the -help option to obtain information about available options and their syntax. You can use -help in one of three ways:
Use
-helpwith no parameters to obtain a list of all the available options with a brief one-line description of each.Add a parameter to -help to restrict the output to information about a specific option. The syntax for this usage is this:
-help <command line option>
Add a parameter to -help to restrict the output to a specific set of options or to a building process. The syntax for this usage is this:
-help=<subgroup>
The following table lists and describes the subgroups available with -help.
For more examples of -help, refer to ‘Help with Command-line Options.’
Related options
3.2.23. -I
Adds a directory to the search path for files that are included using either the INCLUDE statement or the preprocessor directive #include.
Default
The compiler searches only certain directories for included files.
For gcc-lib includes:
/usr/lib64/gcc-libFor system includes:
/usr/include
Syntax
-Idirectory
Where directory is the name of the directory added to the standard search path for include files.
Usage
In the following example, the compiler first searches the directory mydir and then searches the default directories for include files.
$ nvfortran -Imydir
Description
Adds a directory to the search path for files that are included using the INCLUDE statement or the preprocessor directive #include. Use the -I option to add a directory to the list of where to search for the included files. The compiler searches the directory specified by the -I option before the default directories, but after the directory that contains the source file.
The Fortran INCLUDE statement directs the compiler to begin reading from another file. The compiler uses two rules to locate the file:
If the file name specified in the INCLUDE statement includes a path name, the compiler begins reading from the file it specifies.
If no path name is provided in the INCLUDE statement, the compiler searches (in order):
The directory containing the source file
Any directories specified using the -I option (in the order specified)
For example, the compiler applies rule (1) to the following statements:
INCLUDE '/bob/include/file1' (absolute path name) INCLUDE '../../file1' (relative path name)
and rule (2) to this statement:
INCLUDE 'file1'
Related options
None.
3.2.24. -i2, -i4, -i8
Treat INTEGER and LOGICAL variables as either four or eight bytes.
Default
The compiler treats INTEGER and LOGICAL variables as four bytes.
Usage
In the following example, using the -i8 switch causes the integer variables to be treated as 64 bits.
$ nvfortran -i8 int.f
int.f is a function similar to this:
int.f
print *, "Integer size:", bit_size(i)
end
Description
Use this option to treat INTEGER and LOGICAL variables as either four or eight bytes. INTEGER*8 values not only occupy 8 bytes of storage, but operations use 64 bits, instead of 32 bits.
-i4: Treat INTEGER variables as 4 bytes.
-i8: Treat INTEGER and LOGICAL variables as 8 bytes and use 64-bits for INTEGER*8 operations.
Related options
None.
3.2.25. -K<flag>
Requests that the compiler provide special compilation semantics with regard to conformance to IEEE 754.
Default
The default is -Knoieee and the compiler does not provide special compilation semantics.
Syntax
-K<flag>
Where flag is one of the following:
ieeePerform floating-point operations in strict conformance with the IEEE 754 standard. Some optimizations are disabled, and on some systems a more accurate math library is linked if
-Kieeeis used during the link step.noieeeDefault flag. Use the fastest available means to perform floating-point operations, link in faster non-IEEE libraries if available, and disable underflow traps.
trap=option[,option]...Controls the behavior of the processor when floating-point exceptions occur. Possible options include:
fpalign(ignored)invdenormdivzovfunfinexactnone
Note
Same floating-point exception functionality as -Ktrap=flag[,flag] can be achieved with the runtime environment variable NVCOMPILER_FPU_STATE
Usage
In the following example, the compiler performs floating-point operations in strict conformance with the IEEE 754 standard
$ nvfortran -Kieee myprog.f
Description
Use -K to instruct the compiler to provide special compilation and runtime
semantics.
-Ktrap=flag[,flag] controls Floating-point Exception (FPE) behavior
during compilation and runtime.
This option has a dual role:
At compilation, -Ktrap instructs the compiler to maintain the exact FPE
behavior defined in the source code. The compiler won’t introduce new FPEs
through optimizations and will preserve all existing ones. The -Ktrap option
applies to the treatment of all FPEs in compiled code; the individual flags
provided to -Ktrap=flag[,flag] do not influence code generation.
At runtime, -Ktrap=flag[,flag] uses the provided flags to unmask specific
FPEs when the program starts. Normally, a processor’s FPEs are masked, which
means it will recover from the error and continue running. By unmasking them
with -Ktrap=flag[,flag], the program will terminate with a SIGFPE signal
(an arithmetic exception) if one of those specified FPEs occurs. The FPE flags
are only processed when compiling the main program.
Flags
The flags provided to -Ktrap=flag[,flag] correspond to different types of
floating-point exceptions. These are given as a comma-separated list, and the
last flag in the list takes precedence if there are conflicting settings.
denorm: Denormalized operand, an extremely small number near zero.
divz: Divide-by-zero, a division where the divisor is zero.
inexact: Inexact, a loss of precision during a calculation.
inv: Invalid operation, like taking the square root of a negative number.
ovf: Overflow, when a number is too large to be represented.
unf: Underflow, when a number is too small to be represented.
The special flag -Ktrap=none is used to preserve FPEs during compilation
without unmasking any of them at runtime.
The inv, divz, and ovf flags are often the most interesting, as they
signify abnormal floating-point behavior in the program. These can be enabled with
the useful shorthand -Ktrap=fp.
Note
The NVIDIA HPC Fortran compiler does not support exception-free execution for -Ktrap=inexact. The purpose of this hardware support is for those who have specific uses for its execution, along with the appropriate signal handlers for handling exceptions it produces. It is not designed for normal floating point operation code support.
Related options
None.
3.2.26. -L
Specifies a directory to search for libraries.
Note
Multiple -L options are valid. However, the position of multiple -L options is important relative to -l options supplied.
Default
The compiler searches the standard library directory.
Syntax
-Ldirectory
Where directory is the name of the library directory.
Usage
In the following example, the library directory is /lib and the linker links in the standard libraries required by NVFORTRAN from this directory.
$ nvfortran -L/lib myprog.f
In the following example, the library directory /lib is searched for the library file libx.a and both the directories /lib and /libz are searched for liby.a.
$ nvfortran -L/lib -lx -L/libz -ly myprog.f
Description
Use the -L option to specify a directory to search for libraries. Using -L allows you to add directories to the search path for library files.
Related options
3.2.27. -l<library>
Instructs the linker to load the specified library. The linker searches <library>in addition to the standard libraries.
Note
The linker searches the libraries specified with -l in order of appearance before searching the standard libraries.
Syntax
-llibrary
Where library is the name of the library to search.
Usage: In the following example, if the standard library directory is /lib the linker loads the library /lib/libmylib.a, in addition to the standard libraries.
$ nvfortran myprog.f -lmylib
Description
Use this option to instruct the linker to load the specified library. The compiler prepends the characters lib to the library name and adds the .a extension following the library name. The linker searches each library specified before searching the standard libraries.
Related options
3.2.28. -M<nvflag>
Selects options for code generation. The options are divided into the following categories:
Code generation |
Fortran Language Controls |
Optimization |
Environment |
Inlining |
Miscellaneous |
The following table lists and briefly describes the options alphabetically and includes a field showing the category. For more details about the options as they relate to these categories, refer to ‘-M Options by Category’. The options that Beta NVFORTRAN does not support are not in the table.
nvflag |
Description |
Category |
|---|---|---|
|
Controls whether to use Fortran 95 or Fortran 2003 semantics in allocatable array assignments. |
Fortran Language |
|
Annotate the assembly code with source code. Not yet implemented in Beta NVFORTRAN. |
Miscellaneous |
|
Override the assembler. |
Miscellaneous |
|
Determines how the backslash character is treated in quoted strings. |
Fortran Language |
|
Specifies whether array bounds checking is enabled or disabled. Not yet implemented in Beta NVFORTRAN. |
Miscellaneous |
|
Swap byte-order (big-endian to little-endian or vice versa) during I/O of Fortran unformatted data. |
Miscellaneous |
|
Where possible, align data objects of size greater than or equal to 16 bytes on cache-line boundaries. Deprecated in Beta NVFORTRAN; this alignment is now the default. |
Optimization |
|
Check for NULL pointers. Not yet implemented in Beta NVFORTRAN. |
Miscellaneous |
|
Check the stack for available space upon entry to and before the start of a parallel region. Useful when many private variables are declared. Not yet implemented in Beta NVFORTRAN. |
Miscellaneous |
|
Force Cray Fortran (CF77) compatibility. |
Optimization |
|
Enables CUDA Fortran. |
Fortran Language |
|
Do/don’t treat denormalized operands as zero (default). |
Code Generation |
|
Determines whether all program variables must be declared. |
Fortran Language |
|
Checks for potential data dependencies. Not yet implemented in Beta NVFORTRAN. |
Optimization |
|
Enables [disables] dead store elimination phase for programs making extensive use of function inlining. Not yet implemented in Beta NVFORTRAN. |
Optimization |
|
Specifies not to add DWARF debug information. |
Code Generation |
|
When used with -g, generate DWARF2 format debug information. |
Code Generation |
|
When used with -g, generate DWARF3 format debug information. |
Code Generation |
|
Instructs the compiler to accept 132-column source code; otherwise it accepts 72-column code. |
Fortran Language |
|
invokes the function extractor. Not yet implemented in Beta NVFORTRAN. |
Inlining |
|
Perform certain floating point intrinsic functions using relaxed precision. |
Optimization |
|
Instructs the compiler to assume F77-style fixed format source code. |
Fortran Language |
|
Do [not] treat denormalized results as zero (default). |
Code Generation |
|
Specifies not to use low-precision fp approximation operations. |
Optimization |
|
Instructs the compiler to assume F90-style free format source code. |
Fortran Language |
|
Enable [disable] loop idiom recognition. |
Optimization |
|
Prints informational messages regarding optimization and code generation to standard output as compilation proceeds. |
Miscellaneous |
|
Specifies the minimum level of error severity that the compiler displays. |
Miscellaneous |
|
Initialize local INTEGER*4 and INTEGER*8 variables and arrays to the value n. |
Fortran Language |
|
Initialize local LOGICAL*4 and LOGICAL*8 variables and arrays to true or false. |
Fortran Language |
|
Issue a compiler message through -Minfo for each variable or array that is initialized. |
Fortran Language |
|
Initialize local REAL variables and arrays to nan, snan or zero. |
Fortran Language |
|
Invokes the function inliner. |
Inlining |
|
Enable [disable] inlining of the simplified implementations of intrinsic functions. |
Inlining |
|
Generates additional code to enable instrumentation of functions. |
Code Generation |
|
Preserve intermediate assembly language file. |
Miscellaneous |
|
Enables support for 64-bit indexing and single static data objects of size larger than 2GB. |
Code Generation |
|
Enable [disable] loop-carried redundancy elimination. Not yet implemented in Beta NVFORTRAN. |
Optimization |
|
Link the OpenBLAS libraries. |
Miscellaneous |
|
Add the Intel Math Kernel Libraries to the link line. |
Miscellaneous |
|
Instructs the compiler to produce information on why certain optimizations are not performed. |
Miscellaneous |
|
Eliminates operations that set up a true stack frame pointer for functions. |
Optimization |
|
Treat INTEGER variables and constants as INTEGER(KIND=4). |
Optimization |
|
When the link step is called, don’t include the object file that calls the Fortran main program. |
Code Generation |
|
On Linux, do not add -rpath paths to the link line. |
Miscellaneous |
|
Link the NVIDIA Performance Libraries (Arm only). |
Miscellaneous |
|
Enable PCAST directives. Not yet implemented in Beta NVFORTRAN. |
Miscellaneous |
|
Enable [disable] plugin support. |
Miscellaneous |
|
Perform cpp-like preprocessing on assembly language and Fortran input source files. |
Miscellaneous |
|
Allocate [do not allocate] local variables on the stack; this allows recursion. SAVEd, data-initialized, or namelist members are always allocated statically, regardless of the setting of this switch. |
Code Generation |
|
Specifies whether the compiler avoids optimizations that can prevent code from being reentrant. |
Code Generation |
|
Determines whether the compiler assumes that all local variables are subject to the SAVE statement. |
Fortran Language |
|
Do [do not] add the second underscore to the name of a Fortran global if its name already contains an underscore. Not yet implemented in Beta NVFORTRAN; the compiler reports an error. |
Code Generation |
|
Causes the compiler to flag source code that does not conform to the ANSI standard. |
Fortran Language |
|
Link in the ScaLAPACK library. |
Miscellaneous |
|
Do [do not] generate alternate code for a loop that contains an induction variable whose increment may be zero. Not yet implemented in Beta NVFORTRAN. |
Code Generation |
|
[do not] treat any non-zero logical variable as .TRUE. In Beta NVFORTRAN, |
Fortran Language |
|
Controls loop unrolling. |
Optimization |
|
Determines whether the compiler preserves uppercase letters in identifiers. Fortran keywords must be in lowercase. Deprecated in Beta NVFORTRAN. |
Fortran Language |
|
Do [do not] invoke the code vectorizer. |
Optimization |
|
Store constants in the writable data segment. |
Code Generation |
3.2.29. -m
Displays a link map on the standard output.
Default
The compiler does not display the link map.
Usage
When the following example is executed, nvfortran writes the link map to stdout.
$ nvfortran -m myprog.f
Description
Use this option to display a link map.
On Linux, the map is written to
stdout.
Related options
3.2.30. -march=<target>
Sets the target processor and instruction set for the code that the compiler generates. -march=help lists the supported processors.
Default
native. Beta NVFORTRAN produces code for the processor on which compilation is performed.
Usage
$ nvfortran -march=skylake myprog.f90
Description
On x86-64, Beta NVFORTRAN accepts these values:
nativegenerate code targeted for the host processor.
haswell,broadwellgenerate code for Intel Haswell and Broadwell processors.
skylake,skylake-avx512,skxgenerate code for Intel Skylake Xeon processors.
icelake,icelake-server,icelake-clientgenerate code for Intel Ice Lake processors.
cannonlake,cascadelake,cooperlake,tigerlake,alderlake,rocketlake,sapphirerapids,graniterapids,emeraldrapidsgenerate code for the Intel processor of that name.
znver1,znver2,znver3,znver4,znver5generate code for AMD Zen, Zen 2, Zen 3, Zen 4 and Zen 5 processors.
x86-64-v3,x86-64-v4generate code for the x86-64 microarchitectural levels that include AVX2 and some AVX-512 extensions.
The target must be within the same CPU family as the processor on which compilation is performed. Executables that are created without -march may not be usable on previous-generation systems. For example, executables created on an Intel Skylake processor may use AVX-512 or other instructions that are not available on earlier Intel processors or certain AMD processors.
On Arm, -march is an alias for -mcpu=<target>[<+extension…>].
Beta NVFORTRAN rejects the names px, host, zen, zen2, zen3, zen4 and zen5 for -march, but it accepts them for -tp <target>.
Related options
-tp <target>, -mcpu=<target>[<+extension…>], -mtune=<target>
3.2.31. -mcmodel=<size>
Generates code for the requested memory model in the Linux execution environment.
Default: The compiler generates code for the small memory model on Arm and x86-64 targets.
Usage
The following command line requests the medium memory model:
$ nvfortran -mcmodel=medium myprog.f
Arm Description
The tiny memory model limits the combined area for a user’s object or executable to 1MB. The maximum code size is 1MB.
The small memory model limits the combined area for a user’s object or executable to 4GB. The maximum code size is 2GB.
The medium memory model is not supported on Arm. This will automatically select the large memory model.
The large memory model allows unrestricted data size. The maximum code size is 2GB. -mcmodel=large is not compatible with -fPIC on Arm systems.
x86-64 Description
The tiny memory model is not supported on x86-64.
The small memory model limits the combined area for a user’s object or executable to 2GB. Implies -Mlarge_arrays on x86-64 targets.
The medium memory model allows unrestricted data size. The maximum code size is 2GB.
The Linux environment provides static libxxx.a archive libraries, that are built both with and without -fpic, and dynamic libxxx.so shared object libraries that are compiled with -fpic. Using the link switch -mcmodel=medium implies the -fpic switch and utilizes the shared libraries by default.
Beta NVFORTRAN accepts -mcmodel=large and -mcmodel=kernel on x86-64.
Details
The tiny and small code models are the fastest and should be suitable for the majority of programs. The medium and large code models allow for larger code and data sizes, at the cost of extra instructions. Please see the respective SysV ABI documents for more detail.
Related options
3.2.32. -mcpu=<target>[<+extension…>]
Sets the target processor. An optional list of architecture extensions may follow the target processor. Architecture extensions are disabled by prepending no to the extension name. For example, +nocrypto. Extensions are processed in order, from left-to-right.
Default
The NVIDIA HPC Fortran compiler (NVFORTRAN) produces code specifically targeted to the type of processor on which compilation is performed. In particular, the default is to use all supported instructions wherever possible when compiling on a given system.
The default target processor is auto-selected depending on the processor on which the compilation is performed. You can specify a target processor different than the auto-selected default, but that target must be within the same CPU family as the processor on which compilation is performed. Beta NVFORTRAN supports 2 different families of CPUs: x86_64 and 64-bit Arm Server CPUs.
Executables created on a given system without the -mcpu= flag may not be usable on previous generation systems. For example, executables created on an Intel Skylake processor may use AVX-512 or other instructions that are not available on earlier Intel processors or certain AMD processors.
Usage
In the following example, nvfortran sets the target processor to Arm Neoverse-v2 with Crypto support:
$ nvfortran -mcpu=neoverse-v2+crypto myprog.f
Description
Use this option to set the target architecture. By default, nvfortran uses all supported instructions wherever possible when compiling on a given system.
Processor-specific optimizations can be specified or limited explicitly by using the -mcpu option. Thus, it is possible to create executables that are usable on previous-generation systems.
The following list contains the possible suboptions for -mcpu and the processors that each suboption is intended to target. The Arm suboptions are not tested in this guide on x86-64 systems.
x86-64
Beta NVFORTRAN deprecates -mcpu on x86-64. It issues a warning and ignores the option. Use -march=<target> instead.
Arm
pxgenerate code that is usable on any Arm processor-based system.
hostgenerate code targeted for host processor. Link native version of HPC SDK cpu math library.
nativegenerate code targeted for host processor. Alias for -tp host.
a64fxgenerate code that is usable on a Fujitsu A64fx processor-based system (SVE x 512).
neoverse-n1generate code that is usable on any Arm Neoverse-N1 processor-based system.
neoverse-v1generate code that is usable on any Arm Neoverse-V1 processor-based system (SVE x 256).
neoverse-v2generate code that is usable on any Arm Neoverse-V2 processor-based system (SVE x 128).
olympusgenerate code that is usable on any NVIDIA Olympus processor-based system (SVE x 128).
gracegenerate code that is usable on a NVIDIA Grace processor-based system (SVE x 128).
veragenerate code that is usable on a NVIDIA Vera processor-based system (SVE x 128).
graviton3generate code that is usable on an AWS Graviton3 processor-based system (SVE x 256).
graviton4generate code that is usable on an AWS Graviton4 processor-based system (SVE x 128).
thunderx2t99generate code that is usable on a Cavium Vulcan processor-based system.
Related options
3.2.33. -module <moduledir>
Allows you to specify a particular directory in which generated intermediate .mod files should be placed.
Default
The compiler places .mod files in the current working directory, and searches only in the current working directory for pre-compiled intermediate .mod files.
Usage
The following command line requests that any intermediate module file produced during compilation of myprog.f be placed in the directory mymods; specifically, the file ./mymods/myprog.mod is used.
$ nvfortran -module mymods myprog.f
Description
Use the -module option to specify a particular directory in which generated intermediate .mod files should be placed. If the -module <moduledir> option is present, and USE statements are present in a compiled program unit, then <moduledir> is searched for .mod intermediate files prior to a search in the default local directory.
Related options
None.
3.2.34. -[no]mp
Enable [disable] OpenMP directives. When enabled, it instructs the compiler to interpret user-inserted OpenMP parallel programming directives, and to generate an executable file which will utilize multiple processors in a parallel system.
Default
The compiler does not interpret user-inserted OpenMP parallel programming directives.
Usage
The following command line requests processing of any OpenMP directives present in myprog.f:
$ nvfortran -mp myprog.f
Description
Use the -mp option to instruct the compiler to interpret user-inserted OpenMP parallel programming directives and to generate an executable file which utilizes multiple processors in a parallel system.
The suboptions are one or more of the following:
gpuOpenMP directives are compiled for GPU execution as well as host fallback to the CPU. Beta NVFORTRAN does not yet implement this suboption; it issues the warning
OpenMP target offload is not yet implemented.multicoreOpenMP directives are compiled for multicore CPU execution only; this sub-option is the default.
omptLink against the OMPT-enabled OpenMP runtime library. OMPT is an interface that helps a first-party tool monitor the execution of an OpenMP program.
For more information about how Beta NVFORTRAN supports OpenMP, refer to the “Using OpenMP” section of the HPC Fortran Compiler User’s Guide.
Related options
3.2.35. -mtune=<target>
Optimizes the generated code for the micro-architecture <target>, without changing the instruction set that -march selects. -mtune=help lists the supported micro-architectures.
Default
native.
Usage
$ nvfortran -march=haswell -mtune=skylake myprog.f90
Description
On x86-64, Beta NVFORTRAN accepts the same values for -mtune as for -march=<target>.
Related options
3.2.36. -noswitcherror
Issues warnings instead of errors for unknown switches. Ignores unknown command line switches after printing a warning message.
Default
The compiler prints an error message and then halts.
Usage
In the following example, the compiler ignores unknown command line switches after printing a warning message.
$ nvfortran -noswitcherror myprog.f
Description
Use this option to instruct the compiler to ignore unknown command line switches after printing a warning message.
Tip
You can configure this behavior in the siterc file by adding: set NOSWITCHERROR=1.
Related options
None.
3.2.37. -[no]nvmalloc
Enable [disable] linking with a library containing a custom memory allocator.
Default
On Arm, the compiler links in the custom memory allocator library for dynamic allocations.
On x86-64, the compiler links in the system library for dynamic allocations.
Usage
In the following example, the compiler uses the custom host memory allocator in place of the system library.
$ nvfortran main.f90 -nvmalloc
Description
Use this option to make use of the alternate memory allocator library. Users may see a performance improvement in certain situations by using this library.
Related options
None.
3.2.38. -O<level>
Invokes code optimization at the specified level.
Default
The compiler enables classical global optimization.
Syntax
-O [level]
Where level is an integer from 0 to 4 or “fast”.
Usage
In the following example, since no -O option is specified, the compiler sets the optimization to level 1.
$ nvfortran myprog.f
In the following example, since no optimization level is specified and a -O option is specified, the compiler enables classical global optimizations.
$ nvfortran -O myprog.f
Description
Use this option to invoke code optimization. Using the nvfortran command with the -Olevel option (the capital O is for Optimize), you can specify any of the following optimization levels:
-O0Level zero specifies no optimization. A basic block is generated for each language statement.
-O1Level one specifies local optimization. Scheduling of basic blocks is performed. Register allocation is performed.
-OWhen no level is specified, level global optimizations are performed, including traditional scalar optimizations, induction recognition, and loop invariant motion. No SIMD vectorization is enabled.
-O2Level two specifies all level-1 and global optimizations, and enables more advanced optimizations such as SIMD code generation, cache alignment, and partial redundancy elimination.
-O3Level three specifies aggressive global optimization. This level performs all level-one and level-two global optimizations and enables more aggressive hoisting and scalar replacement optimizations that may or may not be profitable.
-OfastEnables
-O3,-Mfprelaxed,-Mstack_arrays,-Mno-nan,-Mno-inf, and,-fcx-limited-range.Note
-Mstack_arrayis disabled when both command line options-Ofastand-stdparare enabled.Beta NVFORTRAN:
-Ofastenables-O3and these floating-point options: associative and reciprocal math, approximate functions, no NaNs, no infinities, no signed zeros, no parentheses protection, basic complex arithmetic (equivalent to-fcx-limited-range) and stack arrays. The options-Mno-nanand-Mno-infare not accepted as separate options.-O4Level four performs all level-one, level-two, and level-three optimizations and enables hoisting of guarded invariant floating point expressions.
Beta NVFORTRAN:
-O4is the same as-O3.
The following table shows the interaction between the -O option, -g option, and -Mvect option.
Unoptimized code compiled using the option -O0 can be significantly slower than code generated at other optimization levels. In Beta NVFORTRAN, the -Mvect option sets the optimization level to level-2 if the level is lower, and the -Munroll option does not change the optimization level. The -gopt option is recommended for generation of debug information with optimized code. For more information on optimization, refer to the ‘Multicore CPU Optimization’ section of the HPC Fortran Compiler User’s Guide.
Related options
3.2.39. -o
Names the executable file. Use the -o option to specify the filename of the compiler object file. The final output is the result of linking.
Default
The compiler creates executable filenames as needed. If you do not specify the -o option, the default filename is the linker output file a.out.
Syntax
-o filename
Where filename is the name of the file for the compilation output. The filename should not have a .f extension.
Usage
In the following example, the executable file is myprog instead of the default a.out.
$ nvfortran myprog.f -o myprog
Related options
3.2.40. -pg
Instructs the compiler to instrument the generated executable for gprof-style gmon.out sample-based profiling trace file.
Beta NVFORTRAN: not yet implemented. The compiler accepts the option, issues the warning not yet implemented: -pg and does not instrument the executable.
Default
The compiler does not instrument the generated executable for gprof-style profiling.
Usage:
In the following example the program is compiled for profiling using gprof.
$ nvfortran -pg myprog.f
Description
Use this option to instruct the compiler to instrument the generated executable for gprof-style sample-based profiling. You must use this option at both the compile and link steps. A gmon.out style trace is generated when the resulting program is executed, and can be analyzed using gprof.
Related options
None.
3.2.41. -R<directory>
Instructs the linker to hard-code the pathname <directory> into the search path for generated shared object (dynamically linked library) files.
Note
There cannot be a space between R and <directory>.
Usage
In the following example, at runtime the a.out executable searches the specified directory, in this case /home/Joe/myso, for shared objects.
$ nvfortran -R/home/Joe/myso myprog.f
Description
Use this option to instruct the compiler to pass information to the linker to hard-code the pathname <directory> into the search path for shared object (dynamically linked library) files.
Related options
3.2.42. -r
Creates a relocatable object file.
Default
The compiler does not create a relocatable object file and does not use the -r option.
Usage
In this example, nvfortran creates a relocatable object file.
$ nvfortran -r myprog.f
Description
Use this option to create a relocatable object file.
Related options
3.2.43. -r4 and -r8
-r8 interprets REAL variables as DOUBLE PRECISION. -r4 selects the default 4-byte REAL and does not change the kind of DOUBLE PRECISION. Note that these options do not override de facto standard type declarations that explicitly declare the number of bytes in the type name (REAL*4 and REAL*8).
Usage
In this example, the REAL variables are interpreted as DOUBLE PRECISION.
$ nvfortran -r8 myprog.f
Description
With -r8, the kind of a REAL variable is 8. The kind of a DOUBLE PRECISION variable is 8 with or without -r8 or -r4.
Related options
3.2.44. -rc
Specifies the name of the driver startup configuration file. If the file or pathname supplied is not a full pathname, the path for the configuration file loaded is relative to the $DRIVER path (the path of the currently executing driver). If a full pathname is supplied, that file is used for the driver configuration file.
Syntax
-rc [path] filename
Where path is either a relative pathname, relative to the value of $DRIVER, or a full pathname beginning with “/”. Filename is the driver configuration file.
Usage
In the following example, the file .nvfortranrctest, relative to /opt/hpc_sdk/<target>/<release>/compilers/bin, the value of $DRIVER, is the driver configuration file.
$ nvfortran -rc .nvfortranrctest myprog.f
Description
Use this option to specify the name of the compiler driver startup configuration file. If the file or pathname supplied is not a full pathname, the path for the configuration file loaded is relative to the $DRIVER path – the path of the currently executing compiler driver. If a full pathname is supplied, that file is used for the compiler driver configuration file.
Related options
3.2.45. -S
Stops compilation after the compiling phase and writes the assembly-language output to a file.
Default
The compiler does not retain a .s file.
Usage
In this example, nvfortran produces the file myprog.s in the current directory.
$ nvfortran -S myprog.f
Description
Use this option to stop compilation after the compiling phase and then write the assembly-language output to a file. If the input file is filename.f, then the output file is filename.s.
Related options
3.2.46. -s
Strips the symbol-table information from the executable file.
Default
The compiler includes all symbol-table information and does not use the -s option.
Usage
In this example, nvfortran strips symbol-table information from the a.out. executable file.
$ nvfortran -s myprog.f
Description
Use this option to strip the symbol-table information from the executable.
Related options
3.2.47. -shared
Instructs the compiler to pass information to the linker to produce a shared object (dynamically linked library) file.
Default
The compiler does not pass information to the linker to produce a shared object file.
Usage
In the following example the compiler passes information to the linker to produce the shared object file:myso.so.
$ nvfortran -shared myprog.f -o myso.so
Description
Use this option to instruct the compiler to pass information to the linker to produce a shared object (dynamically linked library) file.
Related options
3.2.48. -show
Produces driver help information describing the current driver configuration.
Default
The compiler does not show driver help information.
Usage
In the following example, the driver displays configuration information to the standard output after processing the driver configuration file.
$ nvfortran -show myprog.f
Description
Use this option to produce driver help information describing the current driver configuration.
Related options
3.2.49. -soname
The compiler recognizes the -soname option and passes it through to the linker.
Default
The compiler does not recognize the -soname option.
Usage
In the following example, the driver passes the soname option and its argument through to the linker.
$ nvfortran -soname library.so myprog.f
Description
Use this option to instruct the compiler to recognize the -soname option and pass it through to the linker.
Related options
None.
3.2.50. -static
Statically link all libraries, including the NVIDIA HPC Compilers runtime.
Default
Dynamic linking is the default behavior for Linux
Usage
The following command line explicitly compiles for and links to the static version of the NVIDIA HPC Compilers runtime libraries:
% nvfortran -static -c object1.f
Description
You can use this option to explicitly compile for and link to the static versions of the system libraries and NVIDIA HPC Compilers runtime libraries.
Related options
3.2.51. -static-nvidia
Linux only. Compile and statically link only to the NVIDIA HPC Compilers runtime libraries. Other libraries are dynamically linked. Implies -Mnorpath.
Default
The compiler uses static libraries.
Usage
The following command line explicitly compiles for and links to the static version of the NVIDIA HPC Compilers runtime libraries:
% nvfortran -static-nvidia -c object1.f
Description
You can use this option to explicitly compile for and link to the static version of the NVIDIA HPC Compilers runtime libraries.
Note
On Linux, -static-nvidia results in code that runs on most Linux systems without requiring a Portability package.
Related options
3.2.52. -stdpar
Enable parallelization of Fortran DO CONCURRENT loops (ISO Fortran standard language parallelism); please refer to -gpu for target-specific options. The supported sub-options may be used following an equals sign (“=”), with multiple sub-options separated by commas.
Default
Without sub-options, -stdpar requests generation of code for execution of DO CONCURRENT loops on the GPU.
Sub-options
gpuExecute
DO CONCURRENTloops on the GPU; the default.multicoreExecute
DO CONCURRENTloops in parallel on the CPU. Beta NVFORTRAN issues the warningmapping DO CONCURRENT to OpenMP is experimental.
Usage
The following command-line enables parallelization of DO CONCURRENT loops for offloading to a GPU.
$ nvfortran -stdpar myprog.f90
3.2.53. -time
Print execution times for various compilation steps.
Default
The compiler does not print execution times for compilation steps.
Usage
In the following example, nvfortran prints the execution times for the various compilation steps.
$ nvfortran -time myprog.f
Description
Use this option to print execution times for various compilation steps. Beta NVFORTRAN prints a report of the passes that take the most time, headed Compiler Execution Time Report.
Related options
3.2.54. -tp <target>
Sets the target processor.
Default
The NVIDIA HPC Fortran compiler (NVFORTRAN) produces code specifically targeted to the type of processor on which compilation is performed. In particular, the default is to use all supported instructions wherever possible when compiling on a given system.
The default target processor is auto-selected depending on the processor on which the compilation is performed. You can specify a target processor different than the auto-selected default, but that target must be within the same CPU family as the processor on which compilation is performed. Beta NVFORTRAN supports 2 different families of CPUs: x86_64 and 64-bit Arm Server CPUs.
Executables created on a given system without the -tp flag may not be usable on previous generation systems. For example, executables created on an Intel Skylake processor may use AVX-512 or other instructions that are not available on earlier Intel processors or certain AMD processors.
Usage
In the following example, nvfortran sets the target processor to an Intel Skylake Xeon processor:
$ nvfortran -tp=skylake myprog.f
Description
Use this option to set the target architecture. By default, nvfortran uses all supported instructions wherever possible when compiling on a given system.
Processor-specific optimizations can be specified or limited explicitly by using the -tp option. Thus, it is possible to create executables that are usable on previous-generation systems.
x86-64
-tp is an alias of -march=<target>; it also sets -mtune. -tp=help lists the supported processors. Beta NVFORTRAN accepts the values of -march and these additional names:
pxgenerate code that is usable on any x86-64 processor-based system.
host,nativegenerate code targeted for the host processor.
zen,zen2,zen3,zen4generate code for the AMD Zen processor of that name.
zen5is not accepted; useznver5.
Beta NVFORTRAN rejects the values x86-64-v2, bulldozer, piledriver, bdver3, bdver4 and sandybridge.
Arm
hostgenerate code targeted for host processor. Link native version of HPC SDK cpu math library.
nativegenerate code targeted for host processor. Alias for -tp host.
a64fxgenerate code that is usable on a Fujitsu A64fx processor-based system (SVE x 512).
neoverse-n1generate code that is usable on any Arm Neoverse-N1 processor-based system.
neoverse-v1generate code that is usable on any Arm Neoverse-V1 processor-based system (SVE x 256).
neoverse-v2generate code that is usable on any Arm Neoverse-V2 processor-based system (SVE x 128).
olympusgenerate code that is usable on any NVIDIA Olympus processor-based system (SVE x 128).
gracegenerate code that is usable on a NVIDIA Grace processor-based system (SVE x 128).
veragenerate code that is usable on a NVIDIA Vera processor-based system (SVE x 128).
graviton3generate code that is usable on an AWS Graviton3 processor-based system (SVE x 256).
graviton4generate code that is usable on an AWS Graviton4 processor-based system (SVE x 128).
thunderx2t99generate code that is usable on a Cavium Vulcan processor-based system.
The Arm values are not tested in this guide on x86-64 systems.
Related options
3.2.55. -[no]traceback
Adds debug information for runtime traceback for use with the environment variable NVCOMPILER_TERM.
Default
The compiler enables traceback.
Syntax
-traceback
Usage
In this example, nvfortran enables traceback for the program myprog.f.
$ nvfortran -traceback myprog.f
Description
Use this option to enable or disable runtime traceback information for use with the environment variable NVCOMPILER_TERM.
Setting set TRACEBACK=OFF; in siterc or .mynv*rc also disables default traceback.
Using ON instead of OFF enables default traceback.
Related options
None.
3.2.56. -U
Undefines a preprocessor macro.
Syntax
-Usymbol
Where symbol is a symbolic name.
Usage
The following examples undefine the macro test.
$ nvfortran -Utest myprog.F
$ nvfortran -Dtest -Utest myprog.F
Description
Use this option to undefine a preprocessor macro. You can also use the #undef pre-processor directive to undefine macros.
Related options
3.2.57. -u
Initializes the symbol-table with <symbol>, which is undefined for the linker. An undefined symbol triggers loading of the first member of an archive library.
Default
The compiler does not use the -u option.
Syntax
-usymbol
Where symbol is a symbolic name.
Usage
In this example, nvfortran initializes symbol-table with test.
$ nvfortran -utest myprog.f
Description
Use this option to initialize the symbol-table with <symbol>, which is undefined for the linker. An undefined symbol triggers loading of the first member of an archive library.
Related options
3.2.58. -V[release_number]
Displays additional information, including version messages. Further, if a release_number is appended, the compiler driver attempts to compile using the specified release instead of the default release.
Note
There can be no space between -V and release_number.
Default
The compiler does not display version information and uses the release specified by your path to compile.
Usage
The following command-line shows the output using the -V option.
% nvfortran -V myprog.f
The following command-line causes nvfortran to compile using the 20.7 release instead of the default release.
% nvfortran -V20.7 myprog.f
Description
Use this option to display additional information, including version messages or, if a release_number is appended, to instruct the compiler driver to attempt to compile using the specified release instead of the default release.
The specified release must be co-installed with the default release
Related options
3.2.59. -v
Displays the invocations of the compiler, assembler, and linker.
Default
The compiler does not display individual phase invocations.
Usage
In the following example you use -v to see the commands sent to compiler tools, assembler, and linker.
$ nvfortran -v myprog.f90
Description
Use the -v option to display the invocations of the compiler, assembler, and linker. These invocations are command lines created by the compiler driver from the files and the -W options you specify on the compiler command-line.
Related options
-dryrun, -Minfo[=option [,option,…]], -V[release_number], -W
3.2.60. -W
Passes arguments to a specific phase.
Syntax
-W{0 | a | l },option[,option...]
Note
You cannot have a space between the -W and the single-letter pass identifier, between the identifier and the comma, or between the comma and the option.
0(the number zero) specifies the compiler. Beta NVFORTRAN rejects
-W0with the errorUnknown switch.aspecifies the assembler. Beta NVFORTRAN rejects
-Wawith the errorUnknown switch.l(lowercase letter l) specifies the linker.
optionis a string that is passed to and interpreted by the compiler, assembler or linker. Options separated by commas are passed as separate command line arguments.
Usage
In the following example the linker loads the text segment at address 0xffc00000 and the data segment at address 0xffe00000.
$ nvfortran -Wl,-k,-t,0xffc00000,-d,0xffe00000 myprog.f
Description
Use this option to pass arguments to a specific phase. You can use the -W option to specify options for the assembler, compiler, or linker.
The nvfortran command invokes the compiler driver, which parses the command-line, and generates the appropriate commands for the compiler, assembler, and linker.
Related options
3.2.61. -Werror
Turn all warning messages into error messages. Compilation fails when errors are detected.
Default
The compiler does not abort compilation when only warning messages are generated.
Usage
In the following example all warning messages are fatal messages.
$ nvfortran -Werror myprog.f
Description
Use the -Werror option to abort compilation upon encountering any warning message.
Related options
3.2.62. -w
Do not print warning messages.
Default
The compiler prints warning messages.
Usage
In the following example no warning messages are printed.
$ nvfortran -w myprog.f
Description
Use the -w option to inhibit warning messages.
Related options
None.
3.2.63. -Xlinker
Pass options to the linker.
Syntax
-Xlinker option[,option...]
Default
None.
Usage
In the following example the option –trace-symbol=foo is passed to the linker, which will cause the Linux linker to list all the files that reference symbol foo.
$ nvfortran -Xlinker --trace-symbol=foo myprog.f
Description
Use this option pass options to the linker. This is useful when the link step needs to be customized but the compiler doesn’t understand the necessary linker options. The options supported by the linker are platform dependent and are not listed here. This option has the same effect as -Wl.
Related options
3.3. -M Options by Category
This section describes each of the options available with -M by the categories:
Code Generation |
Fortran Language Controls |
Optimization |
Environment |
Inlining |
Miscellaneous |
The following sections provide detailed descriptions of several, but not all, of the -M<nvflag> options. For a complete alphabetical list of all the options, refer to Table 8. These options are grouped according to categories and are listed with exact syntax, defaults, and notes concerning similar or related options.
For the latest information and description of a given option, or to see all available options, use the --help command-line option, described in -help.
Some of the options in this section are not yet implemented in Beta NVFORTRAN. Beta NVFORTRAN accepts a not yet implemented option, issues the warning not yet implemented and ignores the option. Beta NVFORTRAN accepts a deprecated option, issues a warning and ignores the option. It rejects an option that it does not support with the error Unknown switch.
3.3.1. Code Generation Controls
This section describes the -M<nvflag> options that control code generation.
Related options: -D, -I, -L, -l, -U.
The following list provides the syntax for each -M<nvflag> option that controls code generation. Each option has a description and, if appropriate, any related options.
-MdazSet IEEE denormalized floating point operands to zero; there is a performance benefit but misleading results can occur, such as when dividing a small normalized number by a denormalized number. To take effect, this option must be set when compiling the main program/function. [default]
Note
Same functionality can be achieved with the runtime environment variable
NVCOMPILER_FPU_STATE-MnodazDo not treat denormalized numbers as zero. To take effect, this option must be set for the main program.
Note
Same functionality can be achieved with the runtime environment variable
NVCOMPILER_FPU_STATE-MnodwarfSpecifies not to add DWARF debug information.
-Mdwarf2Generate DWARF2 format debug information. To take effect, this option must be used in combination with
-g.-Mdwarf3Generate DWARF3 format debug information. To take effect, this option must be used in combination with
-g.-MflushzSet floating point control register to flush-to-zero mode; if a floating-point underflow occurs, the result is set to zero. To take effect, this option must be set when compiling the main program/function. [default]
Note
Same functionality can be achieved with the runtime environment variable
NVCOMPILER_FPU_STATE-MnoflushzDo not set flush-to-zero mode; generate underflows. To take effect, this option must be set for the main program.
Note
Same functionality can be achieved with the runtime environment variable
NVCOMPILER_FPU_STATE-MfmaEnable FMA (fused multiply-add) generation on both the CPU and GPU; default at
-O1.Note
The global
-Mfmaoption can be used in conjunction with-gpu=[no]fmato explicitly enable/disable FMAs on either the CPU or GPU.Example:
-Mfma // Enable CPU and GPU FMAs. -Mfma -gpu=nofma // Enable CPU FMAs and disable GPU FMAs. -Mnofma -gpu=fma // Disable CPU FMAs and enable GPU FMAs. -Mnofma // Disable CPU and GPU FMAs.
-MnofmaDisable FMA (fused multiply-add) generation on both the CPU and GPU.
Note
The global
-Mnofmaoption can be used in conjunction with-gpu=[no]fmato explicitly enable/disable FMAs on either the CPU or GPU.-MinstrumentGenerate additional code to enable instrumentation of functions. Just after function entry and just before function exit, the following profiling functions are called with the address of the current function and its call site.
void __cyg_profile_func_enter (void *this_fn, void *call_site); void __cyg_profile_func_exit (void *this_fn, void *call_site);
Note
In these calls, the first argument is the address of the start of the current function.
-Mlarge_arraysEnable support for 64-bit indexing and single static data objects larger than 2 GB in size. On x86-64 targets, this option is the default in the presence of
-mcmodel=medium. It can be used separately together with the default small memory model for certain 64-bit applications that manage their own memory space. For more information, refer to the ‘Programming Considerations for 64-Bit Environments’ section of the HPC Fortran Compiler User’s Guide-MnomainInstructs the compiler not to include the object file that calls the Fortran main program as part of the link step. This option is useful for linking programs in which the main program is written in C/C++ and one or more subroutines are written in Fortran.
-Mrecursiveinstructs the compiler to allow Fortran subprograms to be called recursively.
-MnorecursiveFortran subprograms may not be called recursively.
-Mreentrantinstructs the compiler to avoid optimizations that can prevent code from being reentrant.
-Mnoreentrantinstructs the compiler not to avoid optimizations that can prevent code from being reentrant.
-Msecond_underscoreinstructs the compiler to add a second underscore to the name of a Fortran global symbol if its name already contains an underscore. This option is useful for maintaining compatibility with object code compiled using gfortran, which uses this convention by default.
Beta NVFORTRAN: not yet implemented. The compiler reports the error
not yet implemented: second_underscore.-Mnosecond_underscoreinstructs the compiler not to add a second underscore to the name of a Fortran global symbol if its name already contains an underscore.
Beta NVFORTRAN: not yet implemented. The compiler reports the error
not yet implemented: second_underscore.-Mstack_arraysplaces automatic arrays on the stack.
-Mnostack_arraysallocates automatic arrays on the heap.
-Mnostack_arraysis the default and what traditionally has been the approach used.-Mstride0instructs the compiler to inhibit certain optimizations and to allow for stride 0 array references. This option may degrade performance and should only be used if zero-stride induction variables are possible.
Beta NVFORTRAN: not yet implemented.
-Mwritable-constantsStore constants in the writable data segment.
3.3.2. Environment Controls
This section describes the -M<nvflag> options that control environments.
Beta NVFORTRAN does not support the -M<nvflag> options that control environments. It rejects -Mnostartup, -M[no]hugetlb, -M[no]stddef, -Mnostdinc and -Mnostdlib with the error Unknown switch.
3.3.3. Fortran Language Controls
This section describes the -M<nvflag> options that affect Fortran language interpretations by the NVIDIA Fortran compiler.
Default: For arguments that you do not specify, the defaults are backslash and nodclchk.
The following list provides the syntax for each -M<nvflag> option that affect Fortran language interpretations. Each option has a description and, if appropriate, a list of any related options.
-Mallocatable=95|03controls whether Fortran 95 or Fortran 2003 semantics are used in allocatable array assignments. The default behavior is to use Fortran 95 semantics; the
03option instructs the compiler to use Fortran 2003 semantics.-Mbackslashinstructs the compiler to treat the backslash as a normal character, and not as an escape character in quoted strings. This is the default in Beta NVFORTRAN.
-Mnobackslashinstructs the compiler to recognize a backslash as an escape character in quoted strings (in accordance with standard C usage).
-Mdclchkinstructs the compiler to require that all program variables be declared.
-Mnodclchkinstructs the compiler not to require that all program variables be declared.
-Mextendinstructs the compiler to accept 132-column source code; otherwise it accepts 72-column code.
-Mfixedinstructs the compiler to assume input source files are in FORTRAN 77-style fixed form format.
-Mfreeinstructs the compiler to assume input source files are in Fortran 90/95 freeform format.
-Minit-integer=<n>Initialize local
INTEGER*4andINTEGER*8variables and arrays to the value<n>.-Minit-logical=true|falseInitialize local
LOGICAL*4andLOGICAL*8variables and arrays to.TRUE.or.FALSE..-Minit-msgIssue a compiler message through
-Minfofor each variable or array that the compiler initializes with-Minit-integer,-Minit-logicalor-Minit-real. For example:auto-initializing i as 7.-Minit-real=nan|snan|zeroInitialize local
REALvariables and arrays to a quiet NaN (nan), a signaling NaN (snan) or +0.0 (zero).-Msaveinstructs the compiler to assume that all local variables are subject to the
SAVEstatement. This may allow older Fortran programs to run, but it can greatly reduce performance.-Mnosaveinstructs the compiler not to assume that all local variables are subject to the
SAVEstatement.-Mstandardinstructs the compiler to flag non-ANSI-conforming source code.
-Munixlogicaldirects the compiler to treat logical values as true if the value is non-zero and false if the value is zero (UNIX F77 convention). When
-Munixlogicalis enabled, a logical value or test that is non-zero is.TRUE., and a value or test that is zero is.FALSE.. In addition, the value of a logical expression is guaranteed to be one (1) when the result is.TRUE..-Mnounixlogicaldirects the compiler to use the VMS convention for logical values for true and false. Even values are true and odd values are false.
Beta NVFORTRAN: not yet implemented.
-Mupcaseinstructs the compiler to preserve uppercase letters in identifiers. With
-Mupcase, the identifiersXandxare different. Keywords must be in lower case. This selection affects the linking process. If you compile and link the same source code using-Mupcaseon one occasion and-Mnoupcaseon another, you may get two different executables - depending on whether the source contains uppercase letters. The standard libraries are compiled using the default-Mnoupcase.Beta NVFORTRAN: deprecated. The compiler issues a warning and ignores the option.
-Mnoupcaseinstructs the compiler to convert all identifiers to lower case. This selection affects the linking process. If you compile and link the same source code using
-Mupcaseon one occasion and-Mnoupcaseon another, you may get two different executables, depending on whether the source contains uppercase letters. The standard libraries are compiled using-Mnoupcase.Beta NVFORTRAN: deprecated. The compiler issues a warning and ignores the option.
3.3.4. Inlining Controls
This section describes the -M<nvflag> options that control function inlining.
Usage: In the following example, the compiler inlines functions with fewer than approximately 100 statements in the source file myprog.f.
$ nvfortran -Minline=maxsize:100 myprog.f
The following list provides the syntax for each -M<nvflag> option that controls function inlining. Each option has a description and, if appropriate, a list of any related options.
-Mextract[=option[,option,...]]Extracts functions from the file indicated on the command line and creates or appends to the specified extract directory.
Beta NVFORTRAN: not yet implemented. Because inline libraries cannot be created, the
lib:option of-Minlinehas nothing to use.-Minline[=option[,option,...]]instructs the compiler to pass options to the function inliner, where the option can be any of the following:
except:funcInlines all eligible functions except
func, a function in the source text. You can use a comma-separated list to specify multiple functions.name:funcInlines all functions in the source text whose name matches
func. You can use a comma-separated list to specify multiple functions.Beta NVFORTRAN requires the
name:prefix. A function name without the prefix issues the warningnot yet implemented: -Minline=<funcname>.[maxsize:]numberA numeric option is assumed to be a size. Functions of size
numberor less are inlined. If bothnumberandfunctionare specified, then functions matching the given name(s) or meeting the size requirements are inlined.The size number need not exactly equal the number of statements in a selected function; the size parameter is merely a rough gauge.
reshapeinstructs the inliner to allow inlining in Fortran even when array shapes do not match. The default is
-Minline=noreshape, except with-mp, where the default is-Minline=reshape.Beta NVFORTRAN:
noreshapeis not recognized. It issues the warningnot yet implemented: -Minline=<funcname>.smallsize:numberAlways inline functions of size smaller than
numberregardless of other size limits.totalsize:numberStop inlining in a function when the function’s total inlined size reaches the
numberspecified.lib:filename.extinstructs the inliner to inline the functions within the library file
filename.ext, created with-Mextract. This option is not useful in Beta NVFORTRAN, because-Mextractis not yet implemented.
If you specify both
funcandnumber, the compiler inlines functions that match the function name or havenumberor fewer statements.Inlining can be disabled with
-Mnoinline.For examples of inlining functions, refer to the ‘Using Function Inlining’ section of the HPC Fortran Compiler User’s Guide.
-Minline-intrnEnable inlining of the simplified implementations of intrinsic functions.
-Mnoinline-intrndisables it.
3.3.5. Optimization Controls
This section describes the -M<nvflag> options that control optimization.
Usage: In this example, the compiler invokes the vectorizer with use of packed SIMD instructions enabled.
$ nvfortran -Mvect=simd myprog.f
Note
If you do not supply any sub-options to -Mvect, the compiler uses defaults that are dependent upon the target system. Not all sub-options are valid on all target systems.
Related options: -g, -O
The following list provides the syntax for each -M<nvflag> option that controls optimization. Each option has a description and, if appropriate, a list of any related options.
-Mcache_alignAlign unconstrained objects of length greater than or equal to 16 bytes on cache-line boundaries. An unconstrained object is a data object that is not a member of an aggregate structure or common block. This option does not affect the alignment of allocatable or automatic arrays. To effect cache-line alignment of stack-based local variables, the main program or function must be compiled with
-Mcache_align.Beta NVFORTRAN: deprecated, because this alignment is now the default. The compiler issues a warning and ignores the option.
-Mdepchkinstructs the compiler to assume unresolved data dependencies actually conflict.
Beta NVFORTRAN: not yet implemented.
-MdseEnables a dead store elimination phase that is useful for programs that rely on extensive use of inline function calls for performance. This is disabled by default.
Beta NVFORTRAN: not yet implemented.
-Mnodseis also not yet implemented.-M[no]fpapprox [=option]Perform certain floating point operations using low-precision approximation.
-Mnofpapproxspecifies not to use low-precision fp approximation operations. By default-Mfpapproxis not used. If-Mfpapproxis used without suboptions, it defaults to use approximatediv,sqrt, andrsqrt. The available suboptions are these:divApproximate floating point division
sqrtApproximate floating point square root
rsqrtApproximate floating point reciprocal square root
-M[no]fprelaxed[=option]Instructs the compiler to use [not use] relaxed precision in the calculation of some intrinsic functions. Can result in improved performance at the expense of numerical accuracy. The possible values for option are:
[no]divPerform divide using relaxed precision.
[no]intrinsicEnables use of relaxed precision intrinsics.
[no]orderAllow [do not allow] expression reordering, including factoring.
[no]recipPerform reciprocal using relaxed precision.
[no]rsqrtPerform reciprocal square root (1/sqrt) using relaxed precision.
[no]sqrtPerform square root with relaxed precision.
With no options,
-Mfprelaxedgenerates relaxed precision code for those operations that generate a significant performance improvement, depending on the target processor. The default is-Mnofprelaxedwhich instructs the compiler to not use relaxed precision in the calculation of intrinsic functions.-M[no]idiomEnable [disable] loop idiom recognition.
-Mi4instructs the compiler to treat
INTEGERvariables asINTEGER*4.-MlreEnables loop-carried redundancy elimination, an optimization that can reduce the number of arithmetic operations and memory references in loops.
Beta NVFORTRAN: not yet implemented.
-Mnolreis also not yet implemented.
-MnoframeEliminate operations that set up a true stack frame pointer for every function. With this option enabled, you cannot perform a traceback on the generated code and you cannot access local variables.
-Mprefetchenables generation of prefetch instructions on processors where they are supported.
Beta NVFORTRAN: the option and its suboptions are ignored on x86-64, with a warning.
-Mnoprefetchis also ignored.-M[no]propcondEnables or disables constant propagation from assertions derived from equality conditionals.
Beta NVFORTRAN: not yet implemented.
-M[no]target_tempsinstructs the compiler to enable [disable] using temporaries when passing an array for a callee assumed-shape variable with the target attribute.
Beta NVFORTRAN: deprecated, because the option is no longer required for correct behavior. The compiler issues a warning and ignores the option.
-M[no]unroll[=option [,option...]]invokes the loop unroller to execute multiple instances of the loop during each iteration. The option is one of the following:
c:minstructs the compiler to completely unroll loops with a constant loop count less than or equal to
m, a supplied constant.m:<n>instructs the compiler to unroll multi-block loops
ntimes. This option is useful for loops that have conditional statements.n:<n>instructs the compiler to unroll single-block loops
ntimes, a loop that is not completely unrolled, or has a non-constant loop count.
-Mnounrollinstructs the compiler not to unroll loops.
-M[no]vect[=option [,option,...]]enable [disable] the code vectorizer, where option is one of the following:
[no]assocEnable [disable] certain associativity conversions that can change the results of a computation due to roundoff error. A typical optimization is to change an arithmetic operation to an arithmetic operation that is mathematically correct, but can be computationally different, due to round-off error.
[no]fuseEnable [disable] automatic loop fusion by the vectorizer.
[no]idiomEnable [disable] idiom recognition by the vectorizer.
[no]partialEnable [disable] partial loop vectorization through innermost loop distribution.
simd[:{128|256|512}]Enable vectorization using SIMD instructions and data, either 128 bits, 256 bits or 512 bits wide, on processors where there is a choice.
Beta NVFORTRAN accepts the following keywords, issues a warning and ignores them:
[no]altcode,cachesize:n,[no]gather,levels:n,nocond,prefetch,[no]short,nosimd,[no]simdresidual,[no]sizelimit:nand[no]uniform.
3.3.6. Miscellaneous Controls
This section describes the -M<nvflag> options that do not easily fit into one of the other categories of -M<nvflag> options.
Related options: -m, -S, -V, -v
Usage: In the following example, the assembler does not delete the assembly file myprog.s after the assembly pass.
$ nvfortran -Mkeepasm myprog.f
In the following example, the compiler displays information about inlined functions.
$ nvfortran -Minfo=inline -Minline=maxsize:20 myprog.f
The following list provides the syntax for each miscellaneous -M<nvflag> option. Each option has a description and, if appropriate, a list of any related options.
-Mannoannotate the generated assembly code with source code. Implies
-Mkeepasm.Beta NVFORTRAN: not yet implemented.
-Masm=gnu|llvmOverride the assembler.
gnuuses the GNU assembler andllvmuses the LLVM assembler.
-M[no]boundsEnables [disables] array bounds checking.
Beta NVFORTRAN: not yet implemented. The compiler issues a warning, and the program runs without checking. The option
-Cis also not yet implemented. Beta NVFORTRAN has no other option that checks array bounds at run time.-Mbyteswapioswap byte-order from big-endian to little-endian or vice versa upon input/output of Fortran unformatted data files. See option
-byteswapio.-Mchkptrinstructs the compiler to check for pointers that are dereferenced while initialized to NULL.
Beta NVFORTRAN: not yet implemented.
-Mchkstkinstructs the compiler to check the stack for available space in the prologue of a function and before the start of a parallel region. Prints a warning message and aborts the program gracefully if stack space is insufficient. This option is useful when many local and private variables are declared in an OpenMP program.
Beta NVFORTRAN: not yet implemented.
-M[no]info[=option [,option,...]]instructs the compiler to produce information on standard error, where option is one of the following:
allinstructs the compiler to produce all available
-Minfoinformation.accel[:detail]instructs the compiler to enable accelerator information.
ftninstructs the compiler to enable Fortran-specific information.
inlineinstructs the compiler to display information about inlined functions.
loopinstructs the compiler to display information about loops, such as information on vectorization.
mpinstructs the compiler to display information about parallelization.
optinstructs the compiler to display information about optimization.
stdparinstructs the compiler to emit information about parallelization of Fortran DO CONCURRENT loops.
vectinstructs the compiler to enable vectorizer information.
Beta NVFORTRAN does not yet implement the
par,lre,ccff,extended,pcast,pfo,cputimeandrealtimekeywords. It rejects the keywordsintensity,timeandunrollwith the errorSwitch -Minfo with unknown keyword.-Minform=levelinstructs the compiler to display error messages at the specified and higher levels, where
levelis one of the following:fatalinstructs the compiler to display fatal error messages.
[no]fileinstructs the compiler to print or not print source file names as they are compiled. The default is to print the names:
-Minform=file.informinstructs the compiler to display all error messages (inform, warn, severe and fatal).
severeinstructs the compiler to display severe and fatal error messages.
warninstructs the compiler to display warning, severe and fatal error messages.
-Mkeepasminstructs the compiler to keep the assembly file as compilation continues. Normally, the assembler deletes this file when it is finished. The assembly file has the same filename as the source file, but with a .s extension.
-Mmathlib[=blas|lapack|openblas]Link the OpenBLAS libraries. Without a suboption,
-Mmathliblinks all the OpenBLAS libraries.-MmklAdd the Intel Math Kernel Libraries to the link line. The environment variable
MKLROOTmust be set to the path to the local MKL installation, the part of the path that precedeslib/<arch>.-Mneginfo[=option[,option,...]]instructs the compiler to produce information on standard error about why various optimizations are not performed, where option is one of the following:
allinstructs the compiler to produce all available information on why various optimizations are not performed.
accelinstructs the compiler to enable accelerator information.
ftninstructs the compiler to enable Fortran-specific information.
inlineinstructs the compiler to display information about inlined functions.
loopinstructs the compiler to display information about loops, such as information on vectorization.
mpinstructs the compiler to display information about parallelization.
optinstructs the compiler to display information about optimization.
vectinstructs the compiler to enable vectorizer information.
Beta NVFORTRAN does not yet implement the
parandlrekeywords, and it rejectsconcur.-MnorpathDo not add -rpath to the link line.
-Mnvpl[=option, [option, ...]]instruct the compiler to link in the NVIDIA Performance Libraries (NVPL) into the application. Use this option without sub-options to link against all libraries in the NVPL, or with sub-options to link only against those NVPL libraries specified. To use the NVPL ScaLAPACK library, use
-Mscalapack -Mnvpl. Refer to the section on-Mscalapackfor more information about this option.Note
The NVPL Libraries are only available for Arm CPUs. For more information about NVPL, please visit https://docs.nvidia.com/nvpl/
Valid options for this flag are:
blaslink in the NVPL BLAS library.
fftlink in the NVPL FFT library.
lapacklink in the NVPL LAPACK library. This option will also cause the NVPL BLAS library to be linked in, as BLAS is a dependency of LAPACK.
randlink in the NVPL RAND library.
sparselink in the NVPL Sparse library.
tensorlink in the NVPL Tensor library.
-MpcastEnable PCAST directives.
Beta NVFORTRAN: not yet implemented.
-M[no]pluginEnable [disable] plugin support.
-Mpreprocessinstruct the compiler to perform cpp-like preprocessing on assembly and Fortran input source files.
-Mscalapackinstruct the compiler to link in the ScaLAPACK library. ScaLAPACK is a library of high-performance linear algebra routines for parallel distributed memory machines, which uses MPI as the underlying communication mechanism. If
-Mnvplis also specified on the command line, then this flag will link in the NVPL ScaLAPACK library into the application. Otherwise, the Netlib ScaLAPACK library will be used.
4. Preprocessing
This chapter describes how the Beta NVFORTRAN preprocessor treats Fortran source: when it runs, the directives and macros that it supports, how it works with fixed form and free form source and with continuation lines, and the macros that it defines. The preprocessor is part of the compiler and follows Fortran lexical rules as well as C rules.
For the differences between the preprocessor of Beta NVFORTRAN and the preprocessor of classic NVFORTRAN, see the Porting Guide.
4.1. Running the Preprocessor
Beta NVFORTRAN runs the preprocessor on every Fortran source file, whatever its file name suffix. A file named prog.f90 can contain #define and #if directives.
These options control the preprocessor:
-ERuns only the preprocessor and writes the result to standard output.
-D<macro>[=<value>]Defines a macro.
-U<macro>Undefines a macro.
-I<directory>Adds a directory to the list that the compiler searches for
#includefiles.
The -nocpp option is accepted and has no effect, because Beta NVFORTRAN always runs the preprocessor.
For example, this command shows the result of preprocessing prog.F90 with the macro DEBUG defined as 1:
nvfortran -E -DDEBUG=1 prog.F90
4.2. Preprocessor Directives
The preprocessor supports these directives: #define, #undef, #include, #if, #ifdef, #ifndef, #elif, #else, #endif, #line, #warning and #error.
A directive name can be written in lowercase or in uppercase, for example
#DEFINE, in fixed form and in free form.A backslash at the end of a directive line continues the directive on the next line. This includes the definition of a macro.
/* Old style C comments */are ignored in directives and removed from the bodies of macro definitions, even when a comment continues across lines with a backslash.// New style C commentsare not removed, because//is the Fortran concatenation operator.An expression in
#ifor#elifcan use Fortran relational operators as well as C operators. For example,#if 2 .LT. 3is true.In fixed form, right margin clipping does not apply to directive lines, so a directive can extend past column 72.
In fixed form, a
#in column 6 is a continuation marker, not the start of a directive.A
#defineor#undefdirective that appears among the continuation lines of a statement takes effect for the text that follows it.
4.3. Macros
A keyword-like macro is a name that is replaced by text. A function-like macro takes arguments in parentheses.
#define NX 100
#define SQUARE(x) ((x)*(x))
real :: a(NX)
print *, SQUARE(3)
The preprocessor expands macros as follows:
Macro names and argument names are case-sensitive. After
#define NX 100,nxis not a macro.The preprocessor rescans text after it expands a macro and its arguments, so a macro can expand to another macro.
Macros are not expanded within quoted character literals, within Hollerith constants, or within quoted or Hollerith
FORMATedit descriptors.Tokenization does not hide the names of Fortran operators and logical constants. After
#define FALSE TRUE, the constant.FALSE.becomes.TRUE..In fixed form, spaces inside a macro name at its invocation prevent the name from being recognized as a macro. For example,
K W Mis not an invocation ofKWM.The
##operator pastes tokens together in a function-like macro, and the#operator turns an argument into a string.A function-like macro can take a variable number of arguments. In the macro body,
__VA_ARGS__stands for the extra arguments, and__VA_OPT__(text)produces text only when there are extra arguments.A Fortran comment inside the arguments of a macro invocation is respected, so a macro call works like a function reference. In this free form example, the comment is removed and the result is
(1 + 2*2):#define FLM(x) (x*2) print *, FLM(1 ! comment + 2)
If the argument list of a function-like macro invocation is not closed at the end of the line, the preprocessor continues the invocation on the following lines.
A macro that expands to text containing
&works as a free form line continuation marker.After
#define CM !, a line that begins withCMis a comment.In fixed form, after
#define KWM c,KWMin column 1 starts a comment line. Acin column 1 is still a comment line even whencis defined as a macro, so a macro cannot makecinto a statement label.The preprocessor expands macros in directive lines such as
!$ompand!$acc.
4.4. Fixed Form and Continuation Lines
In fixed form source, the preprocessor handles the right margin and continuation lines this way:
Text after column 72 (or after column 132) is clipped before macros are expanded, not after.
A macro name can be split across a continuation line, and so can the invocation of a function-like macro, either between the name and the left parenthesis or between the parentheses. A comment line can appear between the pieces.
A macro name that is split across a continuation line must be split at column 72 (or 132). If the text before the continuation ends earlier and the line is padded with blanks, the name is not recognized.
A directive line, such as
#define, between the pieces of a split macro name or macro invocation prevents the macro from being recognized.
In free form source, a macro invocation can continue onto the following lines when its argument list is not closed. A backslash at the end of a free form source line is also a continuation marker.
4.5. Order of Processing
The preprocessor processes source as if it performed these steps in order:
Fixed form lines are padded up to column 72 (or 132) and clipped thereafter.
Fortran comments are removed.
C-style line continuations are processed in preprocessing directives.
C old-style comments are removed from directives.
Fortran line continuations are processed outside preprocessing directives. The line continuation rules depend on the source form. Comment lines that are enabled compiler directives, such as
!$acclines, have their line continuations processed. Conditional compilation directives, such as#if, can appear among continuation lines and have their usual effects.Other preprocessing directives are processed and macros are expanded. Along the way, Fortran
INCLUDElines and#includedirectives are expanded, and all these steps are applied recursively to the included text.Any Fortran comments created by macro replacement are removed.
Steps 5 and 6 are interleaved with respect to the preprocessing state. Conditional compilation directives always reflect only the macro definition state produced by the active #define and #undef directives that precede them.
If a compiler directive in an included source file changes the source form (!DIR$ FIXED or !DIR$ FREE), its effect ends at the end of that file.
4.6. Built-in Macros
The preprocessor defines these macros:
Macro |
Meaning |
Example |
|---|---|---|
|
Date of compilation, as a string |
“Nov 10 2026” |
|
Time of compilation in 24-hour format, including seconds, as a string |
“09:24:13” |
|
Date and time of the last modification of the source file, as a string |
“Tue Nov 10 11:49:21 2026” |
|
Name of the current source or include file, as a string |
“prog.F90” |
|
Current line number, as an integer |
10 |
The macros can be used in any source line, for example print *, __FILE__, __LINE__.
For the macros that identify the compiler and the options in use, such as __NVCOMPILER, see Pre-defined Compiler Macros.
4.6.1. Non-standard Extensions
__COUNTER__Replaced by sequential integers on each expansion, starting from 0.
5. Pre-defined Compiler Macros
Beta NVFORTRAN pre-defines macros that identify the compiler and its version, describe the target platform, and show which command-line options you used. Because Beta NVFORTRAN preprocesses every Fortran source file (see Preprocessing), these macros are available in all source files, whatever the file name suffix and without a preprocessing option.
The standard built-in macros __DATE__, __TIME__, __TIMESTAMP__, __FILE__, __LINE__ and __COUNTER__ are described in the Preprocessing chapter.
To list the pre-defined macros and their values, run the preprocessor on any source file, for example:
nvfortran -dM -E test.F90
5.1. Compiler Identification Macros
The next table shows the macros that identify the compiler.
Macro |
Meaning |
|---|---|
|
Always 1. Identifies the NVIDIA HPC compilers. |
|
The major version, minor version and patch level of the compiler. |
|
Always 1. Identifies the Flang-based Beta NVFORTRAN compiler. |
|
The version of the Beta NVFORTRAN compiler. The values are the same as those of |
|
Always 1. The front end of Beta NVFORTRAN is based on LLVM Flang. |
|
The version of LLVM Flang on which the front end is based. |
Beta NVFORTRAN does not define the macros in the next table. Legacy code that tests them, for example #ifdef __PGI, takes the branch that is for a compiler that does not define them.
Macro |
Meaning |
|---|---|
|
Classic NVFORTRAN defines it with the value 1. Beta NVFORTRAN does not define it. |
|
Legacy macros that classic NVFORTRAN defines to identify the compiler and its version. Beta NVFORTRAN does not define them. |
To compile different code for Beta NVFORTRAN and for classic NVFORTRAN, see the Porting Guide.
5.2. Platform Macros
Beta NVFORTRAN defines macros for the target platform.
Macro |
Meaning |
|---|---|
|
The target is x86-64. |
|
The target operating system is Linux. |
|
Position-independent code and executables. The value is 2. |
Beta NVFORTRAN does not define a macro for each processor feature of the target, such as __AVX2__ and __SSE4_2__, by default.
5.3. GPU Memory Mode Macros
The compiler defines a macro for the GPU memory mode that it compiles for. The default memory mode is Separate Memory Mode, except for -stdpar, which defaults to Managed Memory Mode. For the memory modes and the -gpu=mem: options, see the NVIDIA HPC Fortran Compiler User’s Guide.
Macro |
Defined when |
|---|---|
|
The code is compiled for Separate Memory Mode. This is the default, and |
|
The code is compiled for Managed Memory Mode, which |
|
The code is compiled for Unified Memory Mode, which |
|
The code is compiled for Managed or Unified Memory Mode. |
Each of these macros has the value 1.
5.4. Macros That Depend on Options
The compiler defines some macros only when you use certain command-line options. The next table lists the macros that each option defines. Unless noted otherwise, a macro that appears in the table has the value 1.
Command-line option |
Macros defined |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
_OPENACChas the value 202211, which is the value for OpenACC version 3.3.CUDA_VERSIONandCUDART_VERSIONgive the version of the CUDA toolkit that the compiler uses.The
-acc=multicoreoption is not yet implemented in Beta NVFORTRAN. The compiler issues a warning and defines no macros for it.OpenMP target offload is not yet implemented in Beta NVFORTRAN. The
-mp=gpuoption defines__NVCOMPILER_OPENMP_GPU, but the compiler issues a warning that offload is not implemented.
Note
Beta NVFORTRAN defines _OPENMP as 201511, which is the value for OpenMP version 4.5. This value does not match the default OpenMP version of the compiler, which is OpenMP 5.0. The value will be changed in a future release. Do not use _OPENMP to test whether OpenMP 5.0 features are available. The -fopenmp-version option does not change the value of _OPENMP.
6. Runtime Environment
This section describes details related to compiler code generation, including register conventions and calling conventions for x86-64 and AArch64 processor-based systems. It addresses these conventions for processors running Linux operating systems. The x86-64 conventions are described in this section. For AArch64, this section refers you to the Arm ABI documents.
Note
In this section we sometimes refer to word, halfword, and double word. The equivalent byte information is word (4 byte), halfword (2 byte), and double word (8 byte).
6.1. Linux Programming Model
This section defines compiler and assembly language conventions for the use of certain aspects of an x86-64 processor running a Linux operating system. These standards must be followed to guarantee that compilers, application programs, and operating systems written by different people and organizations will work together. The conventions implement the application binary interface (ABI) as defined in the System V Application Binary Interface: AMD64 Architecture Processor Supplement listed in the Preface. The ABI is described in terms of C language data types; the Linux Fortran Supplement section describes how these conventions apply to Fortran.
6.1.1. x86-64 Function Calling Sequence
This section describes the standard function calling sequence, including the stack frame, register usage, and parameter passing.
x86-64 Register Usage Conventions
The following table defines the standard for register allocation. The x86-64 Architecture provides a variety of registers. All the general purpose registers, x87 registers, XMM registers, SSE registers and AVX registers are visible to all procedures in a running program.
Type |
Name |
Purpose |
|---|---|---|
General |
%rax |
1st return register. When callee has a variable number of arguments, %al specifies the number of vector registers passed. |
%rbx |
callee-saved; optional base pointer |
|
%rcx |
pass 4th argument to functions |
|
%rdx |
pass 3rd argument to functions; 2nd return register |
|
%rsp |
stack pointer |
|
%rbp |
callee-saved; optional stack frame pointer |
|
%rsi |
pass 2nd argument to functions |
|
%rdi |
pass 1st argument to functions |
|
%r8 |
pass 5th argument to functions |
|
%r9 |
pass 6th argument to functions |
|
%r10 |
temporary register; pass a function’s static chain pointer |
|
%r11 |
temporary register |
|
%r12-r15 |
callee-saved registers |
|
XMM |
%xmm0-%xmm1 |
pass and return floating point arguments |
%xmm2-%xmm7 |
pass floating point arguments |
|
%xmm8-%xmm15 |
temporary registers |
|
x87 |
%st(0) |
temporary register; return long double arguments |
%st(1) |
temporary register; return long double arguments |
|
%st(2) - %st(7) |
temporary registers |
x86-64 Stack Frame Organization
In addition to the registers, each function has a frame on the run-time stack. This stack grows downward from high addresses. Table 16 shows the stack frame organization.
Position |
Contents |
Frame |
|---|---|---|
8n+16 (%rbp) |
argument eightbyte n … |
previous |
16 (%rbp) |
argument eightbyte 0 |
|
8 (%rbp) |
return address |
current |
0 (%rbp) |
caller’s %rbp |
current |
-8 (%rbp) |
unspecified … |
|
0 (%rsp) |
variable size |
|
-128 (%rsp) |
red zone |
x86-64 Stack Usage Conventions
Key points concerning the stack frame:
The end of the input argument area is aligned on a 16-byte boundary.
The 128-byte area beyond the location of %rsp is called the red zone and can be used for temporary local data storage. This area is not modified by signal or interrupt handlers.
A call instruction pushes the address of the next instruction (the return address) onto the stack. The return instruction pops the address off the stack and effectively continues execution at the next instruction after the call instruction. A function must preserve non-volatile registers, a register whose contents must be preserved across subroutine calls. Additionally, the called function must remove the return address from the stack, leaving the stack pointer (%rsp) with the value it had before the call instruction was executed.
All registers on an x86-64 system are visible to both a calling and a called function. Registers %rbx, %rsp, %rbp, %r12, %r13, %r14, and %r15 are non-volatile across function calls. Therefore, a function must preserve these registers’ values for its caller. Remaining registers are volatile (scratch) registers, that is a register whose contents need not be preserved across subroutine calls. If a calling function wants to preserve such a register value across a function call, it must save its value explicitly.
Registers are used extensively in the standard calling sequence. The first six integer and pointer arguments are passed in these registers (listed in order): %rdi, %rsi, %rdx, %rcx, %r8, %r9. The first eight floating point arguments are passed in the first eight XMM registers: %xmm0, %xmm1, …, %xmm7. The registers %rax and %rdx are used to return integer and pointer values. The registers %xmm0 and %xmm1 are used to return floating point values.
Additional registers with assigned roles in the standard calling sequence:
- %rsp
The stack pointer holds the limit of the current stack frame, which is the address of the stack’s bottom-most, valid word. The stack must be 16-byte aligned.
- %rbp
The frame pointer holds a base address for the current stack frame. Consequently, a function has registers pointing to both ends of its frame. Incoming arguments reside in the previous frame, referenced as positive offsets from %rbp, while local variables reside in the current frame, referenced as negative offsets from %rbp. A function must preserve this register value for its caller.
- RFLAGS
The flags register contains the system flags, such as the direction flag and the carry flag. The direction flag must be set to the “forward” (i.e., zero) direction before entry and upon exit from a function. Other user flags have no specified role in the standard calling sequence and are not preserved.
- Floating Point Control Word
The control word contains the floating-point flags, such as the rounding mode and exception masking. This register is initialized at process initialization time and its value must be preserved.
Signals can interrupt processes. Functions called during signal handling have no unusual restriction on their use of registers. Moreover, if a signal handling function returns, the process resumes its original execution path with registers restored to their original values. Thus, programs and compilers may freely use all registers without danger of signal handlers changing their values.
x86-64 Functions Returning Scalars or No Value
A function that returns an integral or pointer value places its result in the next available register of the sequence %rax, %rdx.
A function that returns a floating point value that fits in the XMM registers returns this value in the next available XMM register of the sequence %xmm0, %xmm1.
An X87 floating-point return value appears on the top of the floating point stack in %st(0) as an 80-bit X87 number. If this X87 return value is a complex number, the real part of the value is returned in %st(0) and the imaginary part in %st(1).
A function that returns a value in memory also returns the address of this memory in %rax.
Functions that return no value (also called procedures or void functions) put no particular value in any register.
x86-64 Functions Returning Structures or Unions
A function can use either registers or memory to return a structure or union. The size and type of the structure or union determine how it is returned. If a structure or union is larger than 16 bytes, it is returned in memory allocated by the caller.
To determine whether a 16-byte or smaller structure or union can be returned in one or more return registers, examine the first eight bytes of the structure or union. The type or types of the structure or union’s fields making up these eight bytes determine how these eight bytes will be returned. If the eight bytes contain at least one integral type, the eight bytes will be returned in %rax even if non-integral types are also present in the eight bytes. If the eight bytes only contain floating point types, these eight bytes will be returned in %xmm0.
If the structure or union is larger than eight bytes but smaller than 17 bytes, examine the type or types of the fields making up the second eight bytes of the structure or union. If these eight bytes contain at least one integral type, these eight bytes will be returned in %rdx even if non-integral types are also present in the eight bytes. If the eight bytes only contain floating point types, these eight bytes will be returned in %xmm1.
If a structure or union is returned in memory, the caller provides the space for the return value and passes its address to the function as a “hidden” first argument in %rdi. This address will also be returned in %rax.
x86-64 Integral and Pointer Arguments
Integral and pointer arguments are passed to a function using the next available register of the sequence %rdi, %rsi, %rdx, %rcx, %r8, %r9. After this list of registers has been exhausted, all remaining integral and pointer arguments are passed to the function via the stack.
x86-64 Floating-Point Arguments
Float and double arguments are passed to a function using the next available XMM register taken in the order from %xmm0 to %xmm7. After this list of registers has been exhausted, all remaining float and double arguments are passed to the function via the stack.
x86-64 Structure and Union Arguments
Structure and union arguments can be passed to a function in either registers or on the stack. The size and type of the structure or union determine how it is passed. If a structure or union is larger than 16 bytes, it is passed to the function in memory.
To determine whether a 16-byte or smaller structure or union can be passed to a function in one or two registers, examine the first eight bytes of the structure or union. The type or types of the structure or union’s fields making up these eight bytes determine how these eight bytes will be passed. If the eight bytes contain at least one integral type, the eight bytes will be passed in the first available general purpose register of the sequence %rdi, %rsi, %rdx, %rcx, %r8, %r9 even if non-integral types are also present in the eight bytes. If the eight bytes only contain floating point types, these eight bytes will be passed in the first available XMM register of the sequence from %xmm0 to %xmm7.
If the structure or union is larger than eight bytes but smaller than 17 bytes, examine the type or types of the fields making up the second eight bytes of the structure or union. If the eight bytes contain at least one integral type, the eight bytes will be passed in the next available general purpose register of the sequence %rdi, %rsi, %rdx, %rcx, %r8, %r9 even if non-integral types are also present in the eight bytes. If these eight bytes only contain floating point types, these eight bytes will be passed in the next available XMM register of the sequence from %xmm0 to %xmm7.
If the first or second eight bytes of the structure or union cannot be passed in a register for some reason, the entire structure or union must be passed in memory.
x86-64 Passing Arguments on the Stack
If there are arguments left after every argument register has been allocated, the remaining arguments are passed to the function on the stack. The unassigned arguments are pushed on the stack in reverse order, with the last argument pushed first.
x86-64 Parameter Passing
Table 17 shows the register allocation and stack frame offsets for the function declaration and call shown in the following example. Both table and example are adapted from System V Application Binary Interface: AMD64 Architecture Processor Supplement.
typedef struct {
int a, b;
double d;
}
structparam;
structparam s;
int e, f, g, h, i, j, k;
float flt;
double m, n;
extern void func(int e, int f, structparam s, int g, int h,
float flt, double m, double n, int i, int j, int k);
void func2()
{
func(e, f, s, g, h, flt, m, n, i, j, k);
}
General Purpose Registers |
Floating Point Registers |
Stack Frame Offset |
|---|---|---|
%rdi: e |
%xmm0: s.d |
0: j |
%rsi: f |
%xmm1: flt |
8: k |
%rdx: s.a,s.b |
%xmm2: m |
|
%rcx: g |
%xmm3: n |
|
%r8: h |
||
%r9: i |
x86-64 Implementing a Stack
In general, compilers and programmers must maintain a software stack. The stack pointer, register %rsp, is set by the operating system for the application when the program is started. The stack must grow downwards from high addresses.
A separate frame pointer enables calls to routines that change the stack pointer to allocate space on the stack at run-time (e.g. alloca). Some languages can also return values from a routine allocated on stack space below the original top-of-stack pointer. Such a routine prevents the calling function from using %rsp-relative addressing for values on the stack. If the compiler does not call routines that leave %rsp in an altered state when they return, a frame pointer is not needed and may not be used if the compiler option -Mnoframe is specified.
The stack must be kept aligned on 16-byte boundaries.
6.1.2. AArch64 Function Calling Sequence
This section describes where to find the standard function calling sequence, including the stack frame, register usage, and parameter passing, for AArch64 (Arm 64-bit) processor-based systems. It addresses these conventions for processors running Linux operating systems. The register conventions and calling conventions of AArch64 are different from those of x86-64, so the x86-64 function calling sequence in the previous section does not apply to AArch64 systems.
The Arm Application Binary Interface (ABI) documents define the function calling sequence for AArch64 systems that run Linux. This guide does not repeat that information. See these documents:
Procedure Call Standard for the Arm 64-bit Architecture (AArch64), which defines the register usage, the stack frame, and how parameters and results are passed.
System V ABI for the Arm 64-bit Architecture (AArch64), which defines the ABI for Linux systems.
The Application Binary Interface for the Arm Architecture repository, which has all of the Arm ABI documents.
6.1.3. Linux Fortran Supplement
Sections A2.4.1 through A2.4.4 of the ABI for Linux defines the Fortran supplement. The register usage conventions set forth in that document remain the same for Fortran.
Fortran Fundamental Types
Fortran Type |
Size (bytes) |
Alignment (bytes) |
|---|---|---|
INTEGER |
4 |
4 |
INTEGER*1 |
1 |
1 |
INTEGER*2 |
2 |
2 |
INTEGER*4 |
4 |
4 |
INTEGER*8 |
8 |
8 |
LOGICAL |
4 |
4 |
LOGICAL*1 |
1 |
1 |
LOGICAL*2 |
2 |
2 |
LOGICAL*4 |
4 |
4 |
LOGICAL*8 |
8 |
8 |
BYTE |
1 |
1 |
CHARACTER*n |
n |
1 |
REAL |
4 |
4 |
REAL*4 |
4 |
4 |
REAL*8 |
8 |
8 |
DOUBLE PRECISION |
8 |
8 |
COMPLEX |
8 |
4 |
COMPLEX*8 |
8 |
4 |
COMPLEX*16 |
16 |
8 |
DOUBLE COMPLEX |
16 |
8 |
A logical constant is one of:
.TRUE.
.FALSE.
In Beta NVFORTRAN, the logical constants .TRUE. and .FALSE. are the four-byte values 1 and 0 respectively, and a LOGICAL value that is not zero is .TRUE.
Note that the value of a character is not automatically NULL-terminated.
Naming Conventions
By default, all globally visible Fortran symbol names (external subroutines, functions, common blocks) are converted to lower-case. In addition, an underscore is appended to Fortran global names to distinguish the Fortran name space from the C/C++ name space.
The names of module procedures and module variables are generated by the compiler and are not meant to be referenced by name from C/C++. For example, the module procedure msub in module mod1 has the symbol name _QMmod1Pmsub, and the module variable mv has the symbol name _QMmod1Emv. To call a module procedure from C/C++, give it the BIND(C) attribute.
Argument Passing and Return Conventions
Arguments are passed by reference (i.e., the address of the argument is passed, rather than the argument itself). In contrast, C/C++ arguments are passed by value.
When passing an argument declared as Fortran type CHARACTER, an argument representing the length of the CHARACTER argument is also passed to the function. This length argument is a four-byte integer passed by value, and is passed at the end of the parameter list following the other formal arguments. A length argument is passed for each CHARACTER argument; the length arguments are passed in the same order as their respective CHARACTER arguments.
A Fortran function, returning a value of type CHARACTER, adds two arguments to the beginning of its argument list. The first additional argument is the address of the area created by the caller for the return value; the second additional argument is the length of the return value. If a Fortran function is declared to return a character value of constant length, for example CHARACTER*4 FUNCTION CHF(), the second extra parameter representing the length of the return value must still be supplied.
On Linux86-64 systems a Fortran COMPLEX function returns its value in registers: a single precision COMPLEX value in %xmm0, and a DOUBLE COMPLEX value in %xmm0 (real part) and %xmm1 (imaginary part). The caller does not pass an extra argument for the return value, so the first argument of the function is passed in %rdi.
Alternate return specifiers of a Fortran function are not passed as arguments by the caller. The alternate return function passes the appropriate return value back to the caller in %rax on Linux86-64.
The handling of the following Fortran 90 features is implementation-defined: internal procedures, pointer arguments, assumed-shape arguments, functions returning arrays, and functions returning derived types.
Inter-language Calling
Inter-language calling between Fortran and C/C++ is possible if function/subroutine parameters and return values match types.
If a C/C++ function returns a value, call it from Fortran as a function, otherwise, call it as a subroutine.
If a Fortran function has type CHARACTER, call it from C/C++ as a void function.
If a Fortran function has type COMPLEX or DOUBLE COMPLEX, call it from C/C++ as a function that returns
float complexordouble complex.If a Fortran subroutine has alternate returns, call it from C/C++ as a function returning int; the value of such a subroutine is the value of the integer expression specified in the alternate RETURN statement.
If a Fortran subroutine does not contain alternate returns, call it from C/C++ as a void function.
Fortran 2003 also provides a mechanism to support interoperability with C. This mechanism includes the ISO_C_BINDING intrinsic module, binding labels, and the BIND attribute.
Table 19 provides the C/C++ data type corresponding to each Fortran data type.
Fortran Type |
C/C++ Type |
Size (bytes) |
|---|---|---|
CHARACTER*n x |
char x[n] |
n |
REAL x |
float x |
4 |
REAL*4 x |
float x |
4 |
REAL*8 x |
double x |
8 |
DOUBLE PRECISION x |
double x |
8 |
INTEGER x |
int x |
4 |
INTEGER*1 x |
signed char x |
1 |
INTEGER*2 x |
short x |
2 |
INTEGER*4 x |
int x |
4 |
INTEGER*8 x |
long x, or long long x |
8 |
LOGICAL x |
int x |
4 |
LOGICAL*1 x |
char x |
1 |
LOGICAL*2 x |
short x |
2 |
LOGICAL*4 x |
int x |
4 |
LOGICAL*8 x |
long x, or long long x |
8 |
Fortran Type (lower case) |
C/C++ Type |
Size (bytes) |
|---|---|---|
complex x |
struct {float r,i;} x; float complex x; |
8 |
complex*8 x |
struct {float r,i;} x; float complex x; |
8 8 |
double complex x |
struct {double dr,di;} x; double complex x; |
16 16 |
complex *16 x |
struct {double dr,di;} x; double complex x; |
16 16 |
Note
For C/C++, the complex type implies C99 or later.
Arrays
C/C++ arrays and Fortran arrays use different default initial array index values. By default, C/C++ arrays start at 0 and Fortran arrays start at 1. A Fortran array can be declared to start at zero.
Another difference between Fortran and C/C++ arrays is the storage method used. Fortran uses column-major order and C/C++ use row-major order. For one-dimensional arrays, this poses no problems. For two-dimensional arrays, where there are an equal number of rows and columns, row and column indexes can simply be reversed. Inter-language function mixing is not recommended for arrays other than single dimensional arrays and square two-dimensional arrays.
Structures, Unions, Maps, and Derived Types
Fields within Fortran structures and derived types conform to the same alignment requirements used by C structures.
Common Blocks
A named Fortran common block can be represented in C/C++ by a structure whose members correspond to the members of the common block. The name of the structure in C/C++ must have the added underscore.
For example, the Fortran common block:
INTEGER I, J
COMPLEX C
DOUBLE COMPLEX CD
DOUBLE PRECISION D
COMMON /COM/ i, j, c, cd, d
is represented in C with the following equivalent:
extern struct {
int i;
int j;
struct {float real, imag;} c;
struct {double real, imag;} cd;
double d;
} com_;
and in C++ with the following equivalent:
extern "C" struct {
int i;
int j;
struct {float real, imag;} c;
struct {double real, imag;} cd;
double d;
} com_;
Note
The compiler-provided name of the BLANK COMMON block is implementation specific.
Calling a Fortran CHARACTER function from C/C++ is not as straightforward as calling other types of Fortran functions. A Fortran CHARACTER function adds two arguments to the beginning of its argument list. The following example of calling a Fortran CHARACTER function from C/C++ illustrates these caller-provided extra parameters:
CHARACTER*(*) FUNCTION CHF(C1, I)
CHARACTER*(*) C1
INTEGER I
END
extern void chf_();
char tmp[10];
char c1[9];
int i;
chf_(tmp, 10, c1, &i, 9);
The extra parameters tmp and 10 are supplied for the return value, while 9 is supplied as the length of c1.
6.2. Environment Variables for Fortran Execution
The Fortran runtime library reads some environment variables when a program starts. This section describes the variables of the Beta NVFORTRAN runtime that are not described in the Environment Variables chapter of the User’s Guide. For the other variables that the runtime reads, such as FORT_CONVERT, FORT_CONVERT_UNIT, FORT_NO_EMPTY_ALLOCATION and NO_STOP_MESSAGE, see that chapter.
DEFAULT_UTF8Set
DEFAULT_UTF8=1to make formatted external input assume the UTF-8 encoding, and to make formatted external output use the UTF-8 encoding. For example, aKIND=1character with the code 233 is written to a formatted file as the two bytes 195 and 169.FORT_CHECK_POINTER_DEALLOCATIONFortran requires that a pointer that appears in a
DEALLOCATEstatement was allocated by anALLOCATEstatement with the same declared type. By default, the runtime library checks this requirement by checking the size of the allocated data, and the program stops with a fatal runtime error if the pointer is not valid. SetFORT_CHECK_POINTER_DEALLOCATION=0to disable this check.FORT_TRUNCATE_STREAMWhen output goes to a formatted unit with
ACCESS="STREAM"after the unit has been repositioned withPOS=to an earlier point in the file, the runtime library truncates the file at the end of the output. This is analogous to the implicit ENDFILE record that is written when output goes to a sequential unit after aBACKSPACEorREWINDstatement. Truncation is the default behavior. SetFORT_TRUNCATE_STREAM=0to turn it off, so that the data that follows the new output remains in the file.
The FORT_FMT_RECL environment variable sets the record length for list-directed and NAMELIST output. In Beta NVFORTRAN the default is 79.
Beta NVFORTRAN accepts -fconvert=<mode>, but it does not implement the option yet and it issues a warning. An explicit CONVERT= specifier in an OPEN statement takes precedence over the FORT_CONVERT environment variable.
For the differences from classic NVFORTRAN that matter when you mix object files and libraries from the two compilers, or when you port code between them, see the Porting Guide.
7. Compiler Directives
This chapter describes the non-standard directives that Beta NVFORTRAN accepts. A directive is a specially formed comment that gives the compiler additional information or instructions. The compiler ignores a directive that it does not support and issues the warning Unrecognized compiler directive was ignored.
7.1. Directive Sentinels
A directive begins with a sentinel:
!dir$is the sentinel in free form and in fixed form.cdir$and*dir$are also accepted in fixed form, in column 1.!pgi$is accepted as an alias for!dir$. A!pgi$directive with a scope letter, such as!pgi$gor!pgi$r, is ignored without a message.
Directive names are not case-sensitive.
7.2. Source Form Directives
!dir$ fixed,!dir$ freeSelect the fixed or free Fortran source form. The effect lasts until the end of the current source file.
7.3. Interface Directive: ignore_tkr
!dir$ ignore_tkr [[(letters)] dummy-arg-name]...Disables some semantic checks at call sites in an interface definition, for the actual arguments that correspond to the named dummy arguments. If no dummy argument name is given, the directive applies to all dummy arguments. The letters name the checks to disable. When no letters appear, the default is
A.Table 21 ignore_tkr letters Letter
Check that is ignored
TType
KKind
RRank
DCUDA
deviceattributeMCUDA managed or unified storage
AAll of
T,K,R,DandMCContiguity. The descriptor of the actual argument is passed as it is, even if attributes such as
ALLOCATABLEorPOINTERdo not matchPPointer and allocatable matching. For example, an allocatable array can be passed to a dummy argument that is a pointer array, and vice versa
For example, this interface declares a utility that sets all the bytes of an argument of any type or rank to zero:
interface subroutine clear(arr, bytes) !dir$ ignore_tkr arr integer(1), intent(out) :: arr(bytes) end subroutine end interface
The
Mletter disables the matching of the CUDA storage (managed or unified) of the actual argument against the dummy argument. It is mainly useful in host modules that overload the same routine with a host-typed specific procedure and adevice-typed specific procedure. PlacingMon thedevice-typed dummy argument makes that specific procedure an overload discriminator.When you compile with
-gpu=mem:unifiedor-gpu=mem:managed, an actual argument without a CUDA attribute is normally allowed to match adevicedummy argument.Mon that dummy argument turns this off. An actual argument without a CUDA attribute then matches the host-typed specific procedure in the same generic interface, while an actual argument with thedevice,managedorunifiedattribute still matches thedevice-typed specific procedure. For example:interface compute module procedure compute_host module procedure compute_device end interface ... subroutine compute_host(alpha) real :: alpha end subroutine subroutine compute_device(alpha) real, device :: alpha !dir$ ignore_tkr(m) alpha end subroutine ... real :: a ! plain host scalar real, device :: d ! device scalar call compute(a) ! always matches compute_host call compute(d) ! always matches compute_device
Without
ignore_tkr(m)oncompute_device,call compute(a)compiled with-gpu=mem:unifiedresolves tocompute_device, because the matching rules letamatch the device dummy argument and rank it as a closer match than the host one. See the table “Attributed Argument Matching Distance Values” in the CUDA Fortran Programming Guide.With
ignore_tkr(R), an array actual argument cannot be passed to a dummy argument that is a scalar with theVALUEattribute, because a scalar with theVALUEattribute can be passed in a register. This example is an error:interface subroutine s(b) !dir$ ignore_tkr(r) b integer, value :: b end subroutine end interface integer :: a(5) call s(a) ! error
A scalar actual argument can be passed to such a dummy argument.
7.4. Loop Directives
A loop directive applies to the DO loop that follows it. These directives affect how the optimizer treats the loop. The optimizer treats them as requests and might not be able to apply one to a particular loop, in which case it can issue a warning.
!dir$ ivdepAsserts that the loop has no vector dependencies. The compiler can vectorize or parallelize the loop if its cost model chooses to do so. The directive does not force vectorization.
!dir$ vector always,!dir$ simdForce vectorization of the loop regardless of the cost model. The loop must still be vectorizable.
simdis an alternative spelling ofvector always. These directives work only on plainDOloops without labels.!dir$ vector vectorlength({fixed|scalable|<num>|<num>,fixed|<num>,scalable})Gives a hint about the desired vectorization factor.
fixedasks the compiler to prefer fixed-width vectorization.scalableasks it to prefer scalable vectorization, although it can choose fixed-width vectorization or none.<num>is an integer literal that the compiler should consider as the vectorization factor. This directive has the same limitations as!dir$ vector always.!dir$ novectorDisables vectorization of the loop.
!dir$ unroll [n]Asks the compiler to unroll the loop
ntimes. Ifnis0or1, the loop is not unrolled. Ifnis2or greater, the loop is unrolled exactlyntimes if possible. Ifnis omitted, the compiler tries to unroll the loop completely. The formsunroll=nandunroll(n)are not accepted; the compiler ignores them with the unrecognized directive warning.!dir$ nounrollDisables unrolling of the loop.
!dir$ unroll_and_jam [n]Asks the compiler to unroll the loop
ntimes and jam the copies into the inner loop. The directive must immediately precede the outer loop of a loop nest. Ifnis0or1, the loop is not unrolled. Ifnis omitted, the optimizer chooses the unrolling factor. When the optimizer cannot perform the transformation, it issues the warningloop not unroll-and-jammed.!dir$ nounroll_and_jamDisables unrolling and jamming of the loop.
!dir$ prefetch designator[, designator]...Asks the compiler to generate prefetch instructions for the memory references that the designators name. A designator can be a variable or an array reference.
!dir$ assume_aligned designator:alignmentIntended to tell the compiler to assume that the designator, a variable that can have array indices, has the given alignment, for example
A:64orB(1,1,1):128. The alignment must be a power of 2 no greater than 256. Beta NVFORTRAN currently recognizes this directive but ignores it, and issues the unrecognized directive warning.
7.4.1. Loop Directives with OpenMP and OpenACC
Support for loop directives on a loop that is also associated with an OpenACC construct is a work in progress. If a loop directive conflicts with an OpenACC directive, the OpenACC directive takes precedence. Loop directives on a loop that has an OpenMP construct are not applied yet.
When a loop directive and an OpenMP loop construct are on the same loop, put the loop directive before the OpenMP directive. Beta NVFORTRAN issues the warning Compiler directives are not allowed inside OpenMP loop constructs for a loop directive that follows the OpenMP directive.
7.5. Inlining Directives
!dir$ inlineAsks the compiler to inline the routines that are called. Put the directive before a call statement to apply it to the call, before a
DOloop to apply it to all the calls in the loop body, or before an assignment statement to apply it to all the function references in the statement.!dir$ forceinlineWorks like
inline, but forces the compiler to inline the call.!dir$ inlinealways [name]An alternative spelling of
forceinline. Put it before a call, or inside the function or subroutine that you want to be inlined.nameis optional and is used only inside a function or subroutine. For example:function test() !dir$ inlinealways test ... end function
!dir$ noinlineWorks like
inline, but prevents the compiler from inlining the call.
7.6. Placement of Directives
A directive that applies to a construct, such as a loop directive, must be followed by that construct. The compiler looks forward from the directive to the next statement that is not a directive, so more than one directive can apply to the same loop:
!dir$ vector always
!dir$ unroll 2
!dir$ ivdep
do i = 1, n
a(i) = a(i) * 2.0
end do
A loop directive that appears in the specification part of a program unit is applied to the loop that follows in the execution part.
Loop directives apply only to DO loops. They cannot be applied to array expressions.
For the differences from classic NVFORTRAN in the directives, see the Porting Guide.
8. Module Hashes
Beta NVFORTRAN uses module hashes to make sure that the module files (.mod files) in a project agree with each other throughout the build. A module hash is a value that the compiler computes from the contents of a module file. The compiler stores the hash in the file and uses it to check, at compile time, that every module file that a source file depends on is the one that it expects.
8.1. Why Module Hashes?
Fortran module files (.mod) store the information that other source files need when they use a module. If a module file is out of date, or is not compatible with the files that depend on it, because a dependency was changed and not recompiled, the result can be a subtle error that is hard to diagnose.
By default, each module file that Beta NVFORTRAN writes includes:
A distinct module hash that is derived from the contents of the module.
A list of the hashes of all the modules that the module uses (its dependencies).
The compiler uses these hashes to check, during compilation, that all the module dependencies match exactly before it proceeds. The hashes also let the compiler choose the right module file when the directories on the search path have more than one module file with the same name. Any change to the contents of a module file changes its hash. This protects you from errors that are caused by mismatched or outdated module files, and it helps you to diagnose build problems that involve several versions of the same module.
8.2. How Module Hashes Work: A Simple Example
These two source files define a module and a second module that uses it:
! module_a.F90
module module_a
implicit none
integer, parameter :: value_a = 10
contains
function get_value_a() result(val)
integer :: val
val = value_a
end function get_value_a
end module module_a
! module_b.F90
module module_b
use module_a
implicit none
contains
function compute_sum(x) result(res)
integer, intent(in) :: x
integer :: res
res = x + get_value_a()
end function compute_sum
end module module_b
When you compile them with nvfortran -c module_a.F90 module_b.F90, the compiler writes these .mod files, which contain the embedded hashes:
module_a.mod:
!mod$ v1 sum:27e1fa3ae95eae28
module module_a
integer(4),parameter::value_a=10_4
contains
function get_value_a() result(val)
integer(4)::val
end
end
module_b.mod:
!mod$ v1 sum:0d3113391053b563
!need$ 27e1fa3ae95eae28 n module_a
module module_b
use module_a,only:value_a
use module_a,only:get_value_a
contains
function compute_sum(x) result(res)
integer(4),intent(in)::x
integer(4)::res
end
end
Note these points about the module files:
The module file format is Fortran free-form source.
The first line,
!mod$ v1 sum:<hash>, contains the distinct hash of the module.The lines that follow the first line, with the format
!need$ <hash> <kind> <module_name>, give the exact hash that the module expects for each module that it uses. The<kind>isnfor a non-intrinsic module andifor an intrinsic module. For example, a module that usesiso_c_bindinghas a line such as!need$ cc29e3b807f9b623 i iso_c_binding.
In this example, the hash of module_a that module_b.mod expects matches the actual hash of module_a.mod, so the two files are consistent.
8.3. Detecting Module Mismatches
A build system that relies only on file timestamps can miss a change in a module interface. Module hashes give a verification that is based on the contents of the module file, so the compiler detects a stale or incompatible module file even when the file names or timestamps look consistent.
Suppose that you change module_a.F90 and recompile it, but you do not recompile module_b.F90. The hash of module_a is updated, but the hash of module_a that module_b.mod expects is not. The next compilation of a file that uses module_b detects the mismatch and gives an error such as:
module_b.mod:4:5: error: Cannot use module file for module 'module_a':
File is not the right module file for 'module_a': module_a.mod
This feedback tells you to recompile the modules that depend on the module that changed.
The module hash checks continue through the whole dependency tree, so they find inconsistencies even when many levels of modules separate the modules. A module hash error can name a module that the file you compile does not use directly, but depends on indirectly.
8.4. Hermetic Module Files
You might want to disable the module hash checks on the dependencies of a module, or to ship a library without all the modules that its modules depend on. For example:
To do administrative or continuous integration builds, in which frequent internal changes do not affect the external interface.
To ship precompiled libraries without all the internal implementation modules.
To avoid version conflicts when several libraries contain modules with the same name.
To disable the module hash checks and to embed the modules that a module depends on into the module file itself, Beta NVFORTRAN provides hermetic module files. A hermetic module file contains all the information that it needs, at the cost of a larger module file.
8.5. How to Create Hermetic Modules
Compile the module with the -fhermetic-module-files option:
nvfortran -c module_b.F90 -fhermetic-module-files
This generates a self-contained module_b.mod that embeds the information that it needs from the non-intrinsic module module_a.mod. The compiler does not check the hash of module_a when a file uses module_b.
This is the hermetic module_b.mod:
!mod$ v1 sum:85eb3c058637a431
module module_b
use module_a,only:value_a
use module_a,only:get_value_a
contains
function compute_sum(x) result(res)
integer(4),intent(in)::x
integer(4)::res
end
end
module module_a
integer(4),parameter::value_a=10_4
contains
function get_value_a() result(val)
integer(4)::val
end
end
Note these points:
The module hash of
module_bchanges, because the embedded information changes the contents of the module.module_b.modno longer has a!need$line formodule_a, so it does not require a matchingmodule_a.mod.You can change and recompile
module_a.F90without recompilingmodule_b.F90.A hermetic
module_b.moddoes not make the module files that depend on it hermetic.module_b.modhas a module hash, and the compiler checks that hash for the modules that usemodule_bunless they are also hermetic.
8.6. Converting Existing Modules to Hermetic
You might have .mod files that were not created as hermetic files, for example in an installed library that was compiled without -fhermetic-module-files. To make them hermetic after the fact, so that you avoid hash mismatch errors later, use these steps:
Copy the
.modfile to a.F90file:cp module_b.mod module_b-hold.F90
Compile the copy with the
-fsyntax-onlyand-fhermetic-module-filesoptions to regenerate the module file:nvfortran module_b-hold.F90 -fsyntax-only -fhermetic-module-files
This creates the hermetic version of the module, and it removes the dependency problems that the module hash checks report. You might see warnings during this conversion, such as Function result is never defined, because the module file has the interfaces of the procedures but not their bodies. You can ignore these warnings.
The conversion works on a .mod file that Beta NVFORTRAN wrote, because that file is Fortran source.
8.7. Summary
Feature |
Behavior |
|---|---|
Standard module files |
Contain distinct module hashes and dependency hashes. |
Module hash checks |
Compiler verifies dependency hashes match before compiling. |
Error on mismatch |
Compilation errors if dependencies are out of sync. |
Hermetic module files |
Self-contained modules that embed dependencies; disable hash checks on dependents. |
Use case for hermetic files |
Library distribution, administrative builds, or advanced use cases where internal dependency changes are isolated and understood. |
8.8. Additional Notes
Module hashes improve the correctness of a build of a complex Fortran project, because they find module files that are out of step with each other.
Hermetic module files give more flexibility at the cost of larger module files.
Always recompile the files that depend on a module after you modify the module, unless the dependents use hermetic module files.
You can convert the modules of an installed library that were compiled without
-fhermetic-module-filesto hermetic modules, to avoid hash mismatch errors with that library.
Beta NVFORTRAN gives the error 'module_a.mod' is not a module file for this compiler when it reads a .mod file that is not in its format. Compile all the files of a project, and the libraries that provide its modules, with the same compiler.
For the differences from classic NVFORTRAN in the module files and the module hashes, see the Porting Guide.
9. Messages
This chapter describes the messages that Beta NVFORTRAN produces: the diagnostic messages that the compiler issues while it compiles a program, the informational messages that report optimizations, and the error messages that the runtime library issues while a program runs.
Beta NVFORTRAN does not have a catalog of messages. The part of the compiler or of the runtime library that detects a condition issues the message for it, and the messages have no numbers. This chapter describes the forms that the messages take and how to control them. It does not list every message.
9.1. Diagnostic Messages
Diagnostic messages provide syntactic and semantic information about your source text. Syntactic information includes information such as syntax errors. Semantic information includes information such as the use of an undeclared name or an argument that does not match its dummy argument. Two parts of Beta NVFORTRAN issue diagnostic messages: the Fortran front end, and the driver, which is the nvfortran command.
9.1.1. Front-End Messages
The front end reports the file, the line and the column where it detects a condition, followed by the severity and the text of the message. It then shows the source line and marks the position or the range of the text that the message is about:
sem.f90:4:7: error: No explicit type declared for 'x'
i = x
^
The severity is one of these:
Severity |
Meaning |
|---|---|
|
The program is not valid. The compiler does not write an object file. |
|
The program is valid, but the compiler found something that is probably a mistake. |
|
The program uses an extension of the Fortran standard. The compiler issues these
messages only with |
A warning ends with the name of the warning in square brackets, for example [-Wignored-directive]. You can use the name to suppress the warning, as Controlling Diagnostics describes:
warn.f90:5:9: warning: Unrecognized compiler directive was ignored [-Wignored-directive]
!dir$ bogusdirective
^^^^^^^^^^^^^^^
A message can have more lines that give the reason for it or the place that it refers to. A line that starts with because: gives the reason. A line that starts with in the context: shows the construct that contains the text. A line that names a declaration shows where the name is declared:
two.f90:4:3: warning: If the procedure's interface were explicit, this reference would be in error [-Wknown-bad-implicit-interface]
call f(x)
^^^^^^^^^
two.f90:4:10: because: Actual argument type 'REAL(4)' is not compatible with dummy argument type 'INTEGER(4)'
call f(x)
^
oob.f90:3:3: warning: subscript 5 is greater than upper bound 3 for dimension 1 of array [-Wout-of-bounds-subscripts]
a(5) = 1
^^^^
oob.f90:2:14: Declaration of 'a'
integer :: a(3)
^
When the front end cannot scan or parse a file, the first line of the output names the file, and the message for the syntax error follows it:
could not scan syn.f90
syn.f90:3:7: error: Unmatched '('
i = (1 + 2
^
When the front end finds errors in the meaning of the program, it starts the output with a line that names the file. When it reports a warning as an error because you specified -Werror, it does the same:
error: Semantic errors in sem.f90
sem.f90:4:7: error: No explicit type declared for 'x'
i = x
^
The compiler stops with the exit status 2 when it issues an error. It stops with the exit status 0 when it issues only warnings.
9.1.2. Driver Messages
The driver issues messages about the command line, the files that you name and the tools that it starts. A driver message starts with nvfortran- and the severity:
Prefix |
Meaning |
|---|---|
|
The command line or a file is not valid. The driver stops with the exit status 1. |
|
The driver cannot continue. |
|
The driver continues, for example when it ignores an option that is not yet implemented. |
|
Information that you asked for, such as the list that |
For example:
nvfortran-Error-Unknown switch: -Xnosuch
nvfortran-Warning-No files to process
nvfortran-Warning-not yet implemented: -C
nvfortran-Fatal-Switch -Mcray must have a value
nvfortran-Error--march=bogus unknown; -march=help for list of supported processors
A message that is issued while the driver runs one of the tools has the form nvfortran: error: or nvfortran: warning::
nvfortran: warning: OpenMP target offload is not yet implemented
nvfortran: error: Compute capabilities less than 75 are not supported
When a source file does not exist, the front end reports it:
could not scan nosuchfile.f90
error: Source file 'nosuchfile.f90' was not found
9.1.3. Controlling Diagnostics
These options control which diagnostic messages the compiler displays and what it does with them.
Option |
Effect |
|---|---|
|
Do not display warnings. See -w. |
|
Do not display the warning that has the name |
|
Treat all warnings as errors. See -Werror. |
|
Stop after |
|
Warn on language extensions. See Standards Checking. |
|
Display messages at |
The option -Werror=<name>, which treats one warning as an error, is not accepted. The option -std=<standard> is accepted, but it is not yet implemented.
9.1.4. Standards Checking
The option -pedantic warns on language extensions. The compiler issues a portability message for each use of an extension of the Fortran standard, such as the TYPE*KIND syntax:
ext.f90:2:7: portability: nonstandard usage: TYPE*KIND syntax
real*8 x
^^^
ext.f90:2:3: in the context: intrinsic type spec
real*8 x
^
ext.f90:1:1: in the context: main program
program t
^
The option -Mstandard gives the same messages. A portability message is a warning. It does not stop the compilation, and the exit status is 0. Without -pedantic or -Mstandard, the compiler does not issue portability messages.
9.2. Informational Messages
The options -Minfo and -Mneginfo ask the compiler to report what it did and what it did not do when it optimized the program. See -Minfo for the keywords. Each remark starts with the name of a compiler pass in square brackets:
vec.f90:
main:
1, [inline] '_QQmain' inlined into 'main' with (cost=160, threshold=225) at callsite main:0:1;
_QQmain:
4, [loop-vectorize] vectorized loop (vectorization width: 8, interleaved count: 4)
[loop-unroll] unrolled vectorized loop by a factor of 4
[loop-unroll] completely unrolled vectorized epilogue loop with 1 iterations
The compiler displays the name of the source file, then the name of the program unit, and then the line number and the remarks for each line.
9.3. Run-time Error Messages
The runtime library issues a message when a program fails while it runs. The message starts with fatal Fortran runtime error, and it gives the file and the line of the statement that failed, and then the text of the error:
fatal Fortran runtime error(run1.f90:7): I/O error (errno=2): No such file or directory
fatal Fortran runtime error(run5.f90:3): Bad character 'a' in INTEGER input field
fatal Fortran runtime error(rt2.f90:8): End of file during input
After a message of this kind, the program stops with the exit status 134.
A statement that has an IOSTAT= specifier does not stop the program. The statement sets the specifier to a non-zero value, and the IOMSG= specifier receives the text of the message. For example, when OPEN cannot find a file, IOSTAT is 2 and IOMSG is No such file or directory. At the end of a file, IOSTAT is -1 and IOMSG is End of file during input.
The STOP and ERROR STOP statements write a message to the standard error. The exit status is the stop code, or 1 for an ERROR STOP that has no integer code:
Fortran STOP: code 3
Fortran ERROR STOP: fatal problem
When you compile with -Ktrap, and the program raises a floating-point exception that you selected, the system ends the program with the signal SIGFPE. The exit status is 136, and the program writes no message. When the environment variable NVCOMPILER_TERM is trace, the program writes the signal and a traceback:
Caught signal: Floating point exception(signum=8) Floating point divide by zero(si_code=3)
#0 0x00005643d2480c7b in _QQmain () at fpe.f90:7
The text of a run-time message comes from the runtime library. This chapter describes the form of the messages and does not list them.
For the differences from the messages of classic NVFORTRAN, see the Porting Guide.
Notices
Notice and Disclaimers
All information provided in this document is provided as-is, for your informational purposes only and is subject to change at any time without notice. Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing. To obtain the latest information, please contact your NVIDIA representative. Product or service performance varies by use, configuration and other factors. Your costs and results may vary. No product or component is absolutely secure. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, NVIDIA DISCLAIMS ALL WARRANTIES AND REPRESENTATIONS OF ANY KIND, WHETHER EXPRESS, IMPLIED OR STATUTORY, RELATING TO OR ARISING UNDER THIS DOCUMENT, INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF TITLE, NONINFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, USAGE OF TRADE AND COURSE OF DEALING. NVIDIA products are not intended or authorized for use as critical components in a system or application where the use of or failure of such system or application developed with products, technology, software or services provided by NVIDIA could result in injury, death or catastrophic damage.
Except for your permitted use of the information contained in this document, no license or right is granted by implication, estoppel or otherwise. If this document directly includes or links to third-party websites, products, services or information, please consult other sources to evaluate if and how to use that information since NVIDIA does not support, endorse or assume any responsibility for any third party offerings or its accuracy or usefulness.
TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL NVIDIA BE LIABLE FOR ANY (I) INDIRECT, PUNITIVE, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, OR (II) DAMAGES FOR THE (A) COST OF PROCURING SUBSTITUTE GOODS OR (B) LOSS OF PROFITS, REVENUES, USE, DATA OR GOODWILL ARISING OUT OF OR RELATED TO THIS DOCUMENT, WHETHER BASED ON BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY, OR OTHERWISE, AND EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND EVEN IF A PARTY’S REMEDIES FAIL THEIR ESSENTIAL PURPOSE. ADDITIONALLY, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, NVIDIA’S TOTAL CUMULATIVE AGGREGATE LIABILITY FOR ANY AND ALL LIABILITIES, OBLIGATIONS OR CLAIMS ARISING OUT OF OR RELATED TO THIS DOCUMENT WILL NOT EXCEED FIVE U.S. DOLLARS (US$5).
Statements in this document that refer to future plans or expectations are forward-looking statements. These statements are based on currently available information, beliefs, assumptions and involve many risks and uncertainties that could cause actual results to differ materially from those expressed or implied in these statements. For more information on the factors that could cause actual results to differ materially, see our most recent earnings release and SEC filings at NVIDIA Corporation SEC Filings.
© NVIDIA Corporation. All rights reserved. NVIDIA, the NVIDIA logo, and other NVIDIA marks are trademarks of NVIDIA Corporation or its affiliates. Other names and brands may be claimed as the property of others.
Trademarks
NVIDIA, the NVIDIA logo, CUDA, CUDA-X, GPUDirect, HPC SDK, NGC, NVIDIA Volta, NVIDIA DGX, NVIDIA Nsight, NVLink, NVSwitch, and Tesla are trademarks and/or registered trademarks of NVIDIA Corporation in the U.S. and other countries. Other company and product names may be trademarks of the respective companies with which they are associated.