Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Call Array ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 11 Topic 8155 of 8775
Post > Topic >>

Re: Call Array valued Fortran function from C

by "FX" <coudert@[EMAIL PROTECTED] > Apr 20, 2008 at 10:49 AM

>    type, bind(C) :: descr
>       type(C_PTR) address
>       integer(C_INTPTR_T) unknown1
>       integer(C_INTPTR_T) unknown2
>       integer(C_INTPTR_T) stride
>       integer(C_INTPTR_T) unknown3
>       integer(C_INTPTR_T) last_element
>    end type descr

No, these are not the types I indicated.

> So it seems that the structure constructor for type(descr) isn't
> assigning that first member, address.

I got to the following reduced testcase:

$ cat a.f90 
program main
   use ISO_C_BINDING
   implicit none
   type, bind(C) :: descr
      type(C_PTR) :: address
   end type descr
   type(descr) :: DD
   double precision, target :: buf(1)

   buf = (/ 0 /)
   DD = descr(c_loc(buf))
   print *, transfer(DD%address, 0_c_intptr_t), &
     transfer(c_loc (buf), 0_c_intptr_t)
end program main
$ gfortran a.f90 && ./a.out
           0 -1073744200

where both gfortran and g95 give weird results (Sun doesn't want to
compile it, for some reason I don't understand).

-- 
FX
 




 11 Posts in Topic:
Call Array valued Fortran function from C
koentjepoppe@[EMAIL PROTE  2008-04-19 10:33:39 
Re: Call Array valued Fortran function from C
glen herrmannsfeldt <g  2008-04-19 12:11:20 
Re: Call Array valued Fortran function from C
"James Van Buskirk&q  2008-04-19 15:54:39 
Re: Call Array valued Fortran function from C
"FX" <couder  2008-04-19 22:23:33 
Re: Call Array valued Fortran function from C
"James Van Buskirk&q  2008-04-19 17:14:50 
Re: Call Array valued Fortran function from C
"FX" <couder  2008-04-20 10:49:38 
Re: Call Array valued Fortran function from C
"James Van Buskirk&q  2008-04-20 09:26:43 
Re: Call Array valued Fortran function from C
"James Van Buskirk&q  2008-04-20 21:21:14 
Re: Call Array valued Fortran function from C
Sebastian Hanigk <hani  2008-04-20 09:44:34 
Re: Call Array valued Fortran function from C
nf.editor@[EMAIL PROTECTE  2008-04-20 08:56:10 
Re: Call Array valued Fortran function from C
"FX" <couder  2008-04-20 16:11:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 3:31:04 CDT 2008.