From: e p chandler on
On Feb 19, 2:42 pm, monir <mon...(a)mondenet.com> wrote:
> On Feb 18, 8:16 pm, "e p chandler" <e...(a)juno.com> wrote:
>
> > "monir" <mon...(a)mondenet.com> wrote in message
>
> > On Feb 18, 4:11 pm, e p chandler <e...(a)juno.com> wrote:
>
> > But you seem to want to read it back in as var(x_index,r_index,t_index)..
> > Unfortunately in Fortran, the first subscript varies the most rapidly, not
> > the last. So you have written out the data as a higher dimensional transpose
> > of the natural order in which Fortran would want to read it.
>
> > --- e
>
> That's correct, and would've caused serious problems if the write/read
> arrays are multidimensional.
> The difference here is that I've the arrays written and read as 1D,
> and simply assigned each read element to a particular position in 2D
> or 3D arrays, as the case may be.
>
> The answer to my inquiry in the OP appears to be much simpler than I
> had originally thought.
> Here's what appears to be working fine for me:
> Data is written to the sequential file with "t" changing faster, then
> "r", and then "x".
> Same for vt, vr, vx.
>
> !.........................
> !The 1D arrays are written in a continuous sequence
> np = nx * nr * nt
> do i =1, nrecords
>    Write (80) (x(m), r(m), t(m), m=1, np)
>    Write (80) (vx(m), vr(m), vt(m), m=1, np)
> end do
>
> !.........................
> !Read the 1D arrays and in the process assign each read element to 2D
> and 3D arrays; as the case may be
> !Arrays x, r, t DO not differ in this example from record to record,
> while the v's arrays DO
> do ii =1, nrecords
>    Read (80) (((xb(i,j,k), rb(i,j,k),tb(i,j,k), k=1,nt), j=1,nr),
> i=1,nx)
>    Read (80) (vxi(ii,m), vri(ii,m), vti(ii,m), m=1,np)
> end do
>
> !.........................
> !For a desired record index "ind", convert the 2D "v" arrays to 3D "v"
> arrays with subscripts i=1,nx, j=1,nr, k=1,nt
> !consistent with the written data
> ind = 5
> kount = 0
> do  i=1, nx
>   do j=1, nr
>     do k=1, nt
>        kount = kount+1
>        vxx(i,j,k) = vxi(ind,kount)
>        vrr(i,j,k) = vri(ind,kount)
>        vtt(i,j,k) = vti(ind,kount)
> end do
>
> I'm sure you experts can easily accomplish same in a more compact and
> more efficient way, but ...
>
> Any comments ??
>
> Regards.
> Monir

Well, why keep x, r and t as 1d arrays?

Start with x(i,j,k) r(i,j,k) and t(i,j,k)

As you are calculating each x,r andd t value, keep the counters i,j
and k at the proper values. Then you are free to write out your data
to files as you please.


for i=1 to nx
for j=1 to nr
for k=1 to nt
x(i,j,k)=....
r(i,j,k)=....
t(i,j,k)=....

Or am I missing something fundamental here?

--- e

From: monir on
On Feb 19, 3:25 pm, e p chandler <e...(a)juno.com> wrote:
> On Feb 19, 2:42 pm, monir <mon...(a)mondenet.com> wrote:
> > On Feb 18, 8:16 pm, "e p chandler" <e...(a)juno.com> wrote:
>
> Well, why keep x, r and t as 1d arrays?
> Start with x(i,j,k) r(i,j,k) and t(i,j,k)
>
> Or am I missing something fundamental here?
>
> --- e-

No, you're not missing anything!
The difficulty in writing the variables x, r, t, vx, vr, vt as 3D
arrays is that other routines read the same variables in the current
1D array format, and it would be a bit risky to do the changes
throughout at this late time!
At least I got that part of the code working properly now!

Thanks again for your time and help.

Regards.
Monir
First  |  Prev  | 
Pages: 1 2
Prev: Hourly mean
Next: virtual memory issue