J3/04-121 Date: 10 Dec. 2003 To: J3 From: Dan Nagle Subject: Finding Logical and Character Kinds Despite years of thought and some discussions, no way has been discovered to define a SELECTED_LOG_KIND function, probably because true is true and false is false and that is that. But a programmer may want to portably set logical kind. Also, character kinds are set via names but kinds not specified in the standard have no guaranteed to be portable name. No way other than blind search for names is possible under Fortran 2003. Number: Title: LOGICAL AND CHARACTER Kinds Available Submitted By: J3 Status: For Consideration References: Basic Functionality: Provide a way to find all character and logical kinds a processor supports to allow a program or an automatic code generator to make a fully informed choice of kinds. Rationale: A program may want to use the smallest logical kind available, say for a randomly addressed array not updated frequently but sharing cache with work arrays. A program may have distinct preferences for character set. But there's no way at present for a program to discover what these kind values are. I know of no suggestion for a SELECTED_LOG_KIND, and SELECTED_CHAR_KIND relies on names (character strings) making a search impossible. Furthermore, the number of character sets with standard-specified names is small. A compiler desiring to interoperate with MS .NET, for example, may want to use Unicode-16. But what's the name for SELECTED_CHAR_KIND? "UTF-16", "Unicode_16"? "ISO_something or other"? Estimated Impact: I estimate the impact of these features is low, as compilers know what kinds they support and, in the case of character kinds, by what name they select them. Detailed Specification: Arrays be added to ISO_FORTRAN_ENV defined to include the kind values of supported logical kinds and the names recognized by SELECTED_CHAR_KIND. The array of logical kinds should be defined so that kinds occur in order of increasing size. These declarations might appear as follows in user-written code: integer, parameter, dimension( ???) :: & logical_kinds = ... character( len= *), parameter, dimension( ??? ) :: & character_kinds = ... Examples: ! choose smallest logical kind logical( kind= logical_kinds( 1)), dimension( large) & :: mask ! print all character kinds write( output_unit, *) character_kinds History: