Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Not sure if this is the place to be asking, but I've got a FORTRAN issue that is driving me crazy.
I've added an OPEN/READ statement to a preexisting energy balance model because i need to run the code with changing atmospheric variables:
Code:
c Distribute cosq, fraq, from latitudinal to global ebm arrays
ie = 0
do j=1,nlat
do i=1,mlon(j)
ie = ie + 1
cosq(ie) = cosq2(j)
fraq(ie) = fraq2(j)
enddo
enddo
c Solar radiation
OPEN(500,FILE = 'inputfile.dat')
READ(500, 550) abs, trans, ref
550 format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
PRINT 550, abs, trans, ref
zt = trans ! atmos transmissivity
zr = ref ! atmos reflectivity (see searchalb.for)
c zt = 0.62 ! 777
c zr = 0.22 ! 777
za = abs ! atmos absorbtivity
do i=1,nebm
everything was working fine until I added the OPEN, READ, format, and PRINT lines. Now I get the following errors upon compiling:
Code:
fortcom: Error: atmos.F, line 72: Syntax error, found INTEGER_CONSTANT '550' when expecting one of: <LABEL> <END-OF-STATEMENT> ; BLOCK BLOCKDATA PROGRAM TYPE COMPLEX BYTE CHARACTER ...
550 format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
------------------------^
fortcom: Error: atmos.F, line 72: Syntax error, found IDENTIFIER 'PE6' when expecting one of: .EQV. .NEQV. .XOR. .OR. .AND. .LT. < .LE. <= .EQ. == .NE. /= .GT. > ...
550 format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
---------------------------------------------^
fortcom: Error: atmos.F, line 72: Syntax error, found IDENTIFIER 'PE6' when expecting one of: .EQV. .NEQV. .XOR. .OR. .AND. .LT. < .LE. <= .EQ. == .NE. /= .GT. > ...
550 format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
---------------------------------------------------------------^
fortcom: Error: atmos.F, line 72: Syntax error, found IDENTIFIER 'PE6' when expecting one of: .EQV. .NEQV. .XOR. .OR. .AND. .LT. < .LE. <= .EQ. == .NE. /= .GT. > ...
550 format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
-------------------------------------------------------------------------------^
compilation aborted for atmos.F (code 1)
make: *** [atmos.o] Error 1
I've tried a few things:
->If I move the format line to the left, then the same error pops up, but the 550 is replaces with a "*".
->If I move the rest of it to the left I get a bunch of problems related to the 'j=1,nlat' part.
->If I change the order of the PRINT and format statements, same errors, no change.
->If I move the block to the right no change in the errors occurs (expectedly).
Unfortunately, the code's *enormous*, so numbering the lines would be a bitch. Anyone have any ideas?
aah, but when I move the FORMAT line to the left I get this:
[ snip huge Fortran compiler error list ]
Here's how to write and compile a computer program:
1. Write a one-line program. Compile it.
2. Did it compile and run? If not, go back to step 1. If it did, go to step 3.
3. Add ONE LINE to your computer program and recompile it. Did it compile and run? If so, repeat. If not, go back to step 1.
In fact, here's your first Fortran program, gratis:
Code:
program hello
print *,"Hello World!"
end program hello
But believe me when I tell you, there is no point in compiling a program that you don't understand, to then see a screenful of errors that you don't understand, and then post the error list to a discussion board hoping someone else will sort out the problems. This is called "programming by newsgroup" and it is fantastically unproductive.
Choose a manageable programming task. Complete it successfully. Then choose a more challenging programming task, but in small increments that you both understand and control.
That way, rather than relying on experts, you become an expert.
I'm not writing this, I'm altering a preexisting program to do something else....
I've fixed many of the problems already, this last one I'm having trouble with.
Fair enough. But at some point, you may want to ask yourself whether it might be more useful to abandon this Fortran program and create the function you are after from first principles.
I say this because you know what the program must do and you intend to test its ability to do that, meaning you won't be accepting anything on blind faith. Given that premise, you might be better off writing the program in a modern language, one that has a future (Fortran only has a past) as well as having more control over the process and the outcome.
I say this because I have been in any number of similar positions during my time at NASA. In modern times, with the wide number of programming choices available, it is even easier to decide to cut one's losses and recreate a program's functions from scratch.
I'm a research assistant for NASA. One of their astrobiology research teams specifically.
I'm using an old energy balance model for Earth (originally written by my advisor's advisor), but have changed it to work for ancient Mars. We need to cover various possible atmospheres - hence the changing input for 'atmos.F'.
The ebm is enormous, with a dozen different make files, so starting over from scratch would take months. Everything's awesome (after some debugging), with the exception of this one block I've added to the atmospheric file. Totally frustrating.
Good luck. Been there. Sometimes these things can be maddening. I've done some scientific programming in C and fortran in the past and these types of bugs make you a better person. ;-) (At least you feel great relief when you figure them out.)
I would recommend carefully reviewing the compile time options and any compiler switches that might affect this module to see if there is anything that might affect this particular syntax.
I'm not familiar with PE6... Is that a short-hand number syntax that you have to enable a special compiler switch to recognize?
I recommend you try my 2nd link, that bypasses the issue.
Another thing I do in any lang for an error I don't get; write a short-as-possible example of the problem code and debug that.
Once you've solved it there, you can dd it to the real program.
Don't keep messing with the big program.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.