Multi-dimensional arrays need to be padded in the fastest-moving dimension, to ensure array sections to be aligned at the desired byte boundaries : npadded= ((n +veclen– 1) /veclen) *veclen Example:
read moreFortran namelist is a I/O method introduced in Fortran 77. It later became a standard in Fortran 90. It allows to read/write data as a dictionary like in plain text files. See below for a simple example: Derived types are user defined types. They extend the basic types REAL, INTEGER and LOGICAL. They can be…
read moreDerived types are User-defined data types that allows to create complex data structures. It is defined with the TYPE statement. In addition, two different derived types exists: The use of PDT’s derived types can be useful in several ways: Its use allows to parametrize the following properties of an array: User types can be parametrized…
read moreWhen launching a “controlled” error it can be useful to show the whole stack trace. In such way, it is easier for the developer to find out where the problem might come. Check below how to do it: The output: Found at Stackoverflow
read moreAmong several things, pointers can be used to represent an array from a specific shape into another one. It can be useful for certain situations. However, the use of pointers is generally not recommended. This is due to potential memory management risks. For instance, It is important to keep the same size when remapping arrays…
read moreEnumeration defines a set of variables related together. It also exists in other languages. Nonetheless, It does not behave in the same way as, for example, in C. That would only allow the enum types when declared. Note It is allowed since the Standard Fortran 2003. Check below how to declare them: How to use…
read moreAn allocatable array is the same as a dynamic array. Its size is not fixed therefore it is not known at compilation time. It is defined at execution time. It has several advantages compared to an explicit shape. The most important of all is its flexibility. It is also more memory efficient because it is…
read moreAbstract objects can have multiple implementations. Fortran does not offer a direct solution to declare them as an array. However, it is still possible to handle it. Check below how to do it: Abstract type: Several implementations: and Declare a dynamic array of concrete objects: Declare a dynamic array of the abstract type shapes: First,…
read moreAn abstract class is defined with the keyword abstract. It tells the class it cannot be instantiated. On the other hand, it can be used as shared behavior between related classes. That’s when a subclass is created by referring its parent. How to define an abstract class: Note two procedures are defined: getSpecies implementation is…
read moreElemental statement provides a simple and generic interface for a procedure regarding its rank -dimensions-. Due to Fortran strong typing programming style, It was a bit challenging to provide generic functions. It required to implement all possible forms (type and rank-dimensions-). Elemental focus in the rank issue with a simple interface. Note an elemental procedure…
read more