Skip to content

Commit

Permalink
added easier implementation of uniform dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
matmartinelli committed Jun 13, 2017
1 parent 1277924 commit 9b5e9d7
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion camb/camb/constants.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ subroutine GlobalError(message, id)
global_error_message=''
end if
if (present(id)) then
if (id==0) error stop('Error id must be non-zero')
if (id==0) error stop ('Error id must be non-zero')
global_error_flag=id
else
global_error_flag=-1
Expand Down
2 changes: 1 addition & 1 deletion camb/eftcamb/constants.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ subroutine GlobalError(message, id)
global_error_message=''
end if
if (present(id)) then
if (id==0) error stop('Error id must be non-zero')
if (id==0) error stop ('Error id must be non-zero')
global_error_flag=id
else
global_error_flag=-1
Expand Down
2 changes: 1 addition & 1 deletion camb/mgcamb/constants.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ subroutine GlobalError(message, id)
global_error_message=''
end if
if (present(id)) then
if (id==0) error stop('Error id must be non-zero')
if (id==0) error stop ('Error id must be non-zero')
global_error_flag=id
else
global_error_flag=-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@
# This is only a test

#Fiducial value for the alpha coupling
alpha_coupling = 1.e-5
alpha_coupling = -3.e-5


#Experimental specifications
number_alpha_redshifts = 4
number_alpha_redshifts = 100
uniform = T

#If uniform = T reads these
alpha_zmin = 0.5
alpha_zmax = 4.0
alpha_uniform_error = 1.e-7


#If uniform = F reads these
alpha_redshift(1) = 0
alpha_redshift(2) = 1
alpha_redshift(3) = 2
alpha_redshift(4) = 3



alpha_error(1) = 1.e-6
alpha_error(2) = 1.e-6
alpha_error(3) = 1.e-6
alpha_error(4) = 1.e-6
alpha_error(1) = 1.e-7
alpha_error(2) = 1.e-7
alpha_error(3) = 1.e-7
alpha_error(4) = 1.e-7

2 changes: 1 addition & 1 deletion examples/parameters/3_varying_alpha.camb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DEFAULT(./parameters/common/common_params_eft.ini)
l_max_scalar = 2500


DEFAULT(./experiments/alpha/mockname.ini)
DEFAULT(./experiments/alpha/codex.ini)
#alpha_coupling = 1.e-5

# CosmicFish parameters to run:
Expand Down
2 changes: 2 additions & 0 deletions sources/004_cosmicfish_types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ module cosmicfish_types
integer :: number_alpha_redshifts
integer, dimension(:), allocatable :: alpha_error !< Error on delta alpha/alpha at each redshift
real(dl), dimension(:), allocatable :: alpha_redshift !< center of redshift bins
real(dl) :: alpha_zmin, alpha_zmax !< limits of uniform data range
logical :: alpha_uniform !< if T makes uniform distribution of data

! fiducial alpha variation parameters:
real(dl) :: alpha_coupling !< fiducial value of the alpha coupling
Expand Down
24 changes: 19 additions & 5 deletions sources/005_init_from_file.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ subroutine init_cosmicfish_from_file( P, FP, filename, param_out_name )

!MMmod
character(LEN=Ini_max_string_len) red_ind
real(dl) :: alpha_step

! open the parameter file:
call Ini_Open(filename, 1, bad, .false.)
Expand Down Expand Up @@ -773,13 +774,26 @@ subroutine init_cosmicfish_from_file( P, FP, filename, param_out_name )
FP%fisher_alpha%alpha_coupling = Ini_Read_Double('alpha_coupling' , 0._dl )

FP%fisher_alpha%number_alpha_redshifts = Ini_Read_Int( 'number_alpha_redshifts', 0 )
FP%fisher_alpha%alpha_uniform = Ini_Read_Logical('uniform',.true.)

allocate(FP%fisher_alpha%alpha_redshift(FP%fisher_alpha%number_alpha_redshifts))
allocate(FP%fisher_alpha%alpha_error(FP%fisher_alpha%number_alpha_redshifts))
do i =1,FP%fisher_alpha%number_alpha_redshifts
write(red_ind,*) i
FP%fisher_alpha%alpha_redshift(i) = Ini_Read_Double( 'alpha_redshift('//trim(adjustl(red_ind))//')')
FP%fisher_alpha%alpha_error(i) = Ini_Read_Double( 'alpha_error('//trim(adjustl(red_ind))//')')
end do
if (FP%fisher_alpha%alpha_uniform) then
FP%fisher_alpha%alpha_zmin = Ini_Read_Double( 'alpha_zmin')
FP%fisher_alpha%alpha_zmax = Ini_Read_Double( 'alpha_zmax')
alpha_step = (FP%fisher_alpha%alpha_zmax-FP%fisher_alpha%alpha_zmin)/FP%fisher_alpha%number_alpha_redshifts
FP%fisher_alpha%alpha_redshift(1) = FP%fisher_alpha%alpha_zmin
FP%fisher_alpha%alpha_error(:) = Ini_Read_Double( 'alpha_uniform_error' )
do i =2,FP%fisher_alpha%number_alpha_redshifts
FP%fisher_alpha%alpha_redshift(i) = FP%fisher_alpha%alpha_zmin + alpha_step
end do
else
do i =1,FP%fisher_alpha%number_alpha_redshifts
write(red_ind,*) i
FP%fisher_alpha%alpha_redshift(i) = Ini_Read_Double( 'alpha_redshift('//trim(adjustl(red_ind))//')')
FP%fisher_alpha%alpha_error(i) = Ini_Read_Double( 'alpha_error('//trim(adjustl(red_ind))//')')
end do
end if
end if
!------------------------------------------------------------------------------

Expand Down

0 comments on commit 9b5e9d7

Please sign in to comment.