Fix typos in upper air regridding code. #43
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While testing regrid.pl and having built the model with the debug options I noticed that interp_restarts was crashing. On examination I found a typo that had been replicated, probably due to copying and pasting code. The typo was that what should have been an ie_i was ie+1 like in the following block of code:
Note these variables were the upper bound for the local processor in the first dimension and ie_i is for the input grid and ie was for the output grid. Finally i is used in a loop before this and loops from ie to is+1.
I've tested now going from c24 -> c48 and c360 -> c90 and I'm getting the same result in the fixed code on the branch and the stock code with the typo. I'm not sure how to explain this as at least in the c360 -> c90 case would result in not enough data getting copied to the left hand side of the expression. However, I even tried making a new variable (u0p in the code below) and comparison when filling it with the right vs wrong expression and the check that the arrays were equal did not report any different values!
So at this point I don't know what to say other than despite the typo it seems like it by accident copies the correct memory into the left hand side.
In addition in fv_regrid_c3c.F90 after regridding to the output grid, a call to p_var is made in get_geos_ic that causes the code to crash when debugging is on when trying to fill pkz. In interp_restarts.F90 after leaving get_geos_ic, we immediately fill pkz anyway so it just gets overwritten. So I added a flag to skip the pkz calculation at the end of p_var so the code will run with debugging on. I've confirmed whether or not you execute the code in p_var that causes the code to crash in debugging mode seems to have no difference in results when running with optimization.