This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
.f90 runs slower than .f
- From: Rachel Dowdall <Rachel dot Dowdall at glasgow dot ac dot uk>
- To: <fortran at gcc dot gnu dot org>
- Date: Thu, 2 Aug 2012 17:35:02 +0100
- Subject: .f90 runs slower than .f
Dear Fortraners, I have not used this list before so sorry if I breach
protocol! I couldn't find my problem on bugzilla, please send me a link
if I failed to find it.
I am updating some old software currently in Fortran 77 but I am reusing
some of the original routines. Most of the time (>75%) goes in the
attached routine psq which does a finite difference operator on complex
3x3 unitary matrices. When I compile and run with it as a fortran 77
routine, ie .f it takes 3.8 sec but with the EXACT same file changed to
.f90 it takes 10 seconds. It would be easier to change it to Fortran 90
standard to use modules etc. Performance is a major issue.
I compiled with gfortran-4.7:
FFLAGS = -static -O3 -pg -ffree-form
with some flags that link to a fortran XML reader (should be
irrelevant), and yes I have tried turning off -pg.
I'm not a computer scientist so I don't really understand what the
compiler would be doing that could cause this or how I can stop it. Does
it make certain assumptions about .f files that it cannot about .f90
(like no pointers)? The rest of the code is using some fortran 2003/2008
features.
My makefile treats both cases identically, ie.
FSRC= .... psq.f....
in either case.
I do not have the same problem with ifort (see below).
Thanks for your help
Rachel
subroutine psq(u, tempgrn, grnfn, up, down, nspace)
! subroutine to calculate p**2 * wt for terms in quark Hamiltonian
! multiplication is done by wt so that p**4 can
! also be done by calling it twice with wt = 1.0
! Note: p**2 is defined with NO powers of u_0 in. i.e. NOT
! defined as del+ * del- as in Nakhleh et al
implicit none
integer nspace
integer, parameter :: ndirn = 4
integer, parameter :: nspd = 3
integer, parameter :: ncolor = 3
integer, parameter :: nskspin = 2
integer twonspd
integer icolor,ispin,idirn,ispace,kcolor
real wt
integer up(0:nspace-1,nspd),down(0:nspace-1,nspd)
complex*16 u(0:nspace-1,ncolor,ncolor,4)
complex*16 grnfn(0:nspace-1,ncolor,nskspin)
complex*16 tempgrn(0:nspace-1,ncolor,nskspin)
twonspd = nspd*2
do 100 ispin = 1, nskspin
do 200 icolor = 1, ncolor
do 300 ispace = 0, nspace -1
! tempgrn(ispace,icolor,ispin) = - twonspd * &
! grnfn(ispace,icolor,ispin)
! tempgrn(ispace,icolor,ispin) = tempgrn(ispace,icolor,ispin)
300 continue
200 continue
100 continue
tempgrn = -twonspd*grnfn
do 10 idirn = 1, nspd
do 20 ispin = 1, nskspin
do 30 icolor = 1, ncolor
do 40 kcolor = 1, ncolor
do 50 ispace = 0, nspace -1
tempgrn(ispace,icolor,ispin) = &
tempgrn(ispace, icolor, ispin) &
+ conjg(u(down(ispace,idirn),kcolor,icolor,idirn))*&
grnfn(down(ispace,idirn),kcolor,ispin)
50 continue
40 continue
30 continue
20 continue
10 continue
do 110 idirn = 1, nspd
do 210 ispin = 1, nskspin
do 310 icolor = 1, ncolor
do 410 kcolor = 1, ncolor
do 510 ispace = 0, nspace -1
tempgrn(ispace,icolor,ispin) = &
tempgrn(ispace, icolor, ispin) &
+ u(ispace,icolor,kcolor,idirn)*&
grnfn(up(ispace,idirn),kcolor,ispin)
510 continue
410 continue
310 continue
210 continue
110 continue
! do 1100 ispin = 1, nskspin
! do 1200 icolor = 1, ncolor
! do 1300 ispace = 1, nspace
! tempgrn(ispace,icolor,ispin) =
! & tempgrn(ispace,icolor,ispin)*wt
!1300 continue
!1200 continue
!1100 continue
return
end