Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MPAS-Ocean units CF compliant #5027

Merged
merged 41 commits into from
Aug 9, 2022
Merged

Conversation

darincomeau
Copy link
Member

@darincomeau darincomeau commented Jun 16, 2022

This makes changes to the units in MPAS-Ocean's Registry files to be CF compliant. CF Standard Units

The main changes for CF compliance are:

  • variables not have a units attribute if they are unitless (i.e. no units='unitless', units='NA', etc.)
  • variables should have units=1 if they are dimensionless (e.g. real-valued coefficients)
  • we cannot use latex symbols like { and } in the units
  • we cannot use units='PSU' for salinity, we need to use units=1e-3, though we can state that the units are grams per kilogram in the description (used as the long_name attribute in output files).

Further discussion found in E3SM-Ocean-Discussion#24

Note this does not change any units on BGC variables, as found in the following Registry files under tracer_groups:

  • Registry_CFC
  • Registry_DMS
  • Registry_MacroMolecules
  • Registry_ecosys
  • Registry_idealAge

[BFB]

Copy link
Contributor

@xylar xylar left a comment

Choose a reason for hiding this comment

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

Wow, @darincomeau! This was a lot of work! Thanks for putting in the time. I went through all the files and found ~80 things to fix, which sounds like a lot but it's a tiny fraction compared to what you changed already.

components/mpas-ocean/src/Registry.xml Outdated Show resolved Hide resolved
components/mpas-ocean/src/Registry.xml Outdated Show resolved Hide resolved
components/mpas-ocean/src/Registry.xml Outdated Show resolved Hide resolved
components/mpas-ocean/src/Registry.xml Outdated Show resolved Hide resolved
components/mpas-ocean/src/Registry.xml Outdated Show resolved Hide resolved
@@ -50,10 +50,10 @@
<var name="binBoundaryZonalMean" type="real" dimensions="nZonalMeanBinsP1" units="varies"
Copy link
Contributor

Choose a reason for hiding this comment

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

@czender, this variable sometimes gets used with units of radians and sometimes with m. Is there a way to handle this in a CF-compliant way?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just noting this is the only review comment I haven't addressed

@darincomeau darincomeau requested a review from czender June 21, 2022 15:15
Copy link
Contributor

@czender czender left a comment

Choose a reason for hiding this comment

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

Looks great. I agree with @xylar on replacing the "per second" with "s^-1" or "second-1", and that inverse salinity is better as "1.e^3" than "1.e^-3^-1".

@darincomeau
Copy link
Member Author

Thanks again @xylar for all of those comments! I've corrected them all, along with some other similar offenders that came up with grep.
I also reran this branch through your new compass_daily_monthly to make sure nothing broke and it passes.

Copy link
Contributor

@mark-petersen mark-petersen left a comment

Choose a reason for hiding this comment

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

Thanks @darincomeau. This looks great. I ran a quick test to make sure. This compiles with both gnu and intel, and passes gnu optimized bfb against the branchpoint (as expected) with the compass nightly suite.

@rljacob
Copy link
Member

rljacob commented Jun 30, 2022

@xylar is this ready?

@xylar
Copy link
Contributor

xylar commented Jun 30, 2022

@rljacob, no these changes are big enough that I will take another look when I get back from vacation and I do want all the reviewers listed here to have a look, too. @milenaveneziani and @vanroekel, can you have a look when you have time?

Copy link
Contributor

@xylar xylar left a comment

Choose a reason for hiding this comment

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

Thanks, @darincomeau, the updated version looks great!

@@ -52,7 +52,7 @@
description="sum of the volumeEdge variable over the full domain, used to normalize global statistics"
packages="forwardMode;analysisMode"
/>
<var name="CFLNumberGlobal" type="real" dimensions="Time" units="unitless"
<var name="CFLNumberGlobal" type="real" dimensions="Time"units="1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Space issue

Suggested change
<var name="CFLNumberGlobal" type="real" dimensions="Time"units="1"
<var name="CFLNumberGlobal" type="real" dimensions="Time" units="1"

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch - thanks!

@darincomeau
Copy link
Member Author

@milenaveneziani @vanroekel , this is good to go as far as I and the approved reviewers. Would you mind taking a look here, since there are extensive changes?

description="Form of pressure gradient terms in momentum equation. For most applications, the gradient of pressure and layer mid-depth are appropriate. For isopycnal coordinates, one may use the gradient of the Montgomery potential. The sea surface height gradient (ssh_gradient) option is for barotropic, depth-averaged pressure."
possible_values="'ssh_gradient', 'pressure_and_zmid' or 'Jacobian_from_density' or 'Jacobian_from_TS' or 'MontgomeryPotential' or 'constant_forced'"
/>
<nml_option name="config_common_level_weight" type="real" default_value="0.5" units="unitless"
<nml_option name="config_common_level_weight" type="real" default_value="0.5"
description="The weight between standard Jacobian and weighted Jacobian, $\gamma$."
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the use of the latex '$$' allowed? (I noticed this here, but there might be other places that I might have missed)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call! Those need to be removed because they just clutter things up now that we're not focusing on the latex documentation. My guess is that they won't cause errors in the CF-checker though.

