Closed rjfarmer closed 2 years ago
what is the read that parses and stores the #Teff line?
character(len=*),dimension(:),pointer,intent(inout) :: col_names
character(len=strlen) :: tmp
read(IO_UBV,fmt=*,iostat=ios) tmp,tmp,tmp,col_names(1:n_colors)
We don't even care what someone calls metallicity we only check for three strings at the start of the line.
for debugging maybe try
character(len=strlen) :: tmp,tmp2,tmp3 read(IO_UBV,fmt=*,iostat=ios) tmp,tmp2,tmp3,col_names(1:n_colors)
and a formatted character read
read(IO_UBV,fmt='(a)',iostat=ios) tmp,tmp,tmp,col_names(1:n_colors)
Switching to multiple tmps doesn't help while using a formatted read does at least keeps us reading the same file but we end up reading entire rows into each variable instead of just the column.
Doing something like a fmt='(8(a10))' and configuring the header to have the right string lengths does work (at the expense that now everything must be the same width).
So it seems its unformatted reads of [Fe/H] is causing gfortran to read a different file.
For now we can try can catch the square brackets usage and warn people not to do that.
fmt='(a)' should mean read each string, with spaces as the delimiter, however long the string is declared. this gets away from a fixed format read. i'm also going to test this issue offline with ifort and gfortran.
a more formal way is to read the entire string and parse it oneself. slightly more overhead but this approach allows all kinds of errant entries to be caught before processing further (e.g., non printing control characters).
Gfortran bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104939
It seems like the / is breaking the read statement
Not a bug. Turns out / in unformatted reads tells Fortran to stop reading. Because no one would ever want to put a / in a string.
We'll need to turn this into a formatted read and either build the format string or manually split it.
i didn't know that! but then i don't do unformatted reads of character strings. i always use fmt='(a)' or format (a).
Well this was a fun bug to find. This is with 21.12.1
If you have a custom colors file where the header is:
Everything works fine
But if you instead have:
(Which is the mist way of writing the metallicity) then instead of correctly reading in the filter names (bessell_u Bessell_B Bessell_V Bessell_R Bessell_I) we end up with the partial contents of data/chem_data/lodders03.data file as the filter names.
If you add
at line 249 in colors/private/mod_colors.f90 then in the working case we have:
and in the broken case we have:
Some how [Fe/H] is breaking gfortran's read routines and i guess we are getting a memory corruption and then start reading a different file in?
Maybe [Fe is being read as a ANSI escape code perhaps? Then /h] means something?
https://en.wikipedia.org/wiki/ANSI_escape_code#Fe_Escape_sequences
Here is a minimal breaking test case file: