Getting ready

In this recipe, we will work with the following example Fortran code (example.f90):

program example  implicit none  real(8) :: array(20000000)  real(8) :: r  integer :: i  do i = 1, size(array)    call random_number(r)    array(i) = r  end do  print *, sum(array)end program

The fact that this is Fortran code does not matter much for the discussion that will follow, but we have chosen Fortran since there is a lot of legacy Fortran code out there where static size allocations are an issue.

In this code, we define an array holding 20,000,000 double precision floats, and we expect this array to occupy 160 MB of memory. What we have done here is not recommended programming practice, since in general this memory will be consumed independently ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.