- #1
prashanth.hsn
- 2
- 0
Hi all,
I'm upgrading a legacy f77 code to f90 standards. I'm trying to make some of the global arrays as dynamic arrays so that at a later stage it would be easier for me to parallelize whole application.
Coming to my problem, I need to read some numbers from a text file so that I can allocate (just enough) memory to the multidimensional arrays. However, while reading the input text file I need to skip say 'n' real numbers and then resume reading. These real numbers span several records (=lines) in the input text file and the number of real numbers per record is not constant sad.
In summary, I know how many real numbers I've to skip, but I do not know in how many records these numbers span.
Ex:
Input.data
I have to read first line and then skip 27 real numbers and then again start reading from line 7.
I currently have a code which works but it is not efficient,
My current code looks like this
I'm upgrading a legacy f77 code to f90 standards. I'm trying to make some of the global arrays as dynamic arrays so that at a later stage it would be easier for me to parallelize whole application.
Coming to my problem, I need to read some numbers from a text file so that I can allocate (just enough) memory to the multidimensional arrays. However, while reading the input text file I need to skip say 'n' real numbers and then resume reading. These real numbers span several records (=lines) in the input text file and the number of real numbers per record is not constant sad.
In summary, I know how many real numbers I've to skip, but I do not know in how many records these numbers span.
Ex:
Input.data
Code:
3 3 3
1.23445 0.2345235 0.345234 0.123425235 0.12343245
0.31415927 1.23445 0.2345235 0.345234 0.123425235 0.12343245
0.31415927 1.23445 0.2345235
0.31415927 1.23445 0.2345235 0.2345235
0.123 0.3245 0.74565355 4.34623431 56.2352354
0.31415927 1.23445 0.2345235 0.2345235
3
33
3
33
12
6
I have to read first line and then skip 27 real numbers and then again start reading from line 7.
I currently have a code which works but it is not efficient,
My current code looks like this
Code:
[COLOR="Blue"]Integer[/COLOR]:: i, j, k, ii, jj, kk, num
[COLOR="Blue"]Real, Allocatable, Dimension[/COLOR](:,:,:):: x
[COLOR="DimGray"]!Start reading the data from file, UNIT=16[/COLOR]
[B]read[/B](16,*) i, j, k
[COLOR="DimGray"]!I want to Skip reading data to dummy x(:,:,:) array[/COLOR]
[B]read [/B](16,*) (((x(ii,jj,kk),ii=1,i),jj=1,j),kk=1,k)
[COLOR="DimGray"]! Resume reading[/COLOR]
[B]read[/B](16,*) num