Re: common from fortran77 to fortran 90
- From: "Colin Watters" <qolin.see_signature@xxxxxxxxxxxxx>
- Date: Tue, 13 Feb 2007 23:33:25 -0000
"aeroguy" <sukhbinder.singh@xxxxxxxxx> wrote in message
news:1171365117.913122.276860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all
I am working on a project to convert FORTRAN 77 code to FORTRAN 90.The
program is huge and contains 60+ subroutines with numerous common
statements, can anyone suggest how I convert this common clutter into
a global module.
Hope someone in the group must have done something like this, your
experience, suggestion and comments are welcome.
Thanks for your time and consideration
I too have been doing this recently, and I discovered a Really Useful Trick.
(Well doubtless I didn't discover it myself, I must have read it somewhere,
quite possibly here, I forget.)
It is possible to access the SAME variables from Common and from a module. A
module can contain COMMON statements. This simple fact allows you to convert
the code step-by-step, testing all the time, and maintaining a working code
throughout.
So this is what you do:
Create a new module, and have it contain all the COMMON statements and
associated declarations. If the COMMONS are all in INCLUDE files this is
easy, if not then it will take a few hours longer. Compile the new module,
include it in the link script, link and test, to verify this step has not
changed the answers.
Now choose the first routine to be converted. If it doesn't have IMPLICIT
NONE, then add this, and add all necessarry declarations to get a clean
compile. Now insert a USE statement, and remove all common statements and
associated declarations. Compile/link/test, verify the answers do not
change.
Do this on every other routine, testing as you go. At any stage in this
process, you can get fancy: use the ONLY clause to restrict access to just
the variables that are actually needed.
If you find that the common statements are not identical across routines,
you can use the USE statement's local renaming feature, eg:
USE fred_mod, only: sid=>sidney
allows the local name SID to access the module's name SIDNEY.
It is a matter of taste and preference whether to use one module, or many. I
prefer one, since the ONLY clause allows access to just the required
variables.
Eventually you will have converted all the routines, and the only place
where COMMON statements will still exist will be in the module. At this
stage they can be removed.
Morceau de gateau, n'est-ce pas?
Qolin
Email: my qname at domain
Domain: qomputing dot demon dot co dot uk
.
- Follow-Ups:
- Re: common from fortran77 to fortran 90
- From: aeroguy
- Re: common from fortran77 to fortran 90
- References:
- common from fortran77 to fortran 90
- From: aeroguy
- common from fortran77 to fortran 90
- Prev by Date: Substring in DATA implied-do
- Next by Date: Re: Substring in DATA implied-do
- Previous by thread: Re: common from fortran77 to fortran 90
- Next by thread: Re: common from fortran77 to fortran 90
- Index(es):
Relevant Pages
|