qd-cae/qd-cae-python

'RuntimeError: Could not re-enable console output.' when running "D3plot('d3plot')"

TomforGitHub opened this issue · 9 comments

Hi Codie,

I installed the qd module successfully with command pip install qd.

The system info is 3.6.6 |Anaconda custom (64-bit)| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)]

When I tried to load a d3plot file with D3plot('d3plot'), an error showed: RuntimeError: Could not re-enable console output.

Hey,
are you using FEMZIP decompression or is it a plain D3plot file?

Detailed Explanation
I've investigated the issue. The problem originates as follows.
In the newest version I automatically detect whether the file was compressed by femzip or not. Unfortunately femzip writes to the console during the test and I had to use a hack to disable this without having access to their source code. Therefore I simply disable stdout while testing for compression. After the test I re-enable stdout again and this exactly fails in your case. I tested the solution on windows and linux and in my case it did work, but the code was also compiled on the very same machines ...

Workaround
I can compile a version without femzip and upload it into the dist folder for you tomorrow. Otherwise an older version should also work.

Comment
The most recent features made unfortunately the code less reliably in terms of portability on windows, but windows is known to give one a hard time to make code portable ... I decided to focus the next minor versions to raise stability. Unfortunately I can not reproduce certain issues on my machines which makes life quite tough. I'm not giving up though.

I successfully installed qd-0.7.3-cp36-cp36m-win_amd64.whl, and D3plot can be imported. But when I run D3plot('d3plot'), this error occurs:
RuntimeError: Wrong filetype 538976288 != 1 (or 5) in header of d3plot. Your file might be in Double Precision or the endian of the file is not the endian of the machine.

Is there a way to set precision?

Is it a double precision file?

Detailed Explanation
When I created the library I did not take double precision files into account, thus they can not be read. I neglected it for a very good reason: When you compute double precision, then dyna also saves the results in double precision (I think they just dump the memory). The additional digits though rarely matter in postprocessing due to the limited numerical precision.

Workaround
You can compute in double precision and write the file in single precision. This also saves you a lot of memory. The additional digits usually do not matter:

  • Inputfile: *DATABASE_FORMAT, IBINARY=1
  • Environment-Variable: export LSTC_BINARY=32ieee
  • Command-line: e. g. ls971 i=input 32ieee=yes

Fix
It is relatively simple to extend this, but I'm just too short in time to do this currently. Since you're the second one requiring it, I might raise the priority of this topic now.

This is a compiled version of 0.8.0 without FEMZIP if you still require it.

qd-0.8.0-cp36-cp36m-win_amd64.whl.zip

I installed verison 0.8.0, and I'll output single precision results and see. Thanks for your time!

Glad I could (partially) help. I will close this issue and open a new one with a request for double precision handling.