Skip to content

Commit 9da22bf

Browse files
Merge pull request #33 from jacobwilliams/32-ci-gfortran-versions
32 ci gfortran versions
2 parents 4abf706 + 249f706 commit 9da22bf

File tree

6 files changed

+136
-8
lines changed

6 files changed

+136
-8
lines changed

.github/workflows/CI.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ubuntu-latest]
13-
gcc_v: [10] # Version of GFortran we want to use.
13+
gcc_v: [9,10,11,12] # gfortran versions to test
1414
python-version: [3.9]
1515
env:
1616
FC: gfortran-${{ matrix.gcc_v }}
@@ -23,11 +23,13 @@ jobs:
2323
submodules: recursive
2424

2525
- name: Install Python
26+
if: contains( matrix.gcc_v, 10 )
2627
uses: actions/setup-python@v4 # Use pip to install latest CMake, & FORD/Jin2For, etc.
2728
with:
2829
python-version: ${{ matrix.python-version }}
2930

3031
- name: Setup Graphviz
32+
if: contains( matrix.gcc_v, 10 )
3133
uses: ts-graphviz/setup-graphviz@v1
3234

3335
- name: Setup Fortran Package Manager
@@ -36,14 +38,13 @@ jobs:
3638
github-token: ${{ secrets.GITHUB_TOKEN }}
3739

3840
- name: Install Python dependencies
39-
if: contains( matrix.os, 'ubuntu')
41+
if: contains( matrix.gcc_v, 10 )
4042
run: |
4143
python -m pip install --upgrade pip
4244
pip install ford numpy matplotlib
4345
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
4446
4547
- name: Install GFortran Linux
46-
if: contains( matrix.os, 'ubuntu')
4748
run: |
4849
sudo apt-get install lcov
4950
sudo update-alternatives \
@@ -58,24 +59,28 @@ jobs:
5859
run: fpm test --profile debug --flag -coverage
5960

