Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoahMP as a submodule in WRF #1653

Merged
merged 6 commits into from
Jan 26, 2022
Merged

Conversation

davegill
Copy link
Contributor

@davegill davegill commented Jan 25, 2022

TYPE: enhancement

KEYWORDS: NoahMP, submodule

SOURCE: Cenlin He (RAL/NCAR), internal

DESCRIPTION OF CHANGES:
This is an initial effort to include an external stand-alone repository into the
WRF system using git "submodules".

Here is the recipe, should we be interested in doing this again.

The code does not build after this initial step, as we are removing mandatory source files that are
required for the build of the physics directory.

  1. Remove the existing WRF-versions of the NoahMP source code
cd WRF/phys
git rm module_sf_noahmp_glacier.F
git rm module_sf_noahmp_groundwater.F
git rm module_sf_noahmpdrv.F
git rm module_sf_noahmplsm.F

... and the single table over which NoahMP has dominion

cd WRF/run
git rm MPTABLE.TBL
  1. Add the NoahMP repository as a submodule
cd WRF/phys
git submodule add https://github.com/NCAR/noahmp noahmp

This generates the new file WRF/.gitmodules

  1. Along with the rest of the staged files, include the SHA1 of the NoahMP repository
    as part of the what the WRF model keeps permanently.
cd WRF/phys/noahmp
git checkout release-v4.4-WRF
cd ..
git add noahmp

Right now, this is SHA1 aed82e17e95b5 from NoahMP
NCAR/noahmp@aed82e1

LIST OF MODIFIED FILES:
A .gitmodules
D phys/module_sf_noahmp_glacier.F
D phys/module_sf_noahmp_groundwater.F
D phys/module_sf_noahmpdrv.F
D phys/module_sf_noahmplsm.F
A phys/noahmp
D run/MPTABLE.TBL

The code builds after this step, which includes the mods to the build system (the variously impacted Makefiles).
LIST OF MODIFIED FILES:
M Makefile
M clean
M phys/Makefile

In the top-level WRF Makefile, the physics target now includes a pre-step
to first build the NoahMP submodule files. If the NoahMP source files exist
(the *.F files).

  • If so, then proceed as normally (they must already be linked in).
  • If the files do not exist, then
    git submodule update --init --recursive to bring in
    the NoahMP repository, and then manually link the files into the
    original WRF locations. Also, if the source files did not exist,
    assume that the NoahMP table file (MPTABLE.TBL) is also missing,
    so put that file in the run directory.

Since these files are not really part of the WRF repo anymore, we remove
them when asked for a super-duper cleaning: clean -aa. Please note that
usage of the clean -aa script removes the backup configure.wrf file.

An "if" test in the phys/Makefile detects if the NoahMP source files
exist. If not, then the git submodule command is used. The important
item is that the top-level Makefile has a submodules target that is processed
for each build.

The NoahMP files are linked into the physics directory. This emulates the existing paradigm
of putting all of the physics source into a single location. This minimizes the infrastructure
modifications, and becomes almost transparent to a casual user. Care will need to be taken
so that no files associated with NoahMP are accidentally re-incorporated back into WRF.

Considerations:
The introduction of an external repository is a complication. We choose to avoid modifying the WRF build
system, meaning that the entire physics directory must be WHOLE for a successful build. This is handled
by copying files from the NoahMP repository directory location to the WRF repository directory location.
The infrastructure has been put in place in the WRF build to copy the files to the expected WRF locations.
Therefore, starting from a clean clone and without a preceding build, a user will not find the NoahMP source
files in the physics directory. The NoahMP repository could be manually included as a submodule with the
following command:

cd WRF
git submodule update --init --recursive

However, again, until a build occurs, the files are not moved from the NoahMP repository directory structure into
the proper and expected locations in the WRF directory structure.

TESTS CONDUCTED:

  1. The code builds locally. When there are no NoahMP files, they are available with a git submodule
    command, and subsequent linking.
  2. With print statements in the Makefiles, when existing NoahMP files are detected, the submodule
    step is bypassed.
  3. If the required files are not available, an error condition is raised, and the compilation stops:
