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

Yngve Inntjore Levinsen yngve.levinsen at gmail.com
Fri Sep 20 05:49:16 EDT 2013


Hi Zaak,

Based on the test for fortran compilers, couldn't you do something similar?

As I am no fortran expert I am not really sure which types you are
looking for, but I would suspect you could get what you want based on
the attached example?

Cheers,
Yngve

Den 19. sep. 2013 22:03, skrev Zaak Beekman:
> Caveat: I am somewhat new to CMake.
>
> I am programming a library to compute diagnostic statistics on VERY
> large data sets. (Possibly in parallel too.) The algorithm is
> numerically stable and online/streaming. The Fortran standard makes no
> guarantee of what (signed) integer types are available on a given
> system, but provides a means of requesting integers of different sizes
> and will let you know at run time whether or not they exist. However,
> kind (type) specification of variables must occur at compile time.
> (This isn't strictly true in F03/F08 but compiler support is limited
> ATM.) Since the algorithm is designed for extremely large data sets
> (9TB!) and the number of elements visited in the set so far appears in
> the algorithm, I would like to use the largest available integer kind
> to keep track of this quantity so that it doesn't overflow.
>
> I think what I need to do is create a test program and use try_run()
> and then configure_file(), which leads me to my questions:
>
>  1. Can I have a multiple source file program and pass it to
>     try_run()? It seems like the answer is no.
>  2. Since Fortran has no concept of a return value (not formally as
>     far as the standard is concerned) it looks like I need to pass the
>     information about available kind types in the RUN_OUTPUT_VARIABLE
>     back to CMake and manipulate it there. Does this variable just get
>     populated with a string which is whatever your code (that you
>     try_ran) outputs to stdout?
>  3. Has someone written a module to diagnose available Fortran kind
>     types? That they're willing to share?
>  4. If not, where do I look for advice and best practices to write one
>     myself?
>
> TIA,
> Izaak Beekman
> ===================================
> (301)244-9367
> Princeton University Doctoral Candidate
> Mechanical and Aerospace Engineering
> ibeekman at princeton.edu <mailto:ibeekman at princeton.edu>
>
> UMD-CP Visiting Graduate Student
> Aerospace Engineering
> ibeekman at umiacs.umd.edu <mailto:ibeekman at umiacs.umd.edu>
> ibeekman at umd.edu <mailto:ibeekman at umd.edu>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130920/16096c3d/attachment-0001.htm>
-------------- next part --------------
cmake_minimum_required(VERSION 2.8)

project(test_fortran_integers Fortran)


macro(test_integer i)
  message("Checking for integer*${i}..")
  set(filename ${CMAKE_BINARY_DIR}/test_integer_${i}.f)
  file(WRITE  ${filename} "      program main\n")
  file(APPEND ${filename} "      integer*${i} myinteger\n")
  file(APPEND ${filename} "      end program main\n")
  try_compile(HAVE_INTEGER_${i} ${CMAKE_BINARY_DIR}
     ${filename})
  message("Checking for integer*${i}.. ${HAVE_INTEGER_${i}}")
endmacro()

test_integer(2)
test_integer(4)
test_integer(6)



More information about the CMake mailing list