[comp.lang.fortran] implicit none

davis@pacific.mps.ohio-state.edu ("John E. Davis") (08/03/90)

Hi,
  VMS fortran has an extension to fortran that forces me to declare all
variable. It is the statement 'implicit none'.  This is a great construct and
I refuse to program fortran on machines that do not support something like
this.  I was wondering if this will be a part of Fortran 90.  Also, what is
the best way to simulate this effect?

Thanks,

--
John

  bitnet: davis@ohstpy
internet: davis@pacific.mps.ohio-state.edu

levine@crimee.ics.uci.edu (David Levine) (08/03/90)

John E. Davis writes:

>  VMS fortran has an extension to fortran that forces me to declare all

>this.  I was wondering if this will be a part of Fortran 90.  Also, what is
>the best way to simulate this effect?

Yes, it is included in Fortran 90.

Many compilers give the same effect with a command line option, e.g.,

VMS: /warn=declare or /warn=all
Microsoft: /4Yd
Sun (and many other UNIX) f77:  -u

I prefer the command line option, if available.  No code changes
are required if you ever have to port to a compiler that doesn't
support IMPLICIT NONE.

David L. Levine, Dept. of ICS             Internet: levine@ics.uci.edu
University of California, Irvine                BITNET: levine@ucivmsa
Irvine, CA 92717                            UUCP: ucbvax!ucivax!levine

cox@lanl.gov (Robert W. Cox) (08/03/90)

From article <26B8B79D.15026@ics.uci.edu>, by levine@crimee.ics.uci.edu (David Levine):
> I prefer the command line option, if available.  No code changes
> are required if you ever have to port to a compiler that doesn't
> support IMPLICIT NONE.

 Not always (unfortunately)!  Not all compilers are perfect, by any means.
 I've used a FORTRAN compiler that produced incorrect object code if you
 explicitly declared a variable to be its default type, such as

    REAL X
    INTEGER I

 As you can imagine, this is annoying and hard to discover.  And makes
 converting from IMPLICIT NONE annoying as well.  Not that I don't
 advocate IMPLICIT NONE -- when someone comes to me with a code that
 doesn't work, the first thing I tell them to do is to declare all
 variables and try again.  This has one advantage:  they go away for
 a while, and it sometimes even fixes their program!

Bob Cox
cox@lanl.gov

jeyadev@rocksanne.uucp (08/04/90)

In article <DAVIS.90Aug2182115@pacific.mps.ohio-state.edu> davis@pacific.mps.ohio-state.edu  (John E. Davis) writes:
>Hi,
>  VMS fortran has an extension to fortran that forces me to declare all
>variable. It is the statement 'implicit none'.  This is a great construct and
>I refuse to program fortran on machines that do not support something like
>this.  I was wondering if this will be a part of Fortran 90.  Also, what is
>the best way to simulate this effect?
>

I do hope that it will become part of standard. I have not done a lot of
Fortran work on VMS, and I was unaware of this facility till a ffew days
ago. However, I have saved a lot of time, by forcing declarations by putting
the statement 

    implicit logical (a-z) 

above all the other declarations. This catches the errors that arise from
the mistyping of variable names -- my favourite failure mode!

--

Surendar Jeyadev	Internet: jeyadev.wbst128@xerox.com
           
Time is just nature's way of keeping everything from happening all at once

peterson@fman.enet.dec.com (Bob Peterson) (08/04/90)

In ye olde days one could approximate the effect
with:
	IMPLICIT LOGICAL (A-Z)

Mind you I find IMPLICIT NONE best.

staff@cadlab.sublink.ORG (Alex Martelli) (08/11/90)

levine@crimee.ics.uci.edu (David Levine) writes:
>John E. Davis writes:
>>  VMS fortran has an extension to fortran that forces me to declare all
>>this.  I was wondering if this will be a part of Fortran 90.  Also, what is
>>the best way to simulate this effect?
>Yes, it is included in Fortran 90.
>Many compilers give the same effect with a command line option, e.g.,

Also, many f77 implementations use "IMPLICIT UNDEFINED A-Z", as 
documented in the original f77 paper.  I just thought I'd mention this
since I've heard people complain that, say, IBM RT f77 had "no way to
force declaration" - just because it has IMPLICIT UNDEFINED rather than
IMPLICIT NONE...!

-- 
Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 45, Bologna, Italia
Email: (work:) staff@cadlab.sublink.org, (home:) alex@am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only; any time of day or night).

jlhaferman@l_eld09.icaen.uiowa.edu (Jeffrey Lawrence Haferman) (08/13/90)

From article <246@cadlab.sublink.ORG>, by staff@cadlab.sublink.ORG (Alex Martelli):
> levine@crimee.ics.uci.edu (David Levine) writes:
>>John E. Davis writes:
>>>  VMS fortran has an extension to fortran that forces me to declare all
>>>this.  I was wondering if this will be a part of Fortran 90.  Also, what is
>>>the best way to simulate this effect?
>>Yes, it is included in Fortran 90.
>>Many compilers give the same effect with a command line option, e.g.,
> 
> Also, many f77 implementations use "IMPLICIT UNDEFINED A-Z", as 
> documented in the original f77 paper.  I just thought I'd mention this
> since I've heard people complain that, say, IBM RT f77 had "no way to
> force declaration" - just because it has IMPLICIT UNDEFINED rather than
> IMPLICIT NONE...!
> 

A trick that I've heard for forcing declarations in f77 is to come up with
a standard such as all LOGICALs must begin with Q.  Then declare

  IMPLICIT LOGICAL A-P,R-Z
  IMPLICIT REAL Q

This will work pretty well if you don't use a lot of LOGICALs.  Of course,
it would work best to choose the letter least likely to be used for a
variable name to choose as the IMPLICIT LOGICAL.  This is a kludge, but
might be handy to some.


Jeff Haferman                            internet: jlhaferman@icaen.uiowa.edu
Department of Mechanical Engineering
University of Iowa
Iowa City IA  52240