JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2000

COMP-FORTRAN-90 2000

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Use of Modules in large Fortran applications

From:

Nils Jönsson <[log in to unmask]>

Reply-To:

Nils Jönsson <[log in to unmask]>

Date:

Mon, 06 Mar 2000 17:03:57 +0100

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (93 lines)


Harvey,

I missed the earlier discussion since I was then not subscribing to the list.
Here are some comments I have been stacking up during my own work.

For reasons of inter-procedural analysis that many compilers do within a
source code file it is often nice to group subroutines into files. This
grouping can also reflect some connection between these subroutines. (E.g.
ioroutines.f90, preanal.f90, solving.f90, utils.f90 etc.) As a project
grows - and in particular if you inherit someone else's large F77 project
there may not be one-directional dependencies between these files. I.e. you
are not able to make each of these files into one module that contains the
subroutines. The reason being that would you create module ioroutines and
module module utils it turns out that routines in utils are USEing routines
in module utils and other routines in module utils are USEing routines in
module ioroutines. When the number of routines are in the order of several
hundreds it becomes cumbersome to sort this out. There are three major lines
taken I guess:

1) Make each subroutine its own module in its own source code file. This 
   disables many optimizations like e.g. inlining for compilers that do 
   not have good support for  cross source-file optimizations. On the other 
   hand it is fairly straightforward to write a Makefile that has the correct 
   dependencies for creating both .mod and .o files. Apart from possible
   compiler optimizations bing lost the structure of the program is also 
   lost as logically connected routines are not longer grouped together in
   source files.

2) Make each subroutine its own module but keeping them in the same source
   code file as earlier. This solution has the same draw-back as the outline
   above that you may find yourself in situations where you can't compile 
   any of files A.f90 and B.f90 before the other as they depend on module
   information from the other file. Makefile construction is harder in this
   case - in particular writing a Makefile that is portable.

3) Keep the subroutines in the original file and write a separate file
   containing a module with the corresponding interfaces for the routines.
   This module is then USEd by each unit that needs to call a routine in
   the file. The win is that the files containing the interfaces can be
   compiled first and the USEd in the compilation of the actual routines.
   The loss is that it is even more of a challenge to write a correct Makefile
   and keep it up to date with code changes. Also, of course, keeping the
   interfaces consistent with the subroutines in question is a pain.

There are tools that tries to aid you in keeping interfaces consistent as well
as keeping Makefile dependencies correct. Being rather dependent on the CPP
pre-processor in most of my major projects it is not so easy to use these tools
though. Most compilers today support natively the use of CPP processed files.
If these compilers included options for writing interfaces and/or dependencies
life would be a lot easier. I am not requesting that they should be able to
write interfaces for the general case - if they wrote the interface for the
CPP-flags submitted to the compiler it would be useful enough. And aiming for 
more than that would probably cause the interfaces to become un-useable or at 
least un-readable.

In the mean time I think the language would gain if it included the following:

1) If it would be allowed to include the interface declaration for a subroutine
   in the subroutine definition itself. And that the language enforces that if
   this is done the interface  information must be used to verify that the 
   subroutine definition and the interface are consistent.

2) That the language included a recommendation that compilers supported an option
   for treating all subroutine references without an explicit interface as a
   compile time error. (Because it is a pain when you find out that there is
   a call somewhere that is incorrect, but there was no inclusion of the correct
   interface in that unit)

I find tools that automatically write interfaces etc extremely useful today 
to create the first version of interface definitions. However, since I tend
to use CPP to separate e.g. serial and parallel versions and/or 2D and 3D 
versions of a code, I find myself doing incremental modifications manually
most of the time. Or, I run the code through CPP to generate ONE version of
the code that I then use to create interfaces/dependencies whereafter I sit
down and insert the #ifdef's needed for the other cases by hand.

Those are my on-top-of-the-head opinions on your question.

/Nils

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   Nils Jönsson                      http://www.pdc.kth.se/
   Center for Parallel Computers     e-mail: [log in to unmask]
   Royal Institute of Technology     Voice:  +46-8-7909115
   KTH                               Fax:    +46-8-247784 
   S-100 44 Stockholm, Sweden        Office: OB2, room 1546
-----------------------------------------------------------------------



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager