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 7 of 11 Topic 8155 of 8774
Post > Topic >>

Re: Call Array valued Fortran function from C

by "James Van Buskirk" <not_valid@[EMAIL PROTECTED] > Apr 20, 2008 at 09:26 AM

"FX" <coudert@[EMAIL PROTECTED]
> wrote in message 
news:fuf742$1j7j$1@[EMAIL PROTECTED]
>>    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.

I know.  These are what I came up with via reverse engineering
gfortran assembly language output.  Given do***entation instead I
would be more inclined towards:

use ISO_C_BINDING, only: C_PTR, C_SIZE_T
type, bind(C) :: descriptor_dimension
   integer(C_SIZE_T) stride
   integer(C_SIZE_T) lbound
   integer(C_SIZE_T) ubound
end type descriptor_dimension
type, bind(C) :: descriptor_1
   type(C_PTR) data
   integer(C_SIZE_T) offset
   integer(C_SIZE_T) dtype
   type(descriptor_dimension) dim(1)
end type descriptor_1

The first kind type that I noticed changed from 32 to 64 bits
on going from 32-bit Windows to 64-bit Windows was C_INTPTR_T,
quite analogous to DVF/CVF/ifort int_ptr_kind().  I guess
size_t does the same thing and ssize_t follows along for the
ride which is why all the descriptor fields ended up being
64 bits wide.  It's hard to tell how they got that way from
reverse engineering alone.

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

> I got to the following reduced testcase:

[snip]

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

Thanks for taking a look at this.  I try to keep you informed when
I find this kind of behavior.

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




 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 Sun Oct 12 23:35:38 CDT 2008.