Reputation: 123
I used to work with Intel Visual Fortran and my code runs smoothly there. However I bought Absoft Fotran Compiler and I am getting many errors...
This is a sample program where I get errors
FUNCTION norm_inv(x)
USE nrtype
USE tauchen
IMPLICIT NONE
REAL(DP), INTENT(IN) :: x
REAL(DP) :: norm_inv,zbrent,x1,x2,tol
tol=1.0E-6
x1=-10.0
x2=10.0
norm_inv=zbrent(fni,x1,x2,tol)
CONTAINS
FUNCTION fni(x0)
USE nrtype
IMPLICIT NONE
REAL(DP), INTENT(IN) :: x0
REAL(DP) :: fni,norm_cdf
fni=norm_cdf(x0)-x
END FUNCTION fni
END FUNCTION norm_inv
And the Absoft compiler tells me
Message Number: 379
A procedure name is used as an actual argument to a function or subroutine call, but the procedure name has not been given the EXTERNAL attribute, is not a module procedure, or is not specified in an interface block. NOTE: Giving the EXTERNAL attribute to the name of the SUBROUTINE being compiled is an extension to the standard.
When I declare it external it tells me
Message Number: 552 The compiler detected a conflict in declarations for this object. Because the object has the given attribute, it must not be declared to be the new item.
Upvotes: 2
Views: 113
Reputation: 32441
fni
is an internal procedure of the function norm_inv
(where the call to zbrent
is made). Passing an internal procedure as an actual argument is a feature new to Fortran 2008. Crucially, this is a feature implemented in the Intel compiler, but not the Absoft.
To make the code more "portable" working around things to make fni
not internal would work. Merely adding the external
attribute to fni
would not be sufficient, and would indeed be incorrect.
Upvotes: 1