Published by the Free Software Foundation 59 Temple Place - Suite 330 Boston, MA 02111-1307 USA
Copyright (C) 1995-1997 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``GNU General Public License,'' ``Funding for Free Software,'' and ``Protect Your Freedom---Fight `Look And Feel''' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled ``GNU General Public License,'' ``Funding for Free Software,'' and ``Protect Your Freedom---Fight `Look And Feel''', and this permission notice, may be included in translations approved by the Free Software Foundation instead of in the original English.
Contributed by James Craig Burley (burley@gnu.org). Inspired by a first pass at translating g77-0.5.16/f/DOC that was contributed to Craig by David Ronis (ronis@onsager.chem.mcgill.ca).
This manual documents how to run, install and port the GNU Fortran compiler, as well as its new features and incompatibilities, and how to report bugs. It corresponds to GNU Fortran version 0.5.21.
g77 fits into the universe.
g77.
g77.
g77.
g77.
g77.
g77 generates code.
g77 about new options.
g77 internals hackers.
g77.
Version 2, June 1991
Copyright © 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software---to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and ``any later version'', you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
NO WARRANTY
END OF TERMS AND CONDITIONS
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the ``copyright'' line and a pointer to where the full notice is found.
one line to give the program's name and a brief idea of what it does. Copyright (C) 19yy name of author This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than show w and show c; they could even be mouse-clicks or menu items---whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a ``copyright disclaimer'' for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
In addition to James Craig Burley, who wrote the front end, many people have helped create and improve GNU Fortran.
libf2c library (combined from the libF77 and
libI77 libraries) provided as part of f2c, available for
free from netlib sites on the Internet.
g77's
public release. This work consisted of testing, researching, sometimes
debugging, and occasionally providing small amounts of code and fixes
for g77, plus offering plenty of helpful advice to Craig:
INTEGER*1, INTEGER*2, and
LOGICAL*1.
This inspired Craig to add further support,
even though the resulting support
would still be incomplete, because version 0.6 is still
a ways off.
g77 code generation to at least be as good
as f2c used in conjunction with gcc.
So far, this has resulted in the three, somewhat
experimental, options added by g77 to the gcc
compiler and its back end.
g77
over the past several years, and undoubtedly more people
will be doing so in the future.
If you have done so, and would like
to see your name listed in the above list, please ask!
The default is that people wish to remain anonymous.
If you want to have more free software a few years from now, it makes sense for you to help encourage people to contribute funds for its development. The most effective approach known is to encourage commercial redistributors to donate.
Users of free software systems can boost the pace of development by encouraging for-a-fee distributors to donate part of their selling price to free software developers---the Free Software Foundation, and others.
The way to convince distributors to do this is to demand it and expect it from them. So when you compare distributors, judge them partly by how much they give to free software development. Show distributors they must compete to be the one who gives the most.
To make this approach work, you must insist on numbers that you can compare, such as, ``We will donate ten dollars to the Frobnitz project for each disk sold.'' Don't be satisfied with a vague promise, such as ``A portion of the profits are donated,'' since it doesn't give a basis for comparison.
Even a precise fraction ``of the profits from this disk'' is not very meaningful, since creative accounting and unrelated business decisions can greatly alter what fraction of the sales price counts as profit. If the price you pay is $50, ten percent of the profit is probably less than a dollar; it might be a few cents, or nothing at all.
Some redistributors do development work themselves. This is useful too; but to keep everyone honest, you need to inquire how much they do, and what kind. Some kinds of development make much more long-term difference than others. For example, maintaining a separate version of a program contributes very little; maintaining the standard version of a program for the whole community contributes much. Easy new ports contribute little, since someone else would surely do them; difficult ports such as adding a new CPU to the GNU C compiler contribute more; major new features or packages contribute the most.
By establishing the idea that supporting further development is ``the proper thing to do'' when distributing free software for a fee, we can assure a steady flow of resources into making more free software.
Copyright (C) 1994 Free Software Foundation, Inc. Verbatim copying and redistribution of this section is permitted without royalty; alteration is not permitted.
Work on GNU Fortran is still being done mostly by its author, James Craig Burley (burley@gnu.org), who is a volunteer for, not an employee of, the Free Software Foundation (FSF). As with other GNU software, funding is important because it can pay for needed equipment, personnel, and so on.
The FSF provides information on the best way to fund ongoing development of GNU software (such as GNU Fortran) in documents such as the ``GNUS Bulletin''. Email gnu@prep.ai.mit.edu for information on funding the FSF.
To fund specific GNU Fortran work in particular, the FSF might provide a means for that, but the FSF does not provide direct funding to the author of GNU Fortran to continue his work. The FSF has employee salary restrictions that can be incompatible with the financial needs of some volunteers, who therefore choose to remain volunteers and thus be able to be free to do contract work and otherwise make their own schedules for doing GNU work.
Still, funding the FSF at least indirectly benefits work on specific projects like GNU Fortran because it ensures the continuing operation of the FSF offices, their workstations, their network connections, and so on, which are invaluable to volunteers. (Similarly, hiring Cygnus Support can help a project like GNU Fortran---Cygnus has been a long-time donor of equipment usage to the author of GNU Fortran, and this too has been invaluable---See Contributors.)
Currently, the only way to directly fund the author of GNU Fortran
in his work on that project is to hire him for the work you want
him to do, or donate money to him.
Several people have done this
already, with the result that he has not needed to immediately find
contract work on a few occasions.
If more people did this, he
would be able to plan on not doing contract work for many months and
could thus devote that time to work on projects (such as the planned
changes for 0.6) that require longer timeframes to complete.
For the latest information on the status of the author, do
finger -l burley@gnu.org on a UNIX system
(or any system with a command like UNIX finger).
Another important way to support work on GNU Fortran is to volunteer to help out. Work is needed on documentation, testing, porting to various machines, and in some cases, coding (although major changes planned for version 0.6 make it difficult to add manpower to this area). Email fortran@gnu.org to volunteer for this work.
See Funding Free Software, for more information.
To preserve the ability to write free software, including replacements for proprietary software, authors must be free to replicate the user interface to which users of existing software have become accustomed.
See Section Protect Your Freedom---Fight ``Look And Feel'' of
If you don't need help getting started reading the portions of this manual that are most important to you, you should skip this portion of the manual.
If you are new to compilers, especially Fortran compilers, or new to how compilers are structured under UNIX and UNIX-like systems, you'll want to see What is GNU Fortran?.
If you are new to GNU compilers, or have used only one GNU
compiler in the past and not had to delve into how it lets
you manage various versions and configurations of gcc,
you should see G77 and GCC.
Everyone except experienced g77 users should
see Invoking G77.
If you're acquainted with previous versions of g77,
you should see News.
Further, if you've actually used previous versions of g77,
especially if you've written or modified Fortran code to
be compiled by previous versions of g77, you
should see Changes.
If you intend to write or otherwise compile code that is not already strictly conforming ANSI FORTRAN 77---and this is probably everyone---you should see Language.
If you don't already have g77 installed on your
system, you must see Installation.
If you run into trouble getting Fortran code to compile,
link, run, or work properly, you might find answers
if you see Debugging and Interfacing,
see Collected Fortran Wisdom,
and see Trouble.
You might also find that the problems you are encountering
are bugs in g77---see Bugs, for information on
reporting them, after reading the other material.
If you need further help with g77, or with
freely redistributable software in general,
see Service.
If you would like to help the g77 project,
see Funding GNU Fortran, for information on
helping financially, and see Projects, for information
on helping in other ways.
If you're generally curious about the future of
g77, see Projects.
If you're curious about its past,
see Contributors,
and see Funding GNU Fortran.
To see a few of the questions maintainers of g77 have,
and that you might be able to answer,
see Open Questions.
GNU Fortran, or g77, is designed initially as a free replacement
for, or alternative to, the UNIX f77 command.
(Similarly, gcc is designed as a replacement
for the UNIX cc command.)
g77 also is designed to fit in well with the other
fine GNU compilers and tools.
Sometimes these design goals conflict---in such cases, resolution often is made in favor of fitting in well with Project GNU. These cases are usually identified in the appropriate sections of this manual.
As compilers, g77, gcc, and f77
share the following characteristics:
gdb).
ld command.
However, the g77 and gcc
commands, as with most compiler commands, automatically
perform the linking step by calling on ld
directly, unless asked to not do so by the user.)
How these actions are performed is generally under the control of the user. Using command-line options, the user can specify how persnickety the compiler is to be regarding the program (whether to diagnose questionable usage of the language), how much time to spend making the generated machine code run faster, and so on.
g77 consists of several components:
gcc command, which also might be
installed as the system's cc command.
(In many cases, cc refers to the
system's ``native'' C compiler, which
might be a non-GNU compiler, or an older version
of gcc considered more stable or that is
used to build the operating system kernel.)
g77 command itself, which also might be installed as the
system's f77 command.
libf2c run-time library.
This library contains the machine code needed to support
capabilities of the Fortran language that are not directly
provided by the machine code generated by the g77
compilation phase.
f771.
Note that f771 does not generate machine code directly---it
generates assembly code that is a more readable form
of machine code, leaving the conversion to actual machine code
to an assembler, usually named as.
gcc is often thought of as ``the C compiler'' only,
but it does more than that.
Based on command-line options and the names given for files
on the command line, gcc determines which actions to perform, including
preprocessing, compiling (in a variety of possible languages), assembling,
and linking.
For example, the command gcc foo.c drives the file
foo.c through the preprocessor cpp, then
the C compiler (internally named
cc1), then the assembler (usually as), then the linker
(ld), producing an executable program named a.out (on
UNIX systems).
As another example, the command gcc foo.cc would do much the same as
gcc foo.c, but instead of using the C compiler named cc1,
gcc would use the C++ compiler (named cc1plus).
In a GNU Fortran installation, gcc recognizes Fortran source
files by name just like it does C and C++ source files.
It knows to use the Fortran compiler named f771, instead of
cc1 or cc1plus, to compile Fortran files.
Non-Fortran-related operation of gcc is generally
unaffected by installing the GNU Fortran version of gcc.
However, without the installed version of gcc being the
GNU Fortran version, gcc will not be able to compile
and link Fortran programs---and since g77 uses gcc
to do most of the actual work, neither will g77!
The g77 command is essentially just a front-end for
the gcc command.
Fortran users will normally use g77 instead of gcc,
because g77
knows how to specify the libraries needed to link with Fortran programs
(libf2c and lm).
g77 can still compile and link programs and
source files written in other languages, just like gcc.
The command g77 -v is a quick
way to display lots of version information for the various programs
used to compile a typical preprocessed Fortran source file---this
produces much more output than gcc -v currently does.
(If it produces an error message near the end of the output---diagnostics
from the linker, usually ld---you might
have an out-of-date libf2c that improperly handles
complex arithmetic.)@
In the output of this command, the line beginning GNU Fortran Front
End identifies the version number of GNU Fortran; immediately
preceding that line is a line identifying the version of gcc
with which that version of g77 was built.
The libf2c library is distributed with GNU Fortran for
the convenience of its users, but is not part of GNU Fortran.
It contains the procedures
needed by Fortran programs while they are running.
For example, while code generated by g77 is likely
to do additions, subtractions, and multiplications in line---in
the actual compiled code---it is not likely to do trigonometric
functions this way.
Instead, operations like trigonometric
functions are compiled by the f771 compiler
(invoked by g77 when compiling Fortran code) into machine
code that, when run, calls on functions in libf2c, so
libf2c must be linked with almost every useful program
having any component compiled by GNU Fortran.
(As mentioned above, the g77 command takes
care of all this for you.)
The f771 program represents most of what is unique to GNU Fortran.
While much of the libf2c component is really part of f2c,
a free Fortran-to-C converter distributed by Bellcore (AT&T),
plus libU77, provided by Dave Love,
and the g77 command is just a small front-end to gcc,
f771 is a combination of two rather
large chunks of code.
One chunk is the so-called GNU Back End, or GBE,
which knows how to generate fast code for a wide variety of processors.
The same GBE is used by the C, C++, and Fortran compiler programs cc1,
cc1plus, and f771, plus others.
Often the GBE is referred to as the ``gcc back end'' or
even just ``gcc''---in this manual, the term GBE is used
whenever the distinction is important.
The other chunk of f771 is the
majority of what is unique about GNU Fortran---the code that knows how
to interpret Fortran programs to determine what they are intending to
do, and then communicate that knowledge to the GBE for actual compilation
of those programs.
This chunk is called the Fortran Front End (FFE).
The cc1 and cc1plus programs have their own front ends,
for the C and C++ languages, respectively.
These fronts ends are responsible for diagnosing
incorrect usage of their respective languages by the
programs the process, and are responsible for most of
the warnings about questionable constructs as well.
(The GBE handles producing some warnings, like those
concerning possible references to undefined variables.)
Because so much is shared among the compilers for various languages, much of the behavior and many of the user-selectable options for these compilers are similar. For example, diagnostics (error messages and warnings) are similar in appearance; command-line options like -Wall have generally similar effects; and the quality of generated code (in terms of speed and size) is roughly similar (since that work is done by the shared GBE).
A GNU Fortran installation includes a modified version of the gcc
command.
In a non-Fortran installation, gcc recognizes C, C++,
and Objective-C source files.
In a GNU Fortran installation, gcc also recognizes Fortran source
files and accepts Fortran-specific command-line options, plus some
command-line options that are designed to cater to Fortran users
but apply to other languages as well.
See Section Compile C; C++; or Objective-C of
gcc).
Also provided as part of GNU Fortran is the g77 command.
The g77 command is designed to make compiling and linking Fortran
programs somewhat easier than when using the gcc command for
these tasks.
It does this by analyzing the command line somewhat and changing it
appropriately before submitting it to the gcc command.
Use the -v option with g77
to see what is going on---the first line of output is the invocation
of the gcc command.
Use --driver=true to disable actual invocation
of gcc (this works because true is the name of a
UNIX command that simply returns success status).
The g77 command supports all the options supported by the
gcc command.
See Section GNU CC Command Options of
gcc command (and,
therefore, the g77 command).
The g77 command supports one option not supported by
the gcc command:
gcc, is to
be invoked by g77 to do its job.
For example, within the gcc build directory after
building GNU Fortran (but without having to install it),
./g77 --driver=./xgcc foo.f -B./.
All other options are supported both by g77 and by gcc as
modified (and reinstalled) by the g77 distribution.
In some cases, options have positive and negative forms;
the negative form of -ffoo would be -fno-foo.
This manual documents only one of these two forms, whichever
one is not the default.
g77 options, without explanations.
Here is a summary of all the options specific to GNU Fortran, grouped by type. Explanations are in the following sections.
--driver -fversion -fset-g77-defaults -fno-silent
-ff66 -fno-f66 -ff77 -fno-f77 -fugly -fno-ugly
-ffree-form -fno-fixed-form -ff90 -fvxt -fdollar-ok -fno-backslash -fno-ugly-args -fno-ugly-assign -fno-ugly-assumed -fugly-comma -fugly-complex -fugly-init -fugly-logint -fonetrip -ftypeless-boz -fintrin-case-initcap -fintrin-case-upper -fintrin-case-lower -fintrin-case-any -fmatch-case-initcap -fmatch-case-upper -fmatch-case-lower -fmatch-case-any -fsource-case-upper -fsource-case-lower -fsource-case-preserve -fsymbol-case-initcap -fsymbol-case-upper -fsymbol-case-lower -fsymbol-case-any -fcase-strict-upper -fcase-strict-lower -fcase-initcap -fcase-upper -fcase-lower -fcase-preserve -ff2c-intrinsics-delete -ff2c-intrinsics-hide -ff2c-intrinsics-disable -ff2c-intrinsics-enable -fbadu77-intrinsics-delete -fbadu77-intrinsics-hide -fbadu77-intrinsics-disable -fbadu77-intrinsics-enable -ff90-intrinsics-delete -ff90-intrinsics-hide -ff90-intrinsics-disable -ff90-intrinsics-enable -fgnu-intrinsics-delete -fgnu-intrinsics-hide -fgnu-intrinsics-disable -fgnu-intrinsics-enable -fmil-intrinsics-delete -fmil-intrinsics-hide -fmil-intrinsics-disable -fmil-intrinsics-enable -funix-intrinsics-delete -funix-intrinsics-hide -funix-intrinsics-disable -funix-intrinsics-enable -fvxt-intrinsics-delete -fvxt-intrinsics-hide -fvxt-intrinsics-disable -fvxt-intrinsics-enable -ffixed-line-length-n -ffixed-line-length-none
-fsyntax-only -pedantic -pedantic-errors -fpedantic -w -Wno-globals -Wimplicit -Wunused -Wuninitialized -Wall -Wsurprising -Werror -W
-g
-malign-double -ffloat-store -fforce-mem -fforce-addr -fno-inline -ffast-math -fstrength-reduce -frerun-cse-after-loop -fexpensive-optimizations -fdelayed-branch -fschedule-insns -fschedule-insn2 -fcaller-saves -funroll-loops -funroll-all-loops -fno-move-all-movables -fno-reduce-all-givs -fno-rerun-loop-opt
-Idir -I-
-fno-automatic -finit-local-zero -fno-f2c -ff2c-library -fno-underscoring -fno-ident -fpcc-struct-return -freg-struct-return -fshort-double -fno-common -fpack-struct -fzeros -fno-second-underscore -fdebug-kludge -fno-emulate-complex -falias-check -fargument-alias -fargument-noalias -fno-argument-noalias-global -fno-globals
Compilation can involve as many as four stages: preprocessing, code generation (often what is really meant by the term ``compilation''), assembly, and linking, always in that order. The first three stages apply to an individual source file, and end by producing an object file; linking combines all the object files (those newly compiled, and those specified as input) into an executable file.
For any given input file, the file name suffix determines what kind of program is contained in the file---that is, the language in which the program is written is generally indicated by the suffix. Suffixes specific to GNU Fortran are listed below. See Section gcc of
, for information on suffixes recognized by GNU CC.Such source code cannot contain any preprocessor directives, such
as #include, #define, #if, and so on.
cpp, which is part of GNU CC).
Note that preprocessing is not extended to the contents of
files included by the INCLUDE directive---the #include
preprocessor directive must be used instead.
ratfor
command, which is available separately (as it is not yet part of
the GNU Fortran distribution).
UNIX users typically use the file.f and file.F nomenclature. Users of other operating systems, especially those that cannot distinguish upper-case letters from lower-case letters in their file names, typically use the file.for and file.fpp nomenclature.
Use of the preprocessor cpp allows use of C-like
constructs such as #define and #include, but can
lead to unexpected, even mistaken, results due to Fortran's source file
format.
It is recommended that use of the C preprocessor
be limited to #include and, in
conjunction with #define, only #if and related directives,
thus avoiding in-line macro expansion entirely.
This recommendation applies especially
when using the traditional fixed source form.
With free source form,
fewer unexpected transformations are likely to happen, but use of
constructs such as Hollerith and character constants can nevertheless
present problems, especially when these are continued across multiple
source lines.
These problems result, primarily, from differences between the way
such constants are interpreted by the C preprocessor and by a Fortran
compiler.
Another example of a problem that results from using the C preprocessor is that a Fortran comment line that happens to contain any characters ``interesting'' to the C preprocessor, such as a backslash at the end of the line, is not recognized by the preprocessor as a comment line, so instead of being passed through ``raw'', the line is edited according to the rules for the preprocessor. For example, the backslash at the end of the line is removed, along with the subsequent newline, resulting in the next line being effectively commented out---unfortunate if that line is a non-comment line of important code!
Note: The -traditional and -undef flags are supplied
to cpp by default, to avoid unpleasant surprises.
See Section Options Controlling the Preprocessor of
The following options that affect overall processing are recognized
by the g77 and gcc commands in a GNU Fortran installation:
g77 command, not
when invoking the gcc command.
See GNU Fortran Command Options, for
information on this option.
g77-specific version of the compiler phase is reported,
if run.
(This is supplied automatically when -v or --verbose
is specified as a command-line option for g77 or gcc
and when the resulting commands compile Fortran source files.)
gcc options are to apply to Fortran
compilations, and avoid running internal consistency checks
that might take some time.
As of version 0.5.20, this is equivalent to -fmove-all-movables -freduce-all-givs -frerun-loop-opt -fargument-noalias-global.
This option is supplied automatically when compiling Fortran code
via the g77 or gcc command.
The description of this option is provided so that users seeing
it in the output of, say, g77 -v understand why it is
there.
Also, developers who run f771 directly might want to specify it
by hand to get the same defaults as they would running f771
via g77 or gcc.
However, such developers should, after linking a new f771
executable, invoke it without this option once,
e.g. via ./f771 -quiet < /dev/null,
to ensure that they have not introduced any
internal inconsistencies (such as in the table of
intrinsics) before proceeding---g77 will crash
with a diagnostic if it detects an inconsistency.
stderr) the names of the program units as
they are compiled, in a form similar to that used by popular
UNIX f77 implementations and f2c.
See Section Options Controlling the Kind of Output of
gcc command
(and, by extension, the g77 command).
The following options serve as ``shorthand'' for other options accepted by the compiler:
-fugly-args -fugly-assign -fugly-assumed -fugly-comma -fugly-complex -fugly-init -fugly-logint
These constructs are considered inappropriate to use in new or well-maintained portable Fortran code, but widely used in old code. See Distensions, for more information.
Note: The -fugly option is likely to be removed in a future version. Implicitly enabling all the -fugly-* options is unlikely to be feasible, or sensible, in the future, so users should learn to specify only those -fugly-* options they really need for a particular source file.
-fno-ugly-args -fno-ugly-assign -fno-ugly-assumed -fno-ugly-comma -fno-ugly-complex -fno-ugly-init -fno-ugly-logint
See Distensions, for more information.
The -fno-f66 option is the inverse of -ff66. As such, it is the same as -fno-onetrip -fno-ugly-assumed.
The meaning of this option is likely to be refined as future
versions of g77 provide more compatibility with other
existing and obsolete Fortran implementations.
f2c product.
Same as -fbackslash -fno-typeless-boz.
The meaning of this option is likely to be refined as future
versions of g77 provide more compatibility with other
existing and obsolete Fortran implementations.
f2c, but in a more widely portable dialect.
-fno-f77 is the same as -fno-backslash.
The meaning of this option is likely to be refined as future
versions of g77 provide more compatibility with other
existing and obsolete Fortran implementations.
The following options control the dialect of Fortran that the compiler accepts:
This option controls whether certain Fortran 90 constructs are recognized. (Other Fortran 90 constructs might or might not be recognized depending on other options such as -fvxt, -ff90-intrinsics-enable, and the current level of support for Fortran 90.)
See Fortran 90, for more information.
The default is -fno-vxt. -fvxt specifies that the VXT Fortran interpretations for those constructs are to be chosen.
See VXT Fortran, for more information.
For example, with -fbackslash in effect, A\nB specifies three characters, with the second one being newline. With -fno-backslash, it specifies four characters, A, \, n, and B.
Note that g77 implements a fairly general form of backslash
processing that is incompatible with the narrower forms supported
by some other compilers.
For example, 'A\003B' is a three-character string in g77,
whereas other compilers that support backslash might not support
the three-octal-digit form, and thus treat that string as longer
than three characters.
See Backslash in Constants, for information on why -fbackslash is the default instead of -fno-backslash.
See Ugly Implicit Argument Conversion, for more information.
See Ugly Assigned Labels, for more information.
For example, DIMENSION X(1) is treated as if it had read DIMENSION X(*).
See Ugly Assumed-Size Arrays, for more information.
For example, CALL FOO(,) is treated as CALL FOO(%VAL(0), %VAL(0)). That is, two null arguments are specified by the procedure call when -fugly-comma is in force. And F = FUNC() is treated as F = FUNC(%VAL(0)).
The default behavior, -fno-ugly-comma, is to ignore a single trailing comma in an argument list. So, by default, CALL FOO(X,) is treated exactly the same as CALL FOO(X).
See Ugly Null Arguments, for more information.
COMPLEX
type other than COMPLEX(KIND=1)---usually
this is used to permit COMPLEX(KIND=2)
(DOUBLE COMPLEX) operands.
The -ff90 option controls the interpretation of this construct.
See Ugly Complex Part Extraction, for more information.
PARAMETER and DATA statements), and
use of character constants to
initialize numeric types and vice versa.
For example, DATA I/'F'/, CHRVAR/65/, J/4HABCD/ is disallowed by -fno-ugly-init.
See Ugly Conversion of Initializers, for more information.
INTEGER and LOGICAL variables and
expressions as potential stand-ins for each other.
For example, automatic conversion between INTEGER and
LOGICAL is enabled, for many contexts, via this option.
See Ugly Integer Conversions, for more information.
DO loops are to be executed at
least once each time they are reached.
ANSI FORTRAN 77 and more recent versions of the Fortran standard
specify that the body of an imperative DO loop is not executed
if the number of iterations calculated from the parameters of the
loop is less than 1.
(For example, DO 10 I = 1, 0.)@
Such a loop is called a zero-trip loop.
Prior to ANSI FORTRAN 77, many compilers implemented DO loops
such that the body of a loop would be executed at least once, even
if the iteration count was zero.
Fortran code written assuming this behavior is said to require
one-trip loops.
For example, some code written to the FORTRAN 66 standard
expects this behavior from its DO loops, although that
standard did not specify this behavior.
The -fonetrip option specifies that the source file(s) being compiled require one-trip loops.
This option affects only those loops specified by the (imperative) DO
statement and by implied-DO lists in I/O statements.
Loops specified by implied-DO lists in DATA and
specification (non-executable) statements are not affected.
INTEGER(KIND=1).
You can test for yourself whether a particular compiler treats
the prefix form as INTEGER(KIND=1) or typeless by running the
following program:
EQUIVALENCE (I, R) R = Z'ABCD1234' J = Z'ABCD1234' IF (J .EQ. I) PRINT *, 'Prefix form is TYPELESS' IF (J .NE. I) PRINT *, 'Prefix form is INTEGER' END
Reports indicate that many compilers process this form as
INTEGER(KIND=1), though a few as typeless, and at least one
based on a command-line option specifying some kind of
compatibility.
Popular values for n include 72 (the standard and the default), 80 (card image), and 132 (corresponds to ``extended-source'' options in some popular compilers). n may be none, meaning that the entire line is meaningful and that continued character constants never have implicit spaces appended to them to fill out the line. -ffixed-line-length-0 means the same thing as -ffixed-line-length-none.
See Source Form, for more information.
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there might have been an error.
You can request many specific warnings with options beginning -W, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning -Wno- to turn off warnings; for example, -Wno-implicit. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of warnings produced by GNU Fortran:
Valid ANSI FORTRAN 77 programs should compile properly with or without this option. However, without this option, certain GNU extensions and traditional Fortran features are supported as well. With this option, many of them are rejected.
Some users try to use -pedantic to check programs for strict ANSI
conformance.
They soon find that it does not do quite what they want---it finds some
non-ANSI practices, but not all.
However, improvements to g77 in this area are welcome.
Also inhibit warnings about inconsistent invocations and/or definitions of global procedures (function and subroutines). Such inconsistencies include different numbers of arguments and different types of arguments.
IMPLICIT NONE statement
in every program unit.
(Some Fortran compilers provide this feature by an option
named -u or /WARNINGS=DECLARATIONS.)
These warnings are possible only in optimizing compilation, because they require data-flow information that is computed only when optimizing. If you don't specify -O, you simply won't get these warnings.
These warnings occur only for variables that are candidates for register allocation. Therefore, they do not occur for a variable whose address is taken, or whose size is other than 1, 2, 4 or 8 bytes. Also, they do not occur for arrays, even when they are in registers.
Note that there might be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data-flow analysis before the warnings are printed.
These warnings are made optional because GNU Fortran is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen:
SUBROUTINE DISPAT(J) IF (J.EQ.1) I=1 IF (J.EQ.2) I=4 IF (J.EQ.3) I=5 CALL FOO(I) ENDIf the value of
J is always 1, 2 or 3, then I is
always initialized, but GNU Fortran doesn't know this. Here is
another common case:
SUBROUTINE MAYBE(FLAG) LOGICAL FLAG IF (FLAG) VALUE = 9.4 ···IF (FLAG) PRINT *, VALUE ENDThis has no bug because
VALUE is used only if it is set.
g77, some might
be added to the list enabled by -Wall.)
The remaining -W··· options are not implied by -Wall because they warn about constructions that we consider reasonable to use, on occasion, in clean programs.
g77, along with many other compilers, interprets
this example differently than many programmers, and a few
other compilers.
Specifically, g77 interprets X**-Y*Z as
(X**(-Y))*Z, while others might think it should
be interpreted as X**(-(Y*Z)).
A revealing example is the constant expression 2**-2*1.,
which g77 evaluates to .25, while others might evaluate
it to 0., the difference resulting from the way precedence affects
type promotion.
(The -fpedantic option also warns about expressions having two arithmetic operators in a row.)
An example of an expression producing different results
in a surprising way is -I*S, where I holds
the value -2147483648 and S holds 0.5.
On many systems, negating I results in the same
value, not a positive number, because it is already the
lower bound of what an INTEGER(KIND=1) variable can hold.
So, the expression evaluates to a positive number, while
the ``expected'' interpretation, (-I)*S, would
evaluate to a negative number.
Even cases such as -I*J produce warnings, even though, in most configurations and situations, there is no computational difference between the results of the two interpretations---the purpose of this warning is to warn about differing interpretations and encourage a better style of coding, not to identify only those places where bugs might exist in the user's code.
DO loops with DO variables that are not
of integral type---that is, using REAL
variables as loop control variables.
Although such loops can be written to work in the
``obvious'' way, the way g77 is required by the
Fortran standard to interpret such code is likely to
be quite different from the way many programmers expect.
(This is true of all DO loops, but the differences
are pronounced for non-integral loop control variables.)
See Loops, for more information.
g77.)
``Extra warnings'' are issued for:
See Section Options to Request or Suppress Warnings of
g77, gcc, and other GNU compilers.
Some of these have no effect when compiling programs written in Fortran:
GNU Fortran has various special options that are used for debugging
either your program or g77.
Support for this option in Fortran programs is incomplete.
In particular, names of variables and arrays in common blocks
or that are storage-associated via EQUIVALENCE are
unavailable to the debugger.
However, version 0.5.19 of g77 does provide this information
in a rudimentary way, as controlled by the
-fdebug-kludge option.
See Options for Code Generation Conventions, for more information.
See Section Options for Debugging Your Program or GNU CC of
Most Fortran users will want to use no optimization when developing and testing programs, and use -O or -O2 when compiling programs for late-cycle testing and for production use.
The following flags have particular applicability when compiling Fortran programs:
Noticeably improves performance of g77 programs making
heavy use of REAL(KIND=2) (DOUBLE PRECISION) data
on some systems.
In particular, systems using Pentium, Pentium Pro, 586, and
686 implementations
of the i386 architecture execute programs faster when
REAL(KIND=2) (DOUBLE PRECISION) data are
aligned on 64-bit boundaries
in memory.
This option can, at least, make benchmark results more consistent across various system configurations, versions of the program, and data sets.
Note: The warning in the gcc documentation about
this option does not apply, generally speaking, to Fortran
code compiled by g77.
Also note: g77 fixes a gcc backend bug to allow
-malign-double to work generally, not just with
statically-allocated data.
Also also note: The negative form of -malign-double is -mno-align-double, not -benign-double.
Analysis of Fortran code optimization and the resulting optimizations triggered by the above options were contributed by Toon Moene (toon@moene.indiv.nluug.nl).
These three options are intended to be removed someday, once they have helped determine the efficacy of various approaches to improving the performance of Fortran code.
Please let us know how use of these options affects
the performance of your production code.
We're particularly interested in code that runs faster
when these options are disabled, and in
non-Fortran code that benefits when they are
enabled via the above gcc command-line options.
See Section Options That Control Optimization of
These options control the C preprocessor, which is run on each C source file before actual compilation.
See Section Options Controlling the Preprocessor of
Some of these options also affect how g77 processes the
INCLUDE directive.
Since this directive is processed even when preprocessing
is not requested, it is not described in this section.
See Options for Directory Search, for
information on how g77 processes the INCLUDE directive.
However, the INCLUDE directive does not apply
preprocessing to the contents of the included file itself.
Therefore, any file that contains preprocessor directives
(such as #include, #define, and #if)
must be included via the #include directive, not
via the INCLUDE directive.
Therefore, any file containing preprocessor directives,
if included, is necessarily included by a file that itself
contains preprocessor directives.
These options affect how the cpp preprocessor searches
for files specified via the #include directive.
Therefore, when compiling Fortran programs, they are meaningful
when the preproecssor is used.
Some of these options also affect how g77 searches
for files specified via the INCLUDE directive,
although files included by that directive are not,
themselves, preprocessed.
These options are:
INCLUDE directive
(as well as of the #include directive of the cpp
preprocessor).
Note that -Idir must be specified without any
spaces between -I and the directory name---that is,
-Ifoo/bar is valid, but -I foo/bar
is rejected by the g77 compiler (though the preprocessor supports
the latter form).
Also note that the general behavior of -I and
INCLUDE is pretty much the same as of -I with
#include in the cpp preprocessor, with regard to
looking for header.gcc files and other such things.
See Section Options for Directory Search of
These machine-independent options control the interface conventions used in code generation.
Most of them have both positive and negative forms; the negative form of -ffoo would be -fno-foo. In the table below, only one of the forms is listed---the one which is not the default. You can figure out the other form by either removing no- or adding it.
SAVE statement was specified
for every local variable and array referenced in it.
Does not affect common blocks.
(Some Fortran compilers provide this option under
the name -static.)
Since there is a run-time penalty for initialization of variables
that are not given the SAVE attribute, it might be a
good idea to also use -fno-automatic with -finit-local-zero.
f2c; use the GNU calling conventions instead.
The f2c calling conventions require functions that return
type REAL(KIND=1) to actually return the C type double,
and functions that return type COMPLEX to return the
values via an extra argument in the calling sequence that points
to where to store the return value.
Under the GNU calling conventions, such functions simply return
their results as they would in GNU C---REAL(KIND=1) functions
return the C type float, and COMPLEX functions
return the GNU C type complex (or its struct
equivalent).
This does not affect the generation of code that interfaces with the
libf2c library.
However, because the libf2c library uses f2c
calling conventions, g77 rejects attempts to pass
intrinsics implemented by routines in this library as actual
arguments when -fno-f2c is used, to avoid bugs when
they are actually called by code expecting the GNU calling
conventions to work.
For example, INTRINSIC ABS;CALL FOO(ABS) is
rejected when -fno-f2c is in force.
(Future versions of the g77 run-time library might
offer routines that provide GNU-callable versions of the
routines that implement the f2c-callable intrinsics
that may be passed as actual arguments, so that
valid programs need not be rejected when -fno-f2c
is used.)
Caution: If -fno-f2c is used when compiling any source file used in a program, it must be used when compiling all Fortran source files used in that program.
libf2c is required.
This is the default for the current version of g77.
Currently it is not
valid to specify -fno-f2c-library.
This option is provided so users can specify it in shell
scripts that build programs and libraries that require the
libf2c library, even when being compiled by future
versions of g77 that might otherwise default to
generating code for an incompatible library.
With -funderscoring in effect, g77 appends two underscores
to names with underscores and one underscore to external names with
no underscores. (g77 also appends two underscores to internal
names with underscores to avoid naming collisions with external names.
The -fno-second-underscore option disables appending of the
second underscore in all cases.)
This is done to ensure compatibility with code produced by many
UNIX Fortran compilers, including f2c, which perform the
same transformations.
Use of -fno-underscoring is not recommended unless you are experimenting with issues such as integration of (GNU) Fortran into existing system environments (vis-a-vis existing libraries, tools, and so on).
For example, with -funderscoring, and assuming other defaults like -fcase-lower and that j() and max_count() are external functions while my_var and lvar are local variables, a statement like
I = J() + MAX_COUNT (MY_VAR, LVAR)is implemented as something akin to:
i = j_() + max_count__(&my_var__, &lvar);
With -fno-underscoring, the same statement is implemented as:
i = j() + max_count(&my_var, &lvar);
Use of -fno-underscoring allows direct specification of
user-defined names while debugging and when interfacing g77-compiled
code with other languages.
Note that just because the names match does not mean that the
interface implemented by g77 for an external name matches the
interface implemented by some other language for that same name.
That is, getting code produced by g77 to link to code produced
by some other compiler using this or any other method can be only a
small part of the overall solution---getting the code generated by
both compilers to agree on issues other than naming can require
significant effort, and, unlike naming disagreements, linkers normally
cannot detect disagreements in these other areas.
Also, note that with -fno-underscoring, the lack of appended underscores introduces the very real possibility that a user-defined external name will conflict with a name in a system library, which could make finding unresolved-reference bugs quite difficult in some cases---they might occur at program run time, and show up only as buggy behavior at run time.
In future versions of g77, we hope to improve naming and linking
issues so that debugging always involves using the names as they appear
in the source, even if the names as seen by the linker are mangled to
prevent accidental linking between procedures with incompatible
interfaces.
This option has no effect if -fno-underscoring is in effect.
Otherwise, with this option, an external name such as MAX_COUNT is implemented as a reference to the link-time external symbol max_count_, instead of max_count__.
As of version 0.5.18, g77 normally treats DATA and
other statements that are used to specify initial values of zero
for variables and arrays as if no values were actually specified,
in the sense that no diagnostics regarding multiple initializations
are produced.
This is done to speed up compiling of programs that initialize large arrays to zeros.
Use -fzeros to revert to the simpler, slower behavior that can catch multiple initializations by keeping track of all initializations, zero or otherwise.
Caution: Future versions of g77 might disregard this option
(and its negative form, the default) or interpret it somewhat
differently.
The interpretation changes will affect only non-standard
programs; standard-conforming programs should not be affected.
COMMON and EQUIVALENCE members
that might help users of debuggers work around lack of proper debugging
information on such members.
As of version 0.5.19, g77 offers this option to emit
information on members of aggregate areas to help users while debugging.
This information consists of establishing the type and contents of each
such member so that, when a debugger is asked to print the contents,
the printed information provides rudimentary debugging information.
This information identifies the name of the aggregate area (either the
COMMON block name, or the g77-assigned name for the
EQUIVALENCE name) and the offset, in bytes, of the member from
the beginning of the area.
Using gdb, this information is not coherently displayed in the Fortran
language mode, so temporarily switching to the C language mode to display the
information is suggested.
Use set language c and set language fortran to accomplish this.
For example:
COMMON /X/A,B
EQUIVALENCE (C,D)
CHARACTER XX*50
EQUIVALENCE (I,XX(20:20))
END
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (lm-gnits-dwim), Copyright 1996 Free Software Foundation, Inc...
(gdb) b MAIN__
Breakpoint 1 at 0t1200000201120112: file cd.f, line 5.
(gdb) r
Starting program: /home/user/a.out
Breakpoint 1, MAIN__ () at cd.f:5
Current language: auto; currently fortran
(gdb) set language c
Warning: the current language does not match this frame.
(gdb) p a
$2 = "At (COMMON) `x_' plus 0 bytes"
(gdb) p b
$3 = "At (COMMON) `x_' plus 4 bytes"
(gdb) p c
$4 = "At (EQUIVALENCE) `__g77_equiv_c' plus 0 bytes"
(gdb) p d
$5 = "At (EQUIVALENCE) `__g77_equiv_c' plus 0 bytes"
(gdb) p i
$6 = "At (EQUIVALENCE) `__g77_equiv_xx' plus 20 bytes"
(gdb) p xx
$7 = "At (EQUIVALENCE) `__g77_equiv_xx' plus 1 bytes"
(gdb) set language fortran
(gdb)
Use -fdebug-kludge to generate this information,
which might make some programs noticeably larger.
Caution: Future versions of g77 might disregard this option
(and its negative form).
Current plans call for this to happen when published versions of g77
and gdb exist that provide proper access to debugging information on
COMMON and EQUIVALENCE members.
COMPLEX arithmetic using the facilities in
the gcc back end that provide direct support of
complex arithmetic, instead of emulating the arithmetic.
gcc has some known problems in its back-end support
for complex arithmetic, due primarily to the support not being
completed as of version 2.7.2.2.
Other front ends for the gcc back end avoid this problem
by emulating complex arithmetic at a higher level, so the
back end sees arithmetic on the real and imaginary components.
To make g77 more portable to systems where complex
support in the gcc back end is particularly troublesome,
g77 now defaults to performing the same kinds of emulations
done by these other front ends.
Use -fno-emulate-complex to try the complex support
in the gcc back end, in case it works and produces faster
programs.
So far, all the known bugs seem to involve compile-time crashes,
rather than the generation of incorrect code.
Use of this option should not affect how Fortran code compiled
by g77 works in terms of its interfaces to other code,
e.g. that compiled by f2c.
Caution: Future versions of g77 are likely to change
the default for this option to
-fno-emulate-complex, and perhaps someday ignore both forms
of this option.
Also, it is possible that use of the -fno-emulate-complex option
could result in incorrect code being silently produced by g77.
But, this is generally true of compilers anyway, so, as usual, test
the programs you compile before assuming they are working.
COMMON (external, or
public) storage.
The default for Fortran code, as mandated by the FORTRAN 77 and Fortran 90 standards, is -fargument-noalias-global. The default for code written in the C language family is -fargument-alias.
Note that, on some systems, compiling with -fforce-addr in effect can produce more optimal code when the default aliasing options are in effect (and when optimization is enabled).
See Aliasing Assumed To Work, for detailed information on the implications of compiling Fortran code that depends on the ability to alias dummy arguments.
Further, this option disables such inlining, to avoid compiler crashes resulting from incorrect code that would otherwise be diagnosed.
As such, this option might be quite useful when
compiling existing, ``working'' code that happens
to have a few bugs that do not generally show
themselves, but g77 exposes via a
diagnostic.
Use of this option therefore has the effect of
instructing g77 to behave more like it did
up through version 0.5.19.1, when it paid little or
no attention to disagreements between program units
about a procedure's type and argument information,
and when it performed no inlining of procedures
(except statement functions).
Without this option, g77 defaults to performing
the potentially inlining procedures as it started doing
in version 0.5.20, but as of version 0.5.21, it also
diagnoses disagreements that might cause such inlining
to crash the compiler.
See Section Options for Code Generation Conventions of
g77, gcc, and other GNU compilers.
Some of these do not work when compiling programs written in Fortran:
libf2c with which
you will be linking all code compiled by g77 with the
same option.
libf2c library,
at the very least, even if it is built with the same option.
GNU Fortran currently does not make use of any environment
variables to control its operation above and beyond those
that affect the operation of gcc.
See Section Environment Variables Affecting GNU CC of
Changes made to recent versions of GNU Fortran are listed below, with the most recent version first.
The changes are generally listed in order:
This order is not strict---for example, some items involve a combination of these elements.
DO loops that
have one or more references to the iteration variable,
or to aliases of it, in their control expressions.
For example, DO 10 J=2,J now is compiled correctly.
The x87 coprocessor stack was being
mismanaged in cases involving assigned GOTO
and ASSIGN.
DTime intrinsic so as not to truncate
results to integer values (on some systems).
SIGNAL intrinsic so it offers portable
support for 64-bit systems (such as Digital Alphas
running GNU/Linux).
NAMELIST on 64-bit
machines such as Alphas.
g77 version of libf2c so it no longer
produces a spurious I/O recursion diagnostic at run time
when an I/O operation (such as READ *,I) is interrupted
in a manner that causes the program to be terminated
via the f_exit routine (such as via C-c).
g77 crash triggered by CASE statement with
an omitted lower or upper bound.
g77 crash compiling references to CPU_Time
intrinsic.
g77 crash
(or apparently infinite run-time)
when compiling certain complicated expressions
involving COMPLEX arithmetic
(especially multiplication).
g77 crash on statements such as
PRINT *, (REAL(Z(I)),I=1,2), where
Z is DOUBLE COMPLEX.
g++ crash.
INTEGER expression.
g77 -g option so procedures that
use ENTRY can be stepped through, line by line,
in gdb.
gcc back end for
Intel x86 architecture.
REAL argument to intrinsics
Second and CPU_Time.
Int2 and Int8.
tempnam, if available, to open scratch files
(as in OPEN(STATUS='SCRATCH')
so that the TMPDIR environment variable,
if present, is used.
gcc keyword restrict to
__restrict__, to avoid rejecting valid, existing,
C programs.
Support for restrict is now more like support
for complex.
libf2c
so it is more likely that the printing of the
active format string is limited to the string,
with no trailing garbage being printed.
(Unlike f2c, g77 did not append
a null byte to its compiled form of every
format string specified via a FORMAT statement.
However, f2c would exhibit the problem
anyway for a statement like PRINT '(I)garbage', 1
by printing (I)garbage as the format string.)
libf2c for statements like PRINT '(I1', 42.
libf2c.
libf2c as of 1997-09-23.
This fixes a formatted-I/O bug that afflicted
64-bit systems with 32-bit integers
(such as Digital Alpha running GNU/Linux).
gcc (C, C++,
Fortran, and so on).
EQUIVALENCE with a
DATA statement that follows
the first executable statement (or is
treated as an executable-context statement
as a result of using the -fpedantic
option).
gcc back end issues a warning about such a case.
This bug afflicted all code compiled by
version 2.7.2.2.f.2 of gcc (C, C++,
Fortran, and so on).
DATA
or similar to initialize a COMPLEX variable or
array to zero.
AND, OR,
or XOR intrinsics.
COMMON
or EQUIVALENCE variable
as the target of an ASSIGN
or assigned-GOTO statement.
SAVE or the -fno-automatic option
is in effect.
This avoids a compiler crash in some cases.
DOUBLE PRECISION optimally on Pentium and
Pentium Pro architectures (586 and 686 in gcc).
The default is to issue such warnings, which are
new as of this version of g77.
The default is to issue such diagnostics and flag the compilation as unsuccessful. With this option, the diagnostics are issued as warnings, or, if -Wno-globals is specified, are not issued at all.
This option also disables inlining of global procedures, to avoid compiler crashes resulting from coding errors that these diagnostics normally would identify.
g77 rejected a
second initialization specification immediately
following the first's closing / without
an intervening comma in a DATA statement,
and the second specification was an implied-DO list.
gcc back end so
certain complicated expressions involving COMPLEX
arithmetic (especially multiplication) don't appear to
take forever to compile.
gcc
back end.
gcc fixes that seem useful in
g77's version of gcc.
(See gcc/ChangeLog for details---compare it
to that file in the vanilla gcc-2.7.2.3.tar.gz
distribution.)
libU77 routines that accept file and other names
to strip trailing blanks from them, for consistency
with other implementations.
Blanks may be forcibly appended to such names by
appending a single null character (CHAR(0))
to the significant trailing blanks.
CHMOD intrinsic to work with file names
that have embedded blanks, commas, and so on.
SIGNAL intrinsic so it accepts an
optional third Status argument.
IDATE() intrinsic subroutine (VXT form)
so it accepts arguments in the correct order.
Documentation fixed accordingly, and for
GMTIME() and LTIME() as well.
libU77 intrinsics to
support existing code more directly.
Such changes include allowing both subroutine and
function forms of many routines, changing MCLOCK()
and TIME() to return INTEGER(KIND=1) values,
introducing MCLOCK8() and TIME8() to
return INTEGER(KIND=2) values,
and placing functions that are intended to perform
side effects in a new intrinsic group, badu77.
libU77 so it is more portable.
g77 and gcc now do a somewhat better
job detecting and diagnosing arrays that are too
large to handle before these cause diagnostics
during the assembler or linker phase, a compiler
crash, or generation of incorrect code.
restrict keyword in gcc
front end.
gcc version 2.7.2.3
(modified by g77 into version 2.7.2.3.f.1),
and remove
support for prior versions of gcc.
gcc back
end into g77's, so GNAT users do not need
to apply GNAT's patches to build both GNAT and g77
from the same source tree.
make rules and related code so that
generation of Info documentation doesn't require
compilation using gcc.
Now, any ANSI C compiler should be adequate to
produce the g77 documentation (in particular,
the tables of intrinsics) from scratch.
INT2 and INT8 intrinsics.
CPU_TIME intrinsic.
ALARM intrinsic.
CTIME intrinsic now accepts any INTEGER
argument, not just INTEGER(KIND=2).
gcc specs file.
make rule g77-cross, used only for
cross-compiling.
libf2c build procedure to re-archive library
if previous attempt to archive was interrupted.
gcc to unroll loops only during the last
invocation (of as many as two invocations) of loop
optimization.
g77 driver to recognize -fsyntax-only
as an option that inhibits linking, just like -c or
-S, and to recognize and properly handle the
-nostdlib, -M, -MM, -nodefaultlibs,
and -Xlinker options.
libf2c as of 1997-08-16.
libf2c to consistently and clearly diagnose
recursive I/O (at run time).
g77 driver now prints version information (such as produced
by g77 -v) to stderr instead of stdout.
ratfor command, available
separately.
gcc determines what kind of
system is being configured and what kinds are supported.
For example, GNU Linux/Alpha ELF systems now are directly
supported.
libf2c that come
from netlib.bell-labs.com; give any such files
that aren't quite accurate in g77's version of
libf2c the suffix .netlib.
INTEGER(KIND=0) for future use.
This option specifies that non-decimal-radix
constants using the prefixed-radix form (such as Z'1234')
are to be interpreted as INTEGER constants.
Specify -ftypeless-boz to cause such
constants to be interpreted as typeless.
(Version 0.5.19 introduced -fno-typeless-boz and its inverse.)
Some programs might use names that clash with
intrinsic names defined (and now enabled) by these
options or by the new libU77 intrinsics.
Users of such programs might need to compile them
differently (using, for example, -ff90-intrinsics-disable)
or, better yet, insert appropriate EXTERNAL
statements specifying that these names are not intended
to be names of intrinsics.
libf2c, which should result in improved
I/O performance, especially over NFS.
Note: If you have code that depends on the behavior
of libf2c when built with ALWAYS_FLUSH defined,
you will have to modify libf2c accordingly before
building it from this and future versions of g77.
libU77 has been
added to the version of libf2c distributed with
and built as part of g77.
g77 now knows about the routines in this library
as intrinsics.
If you used one of these deleted options, you should
re-read the pertinent documentation to determine which
options, if any, are appropriate for compiling your
code with this version of g77.
(Enabling all the -fugly-* options is unlikely to be feasible, or sensible, in the future, so users should learn to specify only those -fugly-* options they really need for a particular source file.)
g77 front end and
the gcc back end to better support Alpha (AXP)
machines.
This includes providing at least one bug-fix to the
gcc back end for Alphas.
LOC()
intrinsic and %LOC() construct now return
values of integer type that is the same width (holds
the same number of bits) as the pointer type on the
machine.
On most machines, this won't make a difference, whereas
on Alphas, the type these constructs return is
INTEGER*8 instead of the more common INTEGER*4.
COMPLEX arithmetic in the g77 front
end, to avoid bugs in complex support in the
gcc back end.
New option -fno-emulate-complex
causes g77 to revert the 0.5.19 behavior.
g77 command driver so that g77 -o foo.f
no longer deletes foo.f before issuing other
diagnostics, and so the -x option is properly
handled.
gcc
back end.
This works as it does for gcc itself---program units
may be inlined for invocations that follow them in the same
program unit, as long as the appropriate compile-time
options are specified.
COMMON areas when any of
these are defined (assigned to) by Fortran code.
This can result in faster and/or smaller programs when compiling with optimization enabled, though on some systems this effect is observed only when -fforce-addr also is specified.
New options -falias-check, -fargument-alias,
-fargument-noalias,
and -fno-argument-noalias-global control the
way g77 handles potential aliasing.
CONJG() and DCONJG() intrinsics now
are compiled in-line.
g77 compiler has been changed back to
assume libf2c has no aliasing problems in
its implementations of the COMPLEX (and
DOUBLE COMPLEX) intrinsics.
The libf2c has been changed to have no such
problems.
As a result, 0.5.20 is expected to offer improved performance over 0.5.19.1, perhaps as good as 0.5.19 in most or all cases, due to this change alone.
Note: This change requires version 0.5.20 of
libf2c, at least, when linking code produced
by any versions of g77 other than 0.5.19.1.
Use g77 -v to determine the version numbers
of the libF77, libI77, and libU77
components of the libf2c library.
(If these version numbers are not printed---in
particular, if the linker complains about unresolved
references to names like g77__fvers__---that
strongly suggests your installation has an obsolete
version of libf2c.)
g77 uses a separate memory location
to hold assigned statement labels.)
FORMAT and ENTRY statements now are allowed to
precede IMPLICIT NONE statements.
SELECT CASE on
CHARACTER type, instead of crashing, at compile time.
libf2c archive
(libf2c.a) so that members are added to it
only when truly necessary, so the user that installs
an already-built g77 doesn't need to have write
access to the build tree (whereas the user doing the
build might not have access to install new software
on the system).
gcc version 2.7.2.2
(modified by g77 into version 2.7.2.2.f.2),
and remove
support for prior versions of gcc.
libf2c as of 1997-02-08, and
fix up some of the build procedures.
g77,
fixing minor bugs (such as deletion of any file
named f771 in the parent directory of gcc/).
INTEGER*8 available in
libf2c and f2c.h so that f2c users
may make full use of its features via the g77
version of f2c.h and the INTEGER*8
support routines in the g77 version of libf2c.
g77 driver and libf2c so that g77 -v
yields version information on the library.
SNGL and FLOAT intrinsics now are
specific intrinsics, instead of synonyms for the
generic intrinsic REAL.
REALPART, IMAGPART,
COMPLEX,
LONG, and SHORT.
REALPART, IMAGPART,
and COMPLEX intrinsics.
An old group, dcp, has been removed.
DOUBLE COMPLEX (or any
complex type other than COMPLEX), unless
-ff90 option specifies Fortran 90 interpretation
or new -fugly-complex option, in conjunction with
-fnot-f90, specifies f2c interpretation.
(Hence the menu item M for the node Diagnostics in the top-level menu of the Info documentation.)
These bugs occurred when assigning the result of an operation to a complex variable (or array element) that also served as an input to that operation.
The operations affected by this bug were: CONJG(),
DCONJG(), CCOS(), CDCOS(),
CLOG(), CDLOG(), CSIN(), CDSIN(),
CSQRT(), CDSQRT(), complex division, and
raising a DOUBLE COMPLEX operand to an INTEGER
power.
(The related generic and Z-prefixed intrinsics,
such as ZSIN(), also were affected.)
For example, C = CSQRT(C), Z = Z/C, and Z = Z**I
(where C is COMPLEX and Z is
DOUBLE COMPLEX) have been fixed.
FORMAT statement parsing so negative values for
specifiers such as P (e.g. FORMAT(-1PF8.1))
are correctly processed as negative.
SIGNAL intrinsic so it once again accepts a
procedure as its second argument.
COMMON and EQUIVALENCE members at debug time.
DO loops.
f77 and f2c.
INTEGER constants.
f77 programs.
CHARACTER arrays having
names such as READ, WRITE, GOTO, and
REALFUNCTIONFOO.
EQUIVALENCE areas so certain cases
of valid Fortran programs are not misdiagnosed as improperly
extending the area backwards.
gcc version 2.7.2.1.
libf2c as of 1996-09-26, and
fix up some of the build procedures.
libf2c that might return non-zero
status codes for some operations previously assumed to always
return zero.
This change not only affects how IOSTAT= variables
are set by list-directed I/O, it also affects whether
END= and ERR= labels are reached by these
operations.
FTELL and FSEEK
procedures in libf2c.
fseek_() in libf2c to be more portable
(though, in practice, there might be no systems where this
matters) and to catch invalid whence arguments.
gcc has not been patched
using the patch file provided in the gcc/f/gbe/
subdirectory.
g77 command, to conform to GNU coding guidelines.
Also add printing of g77 version number when
the --verbose (-v) option is used.
EQUIVALENCE
areas to one based on the alphabetically sorted first name
in the list of names for entities placed at the beginning
of the areas.
INTEGER*1,
INTEGER*2, INTEGER*8,
and their LOGICAL equivalents.
(This support works on most, maybe all, gcc targets.)
Thanks to Scott Snyder (snyder@d0sgif.fnal.gov) for providing the patch for this!
Among the missing elements from the support for these features are full intrinsic support and constants.
BYTE and
WORD type-declaration statements.
BYTE corresponds to INTEGER*1,
while WORD corresponds to INTEGER*2.
Thanks to Scott Snyder (snyder@d0sgif.fnal.gov) for providing the patch for this!
INTEGER*8,
for example.
A new option, -fzeros, is introduced to enable the traditional treatment of zeros as any other value.
g77 incorrectly
interpreted REAL(Z) as returning a REAL
result, instead of as a DOUBLE PRECISION
result.
(Here, Z is DOUBLE COMPLEX.)
With -fno-f90 in force, the interpretation remains
unchanged, since this appears to be how at least some
F77 code using the DOUBLE COMPLEX extension expected
it to work.
Essentially, REAL(Z) in F90 is the same as DBLE(Z), while in extended F77, it appears to be the same as REAL(REAL(Z)).
INTEGER and the right-hand operand
was negative, was erroneously evaluated.
DATA implied-DO constructs
(these involved an errant diagnostic and a crash, both on good
code, one involving subsequent statement-function definition).
INCLUDE files after processing them, so compiling source
files with lots of INCLUDE statements does not result in
being unable to open INCLUDE files after all the available
file descriptors are used up.
gcc back end (GBE).
These options are -fmove-all-movables, -freduce-all-givs,
and -frerun-loop-opt, which are enabled, by default,
for Fortran compilations.
These optimizations are intended to help toon Fortran programs.
gcc
also is patched to make it easier to manage installations,
especially useful if it turns out a g77 change to the
GBE has a bug.
The g77-modified version number is the gcc
version number with the string .f.n appended,
where f identifies the version as enhanced for
Fortran, and n is 1 for the first Fortran
patch for that version of gcc, 2 for the
second, and so on.
So, this introduces version 2.7.2.f.1 of gcc.
DO
loops, instead of these being rejected unless -fpedantic
or -fugly specified.
SAVE of a local variable or array, even after
it has been given an initial value via DATA, for example.
g77 documentation, which
supercedes gcc/f/CREDITS, gcc/f/DOC, and
gcc/f/PROJECTS.
These files will be removed in a future release.
The files gcc/f/BUGS, gcc/f/INSTALL, and
gcc/f/NEWS now are automatically built from
the texinfo source when distributions are made.
This effort was inspired by a first pass at translating g77-0.5.16/f/DOC that was contributed to Craig by David Ronis (ronis@onsager.chem.mcgill.ca).
DO loops work to follow
the F90 standard.
In particular, calculation of the iteration count is
still done by converting the start, end, and increment
parameters to the type of the DO variable, but
the result of the calculation is always converted to
the default INTEGER type.
(This should have no effect on existing code compiled
by g77, but code written to assume that use
of a wider type for the DO variable
will result in an iteration count being fully calculated
using that wider type (wider
than default INTEGER) must be rewritten.)
gcc version 2.7.2.
libf2c as of 1996-03-23, and
fix up some of the build procedures.
Note that the email addresses related to f2c
have changed---the distribution site now is
named netlib.bell-labs.com, and the
maintainer's new address is dmg@bell-labs.com.
All users of version 0.5.16 should ensure that they have not removed /dev/null or replaced it with an ordinary file (e.g. by comparing the output of ls -l /dev/null with ls -l /dev/zero. If the output isn't basically the same, contact your system administrator about restoring /dev/null to its proper status).
This bug is particularly insidious because removing /dev/null as a special file can go undetected for quite a while, aside from various applications and programs exhibiting sudden, strange behaviors.
I sincerely apologize for not realizing the
implications of the fact that when g77 -v runs the ld command
with -o /dev/null that ld tries to remove the executable
it is supposed to build (especially if it reports unresolved
references, which it should in this case)!
ASSIGN'ed variables so they can be SAVE'd or dummy arguments,
and issue clearer error message in cases where target of ASSIGN
or ASSIGNed GOTO/FORMAT is too small (which should
never happen).
libf2c build procedures work on more systems again by
eliminating unnecessary invocations of ld -r -x and mv.
IMPLICIT NONE.
INTEGER
constant for the right-hand operator (e.g. I**32767).
g77 (the fini
utility in particular) is properly built using the host compiler.
g77) in ways that
are surprising to many programmers.
ERF() and ERFC() as generic intrinsics mapping to existing
ERF/DERF and ERFC/DERFC specific intrinsics.
Note: You should
specify INTRINSIC ERF,ERFC in any code where you might use
these as generic intrinsics, to improve likelihood of diagnostics
(instead of subtle run-time bugs) when using a compiler that
doesn't support these as intrinsics (e.g. f2c).
DO
with non-INTEGER index variable; issue that under
-Wsurprising instead.
.EQ./.NE. on LOGICAL
operands.
LOGICAL operands.
DO loops on some
machines.
gcc version 2.7.1.
libf2c as of 1995-11-15.
EQUIVALENCE statements
not involving COMMON.
libf2c from code compiled with -fno-f2c by making these
procedures known to g77 as intrinsics (not affected by -fno-f2c).
This is known to fix code invoking ERF(), ERFC(),
DERF(), and DERFC().
libf2c to include netlib patches through 1995-08-16, and
#define WANT_LEAD_0 to 1 to make g77-compiled code more
consistent with other Fortran implementations by outputting
leading zeros in formatted and list-directed output.
f2c plus gcc (but apparently only when using
gcc-2.7.0 or later).
COMPLEX and
DOUBLE COMPLEX FUNCTIONs and doing COMPLEX and
DOUBLE COMPLEX divides, when the result
of the invocation or divide is assigned directly to a variable
that overlaps one or more of the arguments to the invocation or divide.
gcc back end does not support the necessary
mechanics (and the gcc front end rejects the equivalent
construct, as it turns out).
DOUBLE COMPLEX constant to an INTEGER constant power.
DATA,
for example).
g77 driver.
Provide for easy selection of whether to install copy of g77
as f77 to replace the broken code.
gcc driver (affects g77 thereby) to not
gratuitously invoke the
f771 program (e.g. when -E is specified).
INCLUDE statement.
gcc/g77 when
compiling Fortran files.
These options include -p, -pg, -aux-info, -P,
correct setting of version-number macros for preprocessing, full
recognition of -O0, and
automatic insertion of configuration-specific linker specs.
libf2c:
ABORT, DERF, DERFC, ERF, ERFC, EXIT,
FLUSH, GETARG, GETENV, IARGC,
SIGNAL, and SYSTEM.
Note that ABORT, EXIT, FLUSH, SIGNAL, and
SYSTEM are intrinsic subroutines, not functions (since they
have side effects), so to get the return values from SIGNAL
and SYSTEM, append a final argument specifying an INTEGER
variable or array element (e.g. CALL SYSTEM('rm foo',ISTAT)).
LOC() intrinsic out of the vxt group to the new
unix group.
g77 so that g77 -v by itself (or with
certain other options, including -B, -b, -i,
-nostdlib, and -V) reports lots more useful
version info, and so that long-form options gcc accepts are
understood by g77 as well (even in truncated, unambiguous forms).
g77 option --driver=name to specify driver when
default, gcc, isn't appropriate.
gcc, with info such as
In function `foo': and In file included from...:.
gcc's -fident and -fno-ident options.
DATA implied-DO iteration
variables, even though, strictly speaking, these are not uses
of the variables themselves.
g77 might someday start warning about these)---applies
to gcc versions 2.7.0 and later, since earlier versions didn't
warn about unused dummy arguments.
g77 using the native (non-gcc) compiler on certain machines
(but definitely not all machines nor all non-gcc compilers).
Please
do not report bugs showing problems compilers have with
macros defined in gcc/f/target.h and used in places like
gcc/f/expr.c.
INTEGER, REAL, or LOGICAL size
is not 32 bits,
since g77 is known to not work well for such cases (to be
fixed in Version 0.6---see Actual Bugs We Haven't Fixed Yet).
libf2c with -g0, not -g2, in effect
(by default), to produce
smaller library without lots of debugging clutter.
g77 and the back end (such as for DO loops).
REAL when
the -ff2c option is in force (which it is by default) so that
f2c compatibility is indeed provided.
gcc back end is to be fixed to do this even better, and it
turned out to slow down some code in some cases after all.
COMMON and EQUIVALENCE areas with any members given initial
values (e.g. via DATA), uninitialized members now always
initialized to binary zeros (though this is not required by
the standard, and might not be done in future versions
of g77).
Previously, in some COMMON/EQUIVALENCE areas
(essentially those with members of more than one type), the
uninitialized members were initialized to spaces, to
cater to CHARACTER types, but it seems no existing code expects
that, while much existing code expects binary zeros.
DO loops
for cases
where the loop should not execute at all.
(This bug affected cases
where the difference between the begin and end values was less
than the step count, though probably not for floating-point cases.)
DATA implied-DO list.
MVBITS() intrinsic.
DCMPLX() with a single INTEGER argument.
INCLUDE statement, plus gcc's
header.gcc facility for handling systems like MS-DOS.
INCLUDE statement to be continued across multiple lines,
even allow it to coexist with other statements on the same line.
libf2c through 1995-03-15---this
fixes a bug involving infinite loops reading EOF with empty list-directed
I/O list.
g77-specific auto-configuration scripts, code,
and so on,
except for temporary substitutes for bsearch() and strtoul(), as
too many configure/build problems were reported in these areas.
People will have to fix their systems' problems themselves, or at
least somewhere other than g77, which expects a working ANSI C
environment (and, for now, a GNU C compiler to compile g77 itself).
CHARACTER
and Hollerith constants to be interpreted a la GNU C.
Note that
this behavior is somewhat different from f2c's, which supports only
a limited subset of backslash (escape) sequences.
PARAMETER), and also allows character<->numeric conversion in
those contexts---turn off via -fno-ugly-init.
SAVEd, i.e. made
automatic or static.
IMPLICIT NONE.)
gcc
(i.e. unless -O not specified, since -Wuninitialized
requires -O), and implies -Wunused as well.
EXTERNAL names (since they are assumed to refer to block data
program units, to make use of libraries more reliable).
%LOC() and LOC() of character arguments.
f2c's IMAG() generic intrinsic.
ICHAR(), IACHAR(), and LEN() of
character expressions that are valid in assignments but
not normally as actual arguments.
f2c-style & in column 1 to mean continuation line.
NAMELIST, EXTERNAL, INTRINSIC, and VOLATILE
in BLOCK DATA, even though these are not allowed by the standard.
RETURN in main program unit.
INTEGER (padded on right with spaces if constant
too small, otherwise fully intact if constant wider the INTEGER
type) instead of by value.
Warning: f2c differs on the
interpretation of CALL FOO(1HX), which it treats exactly the
same as CALL FOO('X'), but which the standard and g77 treat
as CALL FOO(%REF('X ')) (padded with as many spaces as necessary
to widen to INTEGER), essentially.
INTEGER value.
INTEGER constant.
%DESCR() of a non-CHARACTER expression now passes a pointer to
the expression plus a length for the expression just as if
it were a CHARACTER expression.
For example, CALL FOO(%DESCR(D)), where
D is REAL*8, is the same as CALL FOO(D,%VAL(8))).
DO loops.
g77 man page.
INTEGER.
SQRT() and DSQRT(),
also when -ffast-math
specified, enable better code generation for SIN() and COS().
This section describes changes to g77 that are visible
to the programmers who actually write and maintain Fortran
code they compile with g77.
Information on changes to installation procedures,
changes to the documentation, and bug fixes is
not provided here, unless it is likely to affect how
users use g77.
See News About GNU Fortran, for information on
such changes to g77.
To find out about existing bugs and ongoing plans for GNU Fortran, retrieve {ftp://alpha.gnu.org/g77.plan} or, if you cannot do that, email fortran@gnu.org asking for a recent copy of the GNU Fortran .plan file.
gcc, g77,
and other GNU compilers that incorporate the gcc
back end as modified by g77, issue
a warning about integer division by constant zero.
The default is to issue such warnings, which are
new as of this version of g77.
The default is to issue such diagnostics and flag the compilation as unsuccessful. With this option, the diagnostics are issued as warnings, or, if -Wno-globals is specified, are not issued at all.
This option also disables inlining of global procedures, to avoid compiler crashes resulting from coding errors that these diagnostics normally would identify.
libU77 routines that accept file names
to strip trailing spaces from them, for consistency
with other implementations.
SIGNAL intrinsic so it accepts an
optional third Status argument.
libU77 intrinsics to
support existing code more directly.
Such changes include allowing both subroutine and
function forms of many routines, changing MCLOCK()
and TIME() to return INTEGER(KIND=1) values,
introducing MCLOCK8() and TIME8() to
return INTEGER(KIND=2) values,
and placing functions that are intended to perform
side effects in a new intrinsic group, badu77.
INT2 and INT8 intrinsics.
CPU_TIME intrinsic.
CTIME intrinsic now accepts any INTEGER
argument, not just INTEGER(KIND=2).
This option specifies that non-decimal-radix
constants using the prefixed-radix form (such as Z'1234')
are to be interpreted as INTEGER(KIND=1) constants.
Specify -ftypeless-boz to cause such
constants to be interpreted as typeless.
(Version 0.5.19 introduced -fno-typeless-boz and its inverse.)
See Options Controlling Fortran Dialect, for information on the -ftypeless-boz option.
Some programs might use names that clash with
intrinsic names defined (and now enabled) by these
options or by the new libU77 intrinsics.
Users of such programs might need to compile them
differently (using, for example, -ff90-intrinsics-disable)
or, better yet, insert appropriate EXTERNAL
statements specifying that these names are not intended
to be names of intrinsics.
libf2c, which should result in improved
I/O performance, especially over NFS.
Note: If you have code that depends on the behavior
of libf2c when built with ALWAYS_FLUSH defined,
you will have to modify libf2c accordingly before
building it from this and future versions of g77.
See Output Assumed To Flush, for more information.
libU77 has been
added to the version of libf2c distributed with
and built by g77.
g77 now knows about the routines in this library
as intrinsics.
See VXT Fortran, for more information on the constructs recognized when the -fvxt option is specified.
If you used one of these deleted options, you should
re-read the pertinent documentation to determine which
options, if any, are appropriate for compiling your
code with this version of g77.
See Other Dialects, for more information.
(Enabling all the -fugly-* options is unlikely to be feasible, or sensible, in the future, so users should learn to specify only those -fugly-* options they really need for a particular source file.)
LOC()
intrinsic and %LOC() construct now return
values of INTEGER(KIND=0) type,
as defined by the GNU Fortran language.
This type is wide enough (holds the same number of bits) as the character-pointer type on the machine.
On most systems, this won't make a noticable difference,
whereas on Alphas and other systems with 64-bit pointers,
the INTEGER(KIND=0) type is equivalent to INTEGER(KIND=2)
(often referred to as INTEGER*8)
instead of the more common INTEGER(KIND=1)
(often referred to as INTEGER*4).
COMPLEX arithmetic in the g77 front
end, to avoid bugs in complex support in the
gcc back end.
New option -fno-emulate-complex
causes g77 to revert the 0.5.19 behavior.
COMMON areas when any of
these are defined (assigned to) by Fortran code.
This can result in faster and/or smaller programs when compiling with optimization enabled, though on some systems this effect is observed only when -fforce-addr also is specified.
New options -falias-check, -fargument-alias,
-fargument-noalias,
and -fno-argument-noalias-global control the
way g77 handles potential aliasing.
See Aliasing Assumed To Work, for detailed information on why the
new defaults might result in some programs no longer working the way they
did when compiled by previous versions of g77.
g77 uses a separate memory location
to hold assigned statement labels.)
See Ugly Assigned Labels, for more information.
FORMAT and ENTRY statements now are allowed to
precede IMPLICIT NONE statements.
INTEGER(KIND=2)
(often referred to as INTEGER*8)
available in
libf2c and f2c.h so that f2c users
may make full use of its features via the g77
version of f2c.h and the INTEGER(KIND=2)
support routines in the g77 version of libf2c.
g77 driver and libf2c so that g77 -v
yields version information on the library.
SNGL and FLOAT intrinsics now are
specific intrinsics, instead of synonyms for the
generic intrinsic REAL.
REALPART, IMAGPART,
COMPLEX,
LONG, and SHORT.
REALPART, IMAGPART,
and COMPLEX intrinsics.
An old group, dcp, has been removed.
COMMON and EQUIVALENCE members at debug time.
See Options for Code Generation Conventions,
for information on the -fdebug-kludge option.
DO loops.
f77 and f2c.
INTEGER(KIND=1) constants.
f77 programs.
libf2c that might return non-zero
status codes for some operations previously assumed to always
return zero.
This change not only affects how IOSTAT= variables
are set by list-directed I/O, it also affects whether
END= and ERR= labels are reached by these
operations.
FTELL and FSEEK
procedures in libf2c.
g77 command, to conform to GNU coding guidelines.
Also add printing of g77 version number when
the --verbose (-v) option is used.
BYTE and WORD statements now are supported,
to a limited extent.
INTEGER*1, INTEGER*2, INTEGER*8,
and their LOGICAL
equivalents, now are supported to a limited extent.
Among the missing elements are complete intrinsic and constant
support.
g77-aware GNU compilers----fmove-all-movables,
-freduce-all-givs, and -frerun-loop-opt---which
can improve the run-time performance of some programs.
ERF() and ERFC() intrinsics now are generic
intrinsics, mapping to ERF/DERF and
ERFC/DERFC, respectively.
Note: Use INTRINSIC ERF,ERFC in any code that
might reference these as generic intrinsics, to
improve the likelihood of diagnostics (instead of subtle run-time
bugs) when using compilers that don't support these as intrinsics.
INTEGER variables now diagnosed only when
-Wsurprising specified.
Previously, this was diagnosed unless -fpedantic or
-fugly was specified.
libf2c changed to output a leading zero (0) digit for floating-point
values output via list-directed and formatted output (to bring g77
more into line with many existing Fortran implementations---the
ANSI FORTRAN 77 standard leaves this choice to the implementation).
libf2c no longer built with debugging information
intact, making it much smaller.
g77 command now works.
gcc,
including messages like In function `foo': and In file
included from...:.
ABORT,
DERF, DERFC, ERF, ERFC, EXIT,
FLUSH, GETARG, GETENV, SIGNAL, and
SYSTEM.
g77 command.
gcc options -fident and -fno-ident
added.
g77 command to better fulfill its role as
a front-end to the gcc driver.
For example, g77 now
recognizes --verbose as a verbose way of specifying -v.
GNU Fortran supports a variety of extensions to, and dialects
of, the Fortran language.
Its primary base is the ANSI FORTRAN 77 standard, currently available on
the network at {http://kumo.swcp.com/fortran/F77_std/f77_std.html}
or in {ftp://ftp.ast.cam.ac.uk/pub/michael/}.
It offers some extensions that are popular among users
of UNIX f77 and f2c compilers, some that
are popular among users of other compilers (such as Digital
products), some that are popular among users of the
newer Fortran 90 standard, and some that are introduced
by GNU Fortran.
(If you need a text on Fortran, a few freely available electronic references have pointers from {http://www.fortran.com/fortran/Books/}.)
Part of what defines a particular implementation of a Fortran
system, such as g77, is the particular characteristics
of how it supports types, constants, and so on.
Much of this is left up to the implementation by the various
Fortran standards and accepted practice in the industry.
The GNU Fortran language is described below. Much of the material is organized along the same lines as the ANSI FORTRAN 77 standard itself.
See Other Dialects, for information on features g77 supports
that are not part of the GNU Fortran language.
Note: This portion of the documentation definitely needs a lot of work!
The purpose of the following description of the GNU Fortran language is to promote wide portability of GNU Fortran programs.
GNU Fortran is an evolving language, due to the
fact that g77 itself is in beta test.
Some current features of the language might later
be redefined as dialects of Fortran supported by g77
when better ways to express these features are added to g77,
for example.
Such features would still be supported by
g77, but would be available only when
one or more command-line options were used.
The GNU Fortran language is distinct from the
GNU Fortran compilation system (g77).
For example, g77 supports various dialects of
Fortran---in a sense, these are languages other than
GNU Fortran---though its primary
purpose is to support the GNU Fortran language, which also is
described in its documentation and by its implementation.
On the other hand, non-GNU compilers might offer support for the GNU Fortran language, and are encouraged to do so.
Currently, the GNU Fortran language is a fairly fuzzy object.
It represents something of a cross between what g77 accepts
when compiling using the prevailing defaults and what this
document describes as being part of the language.
Future versions of g77 are expected to clarify the
definition of the language in the documentation.
Often, this will mean adding new features to the language, in the form
of both new documentation and new support in g77.
However, it might occasionally mean removing a feature
from the language itself to ``dialect'' status.
In such a case, the documentation would be adjusted
to reflect the change, and g77 itself would likely be changed
to require one or more command-line options to continue supporting
the feature.
The development of the GNU Fortran language is intended to strike a balance between:
f77.
One of the biggest practical challenges for the developers of the GNU Fortran language is meeting the sometimes contradictory demands of the above items.
For example, a feature might be widely used in one popular environment, but the exact same code that utilizes that feature might not work as expected---perhaps it might mean something entirely different---in another popular environment.
Traditionally, Fortran compilers---even portable ones---have solved this problem by simply offering the appropriate feature to users of the respective systems. This approach treats users of various Fortran systems and dialects as remote ``islands'', or camps, of programmers, and assume that these camps rarely come into contact with each other (or, especially, with each other's code).
Project GNU takes a radically different approach to software and language design, in that it assumes that users of GNU software do not necessarily care what kind of underlying system they are using, regardless of whether they are using software (at the user-interface level) or writing it (for example, writing Fortran or C code).
As such, GNU users rarely need consider just what kind of underlying hardware (or, in many cases, operating system) they are using at any particular time. They can use and write software designed for a general-purpose, widely portable, heteregenous environment---the GNU environment.
In line with this philosophy, GNU Fortran must evolve into a product that is widely ported and portable not only in the sense that it can be successfully built, installed, and run by users, but in the larger sense that its users can use it in the same way, and expect largely the same behaviors from it, regardless of the kind of system they are using at any particular time.
This approach constrains the solutions g77 can use to resolve
conflicts between various camps of Fortran users.
If these two camps disagree about what a particular construct should
mean, g77 cannot simply be changed to treat that particular construct as
having one meaning without comment (such as a warning), lest the users
expecting it to have the other meaning are unpleasantly surprised that
their code misbehaves when executed.
The use of the ASCII backslash character in character constants is
an excellent (and still somewhat unresolved) example of this kind of
controversy.
See Backslash in Constants.
Other examples are likely to arise in the future, as g77 developers
strive to improve its ability to accept an ever-wider variety of existing
Fortran code without requiring significant modifications to said code.
Development of GNU Fortran is further constrained by the desire
to avoid requiring programmers to change their code.
This is important because it allows programmers, administrators,
and others to more faithfully evaluate and validate g77
(as an overall product and as new versions are distributed)
without having to support multiple versions of their programs
so that they continue to work the same way on their existing
systems (non-GNU perhaps, but possibly also earlier versions
of g77).
GNU Fortran supports ANSI FORTRAN 77 with the following caveats.
In summary, the only ANSI FORTRAN 77 features g77 doesn't
support are those that are probably rarely used in actual code,
some of which are explicitly disallowed by the Fortran 90 standard.
g77 disallows passing of an external procedure
as an actual argument if the procedure's
type is declared CHARACTER*(*). For example:
CHARACTER*(*) CFUNC EXTERNAL CFUNC CALL FOO(CFUNC) ENDIt isn't clear whether the standard considers this conforming.
g77 disallows passing of a dummy procedure
as an actual argument if the procedure's
type is declared CHARACTER*(*).
SUBROUTINE BAR(CFUNC) CHARACTER*(*) CFUNC EXTERNAL CFUNC CALL FOO(CFUNC) ENDIt isn't clear whether the standard considers this conforming.
The DO variable for an implied-DO construct in a
DATA statement may not be used as the DO variable
for an outer implied-DO construct. For example, this
fragment is disallowed by g77:
DATA ((A(I, I), I= 1, 10), I= 1, 10) /···/This also is disallowed by Fortran 90, as it offers no additional capabilities and would have a variety of possible meanings.
Note that it is very unlikely that any production Fortran code tries to use this unsupported construct.
An array element initializer in an implied-DO construct in a
DATA statement must contain at least one reference to the DO
variables of each outer implied-DO construct. For example,
this fragment is disallowed by g77:
DATA (A, I= 1, 1) /1./This also is disallowed by Fortran 90, as FORTRAN 77's more permissive requirements offer no additional capabilities. However,
g77 doesn't necessarily diagnose all cases
where this requirement is not met.
Note that it is very unlikely that any production Fortran code tries to use this unsupported construct.
(The following information augments or overrides the information in Section 1.4 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 1 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
The definition of the GNU Fortran language is akin to that of the ANSI FORTRAN 77 language in that it does not generally require conforming implementations to diagnose cases where programs do not conform to the language.
However, g77 as a compiler is being developed in a way that
is intended to enable it to diagnose such cases in an easy-to-understand
manner.
A program that conforms to the GNU Fortran language should, when
compiled, linked, and executed using a properly installed g77
system, perform as described by the GNU Fortran language definition.
Reasons for different behavior include, among others:
g77.
Despite these ``loopholes'', the availability of a clear specification
of the language of programs submitted to g77, as this document
is intended to provide, is considered an important aspect of providing
a robust, clean, predictable Fortran implementation.
The definition of the GNU Fortran language, while having no special
legal status, can therefore be viewed as a sort of contract, or agreement.
This agreement says, in essence, ``if you write a program in this language,
and run it in an environment (such as a g77 system) that supports
this language, the program should behave in a largely predictable way''.
(The following information augments or overrides the information in Section 1.5 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 1 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
In this chapter, ``must'' denotes a requirement, ``may'' denotes permission, and ``must not'' and ``may not'' denote prohibition. Terms such as ``might'', ``should'', and ``can'' generally add little or nothing in the way of weight to the GNU Fortran language itself, but are used to explain or illustrate the language.
For example:
``The FROBNITZ statement must precede all executable
statements in a program unit, and may not specify any dummy
arguments. It may specify local or common variables and arrays.
Its use should be limited to portions of the program designed to
be non-portable and system-specific, because it might cause the
containing program unit to behave quite differently on different
systems.''
Insofar as the GNU Fortran language is specified,
the requirements and permissions denoted by the above sample statement
are limited to the placement of the statement and the kinds of
things it may specify.
The rest of the statement---the content regarding non-portable portions
of the program and the differing behavior of program units containing
the FROBNITZ statement---does not pertain the GNU Fortran
language itself.
That content offers advice and warnings about the FROBNITZ
statement.
Remember: The GNU Fortran language definition specifies both what constitutes a valid GNU Fortran program and how, given such a program, a valid GNU Fortran implementation is to interpret that program.
It is not incumbent upon a valid GNU Fortran implementation to behave in any particular way, any consistent way, or any predictable way when it is asked to interpret input that is not a valid GNU Fortran program.
Such input is said to have undefined behavior when interpreted by a valid GNU Fortran implementation, though an implementation may choose to specify behaviors for some cases of inputs that are not valid GNU Fortran programs.
Other notation used herein is that of the GNU texinfo format, which is used to generate printed hardcopy, on-line hypertext (Info), and on-line HTML versions, all from a single source document. This notation is used as follows:
COMMON, INTEGER, and
BLOCK DATA.
Note that, in practice, many Fortran programs are written in lowercase---uppercase is used in this manual as a means to readily distinguish keywords and sample Fortran-related text from the prose in this document.
Generally, uppercase is used for all Fortran-specific and Fortran-related text, though this does not always include literal text within Fortran code.
For example: PRINT *, 'My name is Bob'.
``The INTEGER ivar statement specifies that
ivar is a variable or array of type INTEGER.''
In the above example, any valid text may be substituted for the metasyntactic variable ivar to make the statement apply to a specific instance, as long as the same text is substituted for both occurrences of ivar.
See Kind Notation, for information on the relationship
between Fortran 90 nomenclature (such as INTEGER(KIND=1))
and the more traditional, less portably concise nomenclature
(such as INTEGER*4).
(The following information augments or overrides the information in Chapter 2 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 2 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
(Corresponds to Section 2.2 of ANSI X3.9-1978 FORTRAN 77.)
In GNU Fortran, a symbolic name is at least one character long,
and has no arbitrary upper limit on length.
However, names of entities requiring external linkage (such as
external functions, external subroutines, and COMMON areas)
might be restricted to some arbitrary length by the system.
Such a restriction is no more constrained than that of one
through six characters.
Underscores (_) are accepted in symbol names after the first character (which must be a letter).
(Corresponds to Section 2.3 of ANSI X3.9-1978 FORTRAN 77.)
Use of an exclamation point (!) to begin a trailing comment (a comment that extends to the end of the same source line) is permitted under the following conditions:
Use of a semicolon (;) as a statement separator is permitted under the following conditions:
IF statement nor a non-construct
WHERE statement (a Fortran 90 feature) may be
followed (in the same, possibly continued, line) by
a semicolon used as a statement separator.
This restriction avoids the confusion that can result when reading a line such as:
IF (VALIDP) CALL FOO; CALL BARSome readers might think the CALL BAR is executed only if VALIDP is
.TRUE., while others might
assume its execution is unconditional.
(At present, g77 does not diagnose code that
violates this restriction.)
(Corresponds to Section 2.9 of ANSI X3.9-1978 FORTRAN 77.)
Included in the list of entities that have a scope of a program unit are construct names (a Fortran 90 feature). See Construct Names, for more information.
(The following information augments or overrides the information in Chapter 3 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 3 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
(Corresponds to Section 3.1 of ANSI X3.9-1978 FORTRAN 77.)
Letters include uppercase letters (the twenty-six characters of the English alphabet) and lowercase letters (their lowercase equivalent). Generally, lowercase letters may be used in place of uppercase letters, though in character and hollerith constants, they are distinct.
Special characters include:
Note that this document refers to SPC as space, while X3.9-1978 FORTRAN 77 refers to it as blank.
(Corresponds to Section 3.2 of ANSI X3.9-1978 FORTRAN 77.)
The way a Fortran compiler views source files depends entirely on the implementation choices made for the compiler, since those choices are explicitly left to the implementation by the published Fortran standards.
The GNU Fortran language mandates a view applicable to UNIX-like text files---files that are made up of an arbitrary number of lines, each with an arbitrary number of characters (sometimes called stream-based files).
This view does not apply to types of files that are specified as having a particular number of characters on every single line (sometimes referred to as record-based files).
Because a ``line in a program unit is a sequence of 72 characters'', to quote X3.9-1978, the GNU Fortran language specifies that a stream-based text file is translated to GNU Fortran lines as follows:
EOF) also serves to end the line
of text that precedes it (and that does not contain a newline).
For the purposes of the remainder of this description of the GNU Fortran language, the translation described above has already taken place, unless otherwise specified.
The result of the above translation is that the source file appears, in terms of the remainder of this description of the GNU Fortran language, as if it had an arbitrary number of 72-character lines, each character being among the GNU Fortran character set.
For example, if the source file itself has two newlines in a row, the second newline becomes, after the above translation, a single line containing 72 spaces.
(Corresponds to Section 3.2.3 of ANSI X3.9-1978 FORTRAN 77.)
A continuation line is any line that both
A continuation character is any character of the GNU Fortran character set other than space (SPC) or zero (0) in column 6, or a digit (0 through 9) in column 7 through 72 of a line that has only spaces to the left of that digit.
The continuation character is ignored as far as the content of the statement is concerned.
The GNU Fortran language places no limit on the number of continuation lines in a statement. In practice, the limit depends on a variety of factors, such as available memory, statement content, and so on, but no GNU Fortran system may impose an arbitrary limit.
(Corresponds to Section 3.3 of ANSI X3.9-1978 FORTRAN 77.)
Statements may be written using an arbitrary number of continuation lines.
Statements may be separated using the semicolon (;), except
that the logical IF and non-construct WHERE statements
may not be separated from subsequent statements using only a semicolon
as statement separator.
The END PROGRAM, END SUBROUTINE, END FUNCTION,
and END BLOCK DATA statements are alternatives to the END
statement.
These alternatives may be written as normal statements---they are not
subject to the restrictions of the END statement.
However, no statement other than END may have an initial line
that appears to be an END statement---even END PROGRAM,
for example, must not be written as:
END
&PROGRAM
(Corresponds to Section 3.4 of ANSI X3.9-1978 FORTRAN 77.)
A statement separated from its predecessor via a semicolon may be labeled as follows:
A statement may have only one label defined for it.
(Corresponds to Section 3.5 of ANSI X3.9-1978 FORTRAN 77.)
Generally, DATA statements may precede executable statements.
However, specification statements pertaining to any entities
initialized by a DATA statement must precede that DATA
statement.
For example,
after DATA I/1/, INTEGER I is not permitted, but
INTEGER J is permitted.
The last line of a program unit may be an END statement,
or may be:
END PROGRAM statement, if the program unit is a main program.
END SUBROUTINE statement, if the program unit is a subroutine.
END FUNCTION statement, if the program unit is a function.
END BLOCK DATA statement, if the program unit is a block data.
Additional source text may be included in the processing of
the source file via the INCLUDE directive:
INCLUDE filenameThe source text to be included is identified by filename, which is a literal GNU Fortran character constant. The meaning and interpretation of filename depends on the implementation, but typically is a filename.
(g77 treats it as a filename that it searches for
in the current directory and/or directories specified
via the -I command-line option.)
The effect of the INCLUDE directive is as if the
included text directly replaced the directive in the source
file prior to interpretation of the program.
Included text may itself use INCLUDE.
The depth of nested INCLUDE references depends on
the implementation, but typically is a positive integer.
This virtual replacement treats the statements and INCLUDE
directives in the included text as syntactically distinct from
those in the including text.
Therefore, the first non-comment line of the included text
must not be a continuation line.
The included text must therefore have, after the non-comment
lines, either an initial line (statement), an INCLUDE
directive, or nothing (the end of the included text).
Similarly, the including text may end the INCLUDE
directive with a semicolon or the end of the line, but it
cannot follow an INCLUDE directive at the end of its
line with a continuation line.
Thus, the last statement in an included text may not be
continued.
Any statements between two INCLUDE directives on the
same line are treated as if they appeared in between the
respective included texts.
For example:
INCLUDE 'A'; PRINT *, 'B'; INCLUDE 'C'; END PROGRAMIf the text included by INCLUDE 'A' constitutes a PRINT *, 'A' statement and the text included by INCLUDE 'C' constitutes a PRINT *, 'C' statement, then the output of the above sample program would be
A B C(with suitable allowances for how an implementation defines its handling of output).
Included text must not include itself directly or indirectly, regardless of whether the filename used to reference the text is the same.
Note that INCLUDE is not a statement.
As such, it is neither a non-executable or executable
statement.
However, if the text it includes constitutes one or more
executable statements, then the placement of INCLUDE
is subject to effectively the same restrictions as those
on executable statements.
An INCLUDE directive may be continued across multiple
lines as if it were a statement.
This permits long names to be used for filename.
(The following information augments or overrides the information in Chapter 4 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 4 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
To more concisely express the appropriate types for
entities, this document uses the more concise
Fortran 90 nomenclature such as INTEGER(KIND=1)
instead of the more traditional, but less portably concise,
byte-size-based nomenclature such as INTEGER*4,
wherever reasonable.
When referring to generic types---in contexts where the
specific precision and range of a type are not important---this
document uses the generic type names INTEGER, LOGICAL,
REAL, COMPLEX, and CHARACTER.
In some cases, the context requires specification of a particular type. This document uses the KIND= notation to accomplish this throughout, sometimes supplying the more traditional notation for clarification, though the traditional notation might not work the same way on all GNU Fortran implementations.
Use of KIND= makes this document more concise because
g77 is able to define values for KIND= that
have the same meanings on all systems, due to the way the
Fortran 90 standard specifies these values are to be used.
(In particular, that standard permits an implementation to
arbitrarily assign nonnegative values.
There are four distinct sets of assignments: one to the CHARACTER
type; one to the INTEGER type; one to the LOGICAL type;
and the fourth to both the REAL and COMPLEX types.
Implementations are free to assign these values in any order,
leave gaps in the ordering of assignments, and assign more than
one value to a representation.)
This makes KIND= values superior to the values used in non-standard statements such as INTEGER*4, because the meanings of the values in those statements vary from machine to machine, compiler to compiler, even operating system to operating system.
However, use of KIND= is not generally recommended
when writing portable code (unless, for example, the code is
going to be compiled only via g77, which is a widely
ported compiler).
GNU Fortran does not yet have adequate language constructs to
permit use of KIND= in a fashion that would make the
code portable to Fortran 90 implementations; and, this construct
is known to not be accepted by many popular FORTRAN 77
implementations, so it cannot be used in code that is to be ported
to those.
The distinction here is that this document is able to use specific values for KIND= to concisely document the types of various operations and operands.
A Fortran program should use the FORTRAN 77 designations for the
appropriate GNU Fortran types---such as INTEGER for
INTEGER(KIND=1), REAL for REAL(KIND=1),
and DOUBLE COMPLEX for COMPLEX(KIND=2)---and,
where no such designations exist, make use of appropriate
techniques (preprocessor macros, parameters, and so on)
to specify the types in a fashion that may be easily adjusted
to suit each particular implementation to which the program
is ported.
(These types generally won't need to be adjusted for ports of
g77.)
Further details regarding GNU Fortran data types and constants are provided below.
(Corresponds to Section 4.1 of ANSI X3.9-1978 FORTRAN 77.)
GNU Fortran supports these types:
INTEGER)
REAL)
COMPLEX)
LOGICAL)
CHARACTER)
(The types numbered 1 through 6 above are standard FORTRAN 77 types.)
The generic types shown above are referred to in this document using only their generic type names. Such references usually indicate that any specific type (kind) of that generic type is valid.
For example, a context described in this document as accepting
the COMPLEX type also is likely to accept the
DOUBLE COMPLEX type.
The GNU Fortran language supports three ways to specify a specific kind of a generic type.
The GNU Fortran language supports two uses of the keyword
DOUBLE to specify a specific kind of type:
DOUBLE PRECISION, equivalent to REAL(KIND=2)
DOUBLE COMPLEX, equivalent to COMPLEX(KIND=2)
Use one of the above forms where a type name is valid.
While use of this notation is popular, it doesn't scale well in a language or dialect rich in intrinsic types, as is the case for the GNU Fortran language (especially planned future versions of it).
After all, one rarely sees type names such as DOUBLE INTEGER,
QUADRUPLE REAL, or QUARTER INTEGER.
Instead, INTEGER*8, REAL*16, and INTEGER*1
often are substituted for these, respectively, even though they
do not always have the same meanings on all systems.
(And, the fact that DOUBLE REAL does not exist as such
is an inconsistency.)
Therefore, this document uses ``double notation'' only on occasion for the benefit of those readers who are accustomed to it.
The following notation specifies the storage size for a type:
generic-type*ngeneric-type must be a generic type---one of
INTEGER, REAL, COMPLEX, LOGICAL,
or CHARACTER.
n must be one or more digits comprising a decimal
integer number greater than zero.
Use the above form where a type name is valid.
The *n notation specifies that the amount of storage
occupied by variables and array elements of that type is n
times the storage occupied by a CHARACTER*1 variable.
This notation might indicate a different degree of precision and/or range for such variables and array elements, and the functions that return values of types using this notation. It does not limit the precision or range of values of that type in any particular way---use explicit code to do that.
Further, the GNU Fortran language requires no particular values
for n to be supported by an implementation via the *n
notation.
g77 supports INTEGER*1 (as INTEGER(KIND=3))
on all systems, for example,
but not all implementations are required to do so, and g77
is known to not support REAL*1 on most (or all) systems.
As a result, except for generic-type of CHARACTER,
uses of this notation should be limited to isolated
portions of a program that are intended to handle system-specific
tasks and are expected to be non-portable.
(Standard FORTRAN 77 supports the *n notation for
only CHARACTER, where it signifies not only the amount
of storage occupied, but the number of characters in entities
of that type.
However, almost all Fortran compilers have supported this
notation for generic types, though with a variety of meanings
for n.)
Specifications of types using the *n notation always are interpreted as specifications of the appropriate types described in this document using the KIND=n notation, described below.
While use of this notation is popular, it doesn't serve well in the context of a widely portable dialect of Fortran, such as the GNU Fortran language.
For example, even on one particular machine, two or more popular
Fortran compilers might well disagree on the size of a type
declared INTEGER*2 or REAL*16.
Certainly there
is known to be disagreement over such things among Fortran
compilers on different systems.
Further, this notation offers no elegant way to specify sizes
that are not even multiples of the ``byte size'' typically
designated by INTEGER*1.
Use of ``absurd'' values (such as INTEGER*1000) would
certainly be possible, but would perhaps be stretching the original
intent of this notation beyond the breaking point in terms
of widespread readability of documentation and code making use
of it.
Therefore, this document uses ``star notation'' only on occasion for the benefit of those readers who are accustomed to it.
The following notation specifies the kind-type selector of a type:
generic-type(KIND=n)Use the above form where a type name is valid.
generic-type must be a generic type---one of
INTEGER, REAL, COMPLEX, LOGICAL,
or CHARACTER.
n must be an integer initialization expression that
is a positive, nonzero value.
Programmers are discouraged from writing these values directly
into their code.
Future versions of the GNU Fortran language will offer
facilities that will make the writing of code portable
to g77 and Fortran 90 implementations simpler.
However, writing code that ports to existing FORTRAN 77 implementations depends on avoiding the KIND= construct.
The KIND= construct is thus useful in the context of GNU Fortran for two reasons:
The values of n in the GNU Fortran language are assigned using a scheme that:
The assignment system accomplishes this by assigning to each ``fundamental meaning'' of a specific type a unique prime number. Combinations of fundamental meanings---for example, a type that is two times the size of some other type---are assigned values of n that are the products of the values for those fundamental meanings.
A prime value of n is never given more than one fundamental meaning, to avoid situations where some code or system cannot reasonably provide those meanings in the form of a single type.
The values of n assigned so far are:
The planned future use is for this value to designate, explicitly, context-sensitive kind-type selection. For example, the expression 1D0 * 0.1_0 would be equivalent to 1D0 * 0.1D0.
REAL, INTEGER, LOGICAL, COMPLEX,
and CHARACTER, as appropriate.
These are the ``default'' types described in the Fortran 90 standard, though that standard does not assign any particular KIND= value to these types.
(Typically, these are REAL*4, INTEGER*4,
LOGICAL*4, and COMPLEX*8.)
REAL(KIND=2) is DOUBLE PRECISION (typically REAL*8),
COMPLEX(KIND=2) is DOUBLE COMPLEX (typically COMPLEX*16),
These are the ``double precision'' types described in the Fortran 90 standard, though that standard does not assign any particular KIND= value to these types.
n of 4 thus corresponds to types that occupy four times as much storage as the default types, n of 8 to types that occupy eight times as much storage, and so on.
The INTEGER(KIND=2) and LOGICAL(KIND=2) types
are not necessarily supported by every GNU Fortran implementation.
CHARACTER type,
which is the same effective type as CHARACTER(KIND=1)
(making that type effectively the same as CHARACTER(KIND=3)).
(Typically, these are INTEGER*1 and LOGICAL*1.)
n of 6 thus corresponds to types that occupy twice as much storage as the n=3 types, n of 12 to types that occupy four times as much storage, and so on.
These are not necessarily supported by every GNU Fortran implementation.
(Typically, these are INTEGER*2 and LOGICAL*2.)
n of 25 thus corresponds to types that occupy one-quarter as much storage as the default types.
These are not necessarily supported by every GNU Fortran implementation.
INTEGER(KIND=7) and
denotes the INTEGER type that has the smallest
storage size that holds a pointer on the system.
A pointer representable by this type is capable of uniquely
addressing a CHARACTER*1 variable, array, array element,
or substring.
(Typically this is equivalent to INTEGER*4 or,
on 64-bit systems, INTEGER*8.
In a compatible C implementation, it typically would
be the same size and semantics of the C type void *.)
Note that these are proposed correspondences and might change
in future versions of g77---avoid writing code depending
on them while g77, and therefore the GNU Fortran language
it defines, is in beta testing.
Values not specified in the above list are reserved to future versions of the GNU Fortran language.
Implementation-dependent meanings will be assigned new, unique prime numbers so as to not interfere with other implementation-dependent meanings, and offer the possibility of increasing the portability of code depending on such types by offering support for them in other GNU Fortran implementations.
Other meanings that might be given unique values are:
For example, some compilers offer options that cause
INTEGER types to occupy the amount of storage
that would be needed for INTEGER(KIND=2) types, but the
range remains that of INTEGER(KIND=1).
INTEGER(KIND=1).
These could permit, conceptually, use of portable code and
implementations on data files written by existing systems.
Future prime numbers should be given meanings in as incremental a fashion as possible, to allow for flexibility and expressiveness in combining types.
For example, instead of defining a prime number for little-endian IEEE doubles, one prime number might be assigned the meaning ``little-endian'', another the meaning ``IEEE double'', and the value of n for a little-endian IEEE double would thus naturally be the product of those two respective assigned values. (It could even be reasonable to have IEEE values result from the products of prime values denoting exponent and fraction sizes and meanings, hidden bit usage, availability and representations of special values such as subnormals, infinities, and Not-A-Numbers (NaNs), and so on.)
This assignment mechanism, while not inherently required for future versions of the GNU Fortran language, is worth using because it could ease management of the ``space'' of supported types much easier in the long run.
The above approach suggests a mechanism for specifying inheritance of intrinsic (built-in) types for an entire, widely portable product line. It is certainly reasonable that, unlike programmers of other languages offering inheritance mechanisms that employ verbose names for classes and subclasses, along with graphical browsers to elucidate the relationships, Fortran programmers would employ a mechanism that works by multiplying prime numbers together and finding the prime factors of such products.
Most of the advantages for the above scheme have been explained above. One disadvantage is that it could lead to the defining, by the GNU Fortran language, of some fairly large prime numbers. This could lead to the GNU Fortran language being declared ``munitions'' by the United States Department of Defense.
(Corresponds to Section 4.2 of ANSI X3.9-1978 FORTRAN 77.)
A typeless constant has one of the following forms:
'binary-digits'B 'octal-digits'O 'hexadecimal-digits'Z 'hexadecimal-digits'Xbinary-digits, octal-digits, and hexadecimal-digits are nonempty strings of characters in the set 01, 01234567, and 0123456789ABCDEFabcdef, respectively. (The value for A (and a) is 10, for B and b is 11, and so on.)
Typeless constants have values that depend on the context in which they are used.
All other constants, called typed constants, are interpreted---converted to internal form---according to their inherent type. Thus, context is never a determining factor for the type, and hence the interpretation, of a typed constant. (All constants in the ANSI FORTRAN 77 language are typed constants.)
For example, 1 is always type INTEGER(KIND=1) in GNU
Fortran (called default INTEGER in Fortran 90),
9.435784839284958 is always type REAL(KIND=1) (even if the
additional precision specified is lost, and even when used in a
REAL(KIND=2) context), 1E0 is always type REAL(KIND=2),
and 1D0 is always type REAL(KIND=2).
(Corresponds to Section 4.3 of ANSI X3.9-1978 FORTRAN 77.)
An integer constant also may have one of the following forms:
B'binary-digits' O'octal-digits' Z'hexadecimal-digits' X'hexadecimal-digits'binary-digits, octal-digits, and hexadecimal-digits are nonempty strings of characters in the set 01, 01234567, and 0123456789ABCDEFabcdef, respectively. (The value for A (and a) is 10, for B and b is 11, and so on.)
(Corresponds to Section 4.8 of ANSI X3.9-1978 FORTRAN 77.)
A character constant may be delimited by a pair of double quotes (") instead of apostrophes. In this case, an apostrophe within the constant represents a single apostrophe, while a double quote is represented in the source text of the constant by two consecutive double quotes with no intervening spaces.
A character constant may be empty (have a length of zero).
A character constant may include a substring specification, The value of such a constant is the value of the substring---for example, the value of 'hello'(3:5) is the same as the value of 'llo'.
(The following information augments or overrides the information in Chapter 6 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 6 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
%LOC() Construct%LOC(arg)
The %LOC() construct is an expression
that yields the value of the location of its argument,
arg, in memory.
The size of the type of the expression depends on the system---typically,
it is equivalent to either INTEGER(KIND=1) or INTEGER(KIND=2),
though it is actually type INTEGER(KIND=7).
The argument to %LOC() must be suitable as the
left-hand side of an assignment statement.
That is, it may not be a general expression involving
operators such as addition, subtraction, and so on,
nor may it be a constant.
Use of %LOC() is recommended only for code that
is accessing facilities outside of GNU Fortran, such as
operating system or windowing facilities.
It is best to constrain such uses to isolated portions of
a program---portions that deal specifically and exclusively
with low-level, system-dependent facilities.
Such portions might well provide a portable interface for
use by the program as a whole, but are themselves not
portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.
Do not depend on %LOC() returning a pointer that
can be safely used to define (change) the argument.
While this might work in some circumstances, it is hard
to predict whether it will continue to work when a program
(that works using this unsafe behavior)
is recompiled using different command-line options or
a different version of g77.
Generally, %LOC() is safe when used as an argument
to a procedure that makes use of the value of the corresponding
dummy argument only during its activation, and only when
such use is restricted to referencing (reading) the value
of the argument to %LOC().
Implementation Note: Currently, g77 passes
arguments (those not passed using a construct such as %VAL())
by reference or descriptor, depending on the type of
the actual argument.
Thus, given INTEGER I, CALL FOO(I) would
seem to mean the same thing as CALL FOO(%LOC(I)), and
in fact might compile to identical code.
However, CALL FOO(%LOC(I)) emphatically means ``pass the
address of I in memory''.
While CALL FOO(I) might use that same approach in a
particular version of g77, another version or compiler
might choose a different implementation, such as copy-in/copy-out,
to effect the desired behavior---and which will therefore not
necessarily compile to the same code as would CALL FOO(%LOC(I))
using the same version or compiler.
See Debugging and Interfacing, for detailed information on
how this particular version of g77 implements various
constructs.
(The following information augments or overrides the information in Chapter 8 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 8 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
NAMELIST StatementThe NAMELIST statement, and related I/O constructs, are
supported by the GNU Fortran language in essentially the same
way as they are by f2c.
DOUBLE COMPLEX StatementDOUBLE COMPLEX is a type-statement (and type) that
specifies the type COMPLEX(KIND=2) in GNU Fortran.
(The following information augments or overrides the information in Chapter 11 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 11 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
The DO WHILE statement, a feature of both the MIL-STD 1753 and
Fortran 90 standards, is provided by the GNU Fortran language.
The END DO statement is provided by the GNU Fortran language.
This statement is used in one of two ways:
DO loop started with a DO statement
that specifies no termination label.
DO loops, all of which start with a
DO statement that specify the label defined for the
END DO statement.
This kind of END DO statement is merely a synonym for
CONTINUE, except it is permitted only when the statement
is labeled and a target of one or more labeled DO loops.
It is expected that this use of END DO will be removed from
the GNU Fortran language in the future, though it is likely that
it will long be supported by g77 as a dialect form.
The GNU Fortran language supports construct names as defined by the Fortran 90 standard. These names are local to the program unit and are defined as follows:
construct-name: block-statementHere, construct-name is the construct name itself; its definition is connoted by the single colon (:); and block-statement is an
IF, DO,
or SELECT CASE statement that begins a block.
A block that is given a construct name must also specify the same construct name in its termination statement:
END block construct-nameHere, block must be
IF, DO, or SELECT,
as appropriate.
CYCLE and EXIT StatementsThe CYCLE and EXIT statements specify that
the remaining statements in the current iteration of a
particular active (enclosing) DO loop are to be skipped.
CYCLE specifies that these statements are skipped,
but the END DO statement that marks the end of the
DO loop be executed---that is, the next iteration,
if any, is to be started.
If the statement marking the end of the DO loop is
not END DO---in other words, if the loop is not
a block DO---the CYCLE statement does not
execute that statement, but does start the next iteration (if any).
EXIT specifies that the loop specified by the
DO construct is terminated.
The DO loop affected by CYCLE and EXIT
is the innermost enclosing DO loop when the following
forms are used:
CYCLE EXIT
Otherwise, the following forms specify the construct name
of the pertinent DO loop:
CYCLE construct-name EXIT construct-name
CYCLE and EXIT can be viewed as glorified GO TO
statements.
However, they cannot be easily thought of as GO TO statements
in obscure cases involving FORTRAN 77 loops.
For example:
DO 10 I = 1, 5
DO 10 J = 1, 5
IF (J .EQ. 5) EXIT
DO 10 K = 1, 5
IF (K .EQ. 3) CYCLE
10 PRINT *, 'I=', I, ' J=', J, ' K=', K
20 CONTINUE
In particular, neither the EXIT nor CYCLE statements
above are equivalent to a GO TO statement to either label
10 or 20.
To understand the effect of CYCLE and EXIT in the
above fragment, it is helpful to first translate it to its equivalent
using only block DO loops:
DO I = 1, 5
DO J = 1, 5
IF (J .EQ. 5) EXIT
DO K = 1, 5
IF (K .EQ. 3) CYCLE
10 PRINT *, 'I=', I, ' J=', J, ' K=', K
END DO
END DO
END DO
20 CONTINUE
Adding new labels allows translation of CYCLE and EXIT
to GO TO so they may be more easily understood by programmers
accustomed to FORTRAN coding:
DO I = 1, 5
DO J = 1, 5
IF (J .EQ. 5) GOTO 18
DO K = 1, 5
IF (K .EQ. 3) GO TO 12
10 PRINT *, 'I=', I, ' J=', J, ' K=', K
12 END DO
END DO
18 END DO
20 CONTINUE
Thus, the CYCLE statement in the innermost loop skips over
the PRINT statement as it begins the next iteration of the
loop, while the EXIT statement in the middle loop ends that
loop but not the outermost loop.
(The following information augments or overrides the information in Chapter 15 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 15 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
%VAL() Construct%VAL(arg)
The %VAL() construct specifies that an argument,
arg, is to be passed by value, instead of by reference
or descriptor.
%VAL() is restricted to actual arguments in
invocations of external procedures.
Use of %VAL() is recommended only for code that
is accessing facilities outside of GNU Fortran, such as
operating system or windowing facilities.
It is best to constrain such uses to isolated portions of
a program---portions the deal specifically and exclusively
with low-level, system-dependent facilities.
Such portions might well provide a portable interface for
use by the program as a whole, but are themselves not
portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.
Implementation Note: Currently, g77 passes
all arguments either by reference or by descriptor.
Thus, use of %VAL() tends to be restricted to cases
where the called procedure is written in a language other
than Fortran that supports call-by-value semantics.
(C is an example of such a language.)
See Procedures (SUBROUTINE and FUNCTION),
for detailed information on
how this particular version of g77 passes arguments
to procedures.
%REF() Construct%REF(arg)
The %REF() construct specifies that an argument,
arg, is to be passed by reference, instead of by
value or descriptor.
%REF() is restricted to actual arguments in
invocations of external procedures.
Use of %REF() is recommended only for code that
is accessing facilities outside of GNU Fortran, such as
operating system or windowing facilities.
It is best to constrain such uses to isolated portions of
a program---portions the deal specifically and exclusively
with low-level, system-dependent facilities.
Such portions might well provide a portable interface for
use by the program as a whole, but are themselves not
portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.
Do not depend on %REF() supplying a pointer to the
procedure being invoked.
While that is a likely implementation choice, other
implementation choices are available that preserve Fortran
pass-by-reference semantics without passing a pointer to
the argument, arg.
(For example, a copy-in/copy-out implementation.)
Implementation Note: Currently, g77 passes
all arguments
(other than variables and arrays of type CHARACTER)
by reference.
Future versions of, or dialects supported by, g77 might
not pass CHARACTER functions by reference.
Thus, use of %REF() tends to be restricted to cases
where arg is type CHARACTER but the called
procedure accesses it via a means other than the method
used for Fortran CHARACTER arguments.
See Procedures (SUBROUTINE and FUNCTION), for detailed information on
how this particular version of g77 passes arguments
to procedures.
%DESCR() Construct%DESCR(arg)
The %DESCR() construct specifies that an argument,
arg, is to be passed by descriptor, instead of by
value or reference.
%DESCR() is restricted to actual arguments in
invocations of external procedures.
Use of %DESCR() is recommended only for code that
is accessing facilities outside of GNU Fortran, such as
operating system or windowing facilities.
It is best to constrain such uses to isolated portions of
a program---portions the deal specifically and exclusively
with low-level, system-dependent facilities.
Such portions might well provide a portable interface for
use by the program as a whole, but are themselves not
portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.
Do not depend on %DESCR() supplying a pointer
and/or a length passed by value
to the procedure being invoked.
While that is a likely implementation choice, other
implementation choices are available that preserve the
pass-by-reference semantics without passing a pointer to
the argument, arg.
(For example, a copy-in/copy-out implementation.)@
And, future versions of g77 might change the
way descriptors are implemented, such as passing a
single argument pointing to a record containing the
pointer/length information instead of passing that same
information via two arguments as it currently does.
Implementation Note: Currently, g77 passes
all variables and arrays of type CHARACTER
by descriptor.
Future versions of, or dialects supported by, g77 might
pass CHARACTER functions by descriptor as well.
Thus, use of %DESCR() tends to be restricted to cases
where arg is not type CHARACTER but the called
procedure accesses it via a means similar to the method
used for Fortran CHARACTER arguments.
See Procedures (SUBROUTINE and FUNCTION), for detailed information on
how this particular version of g77 passes arguments
to procedures.
The ANSI FORTRAN 77 language defines generic and specific intrinsics. In short, the distinctions are:
Typically, a generic intrinsic has a return type that is determined by the type of one or more of its arguments.
The GNU Fortran language generalizes these concepts somewhat,
especially by providing intrinsic subroutines and generic
intrinsics that are treated as either a specific intrinsic subroutine
or a specific intrinsic function (e.g. SECOND).
However, GNU Fortran avoids generalizing this concept to the point where existing code would be accepted as meaning something possibly different than what was intended.
For example, ABS is a generic intrinsic, so all working
code written using ABS of an INTEGER argument
expects an INTEGER return value.
Similarly, all such code expects that ABS of an INTEGER*2
argument returns an INTEGER*2 return value.
Yet, IABS is a specific intrinsic that accepts only
an INTEGER(KIND=1) argument.
Code that passes something other than an INTEGER(KIND=1)
argument to IABS is not valid GNU Fortran code, because
it is not clear what the author intended.
For example, if J is INTEGER(KIND=6), IABS(J)
is not defined by the GNU Fortran language, because the programmer
might have used that construct to mean any of the following, subtly
different, things:
INTEGER(KIND=1) first
(as if IABS(INT(J)) had been written).
INTEGER(KIND=1)
(as if INT(ABS(J)) had been written).
The distinctions matter especially when types and values wider than
INTEGER(KIND=1) (such as INTEGER(KIND=2)), or when
operations performing more ``arithmetic'' than absolute-value, are involved.
The following sample program is not a valid GNU Fortran program, but might be accepted by other compilers. If so, the output is likely to be revealing in terms of how a given compiler treats intrinsics (that normally are specific) when they are given arguments that do not conform to their stated requirements:
PROGRAM JCB002
C Version 1:
C Modified 1997-05-21 (Burley) to accommodate compilers that implement
C INT(I1-I2) as INT(I1)-INT(I2) given INTEGER*2 I1,I2.
C
C Version 0:
C Written by James Craig Burley 1997-02-20.
C Contact via Internet email: burley@gnu.org
C
C Purpose:
C Determine how compilers handle non-standard IDIM
C on INTEGER*2 operands, which presumably can be
C extrapolated into understanding how the compiler
C generally treats specific intrinsics that are passed
C arguments not of the correct types.
C
C If your compiler implements INTEGER*2 and INTEGER
C as the same type, change all INTEGER*2 below to
C INTEGER*1.
C
INTEGER*2 I0, I4
INTEGER I1, I2, I3
INTEGER*2 ISMALL, ILARGE
INTEGER*2 ITOOLG, ITWO
INTEGER*2 ITMP
LOGICAL L2, L3, L4
C
C Find smallest INTEGER*2 number.
C
ISMALL=0
10 I0 = ISMALL-1
IF ((I0 .GE. ISMALL) .OR. (I0+1 .NE. ISMALL)) GOTO 20
ISMALL = I0
GOTO 10
20 CONTINUE
C
C Find largest INTEGER*2 number.
C
ILARGE=0
30 I0 = ILARGE+1
IF ((I0 .LE. ILARGE) .OR. (I0-1 .NE. ILARGE)) GOTO 40
ILARGE = I0
GOTO 30
40 CONTINUE
C
C Multiplying by two adds stress to the situation.
C
ITWO = 2
C
C Need a number that, added to -2, is too wide to fit in I*2.
C
ITOOLG = ISMALL
C
C Use IDIM the straightforward way.
C
I1 = IDIM (ILARGE, ISMALL) * ITWO + ITOOLG
C
C Calculate result for first interpretation.
C
I2 = (INT (ILARGE) - INT (ISMALL)) * ITWO + ITOOLG
C
C Calculate result for second interpretation.
C
ITMP = ILARGE - ISMALL
I3 = (INT (ITMP)) * ITWO + ITOOLG
C
C Calculate result for third interpretation.
C
I4 = (ILARGE - ISMALL) * ITWO + ITOOLG
C
C Print results.
C
PRINT *, 'ILARGE=', ILARGE
PRINT *, 'ITWO=', ITWO
PRINT *, 'ITOOLG=', ITOOLG
PRINT *, 'ISMALL=', ISMALL
PRINT *, 'I1=', I1
PRINT *, 'I2=', I2
PRINT *, 'I3=', I3
PRINT *, 'I4=', I4
PRINT *
L2 = (I1 .EQ. I2)
L3 = (I1 .EQ. I3)
L4 = (I1 .EQ. I4)
IF (L2 .AND. .NOT.L3 .AND. .NOT.L4) THEN
PRINT *, 'Interp 1: IDIM(I*2,I*2) => IDIM(INT(I*2),INT(I*2))'
STOP
END IF
IF (L3 .AND. .NOT.L2 .AND. .NOT.L4) THEN
PRINT *, 'Interp 2: IDIM(I*2,I*2) => INT(DIM(I*2,I*2))'
STOP
END IF
IF (L4 .AND. .NOT.L2 .AND. .NOT.L3) THEN
PRINT *, 'Interp 3: IDIM(I*2,I*2) => DIM(I*2,I*2)'
STOP
END IF
PRINT *, 'Results need careful analysis.'
END
No future version of the GNU Fortran language
will likely permit specific intrinsic invocations with wrong-typed
arguments (such as IDIM in the above example), since
it has been determined that disagreements exist among
many production compilers on the interpretation of
such invocations.
These disagreements strongly suggest that Fortran programmers,
and certainly existing Fortran programs, disagree about the
meaning of such invocations.
The first version of JCB002 didn't accommodate some compilers'
treatment of INT(I1-I2) where I1 and I2 are
INTEGER*2.
In such a case, these compilers apparently convert both
operands to INTEGER*4 and then do an INTEGER*4 subtraction,
instead of doing an INTEGER*2 subtraction on the
original values in I1 and I2.
However, the results of the careful analyses done on the outputs of programs compiled by these various compilers show that they all implement either Interp 1 or Interp 2 above.
Specifically, it is believed that the new version of JCB002 above will confirm that:
f77 compilers all implement Interp 1.
f77 compiler implements Interp 2.
f77 compilers all implement Interp 3.
If you get different results than the above for the stated compilers, or have results for other compilers that might be worth adding to the above list, please let us know the details (compiler product, version, machine, results, and so on).
REAL() and AIMAG() of ComplexThe GNU Fortran language disallows REAL(expr)
and AIMAG(expr),
where expr is any COMPLEX type other than COMPLEX(KIND=1),
except when they are used in the following way:
REAL(REAL(expr)) REAL(AIMAG(expr))The above forms explicitly specify that the desired effect is to convert the real or imaginary part of expr, which might be some
REAL type other than REAL(KIND=1),
to type REAL(KIND=1),
and have that serve as the value of the expression.
The GNU Fortran language offers clearly named intrinsics to extract the real and imaginary parts of a complex entity without any conversion:
REALPART(expr) IMAGPART(expr)
To express the above using typical extended FORTRAN 77,
use the following constructs
(when expr is COMPLEX(KIND=2)):
DBLE(expr) DIMAG(expr)
The FORTRAN 77 language offers no way
to explicitly specify the real and imaginary parts of a complex expression of
arbitrary type, apparently as a result of requiring support for
only one COMPLEX type (COMPLEX(KIND=1)).
The concepts of converting an expression to type REAL(KIND=1) and
of extracting the real part of a complex expression were
thus ``smooshed'' by FORTRAN 77 into a single intrinsic, since
they happened to have the exact same effect in that language
(due to having only one COMPLEX type).
Note: When -ff90 is in effect,
g77 treats REAL(expr), where expr is of
type COMPLEX, as REALPART(expr),
whereas with -fugly-complex -fno-f90 in effect, it is
treated as REAL(REALPART(expr)).
See Ugly Complex Part Extraction, for more information.
CMPLX() of DOUBLE PRECISIONIn accordance with Fortran 90 and at least some (perhaps all)
other compilers, the GNU Fortran language defines CMPLX()
as always returning a result that is type COMPLEX(KIND=1).
This means CMPLX(D1,D2), where D1 and D2
are REAL(KIND=2) (DOUBLE PRECISION), is treated as:
CMPLX(SNGL(D1), SNGL(D2))
(It was necessary for Fortran 90 to specify this behavior
for DOUBLE PRECISION arguments, since that is
the behavior mandated by FORTRAN 77.)
The GNU Fortran language also provides the DCMPLX() intrinsic,
which is provided by some FORTRAN 77 compilers to construct
a DOUBLE COMPLEX entity from of DOUBLE PRECISION
operands.
However, this solution does not scale well when more COMPLEX types
(having various precisions and ranges) are offered by Fortran implementations.
Fortran 90 extends the CMPLX() intrinsic by adding
an extra argument used to specify the desired kind of complex
result.
However, this solution is somewhat awkward to use, and
g77 currently does not support it.
The GNU Fortran language provides a simple way to build a complex value out of two numbers, with the precise type of the value determined by the types of the two numbers (via the usual type-promotion mechanism):
COMPLEX(real, imag)
When real and imag are the same REAL types, COMPLEX()
performs no conversion other than to put them together to form a
complex result of the same (complex version of real) type.
See Complex Intrinsic, for more information.
The GNU Fortran language includes the MIL-STD 1753 intrinsics
BTEST, IAND, IBCLR, IBITS,
IBSET, IEOR, IOR, ISHFT,
ISHFTC, MVBITS, and NOT.
f77/f2c IntrinsicsThe bit-manipulation intrinsics supported by traditional
f77 and by f2c are available in the GNU Fortran language.
These include AND, LSHIFT, OR, RSHIFT,
and XOR.
Also supported are the intrinsics CDABS,
CDCOS, CDEXP, CDLOG, CDSIN,
CDSQRT, DCMPLX, DCONJG, DFLOAT,
DIMAG, DREAL, and IMAG,
ZABS, ZCOS, ZEXP, ZLOG, ZSIN,
and ZSQRT.
(Corresponds to Section 15.10 of ANSI X3.9-1978 FORTRAN 77.)
The GNU Fortran language adds various functions, subroutines, types, and arguments to the set of intrinsic functions in ANSI FORTRAN 77. The complete set of intrinsics supported by the GNU Fortran language is described below.
Note that a name is not treated as that of an intrinsic if it is
specified in an EXTERNAL statement in the same program unit;
if a command-line option is used to disable the groups to which
the intrinsic belongs; or if the intrinsic is not named in an
INTRINSIC statement and a command-line option is used to
hide the groups to which the intrinsic belongs.
So, it is recommended that any reference in a program unit to
an intrinsic procedure that is not a standard FORTRAN 77
intrinsic be accompanied by an appropriate INTRINSIC
statement in that program unit.
This sort of defensive programming makes it more
likely that an implementation will issue a diagnostic rather
than generate incorrect code for such a reference.
The terminology used below is based on that of the Fortran 90 standard, so that the text may be more concise and accurate:
OPTIONAL means the argument may be omitted.
INTENT(IN) means the argument must be an expression
(such as a constant or a variable that is defined upon invocation
of the intrinsic).
INTENT(OUT) means the argument must be definable by the
invocation of the intrinsic (that is, must not be a constant nor
an expression involving operators other than array reference and
substring reference).
INTENT(INOUT) means the argument must be defined prior to,
and definable by, invocation of the intrinsic (a combination of
the requirements of INTENT(IN) and INTENT(OUT).
KIND.
(Note that the empty lines appearing in the menu below
are not intentional---they result from a bug in the
GNU makeinfo program···a program that, if it
did not exist, would leave this document in far worse shape!)
COMPLEX(KIND=1) value.
INTEGER value truncated to whole number (archaic).
INTEGER value rounded to nearest whole number (archaic).
INTEGER value truncated to whole number.
INTEGER(KIND=6) value truncated to whole number.
INTEGER(KIND=2) value truncated to whole number.
INTEGER(KIND=1) (archaic).
INTEGER value rounded to nearest whole number.
REAL(KIND=1).
INTEGER(KIND=6) value truncated to whole number.
CALL Abort()Intrinsic groups:
unix.
Description:
Prints a message and potentially causes a core dump via abort(3).
Abs(A)Abs:
INTEGER or REAL function.
The exact type depends on that of argument A---if A is
COMPLEX, this function's type is REAL
with the same KIND= value as the type of A.
Otherwise, this function's type is the same as that of A.
A: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the absolute value of A.
If A is type COMPLEX, the absolute
value is computed as:
SQRT(REALPART(A)**2, IMAGPART(A)**2)Otherwise, it is computed by negating the A if it is negative, or returning A.
See Sign Intrinsic, for how to explicitly compute the positive or negative form of the absolute value of an expression.
Access(Name, Mode)Access:
INTEGER(KIND=1) function.
Name: CHARACTER; scalar; INTENT(IN).
Mode: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Checks file Name for accessibility in the mode specified by Mode and
returns 0 if the file is accessible in that mode, otherwise an error
code if the file is inaccessible or Mode is invalid.
See access(2).
A null character (CHAR(0)) marks the end of
the name in Name---otherwise,
trailing blanks in Name are ignored.
Mode may be a concatenation of any of the following characters:
AChar(I)AChar:
CHARACTER*1 function.
I: INTEGER; scalar; INTENT(IN).
Intrinsic groups: f2c, f90.
Description:
Returns the ASCII character corresponding to the code specified by I.
See IAChar Intrinsic, for the inverse of this function.
See Char Intrinsic, for the function corresponding to the system's native character set.
ACos(X)ACos:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the arc-cosine (inverse cosine) of X in radians.
See Cos Intrinsic, for the inverse of this function.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL AdjustL to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL AdjustR to use this name for an external procedure.
AImag(Z)AImag:
REAL function.
This intrinsic is valid when argument Z is
COMPLEX(KIND=1).
When Z is any other COMPLEX type,
this intrinsic is valid only when used as the argument to
REAL(), as explained below.
Z: COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the (possibly converted) imaginary part of Z.
Use of AIMAG() with an argument of a type
other than COMPLEX(KIND=1) is restricted to the following case:
REAL(AIMAG(Z))This expression converts the imaginary part of Z to
REAL(KIND=1).
See REAL() and AIMAG() of Complex, for more information.
AInt(A)AInt:
REAL function, the KIND= value of the type being that of argument A.
A: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns A with the fractional portion of its magnitude truncated and its sign preserved. (Also called ``truncation towards zero''.)
See ANInt Intrinsic, for how to round to nearest whole number.
See Int Intrinsic, for how to truncate and then convert
number to INTEGER.
CALL Alarm(Seconds, Handler, Status)Seconds:
INTEGER; scalar; INTENT(IN).
Handler: Signal handler (INTEGER FUNCTION or SUBROUTINE)
or dummy/global INTEGER(KIND=1) scalar.
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Causes external subroutine Handler to be executed after a delay of
Seconds seconds by using alarm(1) to set up a signal and
signal(2) to catch it.
If Status is supplied, it will be
returned with the the number of seconds remaining until any previously
scheduled alarm was due to be delivered, or zero if there was no
previously scheduled alarm.
See Signal Intrinsic (subroutine).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL All to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Allocated to use this name for an external procedure.
ALog(X)ALog:
REAL(KIND=1) function.
X: REAL(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of LOG() that is specific
to one type for X.
See Log Intrinsic.
ALog10(X)ALog10:
REAL(KIND=1) function.
X: REAL(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of LOG10() that is specific
to one type for X.
See Log10 Intrinsic.
AMax0(A-1, A-2, ···, A-n)AMax0:
REAL(KIND=1) function.
A: INTEGER(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MAX() that is specific
to one type for A and a different return type.
See Max Intrinsic.
AMax1(A-1, A-2, ···, A-n)AMax1:
REAL(KIND=1) function.
A: REAL(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MAX() that is specific
to one type for A.
See Max Intrinsic.
AMin0(A-1, A-2, ···, A-n)AMin0:
REAL(KIND=1) function.
A: INTEGER(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MIN() that is specific
to one type for A and a different return type.
See Min Intrinsic.
AMin1(A-1, A-2, ···, A-n)AMin1:
REAL(KIND=1) function.
A: REAL(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MIN() that is specific
to one type for A.
See Min Intrinsic.
AMod(A, P)AMod:
REAL(KIND=1) function.
A: REAL(KIND=1); scalar; INTENT(IN).
P: REAL(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MOD() that is specific
to one type for A.
See Mod Intrinsic.
And(I, J)And:
INTEGER or LOGICAL function, the exact type being the result of cross-promoting the
types of all the arguments.
I: INTEGER or LOGICAL; scalar; INTENT(IN).
J: INTEGER or LOGICAL; scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Returns value resulting from boolean AND of pair of bits in each of I and J.
ANInt(A)ANInt:
REAL function, the KIND= value of the type being that of argument A.
A: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns A with the fractional portion of its magnitude eliminated by rounding to the nearest whole number and with its sign preserved.
A fractional portion exactly equal to .5 is rounded to the whole number that is larger in magnitude. (Also called ``Fortran round''.)
See AInt Intrinsic, for how to truncate to whole number.
See NInt Intrinsic, for how to round and then convert
number to INTEGER.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Any to use this name for an external procedure.
ASin(X)ASin:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the arc-sine (inverse sine) of X in radians.
See Sin Intrinsic, for the inverse of this function.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Associated to use this name for an external procedure.
ATan(X)ATan:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the arc-tangent (inverse tangent) of X in radians.
See Tan Intrinsic, for the inverse of this function.
ATan2(Y, X)ATan2:
REAL function, the exact type being the result of cross-promoting the
types of all the arguments.
Y: REAL; scalar; INTENT(IN).
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the arc-tangent (inverse tangent) of the complex number (Y, X) in radians.
See Tan Intrinsic, for the inverse of this function.
BesJ0(X)BesJ0:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Calculates the Bessel function of the first kind of order 0 of X.
See bessel(3m), on whose implementation the function depends.
BesJ1(X)BesJ1:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Calculates the Bessel function of the first kind of order 1 of X.
See bessel(3m), on whose implementation the function depends.
BesJN(N, X)BesJN:
REAL function, the KIND= value of the type being that of argument X.
N: INTEGER; scalar; INTENT(IN).
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Calculates the Bessel function of the first kind of order N of X.
See bessel(3m), on whose implementation the function depends.
BesY0(X)BesY0:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Calculates the Bessel function of the second kind of order 0 of X.
See bessel(3m), on whose implementation the function depends.
BesY1(X)BesY1:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Calculates the Bessel function of the second kind of order 1 of X.
See bessel(3m), on whose implementation the function depends.
BesYN(N, X)BesYN:
REAL function, the KIND= value of the type being that of argument X.
N: INTEGER; scalar; INTENT(IN).
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Calculates the Bessel function of the second kind of order N of X.
See bessel(3m), on whose implementation the function depends.
Bit_Size(I)Bit_Size:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar.
Intrinsic groups: f90.
Description:
Returns the number of bits (integer precision plus sign bit) represented by the type for I.
See BTest Intrinsic, for how to test the value of a bit in a variable or array.
See IBSet Intrinsic, for how to set a bit in a variable to 1.
See IBClr Intrinsic, for how to set a bit in a variable to 0.
BTest(I, Pos)BTest:
LOGICAL(KIND=1) function.
I: INTEGER; scalar; INTENT(IN).
Pos: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns .TRUE. if bit Pos in I is
1, .FALSE. otherwise.
(Bit 0 is the low-order (rightmost) bit, adding the value 2**0, or 1, to the number if set to 1; bit 1 is the next-higher-order bit, adding 2**1, or 2; bit 2 adds 2**2, or 4; and so on.)
See Bit_Size Intrinsic, for how to obtain the number of bits in a type. The leftmost bit of I is BIT_SIZE(I-1).
CAbs(A)CAbs:
REAL(KIND=1) function.
A: COMPLEX(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ABS() that is specific
to one type for A.
See Abs Intrinsic.
CCos(X)CCos:
COMPLEX(KIND=1) function.
X: COMPLEX(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of COS() that is specific
to one type for X.
See Cos Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Ceiling to use this name for an external procedure.
CExp(X)CExp:
COMPLEX(KIND=1) function.
X: COMPLEX(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of EXP() that is specific
to one type for X.
See Exp Intrinsic.
Char(I)Char:
CHARACTER*1 function.
I: INTEGER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the character corresponding to the code specified by I, using the system's native character set.
Because the system's native character set is used, the correspondence between character and their codes is not necessarily the same between GNU Fortran implementations.
Note that no intrinsic exists to convert a numerical
value to a printable character string.
For example, there is no intrinsic that, given
an INTEGER or REAL argument with the
value 154, returns the CHARACTER
result '154'.
Instead, you can use internal-file I/O to do this kind of conversion. For example:
INTEGER VALUE CHARACTER*10 STRING VALUE = 154 WRITE (STRING, '(I10)'), VALUE PRINT *, STRING END
The above program, when run, prints:
154
See IChar Intrinsic, for the inverse of the CHAR function.
See AChar Intrinsic, for the function corresponding to the ASCII character set.
CALL ChDir(Dir, Status)Dir:
CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sets the current working directory to be Dir.
If the Status argument is supplied, it contains 0
on success or a non-zero error code otherwise upon return.
See chdir(3).
Caution: Using this routine during I/O to a unit connected with a non-absolute file name can cause subsequent I/O on such a unit to fail because the I/O library may reopen files by name.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See ChDir Intrinsic (function).
CALL ChMod(Name, Mode, Status)Name:
CHARACTER; scalar; INTENT(IN).
Mode: CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Changes the access mode of file Name according to the
specification Mode, which is given in the format of
chmod(1).
A null character (CHAR(0)) marks the end of
the name in Name---otherwise,
trailing blanks in Name are ignored.
Currently, Name must not contain the single quote
character.
If the Status argument is supplied, it contains 0 on success or a non-zero error code upon return.
Note that this currently works
by actually invoking /bin/chmod (or the chmod found when
the library was configured) and so may fail in some circumstances and
will, anyway, be slow.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See ChMod Intrinsic (function).
CLog(X)CLog:
COMPLEX(KIND=1) function.
X: COMPLEX(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of LOG() that is specific
to one type for X.
See Log Intrinsic.
Cmplx(X, Y)Cmplx:
COMPLEX(KIND=1) function.
X: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Y: INTEGER or REAL; OPTIONAL (must be omitted if X is COMPLEX); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
If X is not type COMPLEX,
constructs a value of type COMPLEX(KIND=1) from the
real and imaginary values specified by X and
Y, respectively.
If Y is omitted, 0. is assumed.
If X is type COMPLEX,
converts it to type COMPLEX(KIND=1).
See Complex Intrinsic, for information on easily constructing
a COMPLEX value of arbitrary precision from REAL
arguments.
Complex(Real, Imag)Complex:
COMPLEX function, the exact type being the result of cross-promoting the
types of all the arguments.
Real: INTEGER or REAL; scalar; INTENT(IN).
Imag: INTEGER or REAL; scalar; INTENT(IN).
Intrinsic groups: gnu.
Description:
Returns a COMPLEX value that has Real and Imag as its
real and imaginary parts, respectively.
If Real and Imag are the same type, and that type is not
INTEGER, no data conversion is performed, and the type of
the resulting value has the same kind value as the types
of Real and Imag.
If Real and Imag are not the same type, the usual type-promotion
rules are applied to both, converting either or both to the
appropriate REAL type.
The type of the resulting value has the same kind value as the
type to which both Real and Imag were converted, in this case.
If Real and Imag are both INTEGER, they are both converted
to REAL(KIND=1), and the result of the COMPLEX()
invocation is type COMPLEX(KIND=1).
Note: The way to do this in standard Fortran 90
is too hairy to describe here, but it is important to
note that CMPLX(D1,D2) returns a COMPLEX(KIND=1)
result even if D1 and D2 are type REAL(KIND=2).
Hence the availability of COMPLEX() in GNU Fortran.
Conjg(Z)Conjg:
COMPLEX function, the KIND= value of the type being that of argument Z.
Z: COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the complex conjugate:
COMPLEX(REALPART(Z), -IMAGPART(Z))
Cos(X)Cos:
REAL or COMPLEX function, the exact type being that of argument X.
X: REAL or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the cosine of X, an angle measured in radians.
See ACos Intrinsic, for the inverse of this function.
CosH(X)CosH:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the hyperbolic cosine of X.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Count to use this name for an external procedure.
CALL CPU_Time(Seconds)Seconds:
REAL; scalar; INTENT(OUT).
Intrinsic groups: f90.
Description:
Returns in Seconds the current value of the system time.
This implementation of the Fortran 95 intrinsic is just an alias for
second See Second Intrinsic (subroutine).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL CShift to use this name for an external procedure.
CSin(X)CSin:
COMPLEX(KIND=1) function.
X: COMPLEX(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SIN() that is specific
to one type for X.
See Sin Intrinsic.
CSqRt(X)CSqRt:
COMPLEX(KIND=1) function.
X: COMPLEX(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SQRT() that is specific
to one type for X.
See SqRt Intrinsic.
CALL CTime(Result, STime)Result:
CHARACTER; scalar; INTENT(OUT).
STime: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Converts STime, a system time value, such as returned by
TIME8(), to a string of the form Sat Aug 19 18:13:14 1995,
and returns that string in Result.
See Time8 Intrinsic.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See CTime Intrinsic (function).
CTime(STime)CTime:
CHARACTER*(*) function.
STime: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Converts STime, a system time value, such as returned by
TIME8(), to a string of the form Sat Aug 19 18:13:14 1995,
and returns that string as the function value.
See Time8 Intrinsic.
For information on other intrinsics with the same name: See CTime Intrinsic (subroutine).
DAbs(A)DAbs:
REAL(KIND=2) function.
A: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ABS() that is specific
to one type for A.
See Abs Intrinsic.
DACos(X)DACos:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ACOS() that is specific
to one type for X.
See ACos Intrinsic.
DASin(X)DASin:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ASIN() that is specific
to one type for X.
See ASin Intrinsic.
DATan(X)DATan:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ATAN() that is specific
to one type for X.
See ATan Intrinsic.
DATan2(Y, X)DATan2:
REAL(KIND=2) function.
Y: REAL(KIND=2); scalar; INTENT(IN).
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ATAN2() that is specific
to one type for Y and X.
See ATan2 Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Date_and_Time to use this name for an external procedure.
DbesJ0(X)DbesJ0:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of BESJ0() that is specific
to one type for X.
See BesJ0 Intrinsic.
DbesJ1(X)DbesJ1:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of BESJ1() that is specific
to one type for X.
See BesJ1 Intrinsic.
DbesJN(N, X)DbesJN:
REAL(KIND=2) function.
N: INTEGER; scalar; INTENT(IN).
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of BESJN() that is specific
to one type for X.
See BesJN Intrinsic.
DbesY0(X)DbesY0:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of BESY0() that is specific
to one type for X.
See BesY0 Intrinsic.
DbesY1(X)DbesY1:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of BESY1() that is specific
to one type for X.
See BesY1 Intrinsic.
DbesYN(N, X)DbesYN:
REAL(KIND=2) function.
N: INTEGER; scalar; INTENT(IN).
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of BESYN() that is specific
to one type for X.
See BesYN Intrinsic.
Dble(A)Dble:
REAL(KIND=2) function.
A: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns A converted to double precision
(REAL(KIND=2)).
If A is COMPLEX, the real part of
A is used for the conversion
and the imaginary part disregarded.
See Sngl Intrinsic, for the function that converts to single precision.
See Int Intrinsic, for the function that converts
to INTEGER.
See Complex Intrinsic, for the function that converts
to COMPLEX.
DCos(X)DCos:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of COS() that is specific
to one type for X.
See Cos Intrinsic.
DCosH(X)DCosH:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of COSH() that is specific
to one type for X.
See CosH Intrinsic.
DDiM(X, Y)DDiM:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Y: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of DIM() that is specific
to one type for X and Y.
See DiM Intrinsic.
DErF(X)DErF:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of ERF() that is specific
to one type for X.
See ErF Intrinsic.
DErFC(X)DErFC:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of ERFC() that is specific
to one type for X.
See ErFC Intrinsic.
DExp(X)DExp:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of EXP() that is specific
to one type for X.
See Exp Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Digits to use this name for an external procedure.
DiM(X, Y)DiM:
INTEGER or REAL function, the exact type being the result of cross-promoting the
types of all the arguments.
X: INTEGER or REAL; scalar; INTENT(IN).
Y: INTEGER or REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns X-Y if X is greater than Y; otherwise returns zero.
DInt(A)DInt:
REAL(KIND=2) function.
A: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of AINT() that is specific
to one type for A.
See AInt Intrinsic.
DLog(X)DLog:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of LOG() that is specific
to one type for X.
See Log Intrinsic.
DLog10(X)DLog10:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of LOG10() that is specific
to one type for X.
See Log10 Intrinsic.
DMax1(A-1, A-2, ···, A-n)DMax1:
REAL(KIND=2) function.
A: REAL(KIND=2); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MAX() that is specific
to one type for A.
See Max Intrinsic.
DMin1(A-1, A-2, ···, A-n)DMin1:
REAL(KIND=2) function.
A: REAL(KIND=2); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MIN() that is specific
to one type for A.
See Min Intrinsic.
DMod(A, P)DMod:
REAL(KIND=2) function.
A: REAL(KIND=2); scalar; INTENT(IN).
P: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MOD() that is specific
to one type for A.
See Mod Intrinsic.
DNInt(A)DNInt:
REAL(KIND=2) function.
A: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ANINT() that is specific
to one type for A.
See ANInt Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Dot_Product to use this name for an external procedure.
DProd(X, Y)DProd:
REAL(KIND=2) function.
X: REAL(KIND=1); scalar; INTENT(IN).
Y: REAL(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
DSign(A, B)DSign:
REAL(KIND=2) function.
A: REAL(KIND=2); scalar; INTENT(IN).
B: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SIGN() that is specific
to one type for A and B.
See Sign Intrinsic.
DSin(X)DSin:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SIN() that is specific
to one type for X.
See Sin Intrinsic.
DSinH(X)DSinH:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SINH() that is specific
to one type for X.
See SinH Intrinsic.
DSqRt(X)DSqRt:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SQRT() that is specific
to one type for X.
See SqRt Intrinsic.
DTan(X)DTan:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of TAN() that is specific
to one type for X.
See Tan Intrinsic.
DTanH(X)DTanH:
REAL(KIND=2) function.
X: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of TANH() that is specific
to one type for X.
See TanH Intrinsic.
CALL Dtime(Result, TArray)Result:
REAL(KIND=1); scalar; INTENT(OUT).
TArray: REAL(KIND=1); DIMENSION(2); INTENT(OUT).
Intrinsic groups: unix.
Description:
Initially, return the number of seconds of runtime since the start of the process's execution in Result, and the user and system components of this in TArray(1) and TArray(2) respectively. The value of Result is equal to TArray(1) + TArray(2).
Subsequent invocations of DTIME() set values based on accumulations since the previous invocation.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See Dtime Intrinsic (function).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL EOShift to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Epsilon to use this name for an external procedure.
ErF(X)ErF:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns the error function of X.
See erf(3m), which provides the implementation.
ErFC(X)ErFC:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns the complementary error function of X:
ERFC(R) = 1 - ERF(R) (except that the result may be more
accurate than explicitly evaluating that formulae would give).
See erfc(3m), which provides the implementation.
CALL ETime(Result, TArray)Result:
REAL(KIND=1); scalar; INTENT(OUT).
TArray: REAL(KIND=1); DIMENSION(2); INTENT(OUT).
Intrinsic groups: unix.
Description:
Return the number of seconds of runtime since the start of the process's execution in Result, and the user and system components of this in TArray(1) and TArray(2) respectively. The value of Result is equal to TArray(1) + TArray(2).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See ETime Intrinsic (function).
ETime(TArray)ETime:
REAL(KIND=1) function.
TArray: REAL(KIND=1); DIMENSION(2); INTENT(OUT).
Intrinsic groups: unix.
Description:
Return the number of seconds of runtime since the start of the process's execution as the function value, and the user and system components of this in TArray(1) and TArray(2) respectively. The functions' value is equal to TArray(1) + TArray(2).
For information on other intrinsics with the same name: See ETime Intrinsic (subroutine).
CALL Exit(Status)Status:
INTEGER; OPTIONAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Exit the program with status Status after closing open Fortran
I/O units and otherwise behaving as exit(2).
If Status is omitted the canonical `success' value
will be returned to the system.
Exp(X)Exp:
REAL or COMPLEX function, the exact type being that of argument X.
X: REAL or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns e**X, where e is approximately 2.7182818.
See Log Intrinsic, for the inverse of this function.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Exponent to use this name for an external procedure.
CALL Fdate(Date)Date:
CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Returns the current date (using the same format as CTIME())
in Date.
Equivalent to:
CALL CTIME(Date, TIME8())
See CTime Intrinsic (subroutine).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See Fdate Intrinsic (function).
Fdate()Fdate:
CHARACTER*(*) function.
Intrinsic groups: unix.
Description:
Returns the current date (using the same format as CTIME()).
Equivalent to:
CTIME(TIME8())
See CTime Intrinsic (function).
For information on other intrinsics with the same name: See Fdate Intrinsic (subroutine).
CALL FGet(C, Status)C:
CHARACTER; scalar; INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Reads a single character into C in stream mode from unit 5
(by-passing normal formatted output) using getc(3).
Returns in
Status 0 on success, -1 on end-of-file, and the error code
from ferror(3) otherwise.
Stream I/O should not be mixed with normal record-oriented (formatted or unformatted) I/O on the same unit; the results are unpredictable.
For information on other intrinsics with the same name: See FGet Intrinsic (function).
CALL FGetC(Unit, C, Status)Unit:
INTEGER; scalar; INTENT(IN).
C: CHARACTER; scalar; INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Reads a single character into C in stream mode from unit Unit
(by-passing normal formatted output) using getc(3).
Returns in
Status 0 on success, -1 on end-of-file, and the error code from
ferror(3) otherwise.
Stream I/O should not be mixed with normal record-oriented (formatted or unformatted) I/O on the same unit; the results are unpredictable.
For information on other intrinsics with the same name: See FGetC Intrinsic (function).
Float(A)Float:
REAL(KIND=1) function.
A: INTEGER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of REAL() that is specific
to one type for A.
See Real Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Floor to use this name for an external procedure.
CALL Flush(Unit)Unit:
INTEGER; OPTIONAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Flushes Fortran unit(s) currently open for output. Without the optional argument, all such units are flushed, otherwise just the unit specified by Unit.
Some non-GNU implementations of Fortran provide this intrinsic as a library procedure that might or might not support the (optional) Unit argument.
FNum(Unit)FNum:
INTEGER(KIND=1) function.
Unit: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns the Unix file descriptor number corresponding to the open Fortran I/O unit Unit. This could be passed to an interface to C I/O routines.
CALL FPut(C, Status)C:
CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Writes the single character C in stream mode to unit 6
(by-passing normal formatted output) using putc(3).
Returns in
Status 0 on success, the error code from ferror(3) otherwise.
Stream I/O should not be mixed with normal record-oriented (formatted or unformatted) I/O on the same unit; the results are unpredictable.
For information on other intrinsics with the same name: See FPut Intrinsic (function).
CALL FPutC(Unit, C, Status)Unit:
INTEGER; scalar; INTENT(IN).
C: CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Writes the single character Unit in stream mode to unit 6
(by-passing normal formatted output) using putc(3).
Returns in
C 0 on success, the error code from ferror(3) otherwise.
Stream I/O should not be mixed with normal record-oriented (formatted or unformatted) I/O on the same unit; the results are unpredictable.
For information on other intrinsics with the same name: See FPutC Intrinsic (function).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Fraction to use this name for an external procedure.
CALL FSeek(Unit, Offset, Whence, ErrLab)Unit:
INTEGER; scalar; INTENT(IN).
Offset: INTEGER; scalar; INTENT(IN).
Whence: INTEGER; scalar; INTENT(IN).
ErrLab: *label, where label is the label
of an executable statement; OPTIONAL.
Intrinsic groups: unix.
Description:
Attempts to move Fortran unit Unit to the specified Offset: absolute offset if Offset=0; relative to the current offset if Offset=1; relative to the end of the file if Offset=2. It branches to label Whence if Unit is not open or if the call otherwise fails.
CALL FStat(Unit, SArray, Status)Unit:
INTEGER; scalar; INTENT(IN).
SArray: INTEGER(KIND=1); DIMENSION(13); INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Obtains data about the file open on Fortran I/O unit Unit and
places them in the array SArray.
The values in this array are
extracted from the stat structure as returned by
fstat(2) q.v., as follows:
Not all these elements are relevant on all systems. If an element is not relevant, it is returned as 0.
If the Status argument is supplied, it contains 0 on success or a non-zero error code upon return.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See FStat Intrinsic (function).
FStat(Unit, SArray)FStat:
INTEGER(KIND=1) function.
Unit: INTEGER; scalar; INTENT(IN).
SArray: INTEGER(KIND=1); DIMENSION(13); INTENT(OUT).
Intrinsic groups: unix.
Description:
Obtains data about the file open on Fortran I/O unit Unit and
places them in the array SArray.
The values in this array are
extracted from the stat structure as returned by
fstat(2) q.v., as follows:
Not all these elements are relevant on all systems. If an element is not relevant, it is returned as 0.
Returns 0 on success or a non-zero error code.
For information on other intrinsics with the same name: See FStat Intrinsic (subroutine).
CALL FTell(Unit, Offset)Unit:
INTEGER; scalar; INTENT(IN).
Offset: INTEGER(KIND=1); scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sets Offset to the current offset of Fortran unit Unit (or to -1 if Unit is not open).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See FTell Intrinsic (function).
FTell(Unit)FTell:
INTEGER(KIND=1) function.
Unit: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns the current offset of Fortran unit Unit (or -1 if Unit is not open).
For information on other intrinsics with the same name: See FTell Intrinsic (subroutine).
CALL GError(Message)Message:
CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Returns the system error message corresponding to the last system
error (C errno).
CALL GetArg(Pos, Value)Pos:
INTEGER; scalar; INTENT(IN).
Value: CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sets Value to the Pos-th command-line argument (or to all
blanks if there are fewer than Value command-line arguments);
CALL GETARG(0, value) sets value to the name of the
program (on systems that support this feature).
See IArgC Intrinsic, for information on how to get the number of arguments.
CALL GetCWD(Name, Status)Name:
CHARACTER; scalar; INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Places the current working directory in Name.
If the Status argument is supplied, it contains 0
success or a non-zero error code upon return
(ENOSYS if the system does not provide getcwd(3)
or getwd(3)).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See GetCWD Intrinsic (function).
GetCWD(Name)GetCWD:
INTEGER(KIND=1) function.
Name: CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Places the current working directory in Name.
Returns 0 on
success, otherwise a non-zero error code
(ENOSYS if the system does not provide getcwd(3)
or getwd(3)).
For information on other intrinsics with the same name: See GetCWD Intrinsic (subroutine).
CALL GetEnv(Name, Value)Name:
CHARACTER; scalar; INTENT(IN).
Value: CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sets Value to the value of environment variable given by the
value of Name ($name in shell terms) or to blanks if
$name has not been set.
A null character (CHAR(0)) marks the end of
the name in Name---otherwise,
trailing blanks in Name are ignored.
GetGId()GetGId:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the group id for the current process.
CALL GetLog(Login)Login:
CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Returns the login name for the process in Login.
Caution: On some systems, the getlogin(3)
function, which this intrinsic calls at run time,
is either not implemented or returns a null pointer.
In the latter case, this intrinsic returns blanks
in Login.
GetPId()GetPId:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the process id for the current process.
GetUId()GetUId:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the user id for the current process.
CALL GMTime(STime, TArray)STime:
INTEGER(KIND=1); scalar; INTENT(IN).
TArray: INTEGER(KIND=1); DIMENSION(9); INTENT(OUT).
Intrinsic groups: unix.
Description:
Given a system time value STime, fills TArray with values
extracted from it appropriate to the GMT time zone using
gmtime(3).
The array elements are as follows:
CALL HostNm(Name, Status)Name:
CHARACTER; scalar; INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Fills Name with the system's host name returned by
gethostname(2).
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return
(ENOSYS if the system does not provide gethostname(2)).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See HostNm Intrinsic (function).
HostNm(Name)HostNm:
INTEGER(KIND=1) function.
Name: CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Fills Name with the system's host name returned by
gethostname(2), returning 0 on success or a non-zero error code
(ENOSYS if the system does not provide gethostname(2)).
For information on other intrinsics with the same name: See HostNm Intrinsic (subroutine).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Huge to use this name for an external procedure.
IAbs(A)IAbs:
INTEGER(KIND=1) function.
A: INTEGER(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of ABS() that is specific
to one type for A.
See Abs Intrinsic.
IAChar(C)IAChar:
INTEGER(KIND=1) function.
C: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: f2c, f90.
Description:
Returns the code for the ASCII character in the first character position of C.
See AChar Intrinsic, for the inverse of this function.
See IChar Intrinsic, for the function corresponding to the system's native character set.
IAnd(I, J)IAnd:
INTEGER function, the exact type being the result of cross-promoting the
types of all the arguments.
I: INTEGER; scalar; INTENT(IN).
J: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns value resulting from boolean AND of pair of bits in each of I and J.
IArgC()IArgC:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the number of command-line arguments.
This count does not include the specification of the program name itself.
IBClr(I, Pos)IBClr:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Pos: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns the value of I with bit Pos cleared (set to zero). See BTest Intrinsic for information on bit positions.
IBits(I, Pos, Len)IBits:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Pos: INTEGER; scalar; INTENT(IN).
Len: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Extracts a subfield of length Len from I, starting from bit position Pos and extending left for Len bits. The result is right-justified and the remaining bits are zeroed. The value of Pos+Len must be less than or equal to the value BIT_SIZE(I). See Bit_Size Intrinsic.
IBSet(I, Pos)IBSet:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Pos: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns the value of I with bit Pos set (to one). See BTest Intrinsic for information on bit positions.
IChar(C)IChar:
INTEGER(KIND=1) function.
C: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the code for the character in the first character position of C.
Because the system's native character set is used, the correspondence between character and their codes is not necessarily the same between GNU Fortran implementations.
Note that no intrinsic exists to convert a printable
character string to a numerical value.
For example, there is no intrinsic that, given
the CHARACTER value '154', returns an
INTEGER or REAL value with the value 154.
Instead, you can use internal-file I/O to do this kind of conversion. For example:
INTEGER VALUE CHARACTER*10 STRING STRING = '154' READ (STRING, '(I10)'), VALUE PRINT *, VALUE END
The above program, when run, prints:
154
See Char Intrinsic, for the inverse of the ICHAR function.
See IAChar Intrinsic, for the function corresponding to the ASCII character set.
CALL IDate(TArray)TArray:
INTEGER(KIND=1); DIMENSION(3); INTENT(OUT).
Intrinsic groups: unix.
Description:
Fills TArray with the numerical values at the current local time of day, month (in the range 1--12), and year in elements 1, 2, and 3, respectively. The year has four significant digits.
For information on other intrinsics with the same name: See IDate Intrinsic (VXT).
IDiM(X, Y)IDiM:
INTEGER(KIND=1) function.
X: INTEGER(KIND=1); scalar; INTENT(IN).
Y: INTEGER(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of DIM() that is specific
to one type for X and Y.
See DiM Intrinsic.
IDInt(A)IDInt:
INTEGER(KIND=1) function.
A: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of INT() that is specific
to one type for A.
See Int Intrinsic.
IDNInt(A)IDNInt:
INTEGER(KIND=1) function.
A: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of NINT() that is specific
to one type for A.
See NInt Intrinsic.
IEOr(I, J)IEOr:
INTEGER function, the exact type being the result of cross-promoting the
types of all the arguments.
I: INTEGER; scalar; INTENT(IN).
J: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns value resulting from boolean exclusive-OR of pair of bits in each of I and J.
IErrNo()IErrNo:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the last system error number (corresponding to the C
errno).
IFix(A)IFix:
INTEGER(KIND=1) function.
A: REAL(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of INT() that is specific
to one type for A.
See Int Intrinsic.
Imag(Z)Imag:
REAL function, the KIND= value of the type being that of argument Z.
Z: COMPLEX; scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
The imaginary part of Z is returned, without conversion.
Note: The way to do this in standard Fortran 90
is AIMAG(Z).
However, when, for example, Z is DOUBLE COMPLEX,
AIMAG(Z) means something different for some compilers
that are not true Fortran 90 compilers but offer some
extensions standardized by Fortran 90 (such as the
DOUBLE COMPLEX type, also known as COMPLEX(KIND=2)).
The advantage of IMAG() is that, while not necessarily
more or less portable than AIMAG(), it is more likely to
cause a compiler that doesn't support it to produce a diagnostic
than generate incorrect code.
See REAL() and AIMAG() of Complex, for more information.
ImagPart(Z)ImagPart:
REAL function, the KIND= value of the type being that of argument Z.
Z: COMPLEX; scalar; INTENT(IN).
Intrinsic groups: gnu.
Description:
The imaginary part of Z is returned, without conversion.
Note: The way to do this in standard Fortran 90
is AIMAG(Z).
However, when, for example, Z is DOUBLE COMPLEX,
AIMAG(Z) means something different for some compilers
that are not true Fortran 90 compilers but offer some
extensions standardized by Fortran 90 (such as the
DOUBLE COMPLEX type, also known as COMPLEX(KIND=2)).
The advantage of IMAGPART() is that, while not necessarily
more or less portable than AIMAG(), it is more likely to
cause a compiler that doesn't support it to produce a diagnostic
than generate incorrect code.
See REAL() and AIMAG() of Complex, for more information.
Index(String, Substring)Index:
INTEGER(KIND=1) function.
String: CHARACTER; scalar; INTENT(IN).
Substring: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the position of the start of the first occurrence of string Substring as a substring in String, counting from one. If Substring doesn't occur in String, zero is returned.
Int(A)Int:
INTEGER(KIND=1) function.
A: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns A with the fractional portion of its
magnitude truncated and its sign preserved, converted
to type INTEGER(KIND=1).
If A is type COMPLEX, its real part is
truncated and converted, and its imaginary part is disregarded.
See NInt Intrinsic, for how to convert, rounded to nearest whole number.
See AInt Intrinsic, for how to truncate to whole number without converting.
Int2(A)Int2:
INTEGER(KIND=6) function.
A: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: gnu.
Description:
Returns A with the fractional portion of its
magnitude truncated and its sign preserved, converted
to type INTEGER(KIND=6).
If A is type COMPLEX, its real part
is truncated and converted, and its imaginary part is disgregarded.
See Int Intrinsic.
The precise meaning of this intrinsic might change in a future version of the GNU Fortran language, as more is learned about how it is used.
Int8(A)Int8:
INTEGER(KIND=2) function.
A: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: gnu.
Description:
Returns A with the fractional portion of its
magnitude truncated and its sign preserved, converted
to type INTEGER(KIND=2).
If A is type COMPLEX, its real part
is truncated and converted, and its imaginary part is disgregarded.
See Int Intrinsic.
The precise meaning of this intrinsic might change in a future version of the GNU Fortran language, as more is learned about how it is used.
IOr(I, J)IOr:
INTEGER function, the exact type being the result of cross-promoting the
types of all the arguments.
I: INTEGER; scalar; INTENT(IN).
J: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns value resulting from boolean OR of pair of bits in each of I and J.
IRand(Flag)IRand:
INTEGER(KIND=1) function.
Flag: INTEGER; OPTIONAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns a uniform quasi-random number up to a system-dependent limit.
If Flag is 0, the next number in sequence is returned; if
Flag is 1, the generator is restarted by calling the UNIX function
srand(0); if Flag has any other value,
it is used as a new seed with srand().
See SRand Intrinsic.
Note: As typically implemented (by the routine of the same name in the C library), this random number generator is a very poor one, though the BSD and GNU libraries provide a much better implementation than the `traditional' one. On a different system you almost certainly want to use something better.
IsaTty(Unit)IsaTty:
LOGICAL(KIND=1) function.
Unit: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns .TRUE. if and only if the Fortran I/O unit
specified by Unit is connected
to a terminal device.
See isatty(3).
IShft(I, Shift)IShft:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Shift: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
All bits representing I are shifted Shift places. Shift.GT.0 indicates a left shift, Shift.EQ.0 indicates no shift and Shift.LT.0 indicates a right shift. If the absolute value of the shift count is greater than BIT_SIZE(I), the result is undefined. Bits shifted out from the left end or the right end, as the case may be, are lost. Zeros are shifted in from the opposite end.
See IShftC Intrinsic for the circular-shift equivalent.
IShftC(I, Shift, Size)IShftC:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Shift: INTEGER; scalar; INTENT(IN).
Size: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
The rightmost Size bits of the argument I are shifted circularly Shift places, i.e.@ the bits shifted out of one end are shifted into the opposite end. No bits are lost. The unshifted bits of the result are the same as the unshifted bits of I. The absolute value of the argument Shift must be less than or equal to Size. The value of Size must be greater than or equal to one and less than or equal to BIT_SIZE(I).
See IShft Intrinsic for the logical shift equivalent.
ISign(A, B)ISign:
INTEGER(KIND=1) function.
A: INTEGER(KIND=1); scalar; INTENT(IN).
B: INTEGER(KIND=1); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of SIGN() that is specific
to one type for A and B.
See Sign Intrinsic.
CALL ITime(TArray)TArray:
INTEGER(KIND=1); DIMENSION(3); INTENT(OUT).
Intrinsic groups: unix.
Description:
Returns the current local time hour, minutes, and seconds in elements 1, 2, and 3 of TArray, respectively.
CALL Kill(Pid, Signal, Status)Pid:
INTEGER; scalar; INTENT(IN).
Signal: INTEGER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sends the signal specified by Signal to the process Pid.
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return.
See kill(2).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See Kill Intrinsic (function).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Kind to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL LBound to use this name for an external procedure.
Len(String)Len:
INTEGER(KIND=1) function.
String: CHARACTER; scalar.
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the length of String.
If String is an array, the length of an element of String is returned.
Note that String need not be defined when this intrinsic is invoked, since only the length, not the content, of String is needed.
See Bit_Size Intrinsic, for the function that determines the size of its argument in bits.
Len_Trim(String)Len_Trim:
INTEGER(KIND=1) function.
String: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: f90.
Description:
Returns the index of the last non-blank character in String.
LNBLNK and LEN_TRIM are equivalent.
LGe(String_A, String_B)LGe:
LOGICAL(KIND=1) function.
String_A: CHARACTER; scalar; INTENT(IN).
String_B: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns .TRUE. if String_A.GE.String_B, .FALSE. otherwise. String_A and String_B are interpreted as containing ASCII character codes. If either value contains a character not in the ASCII character set, the result is processor dependent.
If the String_A and String_B are not the same length, the shorter is compared as if spaces were appended to it to form a value that has the same length as the longer.
The lexical comparison intrinsics LGe, LGt,
LLe, and LLt differ from the corresponding
intrinsic operators .GE., .GT.,
.LE., .LT..
Because the ASCII collating sequence is assumed,
the following expressions always return .TRUE.:
LGE ('0', ' ')
LGE ('A', '0')
LGE ('a', 'A')
The following related expressions do not always return .TRUE., as they are not necessarily evaluated assuming the arguments use ASCII encoding:
'0' .GE. ' ' 'A' .GE. '0' 'a' .GE. 'A'
The same difference exists
between LGt and .GT.;
between LLe and .LE.; and
between LLt and .LT..
LGt(String_A, String_B)LGt:
LOGICAL(KIND=1) function.
String_A: CHARACTER; scalar; INTENT(IN).
String_B: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns .TRUE. if String_A.GT.String_B, .FALSE. otherwise. String_A and String_B are interpreted as containing ASCII character codes. If either value contains a character not in the ASCII character set, the result is processor dependent.
If the String_A and String_B are not the same length, the shorter is compared as if spaces were appended to it to form a value that has the same length as the longer.
See LGe Intrinsic, for information on the distinction
between the LGT intrinsic and the .GT.
operator.
CALL Link(Path1, Path2, Status)Path1:
CHARACTER; scalar; INTENT(IN).
Path2: CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Makes a (hard) link from file Path1 to Path2.
A null character (CHAR(0)) marks the end of
the names in Path1 and Path2---otherwise,
trailing blanks in Path1 and Path2 are ignored.
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return.
See link(2).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See Link Intrinsic (function).
LLe(String_A, String_B)LLe:
LOGICAL(KIND=1) function.
String_A: CHARACTER; scalar; INTENT(IN).
String_B: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns .TRUE. if String_A.LE.String_B, .FALSE. otherwise. String_A and String_B are interpreted as containing ASCII character codes. If either value contains a character not in the ASCII character set, the result is processor dependent.
If the String_A and String_B are not the same length, the shorter is compared as if spaces were appended to it to form a value that has the same length as the longer.
See LGe Intrinsic, for information on the distinction
between the LLE intrinsic and the .LE.
operator.
LLt(String_A, String_B)LLt:
LOGICAL(KIND=1) function.
String_A: CHARACTER; scalar; INTENT(IN).
String_B: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns .TRUE. if String_A.LT.String_B, .FALSE. otherwise. String_A and String_B are interpreted as containing ASCII character codes. If either value contains a character not in the ASCII character set, the result is processor dependent.
If the String_A and String_B are not the same length, the shorter is compared as if spaces were appended to it to form a value that has the same length as the longer.
See LGe Intrinsic, for information on the distinction
between the LLT intrinsic and the .LT.
operator.
LnBlnk(String)LnBlnk:
INTEGER(KIND=1) function.
String: CHARACTER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns the index of the last non-blank character in String.
LNBLNK and LEN_TRIM are equivalent.
Loc(Entity)Loc:
INTEGER(KIND=7) function.
Entity: Any type; cannot be a constant or expression.
Intrinsic groups: unix.
Description:
The LOC() intrinsic works the
same way as the %LOC() construct.
See The %LOC() Construct, for
more information.
Log(X)Log:
REAL or COMPLEX function, the exact type being that of argument X.
X: REAL or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the natural logarithm of X, which must
be greater than zero or, if type COMPLEX, must not
be zero.
See Exp Intrinsic, for the inverse of this function.
See Log10 Intrinsic, for the base-10 logarithm function.
Log10(X)Log10:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the natural logarithm of X, which must
be greater than zero or, if type COMPLEX, must not
be zero.
The inverse of this function is 10. ** LOG10(X).
See Log Intrinsic, for the natural logarithm function.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Logical to use this name for an external procedure.
Long(A)Long:
INTEGER(KIND=1) function.
A: INTEGER(KIND=6); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Archaic form of INT() that is specific
to one type for A.
See Int Intrinsic.
The precise meaning of this intrinsic might change in a future version of the GNU Fortran language, as more is learned about how it is used.
LShift(I, Shift)LShift:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Shift: INTEGER; scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Returns I shifted to the left Shift bits.
Although similar to the expression I*(2**Shift), there are important differences. For example, the sign of the result is not necessarily the same as the sign of I.
Currently this intrinsic is defined assuming the underlying representation of I is as a two's-complement integer. It is unclear at this point whether that definition will apply when a different representation is involved.
See LShift Intrinsic, for the inverse of this function.
See IShft Intrinsic, for information on a more widely available left-shifting intrinsic that is also more precisely defined.
CALL LStat(File, SArray, Status)File:
CHARACTER; scalar; INTENT(IN).
SArray: INTEGER(KIND=1); DIMENSION(13); INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Obtains data about the given file File and places them in the array
SArray.
A null character (CHAR(0)) marks the end of
the name in File---otherwise,
trailing blanks in File are ignored.
If File is a symbolic link it returns data on the
link itself, so the routine is available only on systems that support
symbolic links.
The values in this array are extracted from the
stat structure as returned by fstat(2) q.v., as follows:
Not all these elements are relevant on all systems. If an element is not relevant, it is returned as 0.
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return
(ENOSYS if the system does not provide lstat(2)).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See LStat Intrinsic (function).
LStat(File, SArray)LStat:
INTEGER(KIND=1) function.
File: CHARACTER; scalar; INTENT(IN).
SArray: INTEGER(KIND=1); DIMENSION(13); INTENT(OUT).
Intrinsic groups: unix.
Description:
Obtains data about the given file File and places them in the array
SArray.
A null character (CHAR(0)) marks the end of
the name in File---otherwise,
trailing blanks in File are ignored.
If File is a symbolic link it returns data on the
link itself, so the routine is available only on systems that support
symbolic links.
The values in this array are extracted from the
stat structure as returned by fstat(2) q.v., as follows:
Not all these elements are relevant on all systems. If an element is not relevant, it is returned as 0.
Returns 0 on success or a non-zero error code
(ENOSYS if the system does not provide lstat(2)).
For information on other intrinsics with the same name: See LStat Intrinsic (subroutine).
CALL LTime(STime, TArray)STime:
INTEGER(KIND=1); scalar; INTENT(IN).
TArray: INTEGER(KIND=1); DIMENSION(9); INTENT(OUT).
Intrinsic groups: unix.
Description:
Given a system time value STime, fills TArray with values
extracted from it appropriate to the GMT time zone using
localtime(3).
The array elements are as follows:
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MatMul to use this name for an external procedure.
Max(A-1, A-2, ···, A-n)Max:
INTEGER or REAL function, the exact type being the result of cross-promoting the
types of all the arguments.
A: INTEGER or REAL; at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the argument with the largest value.
See Min Intrinsic, for the opposite function.
Max0(A-1, A-2, ···, A-n)Max0:
INTEGER(KIND=1) function.
A: INTEGER(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MAX() that is specific
to one type for A.
See Max Intrinsic.
Max1(A-1, A-2, ···, A-n)Max1:
INTEGER(KIND=1) function.
A: REAL(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MAX() that is specific
to one type for A and a different return type.
See Max Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MaxExponent to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MaxLoc to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MaxVal to use this name for an external procedure.
MClock()MClock:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the number of clock ticks since the start of the process.
Supported on systems with clock(3) (q.v.).
This intrinsic is not fully portable, such as to systems
with 32-bit INTEGER types but supporting times
wider than 32 bits.
See MClock8 Intrinsic, for information on a
similar intrinsic that might be portable to more
GNU Fortran implementations, though to fewer
Fortran compilers.
If the system does not support clock(3),
-1 is returned.
MClock8()MClock8:
INTEGER(KIND=2) function.
Intrinsic groups: unix.
Description:
Returns the number of clock ticks since the start of the process.
Supported on systems with clock(3) (q.v.).
No Fortran implementations other than GNU Fortran are known to support this intrinsic at the time of this writing. See MClock Intrinsic, for information on a similar intrinsic that might be portable to more Fortran compilers, though to fewer GNU Fortran implementations.
If the system does not support clock(3),
-1 is returned.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Merge to use this name for an external procedure.
Min(A-1, A-2, ···, A-n)Min:
INTEGER or REAL function, the exact type being the result of cross-promoting the
types of all the arguments.
A: INTEGER or REAL; at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the argument with the smallest value.
See Max Intrinsic, for the opposite function.
Min0(A-1, A-2, ···, A-n)Min0:
INTEGER(KIND=1) function.
A: INTEGER(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MIN() that is specific
to one type for A.
See Min Intrinsic.
Min1(A-1, A-2, ···, A-n)Min1:
INTEGER(KIND=1) function.
A: REAL(KIND=1); at least two such arguments must be provided; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of MIN() that is specific
to one type for A and a different return type.
See Min Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MinExponent to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MinLoc to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL MinVal to use this name for an external procedure.
Mod(A, P)Mod:
INTEGER or REAL function, the exact type being the result of cross-promoting the
types of all the arguments.
A: INTEGER or REAL; scalar; INTENT(IN).
P: INTEGER or REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns remainder calculated as:
A - (INT(A / P) * P)
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Modulo to use this name for an external procedure.
CALL MvBits(From, FromPos, Len, TO, ToPos)From:
INTEGER; scalar; INTENT(IN).
FromPos: INTEGER; scalar; INTENT(IN).
Len: INTEGER; scalar; INTENT(IN).
TO: INTEGER with same KIND= value as for From; scalar; INTENT(INOUT).
ToPos: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Moves Len bits from positions FromPos through FromPos+Len-1 of From to positions ToPos through FromPos+Len-1 of TO. The portion of argument TO not affected by the movement of bits is unchanged. Arguments From and TO are permitted to be the same numeric storage unit. The values of FromPos+Len and ToPos+Len must be less than or equal to BIT_SIZE(From).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Nearest to use this name for an external procedure.
NInt(A)NInt:
INTEGER(KIND=1) function.
A: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns A with the fractional portion of its
magnitude eliminated by rounding to the nearest whole
number and with its sign preserved, converted
to type INTEGER(KIND=1).
If A is type COMPLEX, its real part is
rounded and converted.
A fractional portion exactly equal to .5 is rounded to the whole number that is larger in magnitude. (Also called ``Fortran round''.)
See Int Intrinsic, for how to convert, truncate to whole number.
See ANInt Intrinsic, for how to round to nearest whole number without converting.
Not(I)Not:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Intrinsic groups: mil, f90, vxt.
Description:
Returns value resulting from boolean NOT of each bit in I.
Or(I, J)Or:
INTEGER or LOGICAL function, the exact type being the result of cross-promoting the
types of all the arguments.
I: INTEGER or LOGICAL; scalar; INTENT(IN).
J: INTEGER or LOGICAL; scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Returns value resulting from boolean OR of pair of bits in each of I and J.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Pack to use this name for an external procedure.
CALL PError(String)String:
CHARACTER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Prints (on the C stderr stream) a newline-terminated error
message corresponding to the last system error.
This is prefixed by String, a colon and a space.
See perror(3).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Precision to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Present to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Product to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Radix to use this name for an external procedure.
Rand(Flag)Rand:
REAL(KIND=1) function.
Flag: INTEGER; OPTIONAL; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns a uniform quasi-random number between 0 and 1.
If Flag is 0, the next number in sequence is returned; if
Flag is 1, the generator is restarted by calling srand(0);
if Flag has any other value, it is used as a new seed with
srand.
See SRand Intrinsic.
Note: As typically implemented (by the routine of the same name in the C library), this random number generator is a very poor one, though the BSD and GNU libraries provide a much better implementation than the `traditional' one. On a different system you almost certainly want to use something better.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Random_Number to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Random_Seed to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Range to use this name for an external procedure.
Real(A)Real:
REAL function.
The exact type is REAL(KIND=1) when argument A is
any type other than COMPLEX, or when it is COMPLEX(KIND=1).
When A is any COMPLEX type other than COMPLEX(KIND=1),
this intrinsic is valid only when used as the argument to
REAL(), as explained below.
A: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Converts A to REAL(KIND=1).
Use of REAL() with a COMPLEX argument
(other than COMPLEX(KIND=1)) is restricted to the following case:
REAL(REAL(A))This expression converts the real part of A to
REAL(KIND=1).
See RealPart Intrinsic, for information on a GNU Fortran
intrinsic that extracts the real part of an arbitrary
COMPLEX value.
See REAL() and AIMAG() of Complex, for more information.
RealPart(Z)RealPart:
REAL function, the KIND= value of the type being that of argument Z.
Z: COMPLEX; scalar; INTENT(IN).
Intrinsic groups: gnu.
Description:
The real part of Z is returned, without conversion.
Note: The way to do this in standard Fortran 90
is REAL(Z).
However, when, for example, Z is COMPLEX(KIND=2),
REAL(Z) means something different for some compilers
that are not true Fortran 90 compilers but offer some
extensions standardized by Fortran 90 (such as the
DOUBLE COMPLEX type, also known as COMPLEX(KIND=2)).
The advantage of REALPART() is that, while not necessarily
more or less portable than REAL(), it is more likely to
cause a compiler that doesn't support it to produce a diagnostic
than generate incorrect code.
See REAL() and AIMAG() of Complex, for more information.
CALL Rename(Path1, Path2, Status)Path1:
CHARACTER; scalar; INTENT(IN).
Path2: CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Renames the file Path1 to Path2.
A null character (CHAR(0)) marks the end of
the names in Path1 and Path2---otherwise,
trailing blanks in Path1 and Path2 are ignored.
See rename(2).
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See Rename Intrinsic (function).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Repeat to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Reshape to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL RRSpacing to use this name for an external procedure.
RShift(I, Shift)RShift:
INTEGER function, the KIND= value of the type being that of argument I.
I: INTEGER; scalar; INTENT(IN).
Shift: INTEGER; scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Returns I shifted to the right Shift bits.
Although similar to the expression I/(2**Shift), there are important differences. For example, the sign of the result is undefined.
Currently this intrinsic is defined assuming the underlying representation of I is as a two's-complement integer. It is unclear at this point whether that definition will apply when a different representation is involved.
See RShift Intrinsic, for the inverse of this function.
See IShft Intrinsic, for information on a more widely available right-shifting intrinsic that is also more precisely defined.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Scale to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Scan to use this name for an external procedure.
Second()Second:
REAL(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the process's runtime in seconds---the same value as the
UNIX function etime returns.
For information on other intrinsics with the same name: See Second Intrinsic (subroutine).
CALL Second(Seconds)Seconds:
REAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Returns the process's runtime in seconds in Seconds---the same value
as the UNIX function etime returns.
This routine is known from Cray Fortran. See CPU_Time Intrinsic for a standard equivalent.
For information on other intrinsics with the same name: See Second Intrinsic (function).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Selected_Int_Kind to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Selected_Real_Kind to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Set_Exponent to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Shape to use this name for an external procedure.
Short(A)Short:
INTEGER(KIND=6) function.
A: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns A with the fractional portion of its
magnitude truncated and its sign preserved, converted
to type INTEGER(KIND=6).
If A is type COMPLEX, its real part
is truncated and converted, and its imaginary part is disgregarded.
See Int Intrinsic.
The precise meaning of this intrinsic might change in a future version of the GNU Fortran language, as more is learned about how it is used.
Sign(A, B)Sign:
INTEGER or REAL function, the exact type being the result of cross-promoting the
types of all the arguments.
A: INTEGER or REAL; scalar; INTENT(IN).
B: INTEGER or REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns ABS(A)*s, where s is +1 if B.GE.0, -1 otherwise.
See Abs Intrinsic, for the function that returns the magnitude of a value.
CALL Signal(Number, Handler, Status)Number:
INTEGER; scalar; INTENT(IN).
Handler: Signal handler (INTEGER FUNCTION or SUBROUTINE)
or dummy/global INTEGER(KIND=1) scalar.
Status: INTEGER(KIND=7); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
If Handler is a an EXTERNAL routine, arranges for it to be
invoked with a single integer argument (of system-dependent length)
when signal Number occurs.
If Handler is an integer, it can be
used to turn off handling of signal Number or revert to its default
action.
See signal(2).
Note that Handler will be called using C conventions,
so the value of its argument in Fortran terms
Fortran terms is obtained by applying %LOC() (or LOC()) to it.
The value returned by signal(2) is written to Status, if
that argument is supplied.
Otherwise the return value is ignored.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
Warning: Use of the libf2c run-time library function
signal_ directly
(such as via EXTERNAL SIGNAL)
requires use of the %VAL() construct
to pass an INTEGER value
(such as SIG_IGN or SIG_DFL)
for the Handler argument.
However, while CALL SIGNAL(signum, %VAL(SIG_IGN))
works when SIGNAL is treated as an external procedure
(and resolves, at link time, to libf2c's signal_ routine),
this construct is not valid when SIGNAL is recognized
as the intrinsic of that name.
Therefore, for maximum portability and reliability, code such references to the SIGNAL facility as follows:
INTRINSIC SIGNAL ···CALL SIGNAL(signum, SIG_IGN)
g77 will compile such a call correctly,
while other compilers will generally either do so as well
or reject the INTRINSIC SIGNAL statement via a diagnostic,
allowing you to take appropriate action.
For information on other intrinsics with the same name: See Signal Intrinsic (function).
Sin(X)Sin:
REAL or COMPLEX function, the exact type being that of argument X.
X: REAL or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the sine of X, an angle measured in radians.
See ASin Intrinsic, for the inverse of this function.
SinH(X)SinH:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the hyperbolic sine of X.
CALL Sleep(Seconds)Seconds:
INTEGER(KIND=1); scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Causes the process to pause for Seconds seconds.
See sleep(2).
Sngl(A)Sngl:
REAL(KIND=1) function.
A: REAL(KIND=2); scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Archaic form of REAL() that is specific
to one type for A.
See Real Intrinsic.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Spacing to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Spread to use this name for an external procedure.
SqRt(X)SqRt:
REAL or COMPLEX function, the exact type being that of argument X.
X: REAL or COMPLEX; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the square root of X, which must not be negative.
To calculate and represent the square root of a negative number, complex arithmetic must be used. For example, SQRT(COMPLEX(X)).
The inverse of this function is SQRT(X) * SQRT(X).
CALL SRand(Seed)Seed:
INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Reinitialises the generator with the seed in Seed. See IRand Intrinsic. See Rand Intrinsic.
CALL Stat(File, SArray, Status)File:
CHARACTER; scalar; INTENT(IN).
SArray: INTEGER(KIND=1); DIMENSION(13); INTENT(OUT).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Obtains data about the given file File and places them in the array
SArray.
A null character (CHAR(0)) marks the end of
the name in File---otherwise,
trailing blanks in File are ignored.
The values in this array are extracted from the
stat structure as returned by fstat(2) q.v., as follows:
Not all these elements are relevant on all systems. If an element is not relevant, it is returned as 0.
If the Status argument is supplied, it contains 0 on success or a non-zero error code upon return.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See Stat Intrinsic (function).
Stat(File, SArray)Stat:
INTEGER(KIND=1) function.
File: CHARACTER; scalar; INTENT(IN).
SArray: INTEGER(KIND=1); DIMENSION(13); INTENT(OUT).
Intrinsic groups: unix.
Description:
Obtains data about the given file File and places them in the array
SArray.
A null character (CHAR(0)) marks the end of
the name in File---otherwise,
trailing blanks in File are ignored.
The values in this array are extracted from the
stat structure as returned by fstat(2) q.v., as follows:
Not all these elements are relevant on all systems. If an element is not relevant, it is returned as 0.
Returns 0 on success or a non-zero error code.
For information on other intrinsics with the same name: See Stat Intrinsic (subroutine).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Sum to use this name for an external procedure.
CALL SymLnk(Path1, Path2, Status)Path1:
CHARACTER; scalar; INTENT(IN).
Path2: CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Makes a symbolic link from file Path1 to Path2.
A null character (CHAR(0)) marks the end of
the names in Path1 and Path2---otherwise,
trailing blanks in Path1 and Path2 are ignored.
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return
(ENOSYS if the system does not provide symlink(2)).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See SymLnk Intrinsic (function).
CALL System(Command, Status)Command:
CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Passes the command Command to a shell (see system(3)).
If argument Status is present, it contains the value returned by
system(3), presumably 0 if the shell command succeeded.
Note that which shell is used to invoke the command is system-dependent
and environment-dependent.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See System Intrinsic (function).
CALL System_Clock(Count, Rate, Max)Count:
INTEGER(KIND=1); scalar; INTENT(OUT).
Rate: INTEGER(KIND=1); scalar; INTENT(OUT).
Max: INTEGER(KIND=1); scalar; INTENT(OUT).
Intrinsic groups: f90.
Description:
Returns in Count the current value of the system clock; this is
the value returned by the UNIX function times(2)
in this implementation, but
isn't in general.
Rate is the number of clock ticks per second and
Max is the maximum value this can take, which isn't very useful
in this implementation since it's just the maximum C unsigned
int value.
Tan(X)Tan:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the tangent of X, an angle measured in radians.
See ATan Intrinsic, for the inverse of this function.
TanH(X)TanH:
REAL function, the KIND= value of the type being that of argument X.
X: REAL; scalar; INTENT(IN).
Intrinsic groups: (standard FORTRAN 77).
Description:
Returns the hyperbolic tangent of X.
Time()Time:
INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the current time encoded as an integer
(in the manner of the UNIX function time(3)).
This value is suitable for passing to CTIME,
GMTIME, and LTIME.
This intrinsic is not fully portable, such as to systems
with 32-bit INTEGER types but supporting times
wider than 32 bits.
See Time8 Intrinsic, for information on a
similar intrinsic that might be portable to more
GNU Fortran implementations, though to fewer
Fortran compilers.
For information on other intrinsics with the same name: See Time Intrinsic (VXT).
Time8()Time8:
INTEGER(KIND=2) function.
Intrinsic groups: unix.
Description:
Returns the current time encoded as a long integer
(in the manner of the UNIX function time(3)).
This value is suitable for passing to CTIME,
GMTIME, and LTIME.
No Fortran implementations other than GNU Fortran are known to support this intrinsic at the time of this writing. See Time Intrinsic (UNIX), for information on a similar intrinsic that might be portable to more Fortran compilers, though to fewer GNU Fortran implementations.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Tiny to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Transfer to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Transpose to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Trim to use this name for an external procedure.
CALL TtyNam(Name, Unit)Name:
CHARACTER; scalar; INTENT(OUT).
Unit: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Sets Name to the name of the terminal device open on logical unit Unit or a blank string if Unit is not connected to a terminal.
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See TtyNam Intrinsic (function).
TtyNam(Unit)TtyNam:
CHARACTER*(*) function.
Unit: INTEGER; scalar; INTENT(IN).
Intrinsic groups: unix.
Description:
Returns the name of the terminal device open on logical unit Unit or a blank string if Unit is not connected to a terminal.
For information on other intrinsics with the same name: See TtyNam Intrinsic (subroutine).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL UBound to use this name for an external procedure.
CALL UMask(Mask, Old)Mask:
INTEGER; scalar; INTENT(IN).
Old: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sets the file creation mask to Mask and returns the old value in
argument Old if it is supplied.
See umask(2).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine.
For information on other intrinsics with the same name: See UMask Intrinsic (function).
CALL Unlink(File, Status)File:
CHARACTER; scalar; INTENT(IN).
Status: INTEGER(KIND=1); OPTIONAL; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Unlink the file File.
A null character (CHAR(0)) marks the end of
the name in File---otherwise,
trailing blanks in File are ignored.
If the Status argument is supplied, it contains
0 on success or a non-zero error code upon return.
See unlink(2).
Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.
For information on other intrinsics with the same name: See Unlink Intrinsic (function).
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Unpack to use this name for an external procedure.
This intrinsic is not yet implemented. The name is, however, reserved as an intrinsic. Use EXTERNAL Verify to use this name for an external procedure.
XOr(I, J)XOr:
INTEGER or LOGICAL function, the exact type being the result of cross-promoting the
types of all the arguments.
I: INTEGER or LOGICAL; scalar; INTENT(IN).
J: INTEGER or LOGICAL; scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Returns value resulting from boolean exclusive-OR of pair of bits in each of I and J.
ZAbs(A)ZAbs:
REAL(KIND=2) function.
A: COMPLEX(KIND=2); scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Archaic form of ABS() that is specific
to one type for A.
See Abs Intrinsic.
ZCos(X)ZCos:
COMPLEX(KIND=2) function.
X: COMPLEX(KIND=2); scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Archaic form of COS() that is specific
to one type for X.
See Cos Intrinsic.
ZExp(X)ZExp:
COMPLEX(KIND=2) function.
X: COMPLEX(KIND=2); scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Archaic form of EXP() that is specific
to one type for X.
See Exp Intrinsic.
ZLog(X)ZLog:
COMPLEX(KIND=2) function.
X: COMPLEX(KIND=2); scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Archaic form of LOG() that is specific
to one type for X.
See Log Intrinsic.
ZSin(X)ZSin:
COMPLEX(KIND=2) function.
X: COMPLEX(KIND=2); scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Archaic form of SIN() that is specific
to one type for X.
See Sin Intrinsic.
ZSqRt(X)ZSqRt:
COMPLEX(KIND=2) function.
X: COMPLEX(KIND=2); scalar; INTENT(IN).
Intrinsic groups: f2c.
Description:
Archaic form of SQRT() that is specific
to one type for X.
See SqRt Intrinsic.
(The following information augments or overrides the information in Chapter 18 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran language. Chapter 18 of that document otherwise serves as the basis for the relevant aspects of GNU Fortran.)
Underscores (_) are accepted in symbol names after the first character (which must be a letter).
GNU Fortran supports a variety of features that are not
considered part of the GNU Fortran language itself, but
are representative of various dialects of Fortran that
g77 supports in whole or in part.
Any of the features listed below might be disallowed by
g77 unless some command-line option is specified.
Currently, some of the features are accepted using the
default invocation of g77, but that might change
in the future.
Note: This portion of the documentation definitely needs a lot of work!
GNU Fortran accepts programs written in either fixed form or free form.
Fixed form corresponds to ANSI FORTRAN 77 (plus popular extensions, such as allowing tabs) and Fortran 90's fixed form.
Free form corresponds to Fortran 90's free form (though possibly not entirely up-to-date, and without complaining about some things that for which Fortran 90 requires diagnostics, such as the spaces in the constant in R = 3 . 1).
The way a Fortran compiler views source files depends entirely on the
implementation choices made for the compiler, since those choices
are explicitly left to the implementation by the published Fortran
standards.
GNU Fortran currently tries to be somewhat like a few popular compilers
(f2c, Digital (``DEC'') Fortran, and so on), though a cleaner default
definition along with more
flexibility offered by command-line options is likely to be offered
in version 0.6.
This section describes how g77 interprets source lines.
Carriage returns (\r) in source lines are ignored.
This is somewhat different from f2c, which seems to treat them as
spaces outside character/Hollerith constants, and encodes them as \r
inside such constants.
A source line with a TAB character anywhere in it is treated as
entirely significant---however long it is---instead of ending in
column 72 (for fixed-form source) or 132 (for free-form source).
This also is different from f2c, which encodes tabs as
\t (the ASCII TAB character) inside character
and Hollerith constants, but nevertheless seems to treat the column
position as if it had been affected by the canonical tab positioning.
g77 effectively
translates tabs to the appropriate number of spaces (a la the default
for the UNIX expand command) before doing any other processing, other
than (currently) noting whether a tab was found on a line and using this
information to decide how to interpret the length of the line and continued
constants.
Note that this default behavior probably will change for version 0.6, when it will presumably be available via a command-line option. The default as of version 0.6 is planned to be a ``pure visual'' model, where tabs are immediately converted to spaces and otherwise have no effect, so the way a typical user sees source lines produces a consistent result no matter how the spacing in those source lines is actually implemented via tabs, spaces, and trailing tabs/spaces before newline. Command-line options are likely to be added to specify whether all or just-tabbed lines are to be extended to 132 or full input-line length, and perhaps even an option will be added to specify the truncated-line behavior to which some Digital compilers default (and which affects the way continued character/Hollerith constants are interpreted).
Source lines shorter than the applicable fixed-form length are treated as if they were padded with spaces to that length. (None of this is relevant to source files written in free form.)
This affects only continued character and Hollerith constants, and is a different interpretation than provided by some other popular compilers (although a bit more consistent with the traditional punched-card basis of Fortran and the way the Fortran standard expressed fixed source form).
g77 might someday offer an option to warn about cases where differences
might be seen as a result of this treatment, and perhaps an option to
specify the alternate behavior as well.
Note that this padding cannot apply to lines that are effectively of infinite length---such lines are specified using command-line options like -ffixed-line-length-none, for example.
Source lines longer than the applicable length are truncated to that
length.
Currently, g77 does not warn if the truncated characters are
not spaces, to accommodate existing code written for systems that
treated truncated text as commentary (especially in columns 73 through 80).
See Options Controlling Fortran Dialect, for information on the -ffixed-line-length-n option, which can be used to set the line length applicable to fixed-form source files.
A & in column 1 of fixed-form source denotes an arbitrary-length
continuation line, imitating the behavior of f2c.
g77 supports use of /* to start a trailing
comment.
In the GNU Fortran language, ! is used for this purpose.
/* is not in the GNU Fortran language because the use of /* in a program might suggest to some readers that a block, not trailing, comment is started (and thus ended by */, not end of line), since that is the meaning of /* in C.
Also, such readers might think they can use // to start a trailing comment as an alternative to /*, but // already denotes concatenation, and such a ``comment'' might actually result in a program that compiles without error (though it would likely behave incorrectly).
Use of D or d as the first character (column 1) of a source line denotes a debug line.
In turn, a debug line is treated as either a comment line or a normal line, depending on whether debug lines are enabled.
When treated as a comment line, a line beginning with D or d is treated as if it the first character was C or c, respectively. When treated as a normal line, such a line is treated as if the first character was SPC (space).
(Currently, g77 provides no means for treating debug
lines as normal lines.)
Dollar signs ($) are allowed in symbol names (after the first character) when the -fdollar-ok option is specified.
GNU Fortran offers the programmer way too much flexibility in deciding how source files are to be treated vis-a-vis uppercase and lowercase characters. There are 66 useful settings that affect case sensitivity, plus 10 settings that are nearly useless, with the remaining 116 settings being either redundant or useless.
None of these settings have any effect on the contents of comments (the text after a c or C in Column 1, for example) or of character or Hollerith constants. Note that things like the E in the statement CALL FOO(3.2E10) and the TO in ASSIGN 10 TO LAB are considered built-in keywords, and so are affected by these settings.
Low-level switches are identified in this section as follows:
Note 1: g77 eventually will support NAMELIST in a manner that is
consistent with these source switches---in the sense that input will be
expected to meet the same requirements as source code in terms
of matching symbol names and keywords (for the exponent letters).
Currently, however, NAMELIST is supported by libf2c,
which uppercases NAMELIST input and symbol names for matching.
This means not only that NAMELIST output currently shows symbol
(and keyword) names in uppercase even if lower-case source
conversion (option A2) is selected, but that NAMELIST cannot be
adequately supported when source case preservation (option A0)
is selected.
If A0 is selected, a warning message will be
output for each NAMELIST statement to this effect.
The behavior
of the program is undefined at run time if two or more symbol names
appear in a given NAMELIST such that the names are identical
when converted to upper case (e.g. NAMELIST /X/ VAR, Var, var).
For complete and total elegance, perhaps there should be a warning
when option A2 is selected, since the output of NAMELIST is currently
in uppercase but will someday be lowercase (when a libg77 is written),
but that seems to be overkill for a product in beta test.
Note 2: Rules for InitialCaps names are:
So A, Ab, ABc, AbC, and Abc are valid InitialCaps names, but AB, A2, and ABC are not. Note that most, but not all, built-in names meet these requirements---the exceptions are some of the two-letter format specifiers, such as BN and BZ.
Here are the names of the corresponding command-line options:
A0: -fsource-case-preserve A1: -fsource-case-upper A2: -fsource-case-lower B0: -fmatch-case-any B1: -fmatch-case-upper B2: -fmatch-case-lower B3: -fmatch-case-initcap C0: -fintrin-case-any C1: -fintrin-case-upper C2: -fintrin-case-lower C3: -fintrin-case-initcap D0: -fsymbol-case-any D1: -fsymbol-case-upper D2: -fsymbol-case-lower D3: -fsymbol-case-initcap
Useful combinations of the above settings, along with abbreviated option names that set some of these combinations all at once:
1: A0-- B0--- C0--- D0--- -fcase-preserve 2: A0-- B0--- C0--- D-1-- 3: A0-- B0--- C0--- D--2- 4: A0-- B0--- C0--- D---3 5: A0-- B0--- C-1-- D0--- 6: A0-- B0--- C-1-- D-1-- 7: A0-- B0--- C-1-- D--2- 8: A0-- B0--- C-1-- D---3 9: A0-- B0--- C--2- D0--- 10: A0-- B0--- C--2- D-1-- 11: A0-- B0--- C--2- D--2- 12: A0-- B0--- C--2- D---3 13: A0-- B0--- C---3 D0--- 14: A0-- B0--- C---3 D-1-- 15: A0-- B0--- C---3 D--2- 16: A0-- B0--- C---3 D---3 17: A0-- B-1-- C0--- D0--- 18: A0-- B-1-- C0--- D-1-- 19: A0-- B-1-- C0--- D--2- 20: A0-- B-1-- C0--- D---3 21: A0-- B-1-- C-1-- D0--- 22: A0-- B-1-- C-1-- D-1-- -fcase-strict-upper 23: A0-- B-1-- C-1-- D--2- 24: A0-- B-1-- C-1-- D---3 25: A0-- B-1-- C--2- D0--- 26: A0-- B-1-- C--2- D-1-- 27: A0-- B-1-- C--2- D--2- 28: A0-- B-1-- C--2- D---3 29: A0-- B-1-- C---3 D0--- 30: A0-- B-1-- C---3 D-1-- 31: A0-- B-1-- C---3 D--2- 32: A0-- B-1-- C---3 D---3 33: A0-- B--2- C0--- D0--- 34: A0-- B--2- C0--- D-1-- 35: A0-- B--2- C0--- D--2- 36: A0-- B--2- C0--- D---3 37: A0-- B--2- C-1-- D0--- 38: A0-- B--2- C-1-- D-1-- 39: A0-- B--2- C-1-- D--2- 40: A0-- B--2- C-1-- D---3 41: A0-- B--2- C--2- D0--- 42: A0-- B--2- C--2- D-1-- 43: A0-- B--2- C--2- D--2- -fcase-strict-lower 44: A0-- B--2- C--2- D---3 45: A0-- B--2- C---3 D0--- 46: A0-- B--2- C---3 D-1-- 47: A0-- B--2- C---3 D--2- 48: A0-- B--2- C---3 D---3 49: A0-- B---3 C0--- D0--- 50: A0-- B---3 C0--- D-1-- 51: A0-- B---3 C0--- D--2- 52: A0-- B---3 C0--- D---3 53: A0-- B---3 C-1-- D0--- 54: A0-- B---3 C-1-- D-1-- 55: A0-- B---3 C-1-- D--2- 56: A0-- B---3 C-1-- D---3 57: A0-- B---3 C--2- D0--- 58: A0-- B---3 C--2- D-1-- 59: A0-- B---3 C--2- D--2- 60: A0-- B---3 C--2- D---3 61: A0-- B---3 C---3 D0--- 62: A0-- B---3 C---3 D-1-- 63: A0-- B---3 C---3 D--2- 64: A0-- B---3 C---3 D---3 -fcase-initcap 65: A-1- B01-- C01-- D01-- -fcase-upper 66: A--2 B0-2- C0-2- D0-2- -fcase-lower
Number 22 is the ``strict'' ANSI FORTRAN 77 model wherein all input (except comments, character constants, and Hollerith strings) must be entered in uppercase. Use -fcase-strict-upper to specify this combination.
Number 43 is like Number 22 except all input must be lowercase. Use -fcase-strict-lower to specify this combination.
Number 65 is the ``classic'' ANSI FORTRAN 77 model as implemented on many non-UNIX machines whereby all the source is translated to uppercase. Use -fcase-upper to specify this combination.
Number 66 is the ``canonical'' UNIX model whereby all the source is translated to lowercase. Use -fcase-lower to specify this combination.
There are a few nearly useless combinations:
67: A-1- B01-- C01-- D--2- 68: A-1- B01-- C01-- D---3 69: A-1- B01-- C--23 D01-- 70: A-1- B01-- C--23 D--2- 71: A-1- B01-- C--23 D---3 72: A--2 B01-- C0-2- D-1-- 73: A--2 B01-- C0-2- D---3 74: A--2 B01-- C-1-3 D0-2- 75: A--2 B01-- C-1-3 D-1-- 76: A--2 B01-- C-1-3 D---3
The above allow some programs to be compiled but with restrictions that make most useful programs impossible: Numbers 67 and 72 warn about any user-defined symbol names (such as SUBROUTINE FOO); Numbers 68 and 73 warn about any user-defined symbol names longer than one character that don't have at least one non-alphabetic character after the first; Numbers 69 and 74 disallow any references to intrinsics; and Numbers 70, 71, 75, and 76 are combinations of the restrictions in 67+69, 68+69, 72+74, and 73+74, respectively.
All redundant combinations are shown in the above tables anyplace where more than one setting is shown for a low-level switch. For example, B0-2- means either setting 0 or 2 is valid for switch B. The ``proper'' setting in such a case is the one that copies the setting of switch A---any other setting might slightly reduce the speed of the compiler, though possibly to an unmeasurable extent.
All remaining combinations are useless in that they prevent successful compilation of non-null source files (source files with something other than comments).
g77 supports certain constructs that
have different meanings in VXT Fortran than they
do in the GNU Fortran language.
Generally, this manual uses the invented term VXT Fortran to refer VAX FORTRAN (circa v4). That compiler offered many popular features, though not necessarily those that are specific to the VAX processor architecture, the VMS operating system, or Digital Equipment Corporation's Fortran product line. (VAX and VMS probably are trademarks of Digital Equipment Corporation.)
An extension offered by a Digital Fortran product that also is
offered by several other Fortran products for different kinds of
systems is probably going to be considered for inclusion in g77
someday, and is considered a VXT Fortran feature.
The -fvxt option generally specifies that, where the meaning of a construct is ambiguous (means one thing in GNU Fortran and another in VXT Fortran), the VXT Fortran meaning is to be assumed.
g77 treats double-quote (")
as beginning an octal constant of INTEGER(KIND=1) type
when the -fvxt option is specified.
The form of this octal constant is
"octal-digitswhere octal-digits is a nonempty string of characters in the set 01234567.
For example, the -fvxt option permits this:
PRINT *, "20 ENDThe above program would print the value 16.
See Integer Type, for information on the preferred construct for integer constants specified using GNU Fortran's octal notation.
(In the GNU Fortran language, the double-quote character (") delimits a character constant just as does apostrophe ('). There is no way to allow both constructs in the general case, since statements like PRINT *,"2000 !comment?" would be ambiguous.)
g77 treats an exclamation point (!) in column 6 of
a fixed-form source file
as a continuation character rather than
as the beginning of a comment
(as it does in any other column)
when the -fvxt option is specified.
The following program, when run, prints a message indicating whether it is interpreted according to GNU Fortran (and Fortran 90) rules or VXT Fortran rules:
C234567 (This line begins in column 1.)
I = 0
!1
IF (I.EQ.0) PRINT *, ' I am a VXT Fortran program'
IF (I.EQ.1) PRINT *, ' I am a Fortran 90 program'
IF (I.LT.0 .OR. I.GT.1) PRINT *, ' I am a HAL 9000 computer'
END
(In the GNU Fortran and Fortran 90 languages, exclamation point is a valid character and, unlike space (SPC) or zero (0), marks a line as a continuation line when it appears in column 6.)
The GNU Fortran language includes a number of features that are
part of Fortran 90, even when the -ff90 option is not specified.
The features enabled by -ff90 are intended to be those that,
when -ff90 is not specified, would have another
meaning to g77---usually meaning something invalid in the
GNU Fortran language.
So, the purpose of -ff90 is not to specify whether g77 is
to gratuitously reject Fortran 90 constructs.
The -pedantic option specified with -fno-f90 is intended
to do that, although its implementation is certainly incomplete at
this point.
When -ff90 is specified:
COMPLEX type,
is the same type as the real part of expr.
For example, assuming Z is type COMPLEX(KIND=2),
REAL(Z) would return a value of type REAL(KIND=2),
not of type REAL(KIND=1), since -ff90 is specified.
The -fpedantic command-line option specifies that g77
is to warn about code that is not standard-conforming.
This is useful for finding
some extensions g77 accepts that other compilers might not accept.
(Note that the -pedantic and -pedantic-errors options
always imply -fpedantic.)
With -fno-f90 in force, ANSI FORTRAN 77 is used as the standard for conforming code. With -ff90 in force, Fortran 90 is used.
The constructs for which g77 issues diagnostics when -fpedantic
and -fno-f90 are in force are:
SUBROUTINE X(N) REAL A(N) ···where A is not listed in any
ENTRY statement,
and thus is not a dummy argument.
These commas are disallowed by FORTRAN 77, but, while strictly superfluous, are syntactically elegant, especially given that commas are required in statements such as READ 99, I and PRINT *, J. Many compilers permit the superfluous commas for this reason.
DOUBLE COMPLEX, either explicitly or implicitly.
An explicit use of this type is via a DOUBLE COMPLEX or
IMPLICIT DOUBLE COMPLEX statement, for examples.
An example of an implicit use is the expression C*D,
where C is COMPLEX(KIND=1)
and D is DOUBLE PRECISION.
This expression is prohibited by ANSI FORTRAN 77
because the rules of promotion would suggest that it
produce a DOUBLE COMPLEX result---a type not
provided for by that standard.
INTEGER(KIND=1) in contexts such as:
GOTO.
FORMAT run-time expressions (not yet supported).
CHARACTER entities in specification statements.
DO
constructs in DATA statements.
LOGICAL expressions to INTEGER
in contexts such as arithmetic IF (where COMPLEX
expressions are disallowed anyway).
INTEGER I(10,20,4:2)
CHARACTER entities, as in:
PRINT *, ''
PRINT *, 'hello'(3:5)
PRINT *, FOO(,3)
COMMON
area is SAVEd (for targets where program units in a single source
file are ``glued'' together as they typically are for UNIX development
environments).
COMMON block.
DATA statement.
(In the GNU Fortran language, DATA I/1/ may be followed by INTEGER J, but not INTEGER I. The -fpedantic option disallows both of these.)
CALL FOO; CALL BAR
CHARACTER constants to initialize numeric entities, and vice
versa.
If -fpedantic is specified along with -ff90, the following constructs result in diagnostics:
INCLUDE directive.
The -fugly-* command-line options determine whether certain features supported by VAX FORTRAN and other such compilers, but considered too ugly to be in code that can be changed to use safer and/or more portable constructs, are accepted. These are humorously referred to as ``distensions'', extensions that just plain look ugly in the harsh light of day.
Note: The -fugly option, which currently serves
as shorthand to enable all of the distensions below, is likely to
be removed in a future version of g77.
That's because it's likely new distensions will be added that
conflict with existing ones in terms of assigning meaning to
a given chunk of code.
(Also, it's pretty clear that users should not use -fugly
as shorthand when the next release of g77 might add a
distension to that that causes their existing code, when recompiled,
to behave differently---perhaps even fail to compile or run
correctly.)
The -fno-ugly-args option disables passing typeless and Hollerith constants as actual arguments in procedure invocations. For example:
CALL FOO(4HABCD)
CALL BAR('123'O)
These constructs can be too easily used to create non-portable
code, but are not considered as ``ugly'' as others.
Further, they are widely used in existing Fortran source code
in ways that often are quite portable.
Therefore, they are enabled by default.
The -fugly-assumed option enables the treatment of any array with a final dimension specified as 1 as an assumed-size array, as if * had been specified instead.
For example, DIMENSION X(1) is treated as if it
had read DIMENSION X(*) if X is listed as
a dummy argument in a preceding SUBROUTINE, FUNCTION,
or ENTRY statement in the same program unit.
Use an explicit lower bound to avoid this interpretation. For example, DIMENSION X(1:1) is never treated as if it had read DIMENSION X(*) or DIMENSION X(1:*). Nor is DIMENSION X(2-1) affected by this option, since that kind of expression is unlikely to have been intended to designate an assumed-size array.
This option is used to prevent warnings being issued about apparent out-of-bounds reference such as X(2) = 99.
It also prevents the array from being used in contexts that disallow assumed-size arrays, such as PRINT *,X. In such cases, a diagnostic is generated and the source file is not compiled.
The construct affected by this option is used only in old code that pre-exists the widespread acceptance of adjustable and assumed-size arrays in the Fortran community.
Note: This option does not affect how DIMENSION X(1) is
treated if X is listed as a dummy argument only
after the DIMENSION statement (presumably in
an ENTRY statement).
For example, -fugly-assumed has no effect on the
following program unit:
SUBROUTINE X REAL A(1) RETURN ENTRY Y(A) PRINT *, A END
The -fugly-complex option enables
use of the REAL() and AIMAG()
intrinsics with arguments that are
COMPLEX types other than COMPLEX(KIND=1).
With -ff90 in effect, these intrinsics return the unconverted real and imaginary parts (respectively) of their argument.
With -fno-f90 in effect, these intrinsics convert
the real and imaginary parts to REAL(KIND=1), and return
the result of that conversion.
Due to this ambiguity, the GNU Fortran language defines
these constructs as invalid, except in the specific
case where they are entirely and solely passed as an
argument to an invocation of the REAL() intrinsic.
For example,
REAL(REAL(Z))is permitted even when Z is
COMPLEX(KIND=2)
and -fno-ugly-complex is in effect, because the
meaning is clear.
g77 enforces this restriction, unless -fugly-complex
is specified, in which case the appropriate interpretation is
chosen and no diagnostic is issued.
See CMPAMBIG, for information on how to cope with existing
code with unclear expectations of REAL() and AIMAG()
with COMPLEX(KIND=2) arguments.
See RealPart Intrinsic, for information on the REALPART()
intrinsic, used to extract the real part of a complex expression
without conversion.
See ImagPart Intrinsic, for information on the IMAGPART()
intrinsic, used to extract the imaginary part of a complex expression
without conversion.
The -fugly-comma option enables use of a single trailing comma to mean ``pass an extra trailing null argument'' in a list of actual arguments to an external procedure, and use of an empty list of arguments to such a procedure to mean ``pass a single null argument''.
(Null arguments often are used in some procedure-calling schemes to indicate omitted arguments.)
For example, CALL FOO(,) means ``pass two null arguments'', rather than ``pass one null argument''. Also, CALL BAR() means ``pass one null argument''.
This construct is considered ``ugly'' because it does not provide an elegant way to pass a single null argument that is syntactically distinct from passing no arguments. That is, this construct changes the meaning of code that makes no use of the construct.
So, with -fugly-comma in force, CALL FOO() and I = JFUNC() pass a single null argument, instead of passing no arguments as required by the Fortran 77 and 90 standards.
Note: Many systems gracefully allow the case where a procedure call passes one extra argument that the called procedure does not expect.
So, in practice, there might be no difference in the behavior of a program that does CALL FOO() or I = JFUNC() and is compiled with -fugly-comma in force as compared to its behavior when compiled with the default, -fno-ugly-comma, in force, assuming FOO and JFUNC do not expect any arguments to be passed.
The constructs disabled by -fno-ugly-init are:
DATA and PARAMETER statements, plus
type-declaration statements specifying initial values.
Here are some sample initializations that are disabled by the -fno-ugly-init option:
PARAMETER (VAL='9A304FFE'X) REAL*8 STRING/8HOUTPUT00/ DATA VAR/4HABCD/
Here are more sample initializations that are disabled by the -fno-ugly-init option:
INTEGER IA CHARACTER BELL PARAMETER (IA = 'A') PARAMETER (BELL = 7)
Here are sample statements that are disabled by the -fno-ugly-init option:
IVAR = 4HABCD PRINT *, IMAX0(2HAB, 2HBA)
The above constructs, when used, can tend to result in non-portable code. But, they are widely used in existing Fortran code in ways that often are quite portable. Therefore, they are enabled by default.
The constructs enabled via -fugly-logint are:
INTEGER and LOGICAL as
dictated by
context (typically implies nonportable dependencies on how a
particular implementation encodes .TRUE. and .FALSE.).
LOGICAL variable in ASSIGN and assigned-GOTO
statements.
The above constructs are disabled by default because use of them tends to lead to non-portable code. Even existing Fortran code that uses that often turns out to be non-portable, if not outright buggy.
Some of this is due to differences among implementations as
far as how .TRUE. and .FALSE. are encoded as
INTEGER values---Fortran code that assumes a particular
coding is likely to use one of the above constructs, and is
also likely to not work correctly on implementations using
different encodings.
See Equivalence Versus Equality, for more information.
The -fugly-assign option forces g77 to use the
same storage for assigned labels as it would for a normal
assignment to the same variable.
For example, consider the following code fragment:
I = 3 ASSIGN 10 TO INormally, for portability and improved diagnostics,
g77
reserves distinct storage for a ``sibling'' of I, used
only for ASSIGN statements to that variable (along with
the corresponding assigned-GOTO and assigned-FORMAT-I/O
statements that reference the variable).
However, some code (that violates the ANSI FORTRAN 77 standard)
attempts to copy assigned labels among variables involved with
ASSIGN statements, as in:
ASSIGN 10 TO I ISTATE(5) = I ···J = ISTATE(ICUR) GOTO JSuch code doesn't work under
g77 unless -fugly-assign
is specified on the command-line, ensuring that the value of I
referenced in the second line is whatever value g77 uses
to designate statement label 10, so the value may be
copied into the ISTATE array, later retrieved into a
variable of the appropriate type (J), and used as the target of
an assigned-GOTO statement.
Note: To avoid subtle program bugs,
when -fugly-assign is specified,
g77 requires the type of variables
specified in assigned-label contexts
must be the same type returned by %LOC().
On many systems, this type is effectively the same
as INTEGER(KIND=1), while, on others, it is
effectively the same as INTEGER(KIND=2).
Do not depend on g77 actually writing valid pointers
to these variables, however.
While g77 currently chooses that implementation, it might
be changed in the future.
See Assigned Statement Labels (ASSIGN and GOTO), for implementation details on assigned-statement labels.
The GNU Fortran compiler, g77, supports programs written
in the GNU Fortran language and in some other dialects of Fortran.
Some aspects of how g77 works are universal regardless
of dialect, and yet are not properly part of the GNU Fortran
language itself.
These are described below.
Note: This portion of the documentation definitely needs a lot of work!
g77, as with GNU tools in general, imposes few arbitrary restrictions
on lengths of identifiers, number of continuation lines, number of external
symbols in a program, and so on.
For example, some other Fortran compiler have an option (such as -Nlx) to increase the limit on the number of continuation lines. Also, some Fortran compilation systems have an option (such as -Nxx) to increase the limit on the number of external symbols.
g77, gcc, and GNU ld (the GNU linker) have
no equivalent options, since they do not impose arbitrary
limits in these areas.
g77 does currently limit the number of dimensions in an array
to the same degree as do the Fortran standards---seven (7).
This restriction might well be lifted in a future version.
Fortran implementations have a fair amount of freedom given them by the
standard as far as how much storage space is used and how much precision
and range is offered by the various types such as LOGICAL(KIND=1),
INTEGER(KIND=1), REAL(KIND=1), REAL(KIND=2),
COMPLEX(KIND=1), and CHARACTER.
Further, many compilers offer so-called *n notation, but
the interpretation of n varies across compilers and target architectures.
The standard requires that LOGICAL(KIND=1), INTEGER(KIND=1),
and REAL(KIND=1)
occupy the same amount of storage space, and that COMPLEX(KIND=1)
and REAL(KIND=2) take twice as much storage space as REAL(KIND=1).
Further, it requires that COMPLEX(KIND=1)
entities be ordered such that when a COMPLEX(KIND=1) variable is
storage-associated (such as via EQUIVALENCE)
with a two-element REAL(KIND=1) array named R, R(1)
corresponds to the real element and R(2) to the imaginary
element of the COMPLEX(KIND=1) variable.
(Few requirements as to precision or ranges of any of these are
placed on the implementation, nor is the relationship of storage sizes of
these types to the CHARACTER type specified, by the standard.)
g77 follows the above requirements, warning when compiling
a program requires placement of items in memory that contradict the
requirements of the target architecture.
(For example, a program can require placement of a REAL(KIND=2)
on a boundary that is not an even multiple of its size, but still an
even multiple of the size of a REAL(KIND=1) variable.
On some target architectures, using the canonical
mapping of Fortran types to underlying architectural types, such
placement is prohibited by the machine definition or
the Application Binary Interface (ABI) in force for
the configuration defined for building gcc and g77.
g77 warns about such
situations when it encounters them.)
g77 follows consistent rules for configuring the mapping between Fortran
types, including the *n notation, and the underlying architectural
types as accessed by a similarly-configured applicable version of the
gcc compiler.
These rules offer a widely portable, consistent Fortran/C
environment, although they might well conflict with the expectations of
users of Fortran compilers designed and written for particular
architectures.
These rules are based on the configuration that is in force for the
version of gcc built in the same release as g77 (and
which was therefore used to build both the g77 compiler
components and the libf2c run-time library):
float type.
float---usually, this is a double.
float---usually, this is either
an int or a long int.
gcc type as INTEGER(KIND=1).
INTEGER(KIND=1)---usually, this is either
a long int or a long long int.
gcc type as INTEGER(KIND=2).
gcc type as signed char.
gcc type as INTEGER(KIND=3).
INTEGER(KIND=3)---usually, this is
a short.