Intel has a nice feature to find bad array definitions. Somehow thinking of C I wrote: real :: coord(N,3) rather than coord(3,N). Using "ifort -check arg_temp_created" this gave then such information at run time (in my example below 20 times):
"forrtl: warning (402): fort: (1): In call to DISTANCE, an array temporary was created for argument #1" While one can sometimes not prevent the need for a array temporary, one often can and should do so to speed up the program. Example program: --------------------------------- program tmp implicit none integer, parameter :: N = 20 real :: coord(N,3) ! better: (3,N) integer :: i real :: d coord = 0.0 do i=1,N d = distance(coord(i,:)) end do contains function distance(a) real :: a(3) real :: distance distance = sqrt(a(1)**2 + a(2)**2 + a(3)**2) end function distance end program tmp -- Summary: Flag to give runtime information " array temporary was created for argument" Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29952