Using and Porting GNU Fortran
Total Page:16
File Type:pdf, Size:1020Kb
Contributed by James Craig Burley ([email protected]). Inspired by a first pass at translating ‘g77-0.5.16/f/DOC’ that was contributed to Craig by David Ronis ([email protected]). Using and Porting GNU Fortran James Craig Burley Last updated 2004-03-21 for version GCC-3.4.6 For the GCC-3.4.6 Version* Published by the Free Software Foundation 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA Copyright c 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Free Software Founda- tion, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License” and “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 Introduction ...................................... 1 GNU GENERAL PUBLIC LICENSE .................... 3 GNU Free Documentation License ....................... 9 Contributors to GNU Fortran ......................... 17 Funding Free Software .............................. 19 1 Funding GNU Fortran ........................... 21 2 Getting Started................................ 23 3 What is GNU Fortran? .......................... 25 4 Compile Fortran, C, or Other Programs ............... 29 5 GNU Fortran Command Options .................... 31 6 News About GNU Fortran ........................ 55 7 User-visible Changes ............................ 75 8 The GNU Fortran Language ....................... 85 9 Other Dialects................................ 183 10 The GNU Fortran Compiler ...................... 197 11 Other Compilers .............................. 225 12 Other Languages .............................. 227 13 Debugging and Interfacing ....................... 231 14 Collected Fortran Wisdom ....................... 241 15 Known Causes of Trouble with GNU Fortran ........... 257 16 Open Questions ............................... 285 17 Reporting Bugs ............................... 287 18 How To Get Help with GNU Fortran ................ 291 19 Adding Options ............................... 293 20 Projects .................................... 295 21 Front End................................... 301 22 Diagnostics .................................. 325 Keyword Index .................................. 333 ii Using and Porting GNU Fortran iii Table of Contents Introduction .................................. 1 GNU GENERAL PUBLIC LICENSE .......... 3 Preamble ...................................................... 3 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION .................... 4 How to Apply These Terms to Your New Programs ............... 8 GNU Free Documentation License ............. 9 ADDENDUM: How to use this License for your documents ....... 15 Contributors to GNU Fortran ................ 17 Funding Free Software ....................... 19 1 Funding GNU Fortran .................... 21 2 Getting Started........................... 23 3 What is GNU Fortran? ................... 25 4 Compile Fortran, C, or Other Programs .... 29 5 GNU Fortran Command Options .......... 31 5.1 Option Summary ......................................... 31 5.2 Options Controlling the Kind of Output .................... 32 5.3 Shorthand Options ....................................... 34 5.4 Options Controlling Fortran Dialect........................ 35 5.5 Options to Request or Suppress Warnings .................. 40 5.6 Options for Debugging Your Program or GNU Fortran ...... 44 5.7 Options That Control Optimization ........................ 44 5.8 Options Controlling the Preprocessor ...................... 47 5.9 Options for Directory Search .............................. 47 5.10 Options for Code Generation Conventions ................. 48 5.11 Environment Variables Affecting GNU Fortran............. 53 6 News About GNU Fortran ................ 55 7 User-visible Changes ...................... 75 iv Using and Porting GNU Fortran 8 The GNU Fortran Language............... 85 8.1 Direction of Language Development ........................ 85 8.2 ANSI FORTRAN 77 Standard Support .................... 87 8.2.1 No Passing External Assumed-length ................ 87 8.2.2 No Passing Dummy Assumed-length ................. 87 8.2.3 No Pathological Implied-DO ........................ 87 8.2.4 No Useless Implied-DO ............................. 88 8.3 Conformance ............................................. 88 8.4 Notation Used in This Chapter ............................ 89 8.5 Fortran Terms and Concepts .............................. 90 8.5.1 Syntactic Items .................................... 90 8.5.2 Statements, Comments, and Lines ................... 90 8.5.3 Scope of Symbolic Names and Statement Labels ...... 91 8.6 Characters, Lines, and Execution Sequence ................. 91 8.6.1 GNU Fortran Character Set......................... 91 8.6.2 Lines .............................................. 92 8.6.3 Continuation Line .................................. 92 8.6.4 Statements ........................................ 93 8.6.5 Statement Labels................................... 93 8.6.6 Order of Statements and Lines ...................... 93 8.6.7 Including Source Text .............................. 94 8.6.8 Cpp-style directives ................................ 94 8.7 Data Types and Constants ................................ 95 8.7.1 Data Types ........................................ 96 8.7.1.1 Double Notation ............................. 96 8.7.1.2 Star Notation................................ 96 8.7.1.3 Kind Notation ............................... 97 8.7.2 Constants ........................................ 100 8.7.3 Integer Type ...................................... 101 8.7.4 Character Type ................................... 101 8.8 Expressions ............................................. 101 8.8.1 The %LOC() Construct ............................. 101 8.9 Specification Statements ................................. 102 8.9.1 NAMELIST Statement............................... 102 8.9.2 DOUBLE COMPLEX Statement ........................ 102 8.10 Control Statements ..................................... 103 8.10.1 DO WHILE ..................................... 103 8.10.2 END DO ........................................ 103 8.10.3 Construct Names................................. 103 8.10.4 The CYCLE and EXIT Statements .................. 103 8.11 Functions and Subroutines .............................. 104 8.11.1 The %VAL() Construct............................ 105 8.11.2 The %REF() Construct............................ 105 8.11.3 The %DESCR() Construct ......................... 106 8.11.4 Generics and Specifics ............................ 106 8.11.5 REAL() and AIMAG() of Complex .................. 109 8.11.6 CMPLX() of DOUBLE PRECISION .................... 110 8.11.7 MIL-STD 1753 Support .......................... 110 v 8.11.8 f77/f2c Intrinsics................................ 110 8.11.9 Table of Intrinsic Functions ....................... 111 8.11.9.1 Abort Intrinsic ............................ 111 8.11.9.2 Abs Intrinsic .............................. 112 8.11.9.3 Access Intrinsic ............................ 112 8.11.9.4 AChar Intrinsic ............................ 112 8.11.9.5 ACos Intrinsic ............................. 113 8.11.9.6 AdjustL Intrinsic .......................... 113 8.11.9.7 AdjustR Intrinsic .......................... 113 8.11.9.8 AImag Intrinsic ............................ 113 8.11.9.9 AInt Intrinsic.............................. 113 8.11.9.10 Alarm Intrinsic ........................... 114 8.11.9.11 All Intrinsic .............................. 114 8.11.9.12 Allocated Intrinsic ........................ 114 8.11.9.13 ALog Intrinsic ............................ 114 8.11.9.14 ALog10 Intrinsic .......................... 114 8.11.9.15 AMax0 Intrinsic .......................... 115 8.11.9.16 AMax1 Intrinsic .......................... 115 8.11.9.17 AMin0 Intrinsic........................... 115 8.11.9.18 AMin1 Intrinsic........................... 115 8.11.9.19 AMod Intrinsic ........................... 115 8.11.9.20 And Intrinsic ............................. 116 8.11.9.21 ANInt Intrinsic ........................... 116 8.11.9.22 Any Intrinsic ............................. 116 8.11.9.23 ASin Intrinsic ............................ 116 8.11.9.24 Associated Intrinsic ....................... 117 8.11.9.25 ATan Intrinsic ............................ 117 8.11.9.26 ATan2 Intrinsic ........................... 117 8.11.9.27 BesJ0 Intrinsic ........................... 117 8.11.9.28 BesJ1 Intrinsic ........................... 117 8.11.9.29 BesJN Intrinsic ........................... 118 8.11.9.30 BesY0 Intrinsic ........................... 118 8.11.9.31 BesY1 Intrinsic ........................... 118 8.11.9.32 BesYN Intrinsic .......................... 118 8.11.9.33 Bit Size Intrinsic ......................... 119 8.11.9.34 BTest Intrinsic ........................... 119 8.11.9.35 CAbs Intrinsic ............................ 119 8.11.9.36 CCos Intrinsic ............................ 119 8.11.9.37 Ceiling Intrinsic