Skip to content

src/offline/cable_output.F90: Update order of operations for CASA unit conversions#710

Merged
SeanBryan51 merged 1 commit intomainfrom
cable-output-update-CASA-unit-conversions
Mar 13, 2026
Merged

src/offline/cable_output.F90: Update order of operations for CASA unit conversions#710
SeanBryan51 merged 1 commit intomainfrom
cable-output-update-CASA-unit-conversions

Conversation

@SeanBryan51
Copy link
Copy Markdown
Collaborator

@SeanBryan51 SeanBryan51 commented Mar 13, 2026

This change updates the order of operations for applying unit conversions CASA output variables such that the unit conversion factor is computed before applying the conversion to the array being written.

This change is required to demonstrate bitwise equivalence with the new parallel I/O output module (#655).

Type of change

  • Enhancement

Testing

  • Are the changes bitwise-compatible with the main branch? If working on an optional feature, are the results bitwise-compatible when this feature is off? If yes, copy benchcab output showing successful completion of the bitwise compatibility tests or equivalent results below this line.

Benchcab currently does not test CASA, so benchcab results are bitwise identical:

2026-03-13 14:27:58,185 - INFO - benchcab.benchcab.py:380 - Running comparison tasks...
2026-03-13 14:27:58,211 - INFO - benchcab.benchcab.py:381 - tasks: 168 (models: 2, sites: 42, science configurations: 4)
2026-03-13 14:30:40,431 - INFO - benchcab.benchcab.py:391 - 0 failed, 168 passed

📚 Documentation preview 📚: https://cable--710.org.readthedocs.build/en/710/

@SeanBryan51
Copy link
Copy Markdown
Collaborator Author

Running CASA manually using these scripts shows precision level differences:

nccmp -df -c 1 archive_main/output000/outputs/cable_out.nc archive_cable-output-update-CASA-unit-conversions/output000/outputs/cable_out.nc
DIFFER : VARIABLE : RootResp : POSITION : [0,20,166] : VALUES : 0.205504 <> 0.205504
DIFFER : VARIABLE : StemResp : POSITION : [0,21,170] : VALUES : 0.0347765 <> 0.0347765
DIFFER : VARIABLE : NBP : POSITION : [0,22,167] : VALUES : -0.743505 <> -0.743505
DIFFER : VARIABLE : dCdt : POSITION : [0,22,167] : VALUES : -0.743505 <> -0.743505
DIFFER : VARIABLE : PlantTurnover : POSITION : [0,21,166] : VALUES : 0.167951 <> 0.167951
DIFFER : VARIABLE : PlantTurnoverLeaf : POSITION : [0,22,168] : VALUES : 0.0308066 <> 0.0308066
DIFFER : VARIABLE : PlantTurnoverFineRoot : POSITION : [0,22,167] : VALUES : 0.148981 <> 0.148981
DIFFER : VARIABLE : PlantTurnoverWood : POSITION : [0,22,169] : VALUES : 2.95271e-08 <> 2.95271e-08

The values are equivalent when allowing for an absolute tolerance of 1e-6:

nccmp -d -t 1e-6 archive_main/output000/outputs/cable_out.nc archive_cable-output-update-CASA-unit-conversions/output000/outputs/cable_out.nc
echo $?
0

Copy link
Copy Markdown
Contributor

@Whyborn Whyborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is because conversion factors will be applied as a multiplication before writing? It's a good idea anyway, since divisions are slower than multiplications.

@SeanBryan51
Copy link
Copy Markdown
Collaborator Author

I'm guessing this is because conversion factors will be applied as a multiplication before writing?

Yup

@SeanBryan51 SeanBryan51 merged commit 0688ca1 into main Mar 13, 2026
5 checks passed
@SeanBryan51 SeanBryan51 deleted the cable-output-update-CASA-unit-conversions branch March 13, 2026 04:09
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