Skip to content

init_atmosphere: move RAP soil mask logic to cases.F for soil moisture and temperature - #324

Open
spanNOAA wants to merge 3 commits into
ufs-community:noaa/developfrom
spanNOAA:fix/init-atm-soilw-watermask
Open

spanNOAA wants to merge 3 commits into
ufs-community:noaa/developfrom
spanNOAA:fix/init-atm-soilw-watermask

Conversation

@spanNOAA

@spanNOAA spanNOAA commented Nov 23, 2026 •

Copy link
Copy Markdown

Description

This PR resolves a land-surface initialization defect in init_atmosphere when cold-starting MPAS from RAP / HRRR / RUC intermediate files (init_atm_case_gfs), where coastal land cells, sand spits, and islands near ice-covered water are erroneously initialized with water/sea-ice placeholder soil values (SMOIS = 1.000 m³/m³ and TSLB[3m] = -1.75 °C).

Following reviewer feedback, the earlier mpas_init_atm_hinterp.F logic has been completely reverted (0 diff vs noaa/develop), and the fix is now scoped cleanly inside src/core_init_atmosphere/mpas_init_atm_cases.F (+57 / -4 lines) for both soil moisture (sm_fg) and soil temperature (st_fg).

Problem Statement: RAP/HRRR/RUC SOILM000 == 1.0 Leakage at Coastal Land Cells

In RAP / HRRR / RUC intermediate files (is_ruc_lsm_source(field % map_source)), ice-covered inland water/sea-ice points (e.g., 1,223 points in RAP:2025-12-16_03 with LANDSEA == 1 and SOTYP == 16) carry open-water/ice placeholders:

  • SOILM000..300 == 1.0 m³/m³
  • Deep soil temperature SOILT300 == -1.75 °C (271.4 K, sea-ice bottom temperature)

Because maskslab treats LANDSEA == 1 as valid land, interp_to_grid allowed those points to act as donors for coastal and island MPAS land cells (landmask == 1), corrupting both SMOIS and TSLB. This PR aligns MPAS with NOAA-GSL's METGRID.TBL.ARW.rap (missing_value=1. on SOILM000 + interp_mask=SOILM000(1) on SOILM* and SOILT*).


Solution & Implementation (mpas_init_atm_cases.F)

flowchart LR
    A["Pass 1: Scan LANDSEA & SOILM000<br/>(is_ruc_lsm_source)"] --> B["maskslab: original LANDSEA mask<br/>(non-soil fields unchanged)"]
    A --> C["soilmaskslab: set 0.0 where<br/>maskslab == 1.0 AND SOILM000 == 1.0"]
    B --> D{"Pass 2: active_maskslab target"}
    C --> D
    D -- "sm_fg (SMOIS) or st_fg (TSLB)<br/>for RUC/RAP/HRRR" --> E["Use soilmaskslab"]
    D -- "All other 2D/3D fields<br/>or non-RUC sources" --> F["Use maskslab"]
    E --> G["Deallocate soilmaskslab after read_met_close()"]
    F --> G
Loading
  1. Pass 1 (LANDSEA / SOILM000 pre-scan): When is_ruc_lsm_source(field % map_source) matches ('NCEP RAP Model', 'NCEP HRRR Model', 'NOAA GSD HRRR Model', 'NOAA GSD Rapid Refresh Model', 'NCEP RUC Model', 'unknown model from NCEP'), builds soilmaskslab alongside maskslab by masking out points where maskslab == 1.0_RKIND .and. soilmaskslab == 1.0_RKIND.
  2. Pass 2 (active_maskslab selection): Routes interp_to_grid to soilmaskslab strictly when interpolating 2D soil moisture (sm_fg) or soil temperature (st_fg) from RUC-LSM sources; all other fields continue using the untouched maskslab.
  3. Cleanup: Explicitly deallocates soilmaskslab immediately after read_met_close().

Verification & Expected Changes

1. CONUS 3 km Cold-Start Verification (RAP:2025-12-16_03, Latest cases.F Fix)

Tested on the CONUS 3 km mesh (conus3km, 2,341,818 cells, Gaea C7, 384 MPI tasks, Slurm Job 269257129, Error messages = 0):

Cell / Domain Scope Landmask Baseline (noaa/develop) This PR (8ec2f412) Status
Pelee Island, Lake Erie (Cell 864889) 1 (Land) SMOIS[0] = 1.000, TSLB[3.0 m] = -1.76 °C SMOIS[0] = 0.126, TSLB[3.0 m] = +9.41 °C (+11.17 °C) Fixed
Long Point Peninsula (Cell 1938925) 1 (Land) SMOIS ~ 0.602, TSLB[3.0 m] = +2.65 °C SMOIS 0.167–0.190, TSLB[3.0 m] = +7.45 °C (matches mainland 1939069: 0.160–0.192, +7.39 °C) Fixed
CONUS smois (all 1,461,560 land cells) 1 (Land) 61 land cells at 1.0, 79 at > 0.9 527 land cells fixed (land == 1.0: 61 -> 0; range [0.002, 0.465], bit-identical to SMOIS-only prototype) Fixed
CONUS tslb (all 1,461,560 land cells) 1 (Land) Sea-ice -1.75 °C cold bias along coast/islands 735 land cells fixed (ΔTSLB [-1.70, +11.17] °C) Fixed
Lake Erie / CONUS Open Water (880,258 cells) 0 (Water) SMOIS = 1.000, TSLB untouched 0 cells changed Bit-Identical
52 / 54 Non-Soil Fields (seaice, xice, skintemp, sst, snow*, sh2o, u10, v10, t2m, rh2, all 3D fields) All Reference 0 diff across all 2,341,818 cells Bit-Identical

2. Zero Side Effects on Interior Continental & Non-Soil Fields

  • Verified all 54 time-dependent variables across all 2,341,818 CONUS 3 km cells: 52 / 54 fields are bit-identical to noaa/develop, smois is bit-identical to the SMOIS-only validation run (which also showed < 0.001 m³/m³ difference across > 24,000 interior Ohio/PA mainland cells), and pure water cells (landmask == 0) remain completely unaffected (0 cells changed in smois or tslb).

3. Zero Side Effects on Non-RUC (NCEP GFS Model) Inputs & Interior Continental Cells

Tested an end-to-end CONUS 3 km GFS cold-start (GFS:2025-12-23_03, map_source = 'NCEP GFS Model', Gaea C7, 384 MPI tasks, Slurm Job 269257380, Error messages = 0) against noaa/develop:

Dataset / Scope Fields Checked Baseline vs This PR (8ec2f412) Status
CONUS 3 km GFS Cold-Start (GFS:2025-12-23_03) All 156 / 156 variables in init.nc (55 time-dependent numeric vars incl. smois, tslb, sh2o, skintemp, sst, seaice, xice, snow*, u10, v10, t2m, rh2, q2, pressure, theta, rho, qv, u, w, hydrometeors/aerosols + 101 static/char vars) 0 differences across all 156 variables 100% Bit-Identical

Visual Comparison

A. Latest cases.F Fix (SMOIS + Deep TSLB Cold-Start Spatial & Vertical Comparison)

image image

B. Initial SMOIS-Only Prototype: Long Point Forecast Timeseries & Soil Profile Detail

(Preserved from initial validation; shows the downstream forecast timeseries improvement at Long Point 1938925 where the SMOIS field in the final cases.F fix is bit-identical to the SMOIS-only prototype.)

long_point_vars_timeseries_comparison long_point_soil_profile_detail

