×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Need help Fortran

Need help Fortran

Need help Fortran

(OP)
Hi everybody.

I'm new in the community of Fortran. I have a problem with a code I'm trying to write using Fortran95. I need my code read an array of unknown size from a file. I know how find the dimensions of the array and how allocate it but when I try to read the numbers into the array I get this error and I can't figure out what is the problem. I attach some part of the code to better explain.

!Reading the arrays

integer, parameter:: kp=selected_real_kind(18,50)

real(kp),dimension(:,:),allocatable:: A

integer :: A_rows, A_col

..........

..........

allocate(A(A_rows,A_col))

doI=1,A_rows
read(iu,200,end=90)A(I,:)

write(*,200)A(I,:)

end do

90continue

200format(5E18.6)

Fortran runtime error: Bad value during floating point read

Thanks for any help.


RE: Need help Fortran

I assume you know the number of rows in the data file but didn't know the number of rows.
You can first read the file and count the number of rows.
Then you allocate your array, rewind your file and read the data into an array in the second reading of the file.
Maybe look at the example here: https://www.tek-tips.com/viewthread.cfm?qid=154233...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close