Skip to content

Commit

Permalink
Merge pull request #14 from jchelly/swift_io
Browse files Browse the repository at this point in the history
Add SWIFT specific read routine
  • Loading branch information
jchelly authored Oct 20, 2021
2 parents b347872 + 901003b commit c7feab1
Show file tree
Hide file tree
Showing 7 changed files with 980 additions and 35 deletions.
2 changes: 1 addition & 1 deletion main/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 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 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
2 changes: 2 additions & 0 deletions main/src/configuration.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module configuration
use gadget_hdf5_reader
use gadget_eagle_reader
use gadget_binary_type2_reader
use swift_reader
use colour_table
use mouse_handler

Expand Down Expand Up @@ -52,6 +53,7 @@ subroutine configuration_read()
call gadget_hdf5_read_conf(dirname)
call gadget_eagle_read_conf(dirname)
call gadget_binary_type2_read_conf(dirname)
call swift_read_conf(dirname)
call colour_table_read_conf(dirname)
call mouse_handler_read_conf(dirname)

Expand Down
9 changes: 6 additions & 3 deletions main/src/gadget_hdf5_reader.F90
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,15 @@ subroutine gadget_hdf5_read_conf(dir)
! Save the new list
call set_key("Gadget HDF5","Extra Properties", extra_prop_config(1:nextra_config))
call write_key_file(fname)
endif
if(file_has_group("Gadget HDF5"))then
else
extra_prop_config(:) = ""
call get_key("Gadget HDF5","Extra Properties", extra_prop_config)
do i = 1, max_extra, 1
if(len_trim(extra_prop_config(i)).gt.0)nextra_config = nextra_config + 1
if(len_trim(extra_prop_config(i)).gt.0)then
nextra_config = i
else
exit
endif
end do
endif
call close_key_file()
Expand Down
31 changes: 2 additions & 29 deletions main/src/main_window.F90
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,9 @@ subroutine main_window_create()
! Add menu options
call gui_create_menu(file_menu, mainwin, "File")
call gui_create_menu_item(file_open_snapshot, file_menu, &
"Read Gadget snapshot...")
"Read simulation snapshot...")
call gui_create_menu_item(file_open_partial, file_menu, &
"Read part of Gadget snapshot...")
!call gui_create_menu_item(file_open_partial, file_menu, &
! "Read Gadget snapshot...")

#ifdef SPECIFIC_FORMAT
call gui_create_menu(file_formats, file_menu, "Read specific format")
call gui_create_menu_item(file_open_binary_gadget, file_formats, &
"Open binary (type 1) gadget file...")
call gui_create_menu_item(file_open_type2_gadget, file_formats, &
"Open binary (type 2) gadget file...")
call gui_create_menu_item(file_open_hdf5_gadget, file_formats, &
"Open HDF5 (type 3) gadget file...")
#endif
"Read part of simulation snapshot...")

! Set up list of group formats we can read
call gui_create_menu(file_read_groups, file_menu, &
Expand Down Expand Up @@ -365,13 +353,6 @@ subroutine main_window_create()
call gui_create_menu_item(file_save_default, file_settings, &
"Make current settings default", separator=.true.)

! Without HDF5 we can't load HDF5 snapshots
#ifndef HAVE_HDF5
#ifdef SPECIFIC_FORMAT
call gui_set_sensitive(file_open_hdf5_gadget,.false.)
#endif
#endif

! Quit option
call gui_create_menu_item(file_exit, file_menu, "Exit", separator=.true.)

Expand Down Expand Up @@ -1081,14 +1062,6 @@ subroutine main_window_process_events()

! File/Open menu options
fmt_to_read = "none"
#ifdef SPECIFIC_FORMATS
if(gui_menu_item_clicked(file_open_binary_gadget)) &
fmt_to_read="GADGET_BINARY"
if(gui_menu_item_clicked(file_open_type2_gadget)) &
fmt_to_read="GADGET_BINARY_TYPE2"
if(gui_menu_item_clicked(file_open_hdf5_gadget)) &
fmt_to_read="GADGET_HDF5"
#endif
if(gui_menu_item_clicked(file_open_snapshot)) &
fmt_to_read="UNKNOWN"
if(gui_menu_item_clicked(file_open_partial)) &
Expand Down
2 changes: 1 addition & 1 deletion main/src/particle_store.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module particle_store
! Maximum length of a species/property name
integer, parameter, public :: maxlen = 500
! Maximum no. of species
integer, parameter, public :: maxspecies = 6
integer, parameter, public :: maxspecies = 8
! Maximum number of additional properties
integer, parameter, public :: maxprops = 100

Expand Down
10 changes: 9 additions & 1 deletion main/src/snapshot_reader.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module snapshot_reader
use particle_store
use gadget_binary_reader
use gadget_binary_type2_reader
use swift_reader
use gadget_hdf5_reader
use gadget_eagle_reader
use dummy_reader
Expand Down Expand Up @@ -40,11 +41,12 @@ module snapshot_reader
logical :: first_read = .true.

! Format names
integer, parameter :: nformat = 5
integer, parameter :: nformat = 6
character(len=20), dimension(nformat) :: format_names = (/ &
"GADGET_BINARY ", &
"GADGET_BINARY_TYPE2 ", &
"GADGET_EAGLE ", &
"SWIFT ", &
"GADGET_HDF5 ", &
"DUMMY " &
/)
Expand Down Expand Up @@ -97,6 +99,8 @@ type (result_type) function snapshot_open(fname, isnap, ri)
res = gadget_binary_type2_open(fname,isnap,ri_in)
case("GADGET_EAGLE")
res = gadget_eagle_open(fname,isnap,ri_in)
case("SWIFT")
res = swift_open(fname,isnap,ri_in)
case("GADGET_HDF5")
res = gadget_hdf5_open(fname,isnap,ri_in)
case("DUMMY")
Expand Down Expand Up @@ -147,6 +151,10 @@ type (result_type) function snapshot_read(isnap)
case("GADGET_EAGLE")
call summary_add_line(s,"Simulation format: Eagle")
res = gadget_eagle_read(isnap, rinfo)

case("SWIFT")
call summary_add_line(s,"Simulation format: SWIFT")
res = swift_read(isnap, rinfo)
case("GADGET_HDF5")
call summary_add_line(s,"Simulation format: Gadget HDF5")
res = gadget_hdf5_read(isnap, rinfo)
Expand Down
Loading

0 comments on commit c7feab1

Please sign in to comment.