1
+ name : Test FC
2
+ description : Test Fortran compiler compatibility
3
+ inputs :
4
+ compiler :
5
+ description : " Toolchain or compiler to install"
6
+ required : true
7
+ version :
8
+ description : " Version of toolchain or compiler"
9
+ required : true
10
+ runs :
11
+ using : " composite"
12
+ steps :
13
+
14
+ - name : Check compiler version
15
+ shell : bash
16
+ run : |
17
+ if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]]); then
18
+ # only last line of output captured by command substitution, write to temp file instead
19
+ ${{ env.FC }} //QV > "$RUNNER_TEMP/${{ env.FC }}.ver" 2>&1
20
+ fcv=$(cat "$RUNNER_TEMP/${{ env.FC }}.ver" | head -n 1)
21
+ fcv=${fcv#*Version }
22
+ fcv=${fcv%% Build*}
23
+ else
24
+ fcv=$(${{ env.FC }} --version | head -n 1)
25
+ fcv=$(echo "$fcv" | grep -woE '[0123456789.]+' | head -n 1)
26
+ fi
27
+ [[ "$fcv" == ${{ inputs.version }}* ]] && (echo "found ${{ env.FC }} version: $fcv") || (echo "unexpected ${{ env.FC }} version: $fcv"; exit 1)
28
+
29
+ - name : Test compile (bash)
30
+ shell : bash
31
+ run : |
32
+ # macos-13/gfortran 7-9 compatibility workaround
33
+ args=""
34
+ if [ "$RUNNER_OS" == "macOS" ]; then
35
+ if [[ $(sw_vers -productVersion) == 13* ]] && \
36
+ [[ ${{ inputs.compiler }} == "gcc" ]] && \
37
+ [[ ${{ inputs.version }} =~ ^(7|8|9)$ ]]
38
+ then
39
+ args="-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
40
+ fi
41
+ fi
42
+
43
+ ${{ env.FC }} $args -o hw hw.f90
44
+ output=$(./hw '2>&1')
45
+ [[ "$output" == *"hello world"* ]] && echo "$output" || (echo "Unexpected Fortran program output: $output"; exit 1)
46
+ rm hw
47
+
48
+ - name : Test compile Fortran (pwsh)
49
+ if : ${{ (success() || failure()) && runner.os == 'Windows' }}
50
+ shell : pwsh
51
+ run : |
52
+ ${{ env.FC }} -o hw.exe hw.f90
53
+ $output=$(& ".\hw.exe")
54
+ if ($output -match "hello world") {
55
+ write-output $output
56
+ } else {
57
+ write-output "unexpected output: $output"
58
+ exit 1
59
+ }
60
+ rm hw.exe
61
+
62
+ - name : Test compile Fortran (powershell)
63
+ if : ${{ (success() || failure()) && runner.os == 'Windows' }}
64
+ shell : powershell
65
+ run : |
66
+ ${{ env.FC }} -o hw.exe hw.f90
67
+ $output=$(& ".\hw.exe")
68
+ if ($output -match "hello world") {
69
+ write-output $output
70
+ } else {
71
+ write-output "unexpected output: $output"
72
+ exit 1
73
+ }
74
+ rm hw.exe
75
+
76
+ - name : Test compile Fortran (cmd)
77
+ if : ${{ (success() || failure()) && runner.os == 'Windows' }}
78
+ shell : cmd
79
+ run : |
80
+ ${{ env.FC }} -o hw.exe hw.f90
81
+ for /f "tokens=* usebackq" %%f in (`.\hw.exe`) do @set "OUTPUT=%%f"
82
+ if "%OUTPUT%"=="hello world" (
83
+ echo %OUTPUT%
84
+ ) else (
85
+ echo unexpected output: %OUTPUT%
86
+ exit 1
87
+ )
88
+ del hw.exe
89
+
0 commit comments