Commit 209976bd authored by Roy Fabrice's avatar Roy Fabrice
Browse files

Merge branch 'fhi-and-syntax' into 'master'

Fhi and syntax

See merge request roy/pFoF_dev!2
parents a1c99fc2 9c14dee3
include ../../Make.inc
EXE = amr2cell_hdf5
EXE = amr2cell_hdf5.exe
COMMONDIR = ../../common/src/
OBJDIR=../../obj/
......@@ -9,10 +9,10 @@ VPATH= $(COMMONDIR):.
SRC = char_utils_m.f90 \
error_handling_m.f90 \
constants_m.f90 \
mpi_process_m.f90 \
timer_m.f90 \
shared_variables_m.f90 \
constants_m.f90 \
index_m.f90 \
ramses_info_m.f90 \
amr2cell_hdf5_parameters_m.f90 \
......
!------------------------------------------------------------------------------------------------------------------------------------
! 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
!! Global variables for amr2cell_hdf5
!! @brief
!!
!! @author Fabrice Roy
!> Global variables for amr2cell_hdf5
module shared_variables_m
use timer_m, only : timer_t
......
......@@ -36,8 +36,8 @@ module modreadcube
use hdf5, only : HID_T
use iso_fortran_env, only : OUTPUT_UNIT
use modconstant, only : IDKIND
use modmpicom, only : info_proc
use modvariables, only : common_meta, inforamses, ngrid, param, xmax, xmin, ymax, ymin, zmax, zmin
use mpi_communicator_m, only : info_proc
use variables_m, only : common_meta, inforamses, ngrid, param, xmax, xmin, ymax, ymin, zmax, zmin
use modmpicommons, only : Emergencystop, procid
use modvarcommons, only : field, global_npart, local_npart, nres, pfof_id, position, potential, velocity
use mpi
......
......@@ -160,11 +160,14 @@ contains
subroutine H5read_halo_dm_data(info_proc, filename, position_part, velocity_part, identity_part,&
mass_part, potential_part, field_part, parameter_pfof, info_ramses, info_cone)
use fortran_hdf5_constants_m, only : H5_FILENAME_LEN, H5_STR_LEN
use fortran_hdf5_manage_files_m, only : hdf5_close_file, hdf5_open_file
use fortran_hdf5_manage_groups_m, only : hdf5_close_group, hdf5_open_group
use fortran_hdf5_read_attribute_m
use fortran_hdf5_read_data_m
use iso_fortran_env, only : ERROR_UNIT, OUTPUT_UNIT
use modconstant, only : ERR_MSG_LEN, IDKIND, &
type_common_metadata, type_parameter_pfof, type_info_ramses, type_info_cone_part
use modhdf5, only : H5_FILENAME_LEN, HID_T, H5_STR_LEN, Hdf5_open_file, Hdf5_open_group, Hdf5_close_group,&
Hdf5_read_data, Hdf5_close_file
use modmpicommons, only : type_info_process
use modreadmeta, only : Read_meta_common, &
Read_meta_halofinder_parameter, &
......
......@@ -53,9 +53,9 @@ module mpi_process_m
procedure :: Init => Init_mpi_process
procedure :: Print => Print_mpi_process
end type mpi_process_t
contains
!----------------------------------------------------------------------------------------------------------------------------------
!> Initialize process
subroutine Init_mpi_process(process)
......@@ -70,6 +70,7 @@ contains
end subroutine Init_mpi_process
!----------------------------------------------------------------------------------------------------------------------------------
!> Print process
subroutine Print_mpi_process(process)
......
......@@ -25,17 +25,17 @@
!! @author Fabrice Roy
!> Subroutine to read one RAMSES part.out file
module read_ramses_part_mod
module read_ramses_part_file_m
implicit none
private
public :: Read_ramses_part
public :: Read_ramses_part_file
contains
!> Read a part. file produced by Ramses
subroutine Read_ramses_part(local_nparts, deltasd, nsd, filename, parameters, positions, velocities, identities, cube_ids, &
subroutine Read_ramses_part_file(local_nparts, deltasd, nsd, filename, parameters, positions, velocities, identities, cube_ids, &
masses, birth_dates, metallicities, fields, potentials)
use iso_fortran_env
......@@ -294,6 +294,6 @@ contains
close(part_unit)
end subroutine read_ramses_part
end subroutine Read_ramses_part_file
end module read_ramses_part_mod
end module read_ramses_part_file_m
......@@ -8,7 +8,6 @@ MODDIR=../../mod/
VPATH= $(COMMONDIR):.
SRC = modconstant.f90 \
mpi_process_m.f90 \
type_info_ramses_mod.f90\
modmpicommons.f90 \
modindex.f90 \
......@@ -24,15 +23,16 @@ SRC = modconstant.f90 \
modwritehalo.f90 \
modreadparameters.f90 \
modfofmpi.f90 \
modvariables.f90 \
modmpicom.f90 \
variables_m.f90 \
mpi_communicator_m.f90 \
modreadcube.f90 \
modwritedmcube.f90 \
modwritestarcube.f90 \
read_ramses_part_mod.f90 \
select_dm_mod.f90 \
modio.f90 \
modfofpara.f90 \
write_dm_cube_m.f90 \
write_star_cube_m.f90 \
read_ramses_part_file_m.f90 \
select_dm_m.f90 \
read_ramses_output_m.f90 \
io_utils_m.f90 \
parallel_fof_m.f90 \
pfof_snap.f90
OBJS_NOPREFIX=$(SRC:%.f90=%.o)
......@@ -47,6 +47,7 @@ else
OBJ_GIT = ../../.git/HEAD ../../.git/index
endif
$(OBJDIR)%.o:%.f90
@echo "--------------------------------"
@echo building $*.o with parameters \
......
!------------------------------------------------------------------------------------------------------------------------------------
! Copyright 2011 Fabrice Roy and Vincent Bouillot
!
! 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
!! This file contains subroutines used for I/O.
!> This module contains subroutines used for I/O.
!> Authors: F. Roy, V. Bouillot
module io_utils_m
use mpi
implicit none
private
public :: Print_screen_parameters,&
Init_parameters,&
The_end, &
Title, &
Write_timings
contains
!=======================================================================
!> This subroutines prints the title message on screen.
subroutine Title()
use iso_fortran_env, only : OUTPUT_UNIT
use modmpicommons, only : procnb
character(len=12) :: charpnb
write(charpnb(1:12),*) procnb
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) ' /\ \ /\ \ /\ \ /\ \ '
write(OUTPUT_UNIT,*) ' / \ \ / \ \ / \ \ / \ \ '
write(OUTPUT_UNIT,*) ' / /\ \ \ / /\ \ \ / /\ \ \ / /\ \ \ '
write(OUTPUT_UNIT,*) ' / / /\ \_\ / / /\ \_\ / / /\ \ \ / / /\ \_\ '
write(OUTPUT_UNIT,*) ' / / /_/ / // /_/_ \/_// / / \ \_\ / /_/_ \/_/ '
write(OUTPUT_UNIT,*) ' / / /__\/ // /____/\ / / / / / // /____/\ '
write(OUTPUT_UNIT,*) ' / / /_____// /\____\/ / / / / / // /\____\/ '
write(OUTPUT_UNIT,*) ' / / / / / / / / /___/ / // / / '
write(OUTPUT_UNIT,*) '/ / / / / / / / /____\/ // / / '
write(OUTPUT_UNIT,*) '\/_/ \/_/ \/_________/ \/_/ '
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) 'Code written by F.Roy and V.Bouillot'
write(OUTPUT_UNIT,*) 'based on a serial implementation written by E.Audit'
write(OUTPUT_UNIT,*) '(see A&A 564, A13 (2014))'
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) 'Snapshot version'
write(OUTPUT_UNIT,*) 'Number of processes: '//trim(adjustl(charpnb))
write(OUTPUT_UNIT,*) ' '
end subroutine Title
!=======================================================================
!> This subroutine print the final completion message on screen.
subroutine The_end()
use iso_fortran_env, only : OUTPUT_UNIT
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) 'Run Completed!'
write(OUTPUT_UNIT,*) ' '
end subroutine The_end
!=======================================================================
!> This subroutine reads the input parameters from pfof_snap.nml file (default name) with process 0
!! and broadcasts them to every processes.
!! It also writes the parameters in a log file and in a backup .nml file.
subroutine Init_parameters()
use iso_fortran_env, only : ERROR_UNIT, OUTPUT_UNIT
use modconstant, only : ERR_MSG_LEN, FILENAME_LEN, LOG_UNIT
use modmpicommons, only : create_mpi_type_param_pfof_snap, emergencystop, MPI_TYPE_PARAMETER_PFOF_SNAP, procid, procnb
use modreadparameters, only : read_pfof_snap_parameters
use variables_m, only : param
character(len=ERR_MSG_LEN) :: errormessage
character(len=FILENAME_LEN) :: filelog
character(len=FILENAME_LEN) :: filename
integer(kind=4) :: ioerr
integer(kind=4) :: mpierr
! The process 0 read the input parameters and pack them for the broadcast.
if(procid==0) then
filename='pfof_snap.nml'
call Read_pfof_snap_parameters(filename, param, ioerr, errormessage, .true.)
if(ioerr /= 0) then
write(ERROR_UNIT,*) errormessage
call EmergencyStop(errormessage,ioerr)
end if
write(OUTPUT_UNIT,*) 'Parallel FoF snapshot version'
write(OUTPUT_UNIT,*) procnb,' processes:'
! Open log file
filelog = 'pfof_log_'//trim(param%simulation_name)//'.log'
open(unit=LOG_UNIT,file=filelog)
write(LOG_UNIT,*) 'Parallel FoF'
write(LOG_UNIT,*) procnb,' processes:'
end if
call Create_mpi_type_param_pfof_snap()
call mpi_bcast(param, 1, mpi_type_parameter_pfof_snap, 0, MPI_COMM_WORLD, mpierr)
end subroutine Init_parameters
!=======================================================================
!> This subroutine writes the input parameters in a .nml file,
!! print them on screen and writes them in the .log file.
!! It should be called only from process 0.
subroutine Print_screen_parameters()
use iso_fortran_env, only : OUTPUT_UNIT
use modmpicommons, only : procid
use variables_m, only : param
if(procid==0) then
! Print input parameters on screen
write(OUTPUT_UNIT,*) 'Input parameters:'
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) 'Type of RAMSES input files: ',param%code_index
write(OUTPUT_UNIT,*) 'Path to input files: ',trim(param%input_path)
write(OUTPUT_UNIT,*) 'Particle files base name: ',trim(param%part_input_file)
write(OUTPUT_UNIT,*) 'Info file base name: ',trim(param%info_input_file)
write(OUTPUT_UNIT,*) 'Size of groups of inputs: ',param%grpsize
write(OUTPUT_UNIT,*) 'Should pFoF discard masses of particles: ',param%do_skip_mass
write(OUTPUT_UNIT,*) 'Were stars written in RAMSES files: ',param%star
write(OUTPUT_UNIT,*) 'Were metallicities written in RAMSES files: ',param%metal
write(OUTPUT_UNIT,*) 'Should pFoF discard stars: ',param%do_skip_star
write(OUTPUT_UNIT,*) 'Should pFoF discard metallicities: ',param%do_skip_metal
write(OUTPUT_UNIT,*) 'Were potentials written in RAMSES files: ',param%do_read_potential
write(OUTPUT_UNIT,*) 'Were forces written in RAMSES files: ',param%do_read_gravitational_field
write(OUTPUT_UNIT,*) 'Read particles from cube files: ',param%do_read_from_cube
write(OUTPUT_UNIT,*) 'Gather factor for cube input: ',param%gatherread_factor
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) 'Halo detection parameters:'
write(OUTPUT_UNIT,*) 'Percolation parameter: ',param%percolation_length
write(OUTPUT_UNIT,*) 'Minimum mass of halo to be analyzed: ',param%mmin
write(OUTPUT_UNIT,*) 'Maximum mass of halo to be analyzed: ',param%mmax
write(OUTPUT_UNIT,*) 'Perform friends of friends halo detection: ',param%do_fof
write(OUTPUT_UNIT,*) 'Perform unbinding: ',param%do_unbinding
write(OUTPUT_UNIT,*) 'Perform subhalo detection: ',param%do_subhalo
write(OUTPUT_UNIT,*) ' '
write(OUTPUT_UNIT,*) 'Output parameters:'
write(OUTPUT_UNIT,*) 'Simulation name: ',trim(param%simulation_name)
write(OUTPUT_UNIT,*) 'Snapshot number: ',param%snapshot
write(OUTPUT_UNIT,*) 'Write cubes of particles: ',param%do_write_cube
write(OUTPUT_UNIT,*) 'Gather factor for cube output: ',param%gatherwrite_factor
write(OUTPUT_UNIT,*) 'Sort particles in cube files: ',param%do_sort_cube
write(OUTPUT_UNIT,*) 'Perform timings (imply extra synchronisations): ',param%do_timings
write(OUTPUT_UNIT,*) ' '
end if
end subroutine Print_screen_parameters
!=======================================================================
!> This subroutine writes timings in the log file and prints them on screen.
!! It should be called only by process 0.
!! It also closes the log file.
subroutine Write_timings()
use iso_fortran_env, only : OUTPUT_UNIT
use modconstant, only : LOG_UNIT
use modtiming
tFoF = tFoFinit + tFoFloc + tRaccord
tOut = tOuthalopart+tOutmass
write(OUTPUT_UNIT,*) ''
write(OUTPUT_UNIT,*) 'Timings:'
write(OUTPUT_UNIT,*) 'Input:',tRead
write(OUTPUT_UNIT,*) ' initialization :',tInitRead
write(OUTPUT_UNIT,*) ' read input files :',tReadFile
write(OUTPUT_UNIT,*) ' scatter particles :',tTailPart
write(OUTPUT_UNIT,*) ''
write(OUTPUT_UNIT,*) 'Friend of Friend:',tFoF
write(OUTPUT_UNIT,*) ' initialization:',tFoFinit
write(OUTPUT_UNIT,*) ' local FoF :',tFoFloc
write(OUTPUT_UNIT,*) ' merge :',tRaccord
write(OUTPUT_UNIT,*) ''
write(OUTPUT_UNIT,*) 'Observables computation and output:',tObs + tOut + tSort + tGatherhalo + tSelecthalo
write(OUTPUT_UNIT,*) ' sort particles following haloID:',tSort
write(OUTPUT_UNIT,*) ' gather particles following haloID: ',tGatherhalo
write(OUTPUT_UNIT,*) ' select halo with M > Mmin: ',tSelecthalo
write(OUTPUT_UNIT,*) ' computation of observables:',tObs
write(OUTPUT_UNIT,*) ' write files:',tOuthalopart+tOutmass
write(LOG_UNIT,*) ''
write(LOG_UNIT,*) 'end of pFoF'
write(LOG_UNIT,*) ''
write(LOG_UNIT,*) 'Timings:'
write(LOG_UNIT,*) 'Input:',tRead
write(LOG_UNIT,*) ' initialization :',tInitRead
write(LOG_UNIT,*) ' read input files :',tReadFile
write(LOG_UNIT,*) ' scatter particles :',tTailPart
write(LOG_UNIT,*) ''
write(LOG_UNIT,*) 'Friend of Friend:',tFoF
write(LOG_UNIT,*) ' initialization:',tFoFinit
write(LOG_UNIT,*) ' local FoF :',tFoFloc
write(LOG_UNIT,*) ' merge :',tRaccord
write(LOG_UNIT,*) ''
write(LOG_UNIT,*) 'Observables computation and output:',tObs + tOut+ tSort + tGatherhalo + tSelecthalo
write(LOG_UNIT,*) ' sort particles following haloID:',tSort
write(LOG_UNIT,*) ' gather particles following haloID: ',tGatherhalo
write(LOG_UNIT,*) ' select halo with M > Mmin: ',tSelecthalo
write(LOG_UNIT,*) ' computation of observables:',tObs
write(LOG_UNIT,*) ' write files:',tOuthalopart+tOutmass
! Close log file
close(LOG_UNIT)
end subroutine Write_timings
end module io_utils_m
......@@ -23,7 +23,7 @@
!> This module contains the subroutines and the variables used for MPI communications.
!> Authors: F. Roy, V. Bouillot
module modmpicom
module mpi_communicator_m
use mpi
use modmpicommons, only : type_info_process,&
......@@ -167,7 +167,7 @@ contains
!! It also creates the communicators used for the parallel hdf5 i/o if they are needed.
subroutine setcommunicators()
use modvariables, only : param
use variables_m, only : param
integer(kind=4) :: mpierr
......@@ -272,4 +272,4 @@ contains
end subroutine setcommunicators
end module modmpicom
end module mpi_communicator_m
\ No newline at end of file
......@@ -24,7 +24,7 @@
!> This module contains the serial FOF algorithm.
!>
!> Authors: E. Audit, F. Roy, V. Bouillot
module modfofpara
module parallel_fof_m
use iso_fortran_env, only : ERROR_UNIT
use modindex, only : coord_to_id, id_to_coord
......@@ -49,7 +49,7 @@ contains
use compute_halo_properties_mod, only : compute_halo_com, compute_halo_radius
use modmpicommons, only : emergencystop, procid
use modmpicom, only : info_proc
use mpi_communicator_m, only : info_proc
use modconstant, only : IDKIND, LOG_UNIT
use modfofmpi, only : mergehaloes, border, nflagloc
......@@ -66,7 +66,7 @@ contains
use modwritehalo, only : h5writehalopart, mpih5writehalomass, mpih5writehalopart
use modtiming, only : tfofloc, tfofinit, tgatherhalo, time0, timeint, tobs, touthalopart, toutmass, traccord, tselecthalo, tsort
use modvarcommons, only : global_npart, local_npart, nres, pfof_id, position, structure_id
use modvariables, only : inforamses, param, xmax, xmin, ymax, ymin, zmax, zmin
use variables_m, only : inforamses, param, xmax, xmin, ymax, ymin, zmax, zmin
use mpi
! Local variables
......@@ -721,6 +721,4 @@ end subroutine Parallel_fof
end subroutine Init
end module modfofpara
end module parallel_fof_m
......@@ -25,19 +25,20 @@ program Friend
use iso_fortran_env, only : ERROR_UNIT, OUTPUT_UNIT
use modconstant, only : LOG_UNIT, ERR_CODE_WRONG_PARAMETER
use modfofpara, only : Parallel_fof
use parallel_fof_m, only : Parallel_fof
use fortran_hdf5_manage_interface_m, only : hdf5_finalize, hdf5_init
use modio, only : Print_screen_parameters, Init_parameters, Read_ramses, The_end, Title, Write_timings
use modmpicom, only : Setcommunicators
use io_utils_m, only : Print_screen_parameters, Init_parameters, The_end, Title, Write_timings
use mpi_communicator_m, only : Setcommunicators
use modmpicommons, only : Emergencystop, procid, procnb
use modreadcube, only : Readcube, Selectreadcubetype
use modtiming, only : tfof, tfofinit, tfofloc, timeint, tobs, tout, traccord, tread, treadfile
use modvarcommons, only : nres
use modvariables, only : ngrid, param
use modwritedmcube, only : Selectwritedmcube, Writedmcube
use modwritestarcube, only : Selectwritestarcube, Writestarcube
use read_ramses_output_m, only : Read_ramses_output
use variables_m, only : ngrid, param
use write_dm_cube_m, only : Selectwritedmcube, Writedmcube
use write_star_cube_m, only : Selectwritestarcube, Writestarcube
use mpi
use select_dm_mod, only : Select_dm_particles
use select_dm_m, only : Select_dm_particles
implicit none
......@@ -88,7 +89,7 @@ program Friend
! RA2 = RAMSES v2
! RA3 = RAMSES v3
! Read the output of the cosmological simulation
call Read_ramses()
call Read_ramses_output()
if (param%star) then
call Select_dm_particles()
end if
......
module select_dm_mod
!------------------------------------------------------------------------------------------------------------------------------------
! 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
!! Select dark matter particles from hydro simulations
!! @brief
!!
!! @author Fabrice Roy
!> Select dark matter particles from hydro simulations
!------------------------------------------------------------------------------------------------------------------------------------
module select_dm_m
use iso_fortran_env, only : ERROR_UNIT, OUTPUT_UNIT
implicit none
private
public :: Select_dm_particles
contains
subroutine Select_dm_particles()
......@@ -12,11 +44,12 @@ contains
use mpi
use modconstant, only : IDKIND, MPI_IDKIND
use modsort, only : heapsort
use modvariables, only : param
use variables_m, only : param
use modvarcommons, only : position, velocity, pfof_id, mass, birth_date, metallicity, field, potential, local_npart, &
star_position, star_velocity, star_ramses_id, star_mass, star_birth_date, star_metallicity, star_field, &
star_potential, global_nstar, local_nstar, global_npart
use modmpicommons, only : procid
integer(kind=4) :: ipart, local_npart_dm
real(kind=4), parameter :: EPSILON=1.e-7
integer(kind=IDKIND), allocatable, dimension(:) :: is_star
......@@ -228,4 +261,4 @@ contains
end subroutine Select_dm_particles
end module select_dm_mod
end module select_dm_m
......@@ -22,7 +22,7 @@
!! This file contains some global variables declarations.
!> This module contains some global variables declarations.
module modvariables
module variables_m
use modconstant, only : IDKIND, type_common_metadata, type_parameter_pfof_snap
use type_info_ramses_mod, only : type_info_ramses
......@@ -45,4 +45,4 @@ module modvariables
inforamses,&
common_meta
end module modvariables
end module variables_m