|Fortran 2003 features||Absoft||Cray||g95||GNU||HP||IBM||Intel||NAG||Oracle||PathScale||PGI|
|Compiler Version Number||14||8.1.1||4.7/4.8||14.1||14.0.0||5.3.1||12.4 Beta||4||14.9|
|ISO TR 15580 IEEE Arithmetic||Y||Y||P||N||Y||Y||Y||Y||Y||Y||Y|
|ISO TR 15581 Allocatable Enhancements||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Data enhancements and object orientation||Absoft||Cray||g95||GNU||HP||IBM||Intel||NAG||Oracle||PathScale||PGI|
|Parameterized derived types||N||Y||N||N||N||Y||N||N||N||N||Y|
|Procedures bound by name to a type||N||Y||N||Y||N||Y||Y||Y||Y||N||Y|
|The PASS attribute||Y||Y||N||Y||Y||Y||Y||Y||Y||N||Y|
|Procedures bound to a type as operators||N||Y||N||Y||N||Y||Y||Y||Y||N||Y|
|Overriding a type-bound procedure||N||Y||N||Y||N||Y||Y||Y||Y||N||Y|
|SELECT TYPE construct||N||Y||N||P||N||Y||Y||Y||Y||N||Y|
|Deferred bindings and abstract types||Y||Y||N||Y||N||Y||Y||Y||Y||N||Y|
|Allocatable scalars (12)||?||Y||?||Y||N||Y||Y||Y||Y||N||Y|
|Allocatable character length (12)||?||Y||?||P||N||Y||Y||Y||Y||N||Y|
|Structure constructor changes||Y||Y||Y||Y||N||Y||Y||Y||Y||N||Y|
|Generic procedure interfaces with the same name as a type (32)||?||?||?||? (31)||?||Y||Y||Y||Y||N||Y|
|The allocate statement||P||Y||P||Y||N||Y||Y||Y||Y||N||Y|
|Assignment to an allocatable array||N||Y (2)||N||P||Y||Y||Y (2)||Y||Y||N||Y (2)|
|Transferring an allocation||N||Y||N||Y||N||Y||Y||Y||Y||N||Y|
|More control of access from a module||Y||Y||N||Y||N||Y||Y||Y||Y||N||Y|
|Renaming operators on the USE statement||Y||Y||Y||P||N||Y||Y||Y||Y||N||Y|
|The VOLATILE attribute||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|The IMPORT statement||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Access to the computing environment||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Support for international character sets||P (19)||P (19)||Y||Y||N||P||P (19)||Y||N||N||P (19)|
|Lengths of names and statements||Y||Y||?||Y||Y||Y||Y||Y||Y||Y||Y|
|Binary, octal and hex constants||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Array constructor syntax||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Specification and initialization expressions||Y||Y||Y||P||Y||Y||P||Y||Y||N||Y|
|Changes to intrinsic functions||Y||Y||Y||P (9)||Y||Y||Y||Y||Y||?||Y|
|Controlling IEEE underflow||Y||Y||N||N||Y||Y||Y||Y||Y||Y||Y|
|Another IEEE class value||Y||Y||N||N||Y||Y||Y||Y||Y||Y||Y|
|Derived type input/output||N||Y||N||N||N||Y||Y||N||N||N||Y|
|Asynchronous input/output||Y||Y||Y||Y (10)||N||Y||Y||Y||Y||N||Y|
|Stream access input/output||N||Y||Y||Y||N||Y||Y||Y||Y||N||Y|
|ROUND= specifier||Y||Y||P||P (30)||Y||Y||Y (20)||Y||Y||N||Y|
|DECIMAL= specifier||Y||Y||Y||Y||Y||Y||Y (22)||Y||Y||N||Y|
|SIGN= specifier||Y||Y||Y||Y||Y||Y||Y (21)||Y||Y||N||Y|
|Kind type parameters of integer specifiers||N||Y||?||N||N||Y||Y||Y||Y||N||Y|
|Intrinsic function for newline character||N||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Input and output of IEEE exceptional values||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Comma after a P edit descriptor||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Interoperability with C||Absoft||Cray||g95||GNU||HP||IBM||Intel||NAG||Oracle||PathScale||PGI|
|Interoperability of intrinsic types||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Interoperability with C pointers||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Interoperability of derived types||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Interoperability of variables||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Interoperability of procedures||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y||Y|
|Interoperability of global data||Y||Y||Y||Y||Y||Y||Y||Y||Y||N||Y|
Legend: Y = Yes, N = No, P = Partial, ? = Not Known
(2) Optional under flag;
(10) implemented as synchronous I/O;
(19) selected_char_kind only;
(20) plus RC, RD, RN, RP, RU, RZ;
(21) plus BLANK=, DELIM=, PAD=, SIZE=;
(22) plus DC,DP;
(30) only for output.
(31) Partial in the 4.9 development version.
(32) These user-defined functions are not to be confused with a type’s structure constructor, which is generated automatically. Structure constructors have also changed in Fortran 2003, e.g. by treating components with default initialization as optional arguments.
Changes between December 2010 and April 2011:
Cray supports ISO TR 15580 IEEE arithmetic, renaming operators on the USE statement, controlling IEEE underflow, another IEEE class value, and the ROUND= specifier.
GNU supports allocatable character length and partially supports assignment to an allocatable array.
HP supports ISO TR 15580 IEEE arithmetic and lengths of names
IBM supports more control of access from a module, renaming operators on the USE statement, and lengths of names and statements.
Intel added finalization, pointer assignment and other items.
Added new columns for Absoft and PGI compilers.
No changes between August 2010 and December 2010.
Changes between April 2010 and August 2010:
Changes between December 2009 and April 2010:
“Compiler Support for the Fortran 2003 and 2008 Standards” is a series of articles in the ACM Fortran Forum by Ian D. Chivers and Jane Sleightholme. Links to previous revisions are given below:
Fortran Forum 29(3), 26-34, December 2010
After modifying the contents of cells in the table, the following Emacs lisp function can be used to synchronize the cell colors with the cell contents:
(defun fortranwiki-update-status-table () (interactive) (save-excursion (beginning-of-buffer) (replace-regexp "#[0-9a-f]+\">Y" "#bbddbb\">Y") (beginning-of-buffer) (replace-regexp "#[0-9a-f]+\">N" "#ffaaaa\">N") (beginning-of-buffer) (replace-regexp "#[0-9a-f]+\">P" "#ffffdd\">P") (beginning-of-buffer) (replace-regexp "#[0-9a-f]+\">\\?" "#eeeeee\">?")))
If you are new to the wiki, here is how to start:
Edit this page by clicking the “Edit” link at the bottom and add your name to the list below surrounded by square brackets to create a wiki link.
Type your name again in the “Submit as” field at the bottom of the page and save your changes by clicking the “Submit” button.
When the page reloads, your name should appear in the list followed by a question mark, indicating a link to a page which doesn’t exist yet. Follow this link to create your user page.
Edit and save your user page, optionally adding some information about yourself such how you use Fortran or a link to your homepage.
There are many editors that support Fortran syntax highlighting.
(TODO expand this list) * Code::Blocks IDE for Fortran An IDE for Fortran 2003 and 2008. * Emacs – V 23.x and later come with f90-mode supporting Fortran 2003. * gedit – free-format Fortran 95 * jed – Programmer’s editor that supports fixed-format Fortran 77 and free-format Fortran 2003 modes with syntax highlighting and smart indentation. * Vim – Supports Fortran syntax up to Fortran 95, but see below. * NEdit – GUI editor with some Fortran support. It used to be a good choice, but is rather obsolete compared to gedit. * Eclipse with Photran – For the IDE users. * Geany: GUI editor with support for many languages as well as Fortran; see below. * Sublime Text 2 – A beautiful text editor (paid but no enforced time limit for free use) that supports Fortran syntax via Textmate bundle. * Kate: – Has syntax highlighting and indentation for Fortran. * Zeus: – A (shareware) programmer’s editor for Windows with Fortran syntax highlighting and code navigation.
An enhanced Vim syntax file that includes Fortran 2003 keywords is available here:
The following can be added to
$HOME/.vimrc. It maps
<shift>-F to toggle between fixed and free format Fortran source. In case it is hit by mistake,
<ctrl>-F is mapped to re-detect the syntax.
nmap <S-F> :set syntax=fortran<CR>:let b:fortran_fixed_source=!b:fortran_fixed_source<CR>:set syntax=text<CR>:set syntax=fortran<CR> nmap <C-F> :filetype detect<CR>
When editing Fortran on Linux I use gedit which is adequate. When editing Fortran on Microsoft Windows (TM) there are lots of editors available, none of them (in my experience) really good enough. Here are my thoughts on a few that I’ve used more than a few times:
Code::Blocks IDE for Fortran (http://darmar.vgtu.lt/): Recommended! Originally developed for C++, this advanced IDE has many features of eclipse and supports most features of Fortran 2003 and 2008. The environment is quite user friendly and easy to use. It is one of the few true IDEs for Fortran. I think the support of the Fortran community will help this IDE to become a very powerful general purpose and fast Fortran programming tool.
Jedit - written in Java - when opening more than one file this has no tabs but a drop-down list at the top, which I find less convenient. But it has good Fortran90 aware syntax highlighting (I had to make a small change to the configuration file to prevent every line starting with C being treated as a comment, but that was not difficult). But the print system is a Java-special, not using the regular Windows print menu, so you can’t alter your printer defaults, e.g. to print 2 pages per sheet of paper. This is an annoyance.
Gedit - there is a windows binary to download which worked with no trouble, but there is no manual and no help (missing file). The syntax highlighting did work for Fortran90, but it did not understand the .f90 or .f95 file extension, and had to be set each time, which was very tedious. I could not find the relevant file on the website, nor when I untarred a regular gedit distribution. Looking at the help on a Linux box there did not seem to be a way of associating file extensions with language highlighting.
Notepad++ - has tabbed browsing, and uses regular Windows printing, but the syntax highlighting was set for Fortran77, and was really not useful. After being annoyed by it for some time, I found it best to disable the highlighting entirely. In principle one could define one’s own Fortran90 syntax file, but I couldn’t be bothered to do this. Apart from this it’s a fairly good editor.
Notetab light - the free version of a commercial editor notetab. This is another adequate editor: regular Windows printing, no tabbed file opening, no syntax highlighting. It seems to have no particular features that at least one of the others has.
Geany(http://www.geany.org/): This is a free open source editor with many capabilities which also supports programming in Fortran. There are several plugins to deal with project management, debugging etc. The editor lets you for extensive customization for a programming language and even adding new one! It is available for both Windows and Linux.
Simply Fortran(http://simplyfortran.com/): lightweight IDE for MS Windows and compatible operating systems. Made with GNU Fortran in mind, but configurable with most compilers, it comes with an intergrated development environment, a graphical debugger, and a collection of other development accessories. In early stages of development as of now, has some bugs, but the author’s working on them.
Programmer’s Notepad - A general source code editor for MS Windows. It can be configured to build Fortran files with arbitrary command lines, or to invoke make in a particular directory. Like many editors, it is C-centric, but the Fortran support is adequate.
Absoft Pro Fortran - A IDE developed by Absoft specially for Fortran. http://www.absoft.com/
PreForM.py is a pre-processor for modern Fortran projects, written in Python.
PreForM.py supports the most used cpp pre-processing directives and provides advanced features typical of templating systems.
As a matter of fact, many Fortran developers use cpp, the C pre-processor, being one of the most diffused and standardised pre-processor. cpp is a great pre-processor, but it is basically a macro processor, meaning that it is quite focused on macro expansion/substitution/evaluation. cpp has some limitations that makes complex using it as a template system. Let us suppose we want to write a generic interface as the following:
... interface foo module procedure foo1 module procedure foo2 module procedure foo3 endinterface contains function foo1(in) result(out) type(first), intent(IN):: in logical:: out out = in%logical_test() endfunction foo1 function foo2(in) result(out) type(second), intent(IN):: in logical:: out out = in%logical_test() endfunction foo2 function foo3(in) result(out) type(third), intent(IN):: in logical:: out out = in%logical_test() endfunction foo3 ...
Writing a macro in cpp syntax to generalize such a generic interface implementation is quite impossible. On the contrary, using PreForM.py as a template system the implementation becomes very simple and elegant:
... interface foo #PFM for i in [1,2,3]: module procedure foo$i #PFM endfor endinterface contains #PFM for i in [1,2,3] and t in [first,second,third]: function foo$i(in) result(out) type($t), intent(IN):: in logical:: out out = in%logical_test() endfunction foo$i #PFM endfor ...
PreForM.py is just a pre-processor for Fortran poor-men supporting the most used cpp directives, but overtaking some of the cpp limitations in order to make PreForM.py similar to a template system using directly the power of Python syntax.
Even if PreForM.py is currently Fortran-agnostic (it being usable within any programming languages) it is focused on Fortran programming language.
Preprocessors serve multiple purposes, including conditional-compilation, macros for code simplification, and inclusion of additional source files. Fortran originally had no proper preprocessor, so it became common to use
cpp. However, cpp is not fully compatible with Fortran source, so Sun developed
fpp, a Fortran-compatible version of
cpp. Around the same time, Fortran 95 defined an optional conditional-compilation preprocessor, called
fpp is essentially the de facto standard Fortran preprocessor, although some compilers still invoke
cpp in traditional mode. Compilers that support
fpp usually support Predefined preprocessor macros that aid compiler-specific code requirements. Although
coco is an official standard, it is generally not supported directly by Fortran compilers, and therefore loses the benefit of compiler-defined preprocessor tokens.
FRUIT is available at http://sourceforge.net/projects/fortranxunit.
A Python interface to FRUIT is available at https://github.com/acroucher/FRUITPy.
You can edit this website using the Edit Page link at the bottom of each page. Feel free to use the Sandbox to experiment. The HowTo contains more information on getting started. For questions, see Fortran Wiki discussion.
.f03 are used for modern, free-form source code conforming to the Fortran 90, Fortran 95, and Fortran 2003 standards. Some choose to use
.f90 to denote any free-form source code, for example, including Fortran 2003 code.
Another convention, used by the GFortran compiler, is to use upper-case extensions to denote files which should be processed by the C preprocessor.
arjen (7 may 2009) Note that the Fortran standard itself does not define any extension, it does not even prescribe the use of files on disk to represent the source code. This may seem odd, but there are good reasons for this: a system might use a database of some sort to store all information in, so if the standard prescribed files on disk as the medium, it would exclude such systems.
What’s more, the concept of a file extension is ubiquitous on Windows platforms, but UNIX/Linux do not attach any special meaning to the last bit of a file name.
That said, the common conventions are: * .f, .for for fixed-form source code * .f90 for free-form source code * .F, .F90 (on UNIX/Linux) for fixed-form or free-form source code that must be preprocessed in a C-like style
Some recommend not using the
.f03 file extensions (not to mention
.f15). Not only are these extension not recognized by all compilers, but Fortran 95 or Fortran 2003 code can be written as fixed-form source (it’s still part of the standard). Use
.f90 to indicate free-form source code. See: Source Form Just Wants to be Free
Chin, L. S., D. J. Worth and C. Greenough (2006). Thoughts on using the Features of Fortran 95. Software Engineering Group Notes no. SEG-N-003.
Gray, M. G. and R. M. Roberts (1997). Object-based programming in Fortran 90. Computers in Physics 11, 355–361.
Reid, J. (2003). The future of Fortran. Computing in Science & Engineering 5, 59–67.
Worth, D. J. (2008). State of the art in object oriented programming with fortran. Technical Report RAL-TR-2008-002.
fake - a shell script for generating Fortran makefiles.
FoBiS.py - a Python script for (automatic) building of modern complex Fortran project.
sfmakedepend - searches for Fortran style includes, C preprocessor includes, and module dependencies.
makedepf90 - Automatic dependency resolution and makefile creation given a set of Fortran sources. Resolves module dependencies, Fortran and C preprocessor includes and external procedures.
CMake - CMake is a cross-platform, open-source build system. It is similar to autoconf, but aims to be simpler, and has first class Fortran support. It includes automatic Fortran dependency resolution and can be used for unit and regression testing, software building, system introspection, cross-compilation, and redistributable software packaging. CMake can use different ‘generators’ to actually perform the build: make files, Visual Studio, Xcode and others.
An intrinsic inquiry function is a function whose result depends on the properties of its arguments rather than the actual values. The arguments may be undefined. Unless the description of an intrinsic inquiry function explicitly states otherwise, its arguments are permitted to be unallocated allocatable variables or undefined or disassociated pointers.
count(mask [, dim [, kind]]) counts the number of
.true. elements of
mask along the dimension of
dim is omitted then the number of ‘.true.’ is counted over the entire array.
dim is a scaler of type
integer in the range of where is the rank of
result = count(mask [, dim [, kind]])
mask- The type shall be
dim- (Optional) The type shall be
kind- (Optional) An
integerinitialization expression indicating the kind parameter of the result.
The return value is of type
integer and of kind
kind is absent, the return value is of default integer kind. The result has a rank equal to that of
program test_count integer, dimension(2,3) :: a, b logical, dimension(2,3) :: mask a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /)) b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /)) print '(3i3)', a(1,:) print '(3i3)', a(2,:) print * print '(3i3)', b(1,:) print '(3i3)', b(2,:) print * mask = a.ne.b print '(3l3)', mask(1,:) print '(3l3)', mask(2,:) print * print '(3i3)', count(mask) print * print '(3i3)', count(mask, 1) print * print '(3i3)', count(mask, 2) end program test_count