How Has This Been Tested?

  • Initialized MPAS atmosphere cold start on CONUS 3km mesh on NOAA HPC (Gaea C7, RAP:2025-12-16_03, Slurm 269257129, Error messages = 0).
  • Verified smois (527 land cells fixed, land == 1.0 reduced from 61 -> 0) and tslb (735 land cells fixed, 0 water cells changed) in init.nc.
  • Confirmed bit-identical (0 diff) output across all 52 non-smois/tslb time-dependent variables and interior continental cells.
  • Initialized MPAS atmosphere cold start on CONUS 3km mesh with GFS:2025-12-23_03 (map_source = 'NCEP GFS Model', Slurm 269257380, Error messages = 0) and confirmed all 156 / 156 variables in init.nc are 100% bit-identical to noaa/develop.

…tal interpolation

When interpolating soil moisture from coarse source grids (e.g., RAP/HRRR/GFS),
open-water grid cells often carry a constant 1.0_RKIND placeholder flag.
For coastal land cells, narrow spits, and barrier islands surrounded by water,
these placeholder values previously leaked into land cells through four-point
stencil averaging or nearest-neighbor searches, setting SMOIS = 1.0 across
all soil layers.

This commit updates search_extrap, four_pt_average, wt_four_pt_average,
and four_pt in mpas_init_atm_hinterp.F to reject donor points when
mask_array == 1.0_RKIND and array == 1.0_RKIND. Restricting the filter to
terrestrial land donors prevents water placeholders from contaminating coastal
land soil moisture while preserving legitimate 100% sea ice (SEAICE = 1.0) on
water points (mask_array == 0.0_RKIND).
@spanNOAA
spanNOAA force-pushed the fix/init-atm-soilw-watermask branch from 7734550 to 9564457 Compare November 23, 2026 23:46
… == 0.0

Encapsulate the open-water placeholder check into a pure function
`is_water_placeholder` that requires `maskval == 0.0_RKIND`. This fixes
an issue where valid 1 m/s land wind donors (which pass maskval = -1.0)
were erroneously excluded in search_extrap.
@spanNOAA
spanNOAA marked this pull request as ready for review November 24, 2026 20:00
@clark-evans clark-evans moved this from Not assigned to Needs review in MPAS-A PRs to process Nov 25, 2026
@guoqing-noaa

Copy link
Copy Markdown
Collaborator

@spanNOAA Thanks for identifying this issue and proposing a fix.
I'm still trying to understand why this happens.
I think your case initializes from GFS.
GFS grib2 files do have 1.0 of SOILW values, but WPS/ungrib will limit SM* variables to no larger than 0.468:
https://github.com/NOAA-GSL/WPS/blob/b8ddb1627c3c551710094b282eb1ab808218bec5/ungrib/src/rrpr.F#L1286-L1294

So I am confused how the 1.0 SMOIL values happen.

@spanNOAA

spanNOAA commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

Thanks for identifying this issue and proposing a fix. I'm still trying to understand why this happens. I think your case initializes from GFS. GFS grib2 files do have 1.0 of SOILW values, but WPS/ungrib will limit SM* variables to no larger than 0.468: https://github.com/NOAA-GSL/WPS/blob/b8ddb1627c3c551710094b282eb1ab808218bec5/ungrib/src/rrpr.F#L1286-L1294

So I am confused how the 1.0 SMOIL values happen.

@guoqing-noaa Even in our RRFS retro cycling runs where atmospheric initial/boundary conditions come from GFS, the cold-start surface fields (SMOIS, TSLB, snowh etc) are updated from a RAP init_atmosphere run. We inspected the raw RAP GRIB2 file:

  • The GRIB2 header has center=7, forecast generating process=105, and year=2025 > 2011.
  • In ungrib/src/rd_grib2.F#L261-L263, this tags every field in the intermediate file with map%source = 'NCEP RAP Model'.
    Because map%source == 'NCEP RAP Model', ungrib/src/rrpr.F bypasses all soil-moisture adjustment routines:
