60 class(hdiag_type),
intent(inout) :: hdiag
61 type(mpl_type),
intent(inout) :: mpl
62 type(rng_type),
intent(inout) :: rng
63 type(nam_type),
intent(inout) :: nam
64 type(geom_type),
intent(in) :: geom
65 type(bpar_type),
intent(in) :: bpar
66 type(io_type),
intent(in) :: io
67 type(ens_type),
intent(in) :: ens1
68 type(ens_type),
intent(in),
optional :: ens2
72 character(len=1024) :: filename
75 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 76 write(mpl%info,
'(a,i5,a)')
'--- Setup sampling (nc1 = ',nam%nc1,
')' 78 call hdiag%samp%setup_sampling(mpl,rng,nam,geom,bpar,io,ens1)
81 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 82 write(mpl%info,
'(a)')
'--- Compute MPI distribution, halos A' 84 call hdiag%samp%compute_mpi_a(mpl,nam,geom)
86 if (nam%new_lct.or.nam%var_diag.or.nam%local_diag.or.nam%displ_diag)
then 88 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 89 write(mpl%info,
'(a)')
'--- Compute MPI distribution, halos A-B' 91 call hdiag%samp%compute_mpi_ab(mpl,nam,geom)
94 if (nam%displ_diag)
then 96 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 97 write(mpl%info,
'(a)')
'--- Compute MPI distribution, halo D' 99 call hdiag%samp%compute_mpi_d(mpl,nam,geom)
102 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 103 write(mpl%info,
'(a)')
'--- Compute displacement diagnostic' 105 call hdiag%displ%compute(mpl,nam,geom,hdiag%samp,ens1)
109 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 110 write(mpl%info,
'(a)')
'--- Compute MPI distribution, halo C' 112 call hdiag%samp%compute_mpi_c(mpl,nam,geom)
114 if ((nam%local_diag.or.nam%displ_diag).and.(nam%diag_rhflt>0.0))
then 116 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 117 write(mpl%info,
'(a)')
'--- Compute MPI distribution, halo F' 119 call hdiag%samp%compute_mpi_f(mpl,nam,geom)
123 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 124 write(mpl%info,
'(a)')
'--- Compute sample moments' 128 write(mpl%info,
'(a7,a)')
'',
'Ensemble 1:' 130 call hdiag%mom_1%compute(mpl,nam,geom,bpar,hdiag%samp,ens1)
132 select case(trim(nam%method))
133 case (
'hyb-rnd',
'dual-ens')
135 write(mpl%info,
'(a7,a)')
'',
'Ensemble 2:' 137 call hdiag%mom_2%compute(mpl,nam,geom,bpar,hdiag%samp,ens2)
141 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 142 write(mpl%info,
'(a)')
'--- Compute statistics' 146 write(mpl%info,
'(a7,a)')
'',
'Ensemble 1:' 148 call hdiag%avg_1%compute(mpl,nam,geom,bpar,hdiag%samp,hdiag%mom_1,nam%ne)
150 select case(trim(nam%method))
151 case (
'hyb-rnd',
'dual-ens')
153 write(mpl%info,
'(a7,a)')
'',
'Ensemble 2:' 155 call hdiag%avg_2%compute(mpl,nam,geom,bpar,hdiag%samp,hdiag%mom_2,nam%ens2_ne)
158 hdiag%avg_2 = hdiag%avg_1%copy(nam,geom,bpar)
161 select case (trim(nam%method))
162 case (
'hyb-avg',
'hyb-rnd',
'dual-ens')
164 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 165 write(mpl%info,
'(a)')
'--- Compute hybrid statistics' 167 call hdiag%avg_2%compute_hyb(mpl,nam,geom,bpar,hdiag%samp,hdiag%mom_1,hdiag%mom_2,hdiag%avg_1)
170 if ((bpar%nbe>bpar%nb).and.bpar%diag_block(bpar%nbe))
then 172 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 173 write(mpl%info,
'(a)')
'--- Compute block-averaged statistics' 175 hdiag%avg_wgt = hdiag%avg_1%copy_wgt(geom,bpar)
176 call hdiag%avg_1%compute_bwavg(mpl,nam,geom,bpar,hdiag%avg_wgt)
177 if ((trim(nam%method)==
'hyb-rnd').or.(trim(nam%method)==
'dual-ens')) &
178 &
call hdiag%avg_2%compute_bwavg(mpl,nam,geom,bpar,hdiag%avg_wgt)
181 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 182 write(mpl%info,
'(a)')
'--- Compute covariance' 186 write(mpl%info,
'(a7,a)')
'',
'Ensemble 1:' 188 call hdiag%cov_1%covariance(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_1,
'cov')
190 select case (trim(nam%method))
191 case (
'hyb-avg',
'hyb-rnd',
'dual-ens')
193 write(mpl%info,
'(a7,a)')
'',
'Ensemble 2:' 195 select case (trim(nam%method))
196 case (
'hyb-avg',
'hyb-rnd')
197 call hdiag%cov_2%covariance(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_2,
'cov_sta')
199 call hdiag%cov_2%covariance(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_2,
'cov_lr')
203 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 204 write(mpl%info,
'(a)')
'--- Compute correlation' 208 write(mpl%info,
'(a7,a)')
'',
'Ensemble 1:' 210 call hdiag%cor_1%correlation(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_1,
'cor')
212 select case (trim(nam%method))
213 case (
'hyb-avg',
'hyb-rnd',
'dual-ens')
215 write(mpl%info,
'(a7,a)')
'',
'Ensemble 2:' 217 select case (trim(nam%method))
218 case (
'hyb-avg',
'hyb-rnd')
219 call hdiag%cor_2%correlation(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_2,
'cor_sta')
221 call hdiag%cor_2%correlation(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_2,
'cor_lr')
225 select case (trim(nam%method))
226 case (
'loc_norm',
'loc',
'hyb-avg',
'hyb-rnd',
'dual-ens')
228 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 229 write(mpl%info,
'(a)')
'--- Compute localization' 230 write(mpl%info,
'(a7,a)')
'',
'Ensemble 1:' 232 call hdiag%loc_1%localization(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_1,
'loc')
235 select case (trim(nam%method))
236 case (
'hyb-avg',
'hyb-rnd')
238 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 239 write(mpl%info,
'(a)')
'--- Compute static hybridization' 240 write(mpl%info,
'(a7,a)')
'',
'Ensemble 1 and 2:' 242 call hdiag%loc_2%hybridization(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_1,hdiag%avg_2,
'loc_hyb')
245 if (trim(nam%method)==
'dual-ens')
then 247 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 248 write(mpl%info,
'(a)')
'--- Compute dual-ensemble hybridization' 249 write(mpl%info,
'(a7,a)')
'',
'Ensembles 1 and 2:' 251 call hdiag%loc_2%dualens(mpl,nam,geom,bpar,io,hdiag%samp,hdiag%avg_1,hdiag%avg_2,hdiag%loc_3,
'loc_deh',
'loc_deh_lr')
255 write(mpl%info,
'(a)')
'-------------------------------------------------------------------' 256 write(mpl%info,
'(a)')
'--- Write data' 260 if (nam%displ_diag)
call hdiag%displ%write(mpl,nam,geom,hdiag%samp,trim(nam%prefix)//
'_displ_diag.nc')
263 if (nam%var_full)
then 264 filename = trim(nam%prefix)//
'_var_full' 266 if (bpar%diag_block(ib))
call io%fld_write(mpl,nam,geom,filename,trim(bpar%blockname(ib))//
'_var', &
267 & sum(hdiag%mom_1%blk(ib)%m2full,dim=3)/
real(hdiag%mom_1%blk(ib)%nsub,kind_real))
subroutine hdiag_run_hdiag(hdiag, mpl, rng, nam, geom, bpar, io, ens1, ens2)
integer, parameter, public kind_real