LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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



Reply
 
Search this Thread
Old 09-16-2009, 01:31 AM   #1
Laughing_Man
LQ Newbie
 
Registered: Sep 2009
Location: Seattle
Posts: 8

Rep: Reputation: 0
Syntax error when compiling


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?
 
Old 09-16-2009, 02:51 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Here we go
Quote:
The statement label may be placed anywhere in columns 1 through 5 of the initial line of the statement.
http://www.fortran.com/F77_std/rjcnf...-3.html#sh-3.4

but see http://www.cs.mtu.edu/~shene/COURSES...05/format.html for different and allegedly better solution
 
Old 09-16-2009, 04:26 AM   #3
Laughing_Man
LQ Newbie
 
Registered: Sep 2009
Location: Seattle
Posts: 8

Original Poster
Rep: Reputation: 0
aah, but when I move the FORMAT line to the left I get this:

Code:
echo '** Compiling atmos.F'
** Compiling atmos.F
ifort -r8 -DLINUX  -O2 -I. -I/[##(file location)##]-c atmos.F
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. > ...
     * 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. > ...
     * 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. > ...
     * format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
----------------------------------------------------------^
fortcom: Error: atmos.F, line 71: This label has not been defined as a FORMAT label.   [550]
                READ(500,550) abs, trans, ref50
-------------------------^
fortcom: Error: atmos.F, line 72: The highest data type rank permitted is INTEGER(KIND=8).   [.0]
     * format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
---------------------------^
fortcom: Error: atmos.F, line 72: The highest data type rank permitted is INTEGER(KIND=8).   [.0]
     * format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
---------------------------------------------^
fortcom: Error: atmos.F, line 72: The highest data type rank permitted is INTEGER(KIND=8).   [.0]
     * format("abs = ",1PE6.0,"trans = ",1PE6.0,"ref = ",1PE6.0)
-------------------------------------------------------------^
fortcom: Error: atmos.F, line 71: Constants and expressions are invalid in read-only I/O lists.   [REF50FORMAT]
                READ(500,550) abs, trans, ref50
------------------------------------------^
fortcom: Error: atmos.F, line 73: This label has not been defined as a FORMAT label.   [550]
                PRINT 550, abs, trans, ref
----------------------^
fortcom: Error: atmos.F, line 71: This label is undefined.   [550]
                READ(500,550) abs, trans, ref50
-------------------------^
compilation aborted for atmos.F (code 1)
make: *** [atmos.o] Error 1
 
Old 09-16-2009, 04:59 AM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by Laughing_Man View Post
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.
 
Old 09-16-2009, 12:29 PM   #5
Laughing_Man
LQ Newbie
 
Registered: Sep 2009
Location: Seattle
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 09-16-2009, 01:26 PM   #6
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by Laughing_Man View Post
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.
 
Old 09-16-2009, 02:15 PM   #7
Laughing_Man
LQ Newbie
 
Registered: Sep 2009
Location: Seattle
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 09-16-2009, 05:26 PM   #8
bbneo
Member
 
Registered: Jun 2008
Location: Northeast Ohio
Distribution: fedora 10, Debian, Ubuntu
Posts: 34

Rep: Reputation: 16
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?
 
Old 09-16-2009, 07:03 PM   #9
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 01:52 PM
Help with compiling C program, syntax error MrUmunhum Programming 7 11-26-2008 03:07 PM
why am getting error ksh: syntax error: `fi' unexpected while running script deb4you Linux - Newbie 4 09-06-2008 09:37 AM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 07:09 PM
ERROR running make when installing Nvidia drivers (syntax error) randyriver10 Linux - Software 5 02-21-2004 05:51 PM


All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration