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

📄 gfortran.texi

📁 gcc-fortran,linux使用fortran的编译软件。很好用的。
💻 TEXI
📖 第 1 页 / 共 3 页
字号:
overhead occurs) or generate function calls (good for large arrays as itallows use of hand-optimized assembly routines, SIMD instructions, etc.)The IO library is in a mostly usable state.  Unformatted I/O for@code{REAL(KIND=10)} variables is currently not recommended.Array intrinsics mostly work.@node Proposed Extensions@section Proposed ExtensionsHere's a list of proposed extensions for @command{gfortran}, in no particularorder.  Most of these are necessary to be fully compatible withexisting Fortran compilers, but they are not part of the officialJ3 Fortran 95 standard.@subsection Compiler extensions: @itemize @bullet@itemFlag for defining the kind number for default logicals.@itemUser-specified alignment rules for structures.@itemFlag to generate @code{Makefile} info.@itemAutomatically extend single precision constants to double.@itemCompile code that conserves memory by dynamically allocating common andmodule storage either on stack or heap.@itemFlag to cause the compiler to distinguish between upper and lower casenames.  The Fortran 95 standard does not distinguish them.@itemCompile flag to generate code for array conformance checking (suggest -CC).@itemUser control of symbol names (underscores, etc).@itemCompile setting for maximum size of stack frame size before spillingparts to static or heap.@itemFlag to force local variables into static space.@itemFlag to force local variables onto stack.@itemFlag to compile lines beginning with ``D''.@itemFlag to ignore lines beginning with ``D''.@itemFlag for maximum errors before ending compile.@itemGenerate code to check for null pointer dereferences -- prints locus ofdereference instead of segfaulting.  There was some discussion about thisoption in the g95 development mailing list.@itemAllow setting the default unit number.@itemOption to initialize otherwise uninitialized integer and floatingpoint variables.@itemSupport for OpenMP directives.  This also requires support from the runtimelibrary and the rest of the compiler.@itemSupport for Fortran 200x. This includes several new features includingfloating point exceptions, extended use of allocatable arrays, Cinteroperability, Parameterizer data types and function pointers.@end itemize@subsection Environment Options@itemize @bullet@itemPluggable library modules for random numbers, linear algebra.LA should use BLAS calling conventions.@itemEnvironment variables controlling actions on arithmetic exceptions likeoverflow, underflow, precision loss -- Generate NaN, abort, default.action.@itemSet precision for fp units that support it (i387).@itemVariable for setting fp rounding mode.@itemVariable to fill uninitialized variables with a user-defined bitpattern.@itemEnvironment variable controlling filename that is opened for that unitnumber.@itemEnvironment variable to clear/trash memory being freed.@itemEnvironment variable to control tracing of allocations and frees.@itemEnvironment variable to display allocated memory at normal program end.@itemEnvironment variable for filename for * IO-unit.@itemEnvironment variable for temporary file directory.@itemEnvironment variable forcing standard output to be line buffered (unix).@end itemize@node Runtime@chapter Runtime:  Influencing runtime behavior with environment variables@cindex RuntimeThe behaviour of the @command{gfortran} can be influenced byenvironment variables.@menu* GFORTRAN_CONVERT_UNIT::  Set endianness for unformatted I/O@end menu@node GFORTRAN_CONVERT_UNIT@section GFORTRAN_CONVERT_UNIT --- Set endianness for unformatted I/OBy setting the @code{GFORTRAN_CONVERT_UNIT variable}, it is possibleto change the representation of data for unformatted files.The syntax for the @code{GFORTRAN_CONVERT_UNIT} variable is:@smallexampleGFORTRAN_CONVERT_UNIT: mode | mode ';' exception ;mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ;exception: mode ':' unit_list | unit_list ;unit_list: unit_spec | unit_list unit_spec ;unit_spec: INTEGER | INTEGER '-' INTEGER ;@end smallexampleThe variable consists of an optional default mode, followed bya list of optional exceptions, which are separated by semicolonsfrom the preceding default and each other.  Each exception consistsof a format and a comma-separated list of units.  Valid values forthe modes are the same as for the @code{CONVERT} specifier:@itemize @w{}@item @code{NATIVE} Use the native format.  This is the default.@item @code{SWAP} Swap between little- and big-endian.@item @code{LITTLE_ENDIAN} Use the little-endian format        for unformatted files.@item @code{BIG_ENDIAN} Use the big-endian format for unformatted files.@end itemizeA missing mode for an exception is taken to mean @code{BIG_ENDIAN}.Examples of values for @code{GFORTRAN_CONVERT_UNIT} are:@itemize @w{}@item @code{'big_endian'}  Do all unformatted I/O in big_endian mode.@item @code{'little_endian;native:10-20,25'}  Do all unformatted I/O in little_endian mode, except for units 10 to 20 and 25, which are innative format.@item @code{'10-20'}  Units 10 to 20 are big-endian, the rest is native.@end itemizeSetting the environment variables should be done on the commandline or via the @code{export}command for @code{sh}-compatible shells and via @code{setenv}for @code{csh}-compatible shells.Example for @code{sh}:@smallexample$ gfortran foo.f90$ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out@end smallexampleExample code for @code{csh}:@smallexample% gfortran foo.f90% setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20'% ./a.out@end smallexampleUsing anything but the native representation for unformatted datacarries a significant speed overhead.  If speed in this area mattersto you, it is best if you use this only for data that needs to beportable.@xref{CONVERT specifier}, for an alternative way to specify thedata representation for unformatted files.  @xref{Runtime Options}, forsetting a default data representation for the whole program.  The@code{CONVERT} specifier overrides the @code{-fconvert} compile options.@c ---------------------------------------------------------------------@c Extensions@c ---------------------------------------------------------------------@c Maybe this chapter should be merged with the 'Standards' section,@c whenever that is written :-)@node Extensions@chapter Extensions@cindex Extension@command{gfortran} implements a number of extensions over standardFortran. This chapter contains information on their syntax andmeaning.  There are currently two categories of @command{gfortran}extensions, those that provide functionality beyond that providedby any standard, and those that are supported by @command{gfortran}purely for backward compatibility with legacy compilers.  By default,@option{-std=gnu} allows the compiler to accept both types ofextensions, but to warn about the use of the latter.  Specifyingeither @option{-std=f95} or @option{-std=f2003} disables both typesof extensions, and @option{-std=legacy} allows both without warning.@menu* Old-style kind specifications::* Old-style variable initialization::* Extensions to namelist::* X format descriptor::* Commas in FORMAT specifications::* I/O item lists::* Hexadecimal constants::* Real array indices::* Unary operators::* Implicitly interconvert LOGICAL and INTEGER::* Hollerith constants support::* Cray pointers::* CONVERT specifier::@end menu@node Old-style kind specifications@section Old-style kind specifications@cindex Kind specifications@command{gfortran} allows old-style kind specifications indeclarations. These look like:@smallexample      TYPESPEC*k x,y,z@end smallexamplewhere @code{TYPESPEC} is a basic type, and where @code{k} is a valid kindnumber for that type. The statement then declares @code{x}, @code{y}and @code{z} to be of type @code{TYPESPEC} with kind @code{k}. Inother words, it is equivalent to the standard conforming declaration@smallexample      TYPESPEC(k) x,y,z@end smallexample@node Old-style variable initialization@section Old-style variable initialization@cindex Initialization@command{gfortran} allows old-style initialization of variables of theform:@smallexample      INTEGER*4 i/1/,j/2/      REAL*8 x(2,2) /3*0.,1./@end smallexampleThese are only allowed in declarations without double colons(@code{::}), as these were introduced in Fortran 90 which alsointroduced a new syntax for variable initializations. The syntax forthe individual initializers is as for the @code{DATA} statement, butunlike in a @code{DATA} statement, an initializer only applies to thevariable immediately preceding. In other words, something like@code{INTEGER I,J/2,3/} is not valid.Examples of standard conforming code equivalent to the above example, are:@smallexample! Fortran 90      INTEGER(4) :: i = 1, j = 2      REAL(8) :: x(2,2) = RESHAPE((/0.,0.,0.,1./),SHAPE(x))! Fortran 77      INTEGER  i, j      DOUBLE PRECISION x(2,2)      DATA i,j,x /1,2,3*0.,1./@end smallexample@node Extensions to namelist@section Extensions to namelist@cindex Namelist@command{gfortran} fully supports the Fortran 95 standard for namelist I/Oincluding array qualifiers, substrings and fully qualified derived types.The output from a namelist write is compatible with namelist read.  Theoutput has all names in upper case and indentation to column 1 after thenamelist name.  Two extensions are permitted:Old-style use of $ instead of &@smallexample$MYNML X(:)%Y(2) = 1.0 2.0 3.0 CH(1:4) = "abcd"$END@end smallexampleIt should be noticed that the default terminator is / rather than &END.Querying of the namelist when inputting from stdin. After at leastone space, entering ? sends to stdout the namelist name and the names ofthe variables in the namelist:@smallexample?&mynml x x%y ch&end@end smallexampleEntering =? outputs the namelist to stdout, as if WRITE (*,NML = mynml)had been called:@smallexample=?&MYNML X(1)%Y=  0.000000    ,  1.000000    ,  0.000000    , X(2)%Y=  0.000000    ,  2.000000    ,  0.000000    , X(3)%Y=  0.000000    ,  3.000000    ,  0.000000    , CH=abcd,  /@end smallexampleTo aid this dialog, when input is from stdin, errors send theirmessages to stderr and execution continues, even if IOSTAT is set.PRINT namelist is permitted.  This causes an error if -std=f95 is used.@smallexamplePROGRAM test_print  REAL, dimension (4)  ::  x = (/1.0, 2.0, 3.0, 4.0/)  NAMELIST /mynml/ x  PRINT mynmlEND PROGRAM test_print@end smallexample@node X format descriptor@section X format descriptor@cindex X format descriptorTo support legacy codes, @command{gfortran} permits the count fieldof the X edit descriptor in FORMAT statements to be omitted.  Whenomitted, the count is implicitly assumed to be one.@smallexample       PRINT 10, 2, 310     FORMAT (I1, X, I1)@end smallexample@node Commas in FORMAT specifications@section Commas in FORMAT specifications@cindex Commas in FORMAT specificationsTo support legacy codes, @command{gfortran} allows the comma separatorto be omitted immediately before and after character string editdescriptors in FORMAT statements.@smallexample       PRINT 10, 2, 310     FORMAT ('FOO='I1' BAR='I2)@end smallexample@node I/O item lists@section I/O item lists@cindex I/O item listsTo support legacy codes, @command{gfortran} allows the input item listof the READ statement, and the output item lists of the WRITE and PRINTstatements to start with a comma.@node Hexadecimal constants@section Hexadecimal constants@cindex Hexadecimal constantsAs a GNU extension, @command{gfortran} allows hexadecimal constants tobe specified using the X prefix, in addition to the standard Z prefix.@node Real array indices@section Real array indices@cindex Real array indicesAs a GNU extension, @command{gfortran} allows arrays to be indexed usingreal types, whose values are implicitly converted to integers.@node Unary operators@section Unary operators@cindex Unary operatorsAs a GNU extension, @command{gfortran} allows unary plus and unaryminus operators to appear as the second operand of binary arithmeticoperators without the need for parenthesis.@smallexample       X = Y * -Z@end smallexample@node Implicitly interconvert LOGICAL and INTEGER@section Implicitly interconvert LOGICAL and INTEGER@cindex Implicitly interconvert LOGICAL and INTEGERAs a GNU extension for backwards compatibility with other compilers,@command{gfortran} allows the implicit conversion of LOGICALs to INTEGERsand vice versa.  When converting from a LOGICAL to an INTEGER, the numericvalue of @code{.FALSE.} is zero, and that of @code{.TRUE.} is one.  Whenconverting from INTEGER to LOGICAL, the value zero is interpreted as@code{.FALSE.} and any nonzero value is interpreted as @code{.TRUE.}.@smallexample       INTEGER*4 i       i = .FALSE.@end smallexample

⌨️ 快捷键说明

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