Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems compiling mobcal

Status
Not open for further replies.

dunwich

Programmer
Dec 7, 2009
4
AU
Hey guys,
Seriously new to fortran here. I'm using Mac OS X 10.6 and gfortran (also tried out g77 to see if there were any differences). I've been asked by my professor to compile the program "mobcal": but I'm having some difficulty doing so. The problem lies in this area of code

c
c To make it easier to run batches of programs the following
c information is now entered from a file
c
c 1. file for input
c 2. file for output
c 3. random number seed
c
c filen1='gly3h1'
c filen2='temp.out'
c i2=96
c
c From a file
c
open(20,file='mobcal.run')
read(20,'(a30)') filen1
read(20,'(a30)') filen2
read(20,*) i2
close (20)

The main problem here is that I receive an end of file error at line 122 (the open command) when running the executable (i.e. gfortran/g77 will *compile* it with no problem, but then it won't run). Now from what I've read, this is generally a problem that can be solved by fixing the line breaks in the mobcal.run file, and I've even downloaded an app that fixes these things to make sure, and still I get the same error. Any clues, guys?


Also, following the example, I choose a10A1 for filen1 as a10A1.mfj is the input file, but I receive errors if I call filen2 'a10A1.out', the error being about the period. I'm wondering that if I call filen1 and filen2 both a10A1, is the compiler going to know that one of them is an input and the other output? This is a less taxing question however, as I can't really get to here until I've got the program reading this .run!

Thanks for reading!
 
1) I don't really know what the default for open is. It might be safer to add

status='old'

to your open statement.

2) mobcal.run should have 3 lines of data, 2 with strings and one with a number. You could just try what it says in the comment. Create mobcal.run with the following and try running with it.

gly3h1
temp.out
96

I'm a bit confused about the last bit. Is it the same program that is giving you errors when the input filename is a10A1.mfj or is that a different program? Is it in this area of code or a different area? I can't see how a compiler will give you errors on a runtime file that it doesn't know about.
 
Thanks for the quick reply!
Alas I'm now getting errors on the read line below. So I've now got code like
open(20,file='mobcal.run', status='old')
read(20,'(a30)') a10A1
read(20,'(a30)')
read(20,*) i2
close (20)
and an error like this in g77:
fmt: end of file
apparent state: unit 20 named mobcal.run
last format: (a30)
lately reading sequential formatted external IO
Abort trap
logout

And like this in gfortran:
At line 118 of file mobcal.f (unit = 20, file = 'mobcal.run')
Fortran runtime error: End of file
logout

(I typed the wrong line number before, 118 corresponds to the read line)

I tried adding " rewind 20 " as a line under open in hopes it read it, but to no avail. So really, it seems to me I'm having issues even before the input file is considered, it's this darned .run file.
 
Oh, and I did try the suggested mobcal.run only to receive the exact same error. Hmm.
 
Solved! Being relatively new to Macs as well, I didn't know mobcal was reading from empty files in the user directory instead of the folder I was using. Simple thing but the fact it resembled a line break problem had me fuzzled.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top