Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Computers are useless. They can only give you answers. -- Pablo Picasso


devel / comp.lang.fortran / Re: Curious problem with an interface block (conversion of old code)

SubjectAuthor
* Curious problem with an interface block (conversion of old code)Arjen Markus
+* Re: Curious problem with an interface block (conversion of old code)John
|+* Re: Curious problem with an interface block (conversion of old code)John
||`* Re: Curious problem with an interface block (conversion of old code)Arjen Markus
|| `* Re: Curious problem with an interface block (conversion of old code)Arjen Markus
||  +- Re: Curious problem with an interface block (conversion of old code)JRR
||  `* Re: Curious problem with an interface block (conversion of old code)John
||   `- Re: Curious problem with an interface block (conversion of oldJohn
|`- Re: Curious problem with an interface block (conversion of old code)FortranFan
+- Re: Curious problem with an interface block (conversion of old code)gah4
+- Re: Curious problem with an interface block (conversion of old code)Peter Klausler US
`* Re: Curious problem with an interface block (conversion of old code)Robin Vowels
 `- Re: Curious problem with an interface block (conversion of old code)Arjen Markus

1
Curious problem with an interface block (conversion of old code)

<185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2933&group=comp.lang.fortran#2933

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ad4:5be6:0:b0:4b3:ff39:7ad4 with SMTP id k6-20020ad45be6000000b004b3ff397ad4mr12451681qvc.126.1665574054083;
Wed, 12 Oct 2022 04:27:34 -0700 (PDT)
X-Received: by 2002:a05:622a:4cc:b0:39c:bfb1:8a45 with SMTP id
q12-20020a05622a04cc00b0039cbfb18a45mr1857763qtx.647.1665574053903; Wed, 12
Oct 2022 04:27:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 04:27:33 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.206.149; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.206.149
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
Subject: Curious problem with an interface block (conversion of old code)
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Wed, 12 Oct 2022 11:27:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4023
 by: Arjen Markus - Wed, 12 Oct 2022 11:27 UTC

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

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 fragments from source files where this was no problem!).. My workaround is to comment it out.

Here is the source file:

! 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?

Re: Curious problem with an interface block (conversion of old code)

<8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2934&group=comp.lang.fortran#2934

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:28ce:b0:6cf:933c:40d3 with SMTP id l14-20020a05620a28ce00b006cf933c40d3mr19440400qkp.258.1665577094174;
Wed, 12 Oct 2022 05:18:14 -0700 (PDT)
X-Received: by 2002:a05:622a:34e:b0:39c:8965:549 with SMTP id
r14-20020a05622a034e00b0039c89650549mr5800888qtw.268.1665577094034; Wed, 12
Oct 2022 05:18:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!glou.org!news.glou.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 05:18:13 -0700 (PDT)
In-Reply-To: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:546:300:4c20:d08b:ed2:b2ce:ab2d;
posting-account=7tVJUQoAAACymEG6aShD5R0lhHCm_A0r
NNTP-Posting-Host: 2601:546:300:4c20:d08b:ed2:b2ce:ab2d
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: urbanjost@comcast.net (John)
Injection-Date: Wed, 12 Oct 2022 12:18:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: John - Wed, 12 Oct 2022 12:18 UTC

On Wednesday, October 12, 2022 at 7:27:36 AM UTC-4, arjen.m...@gmail.com wrote:
> 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
>
> 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 fragments from source files where this was no problem!). My workaround is to comment it out.
>
> Here is the source file:
>
> ! 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?
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.

Re: Curious problem with an interface block (conversion of old code)

<ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2935&group=comp.lang.fortran#2935

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:2293:b0:6ee:94a6:5cd4 with SMTP id o19-20020a05620a229300b006ee94a65cd4mr2184992qkh.537.1665577860034;
Wed, 12 Oct 2022 05:31:00 -0700 (PDT)
X-Received: by 2002:a0c:9151:0:b0:4b1:8375:46d3 with SMTP id
q75-20020a0c9151000000b004b1837546d3mr22810389qvq.122.1665577859851; Wed, 12
Oct 2022 05:30:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 05:30:59 -0700 (PDT)
In-Reply-To: <8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:546:300:4c20:d08b:ed2:b2ce:ab2d;
posting-account=7tVJUQoAAACymEG6aShD5R0lhHCm_A0r
NNTP-Posting-Host: 2601:546:300:4c20:d08b:ed2:b2ce:ab2d
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com> <8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: urbanjost@comcast.net (John)
Injection-Date: Wed, 12 Oct 2022 12:31:00 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2088
 by: John - Wed, 12 Oct 2022 12:30 UTC

> 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 messages really went off the map.

(test1) urbanjs@venus:/tmp$ nvfortran xx.f90 -c
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

Re: Curious problem with an interface block (conversion of old code)

<7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2936&group=comp.lang.fortran#2936

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:1441:b0:35c:da34:d5dc with SMTP id v1-20020a05622a144100b0035cda34d5dcmr23582269qtx.338.1665578698469;
Wed, 12 Oct 2022 05:44:58 -0700 (PDT)
X-Received: by 2002:ad4:5dee:0:b0:4b4:b8a:78db with SMTP id
jn14-20020ad45dee000000b004b40b8a78dbmr11143025qvb.12.1665578687544; Wed, 12
Oct 2022 05:44:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 05:44:47 -0700 (PDT)
In-Reply-To: <ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.206.149; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.206.149
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
<8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com> <ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Wed, 12 Oct 2022 12:44:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2403
 by: Arjen Markus - Wed, 12 Oct 2022 12:44 UTC

On Wednesday, October 12, 2022 at 2:31:01 PM UTC+2, John wrote:
> > 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 messages really went off the map.
>
>
> (test1) urbanjs:/tmp$ nvfortran xx.f90 -c
> 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 overlook anything obvious.

Regards,

Arjen

Re: Curious problem with an interface block (conversion of old code)

<0eb93353-834c-4230-a827-46ad21fc3701n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2937&group=comp.lang.fortran#2937

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:4092:b0:6d9:4c68:4715 with SMTP id f18-20020a05620a409200b006d94c684715mr20336185qko.518.1665579423491;
Wed, 12 Oct 2022 05:57:03 -0700 (PDT)
X-Received: by 2002:ac8:4d5b:0:b0:39c:b6d2:b631 with SMTP id
x27-20020ac84d5b000000b0039cb6d2b631mr5349060qtv.487.1665579423329; Wed, 12
Oct 2022 05:57:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 05:57:03 -0700 (PDT)
In-Reply-To: <7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.206.149; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.206.149
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
<8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com> <ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
<7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0eb93353-834c-4230-a827-46ad21fc3701n@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Wed, 12 Oct 2022 12:57:03 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1972
 by: Arjen Markus - Wed, 12 Oct 2022 12:57 UTC

On Wednesday, October 12, 2022 at 2:45:11 PM UTC+2, Arjen Markus wrote:

> 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 anything obvious.
>
> 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

Re: Curious problem with an interface block (conversion of old code)

<ti6id8$gf7$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2938&group=comp.lang.fortran#2938

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!ffe3+6itofTbJEE5OLJN6w.user.46.165.242.91.POSTED!not-for-mail
From: juergen.reuter@invalid.com (JRR)
Newsgroups: comp.lang.fortran
Subject: Re: Curious problem with an interface block (conversion of old code)
Date: Wed, 12 Oct 2022 16:19:19 +0200
Organization: Aioe.org NNTP Server
Message-ID: <ti6id8$gf7$1@gioia.aioe.org>
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
<8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>
<ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
<7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com>
<0eb93353-834c-4230-a827-46ad21fc3701n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="16871"; posting-host="ffe3+6itofTbJEE5OLJN6w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.3.2
X-Notice: Filtered by postfilter v. 0.9.2
 by: JRR - Wed, 12 Oct 2022 14:19 UTC

Am 12.10.22 um 14:57 schrieb Arjen Markus:
> On Wednesday, October 12, 2022 at 2:45:11 PM UTC+2, Arjen Markus wrote:
>
>> 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 anything obvious.
>>
>> 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

Hi Arjen,
supposedly this is sort of a bug when gfortran/gcc flushes its error
messages. An error is triggered, I would guess, by the duplicate
interface for dexp, but parsing seems to continue. And then gfortran
stumbles over the following problem. In an interface like
real(kind=dp) function dexp (x)
import dp
....

the usage of dp comes before the import of dp. This confused several
compilers before, and some wouldn't allow that for some time. Here, the
parsing is somehow stopped because of the duplicate dexp interface,
and then the import is not correctly parsed, such that gfortran doesn't
understand the constant in real(kind=dp) and throws the error message:
46 | real(kind=dp) function dexp( x ) ! -- why is this a
problem?
| 1
Error: Parameter ‘dp’ at (1) has not been declared or is a variable,
which does not reduce to a constant expression
foo.f90:47:19:

47 | import :: dp
| 1
Error: IMPORT statement at (1) only permitted in an INTERFACE body

--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron (DESY)
Hamburg, Germany

Re: Curious problem with an interface block (conversion of old code)

<b1b99660-e295-403b-8f99-7cad1813aaa5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2939&group=comp.lang.fortran#2939

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:28ce:b0:6cf:933c:40d3 with SMTP id l14-20020a05620a28ce00b006cf933c40d3mr19912078qkp.258.1665584437388;
Wed, 12 Oct 2022 07:20:37 -0700 (PDT)
X-Received: by 2002:ac8:5c84:0:b0:35c:cc95:def with SMTP id
r4-20020ac85c84000000b0035ccc950defmr23948901qta.552.1665584437257; Wed, 12
Oct 2022 07:20:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 07:20:37 -0700 (PDT)
In-Reply-To: <0eb93353-834c-4230-a827-46ad21fc3701n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:546:300:4c20:d08b:ed2:b2ce:ab2d;
posting-account=7tVJUQoAAACymEG6aShD5R0lhHCm_A0r
NNTP-Posting-Host: 2601:546:300:4c20:d08b:ed2:b2ce:ab2d
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
<8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com> <ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
<7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com> <0eb93353-834c-4230-a827-46ad21fc3701n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b1b99660-e295-403b-8f99-7cad1813aaa5n@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: urbanjost@comcast.net (John)
Injection-Date: Wed, 12 Oct 2022 14:20:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2479
 by: John - Wed, 12 Oct 2022 14:20 UTC

On Wednesday, October 12, 2022 at 8:57:05 AM UTC-4, arjen.m...@gmail.com wrote:
> On Wednesday, October 12, 2022 at 2:45:11 PM UTC+2, Arjen Markus wrote:
>
> > 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 anything obvious.
> >
> > 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

Yes, same experience. The intel message was technically correct but vague, and the gfortran errors already had me looking for UNICODE characters, etc.. ; so saw it by eye first. I nice "duplicate interface for dexp" message would have been nice to have gotten from any of them.

Re: Curious problem with an interface block (conversion of old code)function dexp( x ) import :: dp real(kind=dp), intent(in) :: x real(kind=dp) :: dexp end function dexp

<75db6dac-d278-4e8b-a2be-cd015389f63bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2940&group=comp.lang.fortran#2940

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:191c:b0:6ed:88c5:e839 with SMTP id bj28-20020a05620a191c00b006ed88c5e839mr9768636qkb.627.1665585870575;
Wed, 12 Oct 2022 07:44:30 -0700 (PDT)
X-Received: by 2002:a05:620a:1721:b0:6ce:78a7:daca with SMTP id
az33-20020a05620a172100b006ce78a7dacamr20993223qkb.487.1665585870449; Wed, 12
Oct 2022 07:44:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 07:44:30 -0700 (PDT)
In-Reply-To: <b1b99660-e295-403b-8f99-7cad1813aaa5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:546:300:4c20:d08b:ed2:b2ce:ab2d;
posting-account=7tVJUQoAAACymEG6aShD5R0lhHCm_A0r
NNTP-Posting-Host: 2601:546:300:4c20:d08b:ed2:b2ce:ab2d
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
<8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com> <ba25112b-bffe-42ea-a112-ee70e009a046n@googlegroups.com>
<7c53ff57-2413-4ee4-a324-855320c9eb02n@googlegroups.com> <0eb93353-834c-4230-a827-46ad21fc3701n@googlegroups.com>
<b1b99660-e295-403b-8f99-7cad1813aaa5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <75db6dac-d278-4e8b-a2be-cd015389f63bn@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old
code)function dexp( x ) import :: dp real(kind=dp), intent(in) :: x
real(kind=dp) :: dexp end function dexp
From: urbanjost@comcast.net (John)
Injection-Date: Wed, 12 Oct 2022 14:44:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2018
 by: John - Wed, 12 Oct 2022 14:44 UTC

43 | function dexp( x )
| 1
Error: Symbol ‘dexp’ at (1) already has an explicit interface

Using dp before the import does seem to be conflating it. Get a nice message if routine is instead

function dexp( x )
import :: dp
real(kind=dp), intent(in) :: x
real(kind=dp) :: dexp
end function dexp

Re: Curious problem with an interface block (conversion of old code)

<045e04f7-1fc5-4650-add4-0a0aa0a8f5een@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2941&group=comp.lang.fortran#2941

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:138b:b0:35b:b619:b87d with SMTP id o11-20020a05622a138b00b0035bb619b87dmr23948694qtk.146.1665586056509;
Wed, 12 Oct 2022 07:47:36 -0700 (PDT)
X-Received: by 2002:a05:622a:1e0e:b0:35c:fe96:e7c2 with SMTP id
br14-20020a05622a1e0e00b0035cfe96e7c2mr24043996qtb.339.1665586056293; Wed, 12
Oct 2022 07:47:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 07:47:36 -0700 (PDT)
In-Reply-To: <8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.226.61.14; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 136.226.61.14
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com> <8b839075-06c6-46b4-9e70-afd2bda99024n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <045e04f7-1fc5-4650-add4-0a0aa0a8f5een@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Wed, 12 Oct 2022 14:47:36 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 19
 by: FortranFan - Wed, 12 Oct 2022 14:47 UTC

On Wednesday, October 12, 2022 at 8:18:15 AM UTC-4, John wrote:

> 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.

One processor gave the following which seems informative enough:
--- begin message ---
C:\temp>ifort /c /standard-semantics dgami.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

dgami.f90(42): error #6623: The procedure name of the INTERFACE block conflicts with a name in the encompassing scoping unit. [DEXP]
real(kind=dp) function dexp( x ) ! -- why is this a problem?
-----------------------^
compilation aborted for dgami.f90 (code 1)
--- end message ---

Dismayingly, OP didn't include in the original post the compiler messages received nor any details on the processors themselves.

Re: Curious problem with an interface block (conversion of old code)

<3b86ba73-ed89-484d-ade9-64cb7e504babn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2942&group=comp.lang.fortran#2942

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a0c:8041:0:b0:4af:b13b:2624 with SMTP id 59-20020a0c8041000000b004afb13b2624mr23462232qva.92.1665587982013;
Wed, 12 Oct 2022 08:19:42 -0700 (PDT)
X-Received: by 2002:a05:622a:34e:b0:39c:8965:549 with SMTP id
r14-20020a05622a034e00b0039c89650549mr6632427qtw.268.1665587981882; Wed, 12
Oct 2022 08:19:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 08:19:41 -0700 (PDT)
In-Reply-To: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:5468:f76:d9f:ee23;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:5468:f76:d9f:ee23
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3b86ba73-ed89-484d-ade9-64cb7e504babn@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 12 Oct 2022 15:19:42 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2732
 by: gah4 - Wed, 12 Oct 2022 15:19 UTC

On Wednesday, October 12, 2022 at 4:27:36 AM UTC-7, arjen.m...@gmail.com wrote:
> 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

Using the names of existing Fortran library functions as names of your functions
does complicate things.

Traditionally, you put the name in an EXTERNAL statement when you use them.

In Fortran 66, there are intrinsic functions, which the compiler normally generates
code for inline, and external functions, which are calls to actual library functions.

That distinction was important, as the latter could be used as an actual argument
to another function or subroutine. (For example, an argument to a numerical
integration routine.)

While Fortran now calls all the functions in the standard intrinsic, the
distinction is still there. There is a list of functions that can be used as
an actual argument, and ones that can't.

DLOG and DEXP are listed in the ones that can, called "unrestricted".

It might be less confusing to rename them, such as MYDLOG and MYDEXP.

Re: Curious problem with an interface block (conversion of old code)

<744033d4-1b92-434d-a78a-221dd0d70aebn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2943&group=comp.lang.fortran#2943

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:1450:b0:35d:140d:f7bf with SMTP id v16-20020a05622a145000b0035d140df7bfmr24200281qtx.612.1665596729532;
Wed, 12 Oct 2022 10:45:29 -0700 (PDT)
X-Received: by 2002:a0c:abc7:0:b0:4b4:8d4e:d2f8 with SMTP id
k7-20020a0cabc7000000b004b48d4ed2f8mr1485560qvb.43.1665596729301; Wed, 12 Oct
2022 10:45:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 10:45:29 -0700 (PDT)
In-Reply-To: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=ZT-cAwoAAACx2tBPXm-WZoHIT8sjnGGy
NNTP-Posting-Host: 12.154.207.45
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <744033d4-1b92-434d-a78a-221dd0d70aebn@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: pklausler@nvidia.com (Peter Klausler US)
Injection-Date: Wed, 12 Oct 2022 17:45:29 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1482
 by: Peter Klausler US - Wed, 12 Oct 2022 17:45 UTC

$ f18 -fsyntax-only t2.f90
../t2.f90:29:24: error: 'dexp' is already declared in this scoping unit
real(kind=dp) function dexp( x ) ! -- why is this a problem?
^^^^
../t2.f90:19:24: Previous declaration of 'dexp'
real(kind=dp) function dexp( x )
^^^^

Re: Curious problem with an interface block (conversion of old code)

<a9e23fa7-264b-4a3e-b3ae-18862ab6c63fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2944&group=comp.lang.fortran#2944

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:178d:b0:6ee:9241:89c8 with SMTP id ay13-20020a05620a178d00b006ee924189c8mr5386786qkb.194.1665617671320;
Wed, 12 Oct 2022 16:34:31 -0700 (PDT)
X-Received: by 2002:ad4:5f47:0:b0:4ac:b8de:1484 with SMTP id
p7-20020ad45f47000000b004acb8de1484mr25362585qvg.77.1665617671135; Wed, 12
Oct 2022 16:34:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 12 Oct 2022 16:34:30 -0700 (PDT)
In-Reply-To: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a9e23fa7-264b-4a3e-b3ae-18862ab6c63fn@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Wed, 12 Oct 2022 23:34:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1693
 by: Robin Vowels - Wed, 12 Oct 2022 23:34 UTC

On Wednesday, October 12, 2022 at 10:27:36 PM UTC+11, arjen.m...@gmail.com wrote:
> 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:
..
Why not just convert dexp, dlog to exp and log?

Re: Curious problem with an interface block (conversion of old code)

<a119d89e-7b24-44ba-bf4c-aaa077dc9cc9n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2945&group=comp.lang.fortran#2945

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:144a:b0:39c:c974:9522 with SMTP id v10-20020a05622a144a00b0039cc9749522mr2371035qtx.338.1665645041191;
Thu, 13 Oct 2022 00:10:41 -0700 (PDT)
X-Received: by 2002:ad4:5dc6:0:b0:4b3:5d60:f41c with SMTP id
m6-20020ad45dc6000000b004b35d60f41cmr24036214qvh.100.1665645041048; Thu, 13
Oct 2022 00:10:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 13 Oct 2022 00:10:40 -0700 (PDT)
In-Reply-To: <a9e23fa7-264b-4a3e-b3ae-18862ab6c63fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.212.232; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.212.232
References: <185c890b-dfd4-4749-8849-512f2730ed92n@googlegroups.com> <a9e23fa7-264b-4a3e-b3ae-18862ab6c63fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a119d89e-7b24-44ba-bf4c-aaa077dc9cc9n@googlegroups.com>
Subject: Re: Curious problem with an interface block (conversion of old code)
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Thu, 13 Oct 2022 07:10:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2577
 by: Arjen Markus - Thu, 13 Oct 2022 07:10 UTC

On Thursday, October 13, 2022 at 1:34:32 AM UTC+2, Robin Vowels wrote:
> On Wednesday, October 12, 2022 at 10:27:36 PM UTC+11, arjen wrote:
> > 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:
> .
> Why not just convert dexp, dlog to exp and log?

Thanks for all your reactions. I am trying to modernise the original code and the source I posted is a first step in that direction. The incomprehensibility of the messages I got with gfortran led to me being blinded for the actual problem.
The original library supplies its own, apparently portable, versions of the standard functions (single and double-precision). I will turn to the standard implementation later, but to ensure that the results are the same, I have left in the library's substitutes.

(It also provided me with an opportunity to post here: as I had not seen any posts for a surprisingly long time, I was beginning to wonder if we had a Google outage again, like a couple of years ago)
Regards,

Arjen

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor