New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 12243 – NEMO

Changeset 12243


Ignore:
Timestamp:
2019-12-13T12:55:39+01:00 (4 years ago)
Author:
clem
Message:

avoid out of bounds when the size of the regional domain is exactly the same as the size of the reference domain (with ln_agrif_domain=F)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • utils/tools/NESTING/src/agrif_interpolation.f90

    r10381 r12243  
    198198    CHARACTER(*) :: typevar    
    199199 
    200     INTEGER :: nxf,nyf,zx,zy 
    201     INTEGER :: ji,jj,jif,jjf,jic,jjc,jdecx,jdecy 
     200    INTEGER :: nxf,nyf,nxc,nyc,zx,zy 
     201    INTEGER :: ji,jj,jif,jjf,jic,jjc,jic1,jjc1,jdecx,jdecy 
    202202    REAL*8 :: Ax, Bx, Ay, By 
    203203 
    204204    nxf = SIZE(tabout,1) 
    205205    nyf = SIZE(tabout,2) 
     206 
     207    nxc = SIZE(tabin,1) 
     208    nyc = SIZE(tabin,2) 
    206209 
    207210    SELECT CASE(typevar) 
     
    248251          Ay = 1. - By 
    249252 
    250           tabout(ji,jj) = ( Bx * tabin(jic+1,jjc  ) + Ax * tabin(jic,jjc  ) ) * Ay + & 
    251              &            ( Bx * tabin(jic+1,jjc+1) + Ax * tabin(jic,jjc+1) ) * By 
     253          jic1 = MIN( nxc, jic+1 ) ! avoid out of bounds for tabin below 
     254          jjc1 = MIN( nyc, jjc+1 ) !             -- 
     255 
     256          tabout(ji,jj) = ( Bx * tabin(jic1,jjc ) + Ax * tabin(jic,jjc ) ) * Ay + & 
     257             &            ( Bx * tabin(jic1,jjc1) + Ax * tabin(jic,jjc1) ) * By 
    252258       END DO 
    253259    END DO 
Note: See TracChangeset for help on using the changeset viewer.