Welcome to Dream.In.Code
Become an Expert!

Join 137,424 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,968 people online right now. Registration is fast and FREE... Join Now!




Help with Fortran I/O

 
Reply to this topicStart new topic

Help with Fortran I/O

pught
10 Jan, 2008 - 05:51 AM
Post #1

New D.I.C Head
*

Joined: 10 Jan, 2008
Posts: 1

Hi,

I've been having trouble trying to read an input file. With the following message being generated and the program stopped:

fmt: end of file
apparent state: unit 25 named fort.25
last format: (I7,1X,F8.3,3X,F6.3,1X,F9.3,2(2X,F7.3))
lately reading sequential formatted external IO
./run_tom: line 209: 1707 Aborted ./object

Does anybody have any idea what could be causing this error? The relevant code is posted below.

CODE

c Read the data file
       do j=1,nsupl
       read(ichd,1201)time, ztlon(j),ztlat(j),ztpres(j),ztemp(j),zptemp(j)
       write(6,*) 'itime, ztlon, ztlat, ztpres, ztemp and zptemp are '


ichd is a variable set to 25 causing the program to read the input file which is symbolically linked to fort.25.
1201 is the format string
CODE
format(i7,1x,f8.3,3x,f6.3,1x,f9.3,2(2x,f7.3))
which seems to match the input file perfectly.


Cheers very much in advance for any help
User is offlineProfile CardPM
+Quote Post

GravityGuy
RE: Help With Fortran I/O
9 Feb, 2008 - 09:46 PM
Post #2

New D.I.C Head
*

Joined: 21 Jan, 2008
Posts: 45


My Contributions
This topic is a bit old and you're probably on to something else, but...

is the variable time supposed to be itime.

you are not getting a format error if it says end of file. Is it running out of data too soon.

I find it a lot easier to read in numbers using free format and there's no format statement.

read(ichd, *) var1, var2...

Fortran automatically skips white space and commas between the numbers, but it won't continue on the next line. A character string has to go last if you need to read char input, otherwise you're back to a format statement.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 04:34AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month