6061
- name: Create coverage report
62+
if: contains( matrix.gcc_v, 10 )
6163
run: |
6264
mkdir -p ${{ env.COV_DIR }}
63-
lcov --capture --initial --base-directory . --directory build/gfortran_*/ --output-file ${{ env.COV_DIR }}/coverage.base
64-
lcov --capture --base-directory . --directory build/gfortran_*/ --output-file ${{ env.COV_DIR }}/coverage.capture
65+
mv ./build/gfortran_*/*/* ${{ env.COV_DIR }}
66+
lcov --capture --initial --base-directory . --directory ${{ env.COV_DIR }} --output-file ${{ env.COV_DIR }}/coverage.base
67+
lcov --capture --base-directory . --directory ${{ env.COV_DIR }} --output-file ${{ env.COV_DIR }}/coverage.capture
6568
lcov --add-tracefile ${{ env.COV_DIR }}/coverage.base --add-tracefile ${{ env.COV_DIR }}/coverage.capture --output-file ${{ env.COV_DIR }}/coverage.info
6669
env:
6770
COV_DIR: build/coverage
6871

6972
- name: Upload coverage report
73+
if: contains( matrix.gcc_v, 10 )
7074
uses: codecov/codecov-action@v3
7175
with:
7276
files: build/coverage/coverage.info
7377

7478
- name: Build documentation
79+
if: contains( matrix.gcc_v, 10 )
7580
run: ford ./fortran-csv-module.md
7681

7782
- name: Deploy Documentation
78-
if: github.ref == 'refs/heads/master'
83+
if: contains( matrix.gcc_v, 10 ) && github.ref == 'refs/heads/master'
7984
uses: JamesIves/[email protected]
8085
with:
8186
branch: gh-pages # The branch the action should deploy to.

files/test2.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"header1", "header2"
2+
"text1", -2.73
3+
"text2", 0.24

fpm.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ name = "csv_test"
1717
source-dir = "src/tests"
1818
main = "csv_test.f90"
1919

20+
[[test]]
21+
name = "csv_test2"
22+
source-dir = "src/tests"
23+
main = "csv_test2.f90"
24+
25+
[[test]]
26+
name = "csv_test3"
27+
source-dir = "src/tests"
28+
main = "csv_test3.f90"
29+
2030
[install]
2131
library = true
2232

src/csv_module.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ subroutine add_vector(me,val,int_fmt,real_fmt,trim_str)
520520

521521
do i=1,size(val)
522522

523-
#if defined __GFORTRAN__
523+
#if ( defined __GFORTRAN__ ) && ( __GNUC__ <= 10 )
524524
! This is a stupid workaround for gfortran bugs (tested with 7.2.0)
525525
select type (val)
526526
type is (character(len=*))
@@ -966,7 +966,7 @@ subroutine get_column(me,icol,r,status_ok)
966966

967967
do i=1,me%n_rows ! row loop
968968

969-
#if defined __GFORTRAN__
969+
#if ( defined __GFORTRAN__ ) && ( __GNUC__ <= 10 )
970970
! the following is a workaround for gfortran bugs:
971971
select type (r)
972972
type is (character(len=*))

src/tests/csv_test2.f90

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
3+
!*****************************************************************************************
4+
!> author: Jacob Williams
5+
! license: BSD
6+
!
7+
! Test of reading a CSV file.
8+
9+
program csv_test2
10+
11+
use csv_module
12+
use iso_fortran_env, only: wp => real64, sp => real32
13+
14+
implicit none
15+
16+
type(csv_file) :: file
17+
logical :: status_ok
18+
19+
write(*,*) ''
20+
write(*,*) '============================'
21+
write(*,*) ' csv_test_2 '
22+
write(*,*) '============================'
23+
write(*,*) ''
24+
25+
call file%read('files/test2.csv',header_row=1,status_ok=status_ok)
26+
write(*,*) 'status_ok = ', status_ok
27+
28+
end program csv_test2

src/tests/csv_test3.f90

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
!*****************************************************************************************
2+
!>
3+
! Test of string conversions that uncover bugs in Gfortran.
4+
5+
program csv_test3
6+
7+
use csv_module
8+
use iso_fortran_env, only: wp => real64
9+
10+
implicit none
11+
12+
type(csv_file) :: f
13+
logical :: status_ok
14+
character(len=30),dimension(:),allocatable :: header, col1
15+
integer :: i
16+
character(len=100) :: tmp_str
17+
18+
write(*,*) ''
19+
write(*,*) '============================'
20+
write(*,*) ' csv_test_3 '
21+
write(*,*) '============================'
22+
write(*,*) ''
23+
24+
! set optional inputs:
25+
call f%initialize(verbose = .true.)
26+
27+
! open the file
28+
call f%open('test.csv',n_cols=4,status_ok=status_ok)
29+
30+
! add header
31+
call f%add(['x','y','z','t'])
32+
call f%next_row()
33+
34+
! add some data:
35+
call f%add([1.0_wp,2.0_wp,3.0_wp],real_fmt='(F5.3)')
36+
call f%add(.true.)
37+
call f%next_row()
38+
call f%add([2.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
39+
call f%add(.false.)
40+
call f%next_row()
41+
call f%add([3.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
42+
call f%add(.false.)
43+
call f%next_row()
44+
call f%add([4.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
45+
call f%add(.false.)
46+
call f%next_row()
47+
call f%add([5.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
48+
call f%add(.false.)
49+
call f%next_row()
50+
51+
! finished
52+
call f%close(status_ok)
53+
if (.not. status_ok) error stop 'error closing file'
54+
55+
! read the file
56+
call f%read('test.csv',header_row=1,status_ok=status_ok)
57+
if (.not. status_ok) error stop 'error reading file'
58+
59+
! get the header and type info
60+
call f%get_header(header,status_ok)
61+
62+
print "(*(g0))", "HEADER:"
63+
do i = 1, size(header)
64+
print "(*(g0))", ">"//trim(header(i))//"<"
65+
end do
66+
if (.not. all(header == ['x','y','z','t'])) error stop 'error reading header'
67+
68+
call f%get(1,col1,status_ok)
69+
print "(*(g0))", "col1:"
70+
do i = 1, size(col1)
71+
print "(*(g0))", ">",trim(col1(i)),"<"
72+
end do
73+
74+
do i = 1, 5
75+
write(tmp_str,'(F5.3)') real(i,wp)
76+
if (col1(i) /= tmp_str) error stop 'error converting cell to string:'//tmp_str
77+
end do
78+
79+
! destroy the file
80+
call f%destroy()
81+
82+
end program csv_test3

0 commit comments

Comments
 (0)