Re: Huge program, no interfaces, ugh



On 2007-01-31 13:01:36 -0400, "Ancient_Hacker" <grg2@xxxxxxxxxxx> said:

HI, I have this relatively huge program, about 40,000 lines in 183
source files.

I've found lots of errors in the source code caused by arguments that
don't match the subroutine dummy argument type.

But the compiler doesnt find many of these by itself, as none of the
subroutines had interfaces (to start out with). I'm building up
interfaces as I go along, but the task is error-prone-- if I forget to
add "use glue" to a subroutine, it will silently compile anyway and
generate bad calls.

It sure would be nice if the compiler required interfaces for every
called function or subroutine.

Is there some Fortran option to require these?

Thanks,

grg

A way to get there with a small amount of work is to make everything
into CONTAINed units. You end up with

program all_of_it
implicit none

call old_main

contains

subroutine old_main ! which used to be program main
...
end subroutine ! use a text editor to turn END into END SUBROUTINE

subroutine xxx
...
end subroutine ! use a text editor to turn END into END SUBROUTINE

function yyy
...
end function ! use a text editor to turn END into END FUNCTION

end

and note a couple gotchas
1. external units don't work as you can not pass the
internal units as arguements
2. external statments need to be taken out
as they force things to not be internal.
To bad as an otherwise good style bites.
3. no declarations at all before the CONTAINs to
keep from accidental host associations for undeclared variables.
But then you have implicit none everywhere don't you!

All this may solve your problems if you do not have the gotchas. They
can be worked around. You will need lots of include statements and fixing
all the ENDs is a bother. But you have to choose what is the least fuss
to get the F90 checking. Do it on a copy etc, etc.

When you are done it will be time to make up various modules of groups
of your units.






.



Relevant Pages

  • Re: DPROD issues
    ... a switch like that typically ... makes a compiler nonstandard in that mode. ... treatment of specific intrinsics is one ... subroutine sub1a ...
    (comp.lang.fortran)
  • Re: Jumping into block of an if construct
    ... (For that matter a clever enough compiler could replace this PUT DATA ... routine which itself executes the loops around element handling. ... Either way I think the cost of element handling will usually ... So locally based on subroutine arguments, but not on, for example, ...
    (comp.lang.fortran)
  • Re: Bus error/ segmentation fault--help?
    ... When I compile with the intel fortran compiler, ... This subroutine integrates the function y3 up one step, ... implicit double precision (a-h, o-z) ...
    (comp.lang.fortran)
  • Re: Question about name conflicts in Fortran
    ... I am hacking the g95 compiler so that it dumps the structure ... Subroutine foo ... The para after the 2nd numbered list in 16.2 covers the case where the ... One of the exceptions is "a generic name may be the ...
    (comp.lang.fortran)
  • Re: using dot_product from c++
    ... I tried to write a very simple subroutine where two vector are dot ... Assumed shape arrays are incompatible with mixed language use unless you code explicitly for the descriptor on the other side, which will be highly nonportable (even from one version of a compiler to another, let alone from one compiler to another). ... You should either not initialize the vectors or you should not use push_back but instead reference the location you wish to access directly. ... I guess maybe it arises because the misunderstandings between the codes multiply to put the memory manager out of whack. ...
    (comp.lang.fortran)