[CMake] try_run or similar to find available Fortran integer kinds

Zaak Beekman zbeekman at gmail.com
Fri Sep 20 12:16:11 EDT 2013


On Fri, Sep 20, 2013 at 12:00 PM, <cmake-request at cmake.org> wrote:

> Is your original
> message saying that a Fortran compiler might compile
>
>  integer*8 myinteger
>
> but fail at runtime?
>

No, my point is that there is no guarantee that integer*8 or integer*16
exist at all (at compile time) but you can query whether or not they exist
at run time. However, you cannot dynamically pick the integer type of a
variable at run time.

For example, you can write code to request progressively larger integer
kinds and return their kind if they exist, at run time. If they don't exist
an error value is returned instead. However, the integer kind of a variable
must be specified at compile time, so there is (currently) no viable way to
dynamically select a variable's integer type. (Unlimited polymorphic
variables and parameterized derived types fix these issues, but compiler
support is spotty for the former and non-existent for the latter, and will
take a long time to change.)

To summarize the issue: Variable's integer kind type must be a compile time
constant (currently) AND checks to determine what integer types are
supported are run time only.

It seems the array variable integer_kinds supplied in ISO_FORTRAN_ENV by
the F2008 standard partially circumvents this issue, but, to my knowledge,
there is no guarantee in the standard that the array holds the available
integer kinds in a sorted order with the smallest integer kind as
integer_kinds(1) and the largest as integer_kinds(size(integer_kinds)), but
this would seem to be a reasonable assumption. I still am determining
compiler support/compliance for this F2008 feature.

Izaak Beekman
===================================
(301)244-9367
Princeton University Doctoral Candidate
Mechanical and Aerospace Engineering
ibeekman at princeton.edu

UMD-CP Visiting Graduate Student
Aerospace Engineering
ibeekman at umiacs.umd.edu
ibeekman at umd.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130920/ff454fe9/attachment.htm>


More information about the CMake mailing list