I have an array created by another routine (i wrote it so I can change
it according to your suggestion) which gives the neighbour index of
site i.
I want to extend it for n-th neighbour. I checked the verlet algo and
linked cell. But still clueless. Can you suggest me any good source?
My second question is, since the number of neighbour varies as i go
from 1st to n-th neighbouring shell, how can I read them? if number of
index is fixed, then i can open the file and
do i=1,tot
read(10,*)nn(i,j)j=1,nn
end do
but since nn varies in every shell, what I can do?
Is there any EOF type of thing here for the purpose?
|
|
0
|
|
|
|
Reply
|
bnrj.rudra (343)
|
5/15/2011 5:26:13 PM |
|
On Sun, 15 May 2011 10:26:13 -0700 (PDT), rudra <bnrj.rudra@gmail.com>
wrote:
>I have an array created by another routine (i wrote it so I can change
>it according to your suggestion) which gives the neighbour index of
>site i.
>I want to extend it for n-th neighbour. I checked the verlet algo and
>linked cell. But still clueless. Can you suggest me any good source?
>My second question is, since the number of neighbour varies as i go
>from 1st to n-th neighbouring shell, how can I read them? if number of
>index is fixed, then i can open the file and
>do i=1,tot
> read(10,*)nn(i,j)j=1,nn
>end do
>but since nn varies in every shell, what I can do?
>Is there any EOF type of thing here for the purpose?
Perhaps you'd better give an example. I'm having a hard time
understanding what you're trying to do.
Note that "read(10,*)nn(i,j)j=1,nn" is confusing, since you seem to be
using "nn" both as an array name and as an ending index to the implied
"for" loop.
Louis
|
|
0
|
|
|
|
Reply
|
lkrupp3 (25)
|
5/15/2011 7:18:34 PM
|
|
rudra <bnrj.rudra@gmail.com> wrote:
(snip)
> I want to extend it for n-th neighbour. I checked the verlet algo and
> linked cell. But still clueless. Can you suggest me any good source?
> My second question is, since the number of neighbour varies as i go
> from 1st to n-th neighbouring shell, how can I read them? if number of
> index is fixed, then i can open the file and
> do i=1,tot
> read(10,*)nn(i,j)j=1,nn
> end do
> but since nn varies in every shell, what I can do?
> Is there any EOF type of thing here for the purpose?
If you know the number in advance, or even on the same line,
it is easy. Just put the number in the implied-DO.
do i=1,tot
read(10,*) (nn(j,i),j=1,i)
enddo
or
do i=1,tot
read(10,*) num,(nn(j,i),j=1,num)
enddo
(and note that both read the arrays in storage order,
which is a little more efficient.)
If you don't know before reading the line, then read into
a CHARACTER variable, then use internal read to read it out.
-- glen
|
|
0
|
|
|
|
Reply
|
gah (12236)
|
5/15/2011 7:32:06 PM
|
|
On 5/15/2011 12:26 PM, rudra wrote:
> I have an array created by another routine (i wrote it so I can change
> it according to your suggestion) ...
> ... since the number of neighbour varies as i go
> from 1st to n-th neighbouring shell, how can I read them?...
Since you're controlling the file format from the other routine, unless
you have other logic that determines the number, write the number on the
record so the input routine can READ the expected number and act
accordingly.
I don't follow enough of the first part of the original posting to even
try to comment.
--
|
|
0
|
|
|
|
Reply
|
none1568 (6639)
|
5/15/2011 7:50:22 PM
|
|
|
3 Replies
36 Views
(page loaded in 0.072 seconds)
|