-
Notifications
You must be signed in to change notification settings - Fork 388
Fixes indexing issue in SurfaceAreaWeighted AM #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes indexing issue in SurfaceAreaWeighted AM #173
Conversation
|
There is an issue in MPAS-analysis with time series analysis in the ocean. The surface area averaged SST does not look correct, e.g. see here in newer versions of the code, the workArray variable is started at 2 instead of 1 as in earlier versions of the code. This PR fixes this discrepancy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch @vanroekel. But didn't the n=1 on the previous line help initialize workArray(n,:) correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it only initialized the 1st index, previously all indices were initialized to zero. I've reverted now to using
workArray(:,:) = 0.0_RKIND
which should initialize the whole array to zero and not just workArray(1,:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I don't even remember when this analysis member was changed. Anyways, thanks for finding this.
xylar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix looks right to me. I'm surprised that we just noticed it now, given that the code changes are from 6 months ago.
|
So if I understand the error correctly, the plots are actually showing a time series of global mean |
because probably most simulations we have looked at recently were run with an older version of the code.. We finally noticed when @darincomeau and Gennaro used the most recent code for the newer simulations. Glad it didn't affect the larger simulation campaigns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are removing an index advancement here. Were all the variables off by an index of one before?
For example, latentHeatFlux was put in workArray(4,:) and will now be put in workArray(3,:). Do we need to make a corresponding index adjustment somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, everything is off by one index. Currently, we only use SST in MPAS analysis so that's the only one we noticed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I've answered my own question. This is the original in 0b984bd
src/core_ocean/analysis_members/mpas_ocn_surface_area_weighted_averages.F
345 ! copy data into work array
346 workArray( :,:) = 0.0_RKIND
347 workArray( 1,:) = workMask(:)
348 workArray( 2,:) = areaCell(:)
349 if (activeTracersBulkRestoringPKG) workArray( 3,:) = latentHeatFlux(:)
and the bug was introduced in 4b64b2d. So this PR just restores the indexing back to the original.
mark-petersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @vanroekel
|
This will need to be put on maint-1.1 and maint-1.2. |
|
We will also need to decide how to proceed with the Cryosphere simulations. We could put a hack in MPAS-Analysis if we don't want to start anything (particularly the mid-res) over. |
|
@matthewhoffman, you are marked as a reviewer here because the code being modified was yours. I think this is a pretty high priority to fix so please take a look when you can. |
So I think this needs some discussion. The trick that @mark-petersen used to merge to maint-1.2 the last time is kind of a one-off. There are now 2 copies of the same commit in the history of |
Yes, I'd say let's do that for the simulation that has already started (@darincomeau can do that on his local branch of mpas-a), and then update to this fix for the newer simulations. |
|
Yes, since we are just off by an index, it is easier to adjust MPAS-Analysis, rather than have an index change part-way through by changing MPAS-Ocean code for a particular simulation already underway. |
|
To get this to work in mpas-analysis, I think the global SST and nino index routines need to read |
|
@vanroekel: I would do a mpas-a hack only locally (not on |
|
We have 8 simulations underway with the |
|
So, I would not change the code for the 8 simulations that are already under way, just have an extra version of mpas-a (we could tag it, for provenance) to analyze them. |
Nothing is presently being stored in workArray(1,:) leading to all values in the var_array being shifted by one index. This is causing MPAS-Analysis failures. This results in avgSurfaceTemperature values being stored in avgSurfaceSalinity in output files. This commit shifts indices back one value so the ordering is as expected.
46726cb to
5a8f91c
Compare
|
@vanroekel, I was able to force push to your fork after rebasing your branch to the commit that introduced the bug. The commit itself is unchanged, just its branch point. |
|
@jonbob This PR is number 3 on the list to get into E3SM master. I will merge this PR after the other two go in:
Our philosophy here is to make smaller, more frequent commits into E3SM so we can more easily catch and fix bugs. I also don't want to merge into MPAS-Model:ocean/develop until it is next in line for E3SM. |
|
OK, I'll get started with 2779 today and we'll try to clear up the backlog |
…elop Nothing is presently being stored in workArray(1,:) leading to all values in the var_array being shifted by one index. This is causing MPAS-Analysis failures. This results in avgSurfaceTemperature values being stored in avgSurfaceSalinity in output files. This commit shifts indices back one value so the ordering is as expected.
|
Retested local merge with MPAS nightly regression suite, and on E3SM: |
…elop Nothing is presently being stored in workArray(1,:) leading to all values in the var_array being shifted by one index. This is causing MPAS-Analysis failures. This results in avgSurfaceTemperature values being stored in avgSurfaceSalinity in output files. This commit shifts indices back one value so the ordering is as expected.
…elop Nothing is presently being stored in workArray(1,:) leading to all values in the var_array being shifted by one index. This is causing MPAS-Analysis failures. This results in avgSurfaceTemperature values being stored in avgSurfaceSalinity in output files. This commit shifts indices back one value so the ordering is as expected.
Nothing is presently being stored in workArray(1,:) leading to all
values in the var_array being shifted by one index. This is causing
MPAS-Analysis failures. This results in avgSurfaceTemperature values
being stored in avgSurfaceSalinity in output files.
This commit shifts indices back one value so the ordering is as
expected.