29 use fckit_mpi_module,
only: fckit_mpi_sum
34 integer,
parameter ::
nfac = 10
35 integer,
parameter ::
ntest = 100
40 character(len=1024) :: prefix
80 class(nicas_type),
intent(inout) :: nicas
81 type(mpl_type),
intent(in) :: mpl
82 type(nam_type),
intent(in) :: nam
83 type(bpar_type),
intent(in) :: bpar
84 character(len=*),
intent(in) :: prefix
93 allocate(nicas%blk(bpar%nbe))
99 write(nicas%blk(ib)%name,
'(a,i1,a,i4.4,a,i4.4,a,a)') trim(prefix)//
'-',nam%mpicom,
'-sqrt_',mpl%nproc,
'-',mpl%myproc, &
100 &
'_',trim(bpar%blockname(ib))
102 write(nicas%blk(ib)%name,
'(a,i1,a,i4.4,a,i4.4,a,a)') trim(prefix)//
'-',nam%mpicom,
'_',mpl%nproc,
'-',mpl%myproc, &
103 &
'_',trim(bpar%blockname(ib))
108 nicas%allocated = .true.
119 class(nicas_type),
intent(inout) :: nicas
120 type(nam_type),
intent(in) :: nam
121 type(geom_type),
intent(in) :: geom
122 type(bpar_type),
intent(in) :: bpar
128 if (
allocated(nicas%blk))
then 130 call nicas%blk(ib)%dealloc(nam,geom)
132 deallocate(nicas%blk)
136 nicas%allocated = .false.
144 subroutine nicas_read(nicas,mpl,nam,geom,bpar)
149 class(nicas_type),
intent(inout) :: nicas
150 type(mpl_type),
intent(in) :: mpl
151 type(nam_type),
intent(in) :: nam
152 type(geom_type),
intent(in) :: geom
153 type(bpar_type),
intent(in) :: bpar
156 integer :: ib,il0i,il1,its,il0
157 integer :: info,nl0_test,nc0a_test
158 integer :: ncid,nl0_id,nc0a_id,nc1b_id,nl1_id,nsa_id,nsb_id,nc0d_id,nc0dinv_id
159 integer :: sb_to_c1b_id,sb_to_l1_id
160 integer :: sa_to_sc_id,sb_to_sc_id
161 integer :: norm_id,coef_ens_id
162 character(len=1024) :: filename
163 character(len=1024) :: subr =
'nicas_read' 166 call nicas%alloc(mpl,nam,bpar,
'nicas')
169 if (bpar%B_block(ib))
then 171 filename = trim(nam%prefix)//
'_'//trim(nicas%blk(ib)%name)//
'.nc' 172 call mpl%ncerr(subr,nf90_open(trim(nam%datadir)//
'/'//trim(filename),nf90_nowrite,ncid))
175 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'nl0',nl0_id))
176 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nl0_id,len=nl0_test))
177 if (nl0_test/=geom%nl0)
call mpl%abort(
'wrong dimension when reading nicas')
178 if (bpar%nicas_block(ib))
then 179 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'nc0a',nc0a_id))
180 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nc0a_id,len=nc0a_test))
181 if (nc0a_test/=geom%nc0a)
call mpl%abort(
'wrong dimension when reading nicas')
182 info = nf90_inq_dimid(ncid,
'nc1b',nc1b_id)
183 if (info==nf90_noerr)
then 184 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nc1b_id,len=nicas%blk(ib)%nc1b))
186 nicas%blk(ib)%nc1b = 0
188 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'nl1',nl1_id))
189 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nl1_id,len=nicas%blk(ib)%nl1))
190 info = nf90_inq_dimid(ncid,
'nsa',nsa_id)
191 if (info==nf90_noerr)
then 192 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nsa_id,len=nicas%blk(ib)%nsa))
194 nicas%blk(ib)%nsa = 0
196 info = nf90_inq_dimid(ncid,
'nsb',nsb_id)
197 if (info==nf90_noerr)
then 198 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nsb_id,len=nicas%blk(ib)%nsb))
200 nicas%blk(ib)%nsb = 0
202 call mpl%ncerr(subr,nf90_get_att(ncid,nf90_global,
'nsc',nicas%blk(ib)%nsc))
204 if ((ib==bpar%nbe).and.(abs(nam%advmode)==1))
then 205 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'nc0d',nc0d_id))
206 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nc0d_id,len=nicas%blk(ib)%nc0d))
207 call mpl%ncerr(subr,nf90_inq_dimid(ncid,
'nc0dinv',nc0dinv_id))
208 call mpl%ncerr(subr,nf90_inquire_dimension(ncid,nc0dinv_id,len=nicas%blk(ib)%nc0dinv))
212 if (bpar%nicas_block(ib))
then 213 if (nicas%blk(ib)%nsb>0)
allocate(nicas%blk(ib)%sb_to_c1b(nicas%blk(ib)%nsb))
214 if (nicas%blk(ib)%nsb>0)
allocate(nicas%blk(ib)%sb_to_l1(nicas%blk(ib)%nsb))
215 if (nicas%blk(ib)%nsa>0)
allocate(nicas%blk(ib)%sa_to_sc(nicas%blk(ib)%nsa))
216 if (nicas%blk(ib)%nsb>0)
allocate(nicas%blk(ib)%sb_to_sc(nicas%blk(ib)%nsb))
217 allocate(nicas%blk(ib)%norm(geom%nc0a,geom%nl0))
218 allocate(nicas%blk(ib)%coef_ens(geom%nc0a,geom%nl0))
219 allocate(nicas%blk(ib)%h(geom%nl0i))
220 allocate(nicas%blk(ib)%s(nicas%blk(ib)%nl1))
222 if ((ib==bpar%nbe).and.(abs(nam%advmode)==1))
then 223 allocate(nicas%blk(ib)%d(geom%nl0,2:nam%nts))
224 allocate(nicas%blk(ib)%dinv(geom%nl0,2:nam%nts))
228 if (bpar%nicas_block(ib))
then 229 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_inq_varid(ncid,
'sb_to_c1b',sb_to_c1b_id))
230 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_inq_varid(ncid,
'sb_to_l1',sb_to_l1_id))
231 if (nicas%blk(ib)%nsa>0)
call mpl%ncerr(subr,nf90_inq_varid(ncid,
'sa_to_sc',sa_to_sc_id))
232 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_inq_varid(ncid,
'sb_to_sc',sb_to_sc_id))
233 call mpl%ncerr(subr,nf90_inq_varid(ncid,
'norm',norm_id))
234 call mpl%ncerr(subr,nf90_inq_varid(ncid,
'coef_ens',coef_ens_id))
238 if (bpar%nicas_block(ib))
then 239 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_get_var(ncid,sb_to_c1b_id,nicas%blk(ib)%sb_to_c1b))
240 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_get_var(ncid,sb_to_l1_id,nicas%blk(ib)%sb_to_l1))
241 if (nicas%blk(ib)%nsa>0)
call mpl%ncerr(subr,nf90_get_var(ncid,sa_to_sc_id,nicas%blk(ib)%sa_to_sc))
242 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_get_var(ncid,sb_to_sc_id,nicas%blk(ib)%sb_to_sc))
243 call mpl%ncerr(subr,nf90_get_var(ncid,norm_id,nicas%blk(ib)%norm))
244 call mpl%ncerr(subr,nf90_get_var(ncid,coef_ens_id,nicas%blk(ib)%coef_ens))
245 call nicas%blk(ib)%com_AB%read(mpl,ncid,
'com_AB')
246 call nicas%blk(ib)%com_AC%read(mpl,ncid,
'com_AC')
247 nicas%blk(ib)%c%prefix =
'c' 248 call nicas%blk(ib)%c%read(mpl,ncid)
250 write(nicas%blk(ib)%h(il0i)%prefix,
'(a,i3.3)')
'h_',il0i
251 call nicas%blk(ib)%h(il0i)%read(mpl,ncid)
253 nicas%blk(ib)%v%prefix =
'v' 254 call nicas%blk(ib)%v%read(mpl,ncid)
255 do il1=1,nicas%blk(ib)%nl1
256 write(nicas%blk(ib)%s(il1)%prefix,
'(a,i3.3)')
's_',il1
257 call nicas%blk(ib)%s(il1)%read(mpl,ncid)
260 if ((ib==bpar%nbe).and.(abs(nam%advmode)==1))
then 261 call nicas%blk(ib)%com_AD%read(mpl,ncid,
'com_AD')
262 call nicas%blk(ib)%com_ADinv%read(mpl,ncid,
'com_ADinv')
265 write(nicas%blk(ib)%d(il0,its)%prefix,
'(a,i3.3,a,i2.2)')
'd_',il0,
'_',its
266 call nicas%blk(ib)%d(il0,its)%read(mpl,ncid)
267 write(nicas%blk(ib)%dinv(il0,its)%prefix,
'(a,i3.3,a,i2.2)')
'dinv_',il0,
'_',its
268 call nicas%blk(ib)%dinv(il0,its)%read(mpl,ncid)
274 call mpl%ncerr(subr,nf90_get_att(ncid,nf90_global,
'wgt',nicas%blk(ib)%wgt))
277 call mpl%ncerr(subr,nf90_close(ncid))
292 class(nicas_type),
intent(in) :: nicas
293 type(mpl_type),
intent(in) :: mpl
294 type(nam_type),
intent(in) :: nam
295 type(geom_type),
intent(in) :: geom
296 type(bpar_type),
intent(in) :: bpar
299 integer :: ib,il0i,il1,its,il0
300 integer :: ncid,nl0_id,nc0a_id,nc1b_id,nl1_id,nsa_id,nsb_id,nc0d_id,nc0dinv_id
301 integer :: sb_to_c1b_id,sb_to_l1_id
302 integer :: sa_to_sc_id,sb_to_sc_id
303 integer :: norm_id,coef_ens_id
304 character(len=1024) :: filename
305 character(len=1024) :: subr =
'nicas_write' 308 if (bpar%B_block(ib))
then 310 filename = trim(nam%prefix)//
'_'//trim(nicas%blk(ib)%name)//
'.nc' 311 call mpl%ncerr(subr,nf90_create(trim(nam%datadir)//
'/'//trim(filename),or(nf90_clobber,nf90_64bit_offset),ncid))
314 call nam%ncwrite(mpl,ncid)
317 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nl0',geom%nl0,nl0_id))
318 if (bpar%nicas_block(ib))
then 319 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nc0a',geom%nc0a,nc0a_id))
320 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'nl0i',geom%nl0i))
321 if (nicas%blk(ib)%nc1b>0)
call mpl%ncerr(subr,nf90_def_dim(ncid,
'nc1b',nicas%blk(ib)%nc1b,nc1b_id))
322 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nl1',nicas%blk(ib)%nl1,nl1_id))
323 if (nicas%blk(ib)%nsa>0)
call mpl%ncerr(subr,nf90_def_dim(ncid,
'nsa',nicas%blk(ib)%nsa,nsa_id))
324 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_def_dim(ncid,
'nsb',nicas%blk(ib)%nsb,nsb_id))
325 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'nsc',nicas%blk(ib)%nsc))
327 if ((ib==bpar%nbe).and.nam%displ_diag)
then 328 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nc0d',nicas%blk(ib)%nc0d,nc0d_id))
329 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nc0dinv',nicas%blk(ib)%nc0dinv,nc0dinv_id))
333 call mpl%ncerr(subr,nf90_put_att(ncid,nf90_global,
'wgt',nicas%blk(ib)%wgt))
336 if (bpar%nicas_block(ib))
then 337 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_def_var(ncid,
'sb_to_c1b',nf90_int,(/nsb_id/),sb_to_c1b_id))
338 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_def_var(ncid,
'sb_to_l1',nf90_int,(/nsb_id/),sb_to_l1_id))
339 if (nicas%blk(ib)%nsa>0)
call mpl%ncerr(subr,nf90_def_var(ncid,
'sa_to_sc',nf90_int,(/nsa_id/),sa_to_sc_id))
340 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_def_var(ncid,
'sb_to_sc',nf90_int,(/nsb_id/),sb_to_sc_id))
341 call mpl%ncerr(subr,nf90_def_var(ncid,
'norm',
ncfloat,(/nc0a_id,nl0_id/),norm_id))
342 call mpl%ncerr(subr,nf90_def_var(ncid,
'coef_ens',
ncfloat,(/nc0a_id,nl0_id/),coef_ens_id))
344 if (nicas%blk(ib)%nsa>0)
call mpl%ncerr(subr,nf90_put_att(ncid,sa_to_sc_id,
'_FillValue',
msvali))
345 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_put_att(ncid,sb_to_sc_id,
'_FillValue',
msvali))
346 call mpl%ncerr(subr,nf90_put_att(ncid,norm_id,
'_FillValue',
msvalr))
347 call mpl%ncerr(subr,nf90_put_att(ncid,coef_ens_id,
'_FillValue',
msvalr))
351 call mpl%ncerr(subr,nf90_enddef(ncid))
354 if (bpar%nicas_block(ib))
then 355 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_put_var(ncid,sb_to_c1b_id,nicas%blk(ib)%sb_to_c1b))
356 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_put_var(ncid,sb_to_l1_id,nicas%blk(ib)%sb_to_l1))
357 if (nicas%blk(ib)%nsa>0)
call mpl%ncerr(subr,nf90_put_var(ncid,sa_to_sc_id,nicas%blk(ib)%sa_to_sc))
358 if (nicas%blk(ib)%nsb>0)
call mpl%ncerr(subr,nf90_put_var(ncid,sb_to_sc_id,nicas%blk(ib)%sb_to_sc))
359 call mpl%ncerr(subr,nf90_put_var(ncid,norm_id,nicas%blk(ib)%norm))
360 call mpl%ncerr(subr,nf90_put_var(ncid,coef_ens_id,nicas%blk(ib)%coef_ens))
361 call nicas%blk(ib)%com_AB%write(mpl,ncid)
362 call nicas%blk(ib)%com_AC%write(mpl,ncid)
363 call nicas%blk(ib)%c%write(mpl,ncid)
365 call nicas%blk(ib)%h(il0i)%write(mpl,ncid)
367 call nicas%blk(ib)%v%write(mpl,ncid)
368 do il1=1,nicas%blk(ib)%nl1
369 call nicas%blk(ib)%s(il1)%write(mpl,ncid)
372 if ((ib==bpar%nbe).and.nam%displ_diag)
then 373 call nicas%blk(ib)%com_AD%write(mpl,ncid)
374 call nicas%blk(ib)%com_ADinv%write(mpl,ncid)
377 call nicas%blk(ib)%d(il0,its)%write(mpl,ncid)
378 call nicas%blk(ib)%dinv(il0,its)%write(mpl,ncid)
384 call mpl%ncerr(subr,nf90_close(ncid))
399 class(nicas_type),
intent(in) :: nicas
400 type(mpl_type),
intent(in) :: mpl
401 type(nam_type),
intent(in) :: nam
402 type(geom_type),
intent(in) :: geom
403 type(bpar_type),
intent(in) :: bpar
406 integer :: ib,is,ic1,il1
407 integer :: ncid,nc0_id,nc1_id,nl1_id
408 integer :: lon_id,lat_id,c0_to_proc_id,c1_to_c0_id,l1_to_l0_id,lcheck_id
409 real(kind_real),
allocatable :: lcheck(:,:)
410 character(len=1024) :: filename
411 character(len=1024) :: subr =
'nicas_write_mpi_summary' 414 if (bpar%nicas_block(ib))
then 416 allocate(lcheck(nicas%blk(ib)%nc1,nicas%blk(ib)%nl1))
419 filename = trim(nam%prefix)//
'_'//trim(nicas%blk(ib)%name)//
'_summary.nc' 420 call mpl%ncerr(subr,nf90_create(trim(nam%datadir)//
'/'//trim(filename),or(nf90_clobber,nf90_64bit_offset),ncid))
423 call nam%ncwrite(mpl,ncid)
426 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nc0',geom%nc0,nc0_id))
427 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nc1',nicas%blk(ib)%nc1,nc1_id))
428 call mpl%ncerr(subr,nf90_def_dim(ncid,
'nl1',nicas%blk(ib)%nl1,nl1_id))
431 call mpl%ncerr(subr,nf90_def_var(ncid,
'lon',
ncfloat,(/nc0_id/),lon_id))
432 call mpl%ncerr(subr,nf90_def_var(ncid,
'lat',
ncfloat,(/nc0_id/),lat_id))
433 call mpl%ncerr(subr,nf90_def_var(ncid,
'c0_to_proc',nf90_int,(/nc0_id/),c0_to_proc_id))
434 call mpl%ncerr(subr,nf90_def_var(ncid,
'c1_to_c0',nf90_int,(/nc1_id/),c1_to_c0_id))
435 call mpl%ncerr(subr,nf90_def_var(ncid,
'l1_to_l0',nf90_int,(/nl1_id/),l1_to_l0_id))
436 call mpl%ncerr(subr,nf90_def_var(ncid,
'lcheck',
ncfloat,(/nc1_id,nl1_id/),lcheck_id))
439 call mpl%ncerr(subr,nf90_enddef(ncid))
442 call mpl%ncerr(subr,nf90_put_var(ncid,lon_id,geom%lon*
rad2deg))
443 call mpl%ncerr(subr,nf90_put_var(ncid,lat_id,geom%lat*
rad2deg))
444 call mpl%ncerr(subr,nf90_put_var(ncid,c0_to_proc_id,geom%c0_to_proc))
445 call mpl%ncerr(subr,nf90_put_var(ncid,c1_to_c0_id,nicas%blk(ib)%c1_to_c0))
446 call mpl%ncerr(subr,nf90_put_var(ncid,l1_to_l0_id,nicas%blk(ib)%l1_to_l0))
448 do is=1,nicas%blk(ib)%ns
449 ic1 = nicas%blk(ib)%s_to_c1(is)
450 il1 = nicas%blk(ib)%s_to_l1(is)
451 if (nicas%blk(ib)%lcheck_sa(is))
then 452 lcheck(ic1,il1) = 1.0
453 elseif (nicas%blk(ib)%lcheck_sb(is))
then 454 lcheck(ic1,il1) = 2.0
455 elseif (nicas%blk(ib)%lcheck_sc(is))
then 456 lcheck(ic1,il1) = 3.0
458 lcheck(ic1,il1) = 4.0
461 call mpl%ncerr(subr,nf90_put_var(ncid,lcheck_id,lcheck))
464 call mpl%ncerr(subr,nf90_close(ncid))
482 class(nicas_type),
intent(inout) :: nicas
483 type(mpl_type),
intent(inout) :: mpl
484 type(rng_type),
intent(inout) :: rng
485 type(nam_type),
intent(inout) :: nam
486 type(geom_type),
intent(inout) :: geom
487 type(bpar_type),
intent(in) :: bpar
488 type(cmat_type),
intent(in) :: cmat
494 call nicas%alloc(mpl,nam,bpar,
'nicas')
497 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 498 write(mpl%info,
'(a)')
'--- Compute NICAS parameters' 502 if (bpar%nicas_block(ib).or.((ib==bpar%nbe).and.nam%displ_diag))
then 503 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 504 write(mpl%info,
'(a)')
'--- Block: '//trim(bpar%blockname(ib))
509 if (bpar%nicas_block(ib))
call nicas%blk(ib)%compute_parameters(mpl,rng,nam,geom,cmat%blk(ib))
512 if ((ib==bpar%nbe).and.nam%displ_diag)
call nicas%blk(ib)%compute_adv(mpl,rng,nam,geom,cmat%blk(ib))
515 if (bpar%B_block(ib))
then 517 nicas%blk(ib)%wgt = cmat%blk(ib)%wgt
518 if (bpar%nicas_block(ib))
then 519 allocate(nicas%blk(ib)%coef_ens(geom%nc0a,geom%nl0))
520 nicas%blk(ib)%coef_ens = cmat%blk(ib)%coef_ens
526 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 527 write(mpl%info,
'(a)')
'--- Write NICAS parameters' 529 call nicas%write(mpl,nam,geom,bpar)
532 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 533 write(mpl%info,
'(a)')
'--- Write NICAS MPI summary' 535 call nicas%write_mpi_summary(mpl,nam,geom,bpar)
548 class(nicas_type),
intent(inout) :: nicas
549 type(mpl_type),
intent(inout) :: mpl
550 type(rng_type),
intent(inout) :: rng
551 type(nam_type),
intent(inout) :: nam
552 type(geom_type),
intent(inout) :: geom
553 type(bpar_type),
intent(in) :: bpar
554 type(io_type),
intent(in) :: io
555 type(cmat_type),
intent(in) :: cmat
556 type(ens_type),
intent(in) :: ens
561 if (nam%check_adjoints)
then 563 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 564 write(mpl%info,
'(a)')
'--- Test NICAS adjoint' 568 if (bpar%nicas_block(ib))
then 569 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 570 write(mpl%info,
'(a)')
'--- Block: '//trim(bpar%blockname(ib))
572 call nicas%blk(ib)%test_adjoint(mpl,rng,nam,geom)
577 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 578 write(mpl%info,
'(a)')
'--- Test NICAS adjoint' 580 call nicas%test_adjoint(mpl,rng,nam,geom,bpar,ens)
583 if (nam%check_pos_def)
then 585 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 586 write(mpl%info,
'(a)')
'--- Test NICAS positive definiteness' 590 if (bpar%nicas_block(ib))
then 591 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 592 write(mpl%info,
'(a)')
'--- Block: '//trim(bpar%blockname(ib))
594 call nicas%blk(ib)%test_pos_def(mpl,rng,nam,geom)
599 if (nam%check_sqrt)
then 601 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 602 write(mpl%info,
'(a)')
'--- Test NICAS full/square-root equivalence' 606 if (bpar%nicas_block(ib))
then 607 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 608 write(mpl%info,
'(a)')
'--- Block: '//trim(bpar%blockname(ib))
610 call nicas%blk(ib)%test_sqrt(mpl,rng,nam,geom,bpar,io,cmat%blk(ib))
615 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 616 write(mpl%info,
'(a)')
'--- Test NICAS full/square-root equivalence' 618 call nicas%test_sqrt(mpl,rng,nam,geom,bpar,io,cmat,ens)
621 if (nam%check_dirac)
then 623 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 624 write(mpl%info,
'(a)')
'--- Apply NICAS to diracs' 628 if (bpar%nicas_block(ib))
then 629 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 630 write(mpl%info,
'(a)')
'--- Block: '//trim(bpar%blockname(ib))
632 call nicas%blk(ib)%test_dirac(mpl,nam,geom,bpar,io)
637 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 638 write(mpl%info,
'(a)')
'--- Apply NICAS to diracs' 640 call nicas%test_dirac(mpl,nam,geom,bpar,io,ens)
643 if (nam%check_randomization)
then 645 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 646 write(mpl%info,
'(a)')
'--- Test NICAS randomization' 648 call nicas%test_randomization(mpl,rng,nam,geom,bpar,io)
651 if (nam%check_consistency)
then 653 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 654 write(mpl%info,
'(a)')
'--- Test HDIAG-NICAS consistency' 656 call nicas%test_consistency(mpl,rng,nam,geom,bpar,io,cmat)
659 if (nam%check_optimality)
then 661 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 662 write(mpl%info,
'(a)')
'--- Test HDIAG optimality' 664 call nicas%test_optimality(mpl,rng,nam,geom,bpar,io)
678 class(nicas_type),
intent(in) :: nicas
679 type(bpar_type),
intent(in) :: bpar
680 type(cv_type),
intent(inout) :: cv
681 logical,
intent(in),
optional :: getsizeonly
685 logical :: lgetsizeonly
688 lgetsizeonly = .false.
689 if (
present(getsizeonly)) lgetsizeonly = getsizeonly
692 allocate(cv%blk(bpar%nbe))
699 if (bpar%cv_block(ib))
then 701 cv%blk(ib)%n = nicas%blk(ib)%nsa
704 cv%n = cv%n+nicas%blk(ib)%nsa
706 if (.not.lgetsizeonly)
then 708 allocate(cv%blk(ib)%alpha(cv%blk(ib)%n))
711 call msr(cv%blk(ib)%alpha)
730 class(nicas_type),
intent(in) :: nicas
731 type(rng_type),
intent(inout) :: rng
732 type(bpar_type),
intent(in) :: bpar
733 type(cv_type),
intent(out) :: cv
739 call nicas%alloc_cv(bpar,cv)
743 if (bpar%cv_block(ib))
call rng%rand_gau(cv%blk(ib)%alpha)
752 subroutine nicas_apply(nicas,mpl,nam,geom,bpar,fld)
757 class(nicas_type),
intent(in) :: nicas
758 type(mpl_type),
intent(in) :: mpl
759 type(nam_type),
target,
intent(in) :: nam
760 type(geom_type),
target,
intent(in) :: geom
761 type(bpar_type),
target,
intent(in) :: bpar
762 real(kind_real),
intent(inout) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts)
765 integer :: ib,its,iv,jv,il0,ic0a
766 real(kind_real) :: prod,prod_tot
767 real(kind_real),
allocatable :: fld_3d(:,:),fld_4d(:,:,:),fld_4d_tmp(:,:,:)
768 real(kind_real),
allocatable :: wgt(:,:),wgt_diag(:)
769 real(kind_real),
allocatable :: fld_save(:,:,:,:)
773 allocate(fld_save(geom%nc0a,geom%nl0,nam%nv,nam%nts))
778 if (nam%advmode==1)
call nicas%blk(bpar%nbe)%apply_adv_ad(mpl,nam,geom,fld)
780 select case (nam%strategy)
783 allocate(fld_3d(geom%nc0a,geom%nl0))
792 fld_3d(ic0a,il0) = fld_3d(ic0a,il0)+fld(ic0a,il0,iv,its)
803 if (geom%mask_c0a(ic0a,il0)) fld_3d(ic0a,il0) = fld_3d(ic0a,il0)*sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
809 call nicas%blk(bpar%nbe)%apply(mpl,nam,geom,fld_3d)
815 if (geom%mask_c0a(ic0a,il0)) fld_3d(ic0a,il0) = fld_3d(ic0a,il0)*sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
826 fld(ic0a,il0,iv,its) = fld_3d(ic0a,il0)
832 case (
'common_univariate')
834 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
839 fld_4d = fld_4d+fld(:,:,:,its)
847 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
848 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
854 call nicas%blk(bpar%nbe)%apply(mpl,nam,geom,fld_4d(:,:,iv))
860 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
861 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
869 fld(:,:,:,its) = fld_4d
871 case (
'common_weighted')
873 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
874 allocate(fld_4d_tmp(geom%nc0a,geom%nl0,nam%nv))
875 allocate(wgt(nam%nv,nam%nv))
876 allocate(wgt_diag(nam%nv))
880 if (bpar%B_block(ib))
then 882 iv = bpar%b_to_v1(ib)
883 jv = bpar%b_to_v2(ib)
884 if (
isnotmsr(nicas%blk(ib)%wgt))
then 885 wgt(iv,jv) = nicas%blk(ib)%wgt
889 if (iv==jv) wgt_diag(iv) = wgt(iv,iv)
896 wgt(iv,jv) = wgt(iv,jv)/sqrt(wgt_diag(iv)*wgt_diag(jv))
903 fld_4d = fld_4d+fld(:,:,:,its)
911 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
912 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
918 call nicas%blk(bpar%nbe)%apply(mpl,nam,geom,fld_4d(:,:,iv))
924 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
925 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
935 fld_4d_tmp(:,:,iv) = fld_4d_tmp(:,:,iv)+wgt(iv,jv)*fld_4d(:,:,jv)
941 fld(:,:,:,its) = fld_4d_tmp
943 case (
'specific_univariate')
945 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
950 fld_4d = fld_4d+fld(:,:,:,its)
954 if (bpar%nicas_block(ib))
then 956 iv = bpar%b_to_v1(ib)
962 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
963 & *sqrt(nicas%blk(ib)%coef_ens(ic0a,il0))
969 call nicas%blk(ib)%apply(mpl,nam,geom,fld_4d(:,:,iv))
975 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
976 & *sqrt(nicas%blk(ib)%coef_ens(ic0a,il0))
985 fld(:,:,:,its) = fld_4d
987 case (
'specific_multivariate')
988 call mpl%abort(
'specific multivariate strategy should not be called from apply_NICAS (lsqrt required)')
993 prod = sum(fld_save*fld)
994 call mpl%f_comm%allreduce(prod,prod_tot,fckit_mpi_sum())
995 if (prod_tot<0.0)
call mpl%abort(
'negative result in nicas_apply')
999 if (nam%advmode==1)
call nicas%blk(bpar%nbe)%apply_adv(mpl,nam,geom,fld)
1012 class(nicas_type),
intent(in) :: nicas
1013 type(mpl_type),
intent(in) :: mpl
1014 type(nam_type),
target,
intent(in) :: nam
1015 type(geom_type),
target,
intent(in) :: geom
1016 type(bpar_type),
target,
intent(in) :: bpar
1017 real(kind_real),
intent(inout) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1020 real(kind_real) :: prod,prod_tot
1021 real(kind_real),
allocatable :: fld_save(:,:,:,:)
1026 allocate(fld_save(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1031 call nicas%apply_sqrt_ad(mpl,nam,geom,bpar,fld,cv)
1034 call nicas%apply_sqrt(mpl,nam,geom,bpar,cv,fld)
1038 prod = sum(fld_save*fld)
1039 call mpl%f_comm%allreduce(prod,prod_tot,fckit_mpi_sum())
1040 if (prod_tot<0.0)
call mpl%abort(
'negative result in nicas_apply')
1054 class(nicas_type),
intent(in) :: nicas
1055 type(mpl_type),
intent(in) :: mpl
1056 type(nam_type),
target,
intent(in) :: nam
1057 type(geom_type),
target,
intent(in) :: geom
1058 type(bpar_type),
target,
intent(in) :: bpar
1059 type(cv_type),
intent(in) :: cv
1060 real(kind_real),
intent(out) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1063 integer :: ib,its,iv,jv,ic0a,il0
1064 real(kind_real),
allocatable :: fld_3d(:,:),fld_4d(:,:,:),fld_4d_tmp(:,:,:)
1065 real(kind_real),
allocatable :: wgt(:,:),wgt_diag(:),wgt_u(:,:)
1067 select case (nam%strategy)
1070 allocate(fld_3d(geom%nc0a,geom%nl0))
1073 call nicas%blk(bpar%nbe)%apply_sqrt(mpl,geom,cv%blk(bpar%nbe)%alpha,fld_3d)
1079 if (geom%mask_c0a(ic0a,il0)) fld_3d(ic0a,il0) = fld_3d(ic0a,il0)*sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
1087 fld(:,:,iv,its) = fld_3d
1090 case (
'common_univariate')
1092 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1095 if (bpar%cv_block(ib))
then 1097 iv = bpar%b_to_v1(ib)
1100 call nicas%blk(bpar%nbe)%apply_sqrt(mpl,geom,cv%blk(ib)%alpha,fld_4d(:,:,iv))
1106 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
1107 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
1116 fld(:,:,:,its) = fld_4d
1118 case (
'common_weighted')
1120 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1121 allocate(fld_4d_tmp(geom%nc0a,geom%nl0,nam%nv))
1122 allocate(wgt(nam%nv,nam%nv))
1123 allocate(wgt_diag(nam%nv))
1124 allocate(wgt_u(nam%nv,nam%nv))
1128 if (bpar%B_block(ib))
then 1130 iv = bpar%b_to_v1(ib)
1131 jv = bpar%b_to_v2(ib)
1132 if (
isnotmsr(nicas%blk(ib)%wgt))
then 1133 wgt(iv,jv) = nicas%blk(ib)%wgt
1137 if (iv==jv) wgt_diag(iv) = wgt(iv,iv)
1144 wgt(iv,jv) = wgt(iv,jv)/sqrt(wgt_diag(iv)*wgt_diag(jv))
1149 call cholesky(mpl,nam%nv,wgt,wgt_u)
1152 if (bpar%cv_block(ib))
then 1154 iv = bpar%b_to_v1(ib)
1157 call nicas%blk(bpar%nbe)%apply_sqrt(mpl,geom,cv%blk(ib)%alpha,fld_4d(:,:,iv))
1163 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
1164 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
1175 fld_4d_tmp(:,:,iv) = fld_4d_tmp(:,:,iv)+wgt_u(iv,jv)*fld_4d(:,:,jv)
1181 fld(:,:,:,its) = fld_4d_tmp
1183 case (
'specific_univariate')
1185 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1188 if (bpar%nicas_block(ib))
then 1190 iv = bpar%b_to_v1(ib)
1193 call nicas%blk(ib)%apply_sqrt(mpl,geom,cv%blk(ib)%alpha,fld_4d(:,:,iv))
1199 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
1200 & *sqrt(nicas%blk(ib)%coef_ens(ic0a,il0))
1209 fld(:,:,:,its) = fld_4d
1211 case (
'specific_multivariate')
1213 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1216 if (bpar%nicas_block(ib))
then 1218 iv = bpar%b_to_v1(ib)
1221 call nicas%blk(ib)%apply_sqrt(mpl,geom,cv%blk(bpar%nbe)%alpha,fld_4d(:,:,iv))
1227 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
1228 & *sqrt(nicas%blk(ib)%coef_ens(ic0a,il0))
1237 fld(:,:,:,its) = fld_4d
1242 if (nam%advmode==1)
call nicas%blk(bpar%nbe)%apply_adv(mpl,nam,geom,fld)
1255 class(nicas_type),
intent(in) :: nicas
1256 type(mpl_type),
intent(in) :: mpl
1257 type(nam_type),
target,
intent(in) :: nam
1258 type(geom_type),
target,
intent(in) :: geom
1259 type(bpar_type),
target,
intent(in) :: bpar
1260 real(kind_real),
intent(in) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1261 type(cv_type),
intent(out) :: cv
1264 integer :: ib,its,iv,jv,ic0a,il0
1265 real(kind_real),
allocatable :: fld_3d(:,:),fld_4d(:,:,:),fld_4d_tmp(:,:,:),fld_5d(:,:,:,:)
1266 real(kind_real),
allocatable :: wgt(:,:),wgt_diag(:),wgt_u(:,:)
1267 type(cv_type) :: cv_tmp
1270 allocate(fld_5d(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1271 call nicas%alloc_cv(bpar,cv)
1277 if (nam%advmode==1)
call nicas%blk(bpar%nbe)%apply_adv_ad(mpl,nam,geom,fld_5d)
1279 select case (nam%strategy)
1282 allocate(fld_3d(geom%nc0a,geom%nl0))
1288 fld_3d = fld_3d+fld_5d(:,:,iv,its)
1296 if (geom%mask_c0a(ic0a,il0)) fld_3d(ic0a,il0) = fld_3d(ic0a,il0)*sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
1302 call nicas%blk(bpar%nbe)%apply_sqrt_ad(mpl,geom,fld_3d,cv%blk(bpar%nbe)%alpha)
1303 case (
'common_univariate')
1305 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1310 fld_4d = fld_4d+fld_5d(:,:,:,its)
1314 if (bpar%cv_block(ib))
then 1316 iv = bpar%b_to_v1(ib)
1322 if (geom%mask_c0a(ic0a,il0)) fld_4d_tmp(ic0a,il0,iv) = fld_4d_tmp(ic0a,il0,iv) &
1323 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
1329 call nicas%blk(bpar%nbe)%apply_sqrt_ad(mpl,geom,fld_4d_tmp(:,:,iv),cv%blk(ib)%alpha)
1332 case (
'common_weighted')
1334 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1335 allocate(fld_4d_tmp(geom%nc0a,geom%nl0,nam%nv))
1336 allocate(wgt(nam%nv,nam%nv))
1337 allocate(wgt_diag(nam%nv))
1338 allocate(wgt_u(nam%nv,nam%nv))
1342 if (bpar%B_block(ib))
then 1344 iv = bpar%b_to_v1(ib)
1345 jv = bpar%b_to_v2(ib)
1346 if (
isnotmsr(nicas%blk(ib)%wgt))
then 1347 wgt(iv,jv) = nicas%blk(ib)%wgt
1351 if (iv==jv) wgt_diag(iv) = wgt(iv,iv)
1358 wgt(iv,jv) = wgt(iv,jv)/sqrt(wgt_diag(iv)*wgt_diag(jv))
1363 call cholesky(mpl,nam%nv,wgt,wgt_u)
1368 fld_4d = fld_4d+fld_5d(:,:,:,its)
1375 fld_4d_tmp(:,:,iv) = fld_4d_tmp(:,:,iv)+wgt_u(iv,jv)*fld_4d(:,:,jv)
1380 if (bpar%cv_block(ib))
then 1382 iv = bpar%b_to_v1(ib)
1388 if (geom%mask_c0a(ic0a,il0)) fld_4d_tmp(ic0a,il0,iv) = fld_4d_tmp(ic0a,il0,iv) &
1389 & *sqrt(nicas%blk(bpar%nbe)%coef_ens(ic0a,il0))
1395 call nicas%blk(bpar%nbe)%apply_sqrt_ad(mpl,geom,fld_4d_tmp(:,:,iv),cv%blk(ib)%alpha)
1398 case (
'specific_univariate')
1400 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1405 fld_4d = fld_4d+fld_5d(:,:,:,its)
1409 if (bpar%nicas_block(ib))
then 1411 iv = bpar%b_to_v1(ib)
1417 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
1418 & *sqrt(nicas%blk(ib)%coef_ens(ic0a,il0))
1424 call nicas%blk(ib)%apply_sqrt_ad(mpl,geom,fld_4d(:,:,iv),cv%blk(ib)%alpha)
1427 case (
'specific_multivariate')
1429 allocate(fld_4d(geom%nc0a,geom%nl0,nam%nv))
1430 call nicas%alloc_cv(bpar,cv_tmp)
1433 cv%blk(bpar%nbe)%alpha = 0.0
1438 fld_4d = fld_4d+fld_5d(:,:,:,its)
1442 if (bpar%nicas_block(ib))
then 1444 iv = bpar%b_to_v1(ib)
1450 if (geom%mask_c0a(ic0a,il0)) fld_4d(ic0a,il0,iv) = fld_4d(ic0a,il0,iv) &
1451 & *sqrt(nicas%blk(ib)%coef_ens(ic0a,il0))
1457 call nicas%blk(ib)%apply_sqrt_ad(mpl,geom,fld_4d(:,:,iv),cv_tmp%blk(bpar%nbe)%alpha)
1460 cv%blk(bpar%nbe)%alpha = cv%blk(bpar%nbe)%alpha+cv_tmp%blk(bpar%nbe)%alpha
1476 class(nicas_type),
intent(in) :: nicas
1477 type(mpl_type),
intent(in) :: mpl
1478 type(rng_type),
intent(inout) :: rng
1479 type(nam_type),
target,
intent(in) :: nam
1480 type(geom_type),
target,
intent(in) :: geom
1481 type(bpar_type),
target,
intent(in) :: bpar
1482 integer,
intent(in) :: ne
1483 type(ens_type),
intent(out) :: ens
1486 integer :: ie,ic0a,il0,its,iv
1487 real(kind_real) :: norm,mean(geom%nc0a,geom%nl0,nam%nv,nam%nts),std(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1488 type(cv_type) :: cv_ens(ne)
1491 call ens%alloc(nam,geom,ne,1)
1495 call nicas%random_cv(rng,bpar,cv_ens(ie))
1498 call nicas%apply_sqrt(mpl,nam,geom,bpar,cv_ens(ie),ens%fld(:,:,:,:,ie))
1502 mean = sum(ens%fld,dim=5)/
real(ne,kind_real)
1504 ens%fld(:,:,:,:,ie) = ens%fld(:,:,:,:,ie)-mean
1508 norm =
real(ne-1,kind_real)
1514 if (geom%mask_c0a(ic0a,il0)) std(ic0a,il0,iv,its) = sqrt(sum(ens%fld(ic0a,il0,iv,its,:)**2)) &
1528 if (geom%mask_c0a(ic0a,il0)) ens%fld(ic0a,il0,iv,its,:) = ens%fld(ic0a,il0,iv,its,:) &
1529 & /std(ic0a,il0,iv,its)
1547 class(nicas_type),
intent(in) :: nicas
1548 type(mpl_type),
intent(in) :: mpl
1549 type(nam_type),
target,
intent(in) :: nam
1550 type(geom_type),
target,
intent(in) :: geom
1551 type(bpar_type),
target,
intent(in) :: bpar
1552 type(ens_type),
intent(in) :: ens
1553 real(kind_real),
intent(inout) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1557 real(kind_real) :: fld_copy(geom%nc0a,geom%nl0,nam%nv,nam%nts),fld_tmp(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1558 real(kind_real) :: pert(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1564 if (nam%advmode==-1)
call nicas%blk(bpar%nbe)%apply_adv_ad(mpl,nam,geom,fld_copy)
1570 pert = ens%fld(:,:,:,:,ie)
1573 if (nam%advmode==-1)
call nicas%blk(bpar%nbe)%apply_adv_inv(mpl,nam,geom,pert)
1576 fld_tmp = pert*fld_copy
1580 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld_tmp)
1582 call nicas%apply(mpl,nam,geom,bpar,fld_tmp)
1586 fld = fld+fld_tmp*pert
1589 fld = fld/
real(nam%ens1_ne-1,kind_real)
1593 if (nam%advmode==-1)
call nicas%blk(bpar%nbe)%apply_adv(mpl,nam,geom,fld)
1606 class(nicas_type),
intent(in) :: nicas
1607 type(mpl_type),
intent(in) :: mpl
1608 type(nam_type),
target,
intent(in) :: nam
1609 type(geom_type),
target,
intent(in) :: geom
1610 type(ens_type),
intent(in) :: ens
1611 real(kind_real),
intent(inout) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1614 integer :: ie,ic0a,il0,iv,its
1615 real(kind_real) :: alpha,norm
1616 real(kind_real) :: fld_copy(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1617 real(kind_real) :: pert(geom%nc0a,geom%nl0,nam%nv,nam%nts)
1618 character(len=1024) :: dum
1625 norm = sqrt(
real(nam%ens1_ne-1,kind_real))
1633 if (geom%mask_c0a(ic0a,il0)) pert(ic0a,il0,iv,its) = ens%fld(ic0a,il0,iv,its,ie)/norm
1641 call mpl%dot_prod(pert,fld_copy,alpha)
1644 fld = fld+alpha*pert
1661 class(nicas_type),
intent(in) :: nicas
1662 type(mpl_type),
intent(in) :: mpl
1663 type(rng_type),
intent(inout) :: rng
1664 type(nam_type),
intent(in) :: nam
1665 type(geom_type),
intent(in) :: geom
1666 type(bpar_type),
intent(in) :: bpar
1667 type(ens_type),
intent(in) :: ens
1670 real(kind_real) :: sum1,sum2
1671 real(kind_real),
allocatable :: fld1_loc(:,:,:,:),fld1_adv(:,:,:,:),fld1_bens(:,:,:,:),fld1_save(:,:,:,:)
1672 real(kind_real),
allocatable :: fld2_loc(:,:,:,:),fld2_adv(:,:,:,:),fld2_bens(:,:,:,:),fld2_save(:,:,:,:)
1675 allocate(fld1_save(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1676 allocate(fld2_save(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1677 allocate(fld1_loc(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1678 allocate(fld2_loc(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1680 allocate(fld1_bens(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1681 allocate(fld2_bens(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1685 call rng%rand_real(0.0_kind_real,1.0_kind_real,fld1_save)
1686 call rng%rand_real(0.0_kind_real,1.0_kind_real,fld2_save)
1689 fld1_loc = fld1_save
1690 fld2_loc = fld2_save
1692 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld1_loc)
1693 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld2_loc)
1695 call nicas%apply(mpl,nam,geom,bpar,fld1_loc)
1696 call nicas%apply(mpl,nam,geom,bpar,fld2_loc)
1698 if (abs(nam%advmode)==1)
then 1699 fld1_adv = fld1_save
1700 fld2_adv = fld2_save
1701 call nicas%blk(bpar%nbe)%apply_adv(mpl,nam,geom,fld1_adv)
1702 call nicas%blk(bpar%nbe)%apply_adv_ad(mpl,nam,geom,fld2_adv)
1705 fld1_bens = fld1_save
1706 fld2_bens = fld2_save
1707 call nicas%apply_bens(mpl,nam,geom,bpar,ens,fld1_bens)
1708 call nicas%apply_bens(mpl,nam,geom,bpar,ens,fld2_bens)
1712 call mpl%dot_prod(fld1_loc,fld2_save,sum1)
1713 call mpl%dot_prod(fld2_loc,fld1_save,sum2)
1714 write(mpl%info,
'(a7,a,e15.8,a,e15.8,a,e15.8)')
'',
'NICAS adjoint test: ', &
1715 & sum1,
' / ',sum2,
' / ',2.0*abs(sum1-sum2)/abs(sum1+sum2)
1716 call flush(mpl%info)
1717 if (abs(nam%advmode)==1)
then 1718 call mpl%dot_prod(fld1_adv,fld2_save,sum1)
1719 call mpl%dot_prod(fld2_adv,fld1_save,sum2)
1720 write(mpl%info,
'(a7,a,e15.8,a,e15.8,a,e15.8)')
'',
'Advection adjoint test: ', &
1721 & sum1,
' / ',sum2,
' / ',2.0*abs(sum1-sum2)/abs(sum1+sum2)
1722 call flush(mpl%info)
1725 call mpl%dot_prod(fld1_bens,fld2_save,sum1)
1726 call mpl%dot_prod(fld2_bens,fld1_save,sum2)
1727 write(mpl%info,
'(a7,a,e15.8,a,e15.8,a,e15.8)')
'',
'Ensemble B adjoint test: ', &
1728 & sum1,
' / ',sum2,
' / ',2.0*abs(sum1-sum2)/abs(sum1+sum2)
1729 call flush(mpl%info)
1743 class(nicas_type),
intent(in) :: nicas
1744 type(mpl_type),
intent(inout) :: mpl
1745 type(rng_type),
intent(inout) :: rng
1746 type(nam_type),
intent(inout),
target :: nam
1747 type(geom_type),
intent(in),
target :: geom
1748 type(bpar_type),
intent(in) :: bpar
1749 type(io_type),
intent(in) :: io
1750 type(cmat_type),
intent(in) :: cmat
1751 type(ens_type),
intent(in) :: ens
1755 real(kind_real),
allocatable :: fld_loc(:,:,:,:),fld_loc_sqrt(:,:,:,:)
1756 real(kind_real),
allocatable :: fld_bens(:,:,:,:),fld_bens_sqrt(:,:,:,:)
1757 character(len=1024) :: varname(nam%nv)
1758 type(nicas_type) :: nicas_other
1761 allocate(fld_loc(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1762 allocate(fld_loc_sqrt(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1764 allocate(fld_bens(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1765 allocate(fld_bens_sqrt(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1769 call rng%rand_real(-1.0_kind_real,1.0_kind_real,fld_loc)
1770 fld_loc_sqrt = fld_loc
1772 call rng%rand_real(-1.0_kind_real,1.0_kind_real,fld_bens)
1773 fld_bens_sqrt = fld_bens
1778 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld_loc_sqrt)
1780 call nicas%apply(mpl,nam,geom,bpar,fld_loc)
1784 call nicas%apply_bens(mpl,nam,geom,bpar,ens,fld_bens_sqrt)
1786 call nicas%apply_bens(mpl,nam,geom,bpar,ens,fld_bens)
1791 nam%lsqrt = .not.nam%lsqrt
1794 call nicas_other%alloc(mpl,nam,bpar,
'nicas_other')
1798 if (bpar%nicas_block(ib))
then 1800 call nicas_other%blk(ib)%compute_parameters(mpl,rng,nam,geom,cmat%blk(ib))
1803 if (bpar%B_block(ib))
then 1805 nicas_other%blk(ib)%wgt = cmat%blk(ib)%wgt
1806 if (bpar%nicas_block(ib))
then 1807 allocate(nicas_other%blk(ib)%coef_ens(geom%nc0a,geom%nl0))
1808 nicas_other%blk(ib)%coef_ens = cmat%blk(ib)%coef_ens
1815 call nicas_other%apply_from_sqrt(mpl,nam,geom,bpar,fld_loc_sqrt)
1817 call nicas_other%apply(mpl,nam,geom,bpar,fld_loc)
1821 call nicas_other%apply_bens(mpl,nam,geom,bpar,ens,fld_bens_sqrt)
1823 call nicas_other%apply_bens(mpl,nam,geom,bpar,ens,fld_bens)
1829 varname(iv) = nam%varname(iv)
1830 nam%varname(iv) = trim(varname(iv))//
'_sqrt' 1832 if (nam%check_dirac)
call nicas_other%test_dirac(mpl,nam,geom,bpar,io,ens)
1834 nam%varname(iv) = varname(iv)
1838 nam%lsqrt = .not.nam%lsqrt
1841 write(mpl%info,
'(a7,a,f6.1,a)')
'',
'NICAS full / square-root error : ', &
1842 & sqrt(sum((fld_loc_sqrt-fld_loc)**2)/sum(fld_loc**2))*100.0,
'%' 1843 if (ens%ne>0)
write(mpl%info,
'(a7,a,f6.1,a)')
'',
'Ensemble B full / square-root error: ', &
1844 & sqrt(sum((fld_bens_sqrt-fld_bens)**2)/sum(fld_bens**2))*100.0,
'%' 1845 call flush(mpl%info)
1858 class(nicas_type),
intent(in) :: nicas
1859 type(mpl_type),
intent(inout) :: mpl
1860 type(nam_type),
intent(in) :: nam
1861 type(geom_type),
intent(in) :: geom
1862 type(bpar_type),
intent(in) :: bpar
1863 type(io_type),
intent(in) :: io
1864 type(ens_type),
intent(in) :: ens
1867 integer :: idir,iv,its
1868 real(kind_real),
allocatable :: fld(:,:,:,:),fld_loc(:,:,:,:),fld_bens(:,:,:,:)
1869 character(len=2) :: itschar
1870 character(len=1024) :: filename
1873 allocate(fld(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1878 if (geom%iprocdir(idir)==mpl%myproc) fld(geom%ic0adir(idir),geom%il0dir(idir),geom%ivdir(idir),geom%itsdir(idir)) = 1.0
1882 allocate(fld_loc(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1883 if (ens%ne>0)
allocate(fld_bens(geom%nc0a,geom%nl0,nam%nv,nam%nts))
1888 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld_loc)
1890 call nicas%apply(mpl,nam,geom,bpar,fld_loc)
1893 if ((ens%ne>0).and.(trim(nam%method)/=
'cor'))
then 1896 call nicas%apply_bens(mpl,nam,geom,bpar,ens,fld_bens)
1900 filename = trim(nam%prefix)//
'_dirac' 1902 write(itschar,
'(i2.2)') its
1904 call io%fld_write(mpl,nam,geom,filename,trim(nam%varname(iv))//
'_'//itschar,fld_loc(:,:,iv,its))
1905 if ((ens%ne>0).and.(trim(nam%method)/=
'cor'))
call io%fld_write(mpl,nam,geom,filename, &
1906 & trim(nam%varname(iv))//
'_'//itschar//
'_Bens',fld_bens(:,:,iv,its))
1921 class(nicas_type),
intent(in) :: nicas
1922 type(mpl_type),
intent(inout) :: mpl
1923 type(rng_type),
intent(inout) :: rng
1924 type(nam_type),
intent(inout) :: nam
1925 type(geom_type),
intent(in) :: geom
1926 type(bpar_type),
intent(in) :: bpar
1927 type(io_type),
intent(in) :: io
1930 integer :: ifac,itest,nefac(nfac),ens1_ne,iv,its
1931 real(kind_real) :: fld_ref(geom%nc0a,geom%nl0,nam%nv,nam%nts,ntest),fld_save(geom%nc0a,geom%nl0,nam%nv,nam%nts,ntest)
1932 real(kind_real) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts),mse(ntest,nfac),mse_th(ntest,nfac)
1933 character(len=2) :: itschar
1934 character(len=4) :: nechar,itestchar
1935 character(len=1024) :: filename
1936 type(ens_type) :: ens
1939 write(mpl%info,
'(a4,a)')
'',
'Define test vectors' 1940 call flush(mpl%info)
1944 write(mpl%info,
'(a4,a)')
'',
'Apply NICAS to test vectors' 1945 call flush(mpl%info)
1948 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld_ref(:,:,:,:,itest))
1952 do itest=1,
min(ntest,10)
1954 write(itestchar,
'(i4.4)') itest
1955 filename = trim(nam%prefix)//
'_randomize_'//itestchar
1957 write(itschar,
'(i2.2)') its
1959 call io%fld_write(mpl,nam,geom,filename,trim(nam%varname(iv))//
'_ref_'//itschar,fld_ref(:,:,iv,its,itest))
1965 ens1_ne = nam%ens1_ne
1967 write(mpl%info,
'(a4,a)')
'',
'Test randomization for various ensemble sizes:' 1968 call flush(mpl%info)
1971 nefac(ifac) =
max(int(5.0*
real(ifac,kind_real)/
real(nfac,kind_real)*
real(ne_rand,kind_real)),3)
1972 nam%ens1_ne = nefac(ifac)
1973 write(nechar,
'(i4.4)') nefac(ifac)
1976 call nicas%randomize(mpl,rng,nam,geom,bpar,nefac(ifac),ens)
1980 fld = fld_save(:,:,:,:,itest)
1981 call nicas%apply_bens_noloc(mpl,nam,geom,ens,fld)
1984 mse(itest,ifac) = sum((fld-fld_ref(:,:,:,:,itest))**2)
1985 mse_th(itest,ifac) = 1.0/
real(nam%ens1_ne-1,kind_real)*sum(1+fld_ref(:,:,:,:,itest)**2)
1988 if (itest<=
min(ntest,10))
then 1990 write(itestchar,
'(i4.4)') itest
1991 filename = trim(nam%prefix)//
'_randomize_'//itestchar
1993 write(itschar,
'(i2.2)') its
1995 call io%fld_write(mpl,nam,geom,filename,trim(nam%varname(iv))//
'_rand_'//nechar//
'_'//itschar,fld(:,:,iv,its))
2002 write(mpl%info,
'(a7,a,i4,a,e15.8,a,e15.8)')
'',
'Ensemble size ',nefac(ifac),
', MSE (exp. / th.): ', &
2003 & sum(mse(:,ifac))/
real(ntest,kind_real),
' / ',sum(mse_th(:,ifac))/
real(ntest,kind_real)
2004 call flush(mpl%info)
2011 nam%ens1_ne = ens1_ne
2024 class(nicas_type),
intent(in) :: nicas
2025 type(mpl_type),
intent(inout) :: mpl
2026 type(rng_type),
intent(inout) :: rng
2027 type(nam_type),
intent(inout) :: nam
2028 type(geom_type),
intent(in) :: geom
2029 type(bpar_type),
intent(in) :: bpar
2030 type(io_type),
intent(in) :: io
2031 type(cmat_type),
intent(in) :: cmat
2034 integer :: ens1_ne,ens1_ne_offset,ens1_nsub,ib,il0
2035 real(kind_real) :: rh_c0_sum,rv_c0_sum,norm
2036 character(len=1024) :: prefix,method
2037 type(cmat_type) :: cmat_test
2038 type(hdiag_type) :: hdiag_test
2039 type(ens_type) :: ens
2042 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 2043 write(mpl%info,
'(a)')
'--- Randomize ensemble' 2044 call flush(mpl%info)
2045 call nicas%randomize(mpl,rng,nam,geom,bpar,
ne_rand,ens)
2048 call execute_command_line(
'cp -f '//trim(nam%datadir)//
'/'//trim(nam%prefix)//
'_sampling.nc ' &
2049 & //trim(nam%datadir)//
'/'//trim(nam%prefix)//
'_consistency-test_sampling.nc')
2054 ens1_ne = nam%ens1_ne
2055 ens1_ne_offset = nam%ens1_ne_offset
2056 ens1_nsub = nam%ens1_nsub
2059 nam%prefix = trim(nam%prefix)//
'_consistency-test' 2062 nam%ens1_ne_offset = 0
2066 call hdiag_test%run_hdiag(mpl,rng,nam,geom,bpar,io,ens)
2069 call cmat_test%from_hdiag(mpl,nam,geom,bpar,hdiag_test)
2072 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 2073 write(mpl%info,
'(a)')
'--- HDIAG/NICAS consistency results' 2075 if (bpar%nicas_block(ib))
then 2076 write(mpl%info,
'(a7,a,a)')
'',
'Block: ',trim(bpar%blockname(ib))
2078 call mpl%f_comm%allreduce(sum(cmat_test%blk(ib)%rh(:,il0)-cmat%blk(ib)%rh(:,il0),geom%mask_c0a(:,il0)), &
2079 & rh_c0_sum,fckit_mpi_sum())
2080 call mpl%f_comm%allreduce(sum(cmat_test%blk(ib)%rv(:,il0)-cmat%blk(ib)%rv(:,il0),geom%mask_c0a(:,il0)),&
2081 & rv_c0_sum,fckit_mpi_sum())
2082 call mpl%f_comm%allreduce(
real(count(geom%mask_c0a(:,il0)),kind_real),norm,fckit_mpi_sum())
2083 write(mpl%info,
'(a10,a7,i3,a4,a25,f6.1,a)')
'',
'Level: ',nam%levs(il0),
' ~> ',
'horizontal length-scale: ', &
2084 & rh_c0_sum/norm*
reqkm,
' km' 2085 if (any(abs(cmat%blk(ib)%rv(:,il0))>0.0))
then 2086 write(mpl%info,
'(a49,f6.1,a)')
'vertical length-scale: ',rh_c0_sum/norm,
' '//trim(mpl%vunitchar)
2091 call flush(mpl%info)
2096 nam%ens1_ne = ens1_ne
2097 nam%ens1_ne_offset = ens1_ne_offset
2098 nam%ens1_nsub = ens1_nsub
2111 class(nicas_type),
intent(in) :: nicas
2112 type(mpl_type),
intent(inout) :: mpl
2113 type(rng_type),
intent(inout) :: rng
2114 type(nam_type),
intent(inout) :: nam
2115 type(geom_type),
intent(in) :: geom
2116 type(bpar_type),
intent(in) :: bpar
2117 type(io_type),
intent(in) :: io
2120 integer :: ib,ifac,itest
2121 real(kind_real) :: fld_ref(geom%nc0a,geom%nl0,nam%nv,nam%nts,ntest),fld_save(geom%nc0a,geom%nl0,nam%nv,nam%nts,ntest)
2122 real(kind_real) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts),fac(nfac),mse(ntest,nfac)
2123 character(len=1024) :: prefix,method
2124 type(cmat_type) :: cmat_save,cmat_test
2125 type(hdiag_type) :: hdiag_save
2126 type(ens_type) :: ens
2127 type(nicas_type) :: nicas_test
2130 write(mpl%info,
'(a4,a)')
'',
'Define test vectors' 2131 call flush(mpl%info)
2135 write(mpl%info,
'(a4,a)')
'',
'Apply NICAS to test vectors' 2136 call flush(mpl%info)
2139 call nicas%apply_from_sqrt(mpl,nam,geom,bpar,fld_ref(:,:,:,:,itest))
2143 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 2144 write(mpl%info,
'(a)')
'--- Randomize ensemble' 2145 call flush(mpl%info)
2146 call nicas%randomize(mpl,rng,nam,geom,bpar,nam%ens1_ne,ens)
2149 call execute_command_line(
'cp -f '//trim(nam%datadir)//
'/'//trim(nam%prefix)//
'_sampling.nc ' &
2150 & //trim(nam%datadir)//
'/'//trim(nam%prefix)//
'_optimality-test_sampling.nc')
2157 nam%prefix = trim(nam%prefix)//
'_optimality-test' 2158 nam%method =
'loc_norm' 2161 call nicas_test%alloc(mpl,nam,bpar,
'nicas_test')
2164 call hdiag_save%run_hdiag(mpl,rng,nam,geom,bpar,io,ens)
2167 call cmat_save%from_hdiag(mpl,nam,geom,bpar,hdiag_save)
2170 cmat_test = cmat_save%copy(nam,geom,bpar)
2174 fac(ifac) = 2.0*
real(ifac,kind_real)/
real(nfac,kind_real)
2176 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 2177 write(mpl%info,
'(a,f4.2,a)')
'--- Apply a multiplicative factor ',fac(ifac),
' to length-scales' 2178 call flush(mpl%info)
2181 if (bpar%nicas_block(ib))
then 2183 cmat_test%blk(ib)%rh = fac(ifac)*cmat_save%blk(ib)%rh
2184 cmat_test%blk(ib)%rv = fac(ifac)*cmat_save%blk(ib)%rv
2185 if (trim(nam%strategy)==
'specific_multivariate')
then 2186 cmat_test%blk(ib)%rhs = fac(ifac)*cmat_save%blk(ib)%rhs
2187 cmat_test%blk(ib)%rvs = fac(ifac)*cmat_save%blk(ib)%rvs
2191 call nicas_test%blk(ib)%compute_parameters(mpl,rng,nam,geom,cmat_test%blk(ib))
2194 if (bpar%B_block(ib))
then 2196 nicas_test%blk(ib)%wgt = cmat_test%blk(ib)%wgt
2197 if (bpar%nicas_block(ib))
then 2198 allocate(nicas_test%blk(ib)%coef_ens(geom%nc0a,geom%nl0))
2199 nicas_test%blk(ib)%coef_ens = cmat_test%blk(ib)%coef_ens
2206 fld = fld_save(:,:,:,:,itest)
2207 call nicas_test%apply_bens(mpl,nam,geom,bpar,ens,fld)
2210 mse(itest,ifac) = sum((fld-fld_ref(:,:,:,:,itest))**2)
2214 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 2215 write(mpl%info,
'(a,f4.2,a,e15.8)')
'--- Optimality results for a factor ',fac(ifac),
', MSE: ', &
2216 & sum(mse(:,ifac))/
real(ntest,kind_real)
2217 call flush(mpl%info)
2221 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 2222 write(mpl%info,
'(a)')
'--- Optimality results summary' 2224 write(mpl%info,
'(a7,a,f4.2,a,e15.8)')
'',
'Factor ',fac(ifac),
', MSE: ',sum(mse(:,ifac))/
real(ntest,kind_real)
2226 call flush(mpl%info)
2241 type(mpl_type),
intent(in) :: mpl
2242 type(rng_type),
intent(inout) :: rng
2243 type(nam_type),
intent(in) :: nam
2244 type(geom_type),
intent(in) :: geom
2245 integer,
intent(in) :: ntest
2246 real(kind_real),
intent(out) :: fld(geom%nc0a,geom%nl0,nam%nv,nam%nts,ntest)
2249 integer :: ic0dir(ntest),il0dir(ntest),ivdir(ntest),itsdir(ntest)
2250 integer :: itest,ic0,iproc,ic0a
2254 call rng%rand_integer(1,geom%nc0,ic0dir)
2255 call rng%rand_integer(1,geom%nl0,il0dir)
2257 call mpl%f_comm%broadcast(ic0dir,mpl%ioproc-1)
2258 call mpl%f_comm%broadcast(il0dir,mpl%ioproc-1)
2264 fld(:,:,:,:,itest) = 0.0
2266 iproc = geom%c0_to_proc(ic0)
2267 if (iproc==mpl%myproc)
then 2268 ic0a = geom%c0_to_c0a(ic0)
2269 fld(ic0a,il0dir(itest),ivdir(itest),itsdir(itest),itest) = 1.0
subroutine nicas_test_dirac(nicas, mpl, nam, geom, bpar, io, ens)
subroutine nicas_alloc_cv(nicas, bpar, cv, getsizeonly)
subroutine nicas_randomize(nicas, mpl, rng, nam, geom, bpar, ne, ens)
logical, parameter pos_def_test
subroutine nicas_read(nicas, mpl, nam, geom, bpar)
subroutine nicas_test_consistency(nicas, mpl, rng, nam, geom, bpar, io, cmat)
subroutine nicas_run_nicas_tests(nicas, mpl, rng, nam, geom, bpar, io, cmat, ens)
subroutine nicas_test_optimality(nicas, mpl, rng, nam, geom, bpar, io)
subroutine nicas_random_cv(nicas, rng, bpar, cv)
subroutine nicas_apply_from_sqrt(nicas, mpl, nam, geom, bpar, fld)
integer, parameter ne_rand
subroutine nicas_write_mpi_summary(nicas, mpl, nam, geom, bpar)
subroutine nicas_apply_sqrt_ad(nicas, mpl, nam, geom, bpar, fld, cv)
subroutine nicas_dealloc(nicas, nam, geom, bpar)
subroutine nicas_write(nicas, mpl, nam, geom, bpar)
subroutine nicas_apply(nicas, mpl, nam, geom, bpar, fld)
subroutine nicas_apply_bens_noloc(nicas, mpl, nam, geom, ens, fld)
subroutine nicas_test_adjoint(nicas, mpl, rng, nam, geom, bpar, ens)
subroutine nicas_alloc(nicas, mpl, nam, bpar, prefix)
subroutine nicas_apply_sqrt(nicas, mpl, nam, geom, bpar, cv, fld)
subroutine nicas_test_sqrt(nicas, mpl, rng, nam, geom, bpar, io, cmat, ens)
subroutine nicas_test_randomization(nicas, mpl, rng, nam, geom, bpar, io)
integer, parameter, public kind_real
subroutine define_test_vectors(mpl, rng, nam, geom, ntest, fld)
subroutine nicas_run_nicas(nicas, mpl, rng, nam, geom, bpar, cmat)
subroutine nicas_apply_bens(nicas, mpl, nam, geom, bpar, ens, fld)
real(fp), parameter, public pi