Fortran and Its Varients
Fortran and Its Varients
CS 20-03
Assignment No:2
Main purpose:
• Fortran is a programming language designed for efficient execution of numerical and
scientific computations. It excels in areas such as:
• Mathematical, statistical, and engineering applications.
• High-performance computing (HPC) due to its efficient handling of arrays and
computational tasks.
• Numerical analysis, weather modelling, fluid dynamics, and computational physics
Fortran Variants
Fortran-I (1957)
• Developer: IBM, led by John W. Backus.
• Platform: IBM 704.
• Key Features:
• Introduced high-level programming for numerical computation.
• Supported basic arithmetic operations and expressions.
• Provided the DO loop for iteration.
• Included conditional statements (IF).
• Allowed simple I/O operations.
• No subroutine supports.
Fortran-II (1958)
Enhancements Over Fortran I:
• Subroutines and Functions: Introduced for modular programming.
• Common Blocks: For sharing data between subprograms.
• Input / Output Improvements: More robust I/O handling.
• Array Handling: Better support for array operations.
• Error Detection: Improved syntax checking.
• Machine Independence: More abstracted from specific hardware.
Fortran-IV (1962)
Enhancements Over Fortran II:
• Logical Data Type: New data type for boolean operations.
• IMPLICIT Statement: Allowed implicit typing of variables.
• External Functions: Support for linking with external libraries.
• More Control Structures: Expanded control structures.
• Standardization: First step towards standard Fortran.
• Improved Arithmetic: More complex mathematical functions.
Fortran-66 (1966)
Enhancements Over Fortran IV:
• Standardization: First ANSI standard (ANSI X3.9-1966) standardized by
American National Standard Institute.
• Parameter Passing: Improved method for passing parameters.
• Data Initialization: Allowed in DATA statements.
• Enhanced Array Handling: Improved multidimensional arrays.
• Format Specification: Better control over I/O formatting.
• Common Blocks: More flexible and powerful.
Fortran-77(1977)
Enhancements Over Fortran 66:
• BLOCK IF and END IF: More Structured programming constructs and decision
making.
• CHARACTER Data Type: Handling of strings and text.
• PARAMETER Statement: For defining constants. Allowed defining constants
that don't change, making programs easier to read and maintain.
• DO Loop Enhancements: Nested DO loops and loop control.
• IMPLICIT NONE: Enforced explicit variable declaration.
• Integer::a=30
• Enhanced I/O: More versatile input and output capabilities.
• Made input and output operations more flexible and powerful, allowing better
handling of data from different sources.
Fortran-90(1991)
Enhancements Over Fortran 77:
• Modules: For better code organization and reuse.
• Array Operations: Whole-array and array-section processing. Allows
operations on entire arrays or sections of arrays at once, simplifying complex
data manipulation.
• Dynamic Memory Allocation: Allocatable arrays and pointers.
• Recursion: Support for recursive procedures.
• Free-Form Source Code: More flexible coding format. Allowed a more flexible
coding format without fixed column positions, making the code easier to read
and write.
• New Intrinsics: Many new intrinsic functions and subroutines. Added many
new built-in functions and subroutines, expanding the language's capabilities
for mathematical, character, and array operations.
Fortran-95(1997)
Enhancements Over Fortran 90:
• FORALL Construct: For parallel array processing, allowing operations to be
performed simultaneously for efficiency.
• WHERE Construct Enhancements: Conditional array assignments.
• PURE and ELEMENTAL Procedures: For side-effect-free functions. functions
that operate element-wise on arrays (ELEMENTAL), enhancing reliability and
performance.
• User-Defined Precision: More control over numerical precision.
• Improved Interoperability: Better integration with C.
• Enhanced I/O: Non-advancing I/O and other I/O enhancements.
Fortran-2003(2004)
Enhancements Over Fortran 95:
• Object-Oriented Programming: Classes, inheritance, polymorphism.
• C Interoperability: ISO C Binding for better C integration.
• Enhanced I/O: Asynchronous I/O operations.
• Procedure Pointers: More flexible procedure referencing allowing dynamic
selection and invocation of different procedures at runtime.
• Finalization: Final procedures for clean-up, which are special routines
automatically called to clean up resources when objects go out of scope or are
no longer needed.
Fortran-2008(2010)
Enhancements Over Fortran 2003:
• Coarray Fortran: Native parallel programming model.
• Submodules: Enhanced modularity and code organization.
• DO CONCURRENT: More efficient parallel loops.
• Extended Intrinsics: Additional intrinsic functions.
• Error Handling: Improved error handling in I/O.
• Performance Enhancements: Various performance optimizations.
Implemented various optimizations to increase the speed and efficiency of
Fortran programs, making them run faster and more efficiently.
PROGRAM DoConcurrentExample
INTEGER, DIMENSION(1000000) :: array
INTEGER :: i
! Initialize the array in parallel
DO CONCURRENT (i = 1:1000000)
array(i) = i * 2
END DO CONCURRENT
PRINT *, 'First 10 elements of array:', array(1:10)
END PROGRAM Do Concurrent Example
The loop is set to run iteration from 1 to 1000000 concurrently
Fortran-2018(2018)
Enhancements Over Fortran 2008:
• Teams and Events: Improved parallel processing controls.
• Atomic Operations: Support for atomic operations in parallel programming.
• Additional Intrinsics: New and extended intrinsic procedures.
• Improved Coarray Features: Enhanced capabilities for coarrays.
• Bit Manipulation: More functions for bitwise operations. Added functions for
directly handling and manipulating individual bits in binary data, useful for low-
level programming tasks.
• Generic Programming: More robust support for generic programming
constructs. Improved ability to write code that works with different data types,
making it more flexible and reusable.
Variables:
Variables are placeholders used to store data values.
They have a name, data type, and value.
Example: integer :: age = 25
Data Types:
Data types define the kind of data that can be stored in variables.
Common data types include integers, real numbers, characters, and logical values.
Example: integer, real, character(len=10)
Operators:
Operators are symbols used to perform operations on variables and values.
They include arithmetic operators (+, -, *, /), comparison operators (==, <, >), and
logical operators (.AND., .OR., .NOT.).
Example: x = y + z
Control Structure:
Control structures are used to control the flow of execution in a program.
They include conditional statements (IF, ELSEIF, ELSE) and looping constructs (DO, DO
WHILE, DO UNTIL).
Example: IF (x > 0) THEN
Function and Subroutines:
Functions and subroutines are reusable blocks of code that perform specific tasks.
Functions return a value, while subroutines do not.
Example: subroutine greet(name)
Arrays:
Arrays are collections of variables of the same data type.
They allow storing multiple values under a single name.
Example: real, dimension(10) :: temperatures
<<<End>>>