10 use fckit_mpi_module,
only: fckit_mpi_sum
56 subroutine avg_alloc(avg,nam,geom,bpar,ne,nsub)
61 class(avg_type),
intent(inout) :: avg
62 type(nam_type),
intent(in) :: nam
63 type(geom_type),
intent(in) :: geom
64 type(bpar_type),
intent(in) :: bpar
65 integer,
intent(in) :: ne
66 integer,
intent(in) :: nsub
76 allocate(avg%blk(0:nam%nc2,bpar%nbe))
78 if (bpar%diag_block(ib))
then 80 call avg%blk(ic2,ib)%alloc(nam,geom,bpar,ic2,ib,ne,nsub)
96 class(avg_type),
intent(inout) :: avg
97 type(nam_type),
intent(in) :: nam
98 type(bpar_type),
intent(in) :: bpar
104 if (
allocated(avg%blk))
then 106 if (bpar%diag_block(ib))
then 108 call avg%blk(ic2,ib)%dealloc
121 type(avg_type) function avg_copy(avg,nam,geom,bpar)
135 call avg_copy%dealloc(nam,bpar)
138 call avg_copy%alloc(nam,geom,bpar,avg%ne,avg%nsub)
142 if (bpar%diag_block(ib))
then 144 avg_copy%blk(ic2,ib) = avg%blk(ic2,ib)%copy(nam,geom,bpar)
160 class(avg_type),
intent(inout) :: avg
161 type(mpl_type),
intent(in) :: mpl
162 type(nam_type),
intent(in) :: nam
163 type(geom_type),
intent(in) :: geom
164 type(bpar_type),
intent(in) :: bpar
167 integer :: npack,offset,ib,ic2
168 real(kind_real),
allocatable :: sbuf(:),rbuf(:)
169 logical,
allocatable :: mask_0(:,:,:),mask_1(:,:,:,:),mask_2(:,:,:,:,:)
174 if (bpar%diag_block(ib))
then 176 if ((ic2==0).or.(nam%var_diag))
then 177 npack = npack+geom%nl0
178 if (nam%var_filter.and.(.not.nam%gau_approx)) npack = npack+geom%nl0
180 if ((ic2==0).or.(nam%local_diag))
then 181 npack = npack+(4+2*avg%blk(ic2,ib)%nsub**2)*bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
182 if (.not.nam%gau_approx) npack = npack+avg%blk(ic2,ib)%nsub*bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
189 allocate(sbuf(npack))
190 allocate(rbuf(npack))
196 if (bpar%diag_block(ib))
then 198 if ((ic2==0).or.(nam%var_diag))
then 199 sbuf(offset+1:offset+geom%nl0) = pack(avg%blk(ic2,ib)%m2,.true.)
200 offset = offset+geom%nl0
201 if (nam%var_filter.and.(.not.nam%gau_approx))
then 202 sbuf(offset+1:offset+geom%nl0) = pack(avg%blk(ic2,ib)%m4,.true.)
203 offset = offset+geom%nl0
206 if ((ic2==0).or.(nam%local_diag))
then 207 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0) = pack(avg%blk(ic2,ib)%nc1a,.true.)
208 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
209 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0) = pack(avg%blk(ic2,ib)%m11,.true.)
210 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
211 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2) = pack(avg%blk(ic2,ib)%m11m11,.true.)
212 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2
213 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2) = pack(avg%blk(ic2,ib)%m2m2,.true.)
214 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2
215 if (.not.nam%gau_approx)
then 216 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub) = pack(avg%blk(ic2,ib)%m22,.true.)
217 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub
219 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0) = pack(avg%blk(ic2,ib)%nc1a_cor,.true.)
220 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
221 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0) = pack(avg%blk(ic2,ib)%cor,.true.)
222 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
229 call mpl%f_comm%allreduce(sbuf,rbuf,fckit_mpi_sum())
234 if (bpar%diag_block(ib))
then 236 allocate(mask_0(bpar%nc3(ib),bpar%nl0r(ib),geom%nl0))
237 allocate(mask_1(bpar%nc3(ib),bpar%nl0r(ib),geom%nl0,avg%blk(0,ib)%nsub))
238 allocate(mask_2(bpar%nc3(ib),bpar%nl0r(ib),geom%nl0,avg%blk(0,ib)%nsub,avg%blk(0,ib)%nsub))
247 if ((ic2==0).or.(nam%var_diag))
then 248 avg%blk(ic2,ib)%m2 = unpack(rbuf(offset+1:offset+geom%nl0),mask_1(1,1,:,:),avg%blk(ic2,ib)%m2)
249 offset = offset+geom%nl0
250 if (nam%var_filter.and.(.not.nam%gau_approx))
then 251 avg%blk(ic2,ib)%m4 = unpack(rbuf(offset+1:offset+geom%nl0),mask_1(1,1,:,:),avg%blk(ic2,ib)%m4)
252 offset = offset+geom%nl0
255 if ((ic2==0).or.(nam%local_diag))
then 256 avg%blk(ic2,ib)%nc1a = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0),mask_0,avg%blk(ic2,ib)%m11)
257 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
258 avg%blk(ic2,ib)%m11 = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0),mask_0,avg%blk(ic2,ib)%m11)
259 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
260 avg%blk(ic2,ib)%m11m11 = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2), &
261 & mask_2,avg%blk(ic2,ib)%m11m11)
262 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2
263 avg%blk(ic2,ib)%m2m2 = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2), &
264 & mask_2,avg%blk(ic2,ib)%m2m2)
265 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub**2
266 if (.not.nam%gau_approx)
then 267 avg%blk(ic2,ib)%m22 = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub), &
268 & mask_1,avg%blk(ic2,ib)%m22)
269 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg%blk(ic2,ib)%nsub
271 avg%blk(ic2,ib)%nc1a_cor = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0), &
272 & mask_0,avg%blk(ic2,ib)%nc1a_cor)
273 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
274 avg%blk(ic2,ib)%cor = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0),mask_0,avg%blk(ic2,ib)%cor)
275 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0
297 class(avg_type),
intent(inout) :: avg
298 type(nam_type),
intent(in) :: nam
299 type(geom_type),
intent(in) :: geom
300 type(bpar_type),
intent(in) :: bpar
303 integer :: ib,ic2,il0,jl0r,jc3,isub,jsub
304 real(kind_real) :: norm
308 if (bpar%diag_block(ib))
then 310 if ((ic2==0).or.(nam%local_diag))
then 313 do jl0r=1,bpar%nl0r(ib)
314 do jc3=1,bpar%nc3(ib)
315 if (avg%blk(ic2,ib)%nc1a(jc3,jl0r,il0)>0.0)
then 316 norm = 1.0/avg%blk(ic2,ib)%nc1a(jc3,jl0r,il0)
317 avg%blk(ic2,ib)%m11(jc3,jl0r,il0) = avg%blk(ic2,ib)%m11(jc3,jl0r,il0)*norm
318 do isub=1,avg%blk(ic2,ib)%nsub
319 do jsub=1,avg%blk(ic2,ib)%nsub
320 avg%blk(ic2,ib)%m11m11(jc3,jl0r,il0,jsub,isub) = avg%blk(ic2,ib)%m11m11(jc3,jl0r,il0,jsub,isub)*norm
321 avg%blk(ic2,ib)%m2m2(jc3,jl0r,il0,jsub,isub) = avg%blk(ic2,ib)%m2m2(jc3,jl0r,il0,jsub,isub)*norm
323 if (.not.nam%gau_approx) avg%blk(ic2,ib)%m22(jc3,jl0r,il0,isub) &
324 & = avg%blk(ic2,ib)%m22(jc3,jl0r,il0,isub)*norm
327 call msr(avg%blk(ic2,ib)%m11(jc3,jl0r,il0))
328 do isub=1,avg%blk(ic2,ib)%nsub
329 do jsub=1,avg%blk(ic2,ib)%nsub
330 call msr(avg%blk(ic2,ib)%m11m11(jc3,jl0r,il0,jsub,isub))
331 call msr(avg%blk(ic2,ib)%m2m2(jc3,jl0r,il0,jsub,isub))
333 if (.not.nam%gau_approx)
call msr(avg%blk(ic2,ib)%m22(jc3,jl0r,il0,isub))
336 if (avg%blk(ic2,ib)%nc1a_cor(jc3,jl0r,il0)>0.0)
then 337 avg%blk(ic2,ib)%cor(jc3,jl0r,il0) = avg%blk(ic2,ib)%cor(jc3,jl0r,il0) &
338 & /avg%blk(ic2,ib)%nc1a_cor(jc3,jl0r,il0)
340 call msr(avg%blk(ic2,ib)%cor(jc3,jl0r,il0))
362 class(avg_type),
intent(inout) :: avg_lr
363 type(mpl_type),
intent(in) :: mpl
364 type(nam_type),
intent(in) :: nam
365 type(geom_type),
intent(in) :: geom
366 type(bpar_type),
intent(in) :: bpar
369 integer :: npack,offset,ib,ic2
370 real(kind_real),
allocatable :: sbuf(:),rbuf(:)
371 logical,
allocatable :: mask_unpack(:,:,:,:,:)
376 if (bpar%diag_block(ib))
then 378 if ((ic2==0).or.(nam%local_diag)) npack = npack+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg_lr%blk(ic2,ib)%nsub**2
384 allocate(sbuf(npack))
385 allocate(rbuf(npack))
391 if (bpar%diag_block(ib))
then 393 if ((ic2==0).or.(nam%local_diag))
then 394 sbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg_lr%blk(ic2,ib)%nsub**2) = &
395 & pack(avg_lr%blk(ic2,ib)%m11lrm11sub,.true.)
396 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg_lr%blk(ic2,ib)%nsub**2
403 call mpl%f_comm%allreduce(sbuf,rbuf,fckit_mpi_sum())
408 if (bpar%diag_block(ib))
then 410 allocate(mask_unpack(bpar%nc3(ib),bpar%nl0r(ib),geom%nl0,avg_lr%nsub,avg_lr%nsub))
417 if ((ic2==0).or.(nam%local_diag))
then 418 avg_lr%blk(ic2,ib)%m11lrm11sub = unpack(rbuf(offset+1:offset+bpar%nc3(ib)*bpar%nl0r(ib)* &
419 & geom%nl0*avg_lr%blk(ic2,ib)%nsub**2),mask_unpack,avg_lr%blk(ic2,ib)%m11lrm11sub)
420 offset = offset+bpar%nc3(ib)*bpar%nl0r(ib)*geom%nl0*avg_lr%blk(ic2,ib)%nsub**2
425 deallocate(mask_unpack)
440 class(avg_type),
intent(inout) :: avg_lr
441 type(nam_type),
intent(in) :: nam
442 type(geom_type),
intent(in) :: geom
443 type(bpar_type),
intent(in) :: bpar
446 integer :: ib,ic2,il0,jl0r,jc3,isub,jsub
447 real(kind_real) :: norm
451 if (bpar%diag_block(ib))
then 453 if ((ic2==0).or.(nam%local_diag))
then 456 do jl0r=1,bpar%nl0r(ib)
457 do jc3=1,bpar%nc3(ib)
458 if (avg_lr%blk(ic2,ib)%nc1a(jc3,jl0r,il0)>0.0)
then 459 norm = 1.0/avg_lr%blk(ic2,ib)%nc1a(jc3,jl0r,il0)
460 do isub=1,avg_lr%blk(ic2,ib)%nsub
461 do jsub=1,avg_lr%blk(ic2,ib)%nsub
462 avg_lr%blk(ic2,ib)%m11lrm11sub(jc3,jl0r,il0,jsub,isub) &
463 & = avg_lr%blk(ic2,ib)%m11lrm11sub(jc3,jl0r,il0,jsub,isub)*norm
467 do isub=1,avg_lr%blk(ic2,ib)%nsub
468 do jsub=1,avg_lr%blk(ic2,ib)%nsub
469 call msr(avg_lr%blk(ic2,ib)%m11lrm11sub(jc3,jl0r,il0,jsub,isub))
493 class(avg_type),
intent(inout) :: avg
494 type(mpl_type),
intent(inout) :: mpl
495 type(nam_type),
intent(in) :: nam
496 type(geom_type),
intent(in) :: geom
497 type(bpar_type),
intent(in) :: bpar
498 type(samp_type),
intent(in) :: samp
501 integer :: n,ib,il0,ic2a,ic2,iter
502 real(kind_real) :: P9,P20,P21
503 real(kind_real) :: m2sq,m4,m2sqasy,rhflt,drhflt
504 real(kind_real) :: m2_ini(samp%nc2a),m2(samp%nc2a),m2prod,m2prod_tot
505 logical :: dichotomy,convergence
509 p9 = -
real(n,kind_real)/
real((n-2)*(n-3),kind_real)
510 p20 =
real((n-1)*(n**2-3*n+3),kind_real)/
real(n*(n-2)*(n-3),kind_real)
511 p21 =
real(n-1,kind_real)/
real(n+1,kind_real)
514 if (bpar%diag_block(ib))
then 515 write(mpl%info,
'(a13,a,a,a)')
'',
'Block ',trim(bpar%blockname(ib)),
':' 519 write(mpl%info,
'(a16,a,i3,a)')
'',
'Level ',nam%levs(il0),
':' 526 m2sq = m2sq+sum(avg%blk(ic2,ib)%m2(il0,:)**2)/
real(avg%nsub,kind_real)
527 if (.not.nam%gau_approx) m4 = m4+sum(avg%blk(ic2,ib)%m4(il0,:))/
real(avg%nsub,kind_real)
531 if (nam%gau_approx)
then 536 m2sqasy = p20*m2sq+p9*m4
541 ic2 = samp%c2a_to_c2(ic2a)
542 m2_ini(ic2a) = sum(avg%blk(ic2,ib)%m2(il0,:))/
real(avg%nsub,kind_real)
546 rhflt = nam%var_rhflt
549 do iter=1,nam%var_niter
554 call samp%diag_filter(mpl,nam,geom,il0,
'median',rhflt,m2)
557 call samp%diag_filter(mpl,nam,geom,il0,
'gc99',rhflt,m2)
560 m2prod = sum(m2*m2_ini)
563 call mpl%f_comm%allreduce(m2prod,m2prod_tot,fckit_mpi_sum())
566 write(mpl%info,
'(a19,a,i2,a,f10.2,a,f10.2)')
'',
'Iteration ',iter,
': rhflt = ', &
567 & rhflt*reqkm,
' km, difference = ',m2prod_tot-m2sqasy
571 if (m2prod_tot>m2sqasy)
then 577 convergence = .false.
586 if (.not.dichotomy)
then 598 avg%blk(0,ib)%m2flt(il0) = sum(avg%blk(0,ib)%m2(il0,:))/
real(avg%nsub,kind_real)
600 ic2 = samp%c2a_to_c2(ic2a)
601 avg%blk(ic2,ib)%m2flt(il0) = m2(ic2a)
613 subroutine avg_compute(avg,mpl,nam,geom,bpar,samp,mom,ne)
618 class(avg_type),
intent(inout) :: avg
619 type(mpl_type),
intent(inout) :: mpl
620 type(nam_type),
intent(in) :: nam
621 type(geom_type),
intent(in) :: geom
622 type(bpar_type),
intent(in) :: bpar
623 type(samp_type),
intent(in) :: samp
624 type(mom_type),
intent(in) :: mom
625 integer,
intent(in) :: ne
631 call avg%alloc(nam,geom,bpar,mom%ne,mom%nsub)
634 write(mpl%info,
'(a10,a)')
'',
'Compute averaged statistics' 637 if (bpar%diag_block(ib))
then 638 write(mpl%info,
'(a13,a,a,a)',advance=
'no')
'',
'Block ',trim(bpar%blockname(ib)),
':' 640 call mpl%prog_init(nam%nc2+1)
642 if ((ic2==0).or.nam%local_diag)
call avg%blk(ic2,ib)%compute(nam,geom,bpar,samp,mom%blk(ib))
643 call mpl%prog_print(ic2+1)
645 write(mpl%info,
'(a)')
'100%' 650 if (mpl%nproc>1)
then 652 write(mpl%info,
'(a10,a)')
'',
'Gather averaged statistics' 654 call avg%gather(mpl,nam,geom,bpar)
658 write(mpl%info,
'(a10,a)')
'',
'Normalize averaged statistics' 660 call avg%normalize(nam,geom,bpar)
662 if (nam%var_filter)
then 664 write(mpl%info,
'(a10,a)')
'',
'Filter variance' 666 call avg%var_filter(mpl,nam,geom,bpar,samp)
670 write(mpl%info,
'(a10,a)')
'',
'Compute asymptotic statistics:' 673 if (bpar%diag_block(ib))
then 674 write(mpl%info,
'(a13,a,a,a)',advance=
'no')
'',
'Block ',trim(bpar%blockname(ib)),
':' 676 call mpl%prog_init(nam%nc2+1)
678 if ((ic2==0).or.nam%local_diag)
call avg%blk(ic2,ib)%compute_asy(nam,geom,bpar,ne)
679 call mpl%prog_print(ic2+1)
681 write(mpl%info,
'(a)')
'100%' 692 subroutine avg_compute_hyb(avg_2,mpl,nam,geom,bpar,samp,mom_1,mom_2,avg_1)
697 class(avg_type),
intent(inout) :: avg_2
698 type(mpl_type),
intent(inout) :: mpl
699 type(nam_type),
intent(in) :: nam
700 type(geom_type),
intent(in) :: geom
701 type(bpar_type),
intent(in) :: bpar
702 type(samp_type),
intent(in) :: samp
703 type(mom_type),
intent(in) :: mom_1
704 type(mom_type),
intent(in) :: mom_2
705 class(avg_type),
intent(inout) :: avg_1
711 if (.not.
allocated(avg_2%blk))
call avg_2%alloc(nam,geom,bpar,avg_2%ne,avg_2%nsub)
714 if (bpar%diag_block(ib))
then 715 write(mpl%info,
'(a10,a,a,a)')
'',
'Block ',trim(bpar%blockname(ib)),
':' 719 write(mpl%info,
'(a13,a)',advance=
'no')
'',
'Compute averaged statistics:' 721 call mpl%prog_init(nam%nc2+1)
723 if ((ic2==0).or.nam%local_diag)
then 724 select case (trim(nam%method))
727 avg_2%blk(ic2,ib)%m11sta = avg_1%blk(ic2,ib)%m11**2
728 avg_2%blk(ic2,ib)%stasq = avg_1%blk(ic2,ib)%m11**2
731 avg_2%blk(ic2,ib)%m11sta = avg_1%blk(ic2,ib)%m11*avg_2%blk(ic2,ib)%m11
732 avg_2%blk(ic2,ib)%stasq = avg_2%blk(ic2,ib)%m11**2
735 call avg_2%blk(ic2,ib)%compute_lr(mpl,nam,geom,bpar,samp,mom_1%blk(ib),mom_2%blk(ib))
738 call mpl%prog_print(ic2+1)
740 write(mpl%info,
'(a)')
'100%' 745 if (trim(nam%method)==
'dual-ens')
then 746 if (mpl%nproc>1)
then 748 write(mpl%info,
'(a13,a)')
'',
'Gather averaged statistics' 750 call avg_2%gather_lr(mpl,nam,geom,bpar)
754 write(mpl%info,
'(a10,a)')
'',
'Normalize averaged statistics' 756 call avg_2%normalize_lr(nam,geom,bpar)
759 if (bpar%diag_block(ib))
then 761 write(mpl%info,
'(a13,a)',advance=
'no')
'',
'Compute asymptotic statistics:' 763 call mpl%prog_init(nam%nc2+1)
765 if ((ic2==0).or.nam%local_diag)
call avg_2%blk(ic2,ib)%compute_asy_lr(nam,geom,bpar)
766 call mpl%prog_print(ic2+1)
768 write(mpl%info,
'(a)')
'100%' 780 type(avg_type) function avg_copy_wgt(avg,geom,bpar)
785 type(geom_type),
intent(in) :: geom
786 type(bpar_type),
intent(in) :: bpar
787 class(
avg_type),
intent(inout) :: avg
792 if (bpar%diag_block(bpar%nbe))
then 794 allocate(avg_copy_wgt%blk(0:0,bpar%nb))
797 if (bpar%diag_block(ib))
then 799 allocate(avg_copy_wgt%blk(0,ib)%m2m2asy(bpar%nc3(ib),bpar%nl0r(ib),geom%nl0))
802 avg_copy_wgt%blk(0,ib)%m2m2asy = avg%blk(0,ib)%m2m2asy
818 class(avg_type),
intent(inout) :: avg
819 type(mpl_type),
intent(inout) :: mpl
820 type(nam_type),
intent(in) :: nam
821 type(geom_type),
intent(in) :: geom
822 type(bpar_type),
intent(in) :: bpar
823 type(avg_type),
intent(in) :: avg_wgt
826 integer :: ib,ic2,il0,jl0r,jc3
827 real(kind_real) :: bwgtsq
828 real(kind_real),
allocatable :: cor(:,:,:),m11asysq(:,:,:),m11sq(:,:,:)
829 real(kind_real),
allocatable :: m11sta(:,:,:),stasq(:,:,:)
830 real(kind_real),
allocatable :: m11lrm11(:,:,:),m11lrm11asy(:,:,:)
833 allocate(cor(nam%nc3,bpar%nl0rmax,geom%nl0))
834 allocate(m11asysq(nam%nc3,bpar%nl0rmax,geom%nl0))
835 allocate(m11sq(nam%nc3,bpar%nl0rmax,geom%nl0))
836 select case (trim(nam%method))
837 case (
'hyb-avg',
'hyb-rnd')
838 allocate(m11sta(nam%nc3,bpar%nl0rmax,geom%nl0))
839 allocate(stasq(nam%nc3,bpar%nl0rmax,geom%nl0))
841 allocate(m11lrm11(nam%nc3,bpar%nl0rmax,geom%nl0))
842 allocate(m11lrm11asy(nam%nc3,bpar%nl0rmax,geom%nl0))
845 write(mpl%info,
'(a10,a,a,a)',advance=
'no')
'',
'Block ',trim(bpar%blockname(bpar%nbe)),
':' 849 call mpl%prog_init(nam%nc2+1)
853 avg%blk(ic2,bpar%nbe)%ne = avg%blk(ic2,1)%ne
854 avg%blk(ic2,bpar%nbe)%nsub = avg%blk(ic2,1)%nsub
856 if ((ic2==0).or.(nam%local_diag))
then 858 avg%blk(ic2,bpar%nbe)%cor = 0.0
860 avg%blk(ic2,bpar%nbe)%m11asysq = 0.0
862 avg%blk(ic2,bpar%nbe)%m11sq = 0.0
864 select case (trim(nam%method))
865 case (
'hyb-avg',
'hyb-rnd')
866 avg%blk(ic2,bpar%nbe)%m11sta = 0.0
868 avg%blk(ic2,bpar%nbe)%stasq = 0.0
871 avg%blk(ic2,bpar%nbe)%m11lrm11 = 0.0
873 avg%blk(ic2,bpar%nbe)%m11lrm11asy = 0.0
879 if (bpar%avg_block(ib))
then 882 do jl0r=1,bpar%nl0r(ib)
884 if (avg_wgt%blk(0,ib)%m2m2asy(1,jl0r,il0)>0.0)
then 885 bwgtsq = 1.0/avg_wgt%blk(0,ib)%m2m2asy(1,jl0r,il0)
892 call add(avg%blk(ic2,ib)%cor(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%cor(jc3,jl0r,il0),cor(jc3,jl0r,il0))
893 call add(avg%blk(ic2,ib)%m11asysq(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%m11asysq(jc3,jl0r,il0), &
894 & m11asysq(jc3,jl0r,il0),bwgtsq)
895 call add(avg%blk(ic2,ib)%m11sq(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%m11sq(jc3,jl0r,il0), &
896 & m11sq(jc3,jl0r,il0),bwgtsq)
897 select case (trim(nam%method))
898 case (
'hyb-avg',
'hyb-rnd')
899 call add(avg%blk(ic2,ib)%m11sta(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%m11sta(jc3,jl0r,il0), &
900 & m11sta(jc3,jl0r,il0),bwgtsq)
901 call add(avg%blk(ic2,ib)%stasq(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%stasq(jc3,jl0r,il0), &
902 & stasq(jc3,jl0r,il0),bwgtsq)
904 call add(avg%blk(ic2,ib)%m11lrm11(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%m11lrm11(jc3,jl0r,il0), &
905 & m11lrm11(jc3,jl0r,il0),bwgtsq)
906 call add(avg%blk(ic2,ib)%m11lrm11asy(jc3,jl0r,il0),avg%blk(ic2,bpar%nbe)%m11lrm11asy(jc3,jl0r,il0), &
907 & m11lrm11asy(jc3,jl0r,il0),bwgtsq)
919 do jl0r=1,bpar%nl0r(ib)
921 call divide(avg%blk(ic2,bpar%nbe)%cor(jc3,jl0r,il0),cor(jc3,jl0r,il0))
922 call divide(avg%blk(ic2,bpar%nbe)%m11asysq(jc3,jl0r,il0),m11asysq(jc3,jl0r,il0))
923 call divide(avg%blk(ic2,bpar%nbe)%m11sq(jc3,jl0r,il0),m11sq(jc3,jl0r,il0))
924 select case (trim(nam%method))
925 case (
'hyb-avg',
'hyb-rnd')
926 call divide(avg%blk(ic2,bpar%nbe)%m11sta(jc3,jl0r,il0),m11sta(jc3,jl0r,il0))
927 call divide(avg%blk(ic2,bpar%nbe)%stasq(jc3,jl0r,il0),stasq(jc3,jl0r,il0))
929 call divide(avg%blk(ic2,bpar%nbe)%m11lrm11(jc3,jl0r,il0),m11lrm11(jc3,jl0r,il0))
930 call divide(avg%blk(ic2,bpar%nbe)%m11lrm11asy(jc3,jl0r,il0),m11lrm11asy(jc3,jl0r,il0))
939 call mpl%prog_print(ic2+1)
941 write(mpl%info,
'(a)')
'100%'
type(avg_type) function avg_copy_wgt(avg, geom, bpar)
subroutine, public copy(self, rhs)
subroutine avg_normalize(avg, nam, geom, bpar)
subroutine avg_alloc(avg, nam, geom, bpar, ne, nsub)
subroutine avg_compute_bwavg(avg, mpl, nam, geom, bpar, avg_wgt)
subroutine avg_gather_lr(avg_lr, mpl, nam, geom, bpar)
subroutine avg_gather(avg, mpl, nam, geom, bpar)
subroutine avg_var_filter(avg, mpl, nam, geom, bpar, samp)
subroutine avg_compute_hyb(avg_2, mpl, nam, geom, bpar, samp, mom_1, mom_2, avg_1)
subroutine avg_normalize_lr(avg_lr, nam, geom, bpar)
type(avg_type) function avg_copy(avg, nam, geom, bpar)
integer, parameter, public kind_real
subroutine avg_dealloc(avg, nam, bpar)
subroutine avg_compute(avg, mpl, nam, geom, bpar, samp, mom, ne)