On Tue, 30 Aug 2005, Peter W. Draper wrote:
> On Fri, 26 Aug 2005, Tim Jenness wrote:
>
>> g95 seems to require that all C programs that go through C main initialise
>> the RTL, else I get core dumps everywhere. (maybe that's a bug in g95 but
>> it cores in memory allocation routines and in Fortran I/O. g77 only seems
>> to need argument lists initalised)
>
> Tim,
>
> that's a documented feature of g95, see:
>
> http://g95.org/docs.html
>
> down at the bottom "Interfacing with g95 programs".
>
> For C calling fortran subroutines, the fortran subroutines will often
> call fortran library subroutines that expect the heap to be initialized
> in some way.
>
> so calling g95_runtime_start() is clearly a requirement.
but strangely, I get a core dump from specx through the MAIN_ so that is
odd.
Anyway, do you have any thoughts on standardising on cnfInitRTL or would
you prefer each C routine to use STAR_INITIALISE_FORTRAN? Similarly for
the cnfStopRTL equivalent.
>
>> I'd also like to sort out the AC_FC_MAIN issue since g95 requires this
>> symbol to be present even if it is just a stub. Maybe something along the
>> lines of
>>
>> #if AC_FC_MAIN != main
>> void AC_FC_MAIN () {}
>> #endif
>>
>> would do the trick?
>
> I wondered if it would be better to say define the default function
> returned by FC_MAIN:
>
> FC_MAIN([pkg_dummy_main])
>
> the default being as now (main).
>
That would work but you would still need to compare the result with what
you put in. The best idea is to undef FC_MAIN completely but that is
seriously bad for backwards compatibility (although it's not clear how
useful it is at the moment).
g95 forces me to do something though since I have to decide whether I'm
using a Fortran main (so don't need cnfInitRTL) or whether I'm using a C
main (and so I do need cnfInitRTL) but all whilst making sure that even if
I'm using a C main I still need to define MAIN_ for g95...
--
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj
|