Part of my inherited research code is a highly parallelized Fortran90 program that produces, as its primary output, a large text file (~1 GB) of complex numbers in the following format:
(1.014631909321741E-002,-1.825468883204626E-002)
As part of my migration to Julia, I’m trying to reimplement the analysis code that would operate on this file, and I’m having the darndest time getting Julia to parse the data in the file as complex numbers. I can get as far as the following:
wfn = open("wfn.dat")
str = strip(readline(wfn), [' ', '(', ')'])
This produces the following output:
"1.014631909321741E-002,-1.825468883204626E-002"
However, attempts to use something like val = parse(ComplexF64, str) to convert this to a complex number fails because parse expects an imaginary unit specifier like im or i, which is obviously not there. The ideal result is that val is converted to a complex number whose real and imaginary parts are given by the two numbers in succession. Is there a straightforward way to do this.
(Side note, I’d love a format=“fortran” argument for parse() or readdlm(), especially since this is Fortran’s default complex number format. If this exists somewhere, please let me know.)