Fortran90 Pitfalls

Several coding issues impact the performance of Fortran90 applications. For example, consider the two cases of using different F90 Array syntax for the two dimensional arrays below:

Case 1:

do j = js,je
  do k = ks,ke
    do i = is,ie
      rt(i,k,j) = rt(i,k,j) - smdiv*(rt(i,k,j) - rtold(i,k,j))
    enddo
  enddo
enddo

Case 2:

rt(is:ie,ks:ke,js:je)=rt(is:ie,ks:ke,js:je) - &
    smdiv * rt(is:ie,ks:ke,js:je) - rtold(is:ie,ks:ke,js:je))

 The array syntax in the computation step of the second approach leads to a significant performance penalty over using explicit loops on cache-based systems, although it is more elegant. Vector systems tend to prefer this array syntax from a performance standpoint. More importantly, the array syntax generates larger temporary arrays on the program stack.

The way the arrays are declared also impacts performance. In the following example, there are two cases of F90 assumed shape arrays. In the second case, the negative performance impact is significantly higher, almost ten-fold in compile time.

Case 1:

REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) :: r, rt, rw, rtold
Results in F77-style assumed-size arrays
Compile time: 46 seconds
Run time: .064 seconds / call

Case 2:

REAL, DIMENSION( ims: , kms: , jms: ) :: r, rt, rw, rtold
Results in F90-style assumed-shape arrays
Compile time: 3120 seconds!!
Run time: .083 seconds / call

Another issue that arises from the F90 assumed shape arrays occurs when it is a parameter in a subroutine. Using assumed shape arrays as a parameter in a subroutine may result in the subroutine being passed a copy, rather than being passed the address of the array itself. This F90 copy-in/copy-out overhead is inefficient and may cause errors when calling external libraries.

Events


    ( ! ) Warning: file_get_contents(https://calendar.tamucc.edu/live/json/events/group/Main%20Calendar/thumb_width/560/thumb_height/315/max/2/): failed to open stream: HTTP request failed! HTTP/1.1 429 Too Many Requests in /home/int/mainweb.svc/html/files/php/models/events-model.php on line 20
    Call Stack
    #TimeMemoryFunctionLocation
    10.0196499128{main}( ).../fortran90-pitfalls.php:0
    20.04831296584include( '/home/int/mainweb.svc/html/files/php/views/related-events-no-images-view.php ).../fortran90-pitfalls.php:1179
    30.04831296584getEvents( $pageIndex = 0, $pageSize = 10, $groupname = '' ).../related-events-no-images-view.php:8
    40.04831297512file_get_contents( $filename = 'https://calendar.tamucc.edu/live/json/events/group/Main%20Calendar/thumb_width/560/thumb_height/315/max/2/', $flags = FALSE, $context = resource(12) of type (stream-context) ).../events-model.php:20

    ( ! ) Warning: Invalid argument supplied for foreach() in /home/int/mainweb.svc/html/files/php/models/events-model.php on line 26
    Call Stack
    #TimeMemoryFunctionLocation
    10.0196499128{main}( ).../fortran90-pitfalls.php:0
    20.04831296584include( '/home/int/mainweb.svc/html/files/php/views/related-events-no-images-view.php ).../fortran90-pitfalls.php:1179
    30.04831296584getEvents( $pageIndex = 0, $pageSize = 10, $groupname = '' ).../related-events-no-images-view.php:8
See All Events