Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
410 changes: 355 additions & 55 deletions scripts/0.run_all.bash

Large diffs are not rendered by default.

176 changes: 125 additions & 51 deletions scripts/1.install_monan.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,51 @@ umask 022
#
#-----------------------------------------------------------------------------#

#Fixed parameters ------------------------------------------------------------#
github_link_CONVERT_MPAS="https://github.com/monanadmin/convert_mpas.git"
#-----------------------------------------------------------------------------#

#--- Function that shows usage.
function show_usage() {
echo " Usage: "
echo ""
echo " ${0} [-h] [-m12] [-bc TAG_CONVERT_MPAS] [-bm TAG_MONAN] [-gm GIT_MONAN] \\"
echo " [-gc GIT_CONVERT_MPAS]"
echo ""
echo " List of optional flags: "
echo ""
echo " -h -- Shows this message."
echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches derived"
echo " from this version (e.g., feature/monan-757-NF)? This is a"
echo " temporary flag that will be removed once the versions"
echo " containing Noah-MP are merged into the new release. This"
echo " allows the script to manage older code and still run on jaci."
echo ""
echo " List of **required** flags: "
echo ""
echo " -bc TAG_CONVERT -- branch or tag name of the MONAN repository. For example:"
echo " \"develop\"."
echo " -bm TAG_MONAN -- branch or tag name of the MONAN repository. For example:"
echo " \"develop\"."
echo " -gc GIT_CONVERT -- GitHub handle for MONAN. For example:"
echo " https://github.com/monanadmin/MONAN-Model.git"
echo " -gm GIT_MONAN -- GitHub handle for MONAN. For example:"
echo " https://github.com/monanadmin/MONAN-Model.git"
echo ""
}
#---~---




#Functions -------------------------------------------------------------------#
function checkout_system() {
local source_dir=$1
local github_link=$2
local tag_or_branch_name=$3
if [ -d "${source_dir}" ]; then
if [[ -d "${source_dir}" ]]; then
echo -e "${GREEN}==>${NC} Source dir already exists, updating it ...\n"
else
echo -e "${GREEN}==>${NC} Cloning your fork repository...\n"
git clone ${github_link} ${source_dir}
if [ ! -d "${source_dir}" ]; then
if [[ ! -d "${source_dir}" ]]; then
echo -e "${RED}==>${NC} An error occurred while cloning your fork. Possible causes: wrong URL, user or password.\n"
exit -1
fi
Expand All @@ -51,48 +81,91 @@ function checkout_system() {
#-----------------------------------------------------------------------------#


if [ $# -lt 1 ]
#---~---
# Retrieve configuration.
#---~---
#--- Default settings (all empty)
MONAN_ONETWO=""
github_link_MONAN=""
tag_or_branch_name_MONAN=""
github_link_CONVERT_MPAS=""
tag_or_branch_name_CONVERT_MPAS=""
#---~---


#---~---
# Parse arguments
#---~---
while [[ ${#} > 0 ]]
do
key="${1}"
case ${key} in
-bc)
tag_or_branch_name_CONVERT_MPAS="${2}"
shift 2 # past flag and argument
;;
-bm)
tag_or_branch_name_MONAN="${2}"
shift 2 # past flag and argument
;;
-gc)
github_link_CONVERT_MPAS="${2}"
shift 2 # past flag and argument
;;
-gm)
github_link_MONAN="${2}"
shift 2 # past flag and argument
;;
-h)
show_usage
exit 0
;;
-m12)
MONAN_ONETWO="${key}"
shift 1 # past flag
;;
*)
echo ""
echo " Option \"${key}\" is not valid."
echo ""
show_usage
echo ""
echo " *** FATAL ERROR! ***"
echo " Unknown key or key-value argument pair."
echo ""
exit 2
;;
esac
done
#---~---

#---~---
# Make sure all required settings were provided.
#---~---
if [[ "${tag_or_branch_name_CONVERT_MPAS}" == "" ]] ||
[[ "${tag_or_branch_name_MONAN}" == "" ]] ||
[[ "${github_link_CONVERT_MPAS}" == "" ]] ||
[[ "${github_link_MONAN}" == "" ]]
then
echo ""
echo "Instructions: execute the command below"
echo ""
echo "${0} [G] [M] [C]"
echo ""
echo "G :: MONAN GitHub link of your personal fork, eg: https://github.com/MYUSER/MONAN-Model.git"
echo "M :: MONAN tag or branch name of your personal fork. (will be used 'develop' if not informed)"
echo "C :: Convert_MPAS tag from ${github_link_CONVERT_MPAS} (will be used 'develop' if not informed)"
echo ""
exit
echo " This script requires arguments to be set through flags."
show_usage
exit 2
fi
#---~---


# Set environment variables exports:
echo ""
echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n"
. setenv.bash
#--- Set environment variables exports:
. setenv.bash ${MONAN_ONETWO}
#---~---

echo ""
echo "---- Installing the Model ----"
echo ""

# Standart directories variables:---------------------------------------
DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES}
DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED}
SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS}
DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN}
DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT}
SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES}
EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS}
#----------------------------------------------------------------------


# Input variables:-----------------------------------------------------
github_link_MONAN=${1}; #github_link=https://github.com/monanadmin/MONAN-Model.git
tag_or_branch_name_MONAN=${2}
tag_or_branch_name_MONAN=${tag_or_branch_name_MONAN:="1.4.3-rc"}
echo "MONAN branch name in use: ${tag_or_branch_name_MONAN}"

tag_or_branch_name_CONVERT_MPAS=${3}
tag_or_branch_name_CONVERT_MPAS=${tag_or_branch_name_CONVERT_MPAS:="1.2.0"}
tag_or_branch_name_MONAN=${tag_or_branch_name_MONAN:="release/1.4.3-rc"}
tag_or_branch_name_CONVERT_MPAS=${tag_or_branch_name_CONVERT_MPAS:="release/1.2.0"}
echo "convert_mpas branch name in use: ${tag_or_branch_name_CONVERT_MPAS}"
#----------------------------------------------------------------------

Expand All @@ -105,7 +178,7 @@ CONVERT_MPAS_DIR=${SOURCES}/convert_mpas_${tag_or_branch_name_CONVERT_MPAS}
#$(sed -i "s;DIR_DADOS=.*$;DIR_DADOS=$(dirname $(dirname $(pwd)));" setenv.bash)
$(sed -i "s;MONANDIR=.*$;MONANDIR=$MONANDIR;" setenv.bash)
chmod 755 ${SCRIPTS}/setenv.bash
. ${SCRIPTS}/setenv.bash
. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO}

#----------------------------------------------------------------------

Expand Down Expand Up @@ -134,22 +207,23 @@ echo "*"
echo "********************************************************************************"

echo ""
echo -e "${GREEN}==>${NC} github_link_MONAN = ${github_link_MONAN}"
echo -e "${GREEN}==>${NC} tag_or_branch_name_MONAN = ${tag_or_branch_name_MONAN}"
echo ""
read -p "Are you sure you are installing the right versions scripts x MONAN-Model ? [Y/n]" confirma
confirma=${confirma:-Y}

if [[ "${confirma}" =~ ^[Yy]$ ]]
then
read -p "Are you sure you are installing the right versions scripts x MONAN-Model ? [Y/n] " confirma
confirma=$(echo ${confirma:-Y} | tr [:upper:] [:lower:])
case "${confirma}" in
y|yes)
echo ""
echo -e "${GREEN}==>${NC} OK, so keep going."
echo -e "${GREEN}==>${NC} OK, proceeding to installation."
echo ""
else
;;
*)
echo ""
echo -e " ${RED}==>${NC} Please, make the right versions and try again."
exit
echo ""
fi
esac


checkout_system ${MONANDIR} ${github_link_MONAN} ${tag_or_branch_name_MONAN}
Expand Down Expand Up @@ -200,7 +274,7 @@ cat << EOF > make-all.sh
# SHAREDLIB=true - generate position-independent code suitable for use in a shared library. Default is false.

cd ${SCRIPTS}
. ${SCRIPTS}/setenv.bash
. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO}
cd $MONANDIR

rm -rf $MONANDIR/default_inputs/ $MONANDIR/src/core_atmosphere/physics/physics_wrf/files
Expand Down Expand Up @@ -244,7 +318,7 @@ mv ${MONANDIR}/init_atmosphere_model ${EXECS}
make clean CORE=init_atmosphere


if [ -s "${EXECS}/init_atmosphere_model" ] && [ -e "${EXECS}/atmosphere_model" ]; then
if [[ -s "${EXECS}/init_atmosphere_model" ]] && [[ -e "${EXECS}/atmosphere_model" ]]; then
echo ""
echo -e "${GREEN}==>${NC} Files init_atmosphere_model and atmosphere_model generated Successfully in ${EXECS} !"
echo
Expand All @@ -261,14 +335,14 @@ echo -e "${GREEN}==>${NC} Installing init_atmosphere_model and atmosphere_model
echo ""
. ${MONANDIR}/make-all.sh

if [ "$HOSTNAME" == "ian" ]; then
if [[ "$HOSTNAME" == "ian" ]]; then
# echo "hostname=$HOSTNAME"
export PATH=$NETCDF/bin:$PATH
fi

# install convert_mpas
echo ""
echo -e "${GREEN}==>${NC} Moduling environment for convert_mpas...\n"
echo -e "${GREEN}==>${NC} Loading modules needed by convert_mpas...\n"

cd ${CONVERT_MPAS_DIR}
make clean
Expand All @@ -279,7 +353,7 @@ mv ${CONVERT_MPAS_DIR}/convert_mpas ${EXECS}/
cp ${CONVERT_MPAS_DIR}/VERSION.txt ${EXECS}/CONVMPAS-VERSION.txt


if [ -s "${EXECS}/convert_mpas" ] ; then
if [[ -s "${EXECS}/convert_mpas" ]] ; then
echo ""
echo -e "${GREEN}==>${NC} File convert_mpas generated Sucessfully in ${CONVERT_MPAS_DIR} and copied to ${EXECS} !"
echo
Expand Down
Loading