Closed GreyREvenson closed 1 year ago
@GreyEvenson-NOAA, please provide an illustrative title for the pull request and include a description (see https://github.com/NOAA-OWP/noah-owp-modular/pull/57 as an example, or this from CFE is even better https://github.com/NOAA-OWP/cfe/pull/62).
Next steps:
driver/
to src/
driver/
and keep original nameinitialize_from_file
, which got replaced by NoahowpReadNamelistModule
in this PRdriver/NoahowpReadNamelistModule.f90
back to src/NamelistRead.f90
NamelistRead.f90
should read the namelist and allocate the namelist variables (it should do no additional function calling or initialization, that will get wrapped into initialize_from_file
in RunModule.f90
as done previously)We also need to update the README.md file on the main level. This includes an updated link to the old Noah-MP codebase and new acknowledgments of NCAR's work on the grid routines (consistent with their license).
I believe we're ready for you to have another look, @SnowHydrology.
In my revisions to the parametersgrid_type
member variables, I tried to error on the side of including x and y dim indices as I believe you mentioned in a call that member variables that do not include x and y dim indices would be the exception rather than the rule. However, please let me know if I misunderstood.
Following all revisions to the PR, I re-ran /test/analysis/compare_outputnc.py and its output was: output_compare_outputnc.txt. I also re-ran /test/noahowp_test.exe and its output was: noahowp_test_output.txt
I clicked on the button to 'Resolve conversation' for your comments that were easy fixes with little ambiguity. However, please let me know if I should leave those conversations open or have other feedback regarding my use of github.
PURPOSE
This PR is meant accomplish the first of three steps/milestones aimed at creating a gridded version of NOAA-NWS OWP's Noah-mp model (i.e., 'Noah-owp'). Step 1 is:
Steps 2 and 3 will be accomplished via subsequent PRs. Steps 2 and 3 are:
ADDITIONS
This PR adds a series of new 'grid' derived data types, each defined in a distinct module, i.e.:
domaingrid_type
in DomainGridType.f90energygrid_type
in EnergyGridType.f90forcinggrid_type
in ForcingGridType.f90levelsgrid_type
in LevelsGridType.f90optionsgrid_type
in OptionsGridType.f90parametersgrid_type
in ParametersGridType.f90watergrid_type
in WaterGridType.f90The PR-added 'gridded' derived data types correspond the original derived data types within the Noah-owp column model, i.e.:
domaingrid_type
corresponds todomain_type
, as defined in DomainType.f90energygrid_type
corresponds toenergy_type
, as defined in EnergyType.f90forcinggrid_type
corresponds toforcing_type
, as defined in ForcingType.f90levelsgrid_type
corresponds tolevels_type
, as defined in LevelsType.f90optionsgrid_type
corresponds tooptions_type
, as defined in OptionsType.f90parametersgrid_type
corresponds toparameters_type
, as defined in ParametersType.f90watergrid_type
corresponds towater_type
, as defined in WaterType.f90The PR-added 'gridded' derived data types contain the same variable names that exist within their corresponding original derived data types (e.g., both
water_type
andwatergrid_type
have a variable namedqinsur
); however, the 'gridded' version of the variables (e.g.,qinsur
inwatergrid_type
) have x and y dimensional indices if the variable varies over those dimensions. For example,qinsur
is defined asreal,allocatable,dimension(:,:) :: qinsur
inwatergrid_type
but is defined asreal :: qinsur
inwater_type
.The PR also adds
noahowpgrid_type
to RunModule.f90.noahowpgrid_type
is composed of the new 'gridded' derived data types and thenamelist_type
, which is mostly unchanged by this PR. Thus,noahowpgrid_type
is defined as:This PR leaves the
noahowp_type
(also in Runmodule.f90) unchanged except for the exclusion of thenamelist_type
. Thus, this PR definesnoahowp_type
as:This PR also adds a series of subroutines to copy/move or 'transfer' model variable values between the 'gridded' and original versions of the derived data types, i.e.:
domaingrid_type
anddomain_type
energygrid_type
andenergy_type
forcinggrid_type
andforcing_type
levelsgrid_type
andlevels_type
optionsgrid_type
andoptions_type
parametersgrid_type
andparameters_type
watergrid_type
andwater_type
This PR also adds a new subroutine called
solve_noahowp_grid
to RunModule.f90. The primary purpose of thesolve_noahowp_grid
subroutine is to iterate over the x and y dimensions of a gridded domain, transfer model variable values that correspond to the iterated grid cell from thenoahowpgrid_type
to an instance ofnoahowp_type
via calls to transfer subroutines, then execute the Noah-owp column model for the iterated grid cell via a call to thesolve_noahowp
subroutine, and finally transfer model variable values fromnoahowp_type
back tonoahowpgrid_type
.CHANGES
This PR modifies the
initialize_from_file
subroutine in RunModule.f90 to initialize an instance ofnoahowpgrid_type
. Previous to this PR, theinitialize_from_file
subroutine instead initialized an instance ofnoahowp_type
. The PR-modifiedinitialize_from_file
subroutine first reads namelist.input via a call tonamelist%ReadNamlist
(i.e.,call namelist%ReadNamelist(config_filename)
). Theinitialize_from_file
subroutine then makes a series of calls to type-bound initialization subroutines and subroutines that transfer namelist.input values tonoahowpgrid_type
and its member derived data types, i.e.:After initializing and transfering namelist.input varaible values to
noahowpgrid_type
, the PR-modifiedinitialize_from_file
subroutine tracks closely with the pre-PRinitialize_from_file
subroutine, i.e.: it initializes important model variables to zero, sets time variables, opens the input forcing file, and finally initializes the output.nc file.This PR removes initialization and transfer subroutines that were previously used to initialize and then transfer namelist.input variable values to
noahowp_type
. These subroutines were recycled/extended to initialize and then transfer namelist.input values tonoahowpgrid_type
instead and are now type-bound subroutines within each of the 'gridded' derived data types, i.e.:domaingrid_type%InitTransfer
in DomainGridType.f90energygrid_type%InitTransfer
in EnergyGridType.f90forcinggrid_type%InitTransfer
in ForcingGridType.f90levelsgrid_type%InitTransfer
in LevelsGridType.f90watergrid_type%InitTransfer
in WaterGridType.f90domaingrid_type%InitTransfer
in DomainGridType.f90This PR adds x and y dimensions to output.nc via modifications to OutputModule.f90.
This PR updates /test/analysis/noahowp_driver_test.f90 to work on the PR-modified code base as a means of testing the PR additions and changes (see TESTING section).
TESTING
The PR-modified Noah-owp model was successfully compiled on MacOS using GNU Fortran (Homebrew GCC 13.1.0) 13.1.0. Then, two tests were completed:
A python script (compare_outputnc.py) was created to read-in the PR-modified model's output netcdf file (which gives output for every grid cell) as well as the output netcdf file from a clean build of the Noah-owp column model. The script checks that output for every grid cell in the PR-modified model matches the output given by the clean build for every time step and every variable in output.nc. As this PR assumes a homogenous grid, the output from every grid cell should be the same and match that of the column model, assuming the same namelist.input is used to initialize. The output from the py script is output_compare_outputnc.txt
noahowp_driver_test.f90 was updated to work with the PR-modified code base. The output from the test program is test_output.txt
NOTES
Concern regarding performance: The general architectural approach of this PR is to have an object/type hold all model variables across the x, y, and z dimensions. For each time step, the grid is iterated in x and y dimensions, the iterated grid cell's values are transferred to a column model object/type, the column model is executed, then the model variables are transferred back to the grid object/type before moving to the next grid cell. This is the approach employed by NCAR's NoahmpDriverMainMod.f90 (in HRLDAS). This architectural approach requires a lot of copying/moving of variable values. Parallel processing should improve performance.
All model variables are included in the transfer subroutines to be on safe side. However, we could improve performance by commenting out / removing variables that are being unnecessarily transferred in these subroutines?
./EtFluxModule.f90, line 708:
energy%LATHEA
was changed toenergy%LATHEAV
becauseenergy%LATHEA
was set to huge(1.) and causing arithmetic error. Is this change acceptable/scientifically valid?Checklist