Hi All,
I have been trying to read in a data using Fortran but for some reasons, it doesn't read the data correctly. Please, any help will be appreciated. To read the data, I used the following (Note, for the attached data, Nm=1, nw-nu=5, nw=10).
The array data(i,j,m,n) is declared as data(1:Nm,1:Nm,-nw:nw,0:nw-u). When it tries reading, it spits the error message "Subscript #4 of the array data has value 1 which is greater than the upper bound of 0". A snippet of the code is below.
2015 read(40,"(a72)") lineda
do n=0,nu
do m=-nw,nw-nu
do i=1,Nm
do j=1,Nm
if(index(lineda(1:72),'data') /= 0 ) then
read(40,"(1x,i2,1x,i2,2x,i5,2x,i5,1x,2(1x,e15.8))",IOSTAT=istat) i1,i2,i3,i4,r1,r2
data(i,j,m,n)=dcmplx(r1,r2)
write(809,"(1x,i2,1x,i2,2x,i5,2x,i5,1x,2(1x,e15.8))") i,j,m,n,data(i,j,m,n)
if(istat /= 0) goto 2018
else
goto 2015
endif
2018 continue
enddo
enddo
enddo
enddo
An example of the data is as as attached.
Thank you very much for your help.
I have been trying to read in a data using Fortran but for some reasons, it doesn't read the data correctly. Please, any help will be appreciated. To read the data, I used the following (Note, for the attached data, Nm=1, nw-nu=5, nw=10).
The array data(i,j,m,n) is declared as data(1:Nm,1:Nm,-nw:nw,0:nw-u). When it tries reading, it spits the error message "Subscript #4 of the array data has value 1 which is greater than the upper bound of 0". A snippet of the code is below.
2015 read(40,"(a72)") lineda
do n=0,nu
do m=-nw,nw-nu
do i=1,Nm
do j=1,Nm
if(index(lineda(1:72),'data') /= 0 ) then
read(40,"(1x,i2,1x,i2,2x,i5,2x,i5,1x,2(1x,e15.8))",IOSTAT=istat) i1,i2,i3,i4,r1,r2
data(i,j,m,n)=dcmplx(r1,r2)
write(809,"(1x,i2,1x,i2,2x,i5,2x,i5,1x,2(1x,e15.8))") i,j,m,n,data(i,j,m,n)
if(istat /= 0) goto 2018
else
goto 2015
endif
2018 continue
enddo
enddo
enddo
enddo
An example of the data is as as attached.
Thank you very much for your help.