⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gfortran.texi

📁 gcc-fortran,linux使用fortran的编译软件。很好用的。
💻 TEXI
📖 第 1 页 / 共 3 页
字号:
\input texinfo  @c -*-texinfo-*-@c %**start of header@setfilename gfortran.info@set copyrights-gfortran 1999-2005@include gcc-common.texi@settitle The GNU Fortran 95 Compiler@c Create a separate index for command line options@defcodeindex op@c Merge the standard indexes into a single one.@syncodeindex fn cp@syncodeindex vr cp@syncodeindex ky cp@syncodeindex pg cp@syncodeindex tp cp@c %**end of header@c Use with @@smallbook.@c %** start of document@c Cause even numbered pages to be printed on the left hand side of@c the page and odd numbered pages to be printed on the right hand@c side of the page.  Using this, you can print on both sides of a@c sheet of paper and have the text on the same part of the sheet.@c The text on right hand pages is pushed towards the right hand@c margin and the text on left hand pages is pushed toward the left@c hand margin.@c (To provide the reverse effect, set bindingoffset to -0.75in.)@c @tex@c \global\bindingoffset=0.75in@c \global\normaloffset =0.75in@c @end tex@copyingCopyright @copyright{} @value{copyrights-gfortran} Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1 orany later version published by the Free Software Foundation; with theInvariant Sections being ``GNU General Public License'' and ``FundingFree Software'', the Front-Covertexts 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.@end copying@ifinfo@dircategory Programming@direntry* gfortran: (gfortran).                  The GNU Fortran 95 Compiler.@end direntryThis file documents the use and the internals ofthe GNU Fortran 95 compiler, (@command{gfortran}).Published by the Free Software Foundation51 Franklin Street, Fifth FloorBoston, MA 02110-1301 USA@insertcopying@end ifinfo@setchapternewpage odd@titlepage@title Using GNU Fortran 95@sp 2@center The gfortran team@page@vskip 0pt plus 1filllFor the @value{version-GCC} Version*@sp 1Published by the Free Software Foundation @*51 Franklin Street, Fifth Floor@*Boston, MA 02110-1301, USA@*@c Last printed ??ber, 19??.@*@c Printed copies are available for $? each.@*@c ISBN ???@sp 1@insertcopying@end titlepage@summarycontents@contents@page@node Top@top Introduction@cindex IntroductionThis manual documents the use of @command{gfortran}, the GNU Fortran 95 compiler. You can find in this manual how to invoke@command{gfortran}, as well as its features and incompatibilities.@ifset DEVELOPMENT@emph{Warning:} This document, and the compiler it describes, are stillunder development.  While efforts are made to keep it up-to-date, it mightnot accurately reflect the status of the most recent @command{gfortran}.@end ifset@comment@comment  When you add a new menu item, please keep the right hand@comment  aligned to the same column.  Do not use tabs.  This provides@comment  better formatting.@comment@menu* Getting Started::      What you should know about @command{gfortran}.* GFORTRAN and GCC::     You can compile Fortran, C, or other programs.* GFORTRAN and G77::     Why we chose to start from scratch.* Invoking GFORTRAN::    Command options supported by @command{gfortran}.* Project Status::       Status of @command{gfortran}, roadmap, proposed extensions.* Contributing::         How you can help.* Standards::	         Standards supported by @command{gfortran}* Runtime::              Influencing runtime behavior with environment variables.* Extensions::           Language extensions implemented by @command{gfortran}* Intrinsic Procedures:: Intrinsic procedures supported by @command{gfortran}* Copying::              GNU General Public License says                         how you can copy and share GNU Fortran.* GNU Free Documentation License::		         How you can copy and share this manual.* Funding::              How to help assure continued work for free software.* Index::                Index of this documentation.@end menu@c ---------------------------------------------------------------------@c Getting Started@c ---------------------------------------------------------------------@node Getting Started@chapter Getting StartedGfortran is the GNU Fortran 95 compiler front end,designed initially as a free replacement for,or alternative to, the unix @command{f95} command;@command{gfortran} is the command you'll use to invoke the compiler.Gfortran is still in an early state of development.@command{gfortran} can generate code for most constructs and expressions,but much work remains to be done.When @command{gfortran} is finished,it will do everything you expect from any decent compiler: @itemize @bullet@itemRead a user's program,stored in a file and containing instructions writtenin Fortran 77, Fortran 90 or Fortran 95.This file contains @dfn{source code}.@itemTranslate the user's program into instructions a computercan carry out more quickly than it takes to translate theinstructions in the firstplace.  The result after compilation of a program is@dfn{machine code},code designed to be efficiently translated and processedby a machine such as your computer.Humans usually aren't as good writing machine codeas they are at writing Fortran (or C++, Ada, or Java),because is easy to make tiny mistakes writing machine code.@itemProvide the user with information about the reasons whythe compiler is unable to create a binary from the source code.Usually this will be the case if the source code is flawed.When writing Fortran, it is easy to make big mistakes.The Fortran 90 requires that the compiler can point outmistakes to the user.An incorrect usage of the language causes an @dfn{error message}.The compiler will also attempt to diagnose cases where theuser's program contains a correct usage of the language,but instructs the computer to do something questionable.This kind of diagnostics message is called a @dfn{warning message}.@itemProvide optional information about the translation passesfrom the source code to machine code.This can help a user of the compiler to find the cause ofcertain bugs which may not be obvious in the source code,but may be more easily found at a lower level compiler output.It also helps developers to find bugs in the compiler itself.@itemProvide information in the generated machine code that canmake it easier to find bugs in the program (using a debugging tool,called a @dfn{debugger}, such as the GNU Debugger @command{gdb}). @itemLocate and gather machine code already generated toperform actions requested by statements in the user's program.This machine code is organized into @dfn{modules} and is locatedand @dfn{linked} to the user program. @end itemizeGfortran consists of several components:@itemize @bullet@itemA version of the @command{gcc} command(which also might be installed as the system's @command{cc} command)that also understands and accepts Fortran source code.The @command{gcc} command is the @dfn{driver} program forall the languages in the GNU Compiler Collection (GCC);With @command{gcc},you can compile the source code of any language forwhich a front end is available in GCC.@itemThe @command{gfortran} command itself,which also might be installed as thesystem's @command{f95} command.@command{gfortran} is just another driver program,but specifically for the Fortran 95 compiler only.The difference with @command{gcc} is that @command{gfortran}will automatically link the correct libraries to your program.@itemA collection of run-time libraries.These libraries contain the machine code needed to supportcapabilities of the Fortran language that are not directlyprovided by the machine code generated by the@command{gfortran} compilation phase,such as intrinsic functions and subroutines,and routines for interaction with files and the operating system.@c and mechanisms to spawn,@c unleash and pause threads in parallelized code.@itemThe Fortran compiler itself, (@command{f951}).This is the gfortran parser and code generator,linked to and interfaced with the GCC backend library.@command{f951} ``translates'' the source code toassembler code.  You would typically not use thisprogram directly;instead, the @command{gcc} or @command{gfortran} driverprograms will call it for you.@end itemize@c ---------------------------------------------------------------------@c GFORTRAN and GCC@c ---------------------------------------------------------------------@node GFORTRAN and GCC@chapter GFORTRAN and GCC@cindex GNU Compiler CollectionGCC used to be the GNU ``C'' Compiler,but is now known as the @dfn{GNU Compiler Collection}.GCC provides the GNU system with a very versatilecompiler middle end (shared optimization passes),and back ends (code generators) for many differentcomputer architectures and operating systems.The code of the middle end and back end are shared by allcompiler front ends that are in the GNU Compiler Collection.A GCC front end is essentially a source code parserand an intermediate code generator.  The code generator translates thesemantics of the source code into a language independent form called@dfn{GENERIC}.The parser takes a source file written in aparticular computer language, reads and parses it,and tries to make sure that the source code conforms tothe language rules.Once the correctness of a program has been established,the compiler will build a data structure known as the@dfn{Abstract Syntax tree},or just @dfn{AST} or ``tree'' for short.This data structure represents the whole programor a subroutine or a function.The ``tree'' is passed to the GCC middle end,which will perform optimization passes on it.  The optimized AST is then handed off too the back end which assembles the program unit.Different phases in this translation process can be,and in fact @emph{are} merged in many compiler front ends.GNU Fortran 95 has a strict separation between theparser and code generator.The goal of the gfortran project is to build a new front end for GCC.Specifically, a Fortran 95 front end.In a non-gfortran installation,@command{gcc} will not be able to compile Fortran 95 source code(only the ``C'' front end has to be compiled if you want to build GCC,all other languages are optional).If you build GCC with gfortran, @command{gcc} will recognize@file{.f/.f90/.f95} source files and accepts Fortran 95 specificcommand line options.@c ---------------------------------------------------------------------@c GFORTRAN and G77@c ---------------------------------------------------------------------@node GFORTRAN and G77@chapter GFORTRAN and G77@cindex Fortran 77@cindex G77Why do we write a compiler front end from scratch? There's a fine Fortran 77 compiler in theGNU Compiler Collection that accepts some featuresof the Fortran 90 standard as extensions.Why not start from there and revamp it?One of the reasons is that Craig Burley, the author of G77,has decided to stop working on the G77 front end.On @uref{http://world.std.com/~burley/g77-why.html,Craig explains the reasons for his decision to stop working on G77}in one of the pages in his homepage.Among the reasons is a lack of interest in improvements to@command{g77}.Users appear to be quite satisfied with @command{g77} as it is.While @command{g77} is still being maintained (by Toon Moene),it is unlikely that sufficient people will be willingto completely rewrite the existing code. But there are other reasons to start from scratch.Many people, including Craig Burley,no longer agreed with certain design decisions in the G77 front end.Also, the interface of @command{g77} to the back end is written ina style which is confusing and not up to date on recommended practice.In fact, a full rewrite had already been planned for GCC 3.0.When Craig decided to stop,it just seemed to be a better idea to start a new project from scratch,because it was expected to be easier to maintain code wedevelop ourselves than to do a major overhaul of @command{g77} first,and then build a Fortran 95 compiler out of it.@include invoke.texi@c ---------------------------------------------------------------------@c Project Status@c ---------------------------------------------------------------------@node Project Status@chapter Project Status@quotationAs soon as gfortran can parse all of the statements correctly,it will be in the ``larva'' state.When we generate code, the ``puppa'' state.When gfortran is done,we'll see if it will be a beautiful butterfly,or just a big bug....--Andy Vaught, April 2000@end quotationThe start of the GNU Fortran 95 project was announced onthe GCC homepage in March 18, 2000(even though Andy had already been working on it for a while,of course).Gfortran is currently reaching the stage where is is able to compile realworld programs.  However it is still under development and has many roughedges.@menu* Compiler Status::* Library Status::* Proposed Extensions::@end menu@node Compiler Status@section Compiler Status@table @emph@item Front endThis is the part of gfortran which parses a source file, verifies that itis valid Fortran 95, performs compile time replacement of constants(PARAMETER variables) and reads and generate module files. This isalmost complete. Every Fortran 95 source should be accepted, and mostnone-Fortran 95 source should be rejected. If you find a source file wherethis is not true, please tell us. You can use the -fsyntax-only switch tomake gfortran quit after running the front end, effectively reducing it toa syntax checker.@item Middle end interfaceThese are the parts of gfortran that take the parse tree generated by thefront end and translate it to the GENERIC form required by the GCC backend. Work is ongoing in these parts of gfortran, but a large part hasalready been completed.@end table@node Library Status@section Library StatusSome intrinsic functions map directly to library functions, and in mostcases the name of the library function used depends on the type of thearguments.  For some intrinsics we generate inline code, and for others,such as sin, cos and sqrt, we rely on the backend to use specialinstructions in the floating point unit of the CPU if available, or tofall back to a call to libm if these are not available.Implementation of some non-elemental intrinsic functions (eg. DOT_PRODUCT,AVERAGE) is not yet optimal. This is hard because we have to make decisionswhether to use inline code (good for small arrays as no function call

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -