climlab / climlab-rrtmg

MIT License
7 stars 4 forks source link

output diffuse and direct components of sw #18

Open bsu-wrudisill opened 6 months ago

bsu-wrudisill commented 6 months ago

Hello,

Here is a feature request. I would like to be able to output the direct and diffuse components of downwelling shortwave radiation. It appears that this might be straightforward to do.

I think that by modifying the driver.f90 script might be possible.

https://github.com/climlab/climlab-rrtmg/blob/3db6e66b1c735c694ca2f37fd259d73bb26868e9/climlab_rrtmg/rrtmg_sw/Driver.f90

brian-rose commented 4 months ago

Agreed that this would be a useful feature. It would require a slightly deeper drive into the fortran code. driver.f90 just passes the same diagnostics reported by the original RRTMG_SW code through to the Python wrapper.

bsu-wrudisill commented 4 months ago

Thanks!

I'm looking in the rrtmg_sw_rad.f90 script — it looks like these are the optional output variables that we want.

https://github.com/climlab/climlab-rrtmg/blob/3db6e66b1c735c694ca2f37fd259d73bb26868e9/climlab_rrtmg/rrtmg_sw/sourcemods/rrtmg_sw_rad.f90#L528C1-L530C1

So, i think the steps would be 1) change the intent of this variable to "out" in the rrtmg_sw_rad.f90 script, and 2) add this variable to the output from driver.f90 here https://github.com/climlab/climlab-rrtmg/blob/3db6e66b1c735c694ca2f37fd259d73bb26868e9/climlab_rrtmg/rrtmg_sw/Driver.f90#L237

And also add the new variables to the f2py declarations here: https://github.com/climlab/climlab-rrtmg/blob/3db6e66b1c735c694ca2f37fd259d73bb26868e9/climlab_rrtmg/rrtmg_sw/Driver.f90#L245

Does that sound about right? Any pointers are appreciated.

brian-rose commented 4 months ago

That sounds more or less right, except that there would need to be a new switch to turn on the optional extra output. The Python wrapper that calls this module would default to setting this switch off, to preserve backwards compatibility.

brian-rose commented 4 months ago

There is some work happening concurrently in a different project that is looking at enabling full spectral output from RRTMG. I think it will be worth taking the time to think through what a consistent interface should look like for turning on and off various optional output.

If you're interested in roughing out a PR that handles diffuse / direct part, I think that would help nudge these efforts along @bsu-wrudisill!