rework or remove max_patch_per_col
- Dominant language
- Fortran
- Stars
- 352
- Forks
- 361
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
**Bill Sacks < sacks@ucar.edu > - 2015-10-04 14:41:13 -0600**
**Bugzilla Id:** [2227](http://bugz.cgd.ucar.edu/show_bug.cgi?id=2227)
**Bugzilla CC:** andre@ucar.edu, rfisher@ucar.edu,
Currently in clm_varpar, we have:
max_patch_per_col= max(numpft+1, numcft, maxpatch_urb)
This is used in loops in the code like this:
do pi = 1,max_patch_per_col
do j = 1,nlevsoi
do fc = 1, num_hydrologyc
c = filter_hydrologyc(fc)
if (pi <= col%npatches(c)) then
However: Using numcft in this 'max' gives a significant overestimate of max_patch_per_col when use_crop is true. This should be reworked - or, better, removed from the code entirely (because it is a maintenance problem, and I can't imagine that looping idioms that use it help performance that much, and likely they hurt performance - at least when it is overestimated by so much.)
Loops like this could be reworked to avoid needing max_patch_per_col by either:
(1) Looping over patches, and finding the corresponding column with patch%col(p)
(2) Looping over columns, then looping from begp to endp in an inner loop. This would likely be less vectorization-friendly, but you save many unnecessary loop iterations, so it's probably not likely to hurt performance much, and may help it.
Contributor guide
Assessment
This issue has not been assessed yet.