Repository navigation
Conversation
|
@AndersJensen-NOAA @dustinswales Gentle ping on this PR. It is a prerequisite for ufs-community/MPAS-Model#299 (t=0 reflectivity for MPAS-WoFS/RRFS reflectivity DA). I noticed recent merges are going into |
AndersJensen-NOAA
left a comment
There was a problem hiding this comment.
Thanks for this contribution. I let Claude do the review (Opus 5.5) and it had one main suggestion.
| subroutine tempo_diagnose_refl(tempo_cfgs, th, pii, pres, qv, qc, qr, nr, qs, qg, refl, ng, qb, & | ||
| is_first_step, its, ite, jts, jte, kts, kte) | ||
| !! 10-cm reflectivity from the current hydrometeor state. | ||
| !! Does not update the hydrometeor profiles. | ||
| type(ty_tempo_cfgs), intent(in) :: tempo_cfgs | ||
| integer, intent(in) :: its, ite, jts, jte, kts, kte | ||
| real(wp), dimension(its:ite, kts:kte, jts:jte), intent(in) :: th, pii, pres, qv, qc, qr, nr, qs, qg | ||
| real(wp), dimension(its:ite, kts:kte, jts:jte), intent(out) :: refl | ||
| real(wp), dimension(its:ite, kts:kte, jts:jte), intent(in), optional :: ng, qb |
There was a problem hiding this comment.
I let Claude do the review: here's them main comment:
Array bounds don't match tempo_run. These are declared over the tile range its:ite, kts:kte, jts:jte. tempo_run takes memory bounds (ims:ime, kms:kme, jms:jme) plus tile bounds and loops over the tile. If a host model with halos (WRF, or any host where ims /= its) passes its full arrays, every index shifts silently. It may happen to be fine for the MPAS call, but this is a public API, so it should follow the same convention as tempo_run.
It would also be good to accept either t or th + pii, the way tempo_run does. Rough sketch:
subroutine tempo_diagnose_refl(tempo_cfgs, pres, qv, qc, qr, nr, qs, qg, refl, &
t, th, pii, ng, qb, is_first_step, &
ims, ime, jms, jme, kms, kme, &
its, ite, jts, jte, kts, kte)
!! 10-cm reflectivity [dBZ] diagnosed from the current hydrometeor state.
!! Hydrometeor fields are not modified. Array conventions follow tempo_run.
type(ty_tempo_cfgs), intent(in) :: tempo_cfgs
integer, intent(in) :: ims, ime, jms, jme, kms, kme
integer, intent(in) :: its, ite, jts, jte, kts, kte
real(wp), dimension(ims:ime, kms:kme, jms:jme), intent(in) :: pres, qv, qc, qr, nr, qs, qg
real(wp), dimension(ims:ime, kms:kme, jms:jme), intent(inout) :: refl
real(wp), dimension(ims:ime, kms:kme, jms:jme), intent(in), optional :: t, th, pii, ng, qb
logical, intent(in), optional :: is_first_step
real(wp), dimension(kts:kte) :: t1d, p1d, qv1d, qc1d, qr1d, nr1d, qs1d, qg1d, ng1d, qb1d, dbz
integer :: i, j, k
logical :: hail_aware, use_temperature
if (present(t)) then
use_temperature = .true.
elseif (present(th) .and. present(pii)) then
use_temperature = .false.
else
! error stop "tempo_diagnose_refl() --- requires either t, or th and pii"
endif
hail_aware = present(ng) .and. present(qb)
do j = jts, jte
do i = its, ite
do k = kts, kte
if (use_temperature) then
t1d(k) = t(i,k,j)
else
t1d(k) = th(i,k,j) * pii(i,k,j)
endif
! ... rest unchanged(refl is intent(inout) so that points outside the tile keep their values. With intent(out) they become undefined.) This changes the argument list, so ufs-community/MPAS-Model#299 would need a matching update.
@ywangwof Yes, please change the base to v3.3.0. There shouldn't be any merge conflicts doing so. |
|
One last comment. Can you test compilation with gfortran in full debug. That should catch uninitialized variables and precision issues. |
…n state
- module_mp_tempo_main: add tempo_diagnose_refl_1d, which reproduces the
end-of-step refl10cm diagnostic of tempo_main without applying any
microphysical tendency. It takes cloud water (qc), splits hail from
graupel via compute_hail_fraction when hailhyperaware_flag is set (as
tempo_main does), and optionally applies graupel_init on the first step.
- module_mp_tempo_driver: add the 3D wrapper tempo_diagnose_refl, following
the tempo_run conventions:
* arrays dimensioned with memory bounds (ims:ime, kms:kme, jms:jme);
only the tile (its:ite, kts:kte, jts:jte) is computed,
* refl is intent(inout); points outside the tile are left unchanged,
* temperature from either t, or th and pii (all optional); if neither is
given, errflg=1 / errmsg are returned,
* ng/qb optional (hail-aware).
Tested with gfortran 12.4 full debug (-O0 -fcheck=all
-ffpe-trap=invalid,zero,overflow -finit-real=snan -Wall -Wextra), DP and SP,
no warnings in new code. A standalone driver with halo memory bounds checks
that refl outside the tile is untouched, inputs are unchanged, t and th*pii
give the same result, the missing-temperature error path, and agreement with
tempo_run refl10cm (turn_off_micro_flag, dt=1e-4 s): max |dBZ diff| < 3e-4
with hailhyperaware on/off and with/without graupel_init.
Co-authored-by: chengsiliu <61298443+chengsiliu@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b721655 to
eed2f33
Compare
…-style interface - TEMPO submodule -> ywangwof/TEMPO@eed2f33 (tempo_diagnose_refl on top of NCAR/TEMPO tempo_v3.3.0, see NCAR/TEMPO#72). - init_reflectivity_diagnostic: allocate work arrays with memory bounds (ims:ime,kms:kme,jms:jme) as for tempo_run, pass memory and tile bounds with keyword arguments, and abort via physics_error_fatal on errflg. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks @AndersJensen-NOAA. Changes pushed:
Details are in the updated PR description. |
Description
Adds
tempo_diagnose_refl(3D driver wrapper) andtempo_diagnose_refl_1d(column routine). Together they diagnose 10-cm reflectivity (refl10cm) from a given model state without applying any microphysical tendency.Motivation: in cycled ensemble reflectivity DA (WoFS / RRFS with MPAS-JEDI),
refl10cmat model initialization (t=0) must match the analyzed hydrometeors. Without a diagnosis it is just whatever was read from the input file. The MPAS-side change that calls this routine at initialization is ufs-community/MPAS-Model#299.tempo_diagnose_refl_1dreproduces the end-of-step reflectivity path oftempo_main:*_check_and_updateplussnow_moments;graupel_initon the first step when hail-aware and the columnng/qbsums are zero, astempo_maindoes;hailhyperaware_flagis set,thermo_varsandcompute_hail_fraction. Hail is split from graupel (viahail_check_and_update, then the graupel re-check), andreflectivity_10cmreceives the hail category, exactly astempo_maindoes.tempo_diagnose_reflfollows thetempo_runconventions:(ims:ime, kms:kme, jms:jme); only the tile(its:ite, kts:kte, jts:jte)is computed;reflisintent(inout); points outside the tile are left unchanged;t, orthandpii(all optional). If neither is given, it returnserrflg = 1with anerrmsg;ng/qbare optional (hail-aware).Input arrays are not modified. The routines are new public entry points; no existing code path changes.
Testing
gfortran 12.4, full debug (
-O0 -g -fcheck=all -ffpe-trap=invalid,zero,overflow -finit-real=snan -finit-integer=-999999 -Wall -Wextra), both double (-fdefault-real-8 -fdefault-double-8) and single precision (-DSINGLE_PREC):run_tempo_testsbuild with no warnings in the new code.refloutside the tile is untouched, and all inputs are unchanged.tandth+piiforms give the same result.errflg /= 0.tempo_runrefl10cm(turn_off_micro_flag, dt = 1e-4 s): max |dBZ diff| < 3e-4 for hailhyperaware on/off × with/withoutgraupel_init, in both DP and SP.run_tempo_tests: all pass in DP. In SP,test_water_conservationfails its 1e-6 tolerance (|R/P| = 1.54e-5). Pristinetempo_v3.3.0fails identically (byte-identical test output), so this is unrelated to this PR.In MPAS-Model (
noaa/develop+ ufs-community/MPAS-Model#299, CMake, Intel, Ursa), the code builds and a 3 km WoFS forecast (96 MPI tasks,mp_tempohail-aware) runs. The t=0refl10cmranges from −35 to 72.9 dBZ and matches the observed convective structure.This branch is based on
tempo_v3.3.0(4df316e).Credits: original implementation by Chengsi Liu (v3.0.3); ported to v3.2.4/v3.3.0 by Yunheng Wang.