title: Function return type mismatch
body: <p>I'm attempting to recode an old C++ program in Fortran to make use of LAPACK (I'm aware that C++ does have LAPACK++, but I'm having a lot of trouble installing it, so I gave up).</p>
  
  <p>I originally didn't have any problems with compilation, but that was when I had all variables declared as <code>REAL</code>. When I started coding the section of the program that required LAPACK, I found that all parameters passed to <code>DSYEV</code> need to be <code>DOUBLE PRECISION</code>. So I tried to change everything to double precision (including changing all hard coded numbers to their double precision counterparts, i.e. 0.0 -> 0.0D0) Now when I try to compile, I get the following error for all of the functions and subroutines that I've written:</p>
  
  <pre><code>    Error: Return type mismatch of function &lt;function&gt; at (1) (REAL(4)/REAL(8))
  </code></pre>
  
  <p>I'm not sure where this is coming from, as everything in the program has been changed to double precision.</p>
  
  <p>For example, I've declared the following:</p>
  
  <pre><code>double precision :: alpha(3),d(3),zeta1,zeta2
  double precision :: A1(3),A2(3),D1(3),D2(3)
  double precision :: PI
  PI = 3.14159265359D0
  alpha = (/0.109818D0, 0.405771D0, 2.22766D0/)
  d = (/0.444635D0, 0.535328D0, 0.154329D0 /)
  
  do 10 i=1,3
  
  A1(i) = alpha(i)*zeta1**2.0D0
  A2(i) = alpha(i)*zeta2**2.0D0
  D1(i) = d(i)*(2.0D0*A1(i)/PI)**(3.0D0/4.0D0)
  D2(i) = d(i)*(2.0D0*A2(i)/PI)**(3.0D0/4.0D0)
  
  10  continue
  </code></pre>
  
  <p>And the function:</p>
  
  <pre><code>subroutine createS(S,A1,A2,D1,D2,r)
  double precision A1(3),A2(3),D1(3),D2(3) 
  double precision r
  double precision S(2,2)
  integer :: i,j
  S(1,1) = 1.0D0
  S(2,2) = 1.0D0
  do 80 i=1,3
  do 90 j=1,3
  
  S(1,2) = S(1,2) + getS(A1(i),A2(j),r)*D1(i)*D2(j)
  
   90 continue
   80 continue
  S(2,1) = S(1,2)
  return
  end
  
  double precision function getS(a,b,r)
  double precision :: PI
  double precision a,b,r
  double precision :: S
  PI = 3.14159265359D0
  S = (PI/(a+b))**1.5D0
  S = S*dexp(-(a*b*r*r)/(a+b))
  getS = S
  return
  end
  </code></pre>
  
  <p>And then I get the error</p>
  
  <pre><code>  HFSTO3G.f:85.28:
  
    S(1,2) = S(1,2) + getS(A1(i),A2(j),r)*D1(i)*D2(j)                 
                          1
    Error: Return type mismatch of function 'gets' at (1) (REAL(4)/REAL(8))
  </code></pre>
  
  <p>I'm using gfortran to compile. Could that be the issue? I'm not new to programming, but new to Fortran. Not programming this in Fortran is not an option.</p>