43 public parametrized_function_2d
49 type,
abstract :: parametrized_function_2d
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( parametrizedfunction2dsetparamnumber ),
deferred :: set_param_number
62 procedure :: set_name => parametrizedfunction2dsetname
63 procedure :: set_param_names => parametrizedfunction2dsetparamnames
64 procedure :: init_from_file => parametrizedfunction2dinitfromfile
65 procedure( parametrizedfunction2dinitparams ),
deferred :: init_parameters
67 procedure :: feedback => parametrizedfunction2dfeedback
68 procedure :: parameter_names => parametrizedfunction2dparameternames
69 procedure :: parameter_names_latex => parametrizedfunction2dparameternameslatex
70 procedure( parametrizedfunction2dparametervalues ),
deferred :: parameter_value
72 procedure( parametrizedfunction2dvalue ),
deferred ::
value 73 procedure( parametrizedfunction2dfirstderivativex ),
deferred :: first_derivative_x
74 procedure( parametrizedfunction2dfirstderivativey ),
deferred :: first_derivative_y
75 procedure( parametrizedfunction2dsecondderivativex ),
deferred :: second_derivative_x
76 procedure( parametrizedfunction2dsecondderivativey ),
deferred :: second_derivative_y
77 procedure( parametrizedfunction2dsecondderivativexy ),
deferred :: second_derivative_xy
79 end type parametrized_function_2d
90 subroutine parametrizedfunction2dsetparamnumber( self )
92 import parametrized_function_2d
94 class(parametrized_function_2d) :: self
95 end subroutine parametrizedfunction2dsetparamnumber
99 subroutine parametrizedfunction2dinitparams( self, array )
101 import parametrized_function_2d
103 class(parametrized_function_2d) :: self
104 real(dl),
dimension(self%parameter_number),
intent(in) :: array
105 end subroutine parametrizedfunction2dinitparams
109 subroutine parametrizedfunction2dparametervalues( self, i, value )
111 import parametrized_function_2d
113 class(parametrized_function_2d) :: self
114 integer ,
intent(in) :: i
115 real(dl),
intent(out) ::
value 116 end subroutine parametrizedfunction2dparametervalues
121 function parametrizedfunction2dvalue( self, x, y, eft_cache )
124 import parametrized_function_2d
126 class(parametrized_function_2d) :: self
127 real(dl),
intent(in) :: x
128 real(dl),
intent(in) :: y
129 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
130 real(dl) :: parametrizedfunction2dvalue
131 end function parametrizedfunction2dvalue
137 function parametrizedfunction2dfirstderivativex( self, x, y, eft_cache )
140 import parametrized_function_2d
142 class(parametrized_function_2d) :: self
143 real(dl),
intent(in) :: x
144 real(dl),
intent(in) :: y
145 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
146 real(dl) :: parametrizedfunction2dfirstderivativex
147 end function parametrizedfunction2dfirstderivativex
153 function parametrizedfunction2dfirstderivativey( self, x, y, eft_cache )
156 import parametrized_function_2d
158 class(parametrized_function_2d) :: self
159 real(dl),
intent(in) :: x
160 real(dl),
intent(in) :: y
161 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
162 real(dl) :: parametrizedfunction2dfirstderivativey
163 end function parametrizedfunction2dfirstderivativey
169 function parametrizedfunction2dsecondderivativex( self, x, y, eft_cache )
172 import parametrized_function_2d
174 class(parametrized_function_2d) :: self
175 real(dl),
intent(in) :: x
176 real(dl),
intent(in) :: y
177 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
178 real(dl) :: parametrizedfunction2dsecondderivativex
179 end function parametrizedfunction2dsecondderivativex
185 function parametrizedfunction2dsecondderivativey( self, x, y, eft_cache )
188 import parametrized_function_2d
190 class(parametrized_function_2d) :: self
191 real(dl),
intent(in) :: x
192 real(dl),
intent(in) :: y
193 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
194 real(dl) :: parametrizedfunction2dsecondderivativey
195 end function parametrizedfunction2dsecondderivativey
201 function parametrizedfunction2dsecondderivativexy( self, x, y, eft_cache )
204 import parametrized_function_2d
206 class(parametrized_function_2d) :: self
207 real(dl),
intent(in) :: x
208 real(dl),
intent(in) :: y
209 type(eftcamb_timestep_cache),
intent(in),
optional :: eft_cache
210 real(dl) :: parametrizedfunction2dsecondderivativexy
211 end function parametrizedfunction2dsecondderivativexy
227 class(parametrized_function_2d) :: self
228 integer :: ParametrizedFunction2DParamNumber
230 parametrizedfunction2dparamnumber = self%parameter_number
236 subroutine parametrizedfunction2dsetname( self, name, latexname )
240 class(parametrized_function_2d) :: self
241 character(*),
intent(in) :: name
242 character(*),
intent(in),
optional :: latexname
245 call self%set_param_number()
248 self%name = trim( name )
250 if (
present(latexname) )
then 251 self%name_latex = trim( latexname )
253 self%name_latex = trim( name )
256 end subroutine parametrizedfunction2dsetname
261 subroutine parametrizedfunction2dsetparamnames( self, param_names, param_names_latex )
265 class(parametrized_function_2d) :: self
266 character(*),
intent(in),
dimension(:) :: param_names
267 character(*),
intent(in),
dimension(:),
optional :: param_names_latex
269 integer :: num_params, ind
272 call self%set_param_number()
275 num_params = self%param_number()
276 if ( num_params /=
size(param_names) )
then 277 write(*,*)
'In parametrized_function_1D:', self%name
278 write(*,*)
'Length of param_names and number of parameters do not coincide.' 279 write(*,*)
'Parameter number:', num_params
280 write(*,*)
'Size of the param_names array:',
size(param_names)
281 call mpistop(
'EFTCAMB error')
283 if (
present(param_names_latex) )
then 285 if ( num_params /=
size(param_names_latex) )
then 286 write(*,*)
'In parametrized_function_1D:', self%name
287 write(*,*)
'Length of param_names_latex and number of parameters do not coincide.' 288 write(*,*)
'Parameter number:', self%parameter_number
289 write(*,*)
'Size of the param_names array:',
size(param_names_latex)
290 call mpistop(
'EFTCAMB error')
295 if (
allocated(self%param_names) )
deallocate(self%param_names)
296 allocate( self%param_names(num_params) )
297 if (
allocated(self%param_names_latex) )
deallocate(self%param_names_latex)
298 allocate( self%param_names_latex(num_params) )
302 self%param_names(ind)%string = param_names(ind)
303 if (
present(param_names_latex) )
then 304 self%param_names_latex(ind)%string = param_names_latex(ind)
306 self%param_names_latex(ind)%string = param_names(ind)
310 end subroutine parametrizedfunction2dsetparamnames
314 subroutine parametrizedfunction2dinitfromfile( self, Ini )
318 class(parametrized_function_2d) :: self
319 type(tinifile) :: Ini
321 character(len=EFT_names_max_length) :: param_name
322 real(dl),
dimension( self%parameter_number ) :: parameters
327 call self%set_param_number()
330 do i=1, self%parameter_number
331 call self%parameter_names( i, param_name )
332 parameters(i) = ini_read_double_file( ini, trim(param_name), 0._dl )
335 call self%init_parameters( parameters )
337 end subroutine parametrizedfunction2dinitfromfile
341 subroutine parametrizedfunction2dfeedback( self, print_params )
345 class(parametrized_function_2d) :: self
346 logical,
optional :: print_params
350 real(dl) :: param_value
351 character(len=EFT_names_max_length) :: param_name
353 if ( .not.
present(print_params) ) print_params = .true.
355 if ( self%parameter_number>0 )
then 356 write(*,*)
'Parametrized function 2D: ', self%name
357 if ( print_params )
then 358 do i=1, self%parameter_number
359 call self%parameter_names( i, param_name )
360 call self%parameter_value( i, param_value )
361 write(*,
'(a23,a,F12.6)') param_name,
'=', param_value
366 end subroutine parametrizedfunction2dfeedback
370 subroutine parametrizedfunction2dparameternames( self, i, name )
374 class(parametrized_function_2d) :: self
375 integer ,
intent(in) :: i
376 character(*),
intent(out) :: name
379 if ( i>self%parameter_number )
then 380 write(*,*)
'In parametrized_function_2D:', self%name
381 write(*,*)
'Illegal index for parameter_names.' 382 write(*,*)
'Maximum value is:', self%parameter_number
383 call mpistop(
'EFTCAMB error')
386 if (
allocated(self%param_names) )
then 387 name = self%param_names(i)%string
392 end subroutine parametrizedfunction2dparameternames
396 subroutine parametrizedfunction2dparameternameslatex( self, i, latexname )
400 class(parametrized_function_2d) :: self
401 integer ,
intent(in) :: i
402 character(*),
intent(out) :: latexname
405 if ( i>self%parameter_number )
then 406 write(*,*)
'In parametrized_function_2D:', self%name
407 write(*,*)
'Illegal index for parameter_names.' 408 write(*,*)
'Maximum value is:', self%parameter_number
409 call mpistop(
'EFTCAMB error')
412 if (
allocated(self%param_names_latex) )
then 413 latexname = self%param_names_latex(i)%string
418 end subroutine parametrizedfunction2dparameternameslatex
This module contains the definition of the EFTCAMB caches. These are used to store parameters that ca...
This module contains the abstract class for generic parametrizations for 2D functions that are used b...
This module contains various generic algorithms that are useful to EFTCAMB.
integer function parametrizedfunction2dparamnumber(self)
Function that returns the number of parameters of the parametrized function.
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.