Short answer: yes, although technically as Beliavsky has explained, it’s not the source form (fixed- vs free-) but rather the type of language constructs used historically vs today.
There’s a nice benchmark example from Michael Hirsch, comparing a Fortran II vs modern Fortran inverse tangent function. For the example subprogram, the difference can be a whole order of magnitude.
The example is taken from the IBM Fortran II manual (pg. 29). The subprogram evaluates arctan(x)
accurate to four decimal places, for any positive input x
. The expansions used are:
\mathrm{arctan}(x) = x - \frac{x^3}{3} + \frac{x^5}{5} - \frac{x^7}{7} + \dots
for the region 0 \leq x \leq 1, and
\mathrm{arctan}(x) = \frac{\pi}{2} - \frac{1}{x} + \frac{\left(\frac{1}{x}\right)^3}{3} - \frac{\left(\frac{1}{x}\right)^5}{5} + \frac{\left(\frac{1}{x}\right)^7}{7} - \dots
where x > 1.
Note: the example below only serves to demonstrate different styles of programming. To evaluate the inverse tangent in practice, use the intrinsic function atan(x)
.
Here is a slightly modified example of the Fortran II code:
function arctan(x)
if (x) 2,3,3
2 arctan = -99 ! instead of stop,
return ! return a value outside plausible range
3 arctan = 0.0
if (x - 1.0) 10, 10, 5
5 term = -1.0/x
arctan = 1.57079 ! pi / 2
goto 11
10 term = x
11 prevxp = 1.0
y = term ** 2.0
12 arctan = arctan + term
presxp = prevxp + 2.0
13 term = -prevxp / presxp * y * term
prevxp = presxp
14 if(term - 0.00005) 15, 12, 12
15 if(-term - 0.00005) 16, 12, 12
16 return
end
Here’s what the new code looks like:
elemental real function arctan(x)
use, intrinsic :: ieee_arithmetic, only: &
ieee_value, ieee_quiet_nan
real, intent(in) :: x
real :: prevxp, presxp, term, y
real :: nan
real, parameter :: pi = 4.*atan(1.)
integer :: i
nan = ieee_value(0., ieee_quiet_nan)
if (x < 0.) then
arctan = nan
return
endif
arctan = 0.
if (x - 1. > 0.) then
term = -1. / x
arctan = pi/2
else
term = x
endif
prevxp = 1.
y = term ** 2.
do while(term-0.00005 >= 0. .or. -term - 0.00005 >= 0.)
arctan = arctan + term
presxp = prevxp + 2.
term = -prevxp / presxp * y * term
prevxp = presxp
enddo
end function arctan