ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
fgauss.f90
Go to the documentation of this file.
1 function fgauss(x, nv, equidistant, s_acc, weights, sig) result(f_fgauss)
2 
3 !----------------------------------------------------------------------------!
4 ! computes a sum of weighted Gauss functions !
5 ! at position x !
6 ! s_acc(1..nv) = centers of Gauss functions !
7 ! weigths(1..nv) = weighting factors !
8 ! sig(1..nv) = widths of Gauss functions !
9 ! equidistant = 0..1: 1 produces equidistant grid, 0 produces pure Gaussian !
10 !----------------------------------------------------------------------------!
11 
12  use itm_types
13 
14  implicit none
15 
16  integer(itm_i4) :: nv
17  real(r8), dimension(nv) :: s_acc, weights, sig
18  real(r8) :: x, equidistant
19  real(r8) :: f_fgauss
20 
21  real(r8) :: gauss_sum, weight
22  integer(itm_i4) :: i
23 
24  weight = 0._r8
25  gauss_sum = 0._r8
26  do i = 1, nv
27  weight = weight + weights(i)
28 ! to avoid floating underflow: exp(-large_number) = 0
29  if (((x - s_acc(i))**2 / sig(i)**2) < 100) then
30  gauss_sum = gauss_sum + weights(i) * (0.39894_r8 / sig(i)) &
31  * exp(-0.5_r8 * (x - s_acc(i))**2 / sig(i)**2)
32  end if
33  end do
34  f_fgauss = equidistant + (1._r8 - equidistant) * gauss_sum / weight
35 
36 end function fgauss
real(r8) function fgauss(x, nv, equidistant, s_acc, weights, sig)
Definition: fgauss.f90:1