Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
damonge committed Feb 19, 2016
0 parents commit 3d7ef2d
Show file tree
Hide file tree
Showing 16 changed files with 4,755 additions and 0 deletions.
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
########## User-definable stuff ##########
#
###Compiler and compilation options
COMP_SER = gcc
COMP_MPI = mpicc
OPTIONS = -Wall -O3
#
### Behavioural flags
#Use double precision integer (enable in general)
DEFINEFLAGS += -D_LONGIDS
#Generate debug help. Only useful for development
DEFINEFLAGS += -D_DEBUG
#Use double precision floating point? Set to "yes" or "no"
USE_SINGLE_PRECISION = yes
#Use OMP parallelization? Set to "yes" or "no"
USE_OMP = yes
#Use MPI parallelization? Set to "yes" or "no"
USE_MPI = yes
#
###Path to libraries and headers
###If two or more of the dependencies reside in the same paths, only
###one instance is necessary.
#GSL
GSL_INC = -I/home/damonge/include
GSL_LIB = -L/home/damonge/lib
#FFTW
FFTW_INC =
FFTW_LIB =
#cfitsio
FITS_INC =
FITS_LIB =
#
########## End of user-definable ##########

ifeq ($(strip $(USE_OMP)),yes)
OPTIONS += -fopenmp
DEFINEFLAGS += -D_HAVE_OMP
endif #OMP

ifeq ($(strip $(USE_MPI)),yes)
DEFINEFLAGS += -D_HAVE_MPI
COMP_PAR = $(COMP_MPI)
else #MPI
COMP_PAR = $(COMP_SER)
endif #MPI

ifeq ($(strip $(USE_SINGLE_PRECISION)),yes)
DEFINEFLAGS += -D_SPREC

ifeq ($(strip $(USE_OMP)),yes)
LIB_FFTW += -lfftw3f_omp
endif #OMP
ifeq ($(strip $(USE_MPI)),yes)
LIB_FFTW += -lfftw3f_mpi
endif #MPI
LIB_FFTW += -lfftw3f

else #SINGLE_PRECISION

ifeq ($(strip $(USE_OMP)),yes)
LIB_FFTW += -lfftw3_omp
endif #OMP
ifeq ($(strip $(USE_MPI)),yes)
LIB_FFTW += -lfftw3_mpi
endif #MPI
LIB_FFTW += -lfftw3

endif #SINGLE_PRECISION


OPTIONS += $(DEFINEFLAGS)

INC_ALL = -I./src $(GSL_INC) $(FFTW_INC) $(FITS_INC)
LIB_ALL = $(GSL_LIB) $(FFTW_LIB) $(FITS_LIB) -lgsl -lgslcblas $(LIB_FFTW) -lcfitsio -lm

COMMONO = src/common.o
COSMOMADO = src/cosmo_mad.o
COSMOO = src/cosmo.o
FOURIERO = src/fourier.o
GRIDO = src/grid_tools.o
IOO = src/io.o
MAIN = src/main.c
OFILES = $(COMMONO) $(COSMOMADO) $(COSMOO) $(FOURIERO) $(GRIDO) $(IOO)

EXEC = CoLoRe

default : $(EXEC)

%.o : %.c
$(COMP_CC) $(OPTIONS) $(INC_ALL) -c $< -o $@

$(OFILES) : COMP_CC := $(COMP_PAR)

$(EXEC) : $(OFILES)
$(COMP_PAR) $(OPTIONS) $(INC_ALL) $(OFILES) $(MAIN) -o $(EXEC) $(LIB_ALL)