------------------------------------------------------------------------------
Error Error Error NoahMP submodule files not populating WRF directories
------------------------------------------------------------------------------
  1. When the NoahMP files are available, a message is printed to the build log:
------------------------------------------------------------------------------
NoahMP submodule files populating WRF directories
------------------------------------------------------------------------------
  1. Jenkins - all tests are pass.

RELEASE NOTE: The NoahMP external repository is now a submodule for WRF.

TYPE: enhancement

KEYWORDS: NoahMP, submodule

SOURCE: Cenlin He (RAL/NCAR), internal

DESCRIPTION OF CHANGES:
This is an initial effort to include an external stand-alone repository into the
WRF system using git "submodules".

Here is the recipe, should we be interested in doing this again. Also this serves as
a "perhaps not that way again" warning. Time will tell.

The code does not build after this initial step. We are just preparing the soil.

1. Remove the existing WRF-versions of the NoahMP source code
```
cd WRF/phys
git rm module_sf_noahmp_glacier.F
git rm module_sf_noahmp_groundwater.F
git rm module_sf_noahmpdrv.F
git rm module_sf_noahmplsm.F
```
... and the single table over which NoahMP has dominion
```
cd WRF/run
git rm MPTABLE.TBL
```
2. Add the NoahMP repository as a submodule
```
cd WRF/phys
git submodule add https://github.com/NCAR/noahmp noahmp
```
This generates the new file WRF/.gitmodules

3. Along with the rest of the staged files, include the SHA1 of the NoahMP repository
as part of the what the WRF model keeps permanently.
```
cd WRF/phys/noahmp
git checkout release-v4.4-WRF
cd ..
git add noahmp
```
Right now, this is SHA1 aed82e17e95b5 from NoahMP
NCAR/noahmp@aed82e1

LIST OF MODIFIED FILES:
A .gitmodules
D phys/module_sf_noahmp_glacier.F
D phys/module_sf_noahmp_groundwater.F
D phys/module_sf_noahmpdrv.F
D phys/module_sf_noahmplsm.F
A phys/noahmp
D run/MPTABLE.TBL

The code builds after this step, which includes the mods to the build system (the
variously impacted Makefiles).
LIST OF MODIFIED FILES:
M Makefile
M clean
M phys/Makefile

In the top-level WRF Makefile, the `physics` target now includes a pre-step
to first build the NoahMP submodule files. If the NoahMP source files exist (the *.F files)
nothing happens. If the files do not exist, then the rule is `git submodule update --init --recursive`
to bring in the NoahMP repository, and then manually link the files into the
original WRF locations. If the source files did not exist, assume that the
NoahMP table files were also missing, so put those in the run directory.

Since these files are not really part of the WRF repo anymore, we remove
them when asked for a super-duper cleaning: `clean -aa`.

The NoahMP files are linked into the physics directory. This emulates the existing paradigm
of putting all of the physics source into a single location. This minimizes the infrastructure
modifications, and becomes almost transparent to a casual user. Care will need to be taken
so that no files associated with NoahMP are accidentally re-incorporated back into WRF.

TESTS CONDUCTED:
1. The code builds locally. When there are no NoahMP files, they are available with a git submodule
command, and subsequent linking.
2. With print statements in the Makefiles, when existing NoahMP files are detected, the submodule
step is bypassed.
3. Jenkins  - all tests are pass.

RELEASE NOTE: The NoahMP external repository is now a submodule for WRF.
In the physics Makefile, before any files source files are processed,
check to see if the NoahMP source files exist (the *.F files). If so,
then proceed as normally (they must already be linked in). If the files
do not exist, then `git submodule update --init --recursive` to bring in
the NoahMP repository, and then manually link the files into the
original WRF locations. If the source files did not exist, assume that the
NoahMP table file (MPTABLE.TBL) is also missing, so put that file in the
run directory.

Since these files are not really part of the WRF repo anymore, we remove
them when asked for a super-duper cleaning: `clean -aa`.

An "if" test in the phys/Makefile detects if the NoahMP source files
exist. If not, then the git submodule command is used. The important
item is that the top-level Makefile has a submodules target that is processed
for each build.

