Commit 6035ae2f authored by Roy Fabrice's avatar Roy Fabrice
Browse files

begin halo post-treatment tool dev

will replace haloanalyzer
parent 371d8bf1
include ../../Make.inc
EXE = halo_post.exe
COMMONDIR = ../../common/src/
OBJDIR=../../obj/
MODDIR=../../mod/
VPATH= $(COMMONDIR):.
SRC = char_utils_m.f90 \
error_handling_m.f90 \
constants_m.f90 \
mpi_process_m.f90 \
timer_m.f90 \
halo_post_shared_var_m.f90 \
halo_post_parameters_m.f90 \
halo_post.f90
OBJS_NOPREFIX=$(SRC:%.f90=%.o)
OBJS=$(addprefix $(OBJDIR), $(OBJS_NOPREFIX))
# variable containing if git is used or not
ifeq ($(wildcard ../../.git/HEAD ../../.git/index),)
OBJ_GIT =
USE_GIT =
else
USE_GIT = $(shell which git)
OBJ_GIT = ../../.git/HEAD ../../.git/index
endif
$(OBJDIR)%.o:%.f90
@echo "--------------------------------"
@echo building $*.o with parameters \
FC=$(FC), FCFLAGS=$(FCFLAGS)
$(FC) -c $(FCFLAGS) $< -o $@
$(MODDIR)%.mod:%.f90
@echo "--------------------------------"
@echo building $*.mod with parameters \
FC=$(FC), FCFLAGS=$(FCFLAGS)
$(FC) -c $(FCFLAGS) $<
all: directories release
release: $(EXE)
debug: FCFLAGS = $(DEBUGFLAGS)
debug: $(EXE)
$(EXE) : gitversion $(OBJS)
@echo "--------------------------------"
@echo $(ROOT_PFOF)
@echo building $(EXE) with parameters \
FC=$(FC), LDFLAGS=$(LDFLAGS)
$(FC) -g -o $(EXE) $(OBJS) $(LDFLAGS)
cleanall :
@echo "--------------------------------"
@echo cleaning compiled objects, modules and executable
rm -f $(OBJDIR)*.o $(MODDIR)*.mod *~ $(EXE) $(COMMONDIR)/gitversion.h
clean:
@echo "--------------------------------"
@echo cleaning executable
rm -f $(EXE)
# create file for git version
gitversion: $(OBJ_GIT)
ifneq ($(USE_GIT), )
@cd $(COMMONDIR) ;\
echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > gitversion.h
else
@cd $(COMMONDIR) ;\
echo "#define GITVERSION \"no_version_found\"" > gitversion.h
endif
directories: ${MODDIR} ${OBJDIR}
${OBJDIR}:
${MKDIR_P} $@
${MODDIR}:
${MKDIR_P} $@
.PHONY: gitversion clean cleanall directories all
!------------------------------------------------------------------------------------------------------------------------------------
! Copyright 2020 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
!! Post treatment for pFoF halos
!! @brief
!!
!! @author Fabrice Roy
!> Post treatment for pFoF halos
!------------------------------------------------------------------------------------------------------------------------------------
program halo_post
use fortran_hdf5_manage_interface_m
use halo_post_parameters_m
use iso_fortran_env, only : OUTPUT_UNIT
use mpi
implicit none
integer :: mpierr
call mpi_init(mpierr)
call hdf5_init()
write(OUTPUT_UNIT,'(a)') 'Halo post-treatment'
call hdf5_finalize()
call mpi_finalize(mpierr)
end program halo_post
\ No newline at end of file
!------------------------------------------------------------------------------------------------------------------------------------
! Copyright 2020 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
!! Class for halo_post input parameters
!! @brief
!!
!! @author Fabrice Roy
!> Class for halo_post input parameters
!----------------------------------------------------------------------------------------------------------------------------------
module halo_post_parameters_m
use error_handling_m
use iso_fortran_env
use mpi
use halo_post_shared_var_m
implicit none
private
public :: halo_post_parameters_t
integer, parameter :: LEN_STRING = 256
integer :: mpi_type_php
type halo_post_parameters_t
integer :: files_number
integer :: halos_number
character(len=LEN_STRING) :: data_directory
character(len=LEN_STRING), allocatable, dimension(:) :: file_names
integer, allocatable, dimension(:) :: halo_ids
contains
procedure :: Write => Write_halo_post_parameters
procedure :: Read => Read_halo_post_parameters
procedure :: Read_hdf5 => Read_hdf5_halo_post_parameters
procedure :: Write_hdf5 => Write_hdf5_halo_post_parameters
end type halo_post_parameters_t
contains
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Read_halo_post_parameters(this)
class(halo_post_parameters_t), intent(out) :: this
integer :: alloc_stat
character(len=LEN_STRING) :: data_directory
character(ERR_MSG_LEN) :: error_message
character(len=LEN_STRING), allocatable, dimension(:) :: file_names
integer :: files_number
integer, dimension(:), allocatable :: halo_ids
integer :: halos_number
integer :: ioerr
integer :: l_string
integer :: mpierr
character(len=:), allocatable :: parameters_filename
integer :: parameters_unit
integer :: status
namelist / input / data_directory, files_number, halos_number
namelist / files / file_names
namelist / halos / halo_ids
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Read_halo_post_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 = 'halo_post.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_halo_post_parameters: get_command_argument for argument 1 failed'
call mpi_abort(MPI_COMM_WORLD, status, mpierr)
end if
end if
write(OUTPUT_UNIT,'(a,a)') 'Parameters read from input file ', trim(parameters_filename)
! read input parameters
open(newunit=parameters_unit, file=parameters_filename, status='old', action='read', iostat=ioerr, iomsg=error_message)
if( ioerr /= 0 ) call IO_error('open file '//parameters_filename, 'Read_halo_post_parameters', &
error_message, ioerr, mpi_process%rank)
read(parameters_unit, nml=input, iostat=ioerr, iomsg=error_message)
if(ioerr /= 0) call IO_error('read input namelist', 'Read_halo_post_parameters', &
error_message, ioerr, mpi_process%rank)
if(files_number /= 0) then
allocate(file_names(files_number), stat=alloc_stat, errmsg=error_message)
if(alloc_stat /= 0) then
call Allocate_error('file_names','Read_halo_post_parameters', error_message, alloc_stat, mpi_process%rank)
end if
read(parameters_unit, nml=files, iostat=ioerr, iomsg=error_message)
if(ioerr /= 0) call IO_error('read files namelist', 'Read_halo_post_parameters', &
error_message, ioerr, mpi_process%rank)
end if
if(halos_number /= 0) then
allocate(halo_ids(halos_number), stat=alloc_stat, errmsg=error_message)
if(alloc_stat /= 0) then
call Allocate_error('halo_ids','Read_halo_post_parameters', error_message, alloc_stat, mpi_process%rank)
end if
read(parameters_unit, nml=halos, iostat=ioerr, iomsg=error_message)
if(ioerr /= 0) call IO_error('read halos namelist', 'Read_halo_post_parameters', &
error_message, ioerr, mpi_process%rank)
end if
close(parameters_unit)
this%data_directory = data_directory
this%files_number = files_number
this%halos_number = halos_number
if(halos_number /= 0) then
call move_alloc(halo_ids, this%halo_ids)
end if
if(files_number /= 0) then
call move_alloc(file_names,this%file_names)
end if
end if
call timer%Inc_inp()
! call Init_mpi_type_a2cp(mpi_type_a2cp, this)
! call mpi_bcast(this, 1, mpi_type_a2cp, 0, MPI_COMM_WORLD, mpierr)
! call timer%Inc_comm()
! if(mpi_process%rank==0) call this%Print(OUTPUT_UNIT)
call timer%Inc_out()
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Read_amr2cell_hdf5_parameter ends on process', mpi_process%rank
#endif
end subroutine Read_halo_post_parameters
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Write_halo_post_parameters(this, unit)
class(halo_post_parameters_t),intent(in) :: this
integer,intent(in) :: unit
end subroutine Write_halo_post_parameters
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Read_hdf5_halo_post_parameters(this, unit)
class(halo_post_parameters_t),intent(in) :: this
integer,intent(in) :: unit
end subroutine Read_hdf5_halo_post_parameters
!----------------------------------------------------------------------------------------------------------------------------------
subroutine Write_hdf5_halo_post_parameters(this, unit)
class(halo_post_parameters_t),intent(in) :: this
integer,intent(in) :: unit
end subroutine Write_hdf5_halo_post_parameters
end module halo_post_parameters_m
\ No newline at end of file
!------------------------------------------------------------------------------------------------------------------------------------
! Copyright 2020 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
!! Global variables for halo_post
!! @brief
!!
!! @author Fabrice Roy
!> Global variables for halo_post
module halo_post_shared_var_m
use timer_m, only : timer_t
use mpi_process_m, only : mpi_process_t
implicit none
private
public :: mpi_process, &
timer
type(mpi_process_t) :: mpi_process
type(timer_t) :: timer
end module halo_post_shared_var_m
Markdown is supported
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