forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c44896f
commit f28bb09
Showing
3 changed files
with
35 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,43 @@ | ||
#!/bin/bash | ||
# Script to fetch submodules for CTSM | ||
# if argument -internal-only is supplied then only checkout CTSM internal submodules, otherwise checkout everything needed for | ||
# CTSM as a top level repository | ||
# | ||
# Script to fetch submodules for NCAR EARTH SYSTEM MODELS | ||
# | ||
set -e | ||
script="install" | ||
function usage { | ||
echo -e "\nusage: $script [-i/--internal-only]\n" | ||
} | ||
# Set default arguments | ||
internal_only=0 | ||
|
||
# Process arguments | ||
while [ "$1" != "" ]; | ||
do | ||
case $1 in | ||
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } | ||
|
||
# Only checkout CISM internal submodules | ||
-i | -internal-only | --internal-only) | ||
internal_only=1 | ||
;; | ||
|
||
*) | ||
echo "$script: illegal option $1" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
# Function to install git-fleximod (uncomment only one option) | ||
function install_git_fleximod() { | ||
# -- Option 1: Install from PyPI using pip | ||
pip install fleximod | ||
# -- Option 2: Install from conda-forge using conda | ||
# conda install -c conda-forge git-fleximod | ||
# -- Option 3: Install from GitHub (adjust URL and path if needed) | ||
# git clone https://github.com/jedwards4b/git-fleximod.git | ||
# cd git-fleximod | ||
# pip install | ||
} | ||
|
||
######################## | ||
|
||
submodules=('src/fates') | ||
|
||
for mod in "${submodules[@]}" | ||
do | ||
echo "Initializing $mod" | ||
git submodule update --init $mod | ||
done | ||
|
||
if [ ${internal_only} -eq 1 ] | ||
then | ||
exit 0 | ||
dir=$(git rev-parse --show-toplevel) | ||
|
||
# Check if git-fleximod is in the path and get its version | ||
if command -v git-fleximod >/dev/null 2>&1; then | ||
gfversion=$(git-fleximod --version) | ||
echo "git-fleximod version: $version" | ||
# Check if the version is acceptable (adjust the logic as needed) | ||
|
||
if [ $(version $gfversion) -ge $(version "0.1.7") ]; then | ||
echo "git-fleximod is already installed and at an acceptable version." | ||
else | ||
echo "Installed git-fleximod version is too old. Updating..." | ||
install_git_fleximod # Call the install function | ||
fi | ||
else | ||
echo "git-fleximod is not installed. Installing..." | ||
install_git_fleximod # Call the install function | ||
fi | ||
|
||
|
||
extra_submodules=('cime' 'components/rtm' 'components/mosart' \ | ||
'components/mizuRoute' 'ccs_config' 'components/cmeps' \ | ||
'components/cdeps' 'components/cpl7' 'share' 'libraries/mct' \ | ||
'libraries/parallelio' 'doc/doc-builder') | ||
|
||
for mod in "${extra_submodules[@]}" | ||
do | ||
echo "Initializing $mod" | ||
git submodule update --init --recursive $mod | ||
done | ||
|
||
# cism needs special handling | ||
git submodule update --init components/cism | ||
pushd components/cism 1>/dev/null | ||
./install -internal-only | ||
pushd ${dir} 1>/dev/null | ||
git fleximod install "$@" | ||
popd 1>/dev/null |