pyclaw
pyclaw copied to clipboard
GaugeSolution.write format?
I notice that in src/pyclaw/gauges.py, GaugeSolution.write uses different formatting than the Fortran code, e.g. producing
# gauge_id= 1 location=( 0.6 0.6 ) num_eqn= 1
# Columns: level time q(1 ... num_eqn)
2 0.0 -0.006115505
2 0.008 -0.006969357
2 0.016 -0.0079234
instead of the Fortran output:
# gauge_id= 1 location=( 0.6000000E+00 0.6000000E+00 ) num_eqn= 1
# Columns: level time q(1 ... num_eqn)
2 0.0000000E+00 -0.6115505E-02
2 0.8000000E-02 -0.6969357E-02
2 0.1600000E-01 -0.7923400E-02
The Python version would potentially print more significant figures although maybe not all since %s formatting is used, e.g.
"%s" % pi
produces '3.14159265359'.
Should we use the same format in both cases? Are the 7 digits we print from Fortran always enough?
I would favor them being identical but also long. We should probably explicitly format the Python and make the Fortran longer then?
Ideally we would make it easy to control how long. Some applications require many gauges over very many time steps and the gauge files can get huge. Ideally we would also support binary gauge output in the Fortran code. Maybe these are enhancements for the future.
For now I'm fine with leaving the pyclaw version alone unless this affects regression tests somehow, but I don't think we are using the write function in the Fortran tests.
My preferred change would be to make both of them print all the digits, as @mandli suggests. I'm also okay with just making the pyclaw version match the fortran version for now if that seems substantially easier.