Radamantis
Programmer
Hi, i'm a new user in this forum and this is my first post.
That's my problem: i need to call a fortran subroutine using as input parameter an array declared in C, using malloc.
the subroutine accepts and fills the array using this code:
after, when executes this code:
(the parts marked as "omitted" doesn't affect the involved variables) it loops infinitely when i=17 and k=13. What's wrong?
If it could be helpful, the subroutine is declared as follows:
Thanks a lot in advance.
That's my problem: i need to call a fortran subroutine using as input parameter an array declared in C, using malloc.
Code:
int *bin = (int*)malloc(sizeof(int)*natoms);
int *binpnt (int*)malloc(sizeof(int)*natoms);
the subroutine accepts and fills the array using this code:
Code:
do i = 1,nbinx*nbiny*nbinz
binpnt(i) = 0
enddo
do i = 1,natoms
ix = (x(1,i) + xprd2) / binsizex
iy = (x(2,i) + yprd2) / binsizey
iz = (x(3,i) + zprd2) / binsizez
ib = iz*nbiny*nbinx + iy*nbinx + ix + 1
bin(i) = binpnt(ib)
binpnt(ib) = i
enddo
after, when executes this code:
Code:
do i=nstart,nend
<omitted>
do k=0,26
<omitted>
ib = iz*nbiny*nbinx + iy*nbinx + ix + 1
j = binpnt(ib)
10 if (j.ne.0) then
<omitted>
j = bin(j)
goto 10
endif
enddo
enddo
(the parts marked as "omitted" doesn't affect the involved variables) it loops infinitely when i=17 and k=13. What's wrong?
If it could be helpful, the subroutine is declared as follows:
Code:
subroutine neighbor1(bin,binpnt,dim_bin,dim_binpnt)
integer,intent(in)::dim_bin
integer,intent(in)::dim_binpnt
integer,intent(inout),dimension(dim_bin)::bin
integer,intent(inout),dimension(dim_binpnt)::binpnt
Thanks a lot in advance.