! Modify the 2017 GFS masked fields
if (index(map%source,'NCEP GFS') .ne. 0 .or. &
    index(map%source,'NCEP GEFS') .ne. 0 ) then
   if ( is_there(200100, 'ST000010')) then
      call get_dims(200100, 'ST000010')
      call fix_gfs_miss (map%nx, map%ny, 200100.)
   endif
endif

Neither map%source ('NCEP RAP Model') matches 'NCEP GFS'/'NCEP GEFS', nor do RAP's 9-layer soil variable names (SOILM000–SOILM300 / SOILT000–SOILT300) match ST000010 or flist (SM000010, SM010040, etc.) in fix_gfs_miss.

As a result, ungrib writes RAP's SOILM* values, including 1.0, directly into the intermediate file untouched.

@guoqing-noaa

Copy link
Copy Markdown
Collaborator

@spanNOAA Thanks for the extra information. That's very helpful!

Upon further investigation, I found the issue came from the the combination of RAP's LAND and SOLTYP fields.

For RAP, LAND=0 means water, LAND=1 can mean either land or ice-covered water.

To determine the actual soil type, we need to check SOTYP as well.
For example:

$ cd /gpfs/f6/bil-fire10-oar/world-shared/RRFS2_RETRO_DATA/May2024/rap/rap.20240506
$ wgrib2 rap.t00z.wrfnatf00.grib2 -match ':(LAND|SOTYP):' -s -ij 494 445
1055:280271314:d=2024050600:SOTYP:surface:anl::val=16
1089:299591199:d=2024050600:LAND:surface:anl::val=1

soiltype=16 means land ice.

For references, here is the RAP STAS-RUC table in SOILPARM.TBL

SOTYP Soil type
1 Sand
2 Loamy sand
3 Sandy loam
4 Silt loam
5 Silt
6 Loam
7 Sandy clay loam
8 Silty clay loam
9 Clay loam
10 Sandy clay
11 Silty clay
12 Clay
13 Organic material
14 Water
15 Bedrock
16 Other / land ice
17 Playa
18 Lava
19 White sand

So I think a better fix may be to read the SOTYP fields during the init_atmosphere step and use it to safeguard correct smois interpolation.

@clark-evans and @harsh-kamath Do you have any suggestions? We'd love to hear your thoughts. Thanks!

@spanNOAA

Copy link
Copy Markdown
Author

@guoqing-noaa Thanks for looking into SOTYP! I totally understand your concern, and using a soil-type mask instead of filtering by a numerical value (1.0) sounds cleaner in principle.

To test this idea, I checked LAND, SOTYP, ICEC, and SOILW across all 794,802 points (953 x 834) in our RAP:2025-12-16_03 GRIB2 file, and found two key reasons why SOTYP does not actually solve the problem cleanly:

  1. SOTYP == 16 cannot be masked out directly without breaking valid land-ice points:

    • Out of 14,811 cells with LAND=1 & SOTYP=16, 13,588 (91.7%) are legitimate land-ice/glacier cells carrying valid moisture values (0.044–0.456, mostly 0.435, with ICEC=0).
    • 1,223 (8.3%) have SOILW = 1.0 (and over the Great Lakes in December, these cells have ICEC = 0.0, i.e., open water rather than ice-covered water).
    • So even if init_atmosphere read SOTYP, we could not reject SOTYP == 16 on its own. We would still have to check SOILW == 1.0 anyway to separate the 1,223 water-placeholder cells from the 13,588 valid land-ice cells.
  2. val == 1.0_RKIND (with maskval == 0.0 .and. mask == 1.0) is already an exact separator:

    • Across all valid soil categories (SOTYP 1–13, max SOILW = 0.482) and valid SOTYP=16 land ice (max SOILW = 0.456), there are 0 cells anywhere having soil moisture between 0.500 and 0.999.
    • Physically, volumetric soil moisture cannot reach 1.0 m³/m³ (100% pure liquid water, 0% soil matrix). Thus val == 1.0_RKIND under maskval == 0.0_RKIND isolates the exact same 1,223 placeholder cells without needing to read an extra SOTYP field at all.

