Posted on 12 October, 2016 by Mathew
Mixing of Fortran types occurs, and often results in problems when mixing free-form Fortran with older styles of Fortran, and when using different compilers.
As pointed out at Geek Tricks.
In Fortran 90/95, a “&” at the end of a line, or in the front of a line, is treated as line continuation sign. But in Fortran 77, it has to be a character at the sixth column. In the code I get, most “&”‘s comply to the Fortran 77 format, but some are not. So I move all “&”‘s to the sixth column, and now the code compile with gfortran.
If you want to replace lots ampersands from the ‘first column’ to the ‘sixth column’ on a lot of lines you could use ‘sed’ string editor to do that.
sed 's/^&/ &/g' input.f > output.f
You also need to check for lines which are too long in your input.
Many errors can be suppressed for now, with command such as
gfortran -std=legacy output.f -o justwork
Filed under: Computers, Fortran, Uncategorized | Tagged: Compiling, F77 F95, Formula Translation, Fortran, Fortran 77, Fortran 95, g77, gfortran, ifort | Leave a comment »
Posted on 4 April, 2015 by Mathew
The BBC is kicking off a new 5 part series of programmes on programming, by looking at the impact that FORTRAN has made on our lives. The series “Code that Changed the World” starts on the the 6th April and is hosted by former “bits” presenter Alex Krotoski.
FORTRAN stands for FORmula TRANslation and it particularly suitable to scientific computing. The language was developed by IBM as a practical alternative to assembly language. The development of FORTRAN had a large influence on the development of compilers, since an objective was the generation of efficient code from the source code written in FORTRAN.
FORTRAN has a large lineage of versions, from early versions designed to be entered by punch cards, to modern versions designed for structured programming.
Punch card images generated at http://www.kloth.net/.
Filed under: Computers, Computers & Internet, Fortran | Tagged: Alex Krotoski, BBC, Fortran | 2 Comments »
Posted on 11 October, 2007 by Mathew
One tool I picked up from Clive Page’s Page on Fortran was ftnchek. This program is a static analyser. It enables checking or Fortran77 for semantic errors (rather than syntax errors), which usually aren’t reported by compilers. Once a Program compiles you can check for syntax errors by running
I found most of my errors are of this type.
Warning near line 189 col 26 file mucg83.f: promotion may not give desired
precision: dble XTO400 + real const 0.0001
What I should have written is
Which means the fortran compiler knows the number involved is meant to be used in double precision. Since there is really no cost penalty to using ‘double’ precision rather than ‘single’ precision used with ‘Real’ numbers – and this might change depending on compiler.
I found the static analyser to be very useful for finding unused parts of a program, this might be useful to find errors, if you think those parts of the code are meant to do something! Or in cleaning up the code after making changes.
ftnchek can be downloaded from the ftnchek developers website, or installed in debian from the program repositories using apt-get, dselect or aptitude, etc.
FTNCHEK Version 3.3 November 2004 Patch Level 1
Filed under: Computers, Fortran, programming, programs | Tagged: Fortran | Leave a comment »
Posted on 10 October, 2007 by Mathew
Useful information and links on Fortran can be found on Clive Page’s list of Fortran Resources. Including programs for converting older Fortran codes into the modern standard, and information about different Fortran compilers.
The Computing Service now run several Fortran90 courses, Please see: http://www-uxsup.csx.cam.ac.uk/courses
Of interested might be this course on converting older programs to the modern standard fortran. Converting Old To Modern Fortran and Decoding and Converting Variant and Old Fortrans
The computing services Fortran course is based on notes by Dr. J. S. Morgan from the computing service of the University of Liverpool.
Also course notes on Scientific Programming.
Filed under: Fortran, programming | Tagged: Fortran | 1 Comment »