Fortran Programming Tools under Linux
Two methods exist for tracking down compiling errors in your Fortran source code: compiler messages and “lints”. Error messages reported by the gcc compiler are helpful, and this may be adequate for relatively simple programs. For example, suppose I made an error in the main program shown in the first example by forgetting to put in the statement:
10 CONTINUE
that was line 11. Furthermore, assume I also messed up the array declaration in the subroutine trig by typing:
DIMENSION X(1)
instead of
DIMENSION X(1), Y(1)
(Hey, it could happen!) Attempting to compile this incorrect program, now named baddemo.f, results in the following error sequence:
$ f77 -o baddemo baddemo.f f2ctmp_baddemo.f: MAIN f77demo: Error on line 17 of f2ctmp_baddemo.f: DO loop or BLOCK IF not closed Error on line 17 of f2ctmp_baddemo.f: missing statement label 10 trig: Error on line 22 of f2ctmp_baddemo.f: statement function y amid executables. Warning on line 25 of f2ctmp_baddemo.f: local variable sin never used Warning on line 25 of f2ctmp_baddemo.f: local variable exp never used
The error messages give information to help isolate the problems, but the line numbers don't always seem to correspond to the the line numbers of the original Fortran source. This makes it a little harder to track down obscure errors, especially in longer programs. Unfortunately, there doesn't seem to be an option in f77 or f2c to generate a program listing with line numbers. (That doesn't mean it can't be done!)
In addition to compiler error messages, there are several source code checkers or “lints” that can be used to help isolate errors in the source code. An easy-to-use checking program is ftnchek. In its simplest usage, ftnchek examines your program for a variety of potential errors, and it can make life easier by generating a program listing. ftnchek has a long list of options and a thorough man page. Remember, Fortran checking programs will not identify all the errors in your program. However, the combination of a checker and f77 error messages should help you combat compilation errors. (Of course, careful programming will help as well!)
The hard-core (and really adventurous) programmer can obtain a package called Toolpack from the usual Linux sites. This large package is a set of programs and C shell scripts that provides rigorous FORTRAN 77 code checking, along with static and dynamic analysis. See the Fortran_FAQ (directory /usr/doc/faq/lang in the Slackware distribution) for a description of Toolpack.
Fortran's main usage has been in the scientific and engineering fields, and because the language has survived for decades, thousands of high-quality programs and subroutine libraries exist, many of which are freely available. These programs include application programs written for specific purposes, mathematical subroutine libraries, general purpose run-time routines, and graphical plotting and display packages.
Describing even a small percentage of available programs is impossible, but you can get a rough idea of what's out there by pointing your Web browser at netlib2.cs.utk.edu. This site is the Netlib Repository at UTK/ORNL, and it archives over 100 packages containing mathematical software, papers, and databases. Fortran programmers will be particularly interested in a “code motherlode” collection called slatec. This is a “...comprehensive library containing over 1400 general purpose mathematical and statistical routines written in FORTRAN 77.” (Source code, folks!) To give an idea of the slatec library's magnitude, its Table of Contents takes up 222,161 bytes on my disk.
One key factor in my decision to use Linux as a Fortran programming platform was the PGPLOT package. This highly versatile Fortran library provides 100 primitive and higher level subroutines for drawing scientific graphs on various graphic display devices. For example, with the PGPLOT library, you can create multiple graphs in multiple X windows, output plots to PostScript and other supported printing devices, or create files that are compatible with HPGL format or Latex picture environment.
In addition to Linux, PGPLOT is available for twelve other flavors of Unix (AIX, Cray, HP, SGI, NeXT, etc.), two versions of OpenVMS, and MS-DOS using Microsoft Power Station 32-bit Fortran. This wide availability is an attractive feature if you want to develop consistent Fortran applications across platforms. I am also informed that PGPLOT capabilities are available in a compiled form (PGPERL) for use with Perl scripts.
A simple demonstration of PGPLOT is provided by the program listed below. This program is the same as the one given previously, with nine (indented) lines of code added to create a simple plot.
C==============================
C Simple Program to Illustrate
C PGPLOT Graphic Tools
C==============================
PROGRAM PGDEMO
INTEGER PGBEG
DIMENSION X(100), Y(100)
PI=2.*ACOS(0.)
N=100
IER = PGBEG(0,'?',1,1)
IF (IER.NE.1) STOP
CALL PGSCRN(0, 'AntiqueWhite', IER)
CALL PGSCRN(1, 'MidnightBlue', IER)
DO 10 I=1,N
X(I)=I*(2*PI/N)
10 CONTINUE
CALL TRIG(N,X,Y)
CALL PGENV(0., 4., 0., .4, 0, 1)
CALL PGLAB('X Values', 'Y Values', 'PGPLOT Demo')
CALL PGLINE(100, X, Y)
CALL PGEND
DO 20 J=1,5
PRINT 15, X(J), Y(J)
15 FORMAT(2X,2F8.3)
20 CONTINUE
STOP
END
SUBROUTINE TRIG(N,X,Y)
DIMENSION X(1), Y(1)
DO 10 I=1,N
Y(I) = SIN(X(I))*EXP(-X(I))
10 CONTINUE
RETURN
END
Subroutine PGBEN in the pgdemo program performs the plot initialization. Placing the ? character in the PGBEN parameter list causes the program to query for which output device to use. The two calls to PGSCRN simply change the background and foreground colors (and there are plenty colors from which to choose). PGENV establishes the limits of the x- and y-axis, and PGLAB labels the axes and plot. (Math/Greek symbols and subscript/superscript capabilities are available.) The generated curve is plotted by PGLINE, and the plot is completed by PGEND.
This PGPLOT program is compiled by the command:
$ f77 -o pgdemo pgdemo.f -pgplot -lX11
It is necessary to include the X11 library after the PGPLOT library because some of the PGPLOT subroutines create X windows and control their attributes.
Program execution results in the messages shown in Figure 1.
The pgdemo program first queried for which output device to use. I answered with a ? to see the list of available devices (which is configured when the package is installed). From the list I then selected /XWINDOW, and the simple plot shown in Figure 2 was drawn in an X window. PGPLOT supports a long list of output devices, but not all are available for Linux users.
Now the fun can really begin by selecting font sizes, axis types, alphanumeric notations, and a host of other options. If you have had any previous experience with Fortran plotting routines, PGPLOT will be easy to learn and use.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Dynamic DNS—an Object Lesson in Problem Solving
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Roll your own dynamic dns
5 hours 9 min ago - Please correct the URL for Salt Stack's web site
8 hours 20 min ago - Android is Linux -- why no better inter-operation
10 hours 35 min ago - Connecting Android device to desktop Linux via USB
11 hours 4 min ago - Find new cell phone and tablet pc
12 hours 2 min ago - Epistle
13 hours 31 min ago - Automatically updating Guest Additions
14 hours 40 min ago - I like your topic on android
15 hours 26 min ago - This is the easiest tutorial
22 hours 2 min ago - Ahh, the Koolaid.
1 day 3 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Fortran on Linux
Take look at this web site:
http://www.fesb.hr/~psarajce/LinuxOS.html
Also, the Netbeans IDE
Also, the Netbeans IDE provides good FORTRAN support.
Fortran F90/95
For those interested in FORTRAN under Linux OS, look for Fortran F90/95 which is a high level programming language, successor to the Fortran F77. It includes pointers, dinamic allocation, collon notation (when working with arrays), operator overloading, modules, and many more! It is equivalent to C programming language in all of it's features, plus everything from standard Fortran F77 (complex numbers native support). Fortran F90/95 is THE choice for scientists and engineers, due to the fact that it can be easily mixed with F77 source codes (calling F77 subroutines from F90 source code)! Thus, all subroutines once written in F77 are accesible through F90 sintax (including all repository subroutines found on Netlib (such as Slatec)! Also, there is an complete IDE for Fortran F90 on Linux OS, which is called Photran (based on Eclipse). KDevelop Multilanguage can be used as Fortran F77 IDE on any Linux OS (with KDE desktop)! Fortran F90/95 compilers (free versions) for Linux include: Intel Fortran Compiler for Linux 9.0, G95 fortran compiler, and GCC 4.0 part called gfortran. They all can be integrated with Photran IDE.