mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
modified to have a minimally compilable PANPHASIA_HO example inside monofonic
This commit is contained in:
parent
b567ba8e68
commit
f7c9d606f7
5 changed files with 1334 additions and 1191 deletions
|
@ -149,6 +149,9 @@ elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
|
||||||
endif()
|
endif()
|
||||||
endif(ENABLE_PANPHASIA)
|
endif(ENABLE_PANPHASIA)
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
# PANPHASIA HO (High-Order, new version)
|
||||||
|
option(ENABLE_PANPHASIA_HO "Enable PANPHASIA-HO random number generator" ON)
|
||||||
|
########################################################################################################################
|
||||||
# INCLUDES
|
# INCLUDES
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
@ -173,6 +176,16 @@ list (APPEND SOURCES
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_PANPHASIA_HO)
|
||||||
|
list (APPEND SOURCES
|
||||||
|
${PROJECT_SOURCE_DIR}/external/panphasia_ho/main.c
|
||||||
|
${PROJECT_SOURCE_DIR}/external/panphasia_ho/high_order_panphasia_routines.c
|
||||||
|
${PROJECT_SOURCE_DIR}/external/panphasia_ho/pan_mpi_routines.c
|
||||||
|
${PROJECT_SOURCE_DIR}/external/panphasia_ho/uniform_rand_threefry4x64.c
|
||||||
|
)
|
||||||
|
# target_include_directories(${PRGNAME} PRIVATE ${PROJECT_SOURCE_DIR}/external/panphasia_ho)
|
||||||
|
endif()
|
||||||
|
|
||||||
# project configuration header
|
# project configuration header
|
||||||
configure_file(
|
configure_file(
|
||||||
${PROJECT_SOURCE_DIR}/include/cmake_config.hh.in
|
${PROJECT_SOURCE_DIR}/include/cmake_config.hh.in
|
||||||
|
@ -246,6 +259,10 @@ if(ENABLE_PANPHASIA)
|
||||||
target_compile_definitions(${PRGNAME} PRIVATE "USE_PANPHASIA")
|
target_compile_definitions(${PRGNAME} PRIVATE "USE_PANPHASIA")
|
||||||
endif(ENABLE_PANPHASIA)
|
endif(ENABLE_PANPHASIA)
|
||||||
|
|
||||||
|
if(ENABLE_PANPHASIA_HO)
|
||||||
|
target_compile_definitions(${PRGNAME} PRIVATE "USE_PANPHASIA_HO")
|
||||||
|
endif(ENABLE_PANPHASIA_HO)
|
||||||
|
|
||||||
if(ENABLE_PLT)
|
if(ENABLE_PLT)
|
||||||
target_compile_definitions(${PRGNAME} PRIVATE "ENABLE_PLT")
|
target_compile_definitions(${PRGNAME} PRIVATE "ENABLE_PLT")
|
||||||
endif(ENABLE_PLT)
|
endif(ENABLE_PLT)
|
||||||
|
|
|
@ -89,15 +89,15 @@ ztarget = 2.5 # target redshift for CLASS module, output at
|
||||||
##> NGenIC compatible random number generator module compatible with V. Springel's original code
|
##> NGenIC compatible random number generator module compatible with V. Springel's original code
|
||||||
## (https://www.h-its.org/2014/11/05/ngenic-code/) as well as the 2LPT code by Pueblas&Scoccmiarro
|
## (https://www.h-its.org/2014/11/05/ngenic-code/) as well as the 2LPT code by Pueblas&Scoccmiarro
|
||||||
## (https://cosmo.nyu.edu/roman/2LPT/)
|
## (https://cosmo.nyu.edu/roman/2LPT/)
|
||||||
generator = NGENIC
|
# generator = NGENIC
|
||||||
seed = 12345
|
# seed = 12345
|
||||||
|
|
||||||
##> The PANPHASIA generator uses a plugin based on original code by A. Jenkins
|
##> The PANPHASIA generator uses a plugin based on original code by A. Jenkins
|
||||||
## Warning: Before using this module, please make sure you read and agree to the distinct license
|
## Warning: Before using this module, please make sure you read and agree to the distinct license
|
||||||
## requirements by registering on the website http://icc.dur.ac.uk/Panphasia.php
|
## requirements by registering on the website http://icc.dur.ac.uk/Panphasia.php
|
||||||
|
|
||||||
# generator = PANPHASIA
|
generator = PANPHASIA_HO
|
||||||
# descriptor = [Panph1,L10,(800,224,576),S9,CH1564365824,MXXL]
|
descriptor = [Panph1,L10,(800,224,576),S9,CH1564365824,MXXL]
|
||||||
# PanphasiaMinRootResolution = 512 # requires the white noise reallisation to be made at least at that resolution (default is 512)
|
# PanphasiaMinRootResolution = 512 # requires the white noise reallisation to be made at least at that resolution (default is 512)
|
||||||
|
|
||||||
##> The MUSIC1 multi-scale random number generator is provided for convenience
|
##> The MUSIC1 multi-scale random number generator is provided for convenience
|
||||||
|
|
2204
external/panphasia_ho/high_order_panphasia_routines.c
vendored
2204
external/panphasia_ho/high_order_panphasia_routines.c
vendored
File diff suppressed because it is too large
Load diff
133
external/panphasia_ho/main.c
vendored
133
external/panphasia_ho/main.c
vendored
|
@ -6,8 +6,6 @@
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
#include <fftw3-mpi.h>
|
#include <fftw3-mpi.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "PAN_FFTW3.h"
|
#include "PAN_FFTW3.h"
|
||||||
#include "panphasia_functions.h"
|
#include "panphasia_functions.h"
|
||||||
|
|
||||||
|
@ -19,79 +17,114 @@ int threads_ok;
|
||||||
int number_omp_threads = 1;
|
int number_omp_threads = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// does the same as the main below, but does not initialise MPI or FFTW (this should be done in MONOFONIC)
|
||||||
|
int PANPHASIA_HO_main(void)
|
||||||
|
{
|
||||||
|
int verbose = 0;
|
||||||
|
int error;
|
||||||
|
size_t x0 = 0, y0 = 0, z0 = 0;
|
||||||
|
size_t rel_level;
|
||||||
|
char descriptor[300] = "[Panph6,L20,(424060,82570,148256),S1,KK0,CH-999,Auriga_100_vol2]";
|
||||||
|
|
||||||
|
PANPHASIA_init_descriptor_(descriptor, &verbose);
|
||||||
|
|
||||||
|
rel_level = 6; //Set size of test dataset
|
||||||
|
|
||||||
|
if (error = PANPHASIA_init_level_(&rel_level, &x0, &y0, &z0, &verbose))
|
||||||
|
{
|
||||||
|
printf("Abort: PANPHASIA_init_level_ :error code %d\n", error);
|
||||||
|
abort();
|
||||||
|
};
|
||||||
|
|
||||||
|
//======================= FFTW ==============================
|
||||||
|
|
||||||
|
ptrdiff_t alloc_local, local_n0, local_0_start;
|
||||||
|
|
||||||
|
ptrdiff_t N0 = descriptor_base_size << rel_level;
|
||||||
|
|
||||||
|
alloc_local = FFTW_MPI_LOCAL_SIZE_3D(N0, N0, N0, MPI_COMM_WORLD, &local_n0, &local_0_start);
|
||||||
|
|
||||||
|
FFTW_COMPLEX *Panphasia_White_Noise_Field;
|
||||||
|
|
||||||
|
Panphasia_White_Noise_Field = FFTW_ALLOC_COMPLEX(alloc_local);
|
||||||
|
|
||||||
|
if (error = PANPHASIA_compute_kspace_field_(rel_level, N0, local_n0, local_0_start, Panphasia_White_Noise_Field))
|
||||||
|
{
|
||||||
|
printf("Error code from PANPHASIA_compute ... %d\n", error);
|
||||||
|
};
|
||||||
|
|
||||||
|
fftw_free(Panphasia_White_Noise_Field);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef STANDALONE_PANPHASIA_HO
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
int verbose=0;
|
int verbose = 0;
|
||||||
int error;
|
int error;
|
||||||
size_t x0=0, y0=0, z0=0;
|
size_t x0 = 0, y0 = 0, z0 = 0;
|
||||||
size_t rel_level;
|
size_t rel_level;
|
||||||
char descriptor[300] = "[Panph6,L20,(424060,82570,148256),S1,KK0,CH-999,Auriga_100_vol2]";
|
char descriptor[300] = "[Panph6,L20,(424060,82570,148256),S1,KK0,CH-999,Auriga_100_vol2]";
|
||||||
|
|
||||||
#ifdef USE_OPENMP
|
#ifdef USE_OPENMP
|
||||||
omp_set_num_threads(number_omp_threads);
|
omp_set_num_threads(number_omp_threads);
|
||||||
int provided;
|
int provided;
|
||||||
MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided);
|
MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided);
|
||||||
threads_ok = provided >= MPI_THREAD_FUNNELED;
|
threads_ok = provided >= MPI_THREAD_FUNNELED;
|
||||||
if (threads_ok) threads_ok = fftw_init_threads();
|
if (threads_ok)
|
||||||
fftw_mpi_init();
|
threads_ok = fftw_init_threads();
|
||||||
int num_threads = number_omp_threads ;
|
fftw_mpi_init();
|
||||||
if (threads_ok){
|
int num_threads = number_omp_threads;
|
||||||
|
if (threads_ok)
|
||||||
|
{
|
||||||
fftw_plan_with_nthreads(num_threads);
|
fftw_plan_with_nthreads(num_threads);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf("Failure to initialise threads ...\n");
|
printf("Failure to initialise threads ...\n");
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("OpenMP threads enabled with FFTW. Number of threads %d\n",fftw_planner_nthreads());
|
printf("OpenMP threads enabled with FFTW. Number of threads %d\n", fftw_planner_nthreads());
|
||||||
#else
|
#else
|
||||||
MPI_Init(&argc, &argv);
|
MPI_Init(&argc, &argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PANPHASIA_init_descriptor_(descriptor,&verbose);
|
PANPHASIA_init_descriptor_(descriptor, &verbose);
|
||||||
|
|
||||||
|
rel_level = 6; //Set size of test dataset
|
||||||
|
|
||||||
rel_level = 6; //Set size of test dataset
|
if (error = PANPHASIA_init_level_(&rel_level, &x0, &y0, &z0, &verbose))
|
||||||
|
{
|
||||||
|
printf("Abort: PANPHASIA_init_level_ :error code %d\n", error);
|
||||||
|
abort();
|
||||||
|
};
|
||||||
|
|
||||||
|
//======================= FFTW ==============================
|
||||||
|
|
||||||
if (error=PANPHASIA_init_level_(&rel_level,&x0,&y0,&z0,&verbose)){
|
fftw_mpi_init();
|
||||||
printf("Abort: PANPHASIA_init_level_ :error code %d\n",error);
|
|
||||||
abort();
|
|
||||||
};
|
|
||||||
|
|
||||||
//======================= FFTW ==============================
|
ptrdiff_t alloc_local, local_n0, local_0_start;
|
||||||
|
|
||||||
fftw_mpi_init();
|
ptrdiff_t N0 = descriptor_base_size << rel_level;
|
||||||
|
|
||||||
ptrdiff_t alloc_local, local_n0, local_0_start;
|
alloc_local = FFTW_MPI_LOCAL_SIZE_3D(N0, N0, N0, MPI_COMM_WORLD, &local_n0, &local_0_start);
|
||||||
|
|
||||||
ptrdiff_t N0 = descriptor_base_size<<rel_level;
|
FFTW_COMPLEX *Panphasia_White_Noise_Field;
|
||||||
|
|
||||||
alloc_local = FFTW_MPI_LOCAL_SIZE_3D(N0,N0,N0,MPI_COMM_WORLD,&local_n0,&local_0_start);
|
Panphasia_White_Noise_Field = FFTW_ALLOC_COMPLEX(alloc_local);
|
||||||
|
|
||||||
|
if (error = PANPHASIA_compute_kspace_field_(rel_level, N0, local_n0, local_0_start, Panphasia_White_Noise_Field))
|
||||||
|
{
|
||||||
|
printf("Error code from PANPHASIA_compute ... %d\n", error);
|
||||||
|
};
|
||||||
|
|
||||||
FFTW_COMPLEX *Panphasia_White_Noise_Field;
|
fftw_free(Panphasia_White_Noise_Field);
|
||||||
|
|
||||||
Panphasia_White_Noise_Field = FFTW_ALLOC_COMPLEX(alloc_local);
|
fftw_mpi_cleanup();
|
||||||
|
//==================== End FFTW ===========================
|
||||||
|
|
||||||
|
MPI_Finalize();
|
||||||
if (error = PANPHASIA_compute_kspace_field_(rel_level,N0, local_n0,local_0_start,Panphasia_White_Noise_Field)){
|
|
||||||
printf("Error code from PANPHASIA_compute ... %d\n",error);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fftw_free(Panphasia_White_Noise_Field);
|
|
||||||
|
|
||||||
fftw_mpi_cleanup();
|
|
||||||
//==================== End FFTW ===========================
|
|
||||||
|
|
||||||
|
|
||||||
MPI_Finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // STANDALONE_PANPHASIA_HO
|
||||||
|
|
||||||
|
|
83
src/plugins/random_panphasia_ho.cc
Normal file
83
src/plugins/random_panphasia_ho.cc
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
// This file is part of monofonIC (MUSIC2)
|
||||||
|
// A software package to generate ICs for cosmological simulations
|
||||||
|
// Copyright (C) 2021 by Oliver Hahn and Adrian Jenkins (this file)
|
||||||
|
// but see distinct licensing for PANPHASIA below
|
||||||
|
//
|
||||||
|
// monofonIC 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.
|
||||||
|
//
|
||||||
|
// monofonIC 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// IMPORTANT NOTICE:
|
||||||
|
// Note that PANPHASIA itself is not released under the GPL. Make sure
|
||||||
|
// to read and agree to its distinct licensing before you use or modify
|
||||||
|
// the code below or in the /external/panphasia directory which can be
|
||||||
|
// found here: http://icc.dur.ac.uk/Panphasia.php
|
||||||
|
// NOTE THAT PANPHASIA REQUIRES REGISTRATION ON THIS WEBSITE PRIOR TO USE
|
||||||
|
|
||||||
|
#if defined(USE_PANPHASIA_HO)
|
||||||
|
|
||||||
|
#include <general.hh>
|
||||||
|
#include <random_plugin.hh>
|
||||||
|
#include <config_file.hh>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <grid_fft.hh>
|
||||||
|
|
||||||
|
extern "C"{
|
||||||
|
int PANPHASIA_HO_main( void );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RNG_panphasia_ho : public RNG_plugin
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
protected:
|
||||||
|
std::string descriptor_string_;
|
||||||
|
int num_threads_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit RNG_panphasia_ho(config_file &cf) : RNG_plugin(cf)
|
||||||
|
{
|
||||||
|
descriptor_string_ = pcf_->get_value<std::string>("random", "descriptor");
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
num_threads_ = omp_get_max_threads();
|
||||||
|
#else
|
||||||
|
num_threads_ = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PANPHASIA_HO_main();
|
||||||
|
}
|
||||||
|
|
||||||
|
~RNG_panphasia_ho() { }
|
||||||
|
|
||||||
|
bool isMultiscale() const { return true; }
|
||||||
|
|
||||||
|
void Fill_Grid(Grid_FFT<real_t> &g)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
RNG_plugin_creator_concrete<RNG_panphasia_ho> creator("PANPHASIA_HO");
|
||||||
|
}
|
||||||
|
#endif // defined(USE_PANPHASIA_HO)
|
Loading…
Reference in a new issue