Skip to content
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

Fix typos in upper air regridding code. #43

Merged
merged 3 commits into from
Jul 19, 2021

Conversation

bena-nasa
Copy link

@bena-nasa bena-nasa commented Jul 15, 2021

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:

u0(is_i:ie_i,js_i:je_i,k) = gslice_r8(is_i:ie+i,tileoff+js_i:tileoff+je_i)

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!

! Read U
         allocate (  u0(isd_i:ied_i,jsd_i:jed_i+1,km) )
         u0(:,:,:) = 0.0
         allocate (  u0p(isd_i:ied_i,jsd_i:jed_i+1,km) )
         u0(:,:,:) = 0.0
         u0p(:,:,:) = 0.0
         if (isNC4) then
            tileoff = (tile-1)*(jm/ntiles)
               write(*,*)"bmaa ", maxval(u0),ie_i,ie+i
            do k=1,km
               call MAPL_VarRead(formatter,"U",gslice_r8,lev=k)
               u0(is_i:ie_i,js_i:je_i,k) = gslice_r8(is_i:ie+i,tileoff+js_i:tileoff+je_i)
               u0p(is_i:ie_i,js_i:je_i,k) = gslice_r8(is_i:ie_i,tileoff+js_i:tileoff+je_i)
            enddo
            if (any(u0/=u0p)) then
               write(*,*)"FOUND DIFF"
            end if

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.

@bena-nasa bena-nasa added Contingent - DNA These changes are contingent on other PRs 0 diff The changes in this pull request have verified to be zero-diff with the target branch. bug Something isn't working and removed Contingent - DNA These changes are contingent on other PRs labels Jul 15, 2021
@bena-nasa bena-nasa requested review from wmputman and mathomp4 July 16, 2021 13:17
Copy link
Member

@mathomp4 mathomp4 left a comment

Choose a reason for hiding this comment

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

I trust Ben. So approved by me!

@mathomp4 mathomp4 added 0 diff structural Structural changes to repository that are zero-diff and removed 0 diff structural Structural changes to repository that are zero-diff labels Jul 16, 2021
@bena-nasa bena-nasa merged commit 3126bd2 into geos/develop Jul 19, 2021
@bena-nasa bena-nasa deleted the hotfix/bmauer/fix_typo_in_geos_regridding branch July 19, 2021 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 diff The changes in this pull request have verified to be zero-diff with the target branch. bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants