Using GNU Fortran (Gfortran.Pdf)

Total Page:16

File Type:pdf, Size:1020Kb

Using GNU Fortran (Gfortran.Pdf) Using GNU Fortran For gcc version 4.8.0 (pre-release) (GCC) The gfortran team Published by the Free Software Foundation 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA Copyright c 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 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 .................................. 63 9 Intrinsic Modules ................................... 213 Contributing ........................................... 217 GNU General Public License .............................. 221 GNU Free Documentation License ......................... 233 Funding Free Software ................................... 241 Option Index .......................................... 243 Keyword Index ......................................... 245 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.......... 17 2.6 Options for directory search ................................... 18 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 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 ................................... 55 7.1.6 Further Interoperability of Fortran with C ................ 57 7.2 GNU Fortran Compiler Directives ............................. 58 7.3 Non-Fortran Main Program ................................... 58 7.3.1 _gfortran_set_args — Save command-line arguments ... 59 v 7.3.2 _gfortran_set_options — Set library option flags....... 59 7.3.3 _gfortran_set_convert — Set endian conversion ........ 60 7.3.4 _gfortran_set_record_marker — Set length of record markers .................................................... 61 7.3.5 _gfortran_set_fpe — Enable floating point exception traps ............................................................ 61 7.3.6 _gfortran_set_max_subrecord_length — Set subrecord length ...................................................... 61 8 Intrinsic Procedures........................... 63 8.1 Introduction to intrinsic procedures ........................... 63 8.2 ABORT — Abort the program .................................. 63 8.3 ABS — Absolute value ......................................... 64 8.4 ACCESS — Checks file access modes............................ 64 8.5 ACHAR — Character in ASCII collating sequence................ 65 8.6 ACOS — Arccosine function .................................... 66 8.7 ACOSH — Inverse hyperbolic cosine function.................... 66 8.8 ADJUSTL — Left adjust a string ............................... 67 8.9 ADJUSTR — Right adjust a string .............................. 67 8.10 AIMAG — Imaginary part of complex number ................. 68 8.11 AINT — Truncate to a whole number ......................... 69 8.12 ALARM — Execute a routine after a given delay ............... 69 8.13 ALL — All values in MASK along DIM are true .............. 70 8.14 ALLOCATED — Status of an allocatable entity ................. 71 8.15 AND — Bitwise logical AND .................................. 71 8.16 ANINT — Nearest whole number .............................. 72 8.17 ANY — Any value in MASK along DIM is true ............... 73 8.18 ASIN — Arcsine function ..................................... 74 8.19 ASINH — Inverse hyperbolic sine function..................... 74 8.20 ASSOCIATED — Status of a pointer or pointer/target pair ..... 75 8.21 ATAN — Arctangent function ................................. 76 8.22 ATAN2 — Arctangent function ................................ 77 8.23 ATANH — Inverse hyperbolic tangent function ................
Recommended publications
  • Fortran Reference Guide
    FORTRAN REFERENCE GUIDE Version 2018 TABLE OF CONTENTS Preface............................................................................................................ xv Audience Description......................................................................................... xv Compatibility and Conformance to Standards............................................................ xv Organization................................................................................................... xvi Hardware and Software Constraints...................................................................... xvii Conventions................................................................................................... xvii Related Publications........................................................................................ xviii Chapter 1. Language Overview............................................................................... 1 1.1. Elements of a Fortran Program Unit.................................................................. 1 1.1.1. Fortran Statements................................................................................. 1 1.1.2. Free and Fixed Source............................................................................. 2 1.1.3. Statement Ordering................................................................................. 2 1.2. The Fortran Character Set.............................................................................. 3 1.3. Free Form Formatting..................................................................................
    [Show full text]
  • SPSS to Orthosim File Conversion Utility Helpfile V.1.4
    SPSS to Orthosim File Conversion Utility Helpfile v.1.4 Paul Barrett Advanced Projects R&D Ltd. Auckland New Zealand email: [email protected] Web: www.pbarrett.net 30th December, 2019 Contents 3 Table of Contents Part I Introduction 5 1 Installation Details ................................................................................................................................... 7 2 Extracting Matrices from SPSS - Cut and Paste ................................................................................................................................... 8 3 Extracting Matrices from SPSS: Orthogonal Factors - E.x..c..e..l. .E..x..p..o..r.t................................................................................................................. 17 4 Extracting Matrices from SPSS: Oblique Factors - Exce.l. .E..x..p..o..r..t...................................................................................................................... 24 5 Creating Orthogonal Factor Orthosim Files ................................................................................................................................... 32 6 Creating Oblique Factor Orthosim Files ................................................................................................................................... 41 3 Paul Barrett Part I 6 SPSS to Orthosim File Conversion Utility Helpfile v.1.4 1 Introduction SPSS-to-Orthosim converts SPSS 11/12/13/14 factor loading and factor correlation matrices into the fixed-format .vf (simple ASCII text) files
    [Show full text]
  • Lexical Analysis with Flex Edition 2.5.35, 8 February 2013
    Lexical Analysis with Flex Edition 2.5.35, 8 February 2013 Vern Paxson, Will Estes and John Millaway The flex manual is placed under the same licensing conditions as the rest of flex: Copyright c 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 The Flex Project. Copyright c 1990, 1997 The Regents of the University of California. All rights reserved. This code is derived from software contributed to Berkeley by Vern Paxson. The United States Government has rights in this work pursuant to contract no. DE- AC03-76SF00098 between the United States Department of Energy and the University of California. Redistribution and use in source and binary forms, with or without modification, are per- mitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of con- ditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IM- PLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WAR- RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. i Table of Contents 1 Copyright ................................. 1 2 Reporting Bugs............................ 2 3 Introduction ............................... 3 4 Some Simple Examples..................... 4 5 Format of the Input File ................... 6 5.1 Format of the Definitions Section ............................
    [Show full text]
  • Comparative Studies of Programming Languages; Course Lecture Notes
    Comparative Studies of Programming Languages, COMP6411 Lecture Notes, Revision 1.9 Joey Paquet Serguei A. Mokhov (Eds.) August 5, 2010 arXiv:1007.2123v6 [cs.PL] 4 Aug 2010 2 Preface Lecture notes for the Comparative Studies of Programming Languages course, COMP6411, taught at the Department of Computer Science and Software Engineering, Faculty of Engineering and Computer Science, Concordia University, Montreal, QC, Canada. These notes include a compiled book of primarily related articles from the Wikipedia, the Free Encyclopedia [24], as well as Comparative Programming Languages book [7] and other resources, including our own. The original notes were compiled by Dr. Paquet [14] 3 4 Contents 1 Brief History and Genealogy of Programming Languages 7 1.1 Introduction . 7 1.1.1 Subreferences . 7 1.2 History . 7 1.2.1 Pre-computer era . 7 1.2.2 Subreferences . 8 1.2.3 Early computer era . 8 1.2.4 Subreferences . 8 1.2.5 Modern/Structured programming languages . 9 1.3 References . 19 2 Programming Paradigms 21 2.1 Introduction . 21 2.2 History . 21 2.2.1 Low-level: binary, assembly . 21 2.2.2 Procedural programming . 22 2.2.3 Object-oriented programming . 23 2.2.4 Declarative programming . 27 3 Program Evaluation 33 3.1 Program analysis and translation phases . 33 3.1.1 Front end . 33 3.1.2 Back end . 34 3.2 Compilation vs. interpretation . 34 3.2.1 Compilation . 34 3.2.2 Interpretation . 36 3.2.3 Subreferences . 37 3.3 Type System . 38 3.3.1 Type checking . 38 3.4 Memory management .
    [Show full text]
  • ILE C/C++ Programmer's Guide
    IBM i 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Programmer's Guide IBM SC09-2712-07 Note Before using this information and the product it supports, read the information in “Notices” on page 441. This edition applies to version 7, release 2, modification 0 of IBM Rational Development Studio for i (product number 5770-WDS) and to all subsequent releases and modifications until otherwise indicated in new editions. This version does not run on all reduced instruction set computer (RISC) models nor does it run on CISC models. This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is licensed to you under the terms of the IBM License Agreement for Machine Code. © Copyright International Business Machines Corporation 1993, 2013. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents ILE C/C++ Programmer’s Guide..............................................................................1 PDF file for ILE C/C++ Programmer’s Guide............................................................................................... 3 About ILE C/C++ Programmer's Guide........................................................................................................5 Install Licensed Program Information................................................................................................... 5 Notes About Examples..........................................................................................................................
    [Show full text]
  • Developing Embedded SQL Applications
    IBM DB2 10.1 for Linux, UNIX, and Windows Developing Embedded SQL Applications SC27-3874-00 IBM DB2 10.1 for Linux, UNIX, and Windows Developing Embedded SQL Applications SC27-3874-00 Note Before using this information and the product it supports, read the general information under Appendix B, “Notices,” on page 209. Edition Notice This document contains proprietary information of IBM. It is provided under a license agreement and is protected by copyright law. The information contained in this publication does not include any product warranties, and any statements provided in this manual should not be interpreted as such. You can order IBM publications online or through your local IBM representative. v To order publications online, go to the IBM Publications Center at http://www.ibm.com/shop/publications/ order v To find your local IBM representative, go to the IBM Directory of Worldwide Contacts at http://www.ibm.com/ planetwide/ To order DB2 publications from DB2 Marketing and Sales in the United States or Canada, call 1-800-IBM-4YOU (426-4968). When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright IBM Corporation 1993, 2012. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Chapter 1. Introduction to embedded Include files for COBOL embedded SQL SQL................1 applications .............29 Embedding SQL statements
    [Show full text]
  • The UCSD P-System STATUT ORIL Y EX E:M PT
    DOCfi!D(ov~ by NSA on 12-01-2011, Transparency Case# 5335]UNCLASSIFIED The UCSD p-System STATUT ORIL Y EX E:M PT This paper discusses the UCSD p-System, an operating system for small computers developed at the University of California at San Diego. The discussion includes the overall system, file managing, editing, and programming in Pascal on the system. INTRODUCTION The UCSD p-System was developed at the University of California at San Diego to support Pascal programming on microcomputers. Similar to MS-DOS, the p-System is an operating system for small computers but is, in many ways, very different. The p-System is written in Pascal and now supports not only Pascal, but also FORTRAN, COBOL, BASIC, and Modula-2. The concept was to have an operating system that, once it was implemented on a machine, allowed any program written under that operating system to be truly transportable from computer to computer. That is to say, the p-System compiler would not actually translate the program into a language that was specific for, say, an 8088 chip on the IBM-PC, but rather would translate it into a "pseudo" language that, when used with an operating system designed for the PC, would run correctly. Similarly, if the operating system were implemented on a Digital Equipment Corporation (DEC) computer, this same pseudo code would still work properly with no modifications. The particular version of UCSD p-System tested was written for the IBM-PC and requires two single-sided double-density disk drives and at least 128K of memory.
    [Show full text]
  • A FORTRAN 77 Program for a Nonparametric Item Response Model: the Mokken Scale Analysis
    BehaviorResearch Methods, Instruments, & Computers 1988, 20 (5), 471-480 A FORTRAN 77 program for a nonparametric item response model: The Mokken scale analysis JOHANNES KINGMA University of Utah, Salt Lake City, Utah and TERRY TAERUM University ofAlberta, Edmonton, Alberta, Canada A nonparametric item response theory model-the Mokken scale analysis (a stochastic elabo­ ration of the deterministic Guttman scale}-and a computer program that performs this analysis are described. Three procedures of scaling are distinguished: a search procedure, an evaluation of the whole set of items, and an extension of an existing scale. All procedures provide a coeffi­ cient of scalability for all items that meet the criteria of the Mokken model and an item coeffi­ cient of scalability for every item. Four different types of reliability coefficient are computed both for the entire set of items and for the scalable items. A test of robustness of the found scale can be performed to analyze whether the scale is invariant across different subgroups or samples. This robustness test serves as a goodness offit test for the established scale. The program is writ­ ten in FORTRAN 77. Two versions are available, an SPSS-X procedure program (which can be used with the SPSS-X mainframe package) and a stand-alone program suitable for both main­ frame and microcomputers. The Mokken scale model is a stochastic elaboration of which both mainframe and MS-DOS versions are avail­ the well-known deterministic Guttman scale (Mokken, able. These programs, both named Mokscal, perform the 1971; Mokken & Lewis, 1982; Mokken, Lewis, & Mokken scale analysis. Before presenting a review of the Sytsma, 1986).
    [Show full text]
  • CALI Round 03.Pdf
    California Academic Learning Initiative 2015 - 2016 Round 3 Written by Ankit Aggarwal, Hidehiro Anto, P.C. Chauhan, Jason Cheng, Boyang Jiao, Aseem Keyal, Eddie Kim, Bruce Lou, Charlie Mann, Kevin Wang, Corry Wang, Kion You TOSSUPS 1. T he Supreme Court has decided that tailored use of this practice is permissible for achieving so-called "critical mass," although Sandra Day O'Connor wrote that this practice would no longer be necessary in 25 years. In 2003 the Supreme Court ruled against a point-based version of this practice in G ratz v. Bollinger. In June 2015 the court agreed to rehear the case (*) Fisher v. Texas challenging this practice. In 1978 quota-based versions of this practice were ruled unconstitutional in B akke v. Regents of the University of California . For 10 points, name this practice of giving preference to historically disadvantaged racial minorities. ANSWER: affirmative action in the college admissions process [accept positive discrimination; prompt on "reverse discrimination" or "discrimination"] 2. A leader criticized this religion's contradictions in his essay Against the Galileans during the 4th century. According to legend, one of this religion's major holidays was specifically scheduled to upstage a festival led by the Sol Invictus cult. Julian the Apostate attempted to roll back the spread of this religion, whose members were systematically persecuted by (*) D iocletian ( "DIE"-oh-klee-shun). It was granted toleration in the Edict of Milan by Constantine the Great, who became the first Roman emperor to convert to it. For 10 points, Pontius Pilate crucified the founder of what religion? ANSWER: Christianity [accept specific forms of Christianity] 3.
    [Show full text]
  • C Programming and Data Structures May/June 2007
    C Programming and Data Structures May/June 2007 SET-2 1. (a) What is a string constant? How do string constants differ from character constants? Do string constants represent numerical values? A string constant is a sequence of characters enclosed in double quotes. The characters may be letters, numbers, special characters and blank spaces. Example: hai , 1982, etc; A character constant is not equivalent to the single character constant. A single character string constant does not have an equivalent integer whereas a character constant has an integer value (ASCII value). String constants do not represent equivalent numerical values. (b) Summarize the standard escape sequences in C. Describe them. Black slash characters are also called escape sequences. Constant Meaning \a Audible alert(bell) \b Back space \f Form feed \n New line \r Carriage return \t Tab space \v Vertical tab \ Single quote \ Double quote \? Question mark \\ Back slash \0 Null (c) What is a variable? How can variables be characterized? Give the rules for variable declaration. A variable is a data name that may be used to store a data value. A variable may take different values at different times during execution. Variables are characterized based on the value they hold. Depending on that they are classified into int, float, char, double, and so on. Rules for variable declaration: · They must begin with a letter. Some compilers permit underscore as the first character. · ANSI standard recognizes a length of 31 characters. However, the length should not be normally more than eight characters. Appendix-C.p65 12 7/29/08, 5:21 PM Solved Question Papers C.13 · Uppercase and lowercase are significant.
    [Show full text]
  • A Modular Structured Approach Using C++ © Kenneth Leroy Busbee
    Programming Fundamentals -A Modular Structured Approach using C++ © Kenneth Leroy Busbee This work is licensed under a Creative Commons-ShareAlike 4.0 International License Original source: Multimedia Educational Resource for Learning and Online Teaching http://www.merlot.org/merlot/viewMaterial.htm?id=515164 Contents Preface .............................................................................................................................1 Orientation and Syllabus ...............................................................................................2 Chapter 1 Introduction to Programming ....................................................................4 1.1 Systems Development Life Cycle .....................................................................................4 1.1.1 Discussion ................................................................................................................4 1.1.2 Definitions ...............................................................................................................5 1.2 Bloodshed Dev-C++ 5 Compiler/IDE ................................................................................6 1.2.1 Introduction ............................................................................................................6 1.2.2 Bloodshed Dev-C++ 5 compiler/IDE .....................................................................6 1.2.3 Preparation before Installation ............................................................................7 1.2.3.1 Creating the
    [Show full text]
  • Introduction to Programming with C-19CSE23 Module 1
    Introduction to programming with C-19CSE23 Module 1 Hardware Components Processor, memoryand Input/Output devices, are the important components of adigital computer. Processor will have ALU (Arithmetic Logic Unit) and Control Unit(CU) as its components. Memory can be subdivided into primary and secondary memory. Input devices accept data and control signals from the user. Examples of input devices are keyboard, mouse, pen based systems, data scanners, game controllers, voice recognition systems etc. Output devices communicate the processed data to the user. Examples of output devices are Monitor, Printer, Plotter, sound system etc. Processor Central Processing Unit (CPU) -It is the brain of the computer. It performs the bulk ofthe data processing operations. The function of the processor is to fetch the instructionfrom memory, examine (decode) the instruction and execute the instructions. It consists of Control unit, Arithmetic Logic Unit (ALU) and registers. Control unit is responsible for fetching the instructions from memory and interpreting them. ALU performs arithmetic and logical operations. Registers are very high speed memory unitsfor storing very small amount of data. Program counter, Instruction register, Memoryaddress register, memory buffer register and accumulator are some examples of registers.Bus is a collection of wires. They may be unidirectional or bidirectional. Bus is usedto connect different parts of a computer. Bus may be serial or parallel. USB is anexample of a serial bus. Bus connecting computer and a dot matrix printer is normallya parallel bus. Parallel bus carries several bits at a time. These bits may indicateinstruction, data, address or commands. Bus width and Bus speed are the two major components for performance measure of a computer.
    [Show full text]