Closed jg110 closed 2 years ago
This problem is fixed by adding two lines to csv_module.F90
starting at line 519 (surrounding lines added for context):
#if defined __GFORTRAN__
! This is a stupid workaround for gfortran bugs (tested with 7.2.0)
select type (val)
type is (character(len=*))
call me%add(val(i),int_fmt,real_fmt,trim_str)
type is (real(wp))
call me%add(val(i),int_fmt,real_fmt,trim_str)
class default
call me%add(val(i),int_fmt,real_fmt,trim_str)
end select
The fix is similar to the one added for character inputs. This bug is especially confusing to me because I tried adding another do loop with a select type
statement for inputs of type real(wp) and everything I tried inside the statement to output the value of i
and val(i)
came out correctly. It's like the iterator is being incremented by one when the add
subroutine is called.
After further testing I've verified that this bug doesn't occur with the Intel Fortran compiler.
What version off the compiler are you using? I don't see this bug with gfortran 9.1.
Also note: this issue is similar to #4
What do you get when you run the updated test on #10
I'm using gfortran 9.2.1 from the Fedora 31 package set. I'll try the updated test and report back.
Sorry it took me a while to get back to this. I'm still getting this issue with the other branch when I replace csv_write_test.f90 with the program in my first post.
Following up on this, it was a bug in older versions of gfortran. With a sufficiently new version (tested with 11.2.1) the above code will generate the correct CSV file:
"x","y","z","t"
1.000,2.000,3.000,T
4.000,5.000,6.000,F
If
csv_write_test.f90
is modified to construct an input array from array values, the first entry is ignored:test.csv: