Skip to content

Use the x map factor on the x slope term of the w horizontal diffusion (diff_opt = 2) - #2454

Open
mirfjc wants to merge 1 commit into
wrf-model:release-v4.8.2from
mirfjc:w_diffusion_slope_map_factor
Open

mirfjc wants to merge 1 commit into
wrf-model:release-v4.8.2from
mirfjc:w_diffusion_slope_map_factor

Conversation

@mirfjc

@mirfjc mirfjc commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

TYPE: bug fix

KEYWORDS: horizontal diffusion, diff_opt 2, map factor, w, slope term, lat-lon, global

SOURCE: Mark I. Richardson (Aeolis Research)

DESCRIPTION OF CHANGES:
Problem:
With diff_opt = 2 each horizontal derivative is taken on a constant-height surface, d/dX = m_x (d/dx - zx d/dz), so the slope (zx) correction must carry the same map factor as the flat x derivative. horizontal_diffusion_u_2, horizontal_diffusion_v_2 and horizontal_diffusion_s do this (msfux/msfvx/msftx on the zx term, msfuy/msfvy/msfty on the zy term), but horizontal_diffusion_w_2 multiplies both slope terms by msfty, so the zx part of the w slope correction has the y map factor. On lat-lon grids (msftx = 1/cos(lat), msfty = 1) that part is too small by cos(lat): half at 60 degrees latitude. The scalars were fixed in c38cfce (#266) and u and v in f854c25 (#368); w was left out. Details in #2453.

Solution:
Factor rdz out and put msftx on the zx term and msfty on the zy term, the same form as the u, v and scalar routines. Projections with msftx = msfty (Lambert, polar stereographic, Mercator) change only in rounding; idealized cases with map factors of 1, hydrostatic runs (w diagnosed) and diff_opt = 1 are unchanged.

ISSUE:
Fixes #2453

LIST OF MODIFIED FILES:
M dyn_em/module_diffusion_em.F

TESTS CONDUCTED:

  1. Yes. em_heldsuarez (129 x 65 x 41 global lat-lon, model top 40 km with damp_opt = 3, non_hydrostatic, diff_opt = 2, km_opt = 1, khdif = 0., kvdif = 10., 600 s steps) with four 2000 m Gaussian mountains (1100 km half-width, the same distance in x and y) added to the initialization at 0, 30, 60 and 75 N, a zonal wind u = 20 cos(lat) min(z / 2 km, 1) m/s and no random perturbation. The first step was run with the current and with the corrected line from the same wrfinput, and the contribution of horizontal_diffusion_w_2 to the w tendency was written out at that call: the change equals -(msftx - msfty) times the x slope term at every point of the domain to roundoff (largest residual 4.8e-9 Pa m s-2 against a largest change of 7.3e-3, relative 6.5e-7), i.e. change / (x slope term) = -0.149 on the 30 N row, -1.029 at 60 N and -2.749 at 75 N, equal to -(1/cos(lat) - 1) of those rows, and -3e-4 next to the equator. On the 60 N row the x slope term is 43% of the routine's largest w tendency, so the current line has it at half its size. The idealized em_hill2d_x case (map factors 1, km_opt = 3, 180 steps) is bitwise identical with and without the change (160 variables compared, 0 differ). Built from tag v4.8.0 (06d4240) with configure option 15 (Darwin gfortran serial) in debug mode (-g -O0), Homebrew gfortran/gcc 16.2.0, macOS on Apple Silicon. On release-v4.8.1 this file differs from that tag by one line elsewhere (line 2834).
  2. The regression (Jenkins) tests: not yet run.

RELEASE NOTE: With diff_opt = 2 on latitude-longitude grids, the slope correction of the horizontal diffusion of w now uses the x map factor on its x part, as the u, v and scalar terms already do; w diffusion over terrain at high latitude changes, other projections and hydrostatic runs are unchanged.

With diff_opt = 2 each horizontal derivative is taken at constant height,
d/dX = m_x (d/dx - zx d/dz), so the slope (zx) term carries the same map
factor as the flat x derivative. horizontal_diffusion_u_2, _v_2 and _s do
this, but horizontal_diffusion_w_2 multiplied both slope terms by msfty.
On lat-lon grids (msftx = 1/cos(lat), msfty = 1) the zx part of the w slope
correction was too small by cos(lat). Put msftx on the zx term and msfty on
the zy term; projections with msftx = msfty change only in rounding.
@weiwangncar

Copy link
Copy Markdown
Collaborator

The (delayed) regression test results:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

dudhia
dudhia previously approved these changes Dec 4, 2026

@dudhia dudhia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

affects lat/long where dx /= dy.

@dudhia
dudhia changed the base branch from release-v4.8.1 to release-v4.8.2 December 4, 2026 16:22
@dudhia
dudhia dismissed their stale review December 4, 2026 16:22

The base branch was changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants