Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

Help for a FORTRAN N00b


I am a FORTRAN n00b and am trying to get a piece of code running.  The
complier I am using is g95.  I did not write the FORTRAN code and I
believe that it is FORTRAN 77 or something but not sure.

If someone has a second, would you mind running the code and seeing if
you get similar errors?

code:
http://rjaengineering.googlepages.com/ex3_8b.f

screen shot of some of the errors I got:
http://rjaengineering.googlepages.com/erros.jpg

Thanks,

Richard

thogy <Richard.All@gmail.com> wrote:
> code:

Yes, this is f77 code. At first glance, it looks pretty ordinary and
should be able to run with pretty much any compiler, including g95, with
some very simple fixes. I don't happen to have a compiler installed on
this machine at the moment. (Need to fix that someday, probably by
downloading g95). The following is based on my eyeball scan.

Looks to me like your only problem is that some things are in the wrong
columns. Fixed source form (the only option in f77) is very picky about
columns. In particular

Most code should lie between columns 7 and 72 inclusive. Columns 1-6 are
reserved for special purposes.  In your case...

Some of the CONTINUE statements seem to have the "CONTINUE" starting in
column 6. That won't do. It must be shoved over to at least column 7.

Don't worry about the stuff with a C in column 1. That's comments. (But
the C does have to be exactly in column 1; I think all yours were ok on
that.)

The & characters that the code is using for continuation lines must be
*EXACTLY* in column 6. No other column will do. Not 5, and not 7. Some
of yours are in 6, but it looks like others have drifted over to column
7. The continuation character doesn't have to be an &, but it looks like
that's what this code uses, which is fine.

Statement numbers must lie between columns 1 and 5 includive. I think
all yours are ok on that. Those are the numbers at the start of some
lines.

Several of the other error messages are just side effects of the errors
elsewhere. In particular, because the CONTINUE statements that end some
loops were messed up, the compiler thought you were still in those
loops, which generated secondary error messages.

Counting exact numbers of blanks is tricky when transcribing code (or
scanning it). I'm assuming something like that is the cause of these
errors.

--
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain

On Apr 4, 11:57 pm, "thogy" <Richard.All@gmail.com> wrote:

> I am a FORTRAN n00b and am trying to get a piece of code running.  The
> complier I am using is g95.  I did not write the FORTRAN code and I
> believe that it is FORTRAN 77 or something but not sure.

> If someone has a second, would you mind running the code and seeing if
> you get similar errors?

> code:http://rjaengineering.googlepages.com/ex3_8b.f

> screen shot of some of the errors I got:http://rjaengineering.googlepages.com/erros.jpg

> Thanks,

> Richard

Richard Maine has explained in his reply that your code is Fortran 77.
The .f extension indicates (in the gcc compiler family) that it is
fixed format source.

You have a series of cascading errors caused by misaligning your
source code. In addition, one statement is flagged as having an extra
parenthesis on the right.

I moved over some CONTINUE statements so that the statement starts in
column 7 and I moved other statements so that the continuation marker
& appears in column 6. You also have a comment in which the initial c
must be in column one. In addition, I guessed where you might need a
left parenthesis added to match the extra one on the right based on
preceeding statements of similar form.

Here follows the output of 'fc' on your original vs my code:

comparing files EX3_8B.F0 and EX3_8B.F
***** EX3_8B.F0
4    CONTINUE

***** EX3_8B.F
4     CONTINUE

*****

***** EX3_8B.F0
      HZ(I,J,K,N)=0
5    CONTINUE
      print *, 'initialization complete'
***** EX3_8B.F
      HZ(I,J,K,N)=0
5     CONTINUE
      print *, 'initialization complete'
*****

***** EX3_8B.F0
        EY(I,J,K,NCUR)=CA(M)*EY(I,J,K,NPR1) + CBMRB(M)*
      &  HX(I,J,K,NCUR)-HX(I,J,K-1,NCUR)+HZ(I-1,J,K,NCUR)
      &                -HZ(I,J,K,NCUR))
        ENDIF
***** EX3_8B.F
        EY(I,J,K,NCUR)=CA(M)*EY(I,J,K,NPR1) + CBMRB(M)*
     &  (HX(I,J,K,NCUR)-HX(I,J,K-1,NCUR)+HZ(I-1,J,K,NCUR)
     &                -HZ(I,J,K,NCUR))
        ENDIF
*****

***** EX3_8B.F0
       ENDIF
      c---k=kmax
       IF(K.EQ.KMAX) THEN
***** EX3_8B.F
       ENDIF
c---k=kmax
       IF(K.EQ.KMAX) THEN
*****

***** EX3_8B.F0
       ENDIF
30   CONTINUE !  I LOOP
C********************************************************
***** EX3_8B.F
       ENDIF
30    CONTINUE !  I LOOP
C********************************************************
*****

After making these changes, the program compiles, runs and gives what
appears to be meaningful output both under g77 and g95 (modulo some
noise in the output of the low order digits beyond the expected ~7
significant figures).

I suggest proofreading your program against the source listing,
bearing in mind the restrictions of fixed source format.

HTH

-- elliot

On Apr 5, 7:13 am, "e p chandler" <e@juno.com> wrote:

> On Apr 4, 11:57 pm, "thogy" <Richard.All@gmail.com> wrote:
> After making these changes, the program compiles, runs and gives what
> appears to be meaningful output both under g77 and g95 (modulo some
> noise in the output of the low order digits beyond the expected ~7
> significant figures).

and with gfortran....

Paul

On Apr 5, 5:51 am, paul.richard.tho@gmail.com wrote:

> On Apr 5, 7:13 am, "e p chandler" <e@juno.com> wrote:

> > On Apr 4, 11:57 pm, "thogy" <Richard.All@gmail.com> wrote:
> > After making these changes, the program compiles, runs and gives what
> > appears to be meaningful output both under g77 and g95 (modulo some
> > noise in the output of the low order digits beyond the expected ~7
> > significant figures).

> and with gfortran....

> Paul

It compiles, runs and produces similar output which differs from that
from g95 only in the result of

print *,'NN=',NN  ! DISPLAY PROGRESS

which includes extra spaces between the string and the value of NN.

Have we confused the OP enough yet?

-- elliot

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc