ifort version 11.1 bug?

ifort version 11.1 bug?

Hi. I compile the following Fortran 90 code with ifort test.f90 -o test

program test
  implicit none
  real  ::  tc
  real  :: tau0
  real  :: theta,tau
  real  :: btau,neout
  real  :: fwhm
  real  :: zs
  integer :: model
  real  :: rcors,conc
  real  :: rs
  logical :: use_own_tau0,key
 
  use_own_tau0 = .false.
 
  theta = 85.1
  fwhm =      1.0
  conc =      2.2  
  tc =   14.4         
  model =      2
  rs = 0.8  
  rcors =  0.04
  zs = 0.05
  key = .false.
 
 
  if(use_own_tau0)then
     call smooth_tau(theta,fwhm,conc,tc,btau,model,rs,rcors,zs,key,tau0)
  else
     call smooth_tau(theta,fwhm,conc,tc,btau,model,rs,rcors,zs,key)
  end if
 
  call tauprofile(tau,theta,tc,conc,model,rs,rcors,zs)              
 

end program test

subroutine smooth_tau(theta,fwhm,conc,tc,btau,model,rs,rcors,r,key,tau0)
  implicit none
  real  :: theta,fwhm
  real ,optional :: tau0
  real  :: t,btau,z,sigma
  real  ::conc,tc
  integer :: i
  real  :: sum, delta,rcors
  real  :: rs,r,t1,t2
  integer :: model
  logical :: key

  write(*,*)theta,fwhm,conc,tc,model,rs,rcors,key,r,present(tau0)
  stop
 
  sigma = fwhm

  delta = sigma/4.0

  sum = 0.d0
  do i=1,24

       if(theta/sigma .gt. 3.d0)then
          t1 = theta + (i-13)*delta
          t2 = theta + (i-12)*delta
       else
          t1 = (i-1)*delta
          t2 = i*delta
       end if

     if(present(tau0))then
        sum = sum+(integrand(t1,sigma,conc,tc,tau0)+integrand(t2,sigma,conc,tc,tau0))*delta/2.d0
     else

        sum = sum+(integrand(t1,sigma,conc,tc)+integrand(t2,sigma,conc,tc))*delta/2.d0
     end if
  end do
 
contains

  function integrand(t,sigma,conc,tc,tau0)
    implicit none
    real  :: t,sigma,conc,tc
    real  :: integrand
    real ,optional :: tau0

    integrand = 0.d0

  end function integrand

end subroutine smooth_tau

subroutine tauprofile(tau,theta,tc,conc,model,rs,rcors,redshift)
  implicit none
  real :: tau,theta,tc,conc
  integer :: model
  real :: rs,rcors,redshift
end subroutine tauprofile

--------------------------------------------------------------------

When I run the code, the following is output to the screen:

   85.10000       1.000000       2.200000       14.40000               2
  0.8000000      3.9999999E-02 F  5.0000001E-02 T

But since use_own_tau0 is false, the subroutine smooth_tau is called without the optional argument tau0, and so the value of present(tau0), which is the final thing written out, should be F. But as you can see, it is output as T.

I've confirmed that compiling with gfortran and running gives the correct result, that is, F.

Furthermore, deleting any of the seemingly extraneous lines of code following 'stop' seems to fix the problem, as does printing out fewer variables to the screen. Is this a bug with ifort, or is there some memory violation which I'm not seeing?

Alex

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Lorri Menard (Intel)'s picture

Because subroutine smooth_tau has an optional argument, its interface needs to be visible within any routine that calls smooth_tau.

That's not true for your "program test".

 

Steve Lionel (Intel)'s picture

Further reading:

Doctor Fortran and the Virtues of Omission
Doctor Fortran Gets Explicit - Again!

Also, if you compile with:

-warn interface

you will get diagnostics such as these:

U393563.f90(28): error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute.
 Required explicit interface is missing from original source.   [TAU0]
     call smooth_tau(theta,fwhm,conc,tc,btau,model,rs,rcors,zs,key,tau0)
-------------------------------------------------------------------^
U393563.f90(30): error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute.
 Required explicit interface is missing from original source.   [SMOOTH_TAU]
     call smooth_tau(theta,fwhm,conc,tc,btau,model,rs,rcors,zs,key)
----------^

Steve

Thankyou, that's very helpful!

Login to leave a comment.