Hi there,
so I am currently working on a Julia script that reads unformatted binary Fortran files.
For this, I am using the package “FortranFiles.jl”. After importing, one can create FortranFile objects with the command
FortranFile("filename.bin")
and then read the content of the file with the base method
read(f, **kwargs)
However, it is not possible to use this nice
FortranFile(filname) do f
some_code
end
In the documentation of the open function, I found that one of the versions of the open function is defined as
function open(f::Function, args...; kwargs...)
io = open(args...; kwargs...)
try
f(io)
finally
close(io)
end
end
But if I do the same thing with the FortranFile, i.e. I define
function FortranFile(f::Function, args...; kwargs...)
io = FortranFile(args...; kwargs...)
try
f(io)
finally
close(io)
end
end
Julia seems to forget the original FortranFile constructor. Every time I call the function above in
FortranFile(filname) do f
construct I get a method error and when I run
methods(FortranFile)
I only get the function I defined.
Can someone tell me, how I properly define the function?