Re: function prototypes

From: TimC (tconnors_at_no.astro.spam.swin.accepted.edu.here.au)
Date: 05/11/04


Date: Tue, 11 May 2004 01:08:33 GMT

Michael Metcalf (aka Bruce) was almost, but not quite, entirely unlike tea:
>
> "Richard Maine" <nospam@see.signature> wrote in message
> news:m1vfj4s3h9.fsf@macfortran.local...
>> Write all procedures as module procedures instead of external ones.
>> Then you get the checking of function proptotypes without actually
>> having to writ ethe prototypes. In essence, the compiler writes them
>> for you. Besides saving effort, this has the *HUGE* advantage that
>> the prototype and the procedure will actually agree.

Every now and then, I come across a subtle bug in my old f77 code,
that I just cannot work out. This is my cue to convert the routines
involved into F90.

I run a couple of emacs macros over the code (I think I tried
convert.f90 at one stage, and ran into some sort of problem - possibly
the fact that the code never was pure F77 - it used F90 comments
sometimes, and a few other oddities) to get free-format code, then I
wrap the module nicities around it.

But only yesterday, it came to link stage after fixing all the calls
to old routines in redundant code, and there were millions of
unresolved functions at link time. Arrrrh! After much hair pulling, I
realised I forgot all the "Use convertlbxy".

Found a couple of potential bugs, but not the ones that are crashing
my code, alas.

> Yes, but if just dumping f77 code into a new module, the user MUST remember
> to add, as a minimum, either function or subroutine, as appropriate, to each
> subprogram end statement. A bind.

If I am understanding you correct, you mean the last line in:
  FUNCTION rsqr(val)
    IMPLICIT NONE

    REAL, INTENT(IN) :: val
    REAL rsqr

    rsqr=val*val
    RETURN
  END FUNCTION rsqr

Luckily for me, the act of pressing 'tab' in emacs automatically does
the pretty printing and the format of the last line, and a few other
things. And repeatedly pressing tab is part of my macro :)

-- 
TimC -- http://astronomy.swin.edu.au/staff/tconnors/
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.