-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSingularity.nemo
153 lines (115 loc) · 4.31 KB
/
Singularity.nemo
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Bootstrap: localimage
From: nemo_baseOS.sif
####
##
## Authors: James Harle, National Oceanography Centre <[email protected]>
## Authors: Chris Wood, EPCC, University of Edinburgh <[email protected]>
## Date: 2021-11-30
## Last updated: 2022-01-28
##
## Definition file for building NEMO/XIOS Singularity Containers using MPICH
##
#####
%files
input_files/NEMO_in /input_files/NEMO_in
input_files/MY_SRC.tar.gz /input_files/MY_SRC.tar.gz
input_files/setup_nemo /input_files/setup_nemo
input_files/arch/nemo/arch-singularity.fcm /input_files/arch/nemo/arch-singularity.fcm
input_files/arch/xios/arch-singularity.fcm /input_files/arch/xios/arch-singularity.fcm
input_files/arch/xios/arch-singularity.env /input_files/arch/xios/arch-singularity.env
input_files/arch/xios/arch-singularity.path /input_files/arch/xios/arch-singularity.path
%post
. /input_files/NEMO_in
WORK_DIR=/nemo >> $SINGULARITY_ENVIRONMENT
cd $WORK_DIR
chown nemo:nemo -R $WORK_DIR
PATH=$PATH:/opt/mpi/install/bin:/opt/hdf5/install/bin
LD_LIBRARY_PATH=/opt/hdf5/install/lib:$LD_LIBRARY_PATH
cd $WORK_DIR
. /input_files/NEMO_in
chmod u+x /input_files/setup_nemo
/input_files/setup_nemo -x /nemo -w /nemo -s /nemo/AMM7_lite -m singularity -v $NEMO_VERSION -c gnu
cd /nemo/nemo/cfgs/NEMO/EXP00
# Need to put in here if TOP include top namelist etc
ln -s ../../SHARED/namelist_ref namelist_ref
ln -s ../../SHARED/namelist_ice_ref namelist_ice_ref
ln -s ../../SHARED/grid_def_nemo.xml grid_def_nemo.xml
ln -s ../../SHARED/field_def_nemo-oce.xml field_def_nemo-oce.xml
ln -s ../../SHARED/field_def_nemo-ice.xml field_def_nemo-ice.xml
ln -s ../../SHARED/domain_def_nemo.xml domain_def_nemo.xml
ln -s ../../SHARED/axis_def_nemo.xml axis_def_nemo.xml
cd $WORK_DIR
mkdir /opt/nemo
mv /nemo/nemo/cfgs/NEMO/EXP00/nemo /opt/nemo/
mkdir /opt/xios
mv /nemo/nemo/cfgs/NEMO/EXP00/xios_server.exe /opt/xios/xios
# make everything we've built be owned by `nemo`
chown -Rv nemo:nemo /opt
# minimal possible permissions: directories executable; binaries read + executable (need to be readable to that library headers can be read!); everything else only readable for g+o
#chmod -Rv 644 /opt
#find /opt -type d -print0 | xargs -0 chmod -v 511
#find /opt -type f -exec file -i {} + | grep ":[^:]*binary[^:]*$" | sed 's/^\(.*\):[^:]*$/\1/' | xargs chmod -v 555
# The above didn't seem to work so blanket chmod for time being
chmod -Rv 755 /opt
# Clean up
rm -rf /var/lib/apt/lists/* /var/lib/dpkg/info/*
%environment
export LD_LIBRARY_PATH=/opt/hdf5/install/lib:$LD_LIBRARY_PATH
%runscript
#!/bin/bash
# This runscript will take 2 arguments: program to run (NEMO or XIOS), and an
# output directory. By default, the output directory will be the job id
# (passed using $SLURM_JOB_ID).
echo "We start in :" $PWD
if ! [[ $1 == "nemo" || $1 == "xios" ]]
then
echo "The program argument should be either 'nemo' or 'xios'"
exit 1
fi
results_dir=$2
if [[ -z $2 ]]
then
results_dir=$SLURM_JOB_ID
fi
if [[ -z $results_dir ]]
then
echo "Please supply an output directory"
exit 1
fi
if [[ ! -d $results_dir ]]
then
mkdir $results_dir
fi
echo "Results directory is: " $results_dir
cd $results_dir
echo "We are in :" $PWD
for file in /nemo/nemo/cfgs/NEMO/EXP00/*
do
# Check if the file is already symlinked to prevent lots of spurious
# error messages
linkfile=`basename $file`
echo "linking file: " $linkfile
if ! [[ -L $linkfile ]]
then
echo $file $linkfile
ln -s $file $linkfile
fi
done
echo "done linking"
if [[ $1 == 'nemo' ]]
then
/opt/nemo/nemo
else
/opt/xios/xios
fi
%labels
Author [email protected]
Author [email protected]
Version v0.0.1
%help
The definition file used to build NEMO and XIOS:
- HDF5 (1.10.5)
- NetCDF C (4.7.1) and Fortran (4.5.2) libraries
This container
To build the container, run
singularity build nemo_mpich.sif Singularity.nemo_mpich_bootstrap