Skip to content

Commit

Permalink
Merge pull request #1 from mandresm/ncn_submodule_and_configure
Browse files Browse the repository at this point in the history
Ncn submodule and configure
  • Loading branch information
pgierz authored May 22, 2024
2 parents 7a47560 + 75aa60b commit c504b1e
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lib/ruby
lib/ruby/gems
.bundle
.paths
build
bin/ncn
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "gitmodules/ncn"]
path = gitmodules/ncn
url = https://github.com/hegish/ncn
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,25 @@ There is an autocompletion file for bash and zsh which can besourced to get auto

# Install Notes

## Automatic installation

If the environment scripts are already available for the machine you are using you'll
be able to run the following to automatically install seamore and build its
dependencies:

```
./configure.sh
```

Before starting using `bin/seamore` make sure you execute:

```
source env.sh
```

Machines that support this type of installation
- Albedo

## In case there is no ruby available

```
Expand All @@ -205,7 +224,7 @@ make -j `nproc --all`
make install
```

## seamore
## Manual installation of seamore

```
cd /path/seamore && bundle install
Expand Down
34 changes: 34 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -e

MY_PATH="$(dirname -- "${BASH_SOURCE[0]}")"
cd ${MY_PATH}

# Local installation
BUNDLE_PATH=${BUNDLE_PATH:-"lib"}
mkdir -p ${BUNDLE_PATH}
BUNDLE_PATH=$(realpath ${BUNDLE_PATH})

touch .paths
source env.sh

RUBY_VERSION=$(ruby --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "export GEM_PATH=\${GEM_PATH}:${BUNDLE_PATH}/ruby/${RUBY_VERSION}" > ./.paths
echo "export PATH=\${PATH}:$(realpath bin)" >> ./.paths

echo "Installing bundle"
bundle config set --local path "lib"
bundle install
gem install --install-dir ${BUNDLE_PATH}/ruby/${RUBY_VERSION} gli

echo "Downloading submodules"
git submodule update --init

echo "Installing ncn"
mkdir -p build/ncn
source gitmodules/ncn/env.sh
cd build/ncn
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ../../gitmodules/ncn
make
cp ncn ../../bin
107 changes: 107 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env bash

# - - -
# # synopsis
# determine which environment directory is to be used for the current host
# # usage
# *source* to silently source the environment for this host system
# *execute* to print the environment directory for this host system
# - - -


# see if we are being sourced or executed
# as we use bash to execute (see shebang), BASH_SOURCE is set when executing
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
BEING_EXECUTED=true
else
BEING_EXECUTED=false
fi

if [ -n "$BASH_VERSION" ]; then
# assume bash
SOURCE="${BASH_SOURCE[0]}"
elif [ -n "$ZSH_VERSION" ]; then
# assume zsh
SOURCE=${(%):-%N}
fi

DIR="$( cd "$( dirname "${SOURCE}" )" && pwd )"

# if an arg is given and doesn't start with - use it as hostname, arguments stating with - are passed on later to cmake
if [[ -z "$1" ]] || [[ "$1" =~ ^- ]]; then
# no argument given
LOGINHOST="$(hostname -f)"
else
LOGINHOST=$1 # 1st arg exists and doesn't start with -, meaning it is machine specification
shift # pop the argument as we already stored it, remaining arguments are passed to cmake
fi


if [[ $LOGINHOST =~ ^m[A-Za-z0-9]+\.hpc\.dkrz\.de$ ]]; then
STRATEGY="mistral.dkrz.de"
elif [[ $LOGINHOST =~ ^levante ]] || [[ $LOGINHOST =~ ^l[:alnum:]+\.lvt\.dkrz\.de$ ]]; then
STRATEGY="levante.dkrz.de"
# following regex only matches if input is 2 word like levante.nvhpc, this enables using different shells for a machine directly
compid_regex="^([[:alnum:]]+)\.([[:alnum:]]+)$"
if [[ $LOGINHOST =~ $compid_regex ]]; then
COMPILERID="${BASH_REMATCH[2]}"
fi
elif [[ $LOGINHOST =~ ^ollie[0-9]$ ]] || [[ $LOGINHOST =~ ^prod-[0-9]{4}$ ]]; then
STRATEGY="ollie"
elif [[ $LOGINHOST =~ ^albedo[0-9]$ ]] || [[ $LOGINHOST =~ ^prod-[0-9]{4}$ ]]; then
STRATEGY="albedo"
elif [[ $LOGINHOST =~ ^h[A-Za-z0-9]+\.hsn\.hlrn\.de$ ]]; then
STRATEGY="hlogin.hlrn.de"
elif [[ $LOGINHOST =~ ^b[A-Za-z0-9]+\.hsn\.hlrn\.de$ ]]; then
STRATEGY="blogin.hlrn.de"
elif [[ $LOGINHOST =~ \.hww\.de$ ]] || [[ $LOGINHOST =~ ^nid[0-9]{5}$ ]]; then
STRATEGY="hazelhen.hww.de"
elif [[ $LOGINHOST =~ \.jureca$ ]]; then
STRATEGY="jureca"
elif [[ $LOGINHOST = ubuntu ]]; then
STRATEGY="ubuntu"
elif [[ $LOGINHOST = bsc ]]; then
STRATEGY="bsc"
elif [[ $LOGINHOST =~ ^juwels[0-9][0-9].ib.juwels.fzj.de$ ]]; then
STRATEGY="juwels"
elif [[ $LOGINHOST =~ ^jwlogin[0-9][0-9].juwels$ ]]; then
STRATEGY="juwels"
elif [[ $LOGINHOST =~ ^cc[a-b]+-login[0-9]+\.ecmwf\.int$ ]]; then
STRATEGY="ecaccess.ecmwf.int"
elif [[ $LOGINHOST =~ ^stco-esl[0-9]+$ ]]; then
STRATEGY="aleph"
elif [[ $LOGINHOST =~ ^[A-Za-z0-9]+\.ecmwf\.int$ ]]; then
STRATEGY="wsecmwf"
elif [[ $LOGINHOST =~ \.bullx$ ]]; then
STRATEGY="atosecmwf"
elif [[ $LOGINHOST =~ uan[0-9][0-9] ]]; then
STRATEGY="lumi"
elif [[ -d $DIR/env/$LOGINHOST ]]; then # check if directory with LOGINHOST exists in env
STRATEGY=$LOGINHOST
else
echo "can not determine environment for host: "$LOGINHOST
echo "To quickly add a new environment create a directory $DIR/env/$LOGINHOST with a shell file with instructions to find compiler, dependencies and runtime settings."
[ $BEING_EXECUTED = true ] && exit 1
return # if we are being sourced, return from this script here
fi


if [ $BEING_EXECUTED = true ]; then
# file is being executed, why is this here?
echo $DIR/env/$STRATEGY
else
# file is being sourced
export FESOM_PLATFORM_STRATEGY=$STRATEGY
SHELLFILE="${DIR}/env/${STRATEGY}/shell"
if [[ -n ${COMPILERID} ]]; then
SHELLFILE="${SHELLFILE}.${COMPILERID}"
fi
if [[ ! -e ${SHELLFILE} ]]; then
echo "Shell file for ${LOGINHOST} doesnt exist: "$SHELLFILE
exit 1
fi
echo "Sourcing $(realpath $SHELLFILE) for environment"
source $SHELLFILE
fi

source ./.paths
2 changes: 2 additions & 0 deletions env/albedo/shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module load ruby/3.1.0

1 change: 1 addition & 0 deletions gitmodules/ncn
Submodule ncn added at 23a14d

0 comments on commit c504b1e

Please sign in to comment.