Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Attempting to read a record with a smaller array length

$
0
0

Hi everyone,

I have a very strange problem while reading a previously written file.  I write an unformatted file using the following code

 

!...... SOME PREVIOUS CODE

COMPLEX(KIND=8), ALLOCATABLE, DIMENSION(:,:) :: D

CALL getenv('DIPFILE',file_dip)
 file_dip = TRIM(file_dip)//".V" ! velocity gauge
OPEN(UNIT=iout, FILE=file_dip, STATUS='REPLACE', &&  ACCESS='SEQUENTIAL', FORM='UNFORMATTED')


 ALLOCATE ( D(dim_t,dim_t), STAT = istatus )
 IF (istatus /= 0) CALL alloc_error ( ilog, 0, istatus, 'D')

 D=CMPLX(0.0_rk, 0.0_rk)

 DO l = 0, l_max


!   SOME OPERATIONS....


   DO j_st = 1, dim_t

     WRITE(iout)  REAL(D(:,j_st))
     WRITE(iout) AIMAG(D(:,j_st))

   ENDDO


 ENDDO

 CLOSE(iout)

 

Then, I read the file using another fortran program (using the same compiling options), but this time I don't read the whole record but just a part of it, I'm doing as follows.

 REAL(KIND=8), ALLOCATABLE, DIMENSION(:)     :: D_re, D_im

 ALLOCATE ( D_re(n_Dip), STAT = istatus )    !
 IF (istatus /= 0) CALL alloc_error ( ilog, 0, istatus, 'D_re')
 ALLOCATE ( D_im(n_Dip), STAT = istatus )    !
 IF (istatus /= 0) CALL alloc_error ( ilog, 0, istatus, 'D_im')



!  SOME CODE INTERMEDIATE CODE



   DO l = 0, l_max


    n_col = NS_sym(l+1)
    n_row = NS_sym(l+1)


    i_D = D_sym(l+1, l+1)


    DO i_col = 1, n_col

      READ(idata) D_re(i_D: i_D + n_row - 1)
      READ(idata) D_im(i_D: i_D + n_row - 1)

      i_D = i_D + n_row

    ENDDO

    DO i_col = n_col + 1, dim_r

      READ(idata)
      READ(idata)

    ENDDO


   ENDDO

   CLOSE(idata)

Now, when I run it I get the error

forrtl: severe (67): input statement requires too much data, unit 10, file "test"

The strange thing is that I'm reading less data that what is actually in the records of the "test" file. Even more strange is that it only happens sometimes, meaning that with other files the program runs perfectly ok. There seems to be no pattern, as when I write and read the matrices of five thousand or more elements it read perfectly, but with few elements works sometimes well, sometimes spits the error above.

Could you help me?

Im using ifort compiler version 15.0.1 using the compiler flags -O3 -xHost -ipo ( I've tried compiling without optimizations and the result is the same in any case)

 

Thanks in advanced,

Ronquentin

 

 

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>