Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

CRITICAL ERROR: NaN detected in 'w' field

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.


New member
Run init_atmosphere_model step without any error, But the error "CRITICAL ERROR: NaN detected in 'w' field." appears when running the atmosphere_model step.
In addition, the SCVT mesh created by myself using the MPAS mesh_tools,96-24km variable-resolution mesh. But didn't any errors when I use the 24km Quasi-uniform mesh,the 24km mesh also ccreated by myself with 1029153 grids.
anyone could help me? thanks
If the uniform 24-km mesh works without problem, that would suggest there may be a problem with the 96-24 km mesh. Can you check the the minimum and maximum of the dcEdge and dvEdge fields? How many time steps is the the model taking before stopping with a NaN in the w field?

Also, which tool, specifically, did you use to generate the mesh?
Thank you for you replay!
(1) dcEdge and dvEdge in 96-24 km mesh :
dcEdge_max = 0.01957847 * 6371 = 124.73 km
dcEdge_min = 0.00252251 * 6371 = 16.07 km
dvEdge_max = 0.01324216 * 6371 = 84.36 km
dvEdge_min = 0.00090375 * 6371 = 5.75 km

**************************some log information at the end of the log.atmosphere.0000.out :
Begin timestep 2017-07-27_00:00:00
Read 'surface' input stream valid at 2017-07-27_00:00:00
Timing for stream input: 0.130875 s
--- time to update background surface albedo, greeness fraction.
--- time to run the LW radiation scheme L_RADLW =T
--- time to run the SW radiation scheme L_RADSW =T
--- time to run the convection scheme L_CONV =T
--- time to apply limit to accumulated rainc and rainnc L_ACRAIN =F
--- time to apply limit to accumulated radiation diags. L_ACRADT =F
--- time to calculate additional physics_diagnostics =F
split dynamics-transport integration 3

global min w: -1.53249 k=51, 17.4425 lat, 127.214 lon
global max w: 1.49144 k=35, 17.3511 lat, 127.413 lon
global min u: -114.226 k=64, -56.9643 lat, 14.1860 lon
global max u: 114.191 k=64, -56.9047 lat, 12.6422 lon
global max wsp: 125.718 k=64, -57.1040 lat, -165.239 lon
Timing for integration step: 3.82357 s

***************************** information in log.atmosphere.0109.err
Beginning MPAS-atmosphere Error Log File for task 109 of 128
Opened at 2019/05/24 14:16:19

CRITICAL ERROR: NaN detected in 'w' field.
Logging complete. Closing file at 2019/05/24 14:16:19

(3) my step of generate 96-24km mesh
a. generate EARTH-REGIONAL-MESH.msh file with jigsaw-geo-matlab-master
the h function in meshdemo.m file at demo5 as follow:
hfun =-96. * exp(-1.0*(XPOS-0.0).^2 -2.0*(YPOS-0.0).^2 ) ;
hfun(hfun < -72.0) = -72.0 ;
hfun = +96.0 + hfun ;
b. use the triangle_jigsaw_to_netcdf generate
c. use MpasMeshConverter.x in mesh_conversion_tools to generate MPAS mesh

Specifically, the meshDensity is created as follow NCL code:
pi = 3.1415926
areaCell = fout->areaCell
meshD = fout->meshDensity
dCell = areaCell/pi ; diameter
dCell_max = max(dCell)
dCell_min = min(dCell)
dCell_hhh = dCell_max - dCell_min
meshD_new = (dCell - dCell_min)/dCell_hhh
fout->meshDensity = meshD_new
Sorry for not responding sooner. I think the issue may be in the meshDensity field that you're producing. The meshDensity field should describe the mesh density function as used in Lloyd's method, where the relative grid distances in any two parts of the mesh are inversely related to the fourth root of the density function at the corresponding two locations in the mesh. Accordingly, I think you may need to raise your meshDensity field to the fourth power. Also, MPAS-Atmosphere assumes that max(meshDensity) = 1.0, and values of meshDensity less than 1.0 represent coarser regions in the mesh.

MPAS-Atmosphere uses the meshDensity field to scale horizontal mixing coefficients, so an incorrect meshDensity field could lead to unstable mixing. I think this might be why your simulations with this mesh result in NaNs so quickly.
Thanks for your replay!
Since the value of all meshDensity in the final variable-resolution mesh file which generated by myself is 1.0, is there any other way, such as deriving meshDensity through the areaCell or other variables? I would be very grateful if can get some detailed steps .
As far as I know, the mesh_tool is for mesh generation for MPAS-O, Is there any program or code available for MPAS-A mesh generation? Maybe these code is not yet perfect, but I can try it by myself.