Using GNU Fortran
Total Page:16
File Type:pdf, Size:1020Kb
Using GNU Fortran For gcc version 4.9.4 (GCC) The gfortran team Published by the Free Software Foundation 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA Copyright c 1999-2014 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being \Funding Free Software", the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents 1 Introduction ::::::::::::::::::::::::::::::::::::::::: 1 Invoking GNU Fortran 2 GNU Fortran Command Options :::::::::::::::::::::::: 7 3 Runtime: Influencing runtime behavior with environment variables ::::::::::::::::::::::::::::::::::::::::::: 27 Language Reference 4 Fortran 2003 and 2008 Status :::::::::::::::::::::::::: 33 5 Compiler Characteristics :::::::::::::::::::::::::::::: 37 6 Extensions :::::::::::::::::::::::::::::::::::::::::: 41 7 Mixed-Language Programming ::::::::::::::::::::::::: 53 8 Intrinsic Procedures :::::::::::::::::::::::::::::::::: 67 9 Intrinsic Modules ::::::::::::::::::::::::::::::::::: 219 Contributing ::::::::::::::::::::::::::::::::::::::::::: 225 GNU General Public License :::::::::::::::::::::::::::::: 229 GNU Free Documentation License ::::::::::::::::::::::::: 241 Funding Free Software ::::::::::::::::::::::::::::::::::: 249 Option Index :::::::::::::::::::::::::::::::::::::::::: 251 Keyword Index ::::::::::::::::::::::::::::::::::::::::: 253 iii Table of Contents 1 Introduction::::::::::::::::::::::::::::::::::::: 1 1.1 About GNU Fortran ::::::::::::::::::::::::::::::::::::::::::: 1 1.2 GNU Fortran and GCC :::::::::::::::::::::::::::::::::::::::: 2 1.3 Preprocessing and conditional compilation :::::::::::::::::::::: 2 1.4 GNU Fortran and G77 ::::::::::::::::::::::::::::::::::::::::: 3 1.5 Project Status ::::::::::::::::::::::::::::::::::::::::::::::::: 3 1.6 Standards :::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 1.6.1 Varying Length Character Strings ::::::::::::::::::::::::: 4 Part I: Invoking GNU Fortran :::::::::::::::::::: 5 2 GNU Fortran Command Options ::::::::::::: 7 2.1 Option summary ::::::::::::::::::::::::::::::::::::::::::::::: 7 2.2 Options controlling Fortran dialect ::::::::::::::::::::::::::::: 8 2.3 Enable and customize preprocessing ::::::::::::::::::::::::::: 11 2.4 Options to request or suppress errors and warnings :::::::::::: 14 2.5 Options for debugging your program or GNU Fortran:::::::::: 18 2.6 Options for directory search ::::::::::::::::::::::::::::::::::: 19 2.7 Influencing the linking step:::::::::::::::::::::::::::::::::::: 19 2.8 Influencing runtime behavior :::::::::::::::::::::::::::::::::: 19 2.9 Options for code generation conventions ::::::::::::::::::::::: 20 2.10 Environment variables affecting gfortran :::::::::::::::::::: 26 3 Runtime: Influencing runtime behavior with environment variables:::::::::::::::::::::::: 27 3.1 TMPDIR|Directory for scratch files :::::::::::::::::::::::::::: 27 3.2 GFORTRAN_STDIN_UNIT|Unit number for standard input :::::: 27 3.3 GFORTRAN_STDOUT_UNIT|Unit number for standard output :::: 27 3.4 GFORTRAN_STDERR_UNIT|Unit number for standard error:::::: 27 3.5 GFORTRAN_UNBUFFERED_ALL|Do not buffer I/O on all units:::: 27 3.6 GFORTRAN_UNBUFFERED_PRECONNECTED|Do not buffer I/O on preconnected units::::::::::::::::::::::::::::::::::::::::::::: 27 3.7 GFORTRAN_SHOW_LOCUS|Show location for runtime errors :::::: 27 3.8 GFORTRAN_OPTIONAL_PLUS|Print leading + where permitted :: 28 3.9 GFORTRAN_DEFAULT_RECL|Default record length for new files :: 28 3.10 GFORTRAN_LIST_SEPARATOR|Separator for list output :::::::: 28 3.11 GFORTRAN_CONVERT_UNIT|Set endianness for unformatted I/O ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 28 3.12 GFORTRAN_ERROR_BACKTRACE|Show backtrace on run-time errors ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 29 Part II: Language Reference ::::::::::::::::::::: 31 iv The GNU Fortran Compiler 4 Fortran 2003 and 2008 Status :::::::::::::::: 33 4.1 Fortran 2003 status ::::::::::::::::::::::::::::::::::::::::::: 33 4.2 Fortran 2008 status ::::::::::::::::::::::::::::::::::::::::::: 34 4.3 Technical Specification 29113 Status ::::::::::::::::::::::::::: 36 5 Compiler Characteristics ::::::::::::::::::::: 37 5.1 KIND Type Parameters ::::::::::::::::::::::::::::::::::::::: 37 5.2 Internal representation of LOGICAL variables ::::::::::::::::: 37 5.3 Thread-safety of the runtime library ::::::::::::::::::::::::::: 38 5.4 Data consistency and durability ::::::::::::::::::::::::::::::: 38 6 Extensions ::::::::::::::::::::::::::::::::::::: 41 6.1 Extensions implemented in GNU Fortran :::::::::::::::::::::: 41 6.1.1 Old-style kind specifications :::::::::::::::::::::::::::::: 41 6.1.2 Old-style variable initialization ::::::::::::::::::::::::::: 41 6.1.3 Extensions to namelist ::::::::::::::::::::::::::::::::::: 42 6.1.4 X format descriptor without count field ::::::::::::::::::: 43 6.1.5 Commas in FORMAT specifications ::::::::::::::::::::::::: 43 6.1.6 Missing period in FORMAT specifications ::::::::::::::::::: 43 6.1.7 I/O item lists :::::::::::::::::::::::::::::::::::::::::::: 43 6.1.8 Q exponent-letter ::::::::::::::::::::::::::::::::::::::::: 43 6.1.9 BOZ literal constants::::::::::::::::::::::::::::::::::::: 43 6.1.10 Real array indices ::::::::::::::::::::::::::::::::::::::: 44 6.1.11 Unary operators :::::::::::::::::::::::::::::::::::::::: 44 6.1.12 Implicitly convert LOGICAL and INTEGER values :::::::::: 44 6.1.13 Hollerith constants support:::::::::::::::::::::::::::::: 44 6.1.14 Cray pointers ::::::::::::::::::::::::::::::::::::::::::: 45 6.1.15 CONVERT specifier:::::::::::::::::::::::::::::::::::::::: 47 6.1.16 OpenMP:::::::::::::::::::::::::::::::::::::::::::::::: 47 6.1.17 Argument list functions %VAL, %REF and %LOC :::::::::::: 48 6.2 Extensions not implemented in GNU Fortran :::::::::::::::::: 49 6.2.1 STRUCTURE and RECORD ::::::::::::::::::::::::::::::::::: 49 6.2.2 ENCODE and DECODE statements ::::::::::::::::::::::::::: 50 6.2.3 Variable FORMAT expressions :::::::::::::::::::::::::::::: 51 6.2.4 Alternate complex function syntax:::::::::::::::::::::::: 51 6.2.5 Volatile COMMON blocks:::::::::::::::::::::::::::::::::::: 51 7 Mixed-Language Programming::::::::::::::: 53 7.1 Interoperability with C :::::::::::::::::::::::::::::::::::::::: 53 7.1.1 Intrinsic Types ::::::::::::::::::::::::::::::::::::::::::: 53 7.1.2 Derived Types and struct::::::::::::::::::::::::::::::::: 53 7.1.3 Interoperable Global Variables:::::::::::::::::::::::::::: 54 7.1.4 Interoperable Subroutines and Functions:::::::::::::::::: 54 7.1.5 Working with Pointers ::::::::::::::::::::::::::::::::::: 56 7.1.6 Further Interoperability of Fortran with C :::::::::::::::: 58 7.2 GNU Fortran Compiler Directives ::::::::::::::::::::::::::::: 59 7.3 Non-Fortran Main Program ::::::::::::::::::::::::::::::::::: 60 v 7.3.1 _gfortran_set_args | Save command-line arguments ::: 60 7.3.2 _gfortran_set_options | Set library option flags::::::: 61 7.3.3 _gfortran_set_convert | Set endian conversion :::::::: 62 7.3.4 _gfortran_set_record_marker | Set length of record markers :::::::::::::::::::::::::::::::::::::::::::::::::::: 62 7.3.5 _gfortran_set_fpe | Enable floating point exception traps :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 63 7.3.6 _gfortran_set_max_subrecord_length | Set subrecord length :::::::::::::::::::::::::::::::::::::::::::::::::::::: 63 7.4 Naming and argument-passing conventions :::::::::::::::::::: 63 7.4.1 Naming conventions :::::::::::::::::::::::::::::::::::::: 64 7.4.2 Argument passing conventions :::::::::::::::::::::::::::: 64 8 Intrinsic Procedures::::::::::::::::::::::::::: 67 8.1 Introduction to intrinsic procedures ::::::::::::::::::::::::::: 67 8.2 ABORT | Abort the program :::::::::::::::::::::::::::::::::: 67 8.3 ABS | Absolute value ::::::::::::::::::::::::::::::::::::::::: 68 8.4 ACCESS | Checks file access modes:::::::::::::::::::::::::::: 68 8.5 ACHAR | Character in ASCII collating sequence:::::::::::::::: 69 8.6 ACOS | Arccosine function :::::::::::::::::::::::::::::::::::: 70 8.7 ACOSH | Inverse hyperbolic cosine function:::::::::::::::::::: 70 8.8 ADJUSTL | Left adjust a string ::::::::::::::::::::::::::::::: 71 8.9 ADJUSTR | Right adjust a string :::::::::::::::::::::::::::::: 71 8.10 AIMAG | Imaginary part of complex number ::::::::::::::::: 72 8.11 AINT | Truncate to a whole number ::::::::::::::::::::::::: 73 8.12 ALARM | Execute a routine after a given delay ::::::::::::::: 73 8.13 ALL | All values in MASK along DIM are true :::::::::::::: 74 8.14 ALLOCATED | Status of an allocatable entity ::::::::::::::::: 75 8.15 AND | Bitwise logical AND :::::::::::::::::::::::::::::::::: 75 8.16 ANINT | Nearest whole number :::::::::::::::::::::::::::::: 76 8.17 ANY | Any value in MASK along DIM is true ::::::::::::::: 77 8.18 ASIN | Arcsine function ::::::::::::::::::::::::::::::::::::: 78 8.19 ASINH | Inverse hyperbolic sine function::::::::::::::::::::: 78 8.20 ASSOCIATED | Status of a pointer or pointer/target pair ::::: 79 8.21 ATAN | Arctangent