This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A couple of FORTRAN porting questions for g77


Janis Johnson wrote:

[ Thanks, Janis, that was a good try at it - now that I'm online again
  I'll try to augment it ]

> On Fri, Jun 07, 2002 at 08:50:18AM -1300, Howard Chiger, hchiger@ttinet.com wrote:

> > 2) I use many PARAMETER statements and always use an IMPLICIT NONE, e.g.,
> >
> >       IMPLICIT NONE
> >       PARAMETER NDIM=100
> >
> > g77 requires the PARAMETER be typed implicitly:
> >
> >       PARAMETER (NDIM=100)
> >
> > and doesn't seem to allow it to be typed.  Thus I have had to remove the
> > IMPLICIT NONE in each routine to get it to compile.  This is an acceptable
> > workaround, especially since the codes are pretty static in their
> > development.  But I feel naked without my IMPLICIT NONE statement.
> > Is there a different workaround?
> 
> The right way to do this (not a workaround) is to declare the type of
> each PARAMETER, just as you would for variables:
> 
>       IMPLICIT NONE
>       INTEGER NDIM
>       PARAMETER (NDIM=100)
>       COMPLEX ZERO
>       PARAMETER (ZERO=(0.0, 0.0))

Correct.  The problem is that a lot of compilers support the

      PARAMETER NDIM=100

form, which is not Standard-conformant.  Aside from missing the
parentheses, it also has a slightly different meaning - it picks up the
type of the "PARAMETER" (NDIM in this case) from the type of the
constant (100 here).  This type happens to be "default INTEGER",
wherefore this will work with IMPLICIT NONE.

Indeed, g77 doesn't support the above form - see:

http://gcc.gnu.org/onlinedocs/gcc-3.1/g77/Old-style-PARAMETER-Statements.html#Old-style%20PARAMETER%20Statements

> > 3) I also need to be able to feed the program input command line
> > parameters.

> I don't know about this one.  Nothing you do here is likely to be
> portable from one operating system to another.

Strictly speaking, this is true, but a lot of Fortran compilers on Unix
systems support the following command line argument passing model:

IARGC - function returning the number of command line arguments:

http://gcc.gnu.org/onlinedocs/gcc-3.1/g77/IArgC-Intrinsic.html#IArgC%20Intrinsic

GETARG - subroutine giving you the I'th command line argument as a
string:

http://gcc.gnu.org/onlinedocs/gcc-3.1/g77/GetArg-Intrinsic.html#GetArg%20Intrinsic

> > Again, let me apologize for contacting you directly, but I can't think
> > of anyone else at this point.  I would greatly appreciate any help
> > you can give me.  And though I basically do all my work in C now,
> > I still think of FORTRAN as my first language and don't want to see
> > it relegated to relic or obsolete status.  If there is anything I
> > can do to help you, be it code development or testing, please do not
> > hesitate to ask me.
> 
> Find a Fortran 77 book; I did this recently and discovered that book
> stores that sell new books don't seem to carry them, but my local used
> techical book store had a good selection, although they were all rather
> musty.
> >
> > Thanks again,
> > Howard Chiger
> > San Diego, CA
> > hchiger@ttinet.com

Another approach is this free (because free of licensing rights) book:

http://www.star.le.ac.uk/~cgp/prof77.html

> Janis (whose first language was Fortran)

Doh - my first language was Dutch !

Most scary message from the flight deck ever:

"We running into a short delay here, because we found a small part of
this machine broke; we've never even heard of this part and there don't
seem to be spares for it, so our technicians are trying to fix it on the
spot."

No, I won't name names here :-)

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]