(j3.2006) C1x standard

Bill Long longb
Thu Dec 22 12:36:10 EST 2011



On 12/22/11 4:20 AM, Van Snyder wrote:

>
> I am contending that it is not unusual to want to pass a string gotten
> using get_command_argument to a BIND(C) procedure that has a kind c_char
> argument, since that's the only character kind the standard provides for
> interoperability.

Remember that the only Fortran character that is interoperable with C is 
KIND=c_char AND LEN=1.  The string that you get back from 
get_command_argument will very likely not be LEN=1.  So you have to do 
some sort of munching of it before sending it to a C function even if 
the KIND is c_char.  (Like adding on the null character at the end).  If 
you have to do that, you might as well do any kind conversion at the 
same time.

I would contend that passing the string to a C function is unusual.  Far 
more likely, the argument is some action token that I would compare to a 
table of options within the Fortran program, and making that table 
default character would certainly be the natural choice.  Or the 
argument is a file name that I later use in an OPEN statement, which 
requires a default character kind.

I'm not convinced that the case you found is sufficient motivation to 
change the standard, especially since it would only reduce, and not 
eliminate, the conversion work that the programmer is required to do anyway.

Cheers,
Bill

-- 
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