Category: 04. Fortran

  • Dynamic Arrays

    A dynamic array is an array, the size of which is not known at compile time, but will be known at execution time. Dynamic arrays are declared with the attribute allocatable. For example, The rank of the array, i.e., the dimensions has to be mentioned however, to allocate memory to such an array, you use the allocate function. After the…

  • Arrays

    Arrays can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. All arrays consist of contiguous memory locations. The lowest address corresponds to…

  • Strings

    The Fortran language can treat characters as single character or contiguous strings. A character string may be only one character in length, or it could even be of zero length. In Fortran, character constants are given between a pair of double or single quotes. The intrinsic data type character stores characters and strings. The length of the…

  • Numbers

    Numbers in Fortran are represented by three intrinsic data types − Integer Type The integer types can hold only integer values. The following example extracts the largest value that could be hold in a usual four byte integer − When you compile and execute the above program it produces the following result − Please note…

  • Loops

    There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially : The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A…

  • Decisions

    Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed, if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Following is the…

  • Constants

    The constants refer to the fixed values that the program cannot alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, a complex constant, or a string literal. There are only two logical constants : .true. and .false.…

  • Variables

    A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable should have a specific type, which determines the size and layout of the variable’s memory; the range of values that can be stored within that memory; and the set of operations that can be applied to…

  • Data Types

    Fortran provides five intrinsic data types, however, you can derive your own data types as well. The five intrinsic types are − Integer Type The integer types can hold only integer values. The following example extracts the largest value that can be held in a usual four byte integer − When you compile and execute…

  • Basic Syntax

    A Fortran program is made of a collection of program units like a main program, modules, and external subprograms or procedures. Each program contains one main program and may or may not contain other program units. The syntax of the main program is as follows − A Simple Program in Fortran Let’s write a program…