Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NoahMP as a submodule in WRF (wrf-model#1653)
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.
- Loading branch information