mom-ocean / MOM5

The Modular Ocean Model
https://mom-ocean.github.io/
GNU Lesser General Public License v3.0
82 stars 95 forks source link

Incorrect temp units when temperature_variable = 'conservative_temp' and cmip_units=.true. #295

Closed aekiss closed 5 years ago

aekiss commented 5 years ago

When temperature_variable = 'conservative_temp' the netcdf diagnostic output for temp has values in K but the incorrect units deg_C. Examples (for those on NCI): /g/data/hh5/tmp/cosima/access-om2-025/025deg_jra55v13_iaf_gmredi6/output150/ocean/ocean.nc and /g/data/hh5/tmp/cosima/access-om2-01/01deg_jra55v13_ryf9091/output000/ocean/ocean.nc Note that pottemp_equal_contemp is irrelevant (it is true in the first example and defaults to false in the second). The pot_temp variable units are correct in both cases.

When temperature_variable = 'potential_temp' both units and values are given correctly in degrees K. For example: /g/data/hh5/tmp/cosima/access-om2-01/01deg_jra55v13_ryf8485_spinup6/output470/ocean/ocean.nc

These runs all use cmip_units=.true., which should set temp_units='degrees K' https://github.com/mom-ocean/MOM5/blob/master/src/mom5/ocean_tracers/ocean_tracer.F90#L605 but this is not being picked up and the old unit 'degC' (NB: not 'degrees C' as for cmip_units=.false.) is used instead.

I'm guessing ocean_prog_tracer_init needs a elseif(T_prog(n)%longname=='Conservative temperature') then clause here https://github.com/mom-ocean/MOM5/blob/50dc61e9d77c181e6ad0047925fafdcead64d87a/src/mom5/ocean_tracers/ocean_tracer.F90#L1252 like this one in ocean_diag_tracer_init: https://github.com/mom-ocean/MOM5/blob/50dc61e9d77c181e6ad0047925fafdcead64d87a/src/mom5/ocean_tracers/ocean_tracer.F90#L1988 It looks like this clause is also needed here in the case of blobs: https://github.com/mom-ocean/MOM5/blob/50dc61e9d77c181e6ad0047925fafdcead64d87a/src/mom5/ocean_tracers/ocean_tracer.F90#L1454

Thanks to Ruth for spotting this.

russfiedler commented 5 years ago

Should be K not degrees K, surely?

aidanheerdegen commented 5 years ago

udunits agrees with you @russfiedler

https://github.com/Unidata/UDUNITS-2/blob/master/lib/udunits2-base.xml#L37-L42

StephenGriffies commented 5 years ago

Sorry to confuse the story, but CMIP6 has degrees C as the preferred temperature unit. I originally had K for CMIP5, to be consistent with the atmosphere. But the ocean community rebelled since no oceanographer thinks of temperature in K. Hence the switch to deg C for CMIP6.

K or C are fine by me for MOM5, so long as everything is self-consistent.

aekiss commented 5 years ago

hmmm, sounds like we need another namelist variable cmipn to specify which cmip...

aekiss commented 5 years ago

https://github.com/mom-ocean/MOM5/commit/fe3906f0eeb875f9d1cb82f959dcbf30e5db730a shows what I had in mind. Comments welcome. I'm yet to check that it compiles.

There's a new namelist variable cmip_version. With cmip_units=.true. the temperature is in K if cmip_version<=5, otherwise in degrees C - @StephenGriffies does this look OK?

I've used the CF standard name sea_water_conservative_temperature but had to invent sea_surface_conservative_temperature and square_of_sea_surface_conservative_temperature

StephenGriffies commented 5 years ago

A brief looks and all seems OK @aekiss . Thanks for this; I approve.

@russfiedler what do you think?

aidanheerdegen commented 5 years ago

I'd suggest make a PR and discuss implementation details there.

aekiss commented 5 years ago

a404d1d fixes this