One of the main features of Fortran 2003 is object-orientation (OO). Derived types can now have specific and generic type-bound procedures, type-bound defined operators, type-bound defined assignment, type-bound finalizers (destructors), and type-bound user-defined derived type IO routines. For example, type base below has specific type-bound procedures find, assign, add and writef, defined operator +, type bound assignment, and a user-defined derived type IO formatted write routine:
integer, allocatable ::... [More]
You might have noticed that the compiler creates files with the mod file extension. These are what we call module symbol files.
A module symbol file contains information about the specification part of a Fortran module. The file name is made of the module name followed by the mod extension. For example, if your Fortran module is called weather , the compiler will generate a module symbol file called weather.mod . The same module symbol file can be used in 32-bit and 64-bit compilations, provided you add the required information to it.
In the Fortran language, the kind type parameter of an intrinsic type is specified between parenthesis following the intrinsic type keyword. For example if you declare a variable of type REAL(8), the variable will have a kind type parameter equal to 8 and it will occupy 8-bytes in memory. A variable of type COMPLEX consists of a real and an imaginary part. Both the real and the imaginary parts are of type REAL. By specifying the kind type parameter in a COMPLEX type declaration, you specify the kind type parameter of each part of the complex... [More]
Last week, I wrote about user-defined constructors in Fortran 2003. This week, I'd like to discuss user-defined assignment bindings and their role as "copy constructors" for allocatable components.
Like Fortran 90's user-defined assignment interface blocks, Fortran 2003's user-defined assignment bindings define a set of subroutines the compiler must call to perform assignment between objects of two types. User-defined assignment bindings are treated differently from interface blocks when you have intrinsic assignment between types... [More]
With multicore and manycore machines becoming popular nowadays, more and more applications are using multi-threading to take advantage of the hardware capabilities and get better performance. Fortran applications are no exception. This blog provides tips on creating thread-safe Fortran applications with XL Fortran.
Like other languages, protect global and heap variables that may be accessed directly or indirectly by multiple threads. In Fortran, global variables are common blocks and module variables. Heap variables are ALLOCATABLE... [More]
Are you concerned about program security? The XL Fortran v13.1 and XL C/C++ v11.1 compilers have a stack protection feature. It is not an active system that protects or denies write access to the stack. Instead, it is a defensive mechanism that can detect a corrupted or overwritten stack and take the appropriate action. Regardless of how the corruption occurred, either due to programming error or an attack on your system, stack protection always terminates the executing program.
The compilers have two new command line options dealing... [More]
C interoperability is one of the most popular features of Fortran 2003. Recently, I was part of a discussion about why XL Fortran flags the following as invalid:
logical(8), target :: logicalarray(20)
p = c_loc(logicalarray) ! XLF will flag an error here
According to Fortran 2003 (and Fortran 2008), the argument to the C_LOC function must either be of an interoperable type or must be a nonpolymorphic scalar. The standard tries to be interoprable with the _Bool type in C, which is of size 1. So... [More]
If you've tried calling system functions from a Fortran program, you might have run into difficulties because these functions don't have a Fortran interface. For example, the following code will fail execution:
p = malloc(40)
if (p == 0) then
! malloc error. Print errno
print *, "malloc failed. errno=", errno()
x = [10.0, 5.0, 4.0, 7.0, 2.0, 1.0, 3.0, 6.0, 9.0, 8.0]
print *, x
The reason is that malloc , errno , exit , and free do not have an... [More]
When the compiler knows that an array occupies a contiguous block of memory, it can perform optimizations based on memory layout. Explicit shape arrays, assumed-size arrays and allocatable arrays occupy contiguous blocks of memory. For array pointers and assumed shape arrays, the compiler cannot determine at compile time if it is the case.
In the latest AIX XL Fortran compiler, -qassert=contiguous was introduced to allow the programmer to indicate to the compiler that: * all array pointers are pointer associated with contiguous... [More]
Input / Output (I/O) performance can be a significant factor in overall program performance. The way you write I/O statements can make a big difference. Consider the following example:
subroutine sub(x, n) real x(n) do i = 1, n, 2 write (unit=11) x(i) enddo end subroutine
The I/O in sub might not be as fast as you'd like. This is due to the accumulation of the overhead for each write statement. The write statement above has to do some preparation work before it can actually write anything. It also has to do some... [More]
If you are using the Parallel Environment's (PE) mpi module with an older version of the XL Fortran compiler , you might hit this error message:
1514-220 (S) Module symbol file for module mpi is in a format not recognized by this compiler. Please compile the module with this
The mpi module was generated using XL Fortran 12.1, so it's incompatible with earlier versions of XL Fortran. We recently published a technote about this. Consider upgrading to take advantage of the extra type-checking offered by this module.
The latest release of XL Fortran introduces new data types and intrinsic functions for the Vector Scalar eXtension (VSX) instruction set tuned for the POWER7 processor. With the VSX instruction set and the original Vector Multimedia eXtension (VMX) intrinsic functions; you can efficiently manipulate vector operations in your application. The Mathematical Acceleration Subsystem (MASS) libraries contain an accelerated set of frequently used mathematical intrinsic functions that provide improved performance over the corresponding standard system... [More]
The April 2012 PTF for XL Fortran for AIX, V13.1 is now available at the following links and on Fix Central . April 2012 PTF for XL Fortran for AIX, V13.1 April 2012 PTF for XL Fortran Runtime for AIX, V13.1 Can't find the updates for your compilers? Check out our C/C++ compilers latest updates page here .
Last week, an XLF user asked a question in the comp.lang.fortran newsgroup about how to get make to compile some Fortran files with fixed form and others with free form. There are several ways of doing this in XLF:
If you use the ".f" file extension only for FORTRAN 77 files, you can use the generic "xlf" command to compile. The "xlf" command checks the file extension of the source file, and chooses default options, including source form, that are appropriate for that extension. For example, if you compile... [More]
The April 2013 Update for XL Fortran for Linux, V14.1 (VRMF: 188.8.131.52) is now available at the following links and on Fix Central
April 2013 Update for XL Fortran for Linux, V14.1
April 2013 Runtime for XL Fortran for Linux, V14.1
Can't find the updates for your compilers? Check out our Fortran compilers latest updates page here