-
Notifications
You must be signed in to change notification settings - Fork 25
/
setup-fortran.sh
executable file
·656 lines (611 loc) · 18.3 KB
/
setup-fortran.sh
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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
#!/usr/bin/env bash
set -ex
require_fetch()
{
if command -v curl > /dev/null 2>&1; then
fetch="curl -L"
elif command -v wget > /dev/null 2>&1; then
fetch="wget -O -"
else
echo "No download mechanism found. Install curl or wget first."
exit 1
fi
}
# Function to install environment-modules via apt
# https://github.com/cea-hpc/modules
install_environment_modules_apt() {
echo "Installing environment-modules package..."
sudo apt-get install -y environment-modules
echo "Environment-modules installed."
echo "Sourcing modules.sh script to set up environment modules..."
source /etc/profile.d/modules.sh
echo "Environment modules set up completed."
}
install_gcc_brew()
{
brew install --force gcc@${version}
# make an unversioned symlink
os_ver=$(sw_vers -productVersion | cut -d'.' -f1)
if (( "$os_ver" > 13 )); then
# default homebrew bin dir changed with macos 14
ln -fs /opt/homebrew/bin/gfortran-${version} /usr/local/bin/gfortran
ln -fs /opt/homebrew/bin/gcc-${version} /usr/local/bin/gcc
ln -fs /opt/homebrew/bin/g++-${version} /usr/local/bin/g++
else
ln -fs /usr/local/bin/gfortran-${version} /usr/local/bin/gfortran
ln -fs /usr/local/bin/gcc-${version} /usr/local/bin/gcc
ln -fs /usr/local/bin/g++-${version} /usr/local/bin/g++
fi
}
install_gcc_apt()
{
# check if gcc preinstalled via apt
cur=$(apt show gcc | grep "Version" | cut -d':' -f3 | cut -d'-' -f1)
maj=$(echo $cur | cut -d'.' -f1)
if [ "$maj" == "$version" ]; then
echo "GCC $version already installed"
else
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-${version} gfortran-${version} g++-${version}
fi
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${version} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${version} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${version} \
--slave /usr/bin/g++ g++ /usr/bin/g++-${version}
}
install_gcc_choco()
{
# check if mingw preinstalled via choco, falling back to check directly for gfortran
cur=$(choco list -e mingw -r | cut -d'|' -f2)
if [[ "$cur" == "" ]] && [[ "$(which gfortran)" != "" ]]; then
cur=$(gfortran --version | grep -woE '[0123456789.]+' | head -n 1)
fi
maj=$(echo $cur | cut -d'.' -f1)
# if already installed, nothing to do
if [ "$maj" == "$version" ]; then
echo "GCC $version already installed"
else
# otherwise hide preinstalled mingw compilers
mv /c/mingw64 "$RUNNER_TEMP/"
# ...and install selected version
case $version in
13)
choco install mingw --version 13.2.0 --force
# mingw 13 on Windows doesn't create shims (http://disq.us/p/2w5c5tj)
# so hide Strawberry compilers and manually add mingw bin dir to PATH
mkdir "$RUNNER_TEMP/strawberry"
mv /c/Strawberry/c/bin/gfortran "$RUNNER_TEMP/strawberry/gfortran"
mv /c/Strawberry/c/bin/gcc "$RUNNER_TEMP/strawberry/gcc"
mv /c/Strawberry/c/bin/g++ "$RUNNER_TEMP/strawberry/g++"
echo "C:\ProgramData\mingw64\mingw64\bin" >> $GITHUB_PATH
;;
12)
choco install mingw --version 12.2.0 --force
;;
11)
choco install mingw --version 11.2.0 --force
;;
10)
choco install mingw --version 10.3.0 --force
;;
9)
choco install mingw --version 9.4.0 --force
;;
8)
choco install mingw --version 8.5.0 --force
;;
*)
echo "Unsupported version: $version (choose 8-13)"
exit 1
;;
esac
fi
# missing DLL workaround
FCDIR=/c/ProgramData/Chocolatey/bin
LNDIR=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin
if [ -d "$FCDIR" ] && [ -f "$LNDIR/libgfortran-5.dll" ] && [ ! -f "$FCDIR/libgfortran-5.dll" ]; then
ln -s "$LNDIR/libgfortran-5.dll" "$FCDIR/libgfortran-5.dll"
fi
}
install_gcc()
{
local platform=$1
case $platform in
linux*)
install_gcc_apt
;;
darwin*)
install_gcc_brew
;;
mingw*)
install_gcc_choco
;;
msys*)
install_gcc_choco
;;
cygwin*)
install_gcc_choco
;;
*)
echo "Unsupported platform: $platform"
exit 1
;;
esac
export FC="gfortran"
export CC="gcc"
export CXX="g++"
}
export_intel_vars()
{
cat >> $GITHUB_ENV <<EOF
LD_LIBRARY_PATH=$LD_LIBRARY_PATH
LIBRARY_PATH=$LIBRARY_PATH
INFOPATH=$INFOPATH
MANPATH=$MANPATH
ONEAPI_ROOT=$ONEAPI_ROOT
CLASSPATH=$CLASSPATH
CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH
OCL_ICD_FILENAMES=$OCL_ICD_FILENAMES
INTEL_PYTHONHOME=$INTEL_PYTHONHOME
CPATH=$CPATH
SETVARS_COMPLETED=$SETVARS_COMPLETED
EOF
for path in ${PATH//:/ }; do
echo $path >> $GITHUB_PATH
done
}
intel_version_map_l()
{
local actual_version=$1
local classic=$2
if $classic; then
case $actual_version in
2021.12.0 | 2021.12)
version=2024.1
;;
2021.11.0 | 2021.11)
version=2024.0
;;
2021.10.0 | 2021.10)
version=2023.2.0
;;
2021.9.0 | 2021.9)
version=2023.1.0
;;
2021.8.0 | 2021.8)
version=2023.0.0
;;
2021.7.1)
version=2022.2.1
;;
2021.7.0 | 2021.7)
version=2022.2.0
;;
2021.6.0 | 2021.6)
version=2022.1.0
;;
2021.5.0 | 2021.5)
version=2022.0.2
# version=2022.0.1
;;
2021.4 | 2021.3 | 2021.2)
version=$actual_version.0
;;
2021.1)
version=2021.1.1
;;
*)
version=$actual_version
;;
esac
else
case $actual_version in
2022.0.0 | 2022.0)
version=2022.0.2
;;
2023.2 | 2023.1 | 2023.0 | 2022.2 | 2022.1 | 2021.4 | 2021.2)
version=$actual_version.0
;;
2024.1 | 2024.1.0)
version=2024.1
;;
2024.0 | 2024.0.0)
version=2024.0
;;
2021.1)
version=2021.1.1
;;
*)
version=$actual_version
;;
esac
fi
}
intel_version_map_m()
{
local actual_version=$1
case $actual_version in
2021.10.0 | 2021.10)
version=2023.2.0
;;
2021.9.0 | 2021.9)
version=2023.1.0
;;
2021.8.0 | 2021.8)
version=2023.0.0
;;
2021.7.1)
version=2022.3.1
;;
2021.7.0 | 2021.7)
version=2022.3.0
;;
2021.6.0 | 2021.6)
version=2022.2.0
;;
2021.5.0 | 2021.5)
version=2022.1.0
;;
2021.4 | 2021.3 | 2021.2 | 2021.1)
version=$actual_version.0
;;
*)
version=$actual_version
;;
esac
}
intel_version_map_w()
{
local actual_version=$1
local classic=$2
if $classic; then
case $actual_version in
2021.12.0 | 2021.12)
version=2024.1.0
;;
2021.11.0 | 2021.11)
version=2024.0.1
;;
2021.10.0 | 2021.10)
version=2023.2.0
;;
2021.9.0 | 2021.9)
version=2023.1.0
;;
2021.8.0 | 2021.8)
version=2023.0.0
;;
2021.7.0 | 2021.7)
version=2022.3.0
;;
2021.6.0 | 2021.6)
version=2022.2.0
;;
*)
version=$actual_version
;;
esac
else
case $actual_version in
2024.1 | 2024.1.0)
version=2024.1.0
;;
2024.0 | 2024.0.0)
version=2024.0.1
;;
2023.2 | 2023.1 | 2023.0)
version=$actual_version.0
;;
2022.2.0 | 2022.2)
version=2022.3.0
;;
2022.1.0 | 2022.1)
version=2022.2.0
;;
*)
version=$actual_version
;;
esac
fi
}
install_intel_apt()
{
local version=$1
local classic=$2
intel_version_map_l $version $classic
require_fetch
local _KEY="GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB"
$fetch https://apt.repos.intel.com/intel-gpg-keys/$_KEY > $_KEY
sudo apt-key add $_KEY
rm $_KEY
echo "deb https://apt.repos.intel.com/oneapi all main" \
| sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
# c/cpp compiler package names changed with 2024+
case $version in
2024*)
sudo apt-get install \
intel-oneapi-compiler-{fortran,dpcpp-cpp}-$version
;;
*)
sudo apt-get install \
intel-oneapi-compiler-{fortran,dpcpp-cpp-and-cpp-classic}-$version
;;
esac
source /opt/intel/oneapi/setvars.sh
export_intel_vars
}
install_intel_dmg()
{
local version=$1
intel_version_map_m $version
case $version in
2021.1.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17426/m_BaseKit_p_2021.1.0.2427.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17398/m_HPCKit_p_2021.1.0.2681.dmg
;;
2021.2.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17714/m_BaseKit_p_2021.2.0.2855.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17643/m_HPCKit_p_2021.2.0.2903.dmg
;;
2021.3.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17969/m_BaseKit_p_2021.3.0.3043.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17890/m_HPCKit_p_2021.3.0.3226.dmg
;;
2021.4.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18256/m_BaseKit_p_2021.4.0.3384.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18242/m_HPCKit_p_2021.4.0.3389.dmg
;;
2022.1.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18342/m_BaseKit_p_2022.1.0.92.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18341/m_HPCKit_p_2022.1.0.86.dmg
;;
2022.2.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18675/m_BaseKit_p_2022.2.0.226_offline.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18681/m_HPCKit_p_2022.2.0.158_offline.dmg
;;
2022.3.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18865/m_BaseKit_p_2022.3.0.8743.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18866/m_HPCKit_p_2022.3.0.8685.dmg
;;
2022.3.1)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18971/m_BaseKit_p_2022.3.1.17244.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18977/m_HPCKit_p_2022.3.1.15344.dmg
;;
2023.0.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19080/m_BaseKit_p_2023.0.0.25441.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19086/m_HPCKit_p_2023.0.0.25440.dmg
;;
2023.1.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2516a0a0-de4d-4f3d-9e83-545b32127dbb/m_BaseKit_p_2023.1.0.45568.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/a99cb1c5-5af6-4824-9811-ae172d24e594/m_HPCKit_p_2023.1.0.44543.dmg
;;
2023.2.0)
MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/cd013e6c-49c4-488b-8b86-25df6693a9b7/m_BaseKit_p_2023.2.0.49398.dmg
MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/edb4dc2f-266f-47f2-8d56-21bc7764e119/m_HPCKit_p_2023.2.0.49443.dmg
;;
*)
exit 1
;;
esac
require_fetch
$fetch $MACOS_HPCKIT_URL > m_HPCKit.dmg
hdiutil attach m_HPCKit.dmg
sudo /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \
--action install \
--eula=accept \
--continue-with-optional-error=yes \
--log-dir=.
hdiutil detach /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)" -quiet
rm m_HPCKit.dmg
source /opt/intel/oneapi/setvars.sh
export_intel_vars
}
install_intel_win()
{
local version=$1
local classic=$2
intel_version_map_w $version $classic
case $version in
2024.1.0)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/c95a3b26-fc45-496c-833b-df08b10297b9/w_HPCKit_p_2024.1.0.561_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-dpcpp-common
;;
2024.0.1)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7a6db8a1-a8b9-4043-8e8e-ca54b56c34e4/w_HPCKit_p_2024.0.1.35_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-dpcpp-common
;;
2023.2.0)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/438527fc-7140-422c-a851-389f2791816b/w_HPCKit_p_2023.2.0.49441_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-compiler
;;
2023.1.0)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2a13d966-fcc5-4a66-9fcc-50603820e0c9/w_HPCKit_p_2023.1.0.46357_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-compiler
;;
2023.0.0)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19085/w_HPCKit_p_2023.0.0.25931_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-compiler
;;
2022.3.1)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18976/w_HPCKit_p_2022.3.1.19755_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-compiler
;;
2022.3.0)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18857/w_HPCKit_p_2022.3.0.9564_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-compiler
;;
2022.2.0)
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18680/w_HPCKit_p_2022.2.0.173_offline.exe
WINDOWS_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler:intel.oneapi.win.cpp-compiler
;;
*)
exit 1
;;
esac
"$GITHUB_ACTION_PATH/install-intel-windows.bat" $WINDOWS_HPCKIT_URL $WINDOWS_HPCKIT_COMPONENTS
# don't call export_intel_vars here because the install may have
# been restored from cache. export variables in action.yml after
# installation or cache restore.
}
install_intel()
{
local platform=$1
local classic=$2
case $platform in
linux*)
install_intel_apt $version $classic
;;
darwin*)
install_intel_dmg $version
;;
mingw*)
install_intel_win $version $classic
;;
msys*)
install_intel_win $version $classic
;;
cygwin*)
install_intel_win $version $classic
;;
*)
echo "Unsupported platform: $platform"
exit 1
;;
esac
if $classic; then
export FC="ifort"
export CC="icc"
export CXX="icpc"
else
export FC="ifx"
export CC="icx"
export CXX="icpx"
fi
}
export_nvidiahpc_vars()
{
local version=$1
# to convert version format from X.Y to X-Y
local cversion=$(echo "$version" | tr '.' '-')
cat >> $GITHUB_ENV <<EOF
NVARCH=`uname -s`_`uname -m`;
NVCOMPILERS=/opt/nvidia/hpc_sdk;
MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/$cversion/compilers/man;
PATH=$NVCOMPILERS/$NVARCH/$cversion/compilers/bin:$PATH;
PATH=$NVCOMPILERS/$NVARCH/$cversion/comm_libs/mpi/bin:$PATH
MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/$cversion/comm_libs/mpi/man
EOF
for path in ${PATH//:/ }; do
echo $path >> $GITHUB_PATH
done
}
install_nvidiahpc_apt()
{
local version=$1
# install environment-modules
install_environment_modules_apt
# to convert version format from X.Y to X-Y
local cversion=$(echo "$version" | tr '.' '-')
# install NVIDIA HPC SDK
echo "Installing NVIDIA HPC SDK $version..."
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
sudo apt-get update -y
sudo apt-get install -y nvhpc-$cversion
echo "NVIDIA HPC SDK $version installed."
# load NVIDIA HPC SDK module
echo "Loading NVIDIA HPC SDK $version module..."
NVCOMPILERS=/opt/nvidia/hpc_sdk; export NVCOMPILERS
export MODULEPATH=$NVCOMPILERS/modulefiles:$MODULEPATH
module load nvhpc
echo "NVIDIA HPC SDK $version module loaded."
# set environment variables
export_nvidiahpc_vars $version
}
install_nvidiahpc()
{
local platform=$1
case $platform in
linux*)
install_nvidiahpc_apt $version
;;
darwin*)
echo "NVIDIA HPC SDK is not supported on macOS."
exit 1
;;
mingw*)
echo "NVIDIA HPC SDK is not supported on Windows."
exit 1
;;
msys*)
echo "NVIDIA HPC SDK is not supported on MSYS."
exit 1
;;
cygwin*)
echo "NVIDIA HPC SDK is not supported on Cygwin."
exit 1
;;
*)
echo "Unsupported platform: $platform"
exit 1
;;
esac
export FC="nvfortran"
export CC="nvc"
export CXX="nvc++"
}
install_lfortran_l()
{
local version=$1
export CC="gcc"
export CXX="g++"
export CONDA=conda
$CONDA install -c conda-forge -n base -y lfortran=$version
}
install_lfortran_w()
{
local version=$1
export CC="cl"
export CXX="cl"
export CONDA=$CONDA\\Scripts\\conda # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md#environment-variables
$CONDA install -c conda-forge -n base -y lfortran=$version
}
install_lfortran_m()
{
local version=$1
export CC="gcc"
export CXX="g++"
export CONDA_ROOT_PREFIX=$MAMBA_ROOT_PREFIX
export CONDA=micromamba
$CONDA install -c conda-forge -n base -y lfortran=$version
}
install_lfortran()
{
local platform=$1
case $platform in
linux*)
install_lfortran_l $version
;;
darwin*)
install_lfortran_m $version
;;
mingw*)
install_lfortran_w $version
;;
msys*)
install_lfortran_w $version
;;
cygwin*)
install_lfortran_w $version
;;
*)
echo "Unsupported platform: $platform"
exit 1
;;
esac
echo $($CONDA run -n base which lfortran | sed 's/lfortran//') >> $GITHUB_PATH
export FC="lfortran"
}