@darincomeau, I suppose it's up to you if that's in the scope of this PR or should be a separate one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out @milenaveneziani . But I think trying to remove all latex syntax from attributes like description, which won't impact CF compliance, are more general registry cleanup and outside the scope here, so I think I'd prefer to leave this as is for now rather than trying to do a more complete job of that.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good @darincomeau. I just wanted to make sure that it wasn't required.

description="divergence of transport velocity at cell centers at a depth of approximately 250 m"
/>
<var name="relativeVorticityVertexAt250m" type="real" dimensions="nVertices Time" units="s^{-1}"
<var name="relativeVorticityVertexAt250m" type="real" dimensions="nVertices Time" units="s^-1"
description="relative vorticity at cell vertices at a depth of approximately 250 m"
/>
<var_array name="activeTracersAtSurface" type="real" dimensions="nCells Time">
<var name="temperatureAtSurface" array_group="activeTracersAtSurface" units="^\circ C" name_in_code="temperatureAtSurface"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 'C' above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely a great catch here.

description="relative vorticity at cell centers at bottom"
/>
<var name="divergenceAtBottom" type="real" dimensions="nCells Time" units="s^{-1}"
<var name="divergenceAtBottom" type="real" dimensions="nCells Time" units="s^-1"
description="divergence at cell centers at bottom"
/>
<var_array name="activeTracersAvgTopto0100" type="real" dimensions="nCells Time">
<var name="temperatureAvgTopto0100" array_group="activeTracersAvgTopto0100" units="^\circ C" name_in_code="temperatureAvgTopto0100"
Copy link
Contributor

@milenaveneziani milenaveneziani Jul 26, 2022

Choose a reason for hiding this comment

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

same here. I also noticed a couple of more places below, so you may want to check the whole file.

Copy link
Member Author

Choose a reason for hiding this comment

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

and here... I'll grep for the offender to fix any others

description="flag to monitor if the particle was transfered"
/>
<!-- TEMP FIELDS THAT NEED MOVED TO NonHalo below after verifying interpolation is correct -->
<var name="particleTemperature" type="real" dimensions="nParticles Time" units="degrees Celsius"
<var name="particleTemperature" type="real" dimensions="nParticles Time" units="C"
description="sampled temperature for particle"
/>
<var name="particleSalinity" type="real" dimensions="nParticles Time" units="grams salt per kilogram seawater"
Copy link
Contributor

Choose a reason for hiding this comment

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

change units above

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks! will do

Copy link
Contributor

@milenaveneziani milenaveneziani left a comment

Choose a reason for hiding this comment

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

wow @darincomeau: these are indeed extensive changes.. Thanks for implementing them.
I noted a few things by going through each file: not sure if I got everything, but hopefully..

@darincomeau
Copy link
Member Author

Thanks for those catches @milenaveneziani - changes have been pushed. I think I've said this earlier in this PR, but I've only actually run cfchecker on the output from the daily output test (which now matches monthly output), so while I do grep for violations and change all I find, there are bound to be some missed.

@rljacob
Copy link
Member

rljacob commented Aug 4, 2022

@vanroekel please review.

Copy link
Contributor

@vanroekel vanroekel left a comment

Choose a reason for hiding this comment

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

looks good to me. Very impressive work @darincomeau

@jonbob
Copy link
Contributor

jonbob commented Aug 8, 2022

@darincomeau - can you please check the conflicts in Registry? I'd like to merge this and I'm not sure about some of the changes that have been introduced since you started this work

@darincomeau darincomeau force-pushed the darincomeau/ocn/cf-compliant-units branch from 7b18ec7 to c577c12 Compare August 8, 2022 19:49
@darincomeau
Copy link
Member Author

Rebased to pick up and resolve conflicts in Registry.xml.

jonbob added a commit that referenced this pull request Aug 8, 2022
Make MPAS-Ocean units CF compliant

This makes changes to the units in MPAS-Ocean's Registry files to be CF
compliant.  The main changes for CF compliance are:
* variables not have a units attribute if they are unitless (i.e. no
  units='unitless', units='NA', etc.)
* variables should have units=1 if they are dimensionless (e.g.
  real-valued coefficients)
* we cannot use latex symbols like { and } in the units
* we cannot use units='PSU' for salinity, we need to use units=1e-3,
  though we can state that the units are grams per kilogram in the
  description (used as the long_name attribute in output files).
Further discussion found in E3SM-Ocean-Discussion#24

Note this does not change any units on BGC variables

[BFB]
@jonbob
Copy link
Contributor

jonbob commented Aug 8, 2022

passed:

  • ERS.ne11_oQU240.WCYCL1850NS.chrysalis_intel
  • SMS_D_Ld3.T62_oQU120.CMPASO-IAF.chrysalis_intel
  • PEM_Ln9.ne30pg2_EC30to60E2r2.WCYCL1850.chrysalis_intel

merged to next

@jonbob jonbob merged commit cd9f5d1 into master Aug 9, 2022
@jonbob
Copy link
Contributor

jonbob commented Aug 9, 2022

merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFB PR leaves answers BFB mpas-ocean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants