|
|
Up |
|
|
  |
Author: James Van BuskirkJames Van Buskirk Date: May 20, 2008 02:39
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:
|
| Show full article (2.43Kb) |
|
| | 24 Comments |
|
  |
Author: FXFX Date: May 20, 2008 02:59
> "R509 language-binding-spec is BIND(C[,NAME =
> scalar-char-initialization-expr ])"
--
FX
|
| |
|
| | no comments |
|
  |
Author: FXFX Date: May 20, 2008 03:08
> 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:
|
| Show full article (1.46Kb) |
| no comments |
|
  |
Author: James Van BuskirkJames Van Buskirk Date: May 20, 2008 03:10
"FX" 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.
--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
|
| |
| no comments |
|
  |
Author: James Van BuskirkJames Van Buskirk Date: May 20, 2008 03:30
"FX" 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
|
| Show full article (1.96Kb) |
| no comments |
|
  |
Author: FXFX Date: May 20, 2008 03:55
> 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
|
| Show full article (0.93Kb) |
| no comments |
|
  |
Author: James Van BuskirkJames Van Buskirk Date: May 20, 2008 07:01
"FX" 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
|
| Show full article (2.78Kb) |
| no comments |
|
  |
Author: nospamnospam Date: May 20, 2008 08:50
James Van Buskirk 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.
|
| Show full article (1.02Kb) |
| no comments |
|
  |
Author: Steve LionelSteve Lionel Date: May 20, 2008 09:08
On Tue, 20 May 2008 04:10:39 -0600, "James Van Buskirk"
comcast.net> wrote:
>Do Intel & Sun accept the version I really care about, with 'cacos'//ext ?
|
| |
| no comments |
|
  |
|
|
  |
Author: Tobias BurnusTobias Burnus Date: May 20, 2008 09:45
Hi all,
On May 20, 11:39 am, "James Van Buskirk" 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
|
| Show full article (1.56Kb) |
| no comments |
|
|
|
|