43 public parametrized_function_1d
49 type,
abstract :: parametrized_function_1d
51 integer :: parameter_number
52 character(len=:),
allocatable :: name
53 character(len=:),
allocatable :: name_latex
54 type(string) ,
allocatable,
dimension(:) :: param_names
55 type(string) ,
allocatable,
dimension(:) :: param_names_latex
60 procedure( parametrizedfunction1dsetparamnumber ),
deferred :: set_param_number
62 procedure :: set_name => parametrizedfunction1dsetname
63 procedure :: set_param_names => parametrizedfunction1dsetparamnames
64 procedure :: init_from_file => parametrizedfunction1dinitfromfile
65 procedure( parametrizedfunction1dinitparams ),
deferred :: init_parameters
67 procedure :: feedback => parametrizedfunction1dfeedback
68 procedure :: parameter_names => parametrizedfunction1dparameternames
69 procedure :: parameter_names_latex => parametrizedfunction1dparameternameslatex
70 procedure( parametrizedfunction1dparametervalues ),
deferred :: parameter_value
72 procedure( parametrizedfunction1dvalue ),
deferred ::
value 73 procedure( parametrizedfunction1dfirstderivative ),
deferred :: first_derivative
74 procedure( parametrizedfunction1dsecondderivative ),
deferred :: second_derivative
75 procedure( parametrizedfunction1dthirdderivative ),
deferred :: third_derivative
76 procedure( parametrizedfunction1dintegral ),
deferred :: integral
78 end type parametrized_function_1d
89 subroutine parametrizedfunction1dsetparamnumber( self )
91 import parametrized_function_1d
93 class(parametrized_function_1d) :: self
94 end subroutine parametrizedfunction1dsetparamnumber
98 subroutine parametrizedfunction1dinitparams( self, array )
100 import parametrized_function_1d
102 class(parametrized_function_1d) :: self
103 real(dl),
dimension(self%parameter_number),
intent(in) :: array
104 end subroutine parametrizedfunction1dinitparams
108 subroutine parametrizedfunction1dparametervalues( self, i, value )
110 import parametrized_function_1d
112 class(parametrized_function_1d) :: self
113 integer ,
intent(in) :: i
114 real(dl),
intent(out) ::
value 115 end subroutine parametrizedfunction1dparametervalues
120 function parametrizedfunction1dvalue( self, x, eft_cache )
123 import parametrized_function_1d
125 class(parametrized_function_1d) :: self
126 real(dl),
intent(in) :: x
127 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
128 real(dl) :: parametrizedfunction1dvalue
129 end function parametrizedfunction1dvalue
135 function parametrizedfunction1dfirstderivative( self, x, eft_cache )
138 import parametrized_function_1d
140 class(parametrized_function_1d) :: self
141 real(dl),
intent(in) :: x
142 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
143 real(dl) :: parametrizedfunction1dfirstderivative
144 end function parametrizedfunction1dfirstderivative
150 function parametrizedfunction1dsecondderivative( self, x, eft_cache )
153 import parametrized_function_1d
155 class(parametrized_function_1d) :: self
156 real(dl),
intent(in) :: x
157 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
158 real(dl) :: parametrizedfunction1dsecondderivative
159 end function parametrizedfunction1dsecondderivative
165 function parametrizedfunction1dthirdderivative( self, x, eft_cache )
168 import parametrized_function_1d
170 class(parametrized_function_1d) :: self
171 real(dl),
intent(in) :: x
172 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
173 real(dl) :: parametrizedfunction1dthirdderivative
174 end function parametrizedfunction1dthirdderivative
179 function parametrizedfunction1dintegral( self, x, eft_cache )
182 import parametrized_function_1d
184 class(parametrized_function_1d) :: self
185 real(dl),
intent(in) :: x
186 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
187 real(dl) :: parametrizedfunction1dintegral
188 end function parametrizedfunction1dintegral
204 class(parametrized_function_1d) :: self
205 integer :: ParametrizedFunction1DParamNumber
207 parametrizedfunction1dparamnumber = self%parameter_number
213 subroutine parametrizedfunction1dsetname( self, name, latexname )
217 class(parametrized_function_1d) :: self
218 character(*),
intent(in) :: name
219 character(*),
intent(in),
optional :: latexname
222 call self%set_param_number()
225 self%name = trim( name )
227 if (
present(latexname) )
then 228 self%name_latex = trim( latexname )
230 self%name_latex = trim( name )
233 end subroutine parametrizedfunction1dsetname
238 subroutine parametrizedfunction1dsetparamnames( self, param_names, param_names_latex )
242 class(parametrized_function_1d) :: self
243 character(*),
intent(in),
dimension(:) :: param_names
244 character(*),
intent(in),
dimension(:),
optional :: param_names_latex
246 character(len=:),
allocatable :: string_array(:)
248 integer :: num_params, ind
251 call self%set_param_number()
254 num_params = self%param_number()
255 if ( num_params /=
size(param_names) )
then 256 write(*,*)
'In parametrized_function_1D:', self%name
257 write(*,*)
'Length of param_names and number of parameters do not coincide.' 258 write(*,*)
'Parameter number:', num_params
259 write(*,*)
'Size of the param_names array:',
size(param_names)
260 call mpistop(
'EFTCAMB error')
262 if (
present(param_names_latex) )
then 264 if ( num_params /=
size(param_names_latex) )
then 265 write(*,*)
'In parametrized_function_1D:', self%name
266 write(*,*)
'Length of param_names_latex and number of parameters do not coincide.' 267 write(*,*)
'Parameter number:', self%parameter_number
268 write(*,*)
'Size of the param_names array:',
size(param_names_latex)
269 call mpistop(
'EFTCAMB error')
274 if (
allocated(self%param_names) )
deallocate(self%param_names)
275 allocate( self%param_names(num_params) )
276 if (
allocated(self%param_names_latex) )
deallocate(self%param_names_latex)
277 allocate( self%param_names_latex(num_params) )
281 self%param_names(ind)%string = param_names(ind)
282 if (
present(param_names_latex) )
then 283 self%param_names_latex(ind)%string = param_names_latex(ind)
285 self%param_names_latex(ind)%string = param_names(ind)
289 end subroutine parametrizedfunction1dsetparamnames
293 subroutine parametrizedfunction1dinitfromfile( self, Ini )
297 class(parametrized_function_1d) :: self
298 type(tinifile) :: Ini
300 character(len=EFT_names_max_length) :: param_name
301 real(dl),
dimension( self%parameter_number ) :: parameters
306 call self%set_param_number()
309 do i=1, self%parameter_number
310 call self%parameter_names( i, param_name )
311 parameters(i) = ini_read_double_file( ini, trim(param_name), 0._dl )
314 call self%init_parameters( parameters )
316 end subroutine parametrizedfunction1dinitfromfile
320 subroutine parametrizedfunction1dfeedback( self, print_params )
324 class(parametrized_function_1d) :: self
325 logical,
optional :: print_params
329 real(dl) :: param_value
330 character(len=EFT_names_max_length) :: param_name
331 logical :: print_params_temp
333 if (
present(print_params) )
then 334 print_params_temp = print_params
336 print_params_temp = .true.
339 if ( self%parameter_number>0 )
then 340 write(*,*)
'Parametrized function 1D: ', self%name
341 if ( print_params_temp )
then 342 do i=1, self%parameter_number
343 call self%parameter_names( i, param_name )
344 call self%parameter_value( i, param_value )
345 write(*,
'(a23,a,F12.6)') param_name,
'=', param_value
350 end subroutine parametrizedfunction1dfeedback
354 subroutine parametrizedfunction1dparameternames( self, i, name )
358 class(parametrized_function_1d) :: self
359 integer ,
intent(in) :: i
360 character(*),
intent(out) :: name
363 if ( i>self%parameter_number )
then 364 write(*,*)
'In parametrized_function_1D:', self%name
365 write(*,*)
'Illegal index for parameter_names.' 366 write(*,*)
'Maximum value is:', self%parameter_number
367 call mpistop(
'EFTCAMB error')
370 if (
allocated(self%param_names) )
then 371 name = self%param_names(i)%string
376 end subroutine parametrizedfunction1dparameternames
380 subroutine parametrizedfunction1dparameternameslatex( self, i, latexname )
384 class(parametrized_function_1d) :: self
385 integer ,
intent(in) :: i
386 character(*),
intent(out) :: latexname
389 if ( i>self%parameter_number )
then 390 write(*,*)
'In parametrized_function_1D:', self%name
391 write(*,*)
'Illegal index for parameter_names.' 392 write(*,*)
'Maximum value is:', self%parameter_number
393 call mpistop(
'EFTCAMB error')
396 if (
allocated(self%param_names_latex) )
then 397 latexname = self%param_names_latex(i)%string
402 end subroutine parametrizedfunction1dparameternameslatex
This module contains the definition of the EFTCAMB caches. These are used to store parameters that ca...
This module contains various generic algorithms that are useful to EFTCAMB.
character(10) function, public integer_to_string(number)
This function converts an integer to a string. Usefull for numbered files output. ...
This module contains the definitions of all the EFTCAMB compile time flags.
integer function parametrizedfunction1dparamnumber(self)
Function that returns the number of parameters of the parametrized function.
This module contains the abstract class for generic parametrizations for 1D functions that are used b...