(j3.2006) A few constants from ISO_Fortran_env for C interop
Bill Long
longb
Mon Oct 24 15:00:58 EDT 2011
On 10/24/11 1:43 PM, Van Snyder wrote:
> One of my colleagues is working on some software that needs to be told
> the Fortran I/O unit to which output should be written.
>
> For two of the destinations, he wants the defaults to be OUTPUT_UNIT and
> ERROR_UNIT from ISO_Fortran_env.
>
> The unit numbers are set in a structure.
>
> He'd like to be able to use the code from C, so he's written a BIND(C)
> interface layer.
>
> A question he asked, that I couldn't answer, is how the C program knows
> the values of OUTPUT_UNIT and ERROR_UNIT.
>
> Should we add these values (and maybe a few more from ISO_Fortran_env)
> to ISO_Fortran_binding.h?
No. This is an extreme end case, and I'm not keen on piling stuff into
ISO_Fortran_binding.h for single users. Also, it is generally better
for maintenance to avoid having constants defined in multiple places.
>
> An alternative is to ask the C caller to call a BIND(C) Fortran
> procedure that returns the values. That seems a bit like a kluge.
>
That would be a better solution. 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.
Cheers,
Bill
>
> _______________________________________________
> 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