Electronicdesign 6353 59461promo Fortran
Electronicdesign 6353 59461promo Fortran
Electronicdesign 6353 59461promo Fortran
Electronicdesign 6353 59461promo Fortran
Electronicdesign 6353 59461promo Fortran

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.

Sponsored Recommendations

Understanding Thermal Challenges in EV Charging Applications

March 28, 2024
As EVs emerge as the dominant mode of transportation, factors such as battery range and quicker charging rates will play pivotal roles in the global economy.

Board-Mount DC/DC Converters in Medical Applications

March 27, 2024
AC/DC or board-mount DC/DC converters provide power for medical devices. This article explains why isolation might be needed and which safety standards apply.

Use Rugged Multiband Antennas to Solve the Mobile Connectivity Challenge

March 27, 2024
Selecting and using antennas for mobile applications requires attention to electrical, mechanical, and environmental characteristics: TE modules can help.

Out-of-the-box Cellular and Wi-Fi connectivity with AWS IoT ExpressLink

March 27, 2024
This demo shows how to enroll LTE-M and Wi-Fi evaluation boards with AWS IoT Core, set up a Connected Health Solution as well as AWS AT commands and AWS IoT ExpressLink security...

Comments

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