I ran into a curious problem with an interface block that I am using while converting an old library. This library contains specific implementations of standard functions like log and exp, the double-precision versions being called dexp and dlog. Ihave used this interface in a number of source files without any problem:
integer, parameter :: dp = kind(1.0d0)fragments from source files where this was no problem!). My workaround is to comment it out.
interface
real(kind=dp) function dexp( x ) -- why is this a problem?
import :: dp
real(kind=dp), intent(in) :: x
end function dexp
end interface
But with one source file where I use that both gfortran and Intel Fortran claim that something is wrong, but I cannot determine what is wrong, quite probably it is staring me in the face, but I seem to be blind for it (mind you, I simply copied
Here is the source file:the error messages make no sense, which is a red herring. You already have dexp defined above so it is a duplicate. It appears to confuse lthe compiler.
! dgami.f90 --
! Original:
! july 1977 edition. w. fullerton, c3, los alamos scientific lab.
!
! evaluate the incomplete gamma function defined by
!
! gami = integral from t = 0 to x of exp(-t) * t**(a-1.0) .
!
! gami is evaluated for positive values of a and non-negative values
! of x. a slight deterioration of 2 or 3 digits accuracy will occur
! when gami is very large or very small, because logarithmic variables
! are used.
!
function dgami (a, x)
use ieee_arithmetic
implicit none
integer, parameter :: dp = kind(1.0d0)
interface
real(kind=dp) function dgamit( a, x )
import :: dp
real(kind=dp), intent(in) :: a, x
end function dgamit
real(kind=dp) function dlngam( x )
import :: dp
real(kind=dp), intent(in) :: x
end function dlngam
real(kind=dp) function dexp( x )
import :: dp
real(kind=dp), intent(in) :: x
end function dexp
real(kind=dp) function dlog( x )
import :: dp
real(kind=dp), intent(in) :: x
end function dlog
!real(kind=dp) function dexp( x ) -- why is this a problem?
! import :: dp
! real(kind=dp), intent(in) :: x
!end function dexp
end interface
real(kind=dp) :: dgami
real(kind=dp) :: a, x
real(kind=dp) :: factor
if ( a <= 0.0d0 .or. x <= 0.0d0 ) then
dgami = ieee_value( x, ieee_quiet_nan )
else
dgami = 0.d0
if ( x /= 0.0d0 ) then
!
! the only error possible in the expression below is a fatal overflow. factor = dexp (dlngam(a) + a*dlog(x))
dgami = factor * dgamit (a, x)
endif
endif
end function dgami
Can anyone point out what is wrong?
messages really went off the map.the error messages make no sense, which is a red herring. You already have dexp defined above so it is a duplicate. It appears to confuse lthe compiler.gfortran gives very confusing messages; ifort is technically correct, and nvfortran correctly complains about a duplicate but seems to be pointing to the arguments; more like it is trying to add the duplicate for a generic interface. But gfortran
(test1) urbanjs:/tmp$ nvfortran xx.f90 -cYes, I first tried to understand the gfortran messages and then tried Intel Fortran. While I understand it is a duplicate, I have used this same code, like I said, in other files without any complaints. Anyway, you confimr that I did not overlook
NVFORTRAN-S-0042-x is a duplicate dummy argument (xx.f90: 42) NVFORTRAN-W-0119-Redundant specification for x (xx.f90: 44)
0 inform, 1 warnings, 1 severes, 0 fatal for dgami
Yes, I first tried to understand the gfortran messages and then tried Intel Fortran. While I understand it is a duplicate, I have used this same code, like I said, in other files without any complaints. Anyway, you confimr that I did not overlookanything obvious.
Regards,
Arjen
the error messages make no sense, which is a red herring. You already have dexp defined above so it is a duplicate. It appears to confuse lthe compiler.
On Wednesday, October 12, 2022 at 2:45:11 PM UTC+2, Arjen Markus wrote:anything obvious.
Yes, I first tried to understand the gfortran messages and then tried Intel Fortran. While I understand it is a duplicate, I have used this same code, like I said, in other files without any complaints. Anyway, you confimr that I did not overlook
Regards,
Arjen
I stared at the messages from gfortran for a long time and, temporarily blinded by them, was unable to grasp the meaning of the messages from Intel Fortran.
Regards,
Arjen
On Wednesday, October 12, 2022 at 2:45:11 PM UTC+2, Arjen Markus wrote:anything obvious.
Yes, I first tried to understand the gfortran messages and then tried Intel Fortran. While I understand it is a duplicate, I have used this same code, like I said, in other files without any complaints. Anyway, you confimr that I did not overlook
Regards,
ArjenI stared at the messages from gfortran for a long time and, temporarily blinded by them, was unable to grasp the meaning of the messages from Intel Fortran.
Regards,
Arjen
On Wednesday, October 12, 2022 at 7:27:36 AM UTC-4, arjen.m...@gmail.com wrote:
..
Can anyone point out what is wrong?the error messages make no sense, which is a red herring. You already have dexp defined above so it is a duplicate. It appears to confuse lthe compiler.
I ran into a curious problem with an interface block that I am using while converting an old library. This library contains specific implementations
of standard functions like log and exp, the double-precision versions being called dexp and dlog.
I have used this interface in a number of source files without any problem:
integer, parameter :: dp = kind(1.0d0)
interface
real(kind=dp) function dexp( x ) -- why is this a problem?
import :: dp
real(kind=dp), intent(in) :: x
end function dexp
end interface
I ran into a curious problem with an interface block that I am using while converting an old library. This library contains specific implementations of standard functions like log and exp, the double-precision versions being called dexp and dlog. Ihave used this interface in a number of source files without any problem:
On Wednesday, October 12, 2022 at 10:27:36 PM UTC+11, arjen wrote:have used this interface in a number of source files without any problem:
I ran into a curious problem with an interface block that I am using while converting an old library. This library contains specific implementations of standard functions like log and exp, the double-precision versions being called dexp and dlog. I
.
Why not just convert dexp, dlog to exp and log?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:37:59 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,579 |