M Makefile
M clean
M phys/Makefile
@davegill davegill requested review from a team as code owners January 25, 2022 01:29
@weiwangncar
Copy link
Collaborator

@davegill What does 'git checkout release-v4.4-WRF' do in step 3? I also tried to do 'clean -aa' from top WRF directory, it seems it does not copy configure.wrf to configure.wrf.backup. Also somewhere we need instructions for those who gets the tar file from us (or github), and how they may get the noahmp code if they don't use git, and/or don't have internet when they compile.

@davegill
Copy link
Contributor Author

@weiwangncar

What does 'git checkout release-v4.4-WRF' do in step 3?

This is the "version" of the NoahMP code that looked like what we wanted. There was also the master branch that I could have chosen. Basically, we issue the submodule, cd into the NoahMP directory, checkout the branch we want, then in the WRF repo we "git add noahmp".

I also tried to do 'clean -aa' from top WRF directory, it seems it does not copy configure.wrf to configure.wrf.backup.

The "-aa" is a clean everything possible option. So, "clean -a" would leave a configure.wrf.backup, but the "-aa" option would not. This seems OK behavior.

Also somewhere we need instructions for those who gets the tar file from us (or github), and how they may get the noahmp code if they don't use git, and/or don't have internet when they compile.

The only restriction is "no access to github". I think the best that we could do would be to trap this event, and report that the build cannot proceed without the NoahMP directory.

Make the EPS args to MP driver optional, then all is well.

M phys/module_microphysics_driver.F
@davegill
Copy link
Contributor Author

davegill commented Jan 25, 2022

Using this PR instead of NoahMP as a submodule in WRF #1646
This PR only uses LSM table MPTABLE.TBL from the NoahMP repo, and the other used four Fortran source files.

@cenlinhe
Copy link
Contributor

@davegill @weiwangncar @dudhia Did we decide to go with this solution for the v4.4 release (i.e., only use MPTABLE.TBL from NoahMP github repo)? If so, I am fine with the current solution for now. We could discuss more in the future. Just want to make sure that for the other two tables, SOILPARM.TBL and GENPARM.TBL in this current WRF repo are the same as those in the NoahMP repo (i.e., WRF is already using the updated SOILPARM.TBL and GENPARM.TBL for v4.4 release).

@davegill
Copy link
Contributor Author

@cenlinhe @weiwangncar @dudhia
Cenlin,
We are going to ONLY take MPTABLE.TBL from the NoahMP repository. Right now, because of your "first put in the NoahMP code directly", our GENPARM.TBL and SOILPARM.TBL files are identical to yours. Going forward, we are going to require that the LSM lookup table files GENPARM.TBL and SOILPARM.TBL be controlled by the WRF repository. That means we will NOT pull them from the NoahMP repository. Prior to out next annual update, the existing files are acceptable. Within the next year, you should have time to work with the NoahMP contributors and stakeholders to come up with NoahMP-specific names by your next release.

@cenlinhe
Copy link
Contributor

Sounds good!

@davegill davegill changed the title NoahMP as a submodule in WRF (3) NoahMP as a submodule in WRF Jan 25, 2022
@davegill
Copy link
Contributor Author

@weiwangncar @dudhia
Folks,
OK, this NoahMP PR is ready for a review.

weiwangncar
weiwangncar previously approved these changes Jan 26, 2022
@davegill davegill merged commit a49fe58 into wrf-model:develop Jan 26, 2022
@davegill
Copy link
Contributor Author

@CenLin @weiwangncar @dudhia
Folks,
The NoahMP submodule PR has been merged into the develop branch.

vlakshmanan-scala pushed a commit to scala-computing/WRF that referenced this pull request Apr 4, 2024
TYPE: enhancement

KEYWORDS: NoahMP, submodule

SOURCE: Cenlin He (RAL/NCAR), internal

DESCRIPTION OF CHANGES:
This is an initial effort to include an external stand-alone repository into the
WRF system using git "submodules".

Here is the recipe, should we be interested in doing this again. 