clean :
rm -f src/*.o

cleaner :
rm -f *~ src/*.o src/*~ $(EXEC)
89 changes: 89 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
CoLoRe - Cosmological Lognormal Realizations


1 Methods.

CoLoRe is a parallel C code for generating fast mock realizations
of a given galaxy sample using a lognormal model for the matter density.
The process is as follows:
1) Generate a Gaussian realization of the linearized density field at
z=0, as well as the corresponding linear radial velocity field.
This is done in a Cartesian grid.
2) Calculate the redshift of each grid point and linearly evolve
the density and velocity to that redshift. Include a linear galaxy
bias (redshift-dependent) in the evolution of the overdensity field.
3) Log-normalize the density field and poisson-sample it using an
input N(z). Each source is randomly placed inside its cell.
4) Compute the cosmological redshift and angular coordinates for each
source, and introduce redshift-space distortions based on the local
value of the velocity field.
5) Write sources to file.

The source code can be found in the folder "src/"

When in doubt, bear in mind that by default CoLoRe uses the following units:
- Lenghts: Mpc/h
- Angles: degrees


2 Compilation and usage.

To compile CoLoRe, open the Makefile and edit it according to your
system. The default options (except for the paths to the external
libraries) should work for most systems. CoLoRe may be very memory-
demanding. To minimize the memory overhead use single precision
floating point (USE_PRECISION = yes).

OpenMP parallelization is enabled by setting the option USE_OMP
to "yes".

MPI parallelization is enabled by setting the option USE_MPI
to "yes".

CoLoRe uses 3 external packages:
- GSL. The GNU Scientific Library (tested for versions 3.*)
- FFTW. The Fastest Fourier Transform of the West (versions 3.*)
- CFITSIO. FITS format library.
The paths to the corresponding headers and libraries should be correctly
set in the Makefile.

Once the Makefile has been editted, typing 'make' should generate
the executable 'CoLoRe'. To run CoLoRe just type

> mpirun -np <number-of-nodes> ./CoLoRe <param_file>

where <param_file> is the path to the parameter file described in
section 3.


3 Parameter file.

The behaviour of CoLoRe is mainly controlled by the input param file. The
param file is basically a set of name-value pairs. Any blank lines, and
anything beyond a #-symbol will be ignored. We provide a sample param
file (param_sample.ini) that includes all the input parameters needed by
CoLoRe. The comments included in this file explain the meaning and
functionality of these parameters.


4 Output.

The main output of CoLoRe is a catalogue of sources written either
as ASCII or FITS files. Each source is characterized by 4 quantities:
- Z0 -> cosmological redshift (without RSDs)
- RA -> right ascension
- DEC -> declination
- RSD -> RSD contribution to the redshift
(i.e. true redshift = Z0 + RSD).


5 License:
CoLoRe is distributed under the GPL license (see COPYING in the root
directory). We kindly ask you to report the program's website
"https://github.com/damonge/CoLoRe" when using it.


6 Contact:
Regarding bugs, suggestions, questions or petitions, feel free to contact
the author:
David Alonso: [email protected]
46 changes: 46 additions & 0 deletions param_sample.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
###File names
#Output prefix. Output will be in prefix_<node ID>.<fits/txt>
prefix_out= out
#Output format. Select FITS or ASCII
output_format= FITS
#Path to power spectrum at z=0. Power spectrum file must
#be in CAMB format: k (h/Mpc), P(k) (Mpc/h)^3.
pk_filename= test_files/Pk_CAMB_test.dat
#Path to N(z) file. Should contain two columns
# 1-> z, 2-> dN(z)/dz*dOmega
# with dN/dzdOmega in units of deg^-2
nz_filename= test_files/Nz_test.txt
#Path to bias file. Should contain two columns
# 1-> z, 2-> b(z)
bias_filename= test_files/Bz_test.txt

###Cosmological parameters
#Non-relativistic matter
omega_M= 0.3
#Dark energy
omega_L= 0.7
#Baryons
omega_B= 0.049
#Hubble parameter (in units of 100 km/s/Mpc)
h= 0.67
#Dark energy equation of state
w= -1.0
#Primordial scalar spectral index
ns= 0.96
#Power spectrum normalization
sigma_8= 0.8

###Redshift range
z_min= 0.1
z_max= 0.5

###Extra Gaussian smoothing scale [Mpc/h] (set to a
#negative value if you don't want any smoothing)
r_smooth= 2.

###Grid resolution.
#Will use a Cartesian grid with n_grid^3 cells
n_grid= 128

###RNG seed
seed= 1001
Loading

0 comments on commit 3d7ef2d

Please sign in to comment.