Commit 26645560 authored by Roy Fabrice's avatar Roy Fabrice
Browse files

change amr2cube into amr2cell_hdf5 everywhere

amr2cube is already used somewhere in RAMSES
parent 15966fe0
include ../../Make.inc
EXE = amr2cube
EXE = amr2cell_hdf5
COMMONDIR = ../../common/src/
OBJDIR=../../obj/
......@@ -15,7 +15,7 @@ SRC = char_utils_m.f90 \
constants_m.f90 \
index_m.f90 \
ramses_info_m.f90 \
amr2cube_parameters_m.f90 \
amr2cell_hdf5_parameters_m.f90 \
cell_m.f90 \
cells_array_m.f90 \
cube_m.f90 \
......@@ -27,7 +27,7 @@ SRC = char_utils_m.f90 \
ramses_amr_data_m.f90 \
ramses_output_m.f90 \
ramses_output_to_cells_m.f90 \
amr2cube.f90
amr2cell_hdf5.f90
OBJS_NOPREFIX=$(SRC:%.f90=%.o)
OBJS=$(addprefix $(OBJDIR), $(OBJS_NOPREFIX))
......
......@@ -27,9 +27,9 @@
!> Contains program that convert binary hydro and amr output files from RAMSES to HDF5 'cube' files
!------------------------------------------------------------------------------------------------------------------------------------
program amr2cube
program amr2cell_hdf5
use amr2cube_parameters_m, only : amr2cube_parameters_t
use amr2cell_hdf5_parameters_m, only : amr2cell_hdf5_parameters_t
use error_handling_m, only : Allocate_error, ERR_MSG_LEN
use cell_m, only : cell_t
use cells_array_m, only : cells_array_t
......@@ -45,7 +45,7 @@ program amr2cube
implicit none
type(amr2cube_parameters_t) :: amr2cube_parameters
type(amr2cell_hdf5_parameters_t) :: amr2cell_hdf5_parameters
type(cells_array_t) :: cells_array
integer, allocatable, dimension(:) :: cube_to_process
type(cubes_array_t) :: cubes_array
......@@ -64,13 +64,13 @@ program amr2cube
call mpi_process%Print()
call amr2cube_parameters%Read()
call amr2cell_hdf5_parameters%Read()
call amr2cube_parameters%Check()
call amr2cell_hdf5_parameters%Check()
call ramses_info%Read(trim(amr2cube_parameters%data_dir)//trim(amr2cube_parameters%info_filename), mpi_process)
call ramses_info%Read(trim(amr2cell_hdf5_parameters%data_dir)//trim(amr2cell_hdf5_parameters%info_filename), mpi_process)
call ramses_output%Init(amr2cube_parameters)
call ramses_output%Init(amr2cell_hdf5_parameters)
call ramses_output%Read()
......@@ -78,9 +78,9 @@ program amr2cube
call ramses_output%Deallocate()
call cells_array%Clean(amr2cube_parameters%cube_level)
call cells_array%Clean(amr2cell_hdf5_parameters%cube_level)
call cubes_array%Init(amr2cube_parameters, ramses_info)
call cubes_array%Init(amr2cell_hdf5_parameters, ramses_info)
call cells_array%Count_cells(local_cells_per_cube, global_cells_per_cube, cubes_array%dims)
......@@ -100,4 +100,4 @@ program amr2cube
call Hdf5_finalize()
call mpi_finalize(mpierr)
end program amr2cube
end program amr2cell_hdf5
......@@ -19,15 +19,15 @@
! along with pFoF. If not, see <http://www.gnu.org/licenses/>.
!> @file
!! Class for amr2cube input parameters
!! Class for amr2cell_hdf5 input parameters
!! @brief
!!
!! @author Fabrice Roy
!> Class for amr2cube input parameters
!> Class for amr2cell_hdf5 input parameters
!----------------------------------------------------------------------------------------------------------------------------------
module amr2cube_parameters_m
module amr2cell_hdf5_parameters_m
use error_handling_m
use iso_fortran_env
......@@ -38,12 +38,12 @@ module amr2cube_parameters_m
private
public :: amr2cube_parameters_t
public :: amr2cell_hdf5_parameters_t
integer, parameter :: LEN_STRING = 256
integer :: mpi_type_a2cp
type amr2cube_parameters_t
type amr2cell_hdf5_parameters_t
character(len=LEN_STRING) :: data_dir
character(len=LEN_STRING) :: amr_filename
character(len=LEN_STRING) :: hydro_filename
......@@ -52,19 +52,19 @@ module amr2cube_parameters_m
character(len=LEN_STRING) :: cube_filename
integer :: cube_level
contains
procedure :: Check => Check_amr2cube_parameters
procedure :: Print => Print_amr2cube_parameters
procedure :: Read => Read_amr2cube_parameters
end type amr2cube_parameters_t
procedure :: Check => Check_amr2cell_hdf5_parameters
procedure :: Print => Print_amr2cell_hdf5_parameters
procedure :: Read => Read_amr2cell_hdf5_parameters
end type amr2cell_hdf5_parameters_t
contains
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Check_amr2cube_parameters(this)
subroutine Check_amr2cell_hdf5_parameters(this)
use char_utils_m, only : Int_to_char5
use constants_m, only : FILENAME_LEN
class(amr2cube_parameters_t), intent(in) :: this
class(amr2cell_hdf5_parameters_t), intent(in) :: this
character(len=FILENAME_LEN) :: filename
integer :: ncubes
......@@ -75,62 +75,62 @@ contains
logical :: info_file_exists
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Check_amr2cube_parameters begins on process', mpi_process%rank
write(ERROR_UNIT,'(a,i0)') 'Check_amr2cell_hdf5_parameters begins on process', mpi_process%rank
#endif
! check if cube numbers is >= process numbers
ncubes = (2**(this%cube_level-1))**3
if( ncubes < mpi_process%comm%size ) then
write(ERROR_UNIT, '(a,i0,a,i0,a)') 'You are using ',mpi_process%comm%size,' processes and you want to write ', ncubes,' cubes.'
call Algorithmic_error('Check_amr2cube_parameters', 'Number of processes used should be <= number of cubes written.', 1000, mpi_process%rank)
call Algorithmic_error('Check_amr2cell_hdf5_parameters', 'Number of processes used should be <= number of cubes written.', 1000, mpi_process%rank)
end if
! test the existance of the files
inquire(directory=this%data_dir, exist=data_dir_exists )
if(.not. data_dir_exists) then
write(ERROR_UNIT, '(a)') 'Data directory = '//trim(this%data_dir)
call Algorithmic_error('Check_amr2cube_parameters', 'This directory does not exist. Check data_dir parameter.', 1001, mpi_process%rank)
call Algorithmic_error('Check_amr2cell_hdf5_parameters', 'This directory does not exist. Check data_dir parameter.', 1001, mpi_process%rank)
end if
filename=trim(this%data_dir)//trim(this%amr_filename)//Int_to_char5(1)
inquire(file=filename, exist=amr_file_exists )
if(.not. amr_file_exists) then
write(ERROR_UNIT, '(a)') '1st amr file = '//filename
call Algorithmic_error('Check_amr2cube_parameters', 'This file does not exist. Check amr_filename parameter.', 1001, mpi_process%rank)
call Algorithmic_error('Check_amr2cell_hdf5_parameters', 'This file does not exist. Check amr_filename parameter.', 1001, mpi_process%rank)
end if
filename=trim(this%data_dir)//trim(this%hydro_filename)//Int_to_char5(1)
inquire(file=filename, exist=hydro_file_exists )
if(.not. hydro_file_exists) then
write(ERROR_UNIT, '(a)') '1st hydro file = '//filename
call Algorithmic_error('Check_amr2cube_parameters', 'This file does not exist. Check hydro_filename parameter.', 1001, mpi_process%rank)
call Algorithmic_error('Check_amr2cell_hdf5_parameters', 'This file does not exist. Check hydro_filename parameter.', 1001, mpi_process%rank)
end if
filename=trim(this%data_dir)//trim(this%info_filename)
inquire(file=filename, exist=info_file_exists )
if(.not. info_file_exists) then
write(ERROR_UNIT, '(a)') 'info file = '//filename
call Algorithmic_error('Check_amr2cube_parameters', 'This file does not exist. Check info_filename parameter.', 1001, mpi_process%rank)
call Algorithmic_error('Check_amr2cell_hdf5_parameters', 'This file does not exist. Check info_filename parameter.', 1001, mpi_process%rank)
end if
filename=trim(this%data_dir)//trim(this%hydro_descriptor_filename)
inquire(file=filename, exist=hydro_descriptor_file_exists )
if(.not. hydro_descriptor_file_exists) then
write(ERROR_UNIT, '(a)') 'hydro descriptor file = '//filename
call Algorithmic_error('Check_amr2cube_parameters', 'This file does not exist. Check hydro_descriptor_filename parameter.', 1001, mpi_process%rank)
call Algorithmic_error('Check_amr2cell_hdf5_parameters', 'This file does not exist. Check hydro_descriptor_filename parameter.', 1001, mpi_process%rank)
end if
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Check_amr2cube_parameters ends on process', mpi_process%rank
write(ERROR_UNIT,'(a,i0)') 'Check_amr2cell_hdf5_parameters ends on process', mpi_process%rank
#endif
end subroutine Check_amr2cube_parameters
end subroutine Check_amr2cell_hdf5_parameters
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Init_mpi_type_a2cp(mpi_type_a2cp, parameters)
integer, intent(out) :: mpi_type_a2cp
type(amr2cube_parameters_t), intent(in) :: parameters
type(amr2cell_hdf5_parameters_t), intent(in) :: parameters
integer(kind=4), allocatable, dimension(:) :: blocklen, type
integer(kind=MPI_ADDRESS_KIND), allocatable, dimension(:) :: disp
......@@ -185,13 +185,13 @@ contains
end subroutine Init_mpi_type_a2cp
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Print_amr2cube_parameters(this, unit_number)
subroutine Print_amr2cell_hdf5_parameters(this, unit_number)
class(amr2cube_parameters_t), intent(in) :: this
class(amr2cell_hdf5_parameters_t), intent(in) :: this
integer, intent(in) :: unit_number
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Print_amr2cube_parameters begins on process', mpi_process%rank
write(ERROR_UNIT,'(a,i0)') 'Print_amr2cell_hdf5_parameters begins on process', mpi_process%rank
#endif
write(unit_number,'(a,a)') '---------------------------------------------------------------------------------'
......@@ -208,15 +208,15 @@ contains
write(unit_number,'(a,a)') '---------------------------------------------------------------------------------'
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Print_amr2cube_parameters ends on process', mpi_process%rank
write(ERROR_UNIT,'(a,i0)') 'Print_amr2cell_hdf5_parameters ends on process', mpi_process%rank
#endif
end subroutine Print_amr2cube_parameters
end subroutine Print_amr2cell_hdf5_parameters
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Read_amr2cube_parameters(this)
subroutine Read_amr2cell_hdf5_parameters(this)
class(amr2cube_parameters_t), intent(out) :: this
class(amr2cell_hdf5_parameters_t), intent(out) :: this
character(len=LEN_STRING) :: data_directory, amr_filename, hydro_filename, info_filename, &
hydro_descriptor_filename
......@@ -236,19 +236,19 @@ contains
namelist / output_parameters / cube_level, cube_filename
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Read_amr2cube_parameters begins on process', mpi_process%rank
write(ERROR_UNIT,'(a,i0)') 'Read_amr2cell_hdf5_parameters begins on process', mpi_process%rank
#endif
call timer%Set_ref()
if (mpi_process%rank==0) then
if( command_argument_count() == 0 ) then
parameters_filename = 'amr2cube.nml'
parameters_filename = 'amr2cell_hdf5.nml'
else
call get_command_argument(1, length=l_string, status=status)
allocate(character(l_string)::parameters_filename)
call get_command_argument(1, parameters_filename, status=status)
if (status /= 0) then
write(ERROR_UNIT,*) 'Error in Read_amr2cube_parameters: get_command_argument for argument 1 failed'
write(ERROR_UNIT,*) 'Error in Read_amr2cell_hdf5_parameters: get_command_argument for argument 1 failed'
call mpi_abort(MPI_COMM_WORLD, status, mpierr)
end if
end if
......@@ -260,11 +260,11 @@ contains
error_message, ioerr, mpi_process%rank)
read(parameters_unit, nml=input_parameters, iostat=ioerr, iomsg=error_message)
if(ioerr /= 0) call IO_error('read input_parameters namelist', 'Read_amr2cube_parameters', &
if(ioerr /= 0) call IO_error('read input_parameters namelist', 'Read_amr2cell_hdf5_parameters', &
error_message, ioerr, mpi_process%rank)
read(parameters_unit, nml=output_parameters, iostat=ioerr, iomsg=error_message)
if(ioerr /= 0) call IO_error('read output_parameters namelist', 'Read_amr2cube_parameters', &
if(ioerr /= 0) call IO_error('read output_parameters namelist', 'Read_amr2cell_hdf5_parameters', &
error_message, ioerr, mpi_process%rank)
close(parameters_unit)
......@@ -288,10 +288,10 @@ contains
#ifdef DEBUG
! check parameters on process 1:
write(ERROR_UNIT,'(a,i0)') 'Read_amr2cube_parameter ends on process', mpi_process%rank
write(ERROR_UNIT,'(a,i0)') 'Read_amr2cell_hdf5_parameter ends on process', mpi_process%rank
#endif
end subroutine Read_amr2cube_parameters
end subroutine Read_amr2cell_hdf5_parameters
end module amr2cube_parameters_m
end module amr2cell_hdf5_parameters_m
......@@ -29,7 +29,7 @@
module cube_m
use amr2cube_parameters_m, only : amr2cube_parameters_t
use amr2cell_hdf5_parameters_m, only : amr2cell_hdf5_parameters_t
use cells_array_m, only : cells_array_t
use constants_m, only : DP
use error_handling_m, only : ERR_MSG_LEN, Allocate_error
......@@ -62,14 +62,14 @@ module cube_m
contains
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Init_cube(this, amr2cube_parameters, identity, ramses_info)
subroutine Init_cube(this, amr2cell_hdf5_parameters, identity, ramses_info)
use constants_m, only : IDKIND
use char_utils_m, only : Int_to_char5
use index_m, only : Id_to_coords
class(cube_t), intent(out) :: this
type(amr2cube_parameters_t), intent(in) :: amr2cube_parameters
type(amr2cell_hdf5_parameters_t), intent(in) :: amr2cell_hdf5_parameters
integer(kind=4), intent(in) :: identity
type(ramses_info_t), intent(in) :: ramses_info
......@@ -82,8 +82,8 @@ contains
#endif
call timer%Set_ref()
this%filename = trim(amr2cube_parameters%cube_filename)//Int_to_char5(identity)//".h5"
this%level = amr2cube_parameters%cube_level
this%filename = trim(amr2cell_hdf5_parameters%cube_filename)//Int_to_char5(identity)//".h5"
this%level = amr2cell_hdf5_parameters%cube_level
this%size = 1.0_DP / (2 ** (this%level-1))
this%number = (2 ** (this%level-1)) ** 3
this%identity = identity
......
......@@ -28,7 +28,7 @@
!----------------------------------------------------------------------------------------------------------------------------------
module cubes_array_m
use amr2cube_parameters_m
use amr2cell_hdf5_parameters_m
use cube_m, only : cube_t
use error_handling_m
use iso_fortran_env, only : ERROR_UNIT, OUTPUT_UNIT
......@@ -161,10 +161,10 @@ contains
end subroutine Associate_cells_to_cubes
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Init_cubes_array(this, amr2cube_parameters, ramses_info)
subroutine Init_cubes_array(this, amr2cell_hdf5_parameters, ramses_info)
class(cubes_array_t), intent(out) :: this
type(amr2cube_parameters_t), intent(in) :: amr2cube_parameters
type(amr2cell_hdf5_parameters_t), intent(in) :: amr2cell_hdf5_parameters
type(ramses_info_t), intent(in) :: ramses_info
integer(kind=4) :: alloc_stat
......@@ -176,7 +176,7 @@ contains
#endif
call timer%Set_ref()
this%dims = 2 ** (amr2cube_parameters%cube_level-1)
this%dims = 2 ** (amr2cell_hdf5_parameters%cube_level-1)
this%ncubes = this%dims(1) * this%dims(2) * this%dims(3)
allocate(this%elts(this%ncubes), stat=alloc_stat, errmsg=error_message)
if(alloc_stat /= 0) then
......@@ -184,7 +184,7 @@ contains
end if
do icube = 1, this%ncubes
call this%elts(icube)%Init(amr2cube_parameters, icube, ramses_info)
call this%elts(icube)%Init(amr2cell_hdf5_parameters, icube, ramses_info)
end do
call timer%Inc_comp()
......
......@@ -109,23 +109,23 @@ contains
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Init_ramses_output(this, amr2cube_parameters)
subroutine Init_ramses_output(this, amr2cell_hdf5_parameters)
use amr2cube_parameters_m
use amr2cell_hdf5_parameters_m
class(ramses_output_t), intent(out) :: this
type(amr2cube_parameters_t), intent(in) :: amr2cube_parameters
type(amr2cell_hdf5_parameters_t), intent(in) :: amr2cell_hdf5_parameters
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Init_ramses_output begins on process', mpi_process%rank
#endif
call timer%Set_ref()
this%data_dir = amr2cube_parameters%data_dir
this%amr_filename = amr2cube_parameters%amr_filename
this%hydro_filename = amr2cube_parameters%hydro_filename
this%info_filename = amr2cube_parameters%info_filename
this%hydro_descriptor_filename = amr2cube_parameters%hydro_descriptor_filename
this%data_dir = amr2cell_hdf5_parameters%data_dir
this%amr_filename = amr2cell_hdf5_parameters%amr_filename
this%hydro_filename = amr2cell_hdf5_parameters%hydro_filename
this%info_filename = amr2cell_hdf5_parameters%info_filename
this%hydro_descriptor_filename = amr2cell_hdf5_parameters%hydro_descriptor_filename
call timer%Inc_comp()
#ifdef DEBUG
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment