Skip to content

Commit

Permalink
Merge pull request #1 from SBU-COSMOLIKE/main
Browse files Browse the repository at this point in the history
v3.1
  • Loading branch information
vivianmiranda authored Aug 24, 2023
2 parents ffa453e + 1eda334 commit 54fae81
Show file tree
Hide file tree
Showing 48 changed files with 4,014 additions and 1,649 deletions.
2 changes: 2 additions & 0 deletions Cocoa/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ core.*
*.egg-info/
*.out
*.egg
*.vfproj
*.sln

Cocoa/external_modules/code/planck/code/spt_clik/svnversion
Cocoa/external_modules/code/PolyChordLite/dist/
Expand Down
2 changes: 2 additions & 0 deletions Cocoa/cobaya/cobaya/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ def compute_temperature(logpost, logprior, loglike, check=True):
of the sample temperature, and raises ``AssertionError`` if inconsistent.
"""
temp = (logprior + loglike) / logpost
#VM BEGINS
if check and isinstance(temp, Iterable) and len(temp) > 1:
assert np.allclose(temp, temp[0]), "Inconsistent temperature in sample."
temp = temp[0]
#VM ENDS
return temp


Expand Down
7 changes: 7 additions & 0 deletions Cocoa/external_modules/code/CAMB/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.txt text
*.f90 text
*.F90 text
Makefile* text
*.m text
*.dat text
*.ini text
21 changes: 21 additions & 0 deletions Cocoa/external_modules/code/CAMB/.readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2

python:
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
path: .

sphinx:
configuration: docs/source/conf.py

formats: all

build:
apt_packages:
- gfortran


submodules:
include: all
105 changes: 105 additions & 0 deletions Cocoa/external_modules/code/CAMB/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
os: linux
language: python

git:
depth: false

dist: bionic

branches:
except:
- CAMB_sources
- rayleigh

jobs:
include:
- name: "Ubuntu 20.04 + Python 3.7"
dist: focal
addons:
apt:
packages:
- gfortran
python: "3.7"
env:
- PYPI_DIST="true"
- name: "GCC10 + Python 3.10 anaconda"
dist: focal
addons:
apt:
packages:
- gfortran-10
env:
- GCC_VERSION="10"
- CHANNEL="defaults"
- PYDIST="ANACONDA"
- FORTRAN="test"
python: "3.10"
- name: "Ubuntu 22.04 + Python 3.11"
dist: jammy
addons:
apt:
packages:
- gfortran
env:
- CHANNEL="defaults"
python: "3.11"
- name: "GCC trunk cosmobox"
language: shell
services:
- docker
before_install:
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
fi
- docker pull cmbant/cosmobox:devel
install:
- chmod +x fortran/tests/run_tests.sh
script:
- docker run -v $(pwd):/camb -t cmbant/cosmobox:devel /bin/bash -c "cd /camb; fortran/tests/run_tests.sh"
after_failure:
- echo "docker fail"

install:
- if [[ "$PYDIST" == "ANACONDA" ]]; then
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p $HOME/miniconda;
export PATH="$HOME/miniconda/bin:$PATH";
hash -r;
conda config --set always_yes yes --set changeps1 no;
conda info -a;
conda create -q -n test-environment -c $CHANNEL python=$TRAVIS_PYTHON_VERSION numpy scipy sympy;
source activate test-environment;
fi
- if [[ "$FORTRAN" == "test" ]]; then
mkdir -p gfortran-symlinks;
ln -s /usr/bin/gfortran-$GCC_VERSION gfortran-symlinks/gfortran;
export PATH=$PWD/gfortran-symlinks:$PATH;
fi
- if [[ "$GCC_VERSION" == "10" ]]; then
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.5;
fi
- gfortran --version
- chmod +x fortran/tests/run_tests.sh
- pip install flake8

script:
- flake8 camb --select=E713,E704,E703,E714,E10,E11,E20,E22,E23,E25,E27,E301,E302,E304,E9,E741,F405,F406,F5,F6,F7,F8,W1,W2,W3,W6 --show-source --statistics
- fortran/tests/run_tests.sh

after_failure:
- test $TRAVIS_PULL_REQUEST == "false" && test $PYPI_DIST == "true" && test $TRAVIS_REPO_SLUG == "cmbant/CAMB" && [ -d fortran/testfiles ] && bash fortran/tests/upload_tests.sh

before_deploy:
- pushd fortran; make clean delete; popd

deploy:
- provider: pypi
distributions: sdist
username: "cmbant"
password:
secure: "UA+nTWbEND3R/KVodbAG/2xXcCibpotNO+PHBIokR8fm7KmYdjSnXF3OXBDNvFPYEQg2KY7L/JviCbUM9yfZmtekvMg7aKP/2fuHcayByNy5VJ4mUgcA48ft6LKp/sLS/8fn7nCzHbclT/Ye/Wo3PmGK1mQqbu9oxXGidY8C7pbXB9ZYnssdMH9DHXSqjIAL23yN95G8U1n9bVLI0dZB0ORFHro/f7XeIPrzJEdEgql33BSq5YArf7WK/2Vlo8Zk0vPNT1xRJvEdNaJ/VZ5Nk31yuym04ZekmWlBmi+kTsO0zwD4wQrkCFGm9qb31JRHjuRTpxrHUTkiXwTvYutmwNtHqJ3SYkQgoTmb6qi9f4Nha3mtAbRviTDxgVi8Dv4gWp59iXVcOQMhRM9hxiCK7QwMkHJsvss4XuL149eLFLP7TfNw6PwHo/tpMMyRyDBdwgT+Vz0wNUyncEKwsgunxgvct9sy4TKNs96NJ90cTee3ditq/ZmrLjzp0xjQkBW5nA1AiW/9g3KkozkWh0Q74qGR1qrSlKInM7na64zLnp8seRb71Ki+2Ad+gx+fREnTmmgBSTIav4AjQCc+hnEIYnZ57DyNqIaqON25jiL1i85oaAdWLDR5pctWlebmzRcS2PvuvgqB76bvgLnIoHPg8pRm4Li7wvYCQhi9fo9RvR4="
on:
branch: master
repo: cmbant/CAMB
tags: true
condition: $PYPI_DIST = true
2 changes: 1 addition & 1 deletion Cocoa/external_modules/code/CAMB/camb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = "Antony Lewis"
__contact__ = "antony at cosmologist dot info"
__url__ = "https://camb.readthedocs.io"
__version__ = "1.4.2.1"
__version__ = "1.5.0"

from . import baseconfig

Expand Down
4 changes: 1 addition & 3 deletions Cocoa/external_modules/code/CAMB/camb/_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ def call_command(cmd):
def get_ifort_version():
return call_command("ifort -v")


#VM BEGINS
#COCOA BEGINS
def get_gfortran_version():
def get_gfortran_version(command='gfortran'):
ver = call_command("$FORTRAN_COMPILER -dumpversion")
if ver and '.' not in ver:
ver = call_command("$FORTRAN_COMPILER -dumpfullversion")
return ver
#COCOA ENDS
#VM ENDS


def check_ifort():
return get_ifort_version() or False

Expand Down
Binary file modified Cocoa/external_modules/code/CAMB/camb/cambdll.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Cocoa/external_modules/code/CAMB/docs/CAMBdemo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2825,7 +2825,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
1 change: 0 additions & 1 deletion Cocoa/external_modules/code/CAMB/fortran/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ gfortErr = 0
#VM ENDS
ifeq "$(gfortErr)" "0"
#Gfortran compiler (version 6+):
compiler_ver = $(shell gfortran -dumpversion 2>&1)
#VM BEGINS
#COCOA BEGINS
#COMPILER = gfortran
Expand Down
2 changes: 1 addition & 1 deletion Cocoa/external_modules/code/CAMB/fortran/camb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ subroutine CAMB_TransfersToPowers(CData)
Cdata%OnlyTransfer = .true. !prevent ClTransferToCl
Cdata%CP%WantTensors = .false.
CData%CP%WantVectors = .false.
call TimeSourcesToCl
call TimeSourcesToCl(CData%ClData%CTransScal)
Cdata%CP%WantTensors = want_tensors
CData%CP%WantVectors = want_vectors
Cdata%OnlyTransfer = .false.
Expand Down
43 changes: 25 additions & 18 deletions Cocoa/external_modules/code/CAMB/fortran/cmbmain.f90
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ module CAMBmain
integer :: max_bessels_l_index = 1000000
real(dl) :: max_bessels_etak = 1000000*2

Type(ClTransferData), pointer :: ThisCT => null()
Type(TTimeSources) , pointer :: ThisSources => null()
Type(TTimeSources), allocatable, target :: TempSources

Expand All @@ -126,6 +125,7 @@ subroutine cmbmain
type(EvolutionVars) EV
Type(TTimer) :: Timer
real(dl) starttime
Type(ClTransferData), pointer :: ThisCT

WantLateTime = CP%DoLensing .or. State%num_redshiftwindows > 0 .or. CP%CustomSources%num_custom_sources>0

Expand Down Expand Up @@ -216,7 +216,7 @@ subroutine cmbmain
! integrating the sources over time and over k.

if (CP%WantCls .and. (.not. CP%WantScalars .or. .not. State%HasScalarTimeSources)) then
call TimeSourcesToCl
call TimeSourcesToCl(ThisCT)

if (CP%WantScalars) then
deallocate(State%ScalarTimeSources)
Expand All @@ -231,9 +231,10 @@ subroutine cmbmain

end subroutine cmbmain

subroutine TimeSourcesToCl
Type(TTimer) :: Timer
subroutine TimeSourcesToCl(ThisCT)
Type(ClTransferData) :: ThisCT
integer q_ix
Type(TTimer) :: Timer

if (CP%WantScalars) ThisSources => State%ScalarTimeSources

Expand All @@ -255,21 +256,21 @@ subroutine TimeSourcesToCl
max_bessels_l_index = ThisCT%ls%nl
max_bessels_etak = maximum_qeta

if (CP%WantScalars) call GetLimberTransfers
if (CP%WantScalars) call GetLimberTransfers(ThisCT)
ThisCT%max_index_nonlimber = max_bessels_l_index

if (State%flat) call InitSpherBessels(ThisCT%ls, CP, max_bessels_l_index,max_bessels_etak )
!This is only slow if not called before with same (or higher) Max_l, Max_eta_k
!Preferably stick to Max_l being a multiple of 50

call SetkValuesForInt
call SetkValuesForInt(ThisCT)

if (DebugMsgs .and. Feedbacklevel > 0) call WriteFormat('Set %d integration k values',ThisCT%q%npoints)

!Begin k-loop and integrate Sources*Bessels over time
!$OMP PARALLEL DO DEFAULT(SHARED), SCHEDULE(STATIC,4)
do q_ix=1,ThisCT%q%npoints
call SourceToTransfers(q_ix)
call SourceToTransfers(ThisCT, q_ix)
end do !q loop
!$OMP END PARALLEL DO

Expand Down Expand Up @@ -398,7 +399,8 @@ subroutine CalcLimberScalCls(CTrans)

end subroutine CalcLimberScalCls

subroutine GetLimberTransfers
subroutine GetLimberTransfers(ThisCT)
Type(ClTransferData), target :: ThisCT
integer ell, ell_needed
integer i, s_ix, s_ix_lens
type(TRedWin), pointer :: W
Expand Down Expand Up @@ -517,7 +519,8 @@ subroutine GetLimberTransfers

end subroutine GetLimberTransfers

subroutine SourceToTransfers(q_ix)
subroutine SourceToTransfers(ThisCT, q_ix)
type(ClTransferData), target :: ThisCT
integer q_ix
type(IntegrationVars) :: IV

Expand All @@ -532,7 +535,7 @@ subroutine SourceToTransfers(q_ix)

call InterpolateSources(IV)

call DoSourceIntegration(IV)
call DoSourceIntegration(IV, ThisCT)

if (.not.State%flat) deallocate(IV%ddSource_q)
deallocate(IV%Source_q)
Expand Down Expand Up @@ -1106,7 +1109,7 @@ subroutine TransferOut


if (DebugMsgs .and. Feedbacklevel > 0) &
call WriteFormat('Transfer k values: %f',State%MT%num_q_trans-n_source_points)
call WriteFormat('Transfer k values: %d',State%MT%num_q_trans-n_source_points)

! loop over wavenumbers.
!$OMP PARALLEL DO DEFAULT(SHARED),SCHEDULE(DYNAMIC), PRIVATE(EV, tau, q_ix)
Expand Down Expand Up @@ -1231,7 +1234,8 @@ subroutine InitSourceInterpolation
end subroutine InitSourceInterpolation


subroutine SetkValuesForInt
subroutine SetkValuesForInt(ThisCT)
Type(ClTransferData) :: ThisCT
integer no
real(dl) dk,dk0,dlnk1, dk2, max_k_dk, k_max_log, k_max_0
integer lognum
Expand Down Expand Up @@ -1392,10 +1396,11 @@ subroutine IntegrationVars_Init(IV)
end subroutine IntegrationVars_Init


subroutine DoSourceIntegration(IV) !for particular wave number q
subroutine DoSourceIntegration(IV, ThisCT) !for particular wave number q
type(IntegrationVars) IV
Type(ClTransferData) :: ThisCT
integer j,ll,llmax
real(dl) nu
type(IntegrationVars) IV
real(dl) :: sixpibynu

nu=IV%q*State%curvature_radius
Expand All @@ -1418,12 +1423,12 @@ subroutine DoSourceIntegration(IV) !for particular wave number q
end if

if (State%flat) then
call DoFlatIntegration(IV,llmax)
call DoFlatIntegration(IV,ThisCT, llmax)
else
do j=1,ThisCT%ls%nl
ll=ThisCT%ls%l(j)
if (ll>llmax) exit
call IntegrateSourcesBessels(IV,j,ll,nu)
call IntegrateSourcesBessels(IV,ThisCT,j,ll,nu)
end do !j loop
end if

Expand All @@ -1449,9 +1454,10 @@ function UseLimber(l)
end function UseLimber

!flat source integration
subroutine DoFlatIntegration(IV, llmax)
subroutine DoFlatIntegration(IV, ThisCT, llmax)
implicit none
type(IntegrationVars) IV
Type(ClTransferData) :: ThisCT
integer llmax
integer j
logical DoInt
Expand Down Expand Up @@ -1641,9 +1647,10 @@ end subroutine DoFlatIntegration

!non-flat source integration

subroutine IntegrateSourcesBessels(IV,j,l,nu)
subroutine IntegrateSourcesBessels(IV,ThisCT,j,l,nu)
use SpherBessels
type(IntegrationVars) IV
Type(ClTransferData) :: ThisCT
logical DoInt
integer l,j, nstart,nDissipative,ntop,nbot,nrange,nnow
real(dl) nu,ChiDissipative,ChiStart,tDissipative,y1,y2,y1dis,y2dis
Expand Down
2 changes: 1 addition & 1 deletion Cocoa/external_modules/code/CAMB/fortran/config.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module config
use constants, only: const_twopi
implicit none

character(LEN=*), parameter :: version = '1.4.2.1'
character(LEN=*), parameter :: version = '1.5.0'

integer :: FeedbackLevel = 0 !if >0 print out useful information about the model

Expand Down
2 changes: 0 additions & 2 deletions Cocoa/external_modules/code/CAMB/forutils/Makefile_compiler
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ endif
endif

else

#VM BEGINS
#COCOA BEGINS
#major_version = $(shell gfortran -dumpversion 2>&1 | cut -d " " -f 3 | cut -d. -f 1)
#ifneq ($(shell test $(major_version) -gt 5; echo $$?),0)
Expand Down
Loading

0 comments on commit 54fae81

Please sign in to comment.