Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is wrong with this Fortran '77 snippet?
    primarykey
    data
    text
    <p>I've been tasked with maintaing some legacy fortran code, and I'm having trouble getting it to compile with gfortran. I've written a fair amount of Fortran 95, but this is my first experience with Fortran 77. This snippet of code is the problematic one:</p> <pre><code> CHARACTER*22 IFILE, OFILE IFILE='TEST.IN' OFILE='TEST.OUT' OPEN(5,FILE=IFILE,STATUS='NEW') OPEN(6,FILE=OFILE,STATUS='NEW') common/pabcde/nfghi </code></pre> <p>When I compile with <code>gfortran file.FOR</code>, all lines starting with the <code>common</code> statement are errors (e.g. <code>Error: Unexpected COMMON statement at (1)</code> for each following line until it hits the 25 error limit). I compiled with <code>-Wall -pedantic</code>, but fixing the warnings did not fix this problem. </p> <p>The crazy thing is that if I comment out <strong>all 4</strong> lines starting with <code>IF='TEST.IN'</code>, the program compiles and works as expected, but <em>I must comment out all of them</em>. Leaving any of them uncommented gives me the same errors starting with the <code>common</code> statement. If I comment out the <code>common</code> statement, I get the same errors, just starting on the following line.</p> <p>I am on OS X Leopard (not Snow Leopard) using <code>gfortran</code>. I've used this very system with <code>gfortran</code> extensively to write Fortran 95 programs, so in theory the compiler itself is sane. What the hell is going on with this code?</p> <hr> <p><strong>Edit</strong>: Compiling with g77 gives: </p> <pre><code>test.FOR: In program `MAIN__': test.FOR:154: IFILE='TEST.IN' 1 test.FOR:158: (continued): common/pabcde/nfghi 2 Statement at (2) invalid in context established by statement at (1) </code></pre> <p>Er, what context is established at (1)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload