20 USE mo_kind,
ONLY: i4, dp
99 subroutine desiletsn0(SoilMoisture, Horizon_depth, Bd, latWater, N0, neutrons)
102 use mo_moment,
only: average
105 real(dp),
dimension(:),
intent(in) :: soilmoisture
106 real(dp),
dimension(:),
intent(in) :: horizon_depth
107 real(dp),
dimension(:),
intent(in) :: bd
108 real(dp),
dimension(:),
intent(in) :: latwater
109 real(dp),
intent(in) :: n0
110 real(dp),
intent(inout) :: neutrons
112 integer(i4) :: nlayers, ll, nn, nintervals
113 real(dp),
dimension(:),
allocatable :: layer_min, layer_max, layer_depth
114 real(dp) :: average_swc, average_bd
115 real(dp) :: d_86_in_cm, d_86_in_mm
116 real(dp),
dimension(:),
allocatable :: cummulative_layer_weight
117 real(dp) :: depth, weight_10mm_spacing, grav_swc
120 nlayers =
size(soilmoisture)
121 allocate( layer_min(nlayers) )
122 allocate( layer_max(nlayers) )
123 allocate( layer_depth(nlayers) )
126 layer_min(1) = 0.0_dp
127 layer_max(1) = horizon_depth(1)
130 layer_min(ll) = layer_max(ll-1)
131 layer_max(ll) = horizon_depth(ll)
135 layer_depth(:) = layer_max(:) - layer_min(:)
138 average_swc = average( soilmoisture(:)/layer_depth(:) )
139 average_bd = average( bd(:) )
142 d_86_in_cm = ( 1.0_dp/average_bd ) * &
143 ( 8.321_dp + 0.14249_dp * (0.96655_dp + exp(-0.01_dp)) * (20.0_dp + average_swc)/(0.0429_dp + average_swc) )
144 d_86_in_mm = d_86_in_cm * 10.0_dp
148 allocate( cummulative_layer_weight(nlayers) )
149 cummulative_layer_weight(:) = 0.0_dp
152 nintervals = nint( maxval(horizon_depth(:))/10.0_dp )
156 do nn = 1, nintervals
157 weight_10mm_spacing = exp(-2.0_dp * depth / d_86_in_mm )
161 if( (depth .GE. layer_min(ll)) .AND. (depth .LT. layer_max(ll)) )
then
162 cummulative_layer_weight(ll) = cummulative_layer_weight(ll) + weight_10mm_spacing
166 depth = depth + 10.0_dp
175 grav_swc = ( soilmoisture(ll) + latwater(ll) )/layer_depth(ll)/bd(ll)
176 average_swc = average_swc + ( grav_swc * cummulative_layer_weight(ll) )
178 average_swc = average_swc / sum( cummulative_layer_weight(:) )
184 deallocate(layer_min, layer_max, layer_depth, cummulative_layer_weight)
253 subroutine cosmic(SoilMoisture, Horizons, neutron_integral_AFast, &
254 interc, snowpack, L1_N0, L1_bulkDens, L1_latticeWater, L1_COSMICL3, &
258 use mo_constants,
only: pi_dp
261 real(dp),
dimension(:),
intent(in) :: soilmoisture
262 real(dp),
dimension(:),
intent(in) :: horizons
263 real(dp),
dimension(:),
intent(in) :: neutron_integral_afast
264 real(dp),
intent(in) :: interc
265 real(dp),
intent(in) :: snowpack
266 real(dp),
intent(in) :: l1_n0
267 real(dp),
dimension(:),
intent(in) :: l1_bulkdens
268 real(dp),
dimension(:),
intent(in) :: l1_latticewater
269 real(dp),
dimension(:),
intent(in) :: l1_cosmicl3
270 real(dp),
intent(inout) :: neutrons
272 real(dp) :: lambdahigh
273 real(dp) :: lambdafast
279 integer(i4):: iflag_snowlayer_intecept
281 real(dp),
dimension(size(Horizons)+1) :: zthick
282 real(dp),
dimension(:),
allocatable :: isoimass
283 real(dp),
dimension(:),
allocatable :: iwatmass
284 real(dp),
dimension(:),
allocatable :: hiflux
285 real(dp),
dimension(:),
allocatable :: xeff
286 real(dp),
dimension(:),
allocatable :: h2oeffheight
287 real(dp),
dimension(:),
allocatable :: h2oeffdens
288 real(dp),
dimension(:),
allocatable :: fastflux
290 integer(i4) :: layers
295 layers =
size(soilmoisture) + 1
298 allocate(hiflux(layers),xeff(layers),&
299 h2oeffdens(layers),h2oeffheight(layers),fastflux(layers),&
300 isoimass(layers),iwatmass(layers))
307 h2oeffdens(:) = 0.0_dp
308 h2oeffheight(:)= 0.0_dp
321 iflag_snowlayer_intecept = 0
335 if( ( zthick(ll) .GT. 0.0_dp ) .AND. ( (iflag_snowlayer_intecept .GT. 0 ) .OR. (ll.NE.1) ) )
then
338 l1_latticewater(:), l1_cosmicl3(:), sm, bd, lw, l3)
341 h2oeffdens(ll) =
h2odens/1000.0_dp
347 h2oeffdens(ll) = (h2oeffheight(ll) + lw/10.0_dp)/zthick(ll)*
h2odens/1000.0_dp
352 isoimass(ll) = bd*(0.5_dp*zthick(ll))*1.0_dp
353 iwatmass(ll) = h2oeffdens(ll)*(0.5_dp*zthick(ll))*1.0_dp
354 if ( ll .gt. 1 )
then
355 isoimass(ll) = isoimass(ll)+isoimass(ll-1)+bd*(0.5_dp*zthick(ll-1))*1.0_dp
356 iwatmass(ll) = iwatmass(ll)+iwatmass(ll-1)+h2oeffdens(ll-1)*(0.5_dp*zthick(ll-1))*1.0_dp
360 lambdafast = isoimass(ll)/l3 + iwatmass(ll)/
cosmic_l4
362 hiflux(ll) = exp(-lambdahigh)
363 xeff(ll) = zthick(ll)*(
cosmic_alpha*bd + h2oeffdens(ll))
365 call lookupintegral(fastflux(ll),neutron_integral_afast,lambdafast)
369 fastflux(ll) = (2.0_dp/pi_dp) * fastflux(ll)
372 totflux = totflux + hiflux(ll) * xeff(ll) * fastflux(ll)
379 neutrons = l1_n0*totflux
382 deallocate( hiflux, xeff, h2oeffheight, h2oeffdens, fastflux, isoimass, iwatmass)
391 L1_COSMICL3,sm,bd,lw,L3 )
393 integer(i4),
intent(in) :: ll
394 real(dp),
dimension(:),
intent(in) :: SoilMoisture
395 real(dp),
dimension(:),
intent(in) :: L1_bulkDens
396 real(dp),
dimension(:),
intent(in) :: L1_latticeWater
397 real(dp),
dimension(:),
intent(in) :: L1_COSMICL3
398 real(dp),
intent(out) :: sm
399 real(dp),
intent(out) :: bd
400 real(dp),
intent(out) :: lw
401 real(dp),
intent(out) :: L3
410 sm = soilmoisture(ll-1)
411 bd = l1_bulkdens(ll-1)
412 lw = l1_latticewater(ll-1)
413 l3 = l1_cosmicl3(ll-1)
422 integer(i4),
intent(in) :: ll
423 real(dp),
dimension(:),
intent(in) :: Horizons
424 real(dp),
intent(in) :: interc
425 real(dp),
intent(in) :: snowpack
426 real(dp),
dimension(:),
intent(out) :: zthick
429 zthick(ll)=(snowpack+interc)/10.0_dp
430 else if (ll.eq.2)
then
431 zthick(ll)=horizons(ll-1)/10.0_dp
433 zthick(ll)=(horizons(ll-1) - horizons(ll-2))/10.0_dp
441 integer(i4),
intent(in) :: ll
442 real(dp),
intent(in) :: sm
443 real(dp),
dimension(:),
intent(out) :: h2oeffheight
446 h2oeffheight(ll) = sm/10.0_dp
465 real(dp),
external :: f
466 real(dp),
intent(in) :: c
467 real(dp),
intent(in) :: xmax
468 real(dp),
intent(in) :: xmin
469 real(dp),
optional :: eps
470 integer(i4),
optional :: steps
471 real(dp),
optional :: fxmin
472 real(dp),
optional :: fxmax
476 integer(i4) :: stepstemp
477 real(dp) :: fxmintemp
478 real(dp) :: fxmaxtemp
481 if (.not.
present(eps))
then
487 if (.not.
present(steps))
then
493 if (.not.
present(fxmin))
then
499 if (.not.
present(fxmax))
then
507 if (stepstemp .gt. 0)
then
518 real(dp),
external :: f
519 real(dp),
intent(in) :: c
520 real(dp),
intent(in) :: xmax
521 real(dp),
intent(in) :: xmin
522 real(dp),
intent(in) :: eps
523 integer(i4),
intent(in) :: steps
524 real(dp),
intent(in) :: fxmin
525 real(dp),
intent(in) :: fxmax
532 xm = (xmax+xmin)/2.0_dp
535 err=abs((fxmax-fxm)*(xmax-xm))
536 if ((err .gt. eps).and.(steps .gt. 1))
then
539 res=res+(xmax-xm)*(fxmax+fxm)/2.0_dp
542 err=abs((fxm-fxmin)*(xm-xmin))
543 if ((err .gt. eps).and.(steps .gt. 1))
then
546 res=res+(xm-xmin)*(fxm+fxmin)/2.0_dp
553 real(dp),
external :: f
554 real(dp),
intent(in) :: c
555 real(dp),
intent(in) :: xmax
556 real(dp),
intent(in) :: xmin
557 real(dp),
intent(in) :: eps
558 real(dp),
intent(in) :: fxmin
559 real(dp),
intent(in) :: fxmax
566 xm = (xmax+xmin)/2.0_dp
569 err=abs((fxmax-fxm)*(xmax-xm))
570 if (err .gt. eps)
then
573 res=res+(xmax-xm)*(fxmax+fxm)/2.0_dp
576 err=abs((fxm-fxmin)*(xm-xmin))
577 if (err .gt. eps)
then
580 res=res+(xm-xmin)*(fxm+fxmin)/2.0_dp
649 use mo_constants,
only: pi_dp
651 real(dp),
dimension(:) :: integral
652 real(dp),
intent(in) :: maxc
657 integer(i4) :: intsize
659 intsize=
size(integral)-2
662 c =real(i-1,dp)*maxc/real(intsize,dp)
664 intgrandfast,c,0.0_dp,pi_dp/2.0_dp,steps=1024,fxmax=0.0_dp)
666 integral(intsize+2)=maxc
672 use mo_constants,
only: pi_dp
674 real(dp),
dimension(:) :: integral
675 integer(i4),
intent(in) :: intsize
676 real(dp),
intent(in) :: maxC
683 c =real(i-1,dp)*maxc/real(intsize/2,dp)
685 intgrandfast,c,0.0_dp,pi_dp/2.0_dp,steps=1024,fxmax=0.0_dp)
688 integral(2*i)=integral(2*i)*maxc/real(intsize/2,dp)
695 use mo_constants,
only: pi_dp
697 real(dp),
intent(out):: res
698 real(dp),
dimension(:),
intent(in) :: integral
699 real(dp),
intent(in) :: c
704 integer(i4) :: intsize
707 intsize=
size(integral)-2
708 maxc=integral(intsize+2)
709 mu=c*real(intsize,dp)/maxc
711 if (place .gt. intsize)
then
714 res=(pi_dp/2.0_dp)*exp(-1.57406_dp*c**0.815488_dp)
716 mu=mu-real(place-1,dp)
717 res=(1.0_dp-mu)*integral(place)+mu*integral(place+1)
723 use mo_constants,
only: pi_dp
726 real(dp),
dimension(:),
intent(in):: integral
727 integer(i4),
intent(in) :: intsize
728 real(dp),
intent(in) :: c
729 real(dp),
intent(in) :: maxC
735 mu=c*real(intsize/2,dp)/maxc
737 if (place .gt. intsize)
then
740 res=(pi_dp/2.0_dp)*exp(-1.57406_dp*c**0.815488_dp)
742 mu=mu-real(place-1,dp)
743 res=
h00(mu)*integral(2*place-1)+
h01(mu)*integral(2*place+1)+&
744 h10(mu)*integral(2*place )+
h11(mu)*integral(2*place+2)
757 real(dp),
intent(in) :: x
762 if (x .le. 0.05_dp)
then
769 else if (x .le. 0.1_dp)
then
776 else if (x .le. 0.5_dp)
then
783 else if (x .le. 1.0_dp)
then
790 else if (x .le. 5.0_dp)
then
809 use mo_constants,
only: pi_dp
812 real(dp),
intent(in) :: c
825 dtheta = 0.5_dp*(pi_dp/180.0_dp)
832 zdeg = real(angle,dp)*0.5_dp
833 zrad = (zdeg*pi_dp)/180.0_dp
836 res = res + exp(-c/costheta)*dtheta
843 real(dp),
intent(in) :: c
844 real(dp),
intent(in) :: phi
852 real(dp),
intent(in) :: c
853 real(dp),
intent(in) :: phi
861 real(dp),
intent(in) :: x
862 real(dp),
intent(in) :: a,b,c,d
872 real(dp),
intent(in) :: t
873 h00=2.0_dp*t**3-3.0_dp*t**2+1.0_dp
880 real(dp),
intent(in) :: t
881 h01=-2.0_dp*t**3+3.0_dp*t**2
888 real(dp),
intent(in) :: t
889 h10=t**3-2.0_dp*t**2+t
896 real(dp),
intent(in) :: t
Provides mHM specific constants.
real(dp), parameter, public desilets_a0
Neutrons and moisture: N0 formula, Desilets et al.
real(dp), parameter, public desilets_a2
real(dp), parameter, public cosmic_l4
real(dp), parameter, public cosmic_l1
real(dp), parameter, public h2odens
real(dp), parameter, public cosmic_l2
real(dp), parameter, public desilets_a1
real(dp), parameter, public cosmic_alpha
Models to predict neutron intensities above soils.
subroutine loopconstants(ll, soilmoisture, l1_bulkdens, l1_latticewater, l1_cosmicl3, sm, bd, lw, l3)
subroutine oldintegration(res, c)
subroutine cosmiceffintegration(res, x)
subroutine, public desiletsn0(soilmoisture, horizon_depth, bd, latwater, n0, neutrons)
Calculate neutrons from soil moisture for effective soil layer.
subroutine, public cosmic(soilmoisture, horizons, neutron_integral_afast, interc, snowpack, l1_n0, l1_bulkdens, l1_latticewater, l1_cosmicl3, neutrons)
Calculate neutrons from soil moisture in all layers.
subroutine layerwaterheight(ll, sm, h2oeffheight)
subroutine approx_mon_int(res, f, c, xmin, xmax, eps, steps, fxmin, fxmax)
subroutine, public tabularintegralafast(integral, maxc)
Save approximation data for A_fast.
subroutine layerthickness(ll, horizons, interc, snowpack, zthick)
recursive subroutine approx_mon_int_steps(res, f, c, xmin, xmax, eps, steps, fxmin, fxmax)
real(dp) function intgrandfast(c, phi)
subroutine lookuphermiteintegral(res, integral, intsize, c, maxc)
recursive subroutine approx_mon_int_eps(res, f, c, xmin, xmax, eps, fxmin, fxmax)
subroutine tabularintegralhermafast(integral, intsize, maxc)
subroutine lookupintegral(res, integral, c)
real(dp) function intgrandderivfast(c, phi)
real(dp) function exppolynomdeg3(x, a, b, c, d)