mom-ocean / MOM5

The Modular Ocean Model
https://mom-ocean.github.io/
GNU Lesser General Public License v3.0
82 stars 95 forks source link

optimise diagnostic masking #352

Closed russfiedler closed 2 years ago

russfiedler commented 2 years ago

This commit reorganizes the masking logic in ocean_util.F90. The rarely used threshold_mask is made allocatable and its use is avoided if not required saving the creation of a 3D temporary array and unneeded multiplication. Savings of about 10% wall time have been observed in one particular OFAM configuration.

aidanheerdegen commented 2 years ago

Nice work @russfiedler.

aidanheerdegen commented 2 years ago

You've tested it works in the absence of abs_max or abs_min. Looks difficult to test the positive case as you need to turn on neutral physics and wait/hope for a value that exceeds the hard-coded thresholds.

Seems ok to me. I'm happy to merge.

aekiss commented 2 years ago

thanks @russfiedler - I saw a 6% speedup with the 0.1deg IAF cycle 4 old: Walltime Used: 00:49:35 new: Walltime Used: 00:46:45

aekiss commented 2 years ago

I can also confirm that this code change does not alter the outputs https://nbviewer.org/github/aekiss/notebooks/blob/2065be9/check-MOM-PR352.ipynb

russfiedler commented 2 years ago

Nice. I think this means that going forward we should pay attention to a) The use of automatic arrays and b) The creation of (possibly unecessary) temporary arrays in arguments to functions/subroutines.