Re: common from fortran77 to fortran 90




"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


.



Relevant Pages

  • Re: How to decide using COMMON block variables or function/subroutine parameters?
    ... In compressor design there are several variables that ARE common to just ... about every calculation - inlet gas properties, shaft speed, desired ... I'd tend to pass variables through 'globals' rather than as ... anything that the routine is going to change, ...
    (comp.lang.fortran)
  • Re: Fortran Standard question: COMMON, SAVE and EQUIVALENCE
    ... it didn't dawn on me until later there is one thing I don't follow in the Silverfrost warnings -- perhaps that was your point of confusion as well and I misinterpreted the question raised. ... The size of the extended blank common is given as "size 40 but is now ... Then one could write a routine that would the dump the ...
    (comp.lang.fortran)
  • Re: Can this be automated in the VBE?
    ... My first impression was that it was a routine to create a table. ... considered suggesting that you find and tally the most common uses (common ... OpenDB strDB, True ... indexes on the SQLite table, ...
    (microsoft.public.vb.general.discussion)
  • Re: Looking for 7-parm least squares code
    ... "glen herrmannsfeldt" wrote in message ... COMMON Q ... THEN THIS ROUTINE IS CALLED k TIMES TO PASS THE kth VALUES ... C (XN IS THE INPUT VARIABLE AVERAGE; ITS WEIGHT IS W) ...
    (comp.lang.fortran)
  • Re: how to crash an app
    ... Crackers will look for common used jump points, ... If every routine uses a different approach it will ... The crc numbers should be created from different ...
    (borland.public.delphi.language.basm)