Would love to hear @clark-evans and @harsh-kamath's thoughts on this as well!

@guoqing-noaa

Copy link
Copy Markdown
Collaborator

@spanNOAA Thanks for the discussions!
The situation is more complicated than expected:
For RAP, Land=0 can mean open water or ice-covered water
and Land=1 can mean land or ice-covered water, :)

Since the interpolation applies to all fields, not smois only, I am not sure whether maskval = 0, mask_array(i,j) = 1, array(i,j,izz) = 1.0 may bring potential issues to other fields.

It will be good if we can limit this check to soil moisture only (or RAP soil moisture only) instead of inside the general code src/core_init_atmosphere/mpas_init_atm_hinterp.F.

May be we can recreate the mask_array for RAP soil moisture fields before do i=1,nInterpPoints, something like:

   fieldmask = maskslab
   where (maskslab == 1.0_RKIND .and. rslab == 1.0_RKIND) fieldmask = 0.0_RKIND
   ! ... call interp_sequence(..., maskval=maskval, mask_array=fieldmask)

Also, since we don't want to use these "unintended" points to interpolate soil moisture to a land MPAS cell, should we also avoid using them for soil temperature interpolation?

@spanNOAA

Copy link
Copy Markdown
Author

@guoqing-noaa Thanks for the helpful suggestion! Moving this logic out of the generic mpas_init_atm_hinterp.F into a dedicated soil mask in mpas_init_atm_cases.F is much cleaner and completely avoids any side effects on non-soil fields.

I also think that we should exclude these same donor points for soil temperature (ST*/SOILT*) as well. Checking TSOIL across all 1,223 LAND=1 & SOILW=1.0 points in our RAP file shows that every single one of them has a deep 3 m temperature locked at -1.75°C (271.4 K, the sea/lake-ice bottom freezing temperature). The impact on Long Point Peninsula (Cell 1938925) makes this super clear:

  • Neighboring normal Ontario mainland cells have warm winter deep soil at 3 m (+7.61°C).
  • The mislabeled LAND=1 & SOILW=1.0 donor cell right next to it has -1.75°C at 3 m.
  • Because our previous patches only filtered smois = 1.0 and did not filter SOILT*, MPAS still included that -1.75°C donor during SOILT300 interpolation—pulling Long Point's 3 m soil temperature (tslb[8]) down to +0.63°C instead of the realistic mainland warmth.

One small detail on how to construct the mask: since mpas_init_atm_cases.F interpolates one 2D field (rslab) at a time, rslab holds temperatures (~270 K) rather than 1.0 when processing ST*/SOILT* (and in RAP intermediate files LANDSEA actually appears after SOILM*/SOILT*). Since mpas_init_atm_cases.F already scans the intermediate file once upfront to read LANDSEA into maskslab, we can construct a dedicated soilmaskslab during that same pre-pass (with zero extra I/O):

  1. Keep the original maskslab untouched for SEAICE, u10/v10, t2m/rh2, etc.
  2. Create soilmaskslab = maskslab, and set soilmaskslab = 0.0_RKIND wherever maskslab == 1.0_RKIND and any SM*/SOILM* field equals 1.0_RKIND.
  3. Pass soilmaskslab whenever maskval == 0.0 (which in mpas_init_atm_cases.F applies exclusively to all terrestrial SM*/SOILM* and ST*/SOILT* fields, including sixteen_pt used by ST*/SOILT*).
  4. Revert all changes to mpas_init_atm_hinterp.F so the generic horizontal interpolation module stays completely clean.

If everyone agrees with this approach, I'll update the PR and re-verify both smois and tslb!

@spanNOAA spanNOAA changed the title init_atmosphere: filter open-water placeholder (1.0_RKIND) in horizontal interpolation init_atmosphere: move RAP soil mask logic to cases.F for soil moisture and temperature Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

2 participants