(j3.2006) A few constants from ISO_Fortran_env for C interop
Bill Long
longb
Mon Oct 24 18:51:09 EDT 2011
On 10/24/11 2:53 PM, Van Snyder wrote:
>
> On Mon, 2011-10-24 at 12:00 -0700, Bill Long wrote:
>> Alternatively, a user-written module, that has a USE of
>> ISO_Fortran_env, could be supplied that declared bind(c) variables
>> that were initialized to these constants. Then the C user could just
>> reference the variables directly. You might name them Fortran_stdout
>> and Fortran_stderr, for example.
>
> The variables aren't constants that a C function can use for
> initialization. So this is a little better than (or not quite as good
> as, depending upon your viewpoint) using a BIND(C) subroutine to set the
> values.
>
I don't see how initialization in C is relevant here. The C programmer
is only going to pass these values back to a Fortran program as actual
arguments in calls. The numerical values of the unit numbers are
pointless to a C programmer.
> Fortran programmers have maybe been spoiled by having default
> initialization.
>
And also lead to poor programming practice through excessive use of
default initialization. Particularly of components.
> I don't see enough C code to know how comfortable the average C
> programmer is with instructions to call several initialization functions
> before calling the one that does what he actually wants done. Is it
The global variables avoid that problem. No initialization functions
involved.
Cheers,
Bill
> common and tolerated, and recognized that failing to do the
> initialization properly is a source for obscure bugs?
>
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
More information about the J3
mailing list