Image

What's The Difference Between FORTRAN - Now And Then

Feb. 6, 2013
FORTRAN has progress since its inception at IBM in 1957.

This article is part of Then and Now in our Series Library

FORTRAN started out as IBM's' Mathematical Formula Translating System. It was designed by a team led by John Backus and targeted computationally intensive applications from physics to weather prediction. Initially programming die hards thought that optimum performance required coding in assembler. C and C++ may be the programming language of choice today but FORTRAN remains popular in high performance computing (HPC) applications. The latest FORTRAN compilers and standard might change your mind about whether FORTRAN is a historical artifact or an effective tool.

FORTRAN is almost as old as I am and I encountered if at FORTRAN IV when punch cards, GOTO's and line numbers still existed. I still remember the three-way, arithmetic IF statement that ended with three line numbers for less than, equal and greater than results. Files were referenced by numbers and FORMAT and DATA statements were sprinkled throughout a card deck.

In my distant past I wrote a FORTRAN development system in BASIC because the only computer we had access to ran BASIC and we really wanted to try FORTRAN. The BASIC system had a remote terminal with paper tape while the FORTRAN system was only available via punch cards that were shipped out daily. Imagine a two day debug turn around.

The initial version of FORTRAN had only 32 statements. This included the FREQUENCY statement that was a hint to the new "optimizing" compilers to improved IF statement performance. It was a precursor to C's pragma statement. The IF statement mapped to the IBM 704 branch instruction. This is comparable to C/C++ auto-increment/decrement support that matched features in the hardware at the time.

FORTRAN has progressed significantly since then. There have been numerous FORTRAN versions and specifications including:

  • FORTRAN
  • FORTRAN II
  • FORTRAN III
  • FORTRAN 1401
  • FORTRAN IV
  • FORTRAN 66
  • FORTRAN 77 - ANSI X3J3/90.4
  • FORTRAN 90 - ISO/IEC standard 1539:1991
  • FORTRAN 95
  • FORTRAN 2003
  • FORTRAN 2008 - ISO/IEC 1539-1:2010

Along the way things like three-way, arithmetic IF statement gave way to the more contemporary IF/THEN/ELSE/END IF construct. Recursion is now supported. Initially recursion was not an option. That actually made my job easier when I put together that FORTRAN simulator. Looping was improved as have data types. There is even support now for object oriented programming. Variable length strings were not added until FORTRAN 95.

Dynamic memory allocation showed up in Fortran 90 along with pointers. Programmers got a taste for modules, operater overloading, structures and structre looping constructs. A portable specification for numerical precision kept FORTRAN at the forefront of numerical calculation.

Identifier lenths were increased to 31 characters and input was now free form. Initially, FORTRAN punch cards were laid out with in 80 columns with leading line numbers. Many will remember terminal screens that were 24 lines of 80 characters.

Many features were deleted in FORTRAN 90 including ASSIGN/GOTO Still, FORTRAN was often playing catch up with other emerging languages including C.

FORTRAN 2003 was a major revision. It provided interoperability with C and included object-oriented programming support (Fig. 1) such as type extension, inheritance, polymorphism and abstract data types. Subroutines could now be polymorphic based on their argument types like Ada and C++.

type shape
  integer :: color
  logical :: filled
  integer :: x
  integer :: y
end type shape
type, EXTENDS ( shape ) :: rectangle
  integer :: length
  integer :: width
end type rectangle
type, EXTENDS ( rectangle ) :: weighted_rectangle
  integer :: weight
end type weighted_rectangle

subroutine sample ( sh )
  class(shape), intent(in) :: sh

  select type (sh)
  class is (rectangle)
    stop 'We have a rectangle'
  class is (weighted_rectangle)
    stop 'We have a weighted_rectangle'
  class default
    stop 'We have something else'
  end select
end subroutine sample

Figure 1. FORTRAN 2003 added object class definitions with inheritance

IEEE floating point support was now standard. The VOLATILE attribute was added along with a range of data manipulation enhancements. Asynchronous file transfer and stream support brought FORTRAN into the new millenium.

FORTRAN 2008 was approved in 2010. Compared to FORTRAN 2003, it is a minor upgrade. Objects can now be declared within a BLOCK construct and storage layout can be forced with the CONTIGUOUS attribute. Recursive allocatable objects means that FORTRAN can now handle arbitrary linked structures. It addresses issues such as deep copying and memory leaks. It adds submodules (Fig. 2) and support for Coarray Fortran (CAF). Submodules are very handy in large applications and for sharing code.

module points
  type :: point
    real :: x,y
  end type point
  interface
    real function point_dist (a,b)
    import :: point
    type(point), intent(in) :: a,b
    end function point_dist
  end interface
end module points
submodule (points) points_a
contains
  real function point_dist (a,b)
    type(point), intent(in) :: a,b
    point_dist = sqrt((a%x-b%x)**2+(a%y-b%y)**2)
  end function point_dist
end submodule points_a

Figure 2. Submodule example from "The new features of Fortran 2008" by John Reid, JKR Associates, UK

CAF programs can be replicated and executed asynchronously. The FORTRAN array syntax has been extended to handle coarrays.

Compared to very early versions of FORTRAN, FORTRAN 2008 looks like a completely different language and it is. On the other hand, it has many familiar or similar constructs and syntax found in C++ and Ada.

FORTRAN 2008 will probably not be used by the average embedded developer or an iPhone and Android app developer. On the other hand, it will be used by everyone from physicists to those crafting military applications.

About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!