Skip to content

Fix number formatting in Fortran output Files in vcsmd.f90

Summary:

This pull request addresses an issue with the formatting of floating point numbers in the output files generated by pw.x. Previously, numbers were jammed together without adequate spacing in various output files for the VCSMD algorithm (e.g., .e, .p), making them difficult to read and parse. This change ensures proper spacing between numbers by adjusting the format specifiers used in WRITE statements throughout the code.

Problem:

In the existing code, numbers were output using format specifiers like D12.5, which did not guarantee spacing between successive numbers in the output files. This was particularly problematic when numbers were close to their maximum width, as they would appear to run together without any delimiter, complicating data analysis and readability.

! in .p file
  0.00000D+00-0.39490D-03 0.00000D+00     0
  0.00000D+00-0.39282D-03-0.39282D-03     1
  0.00000D+00-0.39028D-03-0.39155D-03     2
  0.00000D+00-0.38794D-03-0.39035D-03     3
  0.00000D+00-0.38470D-03-0.38894D-03     4
  0.00000D+00-0.38122D-03-0.38739D-03     5
  0.00000D+00-0.37946D-03-0.38607D-03     6
! in .e file
  0.00000D+00 0.28501D-02 0.28501D-02-0.12555D+00     0
 -0.17188D-03 0.30495D-02 0.28776D-02-0.12488D+00     1
 -0.35507D-03 0.32328D-02 0.28777D-02-0.12408D+00     2
 -0.54950D-03 0.34269D-02 0.28774D-02-0.12333D+00     3
 -0.75511D-03 0.36324D-02 0.28773D-02-0.12230D+00     4

Solution:

We have updated the format specifiers from D12.5 to E13.5 across all relevant WRITE statements. This change ensures that each number is formatted in scientific notation with a consistent total field width, including space for the sign, digits, decimal point, exponent, and crucially, leading spaces for alignment. This modification guarantees at least one space between numbers, enhancing the readability and parseability of the output files.

Expected Impact:

  • Readability: Output files will now have improved readability, with clear separation between numbers.
  • Data Analysis: This change facilitates easier parsing and analysis of the output data by ensuring numbers are distinct and separated.
  • Compatibility: This update maintains backward compatibility with existing data processing scripts, as the change only affects the visual format of the numbers, not their numerical value or precision.

Merge request reports