10 use fckit_mpi_module,
only: fckit_mpi_sum
36 character(len=1024) :: prefix
68 class(cmat_type),
intent(inout) :: cmat
69 type(bpar_type),
intent(in) :: bpar
70 character(len=*),
intent(in) :: prefix
79 if (.not.
allocated(cmat%blk))
allocate(cmat%blk(bpar%nbe))
83 cmat%blk(ib)%name = trim(prefix)//
'_'//trim(bpar%blockname(ib))
97 class(cmat_type),
intent(inout) :: cmat
98 type(nam_type),
target,
intent(in) :: nam
99 type(geom_type),
target,
intent(in) :: geom
100 type(bpar_type),
intent(in) :: bpar
108 call cmat%blk(ib)%alloc(nam,geom,bpar)
112 cmat%allocated = .true.
125 class(cmat_type),
intent(inout) :: cmat
126 type(bpar_type),
intent(in) :: bpar
132 if (
allocated(cmat%blk))
then 134 call cmat%blk(ib)%dealloc
140 cmat%allocated = .false.
148 type(cmat_type) function cmat_copy(cmat,nam,geom,bpar)
154 type(
nam_type),
target,
intent(in) :: nam
155 type(
geom_type),
target,
intent(in) :: geom
162 call cmat_copy%alloc(bpar,trim(cmat%prefix))
166 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 167 cmat_copy%blk(ib)%double_fit = cmat%blk(ib)%double_fit
168 cmat_copy%blk(ib)%anisotropic = cmat%blk(ib)%anisotropic
173 call cmat_copy%alloc(nam,geom,bpar)
177 if (
allocated(cmat%blk(ib)%coef_ens)) cmat_copy%blk(ib)%coef_ens = cmat%blk(ib)%coef_ens
178 if (
allocated(cmat%blk(ib)%coef_sta)) cmat_copy%blk(ib)%coef_sta = cmat%blk(ib)%coef_sta
179 if (
allocated(cmat%blk(ib)%rh)) cmat_copy%blk(ib)%rh = cmat%blk(ib)%rh
180 if (
allocated(cmat%blk(ib)%rv)) cmat_copy%blk(ib)%rv = cmat%blk(ib)%rv
181 if (
allocated(cmat%blk(ib)%rv_rfac)) cmat_copy%blk(ib)%rv_rfac = cmat%blk(ib)%rv_rfac
182 if (
allocated(cmat%blk(ib)%rv_coef)) cmat_copy%blk(ib)%rv_coef = cmat%blk(ib)%rv_coef
183 if (
allocated(cmat%blk(ib)%rhs)) cmat_copy%blk(ib)%rhs = cmat%blk(ib)%rhs
184 if (
allocated(cmat%blk(ib)%rvs)) cmat_copy%blk(ib)%rvs = cmat%blk(ib)%rvs
185 if (
allocated(cmat%blk(ib)%H11)) cmat_copy%blk(ib)%H11 = cmat%blk(ib)%H11
186 if (
allocated(cmat%blk(ib)%H22)) cmat_copy%blk(ib)%H22 = cmat%blk(ib)%H22
187 if (
allocated(cmat%blk(ib)%H33)) cmat_copy%blk(ib)%H33 = cmat%blk(ib)%H33
188 if (
allocated(cmat%blk(ib)%H12)) cmat_copy%blk(ib)%H12 = cmat%blk(ib)%H12
189 if (
allocated(cmat%blk(ib)%Hcoef)) cmat_copy%blk(ib)%Hcoef = cmat%blk(ib)%Hcoef
190 if (
allocated(cmat%blk(ib)%displ_lon)) cmat_copy%blk(ib)%displ_lon = cmat%blk(ib)%displ_lon
191 if (
allocated(cmat%blk(ib)%displ_lat)) cmat_copy%blk(ib)%displ_lat = cmat%blk(ib)%displ_lat
200 subroutine cmat_read(cmat,mpl,nam,geom,bpar,io)
205 class(cmat_type),
intent(inout) :: cmat
206 type(mpl_type),
intent(inout) :: mpl
207 type(nam_type),
intent(in) :: nam
208 type(geom_type),
intent(in) :: geom
209 type(bpar_type),
intent(in) :: bpar
210 type(io_type),
intent(in) :: io
213 integer :: ib,ncid,double_fit,anisotropic
214 character(len=1024) :: filename
215 character(len=1024) :: subr =
'cmat_read' 218 call cmat%alloc(bpar,
'cmat')
221 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 224 filename = trim(nam%prefix)//
'_'//trim(cmat%blk(ib)%name)
227 call mpl%ncerr(subr,nf90_open(trim(nam%datadir)//
'/'//trim(filename)//
'.nc',nf90_nowrite,ncid))
228 call mpl%ncerr(subr,nf90_get_att(ncid,nf90_global,
'double_fit',double_fit))
229 if (double_fit==1)
then 230 cmat%blk(ib)%double_fit = .true.
232 cmat%blk(ib)%double_fit = .false.
234 call mpl%ncerr(subr,nf90_get_att(ncid,nf90_global,
'anisotropic',anisotropic))
235 if (anisotropic==1)
then 236 cmat%blk(ib)%anisotropic = .true.
238 cmat%blk(ib)%anisotropic = .false.
240 call mpl%ncerr(subr,nf90_close(ncid))
244 call mpl%f_comm%broadcast(cmat%blk(ib)%double_fit,mpl%ioproc-1)
245 call mpl%f_comm%broadcast(cmat%blk(ib)%anisotropic,mpl%ioproc-1)
250 call cmat%alloc(nam,geom,bpar)
253 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 255 filename = trim(nam%prefix)//
'_'//trim(cmat%blk(ib)%name)
258 if (bpar%nicas_block(ib))
then 259 call io%fld_read(mpl,nam,geom,filename,
'coef_ens',cmat%blk(ib)%coef_ens)
260 call io%fld_read(mpl,nam,geom,filename,
'coef_sta',cmat%blk(ib)%coef_sta)
261 call io%fld_read(mpl,nam,geom,filename,
'rh',cmat%blk(ib)%rh)
262 call io%fld_read(mpl,nam,geom,filename,
'rv',cmat%blk(ib)%rv)
263 if (cmat%blk(ib)%double_fit)
then 264 call io%fld_read(mpl,nam,geom,filename,
'rv_rfac',cmat%blk(ib)%rv_rfac)
265 call io%fld_read(mpl,nam,geom,filename,
'rv_coef',cmat%blk(ib)%rv_coef)
267 call io%fld_read(mpl,nam,geom,filename,
'rhs',cmat%blk(ib)%rhs)
268 call io%fld_read(mpl,nam,geom,filename,
'rvs',cmat%blk(ib)%rvs)
269 if (cmat%blk(ib)%anisotropic)
then 270 call io%fld_read(mpl,nam,geom,filename,
'H11',cmat%blk(ib)%H11)
271 call io%fld_read(mpl,nam,geom,filename,
'H22',cmat%blk(ib)%H22)
272 call io%fld_read(mpl,nam,geom,filename,
'H33',cmat%blk(ib)%H33)
273 call io%fld_read(mpl,nam,geom,filename,
'H12',cmat%blk(ib)%H12)
276 if ((ib==bpar%nbe).and.nam%displ_diag)
then 277 call io%fld_read(mpl,nam,geom,filename,
'displ_lon',cmat%blk(ib)%displ_lon)
278 call io%fld_read(mpl,nam,geom,filename,
'displ_lat',cmat%blk(ib)%displ_lat)
289 subroutine cmat_write(cmat,mpl,nam,geom,bpar,io)
294 class(cmat_type),
intent(in) :: cmat
295 type(mpl_type),
intent(inout) :: mpl
296 type(nam_type),
intent(in) :: nam
297 type(geom_type),
intent(in) :: geom
298 type(bpar_type),
intent(in) :: bpar
299 type(io_type),
intent(in) :: io
303 character(len=1024) :: filename
304 character(len=1024) :: subr =
'cmat_write' 307 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 309 filename = trim(nam%prefix)//
'_'//trim(cmat%blk(ib)%name)
312 if (bpar%nicas_block(ib))
then 313 call io%fld_write(mpl,nam,geom,filename,
'coef_ens',cmat%blk(ib)%coef_ens)
314 call io%fld_write(mpl,nam,geom,filename,
'coef_sta',cmat%blk(ib)%coef_sta)
315 call io%fld_write(mpl,nam,geom,filename,
'rh',cmat%blk(ib)%rh)
316 call io%fld_write(mpl,nam,geom,filename,
'rv',cmat%blk(ib)%rv)
317 if (cmat%blk(ib)%double_fit)
then 318 call io%fld_write(mpl,nam,geom,filename,
'rv_rfac',cmat%blk(ib)%rv_rfac)
319 call io%fld_write(mpl,nam,geom,filename,
'rv_coef',cmat%blk(ib)%rv_coef)
321 call io%fld_write(mpl,nam,geom,filename,
'rhs',cmat%blk(ib)%rhs)
322 call io%fld_write(mpl,nam,geom,filename,
'rvs',cmat%blk(ib)%rvs)
323 if (cmat%blk(ib)%anisotropic)
then 324 call io%fld_write(mpl,nam,geom,filename,
'H11',cmat%blk(ib)%H11)
325 call io%fld_write(mpl,nam,geom,filename,
'H22',cmat%blk(ib)%H22)
326 call io%fld_write(mpl,nam,geom,filename,
'H33',cmat%blk(ib)%H33)
327 call io%fld_write(mpl,nam,geom,filename,
'H12',cmat%blk(ib)%H12)
330 if ((ib==bpar%nbe).and.nam%displ_diag)
then 331 call io%fld_write(mpl,nam,geom,filename,
'displ_lon',cmat%blk(ib)%displ_lon)
332 call io%fld_write(mpl,nam,geom,filename,
'displ_lat',cmat%blk(ib)%displ_lat)
337 call mpl%ncerr(subr,nf90_open(trim(nam%datadir)//
'/'//trim(filename)//
'.nc',nf90_write,ncid))
338 call mpl%ncerr(subr,nf90_redef(ncid))
339 if (cmat%blk(ib)%double_fit)
then 340 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'double_fit',1))
342 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'double_fit',0))
344 if (cmat%blk(ib)%anisotropic)
then 345 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'anisotropic',1))
347 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'anisotropic',0))
349 call mpl%ncerr(subr,nf90_close(ncid))
365 class(cmat_type),
intent(inout) :: cmat
366 type(mpl_type),
intent(inout) :: mpl
367 type(nam_type),
intent(in) :: nam
368 type(geom_type),
intent(in) :: geom
369 type(bpar_type),
intent(in) :: bpar
370 type(hdiag_type),
intent(in) :: hdiag
373 integer :: ib,n,i,il0,il0i,ic2a,its
374 real(kind_real) :: fld_c2a(hdiag%samp%nc2a,geom%nl0,6),fld_c2b(hdiag%samp%nc2b,geom%nl0),fld_c0a(geom%nc0a,geom%nl0,6)
377 call cmat%alloc(bpar,
'cmat')
381 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 382 select case (trim(nam%method))
384 cmat%blk(ib)%double_fit = hdiag%cor_1%blk(0,ib)%double_fit
385 case (
'loc_norm',
'loc')
386 cmat%blk(ib)%double_fit = hdiag%loc_1%blk(0,ib)%double_fit
387 case (
'hyb-avg',
'hyb-rnd')
388 cmat%blk(ib)%double_fit = hdiag%loc_2%blk(0,ib)%double_fit
390 call mpl%abort(
'dual-ens not ready yet for C matrix')
392 call mpl%abort(
'cmat not implemented yet for this method')
394 cmat%blk(ib)%anisotropic = .false.
399 call cmat%alloc(nam,geom,bpar)
403 if (bpar%B_block(ib))
then 404 if (bpar%nicas_block(ib))
then 405 if (nam%local_diag)
then 408 if (cmat%blk(ib)%double_fit) n = n+2
409 do ic2a=1,hdiag%samp%nc2a
410 select case (trim(nam%method))
412 fld_c2a(ic2a,:,1) = hdiag%cor_1%blk(ic2a,ib)%raw_coef_ens
413 fld_c2a(ic2a,:,2) = 0.0
414 fld_c2a(ic2a,:,3) = hdiag%cor_1%blk(ic2a,ib)%fit_rh
415 fld_c2a(ic2a,:,4) = hdiag%cor_1%blk(ic2a,ib)%fit_rv
416 if (cmat%blk(ib)%double_fit)
then 417 fld_c2a(ic2a,:,5) = hdiag%cor_1%blk(ic2a,ib)%fit_rv_rfac
418 fld_c2a(ic2a,:,6) = hdiag%cor_1%blk(ic2a,ib)%fit_rv_coef
420 case (
'loc_norm',
'loc')
421 fld_c2a(ic2a,:,1) = hdiag%loc_1%blk(ic2a,ib)%raw_coef_ens
422 fld_c2a(ic2a,:,2) = 0.0
423 fld_c2a(ic2a,:,3) = hdiag%loc_1%blk(ic2a,ib)%fit_rh
424 fld_c2a(ic2a,:,4) = hdiag%loc_1%blk(ic2a,ib)%fit_rv
425 if (cmat%blk(ib)%double_fit)
then 426 fld_c2a(ic2a,:,5) = hdiag%loc_1%blk(ic2a,ib)%fit_rv_rfac
427 fld_c2a(ic2a,:,6) = hdiag%loc_1%blk(ic2a,ib)%fit_rv_coef
429 case (
'hyb-avg',
'hyb-rnd')
430 fld_c2a(ic2a,:,1) = hdiag%loc_2%blk(ic2a,ib)%raw_coef_ens
431 fld_c2a(ic2a,:,2) = hdiag%loc_2%blk(ic2a,ib)%raw_coef_sta
432 fld_c2a(ic2a,:,3) = hdiag%loc_2%blk(ic2a,ib)%fit_rh
433 fld_c2a(ic2a,:,4) = hdiag%loc_2%blk(ic2a,ib)%fit_rv
434 if (cmat%blk(ib)%double_fit)
then 435 fld_c2a(ic2a,:,5) = hdiag%loc_2%blk(ic2a,ib)%fit_rv_rfac
436 fld_c2a(ic2a,:,6) = hdiag%loc_2%blk(ic2a,ib)%fit_rv_coef
439 call mpl%abort(
'dual-ens not ready yet for C matrix')
441 call mpl%abort(
'cmat not implemented yet for this method')
448 call hdiag%samp%diag_fill(mpl,nam,geom,il0,fld_c2a(:,il0,i))
452 call hdiag%samp%com_AB%ext(mpl,geom%nl0,fld_c2a(:,:,i),fld_c2b)
454 il0i =
min(il0,geom%nl0i)
455 call hdiag%samp%h(il0i)%apply(mpl,fld_c2b(:,il0),fld_c0a(:,il0,i))
460 cmat%blk(ib)%coef_ens = fld_c0a(:,:,1)
461 call mpl%f_comm%allreduce(sum(cmat%blk(ib)%coef_ens,mask=geom%mask_c0a),cmat%blk(ib)%wgt,fckit_mpi_sum())
462 cmat%blk(ib)%wgt = cmat%blk(ib)%wgt/
real(count(geom%mask_c0),kind_real)
463 cmat%blk(ib)%coef_sta = fld_c0a(:,:,2)
464 cmat%blk(ib)%rh = fld_c0a(:,:,3)
465 cmat%blk(ib)%rv = fld_c0a(:,:,4)
466 if (cmat%blk(ib)%double_fit)
then 467 cmat%blk(ib)%rv_rfac = fld_c0a(:,:,5)
468 cmat%blk(ib)%rv_coef = fld_c0a(:,:,6)
474 select case (trim(nam%method))
476 cmat%blk(ib)%coef_ens(:,il0) = hdiag%cor_1%blk(0,ib)%raw_coef_ens(il0)
477 cmat%blk(ib)%wgt = sum(hdiag%cor_1%blk(0,ib)%raw_coef_ens)/
real(geom%nl0,kind_real)
478 cmat%blk(ib)%coef_sta(:,il0) = 0.0
479 cmat%blk(ib)%rh(:,il0) = hdiag%cor_1%blk(0,ib)%fit_rh(il0)
480 cmat%blk(ib)%rv(:,il0) = hdiag%cor_1%blk(0,ib)%fit_rv(il0)
481 if (cmat%blk(ib)%double_fit)
then 482 cmat%blk(ib)%rv_rfac(:,il0) = hdiag%cor_1%blk(0,ib)%fit_rv_rfac(il0)
483 cmat%blk(ib)%rv_coef(:,il0) = hdiag%cor_1%blk(0,ib)%fit_rv_coef(il0)
485 case (
'loc_norm',
'loc')
486 cmat%blk(ib)%coef_ens(:,il0) = hdiag%loc_1%blk(0,ib)%raw_coef_ens(il0)
487 cmat%blk(ib)%wgt = sum(hdiag%loc_1%blk(0,ib)%raw_coef_ens)/
real(geom%nl0,kind_real)
488 cmat%blk(ib)%coef_sta(:,il0) = 0.0
489 cmat%blk(ib)%rh(:,il0) = hdiag%loc_1%blk(0,ib)%fit_rh(il0)
490 cmat%blk(ib)%rv(:,il0) = hdiag%loc_1%blk(0,ib)%fit_rv(il0)
491 if (cmat%blk(ib)%double_fit)
then 492 cmat%blk(ib)%rv_rfac(:,il0) = hdiag%loc_1%blk(0,ib)%fit_rv_rfac(il0)
493 cmat%blk(ib)%rv_coef(:,il0) = hdiag%loc_1%blk(0,ib)%fit_rv_coef(il0)
495 case (
'hyb-avg',
'hyb-rnd')
496 cmat%blk(ib)%coef_ens(:,il0) = hdiag%loc_2%blk(0,ib)%raw_coef_ens(il0)
497 cmat%blk(ib)%wgt = sum(hdiag%loc_2%blk(0,ib)%raw_coef_ens)/
real(geom%nl0,kind_real)
498 cmat%blk(ib)%coef_sta(:,il0) = hdiag%loc_2%blk(0,ib)%raw_coef_sta
499 cmat%blk(ib)%rh(:,il0) = hdiag%loc_2%blk(0,ib)%fit_rh(il0)
500 cmat%blk(ib)%rv(:,il0) = hdiag%loc_2%blk(0,ib)%fit_rv(il0)
501 if (cmat%blk(ib)%double_fit)
then 502 cmat%blk(ib)%rv_rfac(:,il0) = hdiag%loc_2%blk(0,ib)%fit_rv_rfac(il0)
503 cmat%blk(ib)%rv_coef(:,il0) = hdiag%loc_2%blk(0,ib)%fit_rv_coef(il0)
506 call mpl%abort(
'dual-ens not ready yet for C matrix')
508 call mpl%abort(
'cmat not implemented yet for this method')
514 select case (trim(nam%method))
516 cmat%blk(ib)%wgt = sum(hdiag%cor_1%blk(0,ib)%raw_coef_ens)/
real(geom%nl0,kind_real)
517 case (
'loc_norm',
'loc')
518 cmat%blk(ib)%wgt = sum(hdiag%loc_1%blk(0,ib)%raw_coef_ens)/
real(geom%nl0,kind_real)
519 case (
'hyb-avg',
'hyb-rnd')
520 cmat%blk(ib)%wgt = sum(hdiag%loc_2%blk(0,ib)%raw_coef_ens)/
real(geom%nl0,kind_real)
522 call mpl%abort(
'dual-ens not ready yet for C matrix')
524 call mpl%abort(
'cmat not implemented yet for this method')
531 if (nam%displ_diag)
then 533 cmat%blk(bpar%nbe)%displ_lon(:,:,its) = hdiag%samp%displ_lon(:,:,its)
534 cmat%blk(bpar%nbe)%displ_lat(:,:,its) = hdiag%samp%displ_lat(:,:,its)
549 class(cmat_type),
intent(inout) :: cmat
550 type(mpl_type),
intent(inout) :: mpl
551 type(nam_type),
intent(in) :: nam
552 type(geom_type),
intent(in) :: geom
553 type(bpar_type),
intent(in) :: bpar
554 type(lct_type),
intent(in) :: lct
557 integer :: ib,iv,jv,its,jts,iscales,il0,ic0a
558 real(kind_real) :: tr,det,diff
561 call cmat%alloc(bpar,
'cmat')
565 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 566 cmat%blk(ib)%double_fit = .false.
567 cmat%blk(ib)%anisotropic = .true.
572 call cmat%alloc(nam,geom,bpar)
576 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 578 iv = bpar%b_to_v1(ib)
579 jv = bpar%b_to_v2(ib)
580 its = bpar%b_to_ts1(ib)
581 jts = bpar%b_to_ts2(ib)
582 if ((iv/=jv).or.(its/=jts))
call mpl%abort(
'only diagonal blocks for cmat_from_lct')
584 if (lct%blk(ib)%nscales>1)
call mpl%warning(
'only the first scale is used to define cmat from LCT')
589 if (geom%mask_c0a(ic0a,il0))
then 591 cmat%blk(ib)%H11(ic0a,il0) = lct%blk(ib)%H11(ic0a,il0,iscales)
592 cmat%blk(ib)%H22(ic0a,il0) = lct%blk(ib)%H22(ic0a,il0,iscales)
593 cmat%blk(ib)%H33(ic0a,il0) = lct%blk(ib)%H33(ic0a,il0,iscales)
594 cmat%blk(ib)%H12(ic0a,il0) = lct%blk(ib)%H12(ic0a,il0,iscales)
597 cmat%blk(ib)%Hcoef(ic0a,il0) = lct%blk(ib)%Dcoef(ic0a,il0,iscales)
600 tr = cmat%blk(ib)%H11(ic0a,il0)+cmat%blk(ib)%H22(ic0a,il0)
601 det = cmat%blk(ib)%H11(ic0a,il0)*cmat%blk(ib)%H22(ic0a,il0)-cmat%blk(ib)%H12(ic0a,il0)**2
602 diff = 0.25*(cmat%blk(ib)%H11(ic0a,il0)-cmat%blk(ib)%H22(ic0a,il0))**2+cmat%blk(ib)%H12(ic0a,il0)**2
603 if ((det>0.0).and..not.(diff<0.0))
then 604 if (0.5*tr>sqrt(diff))
then 605 cmat%blk(ib)%rh(ic0a,il0) = gau2gc/(sqrt(0.5*tr-sqrt(diff)))
607 write(mpl%info,*) 0.5*tr,sqrt(diff)
608 call mpl%abort(
'non positive-definite LCT in cmat_from_lct (eigenvalue)')
611 write(mpl%info,*) cmat%blk(ib)%H11(ic0a,il0),cmat%blk(ib)%H22(ic0a,il0), &
612 & cmat%blk(ib)%H12(ic0a,il0)
613 call mpl%abort(
'non positive-definite LCT in cmat_from_lct (determinant)')
615 if (cmat%blk(ib)%H33(ic0a,il0)>0.0)
then 616 cmat%blk(ib)%rv(ic0a,il0) = gau2gc/(sqrt(cmat%blk(ib)%H33(ic0a,il0)))
618 cmat%blk(ib)%rv(ic0a,il0) = 0.0
625 cmat%blk(ib)%coef_ens = 1.0
626 cmat%blk(ib)%coef_sta = 0.0
627 cmat%blk(ib)%wgt = 1.0
642 class(cmat_type),
intent(inout) :: cmat
643 type(mpl_type),
intent(in) :: mpl
644 type(nam_type),
intent(in) :: nam
645 type(geom_type),
intent(in) :: geom
646 type(bpar_type),
intent(in) :: bpar
649 integer :: ib,iv,jv,its,jts
651 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 652 write(mpl%info,
'(a)')
'--- Copy namelist radii into C matrix' 656 call cmat%alloc(bpar,
'cmat')
660 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 661 cmat%blk(ib)%double_fit = .false.
662 cmat%blk(ib)%anisotropic = .false.
667 call cmat%alloc(nam,geom,bpar)
671 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 673 iv = bpar%b_to_v1(ib)
674 jv = bpar%b_to_v2(ib)
675 its = bpar%b_to_ts1(ib)
676 jts = bpar%b_to_ts2(ib)
677 if ((iv/=jv).or.(its/=jts))
call mpl%abort(
'only diagonal blocks for cmat_from_nam')
680 cmat%blk(ib)%rh = nam%rh
681 cmat%blk(ib)%rhs = nam%rh
682 cmat%blk(ib)%rv = nam%rv
683 cmat%blk(ib)%rvs = nam%rv
686 cmat%blk(ib)%coef_ens = 1.0
687 cmat%blk(ib)%coef_sta = 0.0
688 cmat%blk(ib)%wgt = 1.0
703 class(cmat_type),
intent(inout) :: cmat
704 type(mpl_type),
intent(in) :: mpl
705 type(geom_type),
intent(in) :: geom
706 type(bpar_type),
intent(in) :: bpar
712 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 713 if (
allocated(cmat%blk(ib)%oops_coef_ens))
then 714 write(mpl%info,
'(a7,a,a)')
'',
'Ensemble coefficient copied from OOPS for block ',trim(bpar%blockname(ib))
715 cmat%blk(ib)%coef_ens = cmat%blk(ib)%oops_coef_ens
716 call mpl%f_comm%allreduce(sum(cmat%blk(ib)%coef_ens,mask=geom%mask_c0a),cmat%blk(ib)%wgt,fckit_mpi_sum())
717 cmat%blk(ib)%wgt = cmat%blk(ib)%wgt/
real(count(geom%mask_c0),kind_real)
719 if (
allocated(cmat%blk(ib)%oops_coef_sta))
then 720 write(mpl%info,
'(a7,a,a)')
'',
'Static coefficient copied from OOPS for block ',trim(bpar%blockname(ib))
721 cmat%blk(ib)%coef_sta = cmat%blk(ib)%oops_coef_sta
723 if (
allocated(cmat%blk(ib)%oops_rh))
then 724 write(mpl%info,
'(a7,a,a)')
'',
'Horizontal fit support radius copied from OOPS for block ',trim(bpar%blockname(ib))
725 cmat%blk(ib)%rh = cmat%blk(ib)%oops_rh
727 if (
allocated(cmat%blk(ib)%oops_rv))
then 728 write(mpl%info,
'(a7,a,a)')
'',
'Vertical fit support radius copied from OOPS for block ',trim(bpar%blockname(ib))
729 cmat%blk(ib)%rv = cmat%blk(ib)%oops_rv
731 if (
allocated(cmat%blk(ib)%oops_rv_rfac))
then 732 write(mpl%info,
'(a7,a,a)')
'',
'Vertical fit factor copied from OOPS for block ',trim(bpar%blockname(ib))
733 cmat%blk(ib)%rv_rfac = cmat%blk(ib)%oops_rv_rfac
735 if (
allocated(cmat%blk(ib)%oops_rv_coef))
then 736 write(mpl%info,
'(a7,a,a)')
'',
'Vertical fit coefficient copied from OOPS for block ',trim(bpar%blockname(ib))
737 cmat%blk(ib)%rv_coef = cmat%blk(ib)%oops_rv_coef
753 class(cmat_type),
intent(inout) :: cmat
754 type(nam_type),
target,
intent(in) :: nam
755 type(geom_type),
target,
intent(in) :: geom
756 type(bpar_type),
intent(in) :: bpar
759 integer :: ib,il0,ic0a
762 if (trim(nam%strategy)==
'specific_multivariate')
then 764 cmat%blk(bpar%nbe)%rhs = huge(1.0)
765 cmat%blk(bpar%nbe)%rvs = huge(1.0)
767 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 771 cmat%blk(bpar%nbe)%rhs(ic0a,il0) =
min(cmat%blk(bpar%nbe)%rhs(ic0a,il0),cmat%blk(ib)%rh(ic0a,il0))
772 cmat%blk(bpar%nbe)%rvs(ic0a,il0) =
min(cmat%blk(bpar%nbe)%rvs(ic0a,il0),cmat%blk(ib)%rv(ic0a,il0))
780 if (bpar%B_block(ib).and.bpar%nicas_block(ib))
then 781 cmat%blk(ib)%rhs = cmat%blk(ib)%rh
782 cmat%blk(ib)%rvs = cmat%blk(ib)%rv
subroutine cmat_from_hdiag(cmat, mpl, nam, geom, bpar, hdiag)
subroutine cmat_alloc(cmat, bpar, prefix)
subroutine, public copy(self, rhs)
subroutine cmat_dealloc(cmat, bpar)
subroutine cmat_read(cmat, mpl, nam, geom, bpar, io)
subroutine cmat_write(cmat, mpl, nam, geom, bpar, io)
subroutine cmat_from_nam(cmat, mpl, nam, geom, bpar)
type(cmat_type) function cmat_copy(cmat, nam, geom, bpar)
real(kind=kind_real), parameter req
Earth radius at equator (m)
subroutine cmat_from_lct(cmat, mpl, nam, geom, bpar, lct)
subroutine cmat_alloc_blk(cmat, nam, geom, bpar)
subroutine cmat_from_oops(cmat, mpl, geom, bpar)
integer, parameter, public kind_real
subroutine cmat_setup_sampling(cmat, nam, geom, bpar)