Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to split a big array data file into several small data files each

Status
Not open for further replies.

rock31

Programmer
Jul 18, 2004
38
US
Hi,

I have a big array of data stored in a file named as 'A.dat'. I would like to split it into many small files (B11.dat, B12.dat, …B21.dat ,B22.dat, …) with each contains a small data block with size (N X M).

A direct way to deal with it is to read all the data into a big array A, then try to save
A( (n-1)*N+1 : n*N, (m-1)*M+1 : m*M ) )
to file Bnm.dat conresponding to block (n,m)

But I feel this is too clumsy. There should be a better method to do the same thing. Would anyone please comment on it?
Thanks a lot
 
The array variable may be equivalenced to a matrix, the first dimension of which is set to N * M. Example :
DIMENSION A(10000) , B(100,100)
EQUIVALENCE (A , B )
CHARACTER FILENAME * 100 , NUMBER * 3
........
DO 50 IFILE = 1 , 100
WRITE(NUMBER,'(I3)') IFILE
FILENAME = NUMBER//other text
C NEXT OPEN THE FILE AND WRITE THE SELECTED COLUMN OF B


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top