The code does not build after this initial step, as we are removing mandatory source files that are
required for the build of the physics directory.

1. Remove the existing WRF-versions of the NoahMP source code
```
cd WRF/phys
git rm module_sf_noahmp_glacier.F
git rm module_sf_noahmp_groundwater.F
git rm module_sf_noahmpdrv.F
git rm module_sf_noahmplsm.F
```
... and the single table over which NoahMP has dominion
```
cd WRF/run
git rm MPTABLE.TBL
```
2. Add the NoahMP repository as a submodule
```
cd WRF/phys
git submodule add https://github.com/NCAR/noahmp noahmp
```
This generates the new file WRF/.gitmodules

3. Along with the rest of the staged files, include the SHA1 of the NoahMP repository
as part of the what the WRF model keeps permanently.
```
cd WRF/phys/noahmp
git checkout release-v4.4-WRF
cd ..
git add noahmp
```
Right now, this is SHA1 aed82e17e95b5 from NoahMP
NCAR/noahmp@aed82e1

LIST OF MODIFIED FILES:
A .gitmodules
D phys/module_sf_noahmp_glacier.F
D phys/module_sf_noahmp_groundwater.F
D phys/module_sf_noahmpdrv.F
D phys/module_sf_noahmplsm.F
A phys/noahmp
D run/MPTABLE.TBL

The code builds after this step, which includes the mods to the build system (the variously impacted Makefiles).
LIST OF MODIFIED FILES:
M Makefile
M clean
M phys/Makefile

In the top-level WRF Makefile, the `physics` target now includes a pre-step
to first build the NoahMP submodule files. If the NoahMP source files exist 
(the *.F files). 
   * If so, then proceed as normally (they must already be linked in). 
   * If the files do not exist, then 
     `git submodule update --init --recursive` to bring in
     the NoahMP repository, and then manually link the files into the
     original WRF locations. Also, if the source files did not exist, 
     assume that the NoahMP table file (MPTABLE.TBL) is also missing, 
     so put that file in the run directory.

Since these files are not really part of the WRF repo anymore, we remove
them when asked for a super-duper cleaning: `clean -aa`. Please note that
usage of the `clean -aa` script removes the backup configure.wrf file.

An "if" test in the phys/Makefile detects if the NoahMP source files
exist. If not, then the git submodule command is used. The important
item is that the top-level Makefile has a submodules target that is processed
for each build.

The NoahMP files are linked into the physics directory. This emulates the existing paradigm
of putting all of the physics source into a single location. This minimizes the infrastructure
modifications, and becomes almost transparent to a casual user. Care will need to be taken
so that no files associated with NoahMP are accidentally re-incorporated back into WRF.

Considerations:
The introduction of an external repository is a complication. We choose to avoid modifying the WRF build 
system, meaning that the entire physics directory must be WHOLE for a successful build. This is handled 
by copying files from the NoahMP repository directory location to the WRF repository directory location.
The infrastructure has been put in place in the WRF build to copy the files to the expected WRF locations.
Therefore, starting from a clean clone and without a preceding build, a user will not find the NoahMP source 
files in the physics directory. The NoahMP repository could be manually included as a submodule with the 
following command:
```
cd WRF
git submodule update --init --recursive
```
However, again, until a build occurs, the files are not moved from the NoahMP repository directory structure into
the proper and expected locations in the WRF directory structure.

TESTS CONDUCTED:
1. The code builds locally. When there are no NoahMP files, they are available with a git submodule
command, and subsequent linking.
2. With print statements in the Makefiles, when existing NoahMP files are detected, the submodule
step is bypassed.
3. If the required files are not available, an error condition is raised, and the compilation stops:
```
------------------------------------------------------------------------------
Error Error Error NoahMP submodule files not populating WRF directories
------------------------------------------------------------------------------
```
4. When the NoahMP files are available, a message is printed to the build log:
```
------------------------------------------------------------------------------
NoahMP submodule files populating WRF directories
------------------------------------------------------------------------------
```
5. Jenkins  - all tests are pass.

RELEASE NOTE: The NoahMP external repository is now a submodule for WRF.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants