44 subroutine mom_alloc(mom,nam,geom,bpar,samp,ne,nsub)
49 class(mom_type),
intent(inout) :: mom
50 type(nam_type),
intent(in) :: nam
51 type(geom_type),
intent(in) :: geom
52 type(bpar_type),
intent(in) :: bpar
53 type(samp_type),
intent(in) :: samp
54 integer,
intent(in) :: ne
55 integer,
intent(in) :: nsub
65 allocate(mom%blk(bpar%nb))
68 if (bpar%diag_block(ib))
then 71 mom%blk(ib)%nsub = nsub
72 allocate(mom%blk(ib)%m2_1(samp%nc1a,bpar%nc3(ib),geom%nl0,mom%blk(ib)%nsub))
73 allocate(mom%blk(ib)%m2_2(samp%nc1a,bpar%nc3(ib),geom%nl0,mom%blk(ib)%nsub))
74 allocate(mom%blk(ib)%m11(samp%nc1a,bpar%nc3(ib),bpar%nl0r(ib),geom%nl0,mom%blk(ib)%nsub))
75 if (.not.nam%gau_approx)
allocate(mom%blk(ib)%m22(samp%nc1a,bpar%nc3(ib),bpar%nl0r(ib),geom%nl0,mom%blk(ib)%nsub))
76 if (nam%var_full)
allocate(mom%blk(ib)%m2full(geom%nc0a,geom%nl0,mom%blk(ib)%nsub))
79 mom%blk(ib)%m2_1 = 0.0
80 mom%blk(ib)%m2_2 = 0.0
82 if (.not.nam%gau_approx) mom%blk(ib)%m22 = 0.0
83 if (nam%var_full) mom%blk(ib)%m2full = 0.0
93 subroutine mom_compute(mom,mpl,nam,geom,bpar,samp,ens)
98 class(mom_type),
intent(inout) :: mom
99 type(mpl_type),
intent(in) :: mpl
100 type(nam_type),
intent(in) :: nam
101 type(geom_type),
intent(in) :: geom
102 type(bpar_type),
intent(in) :: bpar
103 type(samp_type),
intent(in) :: samp
104 type(ens_type),
intent(in) :: ens
107 integer :: ie,ie_sub,jc0,ic0c,jc0c,ic0,jl0r,jl0,il0,isub,jc3,ic1,ic1a,ib,jv,iv,jts,its
108 real(kind_real),
allocatable :: fld_ext(:,:,:,:),fld_1(:,:,:),fld_2(:,:,:)
109 logical,
allocatable :: mask_unpack(:,:)
112 call mom%alloc(nam,geom,bpar,samp,ens%ne,ens%nsub)
116 if (ens%nsub==1)
then 117 write(mpl%info,
'(a10,a)',advance=
'no')
'',
'Full ensemble, member:' 119 write(mpl%info,
'(a10,a,i4,a)',advance=
'no')
'',
'Sub-ensemble ',isub,
', member:' 124 do ie_sub=1,ens%ne/ens%nsub
125 write(mpl%info,
'(i4)',advance=
'no') ie_sub
129 ie = ie_sub+(isub-1)*ens%ne/ens%nsub
132 allocate(fld_ext(samp%nc0c,geom%nl0,nam%nv,nam%nts))
133 allocate(mask_unpack(samp%nc0c,geom%nl0))
138 iv = bpar%b_to_v1(ib)
139 jv = bpar%b_to_v2(ib)
140 its = bpar%b_to_ts1(ib)
141 jts = bpar%b_to_ts2(ib)
144 if ((iv==jv).and.(its==jts))
call samp%com_AC%ext(mpl,geom%nl0,ens%fld(:,:,iv,its,ie),fld_ext(:,:,iv,its))
148 if (bpar%diag_block(ib))
then 150 allocate(fld_1(samp%nc1a,bpar%nc3(ib),geom%nl0))
151 allocate(fld_2(samp%nc1a,bpar%nc3(ib),geom%nl0))
154 iv = bpar%b_to_v1(ib)
155 jv = bpar%b_to_v2(ib)
156 its = bpar%b_to_ts1(ib)
157 jts = bpar%b_to_ts2(ib)
162 if ((iv/=jv).and.(its/=jts).and.nam%displ_diag)
then 166 call samp%d(il0,its)%apply(mpl,fld_ext(:,il0,iv,its),fld_1(:,1,il0))
167 call samp%d(il0,jts)%apply(mpl,fld_ext(:,il0,jv,jts),fld_2(:,1,il0))
174 do jc3=1,bpar%nc3(ib)
177 ic1 = samp%c1a_to_c1(ic1a)
179 if (samp%c1l0_log(ic1,il0).and.samp%c1c3l0_log(ic1,jc3,il0))
then 181 ic0 = samp%c1_to_c0(ic1)
182 jc0 = samp%c1c3_to_c0(ic1,jc3)
183 ic0c = samp%c0_to_c0c(ic0)
184 jc0c = samp%c0_to_c0c(jc0)
187 fld_1(ic1a,jc3,il0) = fld_ext(ic0c,il0,iv,its)
188 fld_2(ic1a,jc3,il0) = fld_ext(jc0c,il0,jv,jts)
198 do jl0r=1,bpar%nl0r(ib)
199 jl0 = bpar%l0rl0b_to_l0(jl0r,il0,ib)
202 if (.not.nam%gau_approx) mom%blk(ib)%m22(:,:,jl0r,il0,isub) = mom%blk(ib)%m22(:,:,jl0r,il0,isub) &
203 & +fld_1(:,:,il0)**2*fld_2(:,:,jl0)**2
206 mom%blk(ib)%m11(:,:,jl0r,il0,isub) = mom%blk(ib)%m11(:,:,jl0r,il0,isub)+fld_1(:,:,il0)*fld_2(:,:,jl0)
212 mom%blk(ib)%m2_1(:,:,:,isub) = mom%blk(ib)%m2_1(:,:,:,isub)+fld_1**2
213 mom%blk(ib)%m2_2(:,:,:,isub) = mom%blk(ib)%m2_2(:,:,:,isub)+fld_2**2
216 if (nam%var_full) mom%blk(ib)%m2full(:,:,isub) = mom%blk(ib)%m2full(:,:,isub)+ens%fld(:,:,iv,its,ie)**2
226 deallocate(mask_unpack)
228 write(mpl%info,
'(a)')
'' 234 if (bpar%diag_block(ib))
then 235 mom%blk(ib)%m2_1 = mom%blk(ib)%m2_1/
real(mom%ne/mom%nsub-1,kind_real)
236 mom%blk(ib)%m2_2 = mom%blk(ib)%m2_2/
real(mom%ne/mom%nsub-1,kind_real)
237 mom%blk(ib)%m11 = mom%blk(ib)%m11/
real(mom%ne/mom%nsub-1,kind_real)
238 if (.not.nam%gau_approx) mom%blk(ib)%m22 = mom%blk(ib)%m22/
real(mom%ne/mom%nsub,kind_real)
239 if (nam%var_full) mom%blk(ib)%m2full = mom%blk(ib)%m2full/
real(mom%ne/mom%nsub-1,kind_real)
subroutine mom_compute(mom, mpl, nam, geom, bpar, samp, ens)
integer, parameter, public kind_real
subroutine mom_alloc(mom, nam, geom, bpar, samp, ne, nsub)