Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Binding name

41 views
Skip to first unread message

James Van Buskirk

unread,
May 20, 2008, 5:39:43 AM5/20/08
to
Can the binding name of a procedure be an initialization expression?
For example in N1601.pdf, section 5.1.2.4, we see:

"R509 language-binding-spec is BIND(C[,NAME =
scalar-char-initialization-expr ])"

So I tried the following example:

C:\gfortran\test\complex>type complex.f90
module trig_sp
use ISO_C_BINDING
implicit none
private
character(*), parameter :: ext = 'f'
integer, parameter :: rkind = C_FLOAT
integer, parameter :: ckind = C_FLOAT_COMPLEX
public ACOS
interface ACOS
function ACOS(z) bind(C,name='cacosf') ! Compiles
! function ACOS(z) bind(C,name='cacos'//'f') ! Causes error
! function ACOS(z) bind(C,name='cacos'//ext) ! Causes error
import ext, rkind, ckind
complex(ckind), value :: z
complex(ckind) ACOS
end function ACOS
end interface ACOS
end module trig_sp

module trigs
use trig_sp
end module trigs

program complex1
use ISO_C_BINDING
use trigs
implicit none
complex(C_FLOAT_COMPLEX) z

z = (2.0,1.1)
write(*,*) ACOS(z)
write(*,*) cos(ACOS(z))
end program complex1

C:\gfortran\test\complex>gfortran complex.f90 -ocomplex

C:\gfortran\test\complex>complex
( 0.54649514 , -1.4946060 )
( 2.0000010 , 1.0999998 )

So it worked as written. But now I tried an initialization
expression instead of a character literal and I got:

C:\gfortran\test\complex>gfortran complex.f90 -ocomplex
complex.f90:11.42:

function ACOS(z) bind(C,name='cacos'//'f') ! Causes error
1
Error: Missing closing paren for binding label at (1)

and further errors.

What I really want to do is import that 'f' character, but I am
not sure if there is any syntax that permits it. With what I
tried, I got the same error:

C:\gfortran\test\complex>gfortran complex.f90 -ocomplex
complex.f90:12.42:

function ACOS(z) bind(C,name='cacos'//ext) ! Causes error
1
Error: Missing closing paren for binding label at (1)

So what I want to know is:

1) Is the form with 'cacos'//'f' valid Fortran, hence a bug in
gfortran?

2) If the answer to 1) above is yes, then is the form with
'cacos'//ext valid Fortran, where ext was injected via an
IMPORT statement within the interface body?

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


FX

unread,
May 20, 2008, 5:59:04 AM5/20/08
to
> "R509 language-binding-spec is BIND(C[,NAME =
> scalar-char-initialization-expr ])"

I think that's pretty clear, and your example is accepted by both the
Intel and Sun compilers.

This is now GCC PR36275 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36275)

--
FX

FX

unread,
May 20, 2008, 6:08:48 AM5/20/08
to
> 2) If the answer to 1) above is yes, then is the form with
> 'cacos'//ext valid Fortran, where ext was injected via an
> IMPORT statement within the interface body?

That's a good one. And, is there a difference between the two variants
below:

module trig_sp
implicit none


character(*), parameter :: ext = 'f'

interface ACOS
subroutine ACOS
import ext
bind(C,name='cacos' // ext) :: acos
end subroutine ACOS


end interface ACOS
end module trig_sp

and:

module trig_sp
implicit none


character(*), parameter :: ext = 'f'

interface ACOS
subroutine ACOS bind(C,name='cacos' // ext)
import ext
end subroutine ACOS


end interface ACOS
end module trig_sp

If I understand your question 2 above correctly, you're asking about the
second one, right? The first one, I think, is easily seen as valid.
Reasoning by similarity, I'd be tempted to say that both are valid, for
the same reason than both following examples are valid:

module trig_sp
implicit none
integer, parameter :: i = 4
interface ACOS
function ACOS ()
import i
integer(kind=i) :: ACOS


end function ACOS
end interface ACOS
end module trig_sp

module trig_sp
implicit none
integer, parameter :: i = 4
interface ACOS
integer(kind=i) function ACOS ()
import i


end function ACOS
end interface ACOS
end module trig_sp

--
FX

James Van Buskirk

unread,
May 20, 2008, 6:10:39 AM5/20/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g0u7d7$140$1...@nef.ens.fr...

>> "R509 language-binding-spec is BIND(C[,NAME =
>> scalar-char-initialization-expr ])"

> I think that's pretty clear, and your example is accepted by both the
> Intel and Sun compilers.

Do Intel & Sun accept the version I really care about, with 'cacos'//ext ?

Thanks.

James Van Buskirk

unread,
May 20, 2008, 6:30:55 AM5/20/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g0u7vg$140$2...@nef.ens.fr...

> module trig_sp
> implicit none
> character(*), parameter :: ext = 'f'
> interface ACOS
> subroutine ACOS
> import ext
> bind(C,name='cacos' // ext) :: acos
> end subroutine ACOS
> end interface ACOS
> end module trig_sp

> module trig_sp


> implicit none
> character(*), parameter :: ext = 'f'
> interface ACOS
> subroutine ACOS bind(C,name='cacos' // ext)
> import ext
> end subroutine ACOS
> end interface ACOS
> end module trig_sp

If either of these works, I would be able to go forward. I didn't
think of the first form above, not realizing that the language-
binding-spec for a procedure could be placed in the procedure body
as well as the procedure-stmt suffix. I worry because of N1601.pdf,
section 5.2.4, which says:

"5.2.4 BIND statement

R522 bind-stmt is language-binding-spec [ :: ] bind-entity-list
R523 bind-entity is entity-name
or / common-block-name /

C550 (R522) If any bind-entity in a bind-stmt is an entity-name, the
bind-stmt shall appear in the specification part of a module
and the entity shall be an interoperable variable (15.2.4,
15.2.5)."

If the bind-stmt is in an interface body in the specification part
of a module, does that mean that syntactically it is in the
specification part of a module? And is a procedure an interoperable
variable, especially a subroutine?

Also section 5.1.2.4:

"The BIND attribute for a variable or common block specifies that
it is capable of interoperating with a C variable that has external
linkage (15.3)."

So I am not certain that putting the BIND statement within the
interface body is acceptable Fortran. Any Standard gurus have
anything to say about these possibilities?

FX

unread,
May 20, 2008, 6:55:48 AM5/20/08
to
> If the bind-stmt is in an interface body in the specification part of a
> module, does that mean that syntactically it is in the specification
> part of a module?

I'd say so. If not, it's really twisted :)

> And is a procedure an interoperable variable, especially a subroutine?

That is the snag, I guess. (Though there is no different between function
and a subroutine, because the latter corresponds to a C function of
return type "void"). For the following:

module trig_sp
implicit none
interface ACOS
subroutine ACOS
bind(C,name='cacos') :: acos


end subroutine ACOS
end interface ACOS
end module trig_sp

Intel, Sun and g95 compile it. gfortran refuses it because the bind(c)
"can only be used for variables or common blocks". IBM refuses it because
"Variables with the BIND(C) attribute must only appear in the
specification part of a module.

In short, it's a bloody mess.

--
FX

James Van Buskirk

unread,
May 20, 2008, 10:01:36 AM5/20/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g0uank$10rf$1...@nef.ens.fr...

> module trig_sp
> implicit none
> interface ACOS
> subroutine ACOS
> bind(C,name='cacos') :: acos
> end subroutine ACOS
> end interface ACOS
> end module trig_sp

> Intel, Sun and g95 compile it. gfortran refuses it because the bind(c)
> "can only be used for variables or common blocks". IBM refuses it because
> "Variables with the BIND(C) attribute must only appear in the
> specification part of a module.

> In short, it's a bloody mess.

I am still hoping that my original syntax with

function ACOS(z) bind(C,name='cacos'//ext) ! Causes error
import ext, rkind, ckind

is standard-conforming. But it's possible that even so it may
be difficult to get gfortran or any other compiler to accept it.
This is almost as bad as C++ where you know what you want to do and
you know it's within the scope of the language but there is no way
that you can guess the syntax for it.

Here's another attempt with gfortran:

C:\gfortran\test\complex>type complex1.f90


module trig_sp
use ISO_C_BINDING
implicit none
private

character(*), parameter :: ext = 'f'

integer, parameter :: rkind = C_FLOAT
integer, parameter :: ckind = C_FLOAT_COMPLEX

abstract interface
function stub(z) bind(C)
import rkind, ckind
complex(ckind), value :: z
complex(ckind) stub
end function stub
end interface
procedure(stub), bind(C,name='cacosf') :: my_ACOS ! Compiles
! procedure(stub), bind(C,name='cacos'//ext) :: my_ACOS ! Causes error
public ACOS
interface ACOS
procedure my_ACOS


end interface ACOS
end module trig_sp

module trigs


use trig_sp
end module trigs

program complex1
use ISO_C_BINDING
use trigs
implicit none
complex(C_FLOAT_COMPLEX) z

z = (2.0,1.1)
write(*,*) ACOS(z)
write(*,*) cos(ACOS(z))
end program complex1

C:\gfortran\test\complex>gfortran complex1.f90 -ocomplex1
complex1.f90:15.52:

procedure(stub), bind(C,name='cacosf') :: my_ACOS ! Compiles
1
Warning: Variable 'my_acos' at (1) may not be a C interoperable kind but it
is b
ind(c)

C:\gfortran\test\complex>complex1


( 0.54649514 , -1.4946060 )
( 2.0000010 , 1.0999998 )

Now, I don't grok that warning, but gfortran likes this variation
and it's only one step away from liking the "Causes error" version
in that it only needs to handle the initialization expression part,
not the concept of injecting the named constant ext from the
interface body back up into the function statement.

Richard Maine

unread,
May 20, 2008, 11:50:37 AM5/20/08
to
James Van Buskirk <not_...@comcast.net> wrote:

> C550 (R522) If any bind-entity in a bind-stmt is an entity-name, the
> bind-stmt shall appear in the specification part of a module
> and the entity shall be an interoperable variable (15.2.4,
> 15.2.5)."
>
> If the bind-stmt is in an interface body in the specification part
> of a module, does that mean that syntactically it is in the
> specification part of a module?

Yes.

> And is a procedure an interoperable
> variable, especially a subroutine?

No. And that's sort of the point of that constraint - that the separate
BIND statement is only for those two things - not for a procedure or a
type. For a procedure, the BIND atribute specification goes on the
procedure header (the function or subroutine statement). That's the only
place for it.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain

Steve Lionel

unread,
May 20, 2008, 12:08:19 PM5/20/08
to
On Tue, 20 May 2008 04:10:39 -0600, "James Van Buskirk"
<not_...@comcast.net> wrote:

>Do Intel & Sun accept the version I really care about, with 'cacos'//ext ?

Intel does not. I'll report that.
--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/performancetools/fortran
My Fortran blog
http://www.intel.com/software/drfortran

Tobias Burnus

unread,
May 20, 2008, 12:45:09 PM5/20/08
to
Hi all,

On May 20, 11:39 am, "James Van Buskirk" <not_va...@comcast.net>
wrote:


> Can the binding name of a procedure be an initialization expression?
> For example in N1601.pdf, section 5.1.2.4, we see:
>
> "R509 language-binding-spec is BIND(C[,NAME =
> scalar-char-initialization-expr ])"

Well as R509 shows this is valid - and gfortran has a bug.

Note that there is one restriction:
C540 (R509) The scalar-char-initialization-expr shall be of default
character kind.

(I mention this restriction has gfortran is on the way to support
UCS-4 variables/character literals [works largely] and UTF-8 I/O [does
not work yet] - and it currently misses this default-kind check.)


> subroutine ACOS
> import ext
> bind(C,name='cacos' // ext) :: acos
> end subroutine ACOS

This variant is invalid. As "5.2.4 BIND statement" states:

"The BIND statement specifies the BIND attribute (5.1.2.4) for a list
of variables and common blocks."

I would argue that "acos" is not a variable. Even if it were, it is
not allowed:

"C550 (R522) If any bind-entity in a bind-stmt is an entity-name, the
bind-stmt shall appear in the specification part of a module and the
entity shall be an interoperable variable (15.2.4, 15.2.5)."

> procedure(stub), bind(C,name='cacosf') :: my_ACOS ! Compiles
> 1
> Warning: Variable 'my_acos' at (1) may not be a C interoperable kind but it is bind(c)

The warning is wrong. It first appeared in the first week of May and
thus a recent regression.

Tobias

James Van Buskirk

unread,
May 20, 2008, 5:12:02 PM5/20/08
to
"Tobias Burnus" <bur...@net-b.de> wrote in message
news:323723f1-0092-48d1...@l64g2000hse.googlegroups.com...

> > procedure(stub), bind(C,name='cacosf') :: my_ACOS ! Compiles
> > 1
> > Warning: Variable 'my_acos' at (1) may not be a C interoperable kind but
> > it is bind(c)

> The warning is wrong. It first appeared in the first week of May and
> thus a recent regression.

If you want to see what I am trying to achieve here:

C:\gfortran\test\complex>type trigs*.i90

trigs.i90


! procedure(stub), bind(C,name='cacosf') :: my_ACOS ! Compiles


procedure(stub), bind(C,name='cacos'//ext) :: my_ACOS ! Causes error
public ACOS
interface ACOS
procedure my_ACOS
end interface ACOS

! procedure(stub), bind(C,name='cacoshf') :: my_ACOSH ! Compiles
procedure(stub), bind(C,name='cacosh'//ext) :: my_ACOSH ! Causes error
public ACOSH
interface ACOSH
procedure my_ACOSH
end interface ACOSH

! procedure(stub), bind(C,name='casinf') :: my_ASIN ! Compiles
procedure(stub), bind(C,name='casin'//ext) :: my_ASIN ! Causes error
public ASIN
interface ASIN
procedure my_ASIN
end interface ASIN

! procedure(stub), bind(C,name='casinhf') :: my_ASINH ! Compiles
procedure(stub), bind(C,name='casinh'//ext) :: my_ASINH ! Causes error
public ASINH
interface ASINH
procedure my_ASINH
end interface ASINH

! procedure(stub), bind(C,name='catanf') :: my_ATAN ! Compiles
procedure(stub), bind(C,name='catan'//ext) :: my_ATAN ! Causes error
public ATAN
interface ATAN
procedure my_ATAN
end interface ATAN

! procedure(stub), bind(C,name='catanhf') :: my_ATANH ! Compiles
procedure(stub), bind(C,name='catanh'//ext) :: my_ATANH ! Causes error
public ATANH
interface ATANH
procedure my_ATANH
end interface ATANH

! procedure(stub), bind(C,name='ccoshf') :: my_COSH ! Compiles
procedure(stub), bind(C,name='ccosh'//ext) :: my_COSH ! Causes error
public COSH
interface COSH
procedure my_COSH
end interface COSH

! procedure(stub), bind(C,name='csinhf') :: my_SINH ! Compiles
procedure(stub), bind(C,name='csinh'//ext) :: my_SINH ! Causes error
public SINH
interface SINH
procedure my_SINH
end interface SINH

! procedure(stub), bind(C,name='ctanf') :: my_TAN ! Compiles
procedure(stub), bind(C,name='ctan'//ext) :: my_TAN ! Causes error
public TAN
interface TAN
procedure my_TAN
end interface TAN

! procedure(stub), bind(C,name='ctanhf') :: my_TANH ! Compiles
procedure(stub), bind(C,name='cTANH'//ext) :: my_TANH ! Causes error
public TANH
interface TANH
procedure my_TANH
end interface TANH

trigs10.i90


procedure(stub), bind(C,name='cacosl') :: my_ACOS ! Compiles


! procedure(stub), bind(C,name='cacos'//ext) :: my_ACOS ! Causes error
public ACOS
interface ACOS
procedure my_ACOS
end interface ACOS

procedure(stub), bind(C,name='cacoshl') :: my_ACOSH ! Compiles
! procedure(stub), bind(C,name='cacosh'//ext) :: my_ACOSH ! Causes error
public ACOSH
interface ACOSH
procedure my_ACOSH
end interface ACOSH

procedure(stub), bind(C,name='casinl') :: my_ASIN ! Compiles
! procedure(stub), bind(C,name='casin'//ext) :: my_ASIN ! Causes error
public ASIN
interface ASIN
procedure my_ASIN
end interface ASIN

procedure(stub), bind(C,name='casinhl') :: my_ASINH ! Compiles
! procedure(stub), bind(C,name='casinh'//ext) :: my_ASINH ! Causes error
public ASINH
interface ASINH
procedure my_ASINH
end interface ASINH

procedure(stub), bind(C,name='catanl') :: my_ATAN ! Compiles
! procedure(stub), bind(C,name='catan'//ext) :: my_ATAN ! Causes error
public ATAN
interface ATAN
procedure my_ATAN
end interface ATAN

procedure(stub), bind(C,name='catanhl') :: my_ATANH ! Compiles
! procedure(stub), bind(C,name='catanh'//ext) :: my_ATANH ! Causes error
public ATANH
interface ATANH
procedure my_ATANH
end interface ATANH

procedure(stub), bind(C,name='ccoshl') :: my_COSH ! Compiles
! procedure(stub), bind(C,name='ccosh'//ext) :: my_COSH ! Causes error
public COSH
interface COSH
procedure my_COSH
end interface COSH

procedure(stub), bind(C,name='csinhl') :: my_SINH ! Compiles
! procedure(stub), bind(C,name='csinh'//ext) :: my_SINH ! Causes error
public SINH
interface SINH
procedure my_SINH
end interface SINH

procedure(stub), bind(C,name='ctanl') :: my_TAN ! Compiles
! procedure(stub), bind(C,name='ctan'//ext) :: my_TAN ! Causes error
public TAN
interface TAN
procedure my_TAN
end interface TAN

procedure(stub), bind(C,name='ctanhl') :: my_TANH ! Compiles
! procedure(stub), bind(C,name='cTANH'//ext) :: my_TANH ! Causes error
public TANH
interface TANH
procedure my_TANH
end interface TANH

trigs4.i90


procedure(stub), bind(C,name='cacosf') :: my_ACOS ! Compiles

! procedure(stub), bind(C,name='cacos'//ext) :: my_ACOS ! Causes error
public ACOS
interface ACOS
procedure my_ACOS
end interface ACOS

procedure(stub), bind(C,name='cacoshf') :: my_ACOSH ! Compiles
! procedure(stub), bind(C,name='cacosh'//ext) :: my_ACOSH ! Causes error
public ACOSH
interface ACOSH
procedure my_ACOSH
end interface ACOSH

procedure(stub), bind(C,name='casinf') :: my_ASIN ! Compiles
! procedure(stub), bind(C,name='casin'//ext) :: my_ASIN ! Causes error
public ASIN
interface ASIN
procedure my_ASIN
end interface ASIN

procedure(stub), bind(C,name='casinhf') :: my_ASINH ! Compiles
! procedure(stub), bind(C,name='casinh'//ext) :: my_ASINH ! Causes error
public ASINH
interface ASINH
procedure my_ASINH
end interface ASINH

procedure(stub), bind(C,name='catanf') :: my_ATAN ! Compiles
! procedure(stub), bind(C,name='catan'//ext) :: my_ATAN ! Causes error
public ATAN
interface ATAN
procedure my_ATAN
end interface ATAN

procedure(stub), bind(C,name='catanhf') :: my_ATANH ! Compiles
! procedure(stub), bind(C,name='catanh'//ext) :: my_ATANH ! Causes error
public ATANH
interface ATANH
procedure my_ATANH
end interface ATANH

procedure(stub), bind(C,name='ccoshf') :: my_COSH ! Compiles
! procedure(stub), bind(C,name='ccosh'//ext) :: my_COSH ! Causes error
public COSH
interface COSH
procedure my_COSH
end interface COSH

procedure(stub), bind(C,name='csinhf') :: my_SINH ! Compiles
! procedure(stub), bind(C,name='csinh'//ext) :: my_SINH ! Causes error
public SINH
interface SINH
procedure my_SINH
end interface SINH

procedure(stub), bind(C,name='ctanf') :: my_TAN ! Compiles
! procedure(stub), bind(C,name='ctan'//ext) :: my_TAN ! Causes error
public TAN
interface TAN
procedure my_TAN
end interface TAN

procedure(stub), bind(C,name='ctanhf') :: my_TANH ! Compiles
! procedure(stub), bind(C,name='cTANH'//ext) :: my_TANH ! Causes error
public TANH
interface TANH
procedure my_TANH
end interface TANH

trigs8.i90


procedure(stub), bind(C,name='cacos') :: my_ACOS ! Compiles


! procedure(stub), bind(C,name='cacos'//ext) :: my_ACOS ! Causes error
public ACOS
interface ACOS
procedure my_ACOS
end interface ACOS

procedure(stub), bind(C,name='cacosh') :: my_ACOSH ! Compiles
! procedure(stub), bind(C,name='cacosh'//ext) :: my_ACOSH ! Causes error
public ACOSH
interface ACOSH
procedure my_ACOSH
end interface ACOSH

procedure(stub), bind(C,name='casin') :: my_ASIN ! Compiles
! procedure(stub), bind(C,name='casin'//ext) :: my_ASIN ! Causes error
public ASIN
interface ASIN
procedure my_ASIN
end interface ASIN

procedure(stub), bind(C,name='casinh') :: my_ASINH ! Compiles
! procedure(stub), bind(C,name='casinh'//ext) :: my_ASINH ! Causes error
public ASINH
interface ASINH
procedure my_ASINH
end interface ASINH

procedure(stub), bind(C,name='catan') :: my_ATAN ! Compiles
! procedure(stub), bind(C,name='catan'//ext) :: my_ATAN ! Causes error
public ATAN
interface ATAN
procedure my_ATAN
end interface ATAN

procedure(stub), bind(C,name='catanh') :: my_ATANH ! Compiles
! procedure(stub), bind(C,name='catanh'//ext) :: my_ATANH ! Causes error
public ATANH
interface ATANH
procedure my_ATANH
end interface ATANH

procedure(stub), bind(C,name='ccosh') :: my_COSH ! Compiles
! procedure(stub), bind(C,name='ccosh'//ext) :: my_COSH ! Causes error
public COSH
interface COSH
procedure my_COSH
end interface COSH

procedure(stub), bind(C,name='csinh') :: my_SINH ! Compiles
! procedure(stub), bind(C,name='csinh'//ext) :: my_SINH ! Causes error
public SINH
interface SINH
procedure my_SINH
end interface SINH

procedure(stub), bind(C,name='ctan') :: my_TAN ! Compiles
! procedure(stub), bind(C,name='ctan'//ext) :: my_TAN ! Causes error
public TAN
interface TAN
procedure my_TAN
end interface TAN

procedure(stub), bind(C,name='ctanh') :: my_TANH ! Compiles
! procedure(stub), bind(C,name='cTANH'//ext) :: my_TANH ! Causes error
public TANH
interface TANH
procedure my_TANH
end interface TANH

C:\gfortran\test\complex>type test.i90
subroutine test(Z)
complex(ckind) Z(:)
integer i

write(*,*) 'Test of '//label//' function'
do i = 1, size(Z)
write(*,*) 'Point:', Z(i)
write(*,*) label, ifun(Z(i))
write(*,*) 'Back:', fun(ifun(Z(i)))
end do
end subroutine test

C:\gfortran\test\complex>type complex2.f90


module trig_sp
use ISO_C_BINDING
implicit none
private
character(*), parameter :: ext = 'f'

integer, parameter :: ckind = C_FLOAT_COMPLEX
abstract interface
function stub(z) bind(C)

import ckind
complex(ckind), value :: z


complex(ckind) stub
end function stub
end interface

!include 'trigs.i90' ! generic form
include 'trigs4.i90' ! form that compiles
end module trig_sp

module trig_dp


use ISO_C_BINDING
implicit none
private

character(*), parameter :: ext = ''
integer, parameter :: ckind = C_DOUBLE_COMPLEX


abstract interface
function stub(z) bind(C)

import ckind
complex(ckind), value :: z


complex(ckind) stub
end function stub
end interface

!include 'trigs.i90' ! generic form
include 'trigs8.i90' ! form that compiles
end module trig_dp

module trig_qp


use ISO_C_BINDING
implicit none
private

character(*), parameter :: ext = 'l'
integer, parameter :: ckind = C_LONG_DOUBLE_COMPLEX


abstract interface
function stub(z) bind(C)

import ckind
complex(ckind), value :: z


complex(ckind) stub
end function stub
end interface

!include 'trigs.i90' ! generic form
include 'trigs10.i90' ! form that compiles
end module trig_qp

module trigs
use trig_sp
use trig_dp
use trig_qp
intrinsic COS
intrinsic SIN
end module trigs

module mod_acos_sp
use trigs, only: fun => COS, ifun => ACOS
use ISO_C_BINDING, only: ckind => C_FLOAT_COMPLEX
character(*), parameter :: label = 'ACOS'
private
public test_acos
interface test_acos
module procedure test
end interface test_acos
contains
include 'test.i90'
end module mod_acos_sp

module mod_acos_dp
use trigs, only: fun => COS, ifun => ACOS
use ISO_C_BINDING, only: ckind => C_DOUBLE_COMPLEX
character(*), parameter :: label = 'ACOS'
private
public test_acos
interface test_acos
module procedure test
end interface test_acos
contains
include 'test.i90'
end module mod_acos_dp

module mod_acos_qp
use trigs, only: fun => COS, ifun => ACOS
use ISO_C_BINDING, only: ckind => C_LONG_DOUBLE_COMPLEX
character(*), parameter :: label = 'ACOS'
private
public test_acos
interface test_acos
module procedure test
end interface test_acos
contains
include 'test.i90'
end module mod_acos_qp

module mod_acosh_sp
use trigs, only: fun => COSH, ifun => ACOSH
use ISO_C_BINDING, only: ckind => C_FLOAT_COMPLEX
character(*), parameter :: label = 'ACOSH'
private
public test_acosh
interface test_acosh
module procedure test
end interface test_acosh
contains
include 'test.i90'
end module mod_acosh_sp

module mod_acosh_dp
use trigs, only: fun => COSH, ifun => ACOSH
use ISO_C_BINDING, only: ckind => C_DOUBLE_COMPLEX
character(*), parameter :: label = 'ACOSH'
private
public test_acosh
interface test_acosh
module procedure test
end interface test_acosh
contains
include 'test.i90'
end module mod_acosh_dp

module mod_acosh_qp
use trigs, only: fun => COSH, ifun => ACOSH
use ISO_C_BINDING, only: ckind => C_LONG_DOUBLE_COMPLEX
character(*), parameter :: label = 'ACOSH'
private
public test_acosh
interface test_acosh
module procedure test
end interface test_acosh
contains
include 'test.i90'
end module mod_acosh_qp

module mod_asin_sp
use trigs, only: fun => SIN, ifun => ASIN
use ISO_C_BINDING, only: ckind => C_FLOAT_COMPLEX
character(*), parameter :: label = 'ASIN'
private
public test_asin
interface test_asin
module procedure test
end interface test_asin
contains
include 'test.i90'
end module mod_asin_sp

module mod_asin_dp
use trigs, only: fun => SIN, ifun => ASIN
use ISO_C_BINDING, only: ckind => C_DOUBLE_COMPLEX
character(*), parameter :: label = 'ASIN'
private
public test_asin
interface test_asin
module procedure test
end interface test_asin
contains
include 'test.i90'
end module mod_asin_dp

module mod_asin_qp
use trigs, only: fun => SIN, ifun => ASIN
use ISO_C_BINDING, only: ckind => C_LONG_DOUBLE_COMPLEX
character(*), parameter :: label = 'ASIN'
private
public test_asin
interface test_asin
module procedure test
end interface test_asin
contains
include 'test.i90'
end module mod_asin_qp

module mod_asinh_sp
use trigs, only: fun => SINH, ifun => ASINH
use ISO_C_BINDING, only: ckind => C_FLOAT_COMPLEX
character(*), parameter :: label = 'ASINH'
private
public test_asinh
interface test_asinh
module procedure test
end interface test_asinh
contains
include 'test.i90'
end module mod_asinh_sp

module mod_asinh_dp
use trigs, only: fun => SINH, ifun => ASINH
use ISO_C_BINDING, only: ckind => C_DOUBLE_COMPLEX
character(*), parameter :: label = 'ASINH'
private
public test_asinh
interface test_asinh
module procedure test
end interface test_asinh
contains
include 'test.i90'
end module mod_asinh_dp

module mod_asinh_qp
use trigs, only: fun => SINH, ifun => ASINH
use ISO_C_BINDING, only: ckind => C_LONG_DOUBLE_COMPLEX
character(*), parameter :: label = 'ASINH'
private
public test_asinh
interface test_asinh
module procedure test
end interface test_asinh
contains
include 'test.i90'
end module mod_asinh_qp

module mod_atan_sp
use trigs, only: fun => TAN, ifun => ATAN
use ISO_C_BINDING, only: ckind => C_FLOAT_COMPLEX
character(*), parameter :: label = 'ATAN'
private
public test_atan
interface test_atan
module procedure test
end interface test_atan
contains
include 'test.i90'
end module mod_atan_sp

module mod_atan_dp
use trigs, only: fun => TAN, ifun => ATAN
use ISO_C_BINDING, only: ckind => C_DOUBLE_COMPLEX
character(*), parameter :: label = 'ATAN'
private
public test_atan
interface test_atan
module procedure test
end interface test_atan
contains
include 'test.i90'
end module mod_atan_dp

module mod_atan_qp
use trigs, only: fun => TAN, ifun => ATAN
use ISO_C_BINDING, only: ckind => C_LONG_DOUBLE_COMPLEX
character(*), parameter :: label = 'ATAN'
private
public test_atan
interface test_atan
module procedure test
end interface test_atan
contains
include 'test.i90'
end module mod_atan_qp

module mod_atanh_sp
use trigs, only: fun => TANH, ifun => ATANH
use ISO_C_BINDING, only: ckind => C_FLOAT_COMPLEX
character(*), parameter :: label = 'ATANH'
private
public test_atanh
interface test_atanh
module procedure test
end interface test_atanh
contains
include 'test.i90'
end module mod_atanh_sp

module mod_atanh_dp
use trigs, only: fun => TANH, ifun => ATANH
use ISO_C_BINDING, only: ckind => C_DOUBLE_COMPLEX
character(*), parameter :: label = 'ATANH'
private
public test_atanh
interface test_atanh
module procedure test
end interface test_atanh
contains
include 'test.i90'
end module mod_atanh_dp

module mod_atanh_qp
use trigs, only: fun => TANH, ifun => ATANH
use ISO_C_BINDING, only: ckind => C_LONG_DOUBLE_COMPLEX
character(*), parameter :: label = 'ATANH'
private
public test_atanh
interface test_atanh
module procedure test
end interface test_atanh
contains
include 'test.i90'
end module mod_atanh_qp

module mod_test
use mod_acos_sp
use mod_acos_dp
use mod_acos_qp
use mod_acosh_sp
use mod_acosh_dp
use mod_acosh_qp
use mod_asin_sp
use mod_asin_dp
use mod_asin_qp
use mod_asinh_sp
use mod_asinh_dp
use mod_asinh_qp
use mod_atan_sp
use mod_atan_dp
use mod_atan_qp
use mod_atanh_sp
use mod_atanh_dp
use mod_atanh_qp
end module mod_test

program complex2
use ISO_C_BINDING
use mod_test
implicit none
complex(C_FLOAT_COMPLEX) Zr4(6)
complex(C_FLOAT_COMPLEX) Zi4(6)
complex(C_DOUBLE_COMPLEX) Zr8(6)
complex(C_DOUBLE_COMPLEX) Zi8(6)
complex(C_LONG_DOUBLE_COMPLEX) Zr10(6)
complex(C_LONG_DOUBLE_COMPLEX) Zi10(6)
real(C_FLOAT) x4(0:2)
real(C_FLOAT) y4(0:1)
real(C_DOUBLE) x8(0:2)
real(C_DOUBLE) y8(0:1)
real(C_LONG_DOUBLE) x10(0:2)
real(C_LONG_DOUBLE) y10(0:1)
integer i

x4 = [(i,i=-1,1)]*2.5_C_FLOAT
y4 = [(i,i=-1,1,2)]*0.1_C_FLOAT
x8 = [(i,i=-1,1)]*2.5_C_DOUBLE
y8 = [(i,i=-1,1,2)]*0.1_C_DOUBLE
x10 = [(i,i=-1,1)]*2.5_C_LONG_DOUBLE
y10 = [(i,i=-1,1,2)]*0.1_C_LONG_DOUBLE
Zr4 = [(cmplx(x4(mod(i,3)),y4(mod(i,2)),C_FLOAT),i=0,5)]
Zi4 = [(cmplx(y4(mod(i,2)),x4(mod(i,3)),C_FLOAT),i=0,5)]
Zr8 = [(cmplx(x8(mod(i,3)),y8(mod(i,2)),C_DOUBLE),i=0,5)]
Zi8 = [(cmplx(y8(mod(i,2)),x8(mod(i,3)),C_DOUBLE),i=0,5)]
Zr10 = [(cmplx(x10(mod(i,3)),y10(mod(i,2)),C_LONG_DOUBLE),i=0,5)]
Zi10 = [(cmplx(y10(mod(i,2)),x10(mod(i,3)),C_LONG_DOUBLE),i=0,5)]
call test_acos(Zr4)
call test_acos(Zr8)
call test_acos(Zr10)
call test_acosh(Zr4)
call test_acosh(Zr8)
call test_acosh(Zr10)
call test_asin(Zr4)
call test_asin(Zr8)
call test_asin(Zr10)
call test_asinh(Zi4)
call test_asinh(Zi8)
call test_asinh(Zi10)
call test_atan(Zi4)
call test_atan(Zi8)
call test_atan(Zi10)
call test_atanh(Zr4)
call test_atanh(Zr8)
call test_atanh(Zr10)
end program complex2

If the initialization expression syntax rather than the character
literal syntax were permitted I could eliminate trigs4.i90,
trigs8.i90, and trigs10.i90 and instead include trigs.i90 in each of
modules trig_sp, trig_dp, and trig_qp, thus getting rid of a lot of
code duplication. With the extraneous duplication the code compiles
so that module trigs provides the complex ACOS, ACOSH, ASIN, ASINH,
ATAN, ATANH, TAN, and TANH functions from section 13.7 of N1723.pdf.
ACOSH even has the Fortran branch cut, unlike Milton & Irene or
Wolfram. A further problem arises in that the C_LONG_DOUBLE_COMPLEX
versions of the new functions causes some sort of exception at
runtime as happens with the C_LONG_DOUBLE_COMPLEX versions of ABS,
LOG, and SQRT and the C_LONG_DOUBLE versions of HYPOT, RRSPACING,
and SPACING. Is this platform specific to Win64?

Tim Prince

unread,
May 20, 2008, 7:07:36 PM5/20/08
to

James Van Buskirk wrote:
...

> A further problem arises in that the C_LONG_DOUBLE_COMPLEX
> versions of the new functions causes some sort of exception at
> runtime as happens with the C_LONG_DOUBLE_COMPLEX versions of ABS,
> LOG, and SQRT and the C_LONG_DOUBLE versions of HYPOT, RRSPACING,
> and SPACING. Is this platform specific to Win64?
>
Specific to targets such as mingw (32 and 64-bit), which use Microsoft
libraries, where long double is supported only as an alias for double.

FX

unread,
May 20, 2008, 7:40:37 PM5/20/08
to
> Specific to targets such as mingw (32 and 64-bit), which use Microsoft
> libraries, where long double is supported only as an alias for double.

No, Tim. As I wrote here previously, mingw doesn't use the MS libraries
for C99 functions, including long double. mingw provides true long double
functions.

To answer James' original question: yes, it's an issue specific to Win64.
Please send me by mail a short testcase for these, and I'll track it down
and hand it to the mingw-win64 developers.

--
FX

James Van Buskirk

unread,
May 23, 2008, 4:14:47 AM5/23/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g0vnhl$1abe$1...@nef.ens.fr...

> To answer James' original question: yes, it's an issue specific to Win64.
> Please send me by mail a short testcase for these, and I'll track it down
> and hand it to the mingw-win64 developers.

I sent you several short testcases. Did you receive them?
Everything that dies like this seems to call _scalbnl. I found
_scalblnl in libmingwex.a, and it wanted its integer argument to
be passed by reference, but invocations of _scalbnl pass by value.
Is this the problem or are they completely different functions?
You know, Windows Fortran users such as myself have absolutely no
chance of debugging a C/Unix oriented compiler system like
gcc/gfortran.

FX

unread,
May 23, 2008, 5:40:18 AM5/23/08
to
> I sent you several short testcases. Did you receive them?

Yes I did, thanks.

> Everything that dies like this seems to call _scalbnl.

Apparently, this was fixed some time ago. What is your version of
gfortran? And does the website you download gfortran from indicate what
version (indicated by revision number) of the mingw-w64 library is used?
The mingw-w64 developers couldn't reproduce the bug with the latest
combination of gcc and mingw-w64.

--
FX

James Van Buskirk

unread,
May 23, 2008, 6:50:42 AM5/23/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g163e2$2g2n$1...@nef.ens.fr...

> Yes I did, thanks.

I don't know where you inquire about the revision number. All I've
got is

C:\gfortran\test>gfortran -v
Built by Equation Solution (http://www.Equation.com).
Using built-in specs.
Target: x86_64-pc-mingw32
Configured with:
../gcc-4.4-20080516-mingw/configure --host=x86_64-pc-mingw32 --
build=x86_64-unknown-linux-gnu --target=x86_64-pc-mingw32 --prefix=/home/gfortra
n/gcc-home/binary/mingw32/native/x86_64/gcc/4.4-20080516 --with-gmp=/home/gfortr
an/gcc-home/binary/mingw32/native/x86_64/gmp --with-mpfr=/home/gfortran/gcc-home
/binary/mingw32/native/x86_64/mpfr --with-sysroot=/home/gfortran/gcc-home/binary
/mingw32/cross/x86_64/gcc/4.4-20080516 --with-gcc --with-gnu-ld --with-gnu-as
--
disable-shared --disable-nls --disable-tls --enable-languages=c,fortran --enable
-threads=win32 --enable-libgomp --disable-win32-registry
Thread model: win32
gcc version 4.4.0 20080516 (experimental) (GCC)

FX

unread,
May 23, 2008, 8:57:48 AM5/23/08
to
> I don't know where you inquire about the revision number.

There's no easy way to inquire about the revision number, unless it's
stated in the documentation.

--
FX

James Van Buskirk

unread,
May 23, 2008, 11:18:48 PM5/23/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g16f0c$230v$1...@nef.ens.fr...

> There's no easy way to inquire about the revision number, unless it's
> stated in the documentation.

Well, I tried downloading soemthing called
mingw-w64-bin_x86_64-mingw_20080507.zip but it just hung up on
hello.f90:

C:\hp downloads>gfortran hello.f90 -ohello
^C
C:\hp downloads>gfortran -v


Using built-in specs.
Target: x86_64-pc-mingw32
Configured with:

../build/gcc-svn/gcc/configure --target=x86_64-pc-mingw32 --pre
fix=/var/tmp/w64 --with-sysroot=/var/tmp/w64 --host=x86_64-pc-mingw32
Thread model: win32
gcc version 4.4.0 20080507 (experimental) (GCC)

C:\hp downloads>type hello.f90
print*, 'Hello, world!';end

There were some programs generated by bug_collection.f90 whose
failures have nothing to do with mingw. I know zilch about
cutely named UNIX shell scripts like C shell or bash else I
would have it generate one of those as well as collection.bat
so you could tell at a glance which fail on your preferred OS.

It would have been easy for the mingw 64 crew to discover the
unfixed failures as well. Obviously it is not possible for me to
do so because a compiler with said fixes is not available at any
location I can think of.

FX

unread,
May 24, 2008, 3:39:15 AM5/24/08
to
> It would have been easy for the mingw 64 crew to discover the unfixed
> failures as well.

They have a different problem than you: they know nada about Fortran :)

--
FX

James Van Buskirk

unread,
May 24, 2008, 6:34:12 AM5/24/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g18gn2$a1j$1...@nef.ens.fr...

>> It would have been easy for the mingw 64 crew to discover the unfixed
>> failures as well.

> They have a different problem than you: they know nada about Fortran :)

So which of us are the leading blind, and which the following?

I tried playing around with mingw-w64-bin_x86_64-mingw_20080507.zip
some more. I found that compiling with gcc-4.4-20080516-64.exe
from www.equation.com followed by linking with the aforementioned
gfortran worked sometimes. Unfortunately the trick of linking in
a subroutine that set the f.p. control word to its default value
didn't work: it resulted in a Christo of error messages, so I
couldn't assess the results to full accuracy. You have got to
persuade the mingw 64 guys to set up the f.p. control word
correctly: it's too much of an inconvenience to have to do it
myself and in this jury-rigged setup it fails miserably.

The functions which caused an exception at runtime no longer do so
and many of them even yield the correct results now! Since you now
have working ACOS, ACOSH, ASIN, ASINH, ATAN, ATANH, COSH, SINH, TAN,
and TANH functions for complex arguments I don't see why you don't
enable them for ordinary and specification expressions because it
would require almost no effort to implement them and doing so would
make it possible for the user to invoke them elementally, which is
nonstandard for functions made available via a bind(C) interface
as I have been doing. For initialization expressions it would
perhaps take a little more effort because I'm not sure whether mpfr
supports inverse trigonometric and hyperbolic functions for complex
arguments, but as a first step you could simply error out in this case
as happens for ERFC_SCALED for example.

ABS, LOG, and SQRT for complex arguments also now worked, as did
HYPOT and SCALE for real arguments, but RRSPACING now yields
infinity, SPACING and SET_EXPONENT yield garbage and all the other
functions have the same issues they had in my previous email:

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c bug_collection.f90

C:\gcc_mingw64>gfortran bug_collection.o -obug_collection

C:\gcc_mingw64>bug_collection

C:\gcc_mingw64>collection

C:\gcc_mingw64>REM These complex(10) functions require special interface and
cra
sh at runtime

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ACOS_c10i.f90

C:\gcc_mingw64>gfortran ACOS_c10i.o -o ACOS_c10i

C:\gcc_mingw64>ACOS_c10i
Invoking ACOS...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
4.3608017971689
1516706E-0002, -1.5678369121838189051 )
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ACOSH_c10i.f90

C:\gcc_mingw64>gfortran ACOSH_c10i.o -o ACOSH_c10i

C:\gcc_mingw64>ACOSH_c10i
Invoking ACOSH...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.567836912183
8189051 , 4.36080179716891516706E-0002)
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ASIN_c10i.f90

C:\gcc_mingw64>gfortran ASIN_c10i.o -o ASIN_c10i

C:\gcc_mingw64>ASIN_c10i
Invoking ASIN...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.527188308823
2074692 , 1.5678369121838189051 )
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ASINH_c10i.f90

C:\gcc_mingw64>gfortran ASINH_c10i.o -o ASINH_c10i

C:\gcc_mingw64>ASINH_c10i
Invoking ASINH...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.647871185889
3411159 , 3.71255311654403500410E-0002)
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ATAN_c10i.f90

C:\gcc_mingw64>gfortran ATAN_c10i.o -o ATAN_c10i

C:\gcc_mingw64>ATAN_c10i
Invoking ATAN...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.190765099225
7940992 , 1.37775908824697649463E-0002)
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ATANH_c10i.f90

C:\gcc_mingw64>gfortran ATANH_c10i.o -o ATANH_c10i

C:\gcc_mingw64>ATANH_c10i
Invoking ATANH...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
0.4227442792790
7776148 , 1.5517940735445572287 )
...survived!

C:\gcc_mingw64>REM These complex(10) functions crash at runtime

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ABS_c10.f90

C:\gcc_mingw64>gfortran ABS_c10.o -o ABS_c10

C:\gcc_mingw64>ABS_c10
Invoking ABS...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
2.501999200698
9180133 , 0.0000000000000000000 )
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c LOG_c10.f90

C:\gcc_mingw64>gfortran LOG_c10.o -o LOG_c10

C:\gcc_mingw64>LOG_c10
Invoking LOG...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
0.9170900925798
0746252 , 3.99786877183843382784E-0002)
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c SQRT_c10.f90

C:\gcc_mingw64>gfortran SQRT_c10.o -o SQRT_c10

C:\gcc_mingw64>SQRT_c10
Invoking SQRT...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.581454899878
4185851 , 3.16164569403161802019E-0002)
...survived!

C:\gcc_mingw64>REM These real(10) functions crash at runtime

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c RRSPACING_r10.f90

C:\gcc_mingw64>gfortran RRSPACING_r10.o -o RRSPACING_r10

C:\gcc_mingw64>RRSPACING_r10
Invoking RRSPACING...
2.5000000000000000000 +Infinity
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c SPACING_r10.f90

C:\gcc_mingw64>gfortran SPACING_r10.o -o SPACING_r10

C:\gcc_mingw64>SPACING_r10
Invoking SPACING...
2.5000000000000000000 3.36210314311209350626E-4932
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c HYPOT_r10.f90

C:\gcc_mingw64>gfortran HYPOT_r10.o -o HYPOT_r10

C:\gcc_mingw64>HYPOT_r10
Invoking HYPOT...
2.5000000000000000000 0.10000000149011611938
2.501999200698918
0133
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c SCALE_r10.f90

C:\gcc_mingw64>gfortran SCALE_r10.o -o SCALE_r10

C:\gcc_mingw64>SCALE_r10
Invoking SCALE...
2.5000000000000000000 20 2621440.0000000000000
...survived!

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c SET_EXPONENT_r10.f90

C:\gcc_mingw64>gfortran SET_EXPONENT_r10.o -o SET_EXPONENT_r10

C:\gcc_mingw64>SET_EXPONENT_r10
Invoking SET_EXPONENT...
2.5000000000000000000 20 2621440.0000000000000
...survived!

C:\gcc_mingw64>REM These real(10) functions fail to link

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c BESSEL_J0_r10.f90

C:\gcc_mingw64>gfortran BESSEL_J0_r10.o -o BESSEL_J0_r10
BESSEL_J0_r10.o:BESSEL_J0_r10.f90:(.text+0x60): undefined reference to
`_j0l'
collect2: ld returned 1 exit status

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c BESSEL_J1_r10.f90

C:\gcc_mingw64>gfortran BESSEL_J1_r10.o -o BESSEL_J1_r10
BESSEL_J1_r10.o:BESSEL_J1_r10.f90:(.text+0x60): undefined reference to
`_j1l'
collect2: ld returned 1 exit status

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c BESSEL_Y0_r10.f90

C:\gcc_mingw64>gfortran BESSEL_Y0_r10.o -o BESSEL_Y0_r10
BESSEL_Y0_r10.o:BESSEL_Y0_r10.f90:(.text+0x60): undefined reference to
`_y0l'
collect2: ld returned 1 exit status

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c BESSEL_Y1_r10.f90

C:\gcc_mingw64>gfortran BESSEL_Y1_r10.o -o BESSEL_Y1_r10
BESSEL_Y1_r10.o:BESSEL_Y1_r10.f90:(.text+0x60): undefined reference to
`_y1l'
collect2: ld returned 1 exit status

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c BESSEL_JN_r10.f90

C:\gcc_mingw64>gfortran BESSEL_JN_r10.o -o BESSEL_JN_r10
BESSEL_JN_r10.o:BESSEL_JN_r10.f90:(.text+0x7f): undefined reference to
`_jnl'
collect2: ld returned 1 exit status

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c BESSEL_YN_r10.f90

C:\gcc_mingw64>gfortran BESSEL_YN_r10.o -o BESSEL_YN_r10
BESSEL_YN_r10.o:BESSEL_YN_r10.f90:(.text+0x7f): undefined reference to
`_ynl'
collect2: ld returned 1 exit status

C:\gcc_mingw64>REM These real(10) functions yield NaN

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ERF_r10.f90

C:\gcc_mingw64>gfortran ERF_r10.o -o ERF_r10

C:\gcc_mingw64>ERF_r10
ERF NaN

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ERFC_r10.f90

C:\gcc_mingw64>gfortran ERFC_r10.o -o ERFC_r10

C:\gcc_mingw64>ERFC_r10
ERFC NaN

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c GAMMA_r10.f90

C:\gcc_mingw64>gfortran GAMMA_r10.o -o GAMMA_r10

C:\gcc_mingw64>GAMMA_r10
GAMMA NaN

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c LOG_GAMMA_r10.f90

C:\gcc_mingw64>gfortran LOG_GAMMA_r10.o -o LOG_GAMMA_r10

C:\gcc_mingw64>LOG_GAMMA_r10
LOG_GAMMA NaN

C:\gcc_mingw64>REM These real(10) functions yield garbage

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c EXPONENT_r10.f90

C:\gcc_mingw64>gfortran EXPONENT_r10.o -o EXPONENT_r10

C:\gcc_mingw64>EXPONENT_r10
x 2.5000000000000000000
EXPONENT -16381

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c FRACTION_r10.f90

C:\gcc_mingw64>gfortran FRACTION_r10.o -o FRACTION_r10

C:\gcc_mingw64>FRACTION_r10
x 2.5000000000000000000
FRACTION 2.5000000000000000000

C:\gcc_mingw64>REM These real(4) functions are not available for
initialization
expressions

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c ERFC_SCALED_r4.f90
ERFC_SCALED_r4.f90:4.18:

real(int(4+0*y)), parameter :: z = 42.0
1
Error: Constant expression required at (1)

C:\gcc_mingw64>c:\gcc_equation\bin\gfortran -c SIZEOF_r4.f90
SIZEOF_r4.f90:3.28:

real(4), parameter :: y = SIZEOF(x)
1
Error: Intrinsic function 'sizeof' at (1) is not permitted in an
initialization
expression
SIZEOF_r4.f90:4.17:

real(int(4+0*y)), parameter :: z = 42.0
1
Error: Parameter 'y' at (1) has not been declared or is a variable, which
does n
ot reduce to a constant expression

How does nightstrike manage to regression test gfortran if the image
available on the mingw 64 page just hangs as it does for me? Has
anyone else used this snapshot successfully to compile anything
with gfortran?

Another test:

C:\gcc_mingw64>type hello.c
#include <stdio.h>

main()
{
printf("Hello, world!\n");
return 0;
}

C:\gcc_mingw64>gcc hello.c -ohello

C:\gcc_mingw64>hello
Hello, world!

So that snapshot can compile C programs, the problem is only with
Fortran! Maybe nightstrike has something on his machine in his path
that gfortran needs but is not included in this snapshot. Do you
have any ideas how I can make progress in getting this to work?

James Van Buskirk

unread,
May 24, 2008, 10:26:01 AM5/24/08
to
"James Van Buskirk" <not_...@comcast.net> wrote in message
news:-cydneOjpJ6_cqrV...@comcast.com...

> I tried playing around with mingw-w64-bin_x86_64-mingw_20080507.zip
> some more. I found that compiling with gcc-4.4-20080516-64.exe
> from www.equation.com followed by linking with the aforementioned
> gfortran worked sometimes.

Tried a couple more builds: mingw-w64-bin_i686-mingw_20080521.zip
couldn't even compile C:

C:\gcc_mingw64a>type hello.f90
print*, 'Hello, world!";end

C:\gcc_mingw64a>gfortran hello.f90 -ohello
gfortran: CreateProcess: No such file or directory

C:\gcc_mingw64a>type hello.c
#include <stdio.h>
int main()


{
printf("Hello, world!\n");
return 0;
}

C:\gcc_mingw64a>gcc hello.c -ohello
gcc: CreateProcess: No such file or directory

and gcc-4.4-20080523-64.exe still gets killed at runtime by the
COMPLEX(10) and REAL(10) functions, so it isn't picking up the
mingw 64 fixes for some reason.

James Van Buskirk

unread,
May 24, 2008, 12:08:51 PM5/24/08
to
"James Van Buskirk" <not_...@comcast.net> wrote in message
news:fq2dnXJFP53quKXV...@comcast.com...

> and gcc-4.4-20080523-64.exe still gets killed at runtime by the
> COMPLEX(10) and REAL(10) functions, so it isn't picking up the
> mingw 64 fixes for some reason.

So I tried copying the libmingwex.a from the
mingw-w64-bin_i686-mingw_20080521.zip distribution to the
gcc-4.4-20080523-64.exe distribution and compiled with the latter.
This Mary Shelly distribution compiled, even linked with the
assembly subroutine I wrote to reset the f.p. control word and I
got:

C:\gcc_equation\james\bug_collection1>collection

C:\gcc_equation\james\bug_collection1>REM These complex(10) functions
require sp
ecial interface and crash at runtime

C:\gcc_equation\james\bug_collection1>gfortran ACOS_c10i.f90 finit.s -o
ACOS_c10
i

C:\gcc_equation\james\bug_collection1>ACOS_c10i


Invoking ACOS...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
4.3608017971689

1589336E-0002, -1.5678369121838188689 )
...survived!

C:\gcc_equation\james\bug_collection1>gfortran ACOSH_c10i.f90 finit.s -o
ACOSH_c
10i

C:\gcc_equation\james\bug_collection1>ACOSH_c10i


Invoking ACOSH...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.567836912183

8188689 , 4.36080179716891589336E-0002)
...survived!

C:\gcc_equation\james\bug_collection1>gfortran ASIN_c10i.f90 finit.s -o
ASIN_c10
i

C:\gcc_equation\james\bug_collection1>ASIN_c10i


Invoking ASIN...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.527188308823

2074604 , 1.5678369121838188689 )
...survived!

C:\gcc_equation\james\bug_collection1>gfortran ASINH_c10i.f90 finit.s -o
ASINH_c
10i

C:\gcc_equation\james\bug_collection1>ASINH_c10i


Invoking ASINH...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.647871185889

3399170 , 3.71255311654403245977E-0002)
...survived!

C:\gcc_equation\james\bug_collection1>gfortran ATAN_c10i.f90 finit.s -o
ATAN_c10
i

C:\gcc_equation\james\bug_collection1>ATAN_c10i


Invoking ATAN...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.190765099225

7940031 , 1.37775908824698742461E-0002)
...survived!

C:\gcc_equation\james\bug_collection1>gfortran ATANH_c10i.f90 finit.s -o
ATANH_c
10i

C:\gcc_equation\james\bug_collection1>ATANH_c10i


Invoking ATANH...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
0.4227442792790

7768242 , 1.5517940735445572513 )
...survived!

C:\gcc_equation\james\bug_collection1>REM These complex(10) functions crash
at r
untime

C:\gcc_equation\james\bug_collection1>gfortran ABS_c10.f90 finit.s -o
ABS_c10

C:\gcc_equation\james\bug_collection1>ABS_c10


Invoking ABS...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
2.501999200698

9177348 , 0.0000000000000000000 )
...survived!

C:\gcc_equation\james\bug_collection1>gfortran LOG_c10.f90 finit.s -o
LOG_c10

C:\gcc_equation\james\bug_collection1>LOG_c10


Invoking LOG...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
0.9170900925798

0735107 , 3.99786877183843382773E-0002)
...survived!

C:\gcc_equation\james\bug_collection1>gfortran SQRT_c10.f90 finit.s -o
SQRT_c10


C:\gcc_equation\james\bug_collection1>SQRT_c10


Invoking SQRT...
( 2.5000000000000000000 , 0.10000000149011611938 ) (
1.581454899878

4185586 , 3.16164569403161823340E-0002)
...survived!

This compares with calculation by Windows calculator:

z
2.5000000000000000000
0.10000000149011611938

acosh(z)
1.5678369121838188688921270999373
0.043608017971689158861913526192818

acos(z)
0.043608017971689158861913526192818
-1.5678369121838188688921270999373

asin(z)
1.5271883088232074603694081654478
1.5678369121838188688921270999373

asinh(z)
1.6478711858893399169703489867509
0.03712553116544032461189307251869

tan(z)
1.1907650992257940030613043205083
0.013777590882469874236889933165703

atanh(z)
0.4227442792790776824078802387217
1.5517940735445572512633969175547

abs(z)
2.5019992006989177345875970003338

log(z)
0.9170900925798073510818724341794
0.039978687718384338276409165784264

sqrt(z)
1.5814548998784185585308238803575
0.031616456940316182332453349771719

Some progress has therefore been made.

James Van Buskirk

unread,
May 24, 2008, 6:28:03 PM5/24/08
to
"James Van Buskirk" <not_...@comcast.net> wrote in message
news:VYGdnQzh5KASoKXV...@comcast.com...

> So I tried copying the libmingwex.a from the
> mingw-w64-bin_i686-mingw_20080521.zip distribution to the
> gcc-4.4-20080523-64.exe distribution and compiled with the latter.
> This Mary Shelly distribution compiled, even linked with the
> assembly subroutine I wrote to reset the f.p. control word and I
> got:

I found the reason the mingw-w64-bin_i686-mingw_20080521.zip
distribution wasn't working for me: it comes with three versions of
gfortran.exe: one in C:\gcc_mingw64a\bin called
x86_64-pc-mingw32-gfortran.exe, one in C:\gcc_mingw64a\mingw\bin
call gfortran.exe, and one in C:\gcc_mingw64a\x86_64-pc-mingw32\bin
also called gfortran.exe. I had my path set up as

C:\gcc_mingw64a\bin;C:\gcc_mingw64a\mingw\bin;C:\gcc_mingw64a\x86_64-pc-mingw32\bin;%path%

and invoking gfortran.exe in this context cause the
"gfortran: CreateProcess: No such file or directory" problem whereas
invoking x86_64-pc-mingw32-gfortran.exe worked, including the
recent fixes from mingw 64 even if I used the assembly language
subroutine, and the output looked slightly different, perhaps because
there's another library I should have copied over to the
gcc-4.4-20080523-64.exe distribution in my last post. So many
pitfalls!

James Van Buskirk

unread,
May 31, 2008, 2:45:58 AM5/31/08
to
"FX" <cou...@alussinan.org> wrote in message
news:g18gn2$a1j$1...@nef.ens.fr...

>> It would have been easy for the mingw 64 crew to discover the unfixed
>> failures as well.

> They have a different problem than you: they know nada about Fortran :)

Playing around some more with NightStrike's builds: there was a build
entitled mingw-w64-bin_x86-64-mingw_20080528.zip that doesn't work
quite right: if you compile a single file everything is OK:

C:\gcc_mingw64\test>gfortran -v


Using built-in specs.
Target: x86_64-pc-mingw32
Configured with:

../gcc/configure -q --prefix=/var/tmp/w64 --with-sysroot=/var/t
mp/w64 --host=x86_64-pc-mingw32 --target=x86_64-pc-mingw32 --silent
Thread model: win32
gcc version 4.4.0 20080528 (experimental) (GCC)

C:\gcc_mingw64\test>type hello.f90
print*, 'Hello, world';end

C:\gcc_mingw64\test>gfortran hello.f90 -ohello

C:\gcc_mingw64\test>hello
Hello, world

Even if you compile two C source files together it works:

C:\gcc_mingw64\test>gcc -v


Using built-in specs.
Target: x86_64-pc-mingw32
Configured with:

../gcc/configure -q --prefix=/var/tmp/w64 --with-sysroot=/var/t
mp/w64 --host=x86_64-pc-mingw32 --target=x86_64-pc-mingw32 --silent
Thread model: win32
gcc version 4.4.0 20080528 (experimental) (GCC)

C:\gcc_mingw64\test>type hello3.c
void hello4();

int main()
{
hello4();
return 0;
}

C:\gcc_mingw64\test>type hello4.c
#include <stdio.h>

void hello4()
{
printf("Hello, world\n");
return;
}

C:\gcc_mingw64\test>gcc hello3.c hello4.c -ohello3

C:\gcc_mingw64\test>hello3
Hello, world

But if you compile two Fortran source files together...

C:\gcc_mingw64\test>type hello1.f90
program hello1
call hello2
end program hello1

C:\gcc_mingw64\test>type hello2.f90
subroutine hello2
write(*,*) 'Hello, world'
end subroutine hello2

C:\gcc_mingw64\test>gfortran hello1.f90 hello2.f90 -ohello1
c:/gcc_mingw64/bin/../lib/gcc/x86_64-pc-mingw32/4.4.0/../../../../x86_64-pc-ming
w32/lib/crt2.o: In function `__tmainCRTStartup':
/var/tmp/build/mingw/build-x86_64-pc-linux/../mingw-w64-crt/crt64/crtexe.c:175:
undefined reference to `__imp__Sleep'
/var/tmp/build/mingw/build-x86_64-pc-linux/../mingw-w64-crt/crt64/crtexe.c:219:
undefined reference to `__imp__AddVectoredExceptionHandler'
/var/tmp/build/mingw/build-x86_64-pc-linux/../mingw-w64-crt/crt64/crtexe.c:220:
undefined reference to `__imp__SetUnhandledExceptionFilter'
/var/tmp/build/mingw/build-x86_64-pc-linux/../mingw-w64-crt/crt64/crtexe.c:167:
undefined reference to `__imp__GetStartupInfoA'

With several hundred lines of errors to follow. Instead, it works
to add a couple of libraries:

C:\gcc_mingw64\test>gfortran hello1.f90
hello2.f90 -lkernel32 -luser32 -ohello1

C:\gcc_mingw64\test>hello1
Hello, world

The problem doesn't occur for the i686-pc-mingw32 hosted version
of mingw-w64-bin_i686-mingw_20080524.zip :

C:\gcc_mingw64a\test\hello>x86_64-pc-mingw32-gfortran -v


Using built-in specs.
Target: x86_64-pc-mingw32
Configured with:

../gcc/configure --prefix=/var/tmp/rt --with-sysroot=/var/tmp/r
t --host=i686-pc-mingw32 --target=x86_64-pc-mingw32 -q --silent
Thread model: win32
gcc version 4.4.0 20080523 (experimental) (GCC)

C:\gcc_mingw64a\test\hello>x86_64-pc-mingw32-gfortran hello1.f90
hello2.f90 -ohe
llo1

C:\gcc_mingw64a\test\hello>hello1
Hello, world

So is this a problem that can be sorted out from the gfortran end
or is it something only the mingw 64 guys can do anything about?

FX

unread,
Jun 1, 2008, 11:27:02 AM6/1/08
to
> The problem doesn't occur for the i686-pc-mingw32 hosted version of
> mingw-w64-bin_i686-mingw_20080524.zip :

For issues specific to the Win64 GCC builds from Nightstrike, you can
report bugs here:
http://sourceforge.net/tracker/?group_id=202880&atid=983354 (you don't
need to create an account to report a bug)

--
FX

0 new messages