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: module m
integer, allocatable ::... [More]
Operator overloading is a key ingredient of object-oriented programming. Fortran (starting from Fortran 90) supports operator overloading through defined operator which allows you to extend an intrinsic operator or define a new operator. For example, you can extend "+" to perform "var1 = var2 + var3" where var1, var2, and var3 are derived-type objects. Likewise, you can define a new operator, such as ".UNION.", to compute the union of two sets " set3 = set1 .UNION. set2", where set1, set2, and set3 could... [More]
Time really flies! About six years ago, the Fortran 2003 standard (commonly abbreviated as F03) was officially published in an attempt to modernize the language. Over the past few years, we've seen a steady increase of interest in adoption of F03 features in the field, particularly the object-oriented programming (OOP) and C interoperability features. F03's C interoperability features struck a chord in the scientific computation community as mixed language applications are becoming the mainstream. In addition, more and more scientific and... [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. Let's... [More]
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]
The short answer is no. However, Fortran has its own mechanisms for providing additional flexibility in procedure references. For instance you can declare a dummy argument as "optional" by giving it the OPTIONAL attribute. This allows you to skip the actual argument that would normally get associated with that dummy argument in a call. For instance, in the following program: program example
call sub(10, 20)
call sub(10, 20, 30)
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 containing... [More]
Authors: Ka Lin, Daniel Chen A submodule extends a module or another submodule. It can also have its descendant submodules. You can declare a module procedure interface body in a module and define it in one of the descendant submodules. A submodule access entities in its ancestor module or submodules through host association. Here is an example: MODULE m ! The ancestor module m INTEGER ::... [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 objects,... [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 explicit... [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 with... [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: use iso_c_binding
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 the... [More]
XL Fortran V14.1 supports the Fortran 2008 enhancements to the ALLOCATE statement. The first enhancement has to do with the SOURCE= specifier. In Fortran 2003, you are not allowed to omit the bounds information when allocating an array in the ALLOCATE statement. In Fortran 2008, when you use an ALLOCATE statement without specifying the bounds for an array, the bounds of source_expr in the SOURCE= specifier determine the bounds of the array. The second enhancement is the addition of the MOLD= specifier. The MOLD= specifier works... [More]
Author: Ka Lin, Pooja Dayanand We're trying to summarize the benefit of using the BLOCK construct that is introduced by the Fortran 2008 standard. However, we finally draw a conclusion that the BLOCK construct is useful in very large programs, because in small programs, variables are much easier to keep track of. Nevertheless, we would like to use the following small programs to illustrate the benefits. The BLOCK construct improves the readability of code by allowing you to declare variables closer to where they are used in the code. In the... [More]
IBM’s Blue Gene/Q supercomputer, Sequoia, at the Lawrence Livermore National Lab took the number one ranking in the TOP500 list of the world’s fastest machines. And 21 other Blue Gene/Q configurations also earned spots on the list – including four in the top 10. Quite an achievement, given that IBM only started shipping these systems in volume to clients earlier this year. Read 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 cleanup work after it... [More]
Our colleague Jim Xia recently coauthored a new book: Scientific Software Design: The Object-Oriented Way (ISBN: 978-0521888134). The book is a great example of how to use the object-oriented features of Fortran 2003 in scientific design patterns. BTW, the examples in the book compile with XL Fortran. The Back Cover: This book concerns software design. Although many current discussions of scientific programming focus on scalable performance, this book focuses on scalable design. The authors analyze how the structure of a package determines... [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 targets. *... [More]
Check-out this tutorial to learn how to use the interoperability features of the IBM XL Fortran and the IBM XL C/C++ compiler to integrate Fortran, C and Java source code into an application. The demonstration shows how to call Java source routines from Fortran and vice versa. Interoperability is useful for integrating parts written in different languages into an application. This enables developers to take advantage of language best situated for the job or easily integrate legacy assets into a new application. Interoperability of IBM XL... [More]
Check out new exercises in the Power sandbox. You can find them below. You can learn about compiling with a list of options defined in a file, debugging optimized code, new OpenMP3.1 constructs, performance benefits of using F2008 CONTIGUOUS attribute and the F2008 BLOCK construct. Optimize server performance and programmer productivity with IBM
compilers Compile with a list of options defined in a file Debugging optimized XL Fortran code New and enhanced atomic constructs in OpenMP 3.1 The final clause in OpenMP 3.1 with the... [More]
In the past, the intrinsic procedures REAL(z) and AIMAG(z) (where z is of type complex) were used to get the real part and imaginary part of z. For example, COMPLEX :: z = (3.2, 2.1) REAL(z) has the value 3.2. AIMAG(z) has the value 2.1. In Fortran 2008, you can use the complex part designators with the %RE and %IM selectors instead; that is, z % RE has the value 3.2. z % IM has the value 2.1. You might benefit from the direct access to the real or imaginary part of complex entities by using the complex part designators as variables in... [More]
New and enhanced features in XL Fortran Version 14.1 include support of language
features that you can use to port code easily when moving to IBM Power Systems,
as well as improved compilation time at commonly used optimization levels. This
article for those who have some experience with previous versions of XL Fortran
gives the details and describes other highlights. Read more .
Looking to see and learn about the latest compiler enhancements in XL Fortran on AIX and Linux. Download a trial. Here is quick recap of some of the highlights of these new compilers: Compliance to ISO programming language standards including the Fortran 2003
standard and partial support for the Fortran 2008 standard Support for the OpenMP 3.1 industry specification Compile-time performance and scalability improvements Enhancements to the diagnostic reports that can help you identify
opportunities to improve the performance of your... [More]
Fortran Compilers are
now live on the Request for Enhancement (RFE) Community. It is a great
place where you can collaborate with development teams and other product users.
Our development team will review your RFE and provide status updates throughout
its lifecycle. Here is the link to the Community: Fortran RFE Looking forward to
hearing from you.
The June 2012 PTF for XL Fortran for AIX, V13.1 is now available at the following links and on Fix Central : June 2012 Update for XL Fortran for Linux, V13.1 June 2012 Update for XL Fortran Runtime for Linux, V13.1 Can't find the updates for your compilers? Check out our Fortran compilers latest updates page here .
you know that the compiler you use can impact whether or not you
achieve optimal performance from all parts of your systems.
Organizations often overlook the importance of compilers, often running
new high-powered servers with outdated compilers that limit the servers’
potential. Or failing to update compilers that can improve the
efficiency of existing hardware investments as more advanced versions
are released. In practical terms,this translates into greater power
consumption, slower response times,numerous administrative... [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
compiler. 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. If you're... [More]
Check out updated exercises in the Power sandbox. You can find them below. You can learn about tracking compiler use, performance,
auto-vectorization, optimization, interoperability, and reporting Optimize server performance and programmer productivity with IBM
compilers Learn about tracking IBM XL C/C++ and Fortran compiler utilization Enhanced performance with new XL C/C++ and Fortran compilers Explore auto-vectorization Discover uninitialized floating point and integer variables Interoperability of IBM XL Fortran, IBM XL... [More]
The July 2012 PTF for XL Fortran for AIX, V13.1 (VRMF: 188.8.131.52) is now available at the following links and on Fix Central . July 2012 PTF for XL Fortran for AIX, V13.1 July 2012 PTF for XL Fortran Runtime for AIX, V13.1 Can't find the updates for your compilers? Check out our Fortran compilers latest updates page here .
Check out this webinar by IBM Systems Magazine about Smart Tools on IBM i, AIX, and Linux for Faster Time to Market Get an early look at the next version of Rational's offerings for Power Systems. New advancements in compilers and significantly enhanced development tools will give your organization a competitive advantage! Listen to the replay .