CFMIP / COSPv2.0

COSP - The CFMIP (Cloud Feedbacks Model Intercomparison Project) Observation Simulator Package
42 stars 38 forks source link

Be explicit about floating point literals #29

Closed brhillman closed 5 years ago

brhillman commented 5 years ago

Floating point literals that include a decimal without explicit precision, i.e. 1., are dangerous because we do not know what precision the literal will be interpreted as, and expressions like 1.+bpm, where bpm has explicit precision wp caused Intel to throw errors when compiled with the -r8 flag. Adding precision to the literals fixes this problem. That is, replacing 1.+bpm with 1._wp+bpm. Fixes #28.

brhillman commented 5 years ago

Results of regression test:

############################################################################################
Treating relative differences less than 0.0010000000% as insignificant
  atb532_perp:         16.89 % of values differ, relative range:  -5.90e-05 to  7.03e-05
  atb532:              16.93 % of values differ, relative range:  -5.89e-05 to  7.02e-05
  cfadLidarsr532:       0.00 % of values differ, relative range:  -1.00e+00 to  1.00e+00
  lidarBetaMol532:     19.35 % of values differ, relative range:  -5.91e-05 to  7.02e-05
  clthinemis:           0.65 % of values differ, relative range:  -1.19e-05 to -1.19e-05
  lidarBetaMol532gr:     18.42 % of values differ, relative range:  -5.89e-05 to  6.97e-05
  atb532gr:            13.71 % of values differ, relative range:  -5.89e-05 to  6.97e-05
  lidarBetaMol355:      3.97 % of values differ, relative range:  -1.53e-05 to  2.19e-05
  atb355:               3.72 % of values differ, relative range:  -1.53e-05 to  2.21e-05
  dbze94:               0.24 % of values differ, relative range:  -2.78e-04 to  1.05e-04
  boxtauisccp:          1.93 % of values differ, relative range:  -2.37e-05 to  2.40e-05
  boxptopisccp:         2.22 % of values differ, relative range:  -4.67e-05 to  4.10e-05
All other fields match.
brhillman commented 5 years ago

Diffs seem to be result of machine precision. Comparison against outputs from master built and run on the same machine with the same compiler and flags reveals no diffs:

############################################################################################
Treating relative differences less than 0.0010000000% as insignificant
All fields match
(python2) [bhillma@ghost-login2 driver (fix-quickbeam-optics-types)]$
RobertPincus commented 5 years ago

Thanks for doing this, @brhillman.