amr2cell_hdf5.f90 3.25 KB
Newer Older
Roy Fabrice's avatar
Roy Fabrice committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
!------------------------------------------------------------------------------------------------------------------------------------
! Copyright  2018 Fabrice Roy
!
! Contact: fabrice.roy@obspm.fr
!
! This file is part of pFoF.
!
! pFoF is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! pFoF is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
! 
! You should have received a copy of the GNU General Public License
! along with pFoF. If not, see <http://www.gnu.org/licenses/>.

!> @file
!! Contains program that convert binary hydro and amr output files from RAMSES to HDF5 'cube' files
!! @brief
!! 
!! @author Fabrice Roy

!> Contains program that convert binary hydro and amr output files from RAMSES to HDF5 'cube' files
!------------------------------------------------------------------------------------------------------------------------------------

30
program amr2cell_hdf5
Roy Fabrice's avatar
Roy Fabrice committed
31

32
  use amr2cell_hdf5_parameters_m, only : amr2cell_hdf5_parameters_t
Roy Fabrice's avatar
Roy Fabrice committed
33
34
  use error_handling_m, only : Allocate_error, ERR_MSG_LEN
  use cell_m, only : cell_t
35
  use cells_array_m, only : cells_array_t
Roy Fabrice's avatar
Roy Fabrice committed
36
  use constants_m, only : IDKIND
37
  use cubes_array_m, only : cubes_array_t
Roy Fabrice's avatar
Roy Fabrice committed
38
  use fortran_hdf5_manage_interface_m
Roy Fabrice's avatar
Roy Fabrice committed
39
40
  use iso_fortran_env, only : OUTPUT_UNIT
  use mpi
41
  use ramses_info_m, only : ramses_info_t
42
  use ramses_output_m, only : ramses_output_t
Roy Fabrice's avatar
Roy Fabrice committed
43
  use ramses_output_to_cells_m, only : ramses_output_to_cells
44
45
  use shared_variables_m

Roy Fabrice's avatar
Roy Fabrice committed
46
47
  implicit none

48
  type(amr2cell_hdf5_parameters_t) :: amr2cell_hdf5_parameters
49
  type(cells_array_t) :: cells_array
50
  integer, allocatable, dimension(:) :: cube_to_process
51
  type(cubes_array_t) :: cubes_array
Roy Fabrice's avatar
Roy Fabrice committed
52
53
  integer, allocatable, dimension(:) :: global_cells_per_cube
  integer, allocatable, dimension(:) :: local_cells_per_cube
54
55
56
  integer :: mpierr
  type(ramses_info_t) :: ramses_info
  type(ramses_output_t) :: ramses_output
57

Roy Fabrice's avatar
Roy Fabrice committed
58
  call mpi_init(mpierr)
Roy Fabrice's avatar
Roy Fabrice committed
59
60
  call Hdf5_init()

61
62
  call timer%Init()

Roy Fabrice's avatar
Roy Fabrice committed
63
  call mpi_process%Init()
64

Roy Fabrice's avatar
Roy Fabrice committed
65
  call mpi_process%Print()
Roy Fabrice's avatar
Roy Fabrice committed
66

67
  call amr2cell_hdf5_parameters%Read()
Roy Fabrice's avatar
Roy Fabrice committed
68

69
  call amr2cell_hdf5_parameters%Check()
70

71
  call ramses_info%Read(trim(amr2cell_hdf5_parameters%data_dir)//trim(amr2cell_hdf5_parameters%info_filename), mpi_process)
72

73
  call ramses_output%Init(amr2cell_hdf5_parameters)
74

Roy Fabrice's avatar
Roy Fabrice committed
75
  call ramses_output%Read()
Roy Fabrice's avatar
Roy Fabrice committed
76

Roy Fabrice's avatar
Roy Fabrice committed
77
  call Ramses_output_to_cells(cells_array, ramses_output)
78

Roy Fabrice's avatar
Roy Fabrice committed
79
80
  call ramses_output%Deallocate()

81
  call cells_array%Clean(amr2cell_hdf5_parameters%cube_level)
Roy Fabrice's avatar
Roy Fabrice committed
82

83
  call cubes_array%Init(amr2cell_hdf5_parameters, ramses_info)
84

Roy Fabrice's avatar
Roy Fabrice committed
85
  call cells_array%Count_cells(local_cells_per_cube, global_cells_per_cube, cubes_array%dims)
86

Roy Fabrice's avatar
Roy Fabrice committed
87
  call cubes_array%Assign(cube_to_process, local_cells_per_cube)
88

89
  call cells_array%Distribute(cube_to_process)
90

Roy Fabrice's avatar
Roy Fabrice committed
91
  call cubes_array%Associate(cells_array, global_cells_per_cube)
Roy Fabrice's avatar
Roy Fabrice committed
92
93
94

  call cubes_array%Write()

95
96
97
98
99
  call timer%Finalize()
  if ( mpi_process%rank == 0 ) then
     call timer%Print(OUTPUT_UNIT)
  end if

Roy Fabrice's avatar
Roy Fabrice committed
100
  call Hdf5_finalize()
Roy Fabrice's avatar
Roy Fabrice committed
101
  call mpi_finalize(mpierr)
102

103
end program amr2cell_hdf5