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).(adsbygoogle = window.adsbygoogle || []).push({});

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

The sample data is attached.

Thank you very much for your help.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Please, Help with Data Reading in Fortran

Loading...

Similar Threads - Please Help Data | Date |
---|---|

I need help in Fortran please -- Bairstow's method & Newton-Raphson | Nov 26, 2016 |

C/++/# Please help me understand how to solve the problem "Code of Polar function" | Sep 30, 2016 |

Help with understanding programming | Mar 7, 2016 |

Can you please help me understand drag and gravity? | May 21, 2015 |

Fortran 90 Error Please help | Apr 6, 2015 |

**Physics Forums - The Fusion of Science and Community**