Skip to content

Can't read gEQDSK files with multiple new lines at end #10

@bclyons12

Description

@bclyons12

The latest version of EFIT.jl can't read some gEQDSK files that the old version did. For example: g163303.03170_fix.zip

I get the following output:

julia> gfixed = readg(fixed_geqdsk; set_time=0.0)

ERROR: InvalidStateException: Channel is closed.
Stacktrace:
 [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
   @ Base ./task.jl:931
 [2] wait()
   @ Base ./task.jl:995
 [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
   @ Base ./condition.jl:130
 [4] wait
   @ ./condition.jl:125 [inlined]
 [5] take_unbuffered(c::Channel{Float64})
   @ Base ./channels.jl:494
 [6] take!
   @ ./channels.jl:471 [inlined]
 [7] readg(gfile::String; set_time::Float64)
   @ EFIT ~/.julia/dev/EFIT/src/io.jl:198
 [8] top-level scope
   @ REPL[38]:1

This appears to be caused by the fact that this file is missing some of the extra data that is read, and it has multiple new lines at the end. It appears common to files produced by CHEASE. The extra new line causes it not to report eof(f)=true so it tries to read a token in the following lines and fails:

EFIT.jl/src/io.jl

Lines 195 to 199 in d63c58c

for i 1:3
if !eof(f)
xdum = take!(token)
end
end

I'm not sure the best fix for this. Maybe a try-catch?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions