Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(moddump_binary) cleanup to improve code clarity #257

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

themikelau
Copy link
Collaborator

Type of PR:
Cleanup

Description:
Clean up moddump_binary.f90.

Testing:
Used moddump to set up a sink-star-sink binary.

Did you run the bots? yes/no
No

@themikelau
Copy link
Collaborator Author

Is pull request #250 really working fine? I ran the tde benchmark on it from my laptop, and the maximum errors seem to be quite large (of order 1-10). Here is the output from diffdump:

mlau@C02YJ0JQJHD5 ~/p/tde> ./diffdumps tde_01301 tde_01301.ref                                                      1 master!?

 diffdumps: we welcome you


 >>> reading setup from file: tde_01301 on unit   9
 FT:Phantom:2022.0.1:87c8a75 (hydro+grav): 08/03/2022 16:09:52.5
 npart =      4188896
 npart(total) =               4188896
 adiabatic eos: gamma =    1.6666666666666667     
 time =    2094212.0404316501     

--> ALLOCATING ALL ARRAYS
------------------------------------------------------------
 Total memory allocated to arrays:    6.078 GB n =      4188896
------------------------------------------------------------
 reading particles          1:   4188896, from block     1 lims=         1-   4188896
 <<< finished reading (hydro) file 

 > sorting particles by ID...
  copying arrays...
 > sort completed in    1.7518209999999999      s

 >>> reading setup from file: tde_01301.ref on unit  10
 FT:Phantom:2022.0.1:306de79 (hydro+grav): 28/01/2022 15:52:07.4
 npart =      4188896
 npart(total) =               4188896
 ERROR: could not find dtmax0 in header
 adiabatic eos: gamma =    1.6666666666666667     
 time =    2094209.9671074995     
 reading particles          1:   4188896, from block     1 lims=         1-   4188896
 <<< finished reading (hydro) file 

 > sorting particles by ID...
  copying arrays...
 > sort completed in    1.2978269999999998      s
 checking id............................OK     [checked    4188896 values]
 checking x.............................
 x = -1.417E+03 should be -1.417E+03 ratio = 1.000E+00 err = 1.218E-06 (         1)
 x =  9.784E+02 should be  9.784E+02 ratio = 1.000E+00 err = 4.937E-07 (         2)
 x =  3.631E+03 should be  3.631E+03 ratio = 1.000E+00 err = 8.404E-07 (         3)
 x =  3.992E+03 should be  3.992E+03 ratio = 1.000E+00 err = 8.474E-07 (         4)
 x =  3.072E+03 should be  3.072E+03 ratio = 1.000E+00 err = 8.193E-07 (         5)
 x =  4.667E+03 should be  4.667E+03 ratio = 1.000E+00 err = 8.702E-07 (         6)
 x =  4.256E+03 should be  4.256E+03 ratio = 1.000E+00 err = 8.633E-07 (         7)
 x = -1.618E+03 should be -1.618E+03 ratio = 1.000E+00 err = 1.163E-06 (         8)
 x = -5.959E+02 should be -5.959E+02 ratio = 1.000E+00 err = 1.619E-06 (         9)
 x = -1.180E+02 should be -1.180E+02 ratio = 1.000E+00 err = 4.302E-06 (        14)
 x = -1.506E+01 should be -1.506E+01 ratio = 1.000E+00 err = 2.809E-05 (        69)
 x = -5.802E+02 should be -5.802E+02 ratio = 1.000E+00 err = 7.975E-05 (       175)
 x =  3.260E+01 should be  3.263E+01 ratio = 9.991E-01 err = 9.084E-04 (       283)
 x = -4.375E+00 should be -4.385E+00 ratio = 9.977E-01 err = 2.347E-03 (       307)
 x =  1.344E+01 should be  1.363E+01 ratio = 9.858E-01 err = 1.420E-02 (     43253)
 x = -5.021E+00 should be -4.706E+00 ratio = 1.067E+00 err = 6.686E-02 (    115713)
 x =  1.146E-02 should be  1.007E-03 ratio = 1.138E+01 err = 1.038E+01 (    127745)
 x = -1.922E-01 should be -4.333E-03 ratio = 4.436E+01 err = 4.336E+01 (   2976241)
 FAILED [on    4177029 of    4188896 values, max err = 4.336E+01, L2 err =  3.513E-08 tol = 2.225-308]
 checking y.............................
 y =  3.963E+04 should be  3.963E+04 ratio = 1.000E+00 err = 8.441E-07 (         1)
 y =  5.076E+04 should be  5.076E+04 ratio = 1.000E+00 err = 9.059E-07 (         2)
 y =  5.760E+04 should be  5.760E+04 ratio = 1.000E+00 err = 9.276E-07 (         3)
 y =  6.330E+04 should be  6.330E+04 ratio = 1.000E+00 err = 9.405E-07 (         4)
 y =  5.688E+04 should be  5.688E+04 ratio = 1.000E+00 err = 9.256E-07 (         5)
 y =  6.384E+04 should be  6.384E+04 ratio = 1.000E+00 err = 9.415E-07 (         6)
 y =  6.116E+04 should be  6.116E+04 ratio = 1.000E+00 err = 9.358E-07 (         7)
 y =  4.459E+04 should be  4.459E+04 ratio = 1.000E+00 err = 8.771E-07 (         8)
 y =  4.823E+04 should be  4.823E+04 ratio = 1.000E+00 err = 8.954E-07 (         9)
 y =  4.713E+02 should be  4.712E+02 ratio = 1.000E+00 err = 1.876E-04 (       175)
 y = -1.562E+01 should be -1.563E+01 ratio = 9.990E-01 err = 9.836E-04 (       265)
 y =  2.780E+01 should be  2.771E+01 ratio = 1.003E+00 err = 3.435E-03 (     24308)
 y = -3.090E-01 should be -9.471E-02 ratio = 3.262E+00 err = 2.262E+00 (     75650)
 y =  1.729E-01 should be  2.902E-02 ratio = 5.959E+00 err = 4.959E+00 (   2915189)
 FAILED [on    4177029 of    4188896 values, max err = 4.959E+00, L2 err =  1.306E-07 tol = 2.225-308]
 checking z.............................
 z =  1.163E+02 should be  1.163E+02 ratio = 1.000E+00 err = 8.213E-07 (         1)
 z = -1.676E+02 should be -1.676E+02 ratio = 1.000E+00 err = 9.174E-07 (         2)
 z =  4.453E+01 should be  4.453E+01 ratio = 1.000E+00 err = 9.494E-07 (         3)
 z =  2.031E+02 should be  2.031E+02 ratio = 1.000E+00 err = 1.007E-06 (         4)
 z = -4.214E+01 should be -4.214E+01 ratio = 1.000E+00 err = 1.022E-06 (         5)
 z = -4.883E+01 should be -4.883E+01 ratio = 1.000E+00 err = 1.088E-06 (         6)
 z = -1.341E+02 should be -1.341E+02 ratio = 1.000E+00 err = 1.296E-06 (         7)
 z = -1.329E+02 should be -1.329E+02 ratio = 1.000E+00 err = 8.524E-07 (         8)
 z = -3.855E+01 should be -3.855E+01 ratio = 1.000E+00 err = 7.704E-07 (         9)
 z =  1.118E+02 should be  1.118E+02 ratio = 1.000E+00 err = 9.613E-06 (        67)
 z =  6.651E+01 should be  6.651E+01 ratio = 1.000E+00 err = 4.546E-05 (       175)
 z = -5.245E-01 should be -5.244E-01 ratio = 1.000E+00 err = 1.495E-04 (       214)
 z = -1.159E-01 should be -1.158E-01 ratio = 1.000E+00 err = 3.202E-04 (       230)
 z =  3.782E+00 should be  3.790E+00 ratio = 9.980E-01 err = 1.969E-03 (       249)
 z =  1.925E+00 should be  1.884E+00 ratio = 1.022E+00 err = 2.155E-02 (     75464)
 z = -3.261E-02 should be -3.070E-02 ratio = 1.062E+00 err = 6.233E-02 (    104911)
 z = -2.657E-03 should be -1.819E-03 ratio = 1.461E+00 err = 4.608E-01 (    191147)
 z = -4.231E-03 should be -9.810E-04 ratio = 4.313E+00 err = 3.313E+00 (    372336)
 FAILED [on    4177029 of    4188896 values, max err = 3.313E+00, L2 err =  3.141E-08 tol = 2.225-308]
 checking h.............................
 h =  5.393E+02 should be  5.393E+02 ratio = 1.000E+00 err = 7.922E-07 (         1)
 h =  1.538E+02 should be  1.538E+02 ratio = 1.000E+00 err = 9.922E-07 (         2)
 h =  5.370E+02 should be  5.370E+02 ratio = 1.000E+00 err = 9.093E-07 (         3)
 h =  1.504E+03 should be  1.504E+03 ratio = 1.000E+00 err = 1.055E-06 (         4)
 h =  3.277E+02 should be  3.277E+02 ratio = 1.000E+00 err = 1.025E-06 (         5)
 h =  1.577E+03 should be  1.577E+03 ratio = 1.000E+00 err = 1.083E-06 (         6)
 h =  7.226E+02 should be  7.226E+02 ratio = 1.000E+00 err = 1.098E-06 (         7)
 h =  7.318E+01 should be  7.318E+01 ratio = 1.000E+00 err = 8.341E-07 (         8)
 h =  3.234E+01 should be  3.234E+01 ratio = 1.000E+00 err = 8.257E-07 (         9)
 h =  1.228E+02 should be  1.228E+02 ratio = 1.000E+00 err = 4.224E-06 (        67)
 h =  7.668E+01 should be  7.667E+01 ratio = 1.000E+00 err = 4.727E-05 (       238)
 h =  2.256E+01 should be  2.254E+01 ratio = 1.001E+00 err = 5.896E-04 (      2502)
 FAILED [on    4159413 of    4188896 values, max err = 4.017E-03, L2 err =  6.324E-09 tol = 2.225-308]
 checking vx............................
 vx = -8.326E-04 should be -8.326E-04 ratio = 1.000E+00 err = 4.199E-08 (         1)
 vx =  2.330E-04 should be  2.330E-04 ratio = 1.000E+00 err = 6.545E-08 (         2)
 vx =  1.472E-03 should be  1.472E-03 ratio = 1.000E+00 err = 2.068E-08 (         3)
 vx =  1.632E-03 should be  1.632E-03 ratio = 1.000E+00 err = 2.513E-08 (         4)
 vx =  1.214E-03 should be  1.214E-03 ratio = 1.000E+00 err = 2.193E-08 (         5)
 vx =  1.959E-03 should be  1.959E-03 ratio = 1.000E+00 err = 1.936E-08 (         6)
 vx =  1.772E-03 should be  1.772E-03 ratio = 1.000E+00 err = 2.011E-08 (         7)
 vx = -9.072E-04 should be -9.072E-04 ratio = 1.000E+00 err = 4.144E-08 (         8)
 vx = -4.653E-04 should be -4.653E-04 ratio = 1.000E+00 err = 2.269E-08 (         9)
 vx =  1.661E-05 should be  1.661E-05 ratio = 1.000E+00 err = 4.273E-07 (        11)
 vx = -8.286E-04 should be -8.286E-04 ratio = 1.000E+00 err = 1.543E-06 (        31)
 vx = -1.158E-03 should be -1.158E-03 ratio = 1.000E+00 err = 3.364E-06 (        67)
 vx = -1.364E-03 should be -1.364E-03 ratio = 1.000E+00 err = 8.026E-06 (        70)
 vx =  1.340E-04 should be  1.340E-04 ratio = 1.000E+00 err = 3.021E-05 (       167)
 vx =  2.231E-02 should be  2.232E-02 ratio = 9.999E-01 err = 1.239E-04 (       175)
 vx =  9.553E-06 should be  9.557E-06 ratio = 9.996E-01 err = 4.237E-04 (       183)
 vx =  2.259E-05 should be  2.291E-05 ratio = 9.861E-01 err = 1.391E-02 (     43294)
 vx =  1.460E-06 should be  1.359E-06 ratio = 1.075E+00 err = 7.454E-02 (     50432)
 vx = -1.555E-06 should be -4.896E-06 ratio = 3.177E-01 err = 6.823E-01 (    236086)
 FAILED [on    4177029 of    4188896 values, max err = 9.377E-01, L2 err =  2.686E-05 tol = 2.225-308]
 checking vy............................
 vy =  1.614E-02 should be  1.614E-02 ratio = 1.000E+00 err = 8.217E-08 (         1)
 vy =  2.218E-02 should be  2.218E-02 ratio = 1.000E+00 err = 3.621E-08 (         2)
 vy =  2.577E-02 should be  2.577E-02 ratio = 1.000E+00 err = 2.412E-08 (         3)
 vy =  2.871E-02 should be  2.871E-02 ratio = 1.000E+00 err = 1.775E-08 (         4)
 vy =  2.539E-02 should be  2.539E-02 ratio = 1.000E+00 err = 2.514E-08 (         5)
 vy =  2.899E-02 should be  2.899E-02 ratio = 1.000E+00 err = 1.730E-08 (         6)
 vy =  2.761E-02 should be  2.761E-02 ratio = 1.000E+00 err = 1.989E-08 (         7)
 vy =  1.886E-02 should be  1.886E-02 ratio = 1.000E+00 err = 5.512E-08 (         8)
 vy =  2.083E-02 should be  2.083E-02 ratio = 1.000E+00 err = 4.274E-08 (         9)
 vy =  8.652E-04 should be  8.652E-04 ratio = 1.000E+00 err = 8.792E-06 (        31)
 vy = -4.263E-02 should be -4.264E-02 ratio = 9.999E-01 err = 5.115E-05 (       175)
 vy = -6.126E-05 should be -6.130E-05 ratio = 9.993E-01 err = 6.955E-04 (       272)
 vy = -2.195E-02 should be -2.188E-02 ratio = 1.003E+00 err = 3.152E-03 (      2502)
 vy = -6.716E-06 should be -6.988E-06 ratio = 9.611E-01 err = 3.890E-02 (     19458)
 vy = -1.689E-04 should be -1.560E-04 ratio = 1.083E+00 err = 8.266E-02 (     30163)
 vy =  3.906E-05 should be  1.160E-04 ratio = 3.366E-01 err = 6.634E-01 (    495251)
 vy = -3.281E-04 should be -2.609E-05 ratio = 1.258E+01 err = 1.158E+01 (    770745)
 FAILED [on    4177029 of    4188896 values, max err = 1.158E+01, L2 err =  6.277E-06 tol = 2.225-308]
 checking vz............................
 vz =  4.606E-05 should be  4.606E-05 ratio = 1.000E+00 err = 4.983E-07 (         1)
 vz = -7.418E-05 should be -7.418E-05 ratio = 1.000E+00 err = 2.874E-08 (         2)
 vz =  2.039E-05 should be  2.039E-05 ratio = 1.000E+00 err = 2.886E-08 (         3)
 vz =  9.862E-05 should be  9.862E-05 ratio = 1.000E+00 err = 1.816E-08 (         4)
 vz = -2.076E-05 should be -2.076E-05 ratio = 1.000E+00 err = 7.638E-09 (         5)
 vz = -2.563E-05 should be -2.563E-05 ratio = 1.000E+00 err = 1.460E-08 (         6)
 vz = -8.387E-05 should be -8.387E-05 ratio = 1.000E+00 err = 8.042E-08 (         7)
 vz = -5.464E-05 should be -5.464E-05 ratio = 1.000E+00 err = 6.708E-08 (         8)
 vz = -1.432E-05 should be -1.432E-05 ratio = 1.000E+00 err = 5.088E-08 (         9)
 vz =  2.915E-05 should be  2.915E-05 ratio = 1.000E+00 err = 8.184E-06 (        31)
 vz =  5.183E-04 should be  5.183E-04 ratio = 1.000E+00 err = 2.186E-05 (        67)
 vz = -1.458E-03 should be -1.459E-03 ratio = 9.998E-01 err = 1.709E-04 (       175)
 vz =  7.524E-05 should be  7.562E-05 ratio = 9.950E-01 err = 5.022E-03 (       284)
 vz = -4.612E-06 should be -4.392E-06 ratio = 1.050E+00 err = 5.018E-02 (     19460)
 vz =  1.670E-06 should be  1.262E-06 ratio = 1.324E+00 err = 3.240E-01 (     95069)
 vz = -6.683E-06 should be -2.761E-06 ratio = 2.421E+00 err = 1.421E+00 (   2186235)
 FAILED [on    4177029 of    4188896 values, max err = 2.637E+00, L2 err =  1.689E-05 tol = 2.225-308]
 checking u.............................
 u =  4.646E-10 should be  4.646E-10 err = 5.626E-15 (         1)
 u =  3.604E-11 should be  3.604E-11 err = 6.894E-17 (         2)
 u =  1.874E-09 should be  1.874E-09 err = 3.115E-15 (         3)
 u =  2.841E-09 should be  2.841E-09 err = 5.480E-15 (         4)
 u =  1.022E-09 should be  1.022E-09 err = 1.766E-15 (         5)
 u =  3.106E-09 should be  3.106E-09 err = 5.980E-15 (         6)
 u =  2.434E-09 should be  2.434E-09 err = 4.881E-15 (         7)
 u =  2.910E-12 should be  2.910E-12 err = 3.735E-18 (         8)
 u =  1.508E-12 should be  1.508E-12 err = 2.441E-18 (         9)
 u =  1.246E-06 should be  1.246E-06 ratio = 1.000E+00 err = 8.460E-06 (        67)
 u =  3.845E-06 should be  3.846E-06 ratio = 9.999E-01 err = 1.013E-04 (       175)
 u =  6.615E-04 should be  6.631E-04 ratio = 9.976E-01 err = 2.397E-03 (      2502)
 FAILED [on    4177029 of    4188896 values, max err = 3.831E-02, L2 err =  4.915E-06 tol = 2.225-308]

 diffdumps: we wish you a pleasant journey 

       particle IDs differ            0  times
          positions differ      4177029  times
  smoothing lengths differ      4159413  times
         velocities differ      4177029  times
   thermal energies differ      4177029  times

MAX RMS ERROR: 2.6858E-05

 FILES DIFFER

 To specify a tolerance, use:

   diffdumps tde_01301 tde_01301.ref 1.e-15

@danieljprice
Copy link
Owner

yes, the tde benchmark needs updating because we changed a timestep condition. The problem with running the benchmarks in the actions suite is that they are not a test of "correctness", just a test of "sameness". The most common problem is anything that changes the timestep size will cause differences in the benchmark. But "difference" /= "wrong".

@danieljprice danieljprice merged commit 60a33b0 into master Mar 10, 2022
@danieljprice danieljprice deleted the moddump-binary branch March 10, 2022 11:31
StephaneMichoulier pushed a commit to StephaneMichoulier/phantom that referenced this pull request Mar 18, 2023
(moddump_binary) cleanup to improve code clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants