geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
168 stars 165 forks source link

Potential off-by-one bug in convection #2355

Closed sdeastham closed 4 months ago

sdeastham commented 4 months ago

Your name

Sebastian Eastham

Your affiliation

Imperial College London

Please provide a clear and concise description of your question or discussion topic.

In convection_mod.F90, we say that the incoming mass flux to layer K is CMFMC(K-1) unless at the surface, in which case it is zero (https://github.com/geoschem/geos-chem/blame/dd859ee45494af71d29f0877f359ff571f697b67/GeosCore/convection_mod.F90#L776-L782). However, CMFMC is a level-edged variable; shouldn't it therefore be that CMFMC(K) is the incoming mass flux, since CMFMC(1) will correspond to the (zero) mass flux across the Earth's surface while DTRAIN(K) will correspond to the detrainment in the first layer? This would propagate to the line where CMFMC(K) and DTRAIN(K) are summed together to yield total outgoing mass flux (https://github.com/geoschem/geos-chem/blame/dd859ee45494af71d29f0877f359ff571f697b67/GeosCore/convection_mod.F90#L812) - it seems like this should instead be CMFMC(K+1) + DTRAIN(K). However, it would be best to get an expert in convection and/or the GEOS implementation to confirm.

sdeastham commented 4 months ago

RESOLVED: My apologies! I had missed this line in the preamble (https://github.com/geoschem/geos-chem/blame/dd859ee45494af71d29f0877f359ff571f697b67/GeosCore/convection_mod.F90#L557) which means that the indexing for CMFMC is not quite what it looks like. Leaving this here in case others come across this in the future.