CosmicFish  Reference documentation for version 1.0
Looking into future Cosmology
000_Utilities.f90
Go to the documentation of this file.
1 !----------------------------------------------------------------------------------------
2 !
3 ! This file is part of CosmicFish.
4 !
5 ! Copyright (C) 2015-2016 by the CosmicFish authors
6 !
7 ! The CosmicFish code is free software;
8 ! You can use it, redistribute it, and/or modify it under the terms
9 ! of the GNU General Public License as published by the Free Software Foundation;
10 ! either version 3 of the License, or (at your option) any later version.
11 ! The full text of the license can be found in the file LICENSE at
12 ! the top level of the CosmicFish distribution.
13 !
14 !----------------------------------------------------------------------------------------
15 
18 
19 !----------------------------------------------------------------------------------------
21 
23 
25 
26  use precision
27 
28  implicit none
29 
30  private
31 
33 
34 contains
35 
36  ! ---------------------------------------------------------------------------------------------
38  function integer_to_string( number )
39 
40  implicit none
41 
42  integer, intent(in) :: number
43  character(10) :: integer_to_string
44 
45  write( integer_to_string, '(i10)' ) number
46 
47  integer_to_string = trim(adjustl( integer_to_string ))
48 
49  end function integer_to_string
50 
51  ! ---------------------------------------------------------------------------------------------
54  subroutine cosmicfish_write_header( name )
55 
56  implicit none
57 
58  character(len=*) :: name
59 
60  write(*,'(a)') "**************************************************************"
61  write(*,'(a)') " _____ _ _____ __ "
62  write(*,'(a)') " / ___/__ ___ __ _ (_)___/ __(_)__ / / "
63  write(*,'(a)') " / /__/ _ \(_-</ ' \/ / __/ _// (_-</ _ \ "
64  write(*,'(a)') " \___/\___/___/_/_/_/_/\__/_/ /_/___/_//_/ "
65  write(*,'(a)') " "
66  write(*,'(a)') "**************************************************************"
67  write(*,'(a)') name
68  write(*,'(a)') " This application was developed using the CosmicFish code."
69  write(*,'(a)') "**************************************************************"
70 
71  end subroutine cosmicfish_write_header
72 
73  ! ---------------------------------------------------------------------------------------------
76  function dierf(y)
77 
78  implicit none
79 
80  real(dl), intent(in) :: y
81  real(dl) :: dierf
82 
83  real(dl) :: s,t,u,w,x,z,y_temp
84 
85  real(dl), parameter :: &
86  & qa = 9.16461398268964d-01, &
87  & qb = 2.31729200323405d-01, &
88  & qc = 4.88826640273108d-01, &
89  & qd = 1.24610454613712d-01, &
90  & q0 = 4.99999303439796d-01, &
91  & q1 = 1.16065025341614d-01, &
92  & q2 = 1.50689047360223d-01, &
93  & q3 = 2.69999308670029d-01, &
94  & q4 = -7.28846765585675d-02
95 
96  real(dl), parameter :: &
97  & pa = 3.97886080735226000d+00, &
98  & pb = 1.20782237635245222d-01, &
99  & p0 = 2.44044510593190935d-01, &
100  & p1 = 4.34397492331430115d-01, &
101  & p2 = 6.86265948274097816d-01, &
102  & p3 = 9.56464974744799006d-01, &
103  & p4 = 1.16374581931560831d+00, &
104  & p5 = 1.21448730779995237d+00, &
105  & p6 = 1.05375024970847138d+00, &
106  & p7 = 7.13657635868730364d-01, &
107  & p8 = 3.16847638520135944d-01, &
108  & p9 = 1.47297938331485121d-02, &
109  & p10 = -1.05872177941595488d-01, &
110  & p11 = -7.43424357241784861d-02
111 
112  real(dl), parameter :: &
113  & p12 = 2.20995927012179067d-03, &
114  & p13 = 3.46494207789099922d-02, &
115  & p14 = 1.42961988697898018d-02, &
116  & p15 = -1.18598117047771104d-02, &
117  & p16 = -1.12749169332504870d-02, &
118  & p17 = 3.39721910367775861d-03, &
119  & p18 = 6.85649426074558612d-03, &
120  & p19 = -7.71708358954120939d-04, &
121  & p20 = -3.51287146129100025d-03, &
122  & p21 = 1.05739299623423047d-04, &
123  & p22 = 1.12648096188977922d-03
124 
125  ! digest the input:
126 
127  y_temp = 1._dl - y
128 
129  z = y_temp
130  if (y_temp .gt. 1) z = 2 - y_temp
131  w = qa - log(z)
132  u = sqrt(w)
133  s = (qc + log(u)) / w
134  t = 1 / (u + qb)
135  x = u * (1 - s * (0.5d0 + s * qd)) - &
136  & ((((q4 * t + q3) * t + q2) * t + q1) * t + q0) * t
137  t = pa / (pa + x)
138  u = t - 0.5d0
139  s = (((((((((p22 * u + p21) * u + p20) * u + &
140  & p19) * u + p18) * u + p17) * u + p16) * u + &
141  & p15) * u + p14) * u + p13) * u + p12
142  s = ((((((((((((s * u + p11) * u + p10) * u + &
143  & p9) * u + p8) * u + p7) * u + p6) * u + p5) * u + &
144  & p4) * u + p3) * u + p2) * u + p1) * u + p0) * t - &
145  & z * exp(x * x - pb)
146  x = x + s * (1 + x * s)
147  if (y_temp .gt. 1) x = -x
148  dierf = x
149 
150  end function dierf
151 
152 end module cosmicfish_utilities
subroutine, public cosmicfish_write_header(name)
This subroutine writes to the terminal the CosmicFish header. To be called at the beginning of the ap...
real(dl) function, public dierf(y)
This function computes the inverse error function in double precision. Taken from: http://www...
This module contains several general purpose utilities.
character(10) function, public integer_to_string(number)
This function converts an integer to a string. Usefull for numbered files output. ...