AER-RC / MT_CKD

AER continuum model for water vapor and other gases.
15 stars 10 forks source link

vmrh2o used as mixing ratio with respect to dry gas density and total gas density #8

Open hinnes97 opened 1 year ago

hinnes97 commented 1 year ago

Summary of issue

In cntnm_progr.f90, the variable vmrh2o is referred to as a mixing ratio with respect to the total column density: https://github.com/AER-RC/MT_CKD/blob/f6edc93bc608b01029c373d84012c1575d1e58b6/src/cntnm_progr.f90#L187-L188 The variable W_dry is defined consitently with this definition as: https://github.com/AER-RC/MT_CKD/blob/f6edc93bc608b01029c373d84012c1575d1e58b6/src/cntnm_progr.f90#L213 However, later it is written: https://github.com/AER-RC/MT_CKD/blob/f6edc93bc608b01029c373d84012c1575d1e58b6/src/cntnm_progr.f90#L235 where wk(1) is supposed to be the column density of water vapour. This implies that h2ovmr is a mixing ratio with respect to the dry column mass, but taken with the line above this suggests wk(1) = w_dry*h2ovmr = wtot*vmrh2o*(1-vmrh2o), which I think leads to an underestimation in the water column density.

Resulting errors in optical depths

This leads to problems in the LBLRTM cntnm.f90, because WTOT (the total column density) is redefined as the sum of wk entries:

DO 10 M = 1, NMOL
      WTOT = WTOT+WK(M)
10 CONTINUE

leading to it being underestimated, and lower than the value of WTOT in cntnm_progr.f90, or the value derived using the ideal gas law $p/kT \times \text{path length}$. This then affects the value of h2o_fac, which is supposed to be the total $\text{H}_2\text{O}$ column density as wk(1)/WTOT, but is now not equal to vmr_h2o because wk(1) and WTOT have both been underestimated.

This doesn't affect the coefficients in WATER.COEF because they are both divided by and multpilied through by h2o_fac at various points in the code. However, it does affect the optical depths in CNTNM.OPTDPT since these rely on the continuum coefficients being multiplied by wk(1).

Proposed solution

TL;DR, I think this can be solved by changing: WK(1) = VMRH2O * W_dry to WK(1) = VMRH2O * WTOT. Using this change, I can get agreement between optical depths calculated with WATER.COEF coefficients, those in CNTNM.OPTDPT and those derived from the netcdf file absco-ref_wv-mt-ckd.nc

emlawer commented 1 year ago

Thanks for alerting us to this issue. Looking into this, it is clear that a bug was introduced in the cntnm_progr code in 2004 when MT_CKD_1.2 was released. Before that, the relevant line was: WK(1) = VMRH2O WTOT but after that it became: WK(1) = VMRH2O W_dry without any other changes. So, somehow VMRH2O, which clearly is defined as with respect to total air, was mistakenly utilized as though it was with respect to dry air (as it is throughout LBLRTM and MT_CKD). It's unclear why the coder made an exception to the standard definition of mixing ratio in LBLRTM-related codes to have this variable otherwise defined, but once that exception was made the rest of that code should have remained consistent with that definition. It isn't, so users of our standalone continuum code (which is not part of LBLRTM) would have slightly incorrect optical depths, as this comment points out.

There is no issue with LBLRTM calculations since this bug is not part of LBLRTM.

The commenter's suggestion for a fix is exactly what is needed -- basically changing the code back to what it was prior to MT_CKD_1.2. We'll do that in the next release.

Thanks for your help.