From 8194bb4596c31e9edc73f5362afd779f9b87956b Mon Sep 17 00:00:00 2001 From: John Helly Date: Thu, 29 Jun 2023 12:40:36 +0100 Subject: [PATCH 1/5] Fix compilation without HDF5 --- main/src/Makefile.am | 2 +- ...d_gadget4_groups.f90 => read_gadget4_groups.F90} | 13 +++++++++++-- main/src/swift_reader.F90 | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) rename main/src/{read_gadget4_groups.f90 => read_gadget4_groups.F90} (98%) diff --git a/main/src/Makefile.am b/main/src/Makefile.am index b272b2b..1f03b64 100644 --- a/main/src/Makefile.am +++ b/main/src/Makefile.am @@ -15,4 +15,4 @@ bin_PROGRAMS = gadgetviewer @ax_mod_deps_main@ -gadgetviewer_SOURCES = data_types.F90 format_strings.f90 shrink_array.f90 math.F90 partial_read_info.f90 data_array.f90 sort.F90 reorder.f90 shuffle.f90 file_units.f90 return_status.f90 transform.f90 octree.F90 percentiles.f90 string.f90 gadget_path.f90 stereo.f90 colour_table.f90 progress_bar.f90 particle_store.F90 auxiliary_file_list.f90 catalogue_data.f90 additional_data.F90 read_gadget_groups.f90 read_gadget4_groups.f90 velociraptor_groups.F90 group_catalogue.f90 summary.f90 view_parameters.f90 project.f90 selection.F90 graph.F90 colour_bar.F90 sampling.f90 overlay.F90 select_point.f90 dotplot.f90 density2d.F90 property_plot.f90 fancyplot.F90 smoothed_property_plot.F90 gadget_binary_reader.F90 gadget_binary_type2_reader.F90 gadget_hdf5_reader.F90 gadget_eagle_reader.F90 swift_reader.F90 dummy_reader.F90 plotter.f90 mouse_handler.f90 snapshot_reader.f90 movie_parameters.f90 save_settings.F90 threads.F90 movie.f90 screenshot.f90 read_partial.f90 info_window.f90 main_window.F90 configuration.f90 command_line.f90 gadgetviewer.F90 +gadgetviewer_SOURCES = data_types.F90 format_strings.f90 shrink_array.f90 math.F90 partial_read_info.f90 data_array.f90 sort.F90 reorder.f90 shuffle.f90 file_units.f90 return_status.f90 transform.f90 octree.F90 percentiles.f90 string.f90 gadget_path.f90 stereo.f90 colour_table.f90 progress_bar.f90 particle_store.F90 auxiliary_file_list.f90 catalogue_data.f90 additional_data.F90 read_gadget_groups.f90 read_gadget4_groups.F90 velociraptor_groups.F90 group_catalogue.f90 summary.f90 view_parameters.f90 project.f90 selection.F90 graph.F90 colour_bar.F90 sampling.f90 overlay.F90 select_point.f90 dotplot.f90 density2d.F90 property_plot.f90 fancyplot.F90 smoothed_property_plot.F90 gadget_binary_reader.F90 gadget_binary_type2_reader.F90 gadget_hdf5_reader.F90 gadget_eagle_reader.F90 swift_reader.F90 dummy_reader.F90 plotter.f90 mouse_handler.f90 snapshot_reader.f90 movie_parameters.f90 save_settings.F90 threads.F90 movie.f90 screenshot.f90 read_partial.f90 info_window.f90 main_window.F90 configuration.f90 command_line.f90 gadgetviewer.F90 diff --git a/main/src/read_gadget4_groups.f90 b/main/src/read_gadget4_groups.F90 similarity index 98% rename from main/src/read_gadget4_groups.f90 rename to main/src/read_gadget4_groups.F90 index 83f82f9..5c7204b 100644 --- a/main/src/read_gadget4_groups.f90 +++ b/main/src/read_gadget4_groups.F90 @@ -5,8 +5,9 @@ module gadget4_groups use return_status use gadget_path use particle_store +#ifdef HAVE_HDF5 use read_hdf5 - +#endif implicit none private save @@ -26,6 +27,7 @@ type(result_type) function gadget4_groups_read(isnap, path_data, icat, rinfo) re type (path_data_type), intent(in) :: path_data integer, intent(in) :: icat type (read_info) :: rinfo +#ifdef HAVE_HDF5 ! Group catalogue info character(len=fname_maxlen) :: tab_file integer :: ifile, nfiles @@ -227,11 +229,16 @@ type(result_type) function gadget4_groups_read(isnap, path_data, icat, rinfo) re deallocate(grouplen_type) deallocate(subhalolen_type) deallocate(groupnsubs) - +#else + res%string = "Code was compiled without HDF5 support" + res%success = .false. +#endif return contains +#ifdef HAVE_HDF5 + subroutine cleanup() implicit none @@ -246,6 +253,8 @@ subroutine cleanup() return end subroutine cleanup +#endif + end function gadget4_groups_read end module gadget4_groups diff --git a/main/src/swift_reader.F90 b/main/src/swift_reader.F90 index 5365c2e..bcedc30 100644 --- a/main/src/swift_reader.F90 +++ b/main/src/swift_reader.F90 @@ -944,10 +944,12 @@ subroutine cleanup() if(allocated(idata)) deallocate(idata) if(allocated(rdata)) deallocate(rdata) +#ifdef HAVE_HDF5 if(file_open)then hdferr = hdf5_close_file() file_open = .false. endif +#endif return end subroutine cleanup From 4fcbe3e63df8c358a2519507df56dec4e3d7ea14 Mon Sep 17 00:00:00 2001 From: John Helly Date: Thu, 29 Jun 2023 12:47:04 +0100 Subject: [PATCH 2/5] Prevent HDF5 read routines terminating code if HDF5 is not available --- main/src/gadget_eagle_reader.F90 | 5 ----- main/src/gadget_hdf5_reader.F90 | 5 ----- main/src/swift_reader.F90 | 5 ----- 3 files changed, 15 deletions(-) diff --git a/main/src/gadget_eagle_reader.F90 b/main/src/gadget_eagle_reader.F90 index 6acf5fc..2fd2d9b 100644 --- a/main/src/gadget_eagle_reader.F90 +++ b/main/src/gadget_eagle_reader.F90 @@ -312,11 +312,6 @@ type(result_type) function gadget_eagle_open(fname, isnap, rinfo) gadget_eagle_open%success = .true. #else - ! Should never get here because menu option is greyed out if HDF5 not - ! available - call terminate('gadget_eagle_reader - Code was compiled without HDF5 support') - - ! Stop compiler complaining about return value not being set gadget_eagle_open%success = .false. gadget_eagle_open%string = "Compiled without HDF5 support" isnap = 0 diff --git a/main/src/gadget_hdf5_reader.F90 b/main/src/gadget_hdf5_reader.F90 index 6697e30..6149362 100644 --- a/main/src/gadget_hdf5_reader.F90 +++ b/main/src/gadget_hdf5_reader.F90 @@ -423,11 +423,6 @@ type(result_type) function gadget_hdf5_open(fname, isnap, rinfo) gadget_hdf5_open%success = .true. #else - ! Should never get here because menu option is greyed out if HDF5 not - ! available - call terminate('gadget_hdf5_reader - Code was compiled without HDF5 support') - - ! Stop compiler complaining about return value not being set gadget_hdf5_open%success = .false. gadget_hdf5_open%string = "Compiled without HDF5 support" isnap = 0 diff --git a/main/src/swift_reader.F90 b/main/src/swift_reader.F90 index bcedc30..8570264 100644 --- a/main/src/swift_reader.F90 +++ b/main/src/swift_reader.F90 @@ -362,11 +362,6 @@ type(result_type) function swift_open(fname, isnap, rinfo) deallocate(npfile) #else - ! Should never get here because menu option is greyed out if HDF5 not - ! available - call terminate('swift_reader - Code was compiled without HDF5 support') - - ! Stop compiler complaining about return value not being set swift_open%success = .false. swift_open%string = "Compiled without HDF5 support" isnap = 0 From 3bac5a8a9fbf079e8d024fc9c0d604b8b1032396 Mon Sep 17 00:00:00 2001 From: John Helly Date: Fri, 30 Jun 2023 16:42:01 +0100 Subject: [PATCH 3/5] Prevent compiler warnings from key file parser --- f90_util/src/key_file.F90 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/f90_util/src/key_file.F90 b/f90_util/src/key_file.F90 index 546ac33..3020212 100644 --- a/f90_util/src/key_file.F90 +++ b/f90_util/src/key_file.F90 @@ -103,9 +103,9 @@ subroutine set_integer_key_single(group, name, value) ! character(len=*), intent(in) :: group, name integer, intent(in) :: value - integer(kind=C_INT) :: c_value + integer(kind=C_INT) :: c_value(1) - c_value = value + c_value(1) = value call addintkey( & trim(group)//char(0), & @@ -141,9 +141,9 @@ subroutine set_real_key_single(group, name, value) ! character(len=*), intent(in) :: group, name real, intent(in) :: value - real(kind=C_DOUBLE) :: c_value + real(kind=C_DOUBLE) :: c_value(1) - c_value = value + c_value(1) = value call adddoublekey( & trim(group)//char(0), & @@ -222,12 +222,12 @@ subroutine set_logical_key_single(group, name, value) implicit none character(len=*), intent(in) :: group, name logical, intent(in) :: value - integer(kind=C_INT) :: c_value + integer(kind=C_INT) :: c_value(1) if(value)then - c_value = 1 + c_value(1) = 1 else - c_value = 0 + c_value(1) = 0 endif call addintkey( & trim(group)//char(0), & @@ -270,7 +270,7 @@ subroutine get_integer_key_single(group, name, value) ! character(len=*), intent(in) :: group, name integer, intent(inout) :: value - integer(kind=C_INT) :: c_value + integer(kind=C_INT) :: c_value(1) integer(kind=C_INT) :: n call getintkey( & @@ -279,7 +279,7 @@ subroutine get_integer_key_single(group, name, value) c_value, n, & int(1, kind=C_INT)) - if(n.gt.0)value = c_value + if(n.gt.0)value = c_value(1) return end subroutine get_integer_key_single @@ -313,7 +313,7 @@ subroutine get_real_key_single(group, name, value) ! character(len=*), intent(in) :: group, name real, intent(inout) :: value - real(kind=C_DOUBLE) :: c_value + real(kind=C_DOUBLE) :: c_value(1) integer(kind=C_INT) :: n call getdoublekey( & @@ -321,7 +321,7 @@ subroutine get_real_key_single(group, name, value) trim(name)//char(0), & c_value, n, & int(1, kind=C_INT)) - if(n.gt.0)value = c_value + if(n.gt.0)value = c_value(1) return end subroutine get_real_key_single @@ -392,7 +392,7 @@ subroutine get_logical_key_single(group, name, value) implicit none character(len=*), intent(in) :: group, name logical, intent(inout) :: value - integer(kind=C_INT) :: c_value + integer(kind=C_INT) :: c_value(1) integer(kind=C_INT) :: n call getintkey( & @@ -400,7 +400,7 @@ subroutine get_logical_key_single(group, name, value) trim(name)//char(0), & c_value, n, int(1, kind=C_INT)) - if(n.eq.1)value = c_value.ne.0 + if(n.eq.1)value = c_value(1).ne.0 return end subroutine get_logical_key_single From 46a760d4982b87cd554e7aa41be867c8350ff45a Mon Sep 17 00:00:00 2001 From: John Helly Date: Fri, 30 Jun 2023 16:52:24 +0100 Subject: [PATCH 4/5] Fix memory leak in EAGLE reader --- read_eagle/src/read_eagle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/read_eagle/src/read_eagle.c b/read_eagle/src/read_eagle.c index 2923f2a..f32192c 100644 --- a/read_eagle/src/read_eagle.c +++ b/read_eagle/src/read_eagle.c @@ -108,11 +108,11 @@ void cleanup(EagleSnapshot *snap) int ifile; if(snap->hashmap)free(snap->hashmap); - if(snap->first_key_in_file)free(snap->first_key_in_file); - if(snap->last_key_in_file)free(snap->last_key_in_file); - if(snap->num_keys_in_file)free(snap->num_keys_in_file); for(itype=0;itype<6;itype++) { + if(snap->first_key_in_file[itype])free(snap->first_key_in_file[itype]); + if(snap->last_key_in_file[itype])free(snap->last_key_in_file[itype]); + if(snap->num_keys_in_file[itype])free(snap->num_keys_in_file[itype]); if(snap->part_per_cell[itype]) { for(ifile=0;ifilenumfiles;ifile++) From 73a43d4c512275553ba45d2fa1a0ba9aeea67c60 Mon Sep 17 00:00:00 2001 From: John Helly Date: Tue, 18 Jul 2023 14:13:31 +0100 Subject: [PATCH 5/5] Add missing include that broke Gadget-4 subfind reader --- main/src/read_gadget4_groups.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/main/src/read_gadget4_groups.F90 b/main/src/read_gadget4_groups.F90 index 5c7204b..98067fb 100644 --- a/main/src/read_gadget4_groups.F90 +++ b/main/src/read_gadget4_groups.F90 @@ -1,5 +1,6 @@ module gadget4_groups +#include "../../config.h" use f90_util use data_types use return_status