-
Notifications
You must be signed in to change notification settings - Fork 12
468 lines (394 loc) · 18.7 KB
/
check_stella.yml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# Run these tests automatically on Github on every push and pull request.
# Use the macOS operating system, which has 4 cores.
name: Check stella
on: [push, pull_request]
# We always run in a bash shell
defaults:
run:
shell: bash
# First build stella, and then perform python tests
jobs:
#-----------------------------------------------------------------------
# Build stella on different operating systems
#-----------------------------------------------------------------------
build-stella:
# Set environment variables
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
# Run the same set-up multiple times
# Note that macos-12 has been deprecated on GitHub in 2025
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
compiler: [Make, CMake]
# Operating system
runs-on: ${{ matrix.os }}
# Steps
steps:
# Set environment variables as echo "{name}={value}" >> $GITHUB_ENV
- name: Set environment variables
run: |
# Set environment variables
if [ ${{ matrix.os }} == 'macos-12' ] || [ ${{ matrix.os }} == 'macos-13' ]; then
echo "Set STELLA_SYSTEM = macos"
echo "STELLA_SYSTEM=macos" >> $GITHUB_ENV
echo "Set FFTW_LIB_DIR = /usr/local/Cellar/fftw/3.3.10_1/lib/"
echo "FFTW_LIB_DIR=/usr/local/Cellar/fftw/3.3.10_1/lib/" >> $GITHUB_ENV
echo "Set FFTW_INC_DIR = /usr/local/include/"
echo "FFTW_INC_DIR=/usr/local/include/" >> $GITHUB_ENV
echo "Set NETCDF_LIB_DIR = /usr/local/lib -L/usr/local/Cellar/netcdf-fortran/4.6.1_1/lib/"
echo "NETCDF_LIB_DIR=/usr/local/lib -L/usr/local/Cellar/netcdf-fortran/4.6.1_1/lib/" >> $GITHUB_ENV
echo "Set NETCDF_INC_DIR = /usr/local/Cellar/netcdf-fortran/4.6.1_1/include/"
echo "NETCDF_INC_DIR=/usr/local/Cellar/netcdf-fortran/4.6.1_1/include/" >> $GITHUB_ENV
elif [ ${{ matrix.os }} == 'macos-14' ]; then
echo "Set STELLA_SYSTEM = macos"
echo "STELLA_SYSTEM=macos" >> $GITHUB_ENV
echo "Set FFTW_LIB_DIR = /opt/homebrew/Cellar/fftw/3.3.10_1/lib/"
echo "FFTW_LIB_DIR=/opt/homebrew/Cellar/fftw/3.3.10_1/lib/" >> $GITHUB_ENV
echo "Set FFTW_INC_DIR = /opt/homebrew/include/"
echo "FFTW_INC_DIR=/opt/homebrew/include/" >> $GITHUB_ENV
echo "Set NETCDF_LIB_DIR = /opt/homebrew/lib -L/opt/homebrew/Cellar/netcdf-fortran/4.6.1_1/lib/"
echo "NETCDF_LIB_DIR=/opt/homebrew/lib -L/opt/homebrew/Cellar/netcdf-fortran/4.6.1_1/lib/" >> $GITHUB_ENV
echo "Set NETCDF_INC_DIR = /opt/homebrew/Cellar/netcdf-fortran/4.6.1_1/include/"
echo "NETCDF_INC_DIR=/opt/homebrew/Cellar/netcdf-fortran/4.6.1_1/include/" >> $GITHUB_ENV
elif ${{ contains(matrix.os, 'ubuntu') }}; then
echo "Set STELLA_SYSTEM = gnu_ubuntu"
echo "STELLA_SYSTEM=gnu_ubuntu" >> $GITHUB_ENV
fi
# Install dependencies
- name: Install dependencies
run: |
# Install dependencies
if ${{ contains(matrix.os, 'macos') }}; then
brew install gcc@11 make openmpi fftw netcdf-fortran gnu-sed
if [ ${{ matrix.os }} == 'macos-12' ] || [ ${{ matrix.os }} == 'macos-13' ]; then
sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
sudo mkdir /usr/local/gfortran; sudo ln -s /usr/local/Cellar/gcc@11/*/lib/gcc/11 /usr/local/gfortran/lib
elif [ ${{ matrix.os }} == 'macos-14' ]; then
sudo ln -s /opt/homebrew/bin/gfortran-11 /opt/homebrew/bin/gfortran
fi
elif ${{ contains(matrix.os, 'ubuntu') }}; then
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
if [ ${{ matrix.os }} == 'ubuntu-24.04' ]; then sudo apt install -y libblas-dev liblapack-dev; fi
fi
# Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4
# Print system information
- name: System information
run: |
if ${{ contains(matrix.os, 'macos') }}; then
echo " "; echo "System information:"; echo "$(system_profiler SPHardwareDataType | sed 's/^/ /')"
echo " "; echo "Gfortran version:"; echo "$(gfortran --version | sed 's/^/ /')"
echo " "; echo "Clang version:"; echo "$(clang --version | sed 's/^/ /')"
make numerical-tests-system
elif ${{ contains(matrix.os, 'ubuntu') }}; then
echo " "; echo "System information:"; echo "$(cat /etc/*release | sed 's/^/ /')"
echo " "; echo "Number of cores:"; echo "$(lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)' | sed 's/^/ /')"
echo " "; echo "Gfortran version:"; echo "$(gfortran --version | sed 's/^/ /')"
echo " "; echo "Netcdf version:"; echo "$(nf-config --all | sed 's/^/ /')"
make numerical-tests-system
fi
# Build stella executable
- name: Build stella
run: |
# Check system variables needed for Make
if ${{ contains(matrix.os, 'macos') }}; then
echo " "; echo "System variables:"
echo " FFTW_LIB_DIR = $FFTW_LIB_DIR"
echo " FFTW_INC_DIR = $FFTW_INC_DIR"
echo " NETCDF_LIB_DIR = $NETCDF_LIB_DIR"
echo " NETCDF_INC_DIR = $NETCDF_INC_DIR"
fi
# Download the submodules
echo " "; echo "Download submodules:"
git submodule update --init --recursive
# Build stella with Make or CMake
echo " "; echo "Build stella with ${{ matrix.compiler }}:"
if [ ${{ matrix.compiler }} == 'Make' ]; then
make -j 4
fi
if [ ${{ matrix.compiler }} == 'CMake' ]; then
cmake . -B COMPILATION/build_cmake
cmake --build COMPILATION/build_cmake -j 4
fi
# Check $GITHUB_WORKSPACE
- name: Check Github Workspace
if: success() || failure()
run: |
echo " "; echo "Running directory:"; echo " $(pwd)"
echo " "; echo "Files in directory:"; echo "$(ls -la | sed 's/^/ /')"
# Location of packages
- name: Location of packages
if: success() || failure()
run: |
if [ ${{ matrix.compiler }} == 'CMake' ]; then
echo " "; echo "--------- DIRECTORIES OF PACKAGES ----------"
cat COMPILATION/build_cmake/CMakeCache.txt
fi
if [ ${{ matrix.compiler }} == 'Make' ]; then
echo " "; echo "Check the CMake compilation for the location of the packages."
fi
# Install python environment
- name: Install python virtual environment
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then
python3 -m venv AUTOMATIC_TESTS/venv
source AUTOMATIC_TESTS/venv/bin/activate
pip3 install -r AUTOMATIC_TESTS/requirements.txt
else
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
fi
if ${{ contains(matrix.os, 'macos') }}; then
gsed -i 's/nproc = 16/nproc = 4/g' AUTOMATIC_TESTS/config.ini
fi
# Perform python tests
- name: Python tests 1 - Does stella run
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-1
- name: Python tests 2 - Geometry
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-2
- name: Python tests 3 - Gyrokinetic equation
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-3
- name: Python tests 4 - Flux tube
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-4
- name: Python tests 5 - Diagnostics
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-5
- name: Python tests 6 - Full Flux Surface
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-6
- name: Python tests 7 - Electromagnetic effects
if: success() || failure()
run: |
if [ ${{ matrix.os }} == 'ubuntu-24.04' ] || [ ${{ matrix.os }} == 'macos-14' ]; then source AUTOMATIC_TESTS/venv/bin/activate; fi
make numerical-tests-7
#-----------------------------------------------------------------------
# Quick build
#-----------------------------------------------------------------------
# Build stella to perform python and fortran tests
build-stella-quick:
name: Build stella quickly
runs-on: ubuntu-22.04
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu
steps:
# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4
# Install dependencies
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
# Build stella executable
- name: Build stella
run: |
git submodule update --init --recursive
make -j 12
# Stella is bugged when compiling without the flag debug = on
# So the python tests will break when compiling with CMake
#cmake . -B COMPILATION/build_cmake
#cmake --build COMPILATION/build_cmake -j 4
# Upload stella
- name: Upload stella
uses: actions/upload-artifact@v4
with:
name: stella-executable
path: stella
retention-days: 1
#-----------------------------------------------------------------------
# Python tests
#-----------------------------------------------------------------------
# Perform python tests one by one
python-tests:
runs-on: ubuntu-22.04
needs: build-stella-quick
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu
# Run the same set-up multiple times
strategy:
fail-fast: false
matrix:
config:
- name: "1 - Does stella run "
- name: "2 - Geometry"
- name: "3 - Gyrokinetic equation"
- name: "4 - Flux tube"
- name: "5 - Diagnostics"
- name: "6 - Full Flux Surface"
- name: "7 - Electromagnetic effects"
steps:
# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4
# Install dependencies
- name: Install dependencies and python virtual environment
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
sed -i 's/nproc = 16/nproc = 4/g' AUTOMATIC_TESTS/config.ini
# Download stella executable from previous job
- name: Download stella
uses: actions/download-artifact@v4
with:
name: stella-executable
# Perform python tests
- name: Numerical python tests
run: |
# Make stella executable
chmod +x stella
# Run one of the python tests
if ${{ contains(matrix.config.name, '1 -') }}; then make numerical-tests-1; fi
if ${{ contains(matrix.config.name, '2 -') }}; then make numerical-tests-2; fi
if ${{ contains(matrix.config.name, '3 -') }}; then make numerical-tests-3; fi
if ${{ contains(matrix.config.name, '4 -') }}; then make numerical-tests-4; fi
if ${{ contains(matrix.config.name, '5 -') }}; then make numerical-tests-5; fi
if ${{ contains(matrix.config.name, '6 -') }}; then make numerical-tests-6; fi
if ${{ contains(matrix.config.name, '7 -') }}; then make numerical-tests-7; fi
# Perform python on 1 processor.
python-tests-nproc1:
name: Python tests on 1 processor
runs-on: ubuntu-22.04
needs: build-stella-quick
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu
steps:
# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4
# Install dependencies
- name: Install dependencies and python virtual environment
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
sed -i 's/nproc = 16/nproc = 1/g' AUTOMATIC_TESTS/config.ini
# Download stella executable from previous job
- name: Download stella
uses: actions/download-artifact@v4
with:
name: stella-executable
# Make stella executable
- name: Make stella executable
run: chmod +x stella
# Perform python tests
- name: Python tests 1 - Does stella run
run: make numerical-tests-1
- name: Python tests 2 - Geometry
if: success() || failure()
run: make numerical-tests-2
- name: Python tests 3 - Gyrokinetic equation
if: success() || failure()
run: make numerical-tests-3
- name: Python tests 4 - Flux tube
if: success() || failure()
run: make numerical-tests-4
- name: Python tests 5 - Diagnostics
if: success() || failure()
run: make numerical-tests-5
- name: Python tests 6 - Full Flux Surface
if: success() || failure()
run: make numerical-tests-6
- name: Python tests 7 - Electromagnetic effects"
if: success() || failure()
run: make numerical-tests-7
#-----------------------------------------------------------------------
# Fortran tests
#-----------------------------------------------------------------------
fortran-tests:
runs-on: ubuntu-22.04
name: "Automated Fortran tests"
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu
steps:
# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4
# Install dependencies
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev netcdf-bin
sudo apt install -y python3 python3-pip openmpi-bin libopenmpi-dev libblas-dev liblapack-dev
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
# Build stella executable and pFUnit library
- name: Build stella and perform automated Fortran tests
run: |
git submodule update --init --recursive
cmake . -B build -DSTELLA_ENABLE_TESTS=on
cmake --build build -j1 --target check
#-----------------------------------------------------------------------
# Build in debug mode
#-----------------------------------------------------------------------
# Build stella with Make in debug mode, here the python tests do not work!
# Specifically, the flush statement in mini_libstell's
# read_wout_mod.F module in the readw_and_open() routine breaks
# when reading a VMEC equilibirium during the python tests.
debug-build:
runs-on: ubuntu-22.04
name: "Build stella in debug mode"
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu_debug
steps:
# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4
# Install dependencies
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev netcdf-bin
sudo apt install -y python3 python3-pip openmpi-bin libopenmpi-dev libblas-dev liblapack-dev
# Build stella executable
- name: Build stella in debug mode
run: make -j 4
# If the operating system is changed, we can check where modules are installed
# by reading the CMake cache file:
# echo " "; echo "--------- DIRECTORIES ----------"
# cat COMPILATION/build_cmake/CMakeCache.txt
# We can also install Homebrew and use the following lines of code
# echo "Install Homebrew:"
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; brew update
# echo "FFTW_LIB_DIR=/opt/homebrew/lib/" >> $GITHUB_ENV; echo "Set FFTW_LIB_DIR"
# echo "FFTW_INC_DIR=/opt/homebrew/include/" >> $GITHUB_ENV; echo "Set FFTW_INC_DIR"
# echo "NETCDF_LIB_DIR=/opt/homebrew/lib/" >> $GITHUB_ENV; echo "Set NETCDF_LIB_DIR"
# echo "NETCDF_INC_DIR=/opt/homebrew/include/" >> $GITHUB_ENV; echo "Set NETCDF_INC_DIR"
# brew install gcc fftw netcdf netcdf-fortran open-mpi python
# ln -sn /opt/homebrew/bin/gfortran-12 /opt/homebrew/bin/gfortran
# if: github.event_name == 'push'
# Turn this job off for now !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#if: false