-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·50 lines (39 loc) · 1.74 KB
/
Copy pathinit.sh
File metadata and controls
executable file
·50 lines (39 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -u
job_class="$1" # e.g. 's2s', 'Mask', 'Check'
set +u
### Handle environment loading ###
default_env_load_cmd=''
env_load_cmd=''
## Here are some example commands that can load the environment needed by a batch script
#module load mod_name # example load system module
#source /path/to/env_root/bin/activate # example load virtual environment
#conda activate base # example load conda environment
## Modify the two code blocks below to set default and per-script environment load commands
# Set default environment load command for all batch scripts (fallback if no specific script setting)
#default_env_load_cmd="source ~/miniforge3/bin/activate ~/miniforge3/envs/setsmenv"
# Set environment load commands specific to batch scripts
if [ "$job_class" == "s2s" ]; then
env_load_cmd="$default_env_load_cmd"
elif [ "$job_class" == "Mask" ]; then
env_load_cmd="$default_env_load_cmd"
# env_load_cmd="module load gdal/2.1.3 ; module use /mnt/pgc/data/common/repos/gdal-lerc/modules ; module load gdal-lerc/2.4.4"
elif [ "$job_class" == "Check" ]; then
env_load_cmd="$default_env_load_cmd"
elif [ "$job_class" == "Reproj" ]; then
env_load_cmd="$default_env_load_cmd"
fi
# Don't modify the following two code blocks
if [ "$env_load_cmd" == '' ] && [ "$default_env_load_cmd" != '' ]; then
echo "(Job class '${job_class}' has no specific environment load command set, so the default will be used)"
env_load_cmd=$default_env_load_cmd
fi
if [ "$env_load_cmd" != '' ]; then
echo "Loading environment with command: ${env_load_cmd}"
eval "$env_load_cmd"
env_load_status=$?
if (( env_load_status != 0 )); then
echo "Environment load failed with return code: ${env_load_status}"
exit $env_load_status
fi
fi