hyperion-rt / hyperion

Hyperion Radiative Transfer Code
http://www.hyperion-rt.org
BSD 2-Clause "Simplified" License
52 stars 26 forks source link

Initial implementation of the CMake build system #112

Closed bluescarni closed 9 years ago

bluescarni commented 10 years ago

I cleaned up the original implementation, integrated the support for ifort and added the sphinx documentation. I think this can be tested now.

astrofrog commented 10 years ago

Thanks! Will try this out on various machines

astrofrog commented 10 years ago

This is great! Just a few notes after testing it out:

FC=h5fc cmake ../

on my Mac, but not sure why. Would it be possible to tell cmake to use the h5fc or h5pfc 'compilers' rather than trying to call the compilers directly? (kind of like the current configure.ac does). Or do you think it can be fixed in another way?

-- Compiler id: Intel
-- Compiler flags:  -heap-arrays -error-limit 1 -fp-model strict -diag-disable 8291
-- Debug compiler flags: -g -heap-arrays -error-limit 1 -fp-model strict -diag-disable 8291 -check all -warn all -warn nodec -warn interfaces -gen_interfaces -traceback -g

However, should the debug flags not be shown only if the debug mode is active?

astrofrog commented 10 years ago

Just for the record, here's the command that fails on my mac:

/usr/bin/ifort      -heap-arrays -error-limit 1 -fp-model strict -diag-disable 8291 -O3 CMakeFiles/hyperion_amr.dir/fortranlib/src/base_types.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_messages.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_io.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_version.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_algebra.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_conf.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_array.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_statistics.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_random.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_hdf5.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/lib_constants.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/type_angle3d.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/type_vector3d.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/type_stokes.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/type_pdf.f90.o CMakeFiles/hyperion_amr.dir/src/core/type_photon.f90.o CMakeFiles/hyperion_amr.dir/src/main/settings.f90.o CMakeFiles/hyperion_amr.dir/src/main/performance.f90.o CMakeFiles/hyperion_amr.dir/src/images/image_type.f90.o CMakeFiles/hyperion_amr.dir/src/dust/dust_type_4elem.f90.o CMakeFiles/hyperion_amr.dir/src/dust/dust.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_physics_3d.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_monochromatic.f90.o CMakeFiles/hyperion_amr.dir/src/dust/dust_interact.f90.o CMakeFiles/hyperion_amr.dir/src/sources/source_type.f90.o CMakeFiles/hyperion_amr.dir/src/sources/source.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_propagate_3d.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_mrw_3d.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_pda_3d.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_generic.f90.o CMakeFiles/hyperion_amr.dir/src/images/images_binned.f90.o CMakeFiles/hyperion_amr.dir/src/images/images_peeled.f90.o CMakeFiles/hyperion_amr.dir/src/main/setup_rt.f90.o CMakeFiles/hyperion_amr.dir/src/main/iter_lucy.f90.o CMakeFiles/hyperion_amr.dir/src/main/iter_final.f90.o CMakeFiles/hyperion_amr.dir/src/main/iter_final_mono.f90.o CMakeFiles/hyperion_amr.dir/src/main/iter_raytracing.f90.o CMakeFiles/hyperion_amr.dir/src/main/main.f90.o CMakeFiles/hyperion_amr.dir/src/mpi/mpi_core_nompi.f90.o CMakeFiles/hyperion_amr.dir/fortranlib/src/posix_default.f90.o CMakeFiles/hyperion_amr.dir/src/core/core_lib.f90.o CMakeFiles/hyperion_amr.dir/src/main/counters.f90.o CMakeFiles/hyperion_amr.dir/src/mpi/mpi_io_nompi.f90.o CMakeFiles/hyperion_amr.dir/src/grid/type_grid_amr.f90.o CMakeFiles/hyperion_amr.dir/src/core/type_cell_id_amr.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_io_amr.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_geometry_amr.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_geometry_common_3d.f90.o CMakeFiles/hyperion_amr.dir/src/grid/grid_pda_disabled.f90.o CMakeFiles/hyperion_amr.dir/src/mpi/mpi_routines_nompi.f90.o  -o hyperion_amr  /Volumes/Raptor/usr/hyperion/lib/libhdf5_fortran.a /Volumes/Raptor/usr/hyperion/lib/libhdf5.dylib /Volumes/Raptor/usr/hyperion/lib/libz.dylib /usr/lib/libm.dylib 

and here's what flags h5fc uses, so we can check which ones are missing:

$ h5fc -show
ifort -I/Volumes/Raptor/usr/hyperion/include -L/Volumes/Raptor/usr/hyperion/lib /Volumes/Raptor/usr/hyperion/lib/libhdf5hl_fortran.a /Volumes/Raptor/usr/hyperion/lib/libhdf5_hl.a /Volumes/Raptor/usr/hyperion/lib/libhdf5_fortran.a /Volumes/Raptor/usr/hyperion/lib/libhdf5.a -L/Volumes/Raptor/usr/hyperion/lib -lz -lm
bluescarni commented 10 years ago

@astrofrog

  1. yes changing the default optimisation level is not a problem;
  2. I will move the doc;
  3. this is a bit tricky due to the way cmake works, it will try to guess the compiler based on the platform and the compiler variable itself cannot really be changed from the CMakeLists.txt as it is used to bootstrap the whole configuration phase. I would rather try to solve with the explicit linking of the missing libraries on OSX. Alternatively, I can write a small macro that calls the h5... compilers and checks which flags to enable;
  4. that line is a report message I added, it just helps to double-check how the compiler flags are assembled in the CMakeLists.txt logic. I can print the debug flags only in debug mode if you prefer :)
astrofrog commented 10 years ago

For 4, I don't actually mind if this is shown, but it would be nice to have a summary of what options will actually be used when I type 'make' (including for example the optimization flags). Is that possible?

bluescarni commented 10 years ago

Yep that should be no problem. Just need to get the HDF5 toolchain installed on the new setup and I will get to it.

bluescarni commented 10 years ago

@astrofrog I updated the pull request with the changes we discussed.

For the OSX part, it turns out the macro shipped with CMake for detecting HDF5 has a bug:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756108

So the fix at the moment is that I included the patched version of the macro, and this seems to work fine (I can now compile on OSX with both FC=ifort and FC=h5fc).

I also committed the fixes to the documentation and to the CMake output regarding compiler flags that we discussed earlier.

I rebased my branch off the current Hyperion master, if you added new files to Hyperion in the meantime I should add them in the CMake as well.

astrofrog commented 10 years ago

@bluescarni - ok, thanks! I'll do a final round of review/testing.

astrofrog commented 10 years ago

@bluescarni - this looks good and works great! Could you now just an an entry to the changelog to mention this? When you commit it, include [ci skip] at the end of the commit message to avoid running Travis.

astrofrog commented 9 years ago

@bluescarni - I merged this in manually (there were some issues with duplicate commits in this branch). Thanks for all your work on this!