UW-Hydro / VIC

The Variable Infiltration Capacity (VIC) Macroscale Hydrologic Model
http://vic.readthedocs.io
MIT License
259 stars 385 forks source link

Unit conversion bug in support/VIC.4.2.glacier #888

Closed anewman89 closed 5 years ago

anewman89 commented 5 years ago

Via slack discussion with Bart Nijssen, Joe Hamman, and Naoki Mizukami:

From Bart Nijssen:

In: https://github.com/UW-Hydro/VIC/blob/support/VIC.4.2.glacier/src/glacier.c#L74-L79 We determine the amount of glacier volume and area:

for (band = 0; band < Nbands; band++) {
    snow[iveg][band].gl_overflow = 0.;
    if (snow[iveg][band].iwq > 0.0) {
        ice_vol += snow[iveg][band].iwq * veg_con[iveg].Cv *
                          soil_con->AreaFract[band];
        ice_area_old += soil_con->AreaFract[band] *
                                    veg_con[iveg].Cv;
        }
}

then a few lines later (https://github.com/UW-Hydro/VIC/blob/support/VIC.4.2.glacier/src/glacier.c#L81-L84) we scale volume and area to get actual volumes and areas so that we can apply the scaling relationships:

if (ice_vol > 0.0) {
    // ice_vol in km3 and ice_area in km2
    ice_vol *= cell_area / MMPERMETER / METERS_PER_KM;
    ice_area_old *= veg_con[iveg].Cv * cell_area;

Since we already multiplied ice_area_old by veg_con[iveg].Cv in the earlier loop, I don’t think we need to do it again (we don’t do it for ice_vol either, so I think that the second ice_area_old should just be calculated as ice_area_old *= cell_area;. (note that cell_area is already in units of km2 (first calculation in this function). In the end, I am not sure this affects the area hugely (since we calculate the new ice area in part on glacier volume, which is not affected by this), but if it is wrong we should fix it.

anewman89 commented 5 years ago

I have the fix on line #84 ready for this. I can submit a pull request whenever.

bartnijssen commented 5 years ago

From @jhamman on slack: here, I think you are right, ice_area_old *= cell_area;

bartnijssen commented 5 years ago

Closed per PR #889