noaa-oar-arl / canopy-app

Stand-alone/column canopy codes and parameterizations
MIT License
6 stars 6 forks source link

[Structure] Reorganize code/logic from canopy driver to separate submodules #23

Open drnimbusrain opened 1 year ago

drnimbusrain commented 1 year ago

Need to move and reorganize significant amount of code/logic from driver and consolidate in their own submodules. Some locations (based on current develop branch) where this is needed is as follows (with suggested module names):

1) Pull out all physical calculations to separate subroutines: canopy_griddx_mod.F90: https://github.com/noaa-oar-arl/canopy-app/blob/develop/canopy_driver.F90#L189 (Also improve the dx calculation to be dependent on grid cell lat/lon using haversine formula for distance between two points). canopy_foliage_mod.F90: https://github.com/noaa-oar-arl/canopy-app/blob/develop/canopy_driver.F90#L255 canopy_flameh_mod.F90: https://github.com/noaa-oar-arl/canopy-app/blob/develop/canopy_driver.F90#L288

2) Could also make a netcdf_io module based on NACC to read netcdf inputs: https://github.com/noaa-oar-arl/NACC/blob/master/parallel/src/netcdf_io_mod.f90 canopy_txt_io_mod.F90 (for inputting/reading text file data) canopy_netcdf_io_mod.F90 (for inputting/reading netcdf file data)

3) After Issue #22 is completed, the output creation could be moved to txt and netcdf output modules: canopy_outncf.F90: Based on NACC: https://github.com/noaa-oar-arl/NACC/blob/master/parallel/src/outncf.f90 canopy_outtxt.F90: https://github.com/noaa-oar-arl/canopy-app/blob/develop/canopy_driver.F90#L333

4) After Issue #21 is completed, anything else about choosing which things to calculate based on the config or calling computation routines could be consolidated into a subroutine to call on the inputs and config:
canopy_input_mod.F90: https://github.com/noaa-oar-arl/canopy-app/blob/develop/canopy_driver.F90#L278

@zmoon @drnimbusrain

zmoon commented 1 year ago

30 is the first go at addressing this

A future PR will further it, see these comments/threads: https://github.com/noaa-oar-arl/canopy-app/pull/30#pullrequestreview-1139759465 https://github.com/noaa-oar-arl/canopy-app/pull/30/files#r999732896 https://github.com/noaa-oar-arl/canopy-app/pull/30/files#r999774471 https://github.com/noaa-oar-arl/canopy-app/pull/30/files#r999773963 https://github.com/noaa-oar-arl/canopy-app/pull/30#issuecomment-1284532145

drnimbusrain commented 1 year ago

@zmoon I think we have at least in part addressed this organization with latest changes, and with your move from orphaned subroutines to submodules. Do you agree we should close this issue?

zmoon commented 1 year ago

There is still a bit more to do here, so let's wait to close, thanks.

drnimbusrain commented 7 months ago

@zmoon Any further insight into the notes we discussed briefly here, would be helpful before embarking on this and #32 and #21 issues to restructure code to with more streamlined/APIs, config types, modules, and CCPP interface/drivers. Thanks Zach! Just need some other comments or potential helpful code analogs to get a better start. Thanks!