Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!boise.Eng.Sun.COM!wsb From: wsb@boise.Eng.Sun.COM (Walt Brainerd) Newsgroups: comp.lang.fortran Subject: Re: Is the INCLUDE statement standard? Summary: More on INCLUDE/USE Message-ID: <141585@sun.Eng.Sun.COM> Date: 30 Aug 90 17:50:14 GMT References: <1990Aug29.160951.19827@athena.mit.edu> <1990Aug30.105748.19204@cs.dal.ca> Sender: news@sun.Eng.Sun.COM Lines: 59 In article <1990Aug30.105748.19204@cs.dal.ca>, silvert@cs.dal.ca (Bill Silvert) writes: > Most compilers support INCLUDE, but with different formats. ... > ... > along with variants of the F-90 (?) USE command. Since it was only mentioned briefly, I thought I would expand a bit on the MODULE and USE of Fortran 90. The main fact is that these will do everything (and much more) that INCLUDE will do. (This won't help any until you get your Fortran 90 compiler.) And whether to include INCLUDE in Fortran 90 provides an interesting case study. Perhaps you will let folks on X3J3 know which way you feel about doing things like this in the future. Those who think that standards should (only???) codify "existing practice", felt that INCLDUE is an obvious example, since, as has been pointed out, virtually every compiler has an INCLUDE facility. However, as has been mentioned, some do it as a statement and some as a preprocessor (or compiler directive), some start in column 1 and some in column 7, some allow nested INCLUDEs and some don't, and there are many, many other small subtle things like whether it is permissible to have part of a Fortran statement in an INCLUDE and continue the statement in another INCLUDE or the including text. Those opposed to including INCLUDE argued that a) it won't standardize existing practice, because existing implementations are all different (even though, as R. Maine points out, it is easy to transform the syntax, it is not always easy to try to handle all the different rules and restrictions that vary from one implementation to another) and b) it is already (in F90) redundant given the MODULE/USE facility. The "compromise" was to put INCLUDE into Fortran 90, but make it very restrictive in the hope of matching the intersection of some of the many different implementations. Because of the redundancy, it is already a candidate for the "obsolete features" list! Perhaps you can guess how I feel about this. (The question is not whether it _useful_ when writing Fortran 77 programs; it is whether it should be _standardized_, requiring every implementation to conform to the description in the standard, which probably conflicts with what they have already, for the next 30-30,000 years, even if its usefulness ends.) As Maine also pointed out, one of the common(!) uses of INCLUDE is to make sure that your COMMON blocks match exactly in all routines that use them. In order to facilitate migration of existing programs to Fortran 90, it is possible to put COMMON blocks in a module. So, it is possible to take the instances of the COMMON blocks in your INCLUDE file and put MODULE-END MODULE around them and replace the INCLUDE statement with a USE statement. You may find, if your implementation of F90 is even a little bit clever, that the delcarations in the module will be "precompiled" and won't have to be reprocessed in each routine using them, as is the case with INCLUDEd text. Using modules to do really great things is the subject of a longer and more interesting story. -- Walt Brainerd Sun Microsystems, Inc. wsb@eng.sun.com MS MTV 5-40 Mountain View, CA 94043 415/336-5991