NOAA-GFDL / GFDL_atmos_cubed_sphere

The GFDL atmos_cubed_sphere dynamical core code
Other
56 stars 118 forks source link

Units of pressure variables are not machine-readable #350

Open DWesl opened 2 months ago

DWesl commented 2 months ago

Describe the bug

The netCDF history outputs some pressure variables with units of "pa" or "mb". The netCDF Users' Guide and Climate and Forecast (CF) conventions both recommend making the units attribute of a netCDF variable machine-readable, specifically by the UDUNITS software package. This package interprets "pa" as picoannum, a unit of time roughly equal to a microsecond, and "mb" as millibarn, a unit of area used in atomic scattering, rather than as units of pressure.

To Reproduce

Steps to reproduce the behavior: Run the model and let it produce netCDF history files. Inspect the units attribute of the pressure variables (surface pressure and vertical coordinate are the most likely). Ask udunits2 (or another unit-processing software package) to convert from one pressure unit to the other, or to a known pressure unit (atm, torr, or psi should work).

Expected behavior

I expected my unit-processing software package to be able to convert the surface pressure to the same coordinates as the pressure of the vertical layers.

System Environment

Describe the system environment, include:

Additional context

Either of the two following sed scripts should fix the units in the output files. I tried running these on my version of the repository in a NOAA-EMC/global-workflow clone and my software can convert the pressure variables to atm and torr without guidance from me.

sed -i -E -e '/\bpa\b[^(),]/ s/\bpa\b/Pa/g' -e 's/\bmb\b/mbar/g' tools/*.F90 driver/fvGFS/*.F90 model/*.F90
sed -i -e "s/'pa'/'Pa'/g" -e "s|'pa/s(ec)?'|'Pa/s'|g" -e "s/'mb'/'mbar'/g" tools/*.F90 driver/fvGFS/*.F90 model/*.F90

I couldn't figure out how to make a PR with just three commits instead of 50, so I saved the commits as patches with git format-patch and attached the result as updated_units_patch.zip. They should apply cleanly with git am.

bensonr commented 1 month ago

@DWesl - are you planning to put in a PR for this issue?

DWesl commented 1 month ago

Created #355

DWesl commented 1 month ago

Created #356 since I figured out how to make a PR with just the relevant commits.

bensonr commented 1 month ago

@DWesl - thanks for making the changes against the dev/emc branch and submitting a new PR