Changeset 9031
- Timestamp:
- 2017-12-14T11:10:02+01:00 (7 years ago)
- Location:
- branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_lim3_update.F90
r9019 r9031 59 59 Agrif_UseSpecialValueInUpdate = .TRUE. 60 60 # if defined TWO_WAY 61 IF( MOD(nbcline,nbclineupdate) == 0) THEN ! update the whole basin at each nbclineupdate (=nn_cln_update) baroclinic parent time steps 62 ! nbcline is incremented (+1) at the end of each parent time step from 0 (1st time step) 63 CALL Agrif_Update_Variable( tra_ice_id , procname = update_tra_ice ) 64 CALL Agrif_Update_Variable( u_ice_id , procname = update_u_ice ) 65 CALL Agrif_Update_Variable( v_ice_id , procname = update_v_ice ) 66 ELSE ! update only the boundaries defined par locupdate 67 CALL Agrif_Update_Variable( tra_ice_id , locupdate=(/0,2/), procname = update_tra_ice ) 68 CALL Agrif_Update_Variable( u_ice_id , locupdate=(/0,1/), procname = update_u_ice ) 69 CALL Agrif_Update_Variable( v_ice_id , locupdate=(/0,1/), procname = update_v_ice ) 70 ENDIF 61 CALL Agrif_Update_Variable( tra_ice_id , procname = update_tra_ice ) 62 CALL Agrif_Update_Variable( u_ice_id , procname = update_u_ice ) 63 CALL Agrif_Update_Variable( v_ice_id , procname = update_v_ice ) 64 65 ! CALL Agrif_Update_Variable( tra_ice_id , locupdate=(/0,2/), procname = update_tra_ice ) 66 ! CALL Agrif_Update_Variable( u_ice_id , locupdate=(/0,1/), procname = update_u_ice ) 67 ! CALL Agrif_Update_Variable( v_ice_id , locupdate=(/0,1/), procname = update_v_ice ) 71 68 # endif 72 69 Agrif_SpecialValueFineGrid = 0. -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_oce.F90
r9019 r9031 17 17 18 18 PUBLIC agrif_oce_alloc ! routine called by nemo_init in nemogcm.F90 19 19 #if defined key_vertical 20 PUBLIC reconstructandremap ! remapping routine 21 #endif 20 22 ! !!* Namelist namagrif: AGRIF parameters 21 23 LOGICAL , PUBLIC :: ln_spc_dyn = .FALSE. !: 22 INTEGER , PUBLIC :: nn_cln_update = 3 !: update frequency23 24 INTEGER , PUBLIC, PARAMETER :: nn_sponge_len = 2 !: Sponge width (in number of parent grid points) 24 25 REAL(wp), PUBLIC :: rn_sponge_tra = 2800. !: sponge coeff. for tracers 25 26 REAL(wp), PUBLIC :: rn_sponge_dyn = 2800. !: sponge coeff. for dynamics 26 27 LOGICAL , PUBLIC :: ln_chk_bathy = .FALSE. !: check of parent bathymetry 27 28 LOGICAL , PUBLIC :: lk_agrif_clp = .TRUE. !: Force clamped bcs 28 29 ! !!! OLD namelist names 29 INTEGER , PUBLIC :: nbcline = 0 !: update counter30 INTEGER , PUBLIC :: nbclineupdate !: update frequency31 30 REAL(wp), PUBLIC :: visc_tra !: sponge coeff. for tracers 32 31 REAL(wp), PUBLIC :: visc_dyn !: sponge coeff. for dynamics … … 35 34 LOGICAL , PUBLIC :: spongedoneU = .FALSE. !: dynamics sponge layer indicator 36 35 LOGICAL , PUBLIC :: lk_agrif_fstep = .TRUE. !: if true: first step 37 LOGICAL , PUBLIC :: lk_agrif_doupd = .TRUE. !: if true: send update from current grid38 36 LOGICAL , PUBLIC :: lk_agrif_debug = .FALSE. !: if true: print debugging info 39 37 … … 102 100 END FUNCTION agrif_oce_alloc 103 101 102 #if defined key_vertical 103 SUBROUTINE reconstructandremap(tabin,hin,tabout,hout,N,Nout) 104 !!---------------------------------------------------------------------- 105 !! *** FUNCTION reconstructandremap *** 106 !!---------------------------------------------------------------------- 107 IMPLICIT NONE 108 INTEGER N, Nout 109 REAL(wp) tabin(N), tabout(Nout) 110 REAL(wp) hin(N), hout(Nout) 111 REAL(wp) coeffremap(N,3),zwork(N,3) 112 REAL(wp) zwork2(N+1,3) 113 INTEGER jk 114 DOUBLE PRECISION, PARAMETER :: dsmll=1.0d-8 115 REAL(wp) q,q01,q02,q001,q002,q0 116 REAL(wp) z_win(1:N+1), z_wout(1:Nout+1) 117 REAL(wp),PARAMETER :: dpthin = 1.D-3 118 INTEGER :: k1, kbox, ktop, ka, kbot 119 REAL(wp) :: tsum, qbot, rpsum, zbox, ztop, zthk, zbot, offset, qtop 120 121 z_win(1)=0.; z_wout(1)= 0. 122 DO jk=1,N 123 z_win(jk+1)=z_win(jk)+hin(jk) 124 ENDDO 125 126 DO jk=1,Nout 127 z_wout(jk+1)=z_wout(jk)+hout(jk) 128 ENDDO 129 130 DO jk=2,N 131 zwork(jk,1)=1./(hin(jk-1)+hin(jk)) 132 ENDDO 133 134 DO jk=2,N-1 135 q0 = 1./(hin(jk-1)+hin(jk)+hin(jk+1)) 136 zwork(jk,2)=hin(jk-1)+2.*hin(jk)+hin(jk+1) 137 zwork(jk,3)=q0 138 ENDDO 139 140 DO jk= 2,N 141 zwork2(jk,1)=zwork(jk,1)*(tabin(jk)-tabin(jk-1)) 142 ENDDO 143 144 coeffremap(:,1) = tabin(:) 145 146 DO jk=2,N-1 147 q001 = hin(jk)*zwork2(jk+1,1) 148 q002 = hin(jk)*zwork2(jk,1) 149 IF (q001*q002 < 0) then 150 q001 = 0. 151 q002 = 0. 152 ENDIF 153 q=zwork(jk,2) 154 q01=q*zwork2(jk+1,1) 155 q02=q*zwork2(jk,1) 156 IF (abs(q001) > abs(q02)) q001 = q02 157 IF (abs(q002) > abs(q01)) q002 = q01 158 159 q=(q001-q002)*zwork(jk,3) 160 q001=q001-q*hin(jk+1) 161 q002=q002+q*hin(jk-1) 162 163 coeffremap(jk,3)=coeffremap(jk,1)+q001 164 coeffremap(jk,2)=coeffremap(jk,1)-q002 165 166 zwork2(jk,1)=(2.*q001-q002)**2 167 zwork2(jk,2)=(2.*q002-q001)**2 168 ENDDO 169 170 DO jk=1,N 171 IF(jk.EQ.1 .OR. jk.EQ.N .OR. hin(jk).LE.dpthin) THEN 172 coeffremap(jk,3) = coeffremap(jk,1) 173 coeffremap(jk,2) = coeffremap(jk,1) 174 zwork2(jk,1) = 0. 175 zwork2(jk,2) = 0. 176 ENDIF 177 ENDDO 178 179 DO jk=2,N 180 q002=max(zwork2(jk-1,2),dsmll) 181 q001=max(zwork2(jk,1),dsmll) 182 zwork2(jk,3)=(q001*coeffremap(jk-1,3)+q002*coeffremap(jk,2))/(q001+q002) 183 ENDDO 184 185 zwork2(1,3) = 2*coeffremap(1,1)-zwork2(2,3) 186 zwork2(N+1,3)=2*coeffremap(N,1)-zwork2(N,3) 187 188 DO jk=1,N 189 q01=zwork2(jk+1,3)-coeffremap(jk,1) 190 q02=coeffremap(jk,1)-zwork2(jk,3) 191 q001=2.*q01 192 q002=2.*q02 193 IF (q01*q02<0) then 194 q01=0. 195 q02=0. 196 ELSEIF (abs(q01)>abs(q002)) then 197 q01=q002 198 ELSEIF (abs(q02)>abs(q001)) then 199 q02=q001 200 ENDIF 201 coeffremap(jk,2)=coeffremap(jk,1)-q02 202 coeffremap(jk,3)=coeffremap(jk,1)+q01 203 ENDDO 204 205 zbot=0.0 206 kbot=1 207 DO jk=1,Nout 208 ztop=zbot !top is bottom of previous layer 209 ktop=kbot 210 IF (ztop.GE.z_win(ktop+1)) then 211 ktop=ktop+1 212 ENDIF 213 214 zbot=z_wout(jk+1) 215 zthk=zbot-ztop 216 217 IF(zthk.GT.dpthin .AND. ztop.LT.z_wout(Nout+1)) THEN 218 219 kbot=ktop 220 DO while (z_win(kbot+1).lt.zbot.and.kbot.lt.N) 221 kbot=kbot+1 222 ENDDO 223 zbox=zbot 224 DO k1= jk+1,Nout 225 IF (z_wout(k1+1)-z_wout(k1).GT.dpthin) THEN 226 exit !thick layer 227 ELSE 228 zbox=z_wout(k1+1) !include thin adjacent layers 229 IF(zbox.EQ.z_wout(Nout+1)) THEN 230 exit !at bottom 231 ENDIF 232 ENDIF 233 ENDDO 234 zthk=zbox-ztop 235 236 kbox=ktop 237 DO while (z_win(kbox+1).lt.zbox.and.kbox.lt.N) 238 kbox=kbox+1 239 ENDDO 240 241 IF(ktop.EQ.kbox) THEN 242 IF(z_wout(jk).NE.z_win(kbox).OR.z_wout(jk+1).NE.z_win(kbox+1)) THEN 243 IF(hin(kbox).GT.dpthin) THEN 244 q001 = (zbox-z_win(kbox))/hin(kbox) 245 q002 = (ztop-z_win(kbox))/hin(kbox) 246 q01=q001**2+q002**2+q001*q002+1.-2.*(q001+q002) 247 q02=q01-1.+(q001+q002) 248 q0=1.-q01-q02 249 ELSE 250 q0 = 1.0 251 q01 = 0. 252 q02 = 0. 253 ENDIF 254 tabout(jk)=q0*coeffremap(kbox,1)+q01*coeffremap(kbox,2)+q02*coeffremap(kbox,3) 255 ELSE 256 tabout(jk) = tabin(kbox) 257 ENDIF 258 ELSE 259 IF(ktop.LE.jk .AND. kbox.GE.jk) THEN 260 ka = jk 261 ELSEIF (kbox-ktop.GE.3) THEN 262 ka = (kbox+ktop)/2 263 ELSEIF (hin(ktop).GE.hin(kbox)) THEN 264 ka = ktop 265 ELSE 266 ka = kbox 267 ENDIF !choose ka 268 269 offset=coeffremap(ka,1) 270 271 qtop = z_win(ktop+1)-ztop !partial layer thickness 272 IF(hin(ktop).GT.dpthin) THEN 273 q=(ztop-z_win(ktop))/hin(ktop) 274 q01=q*(q-1.) 275 q02=q01+q 276 q0=1-q01-q02 277 ELSE 278 q0 = 1. 279 q01 = 0. 280 q02 = 0. 281 ENDIF 282 283 tsum =((q0*coeffremap(ktop,1)+q01*coeffremap(ktop,2)+q02*coeffremap(ktop,3))-offset)*qtop 284 285 DO k1= ktop+1,kbox-1 286 tsum =tsum +(coeffremap(k1,1)-offset)*hin(k1) 287 ENDDO !k1 288 289 qbot = zbox-z_win(kbox) !partial layer thickness 290 IF(hin(kbox).GT.dpthin) THEN 291 q=qbot/hin(kbox) 292 q01=(q-1.)**2 293 q02=q01-1.+q 294 q0=1-q01-q02 295 ELSE 296 q0 = 1.0 297 q01 = 0. 298 q02 = 0. 299 ENDIF 300 301 tsum = tsum +((q0*coeffremap(kbox,1)+q01*coeffremap(kbox,2)+q02*coeffremap(kbox,3))-offset)*qbot 302 303 rpsum=1.0d0/zthk 304 tabout(jk)=offset+tsum*rpsum 305 306 ENDIF !single or multiple layers 307 ELSE 308 IF (jk==1) THEN 309 write(*,'(a7,i4,i4,3f12.5)')'problem = ',N,Nout,zthk,z_wout(jk+1),hout(1) 310 ENDIF 311 tabout(jk) = tabout(jk-1) 312 313 ENDIF !normal:thin layer 314 ENDDO !jk 315 316 return 317 end subroutine reconstructandremap 318 #endif 319 104 320 #endif 105 321 !!====================================================================== -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90
r9019 r9031 28 28 USE agrif_oce 29 29 USE phycst 30 USE dynspg_ts, ONLY: un_adv, vn_adv 30 31 ! 31 32 USE in_out_manager … … 42 43 PUBLIC interpe3t, interpumsk, interpvmsk 43 44 PUBLIC Agrif_avm, interpavm 45 >>>>>>> .merge-right.r9019 44 46 45 47 INTEGER :: bdy_tinterp = 0 … … 196 198 END DO 197 199 END DO 198 199 zub(nlci-2,:) = 0._wp ! Correct transport 200 ENDIF 201 zub(nlci-2,:) = 0._wp ! Correct transport 202 DO jk = 1, jpkm1 203 DO jj = 1, jpj 204 zub(nlci-2,jj) = zub(nlci-2,jj) + e3u_a(nlci-2,jj,jk) * ua(nlci-2,jj,jk) 205 END DO 206 END DO 207 DO jj = 1, jpj 208 zub(nlci-2,jj) = zub(nlci-2,jj) * r1_hu_a(nlci-2,jj) 209 END DO 210 211 DO jk = 1, jpkm1 212 DO jj = 1, jpj 213 ua(nlci-2,jj,jk) = ( ua(nlci-2,jj,jk) + ua_b(nlci-2,jj) - zub(nlci-2,jj) ) * umask(nlci-2,jj,jk) 214 END DO 215 END DO 216 ! 217 ! Set tangential velocities to time splitting estimate 218 !----------------------------------------------------- 219 IF( ln_dynspg_ts ) THEN 220 zvb(nlci-1,:) = 0._wp 200 221 DO jk = 1, jpkm1 201 222 DO jj = 1, jpj … … 258 279 ENDIF 259 280 ! 260 ! Smoothing if only 1 ghostcell 261 ! ----------------------------- 262 IF( nbghostcells == 1 ) THEN 281 IF (.NOT.lk_agrif_clp) THEN 263 282 DO jk = 1, jpkm1 ! Smooth 264 283 DO ji = i1, i2 … … 267 286 END DO 268 287 END DO 269 !270 zvb(:,2) = 0._wp ! Correct transport271 DO jk=1,jpkm1272 DO ji=1,jpi273 zvb(ji,2) = zvb(ji,2) + e3v_a(ji,2,jk) * va(ji,2,jk) * vmask(ji,2,jk)274 END DO288 ENDIF 289 ! 290 zvb(:,2) = 0._wp ! Correct transport 291 DO jk=1,jpkm1 292 DO ji=1,jpi 293 zvb(ji,2) = zvb(ji,2) + e3v_a(ji,2,jk) * va(ji,2,jk) * vmask(ji,2,jk) 275 294 END DO 276 295 DO ji = 1, jpi … … 330 349 ENDIF 331 350 ! 332 ! Smoothing if only 1 ghostcell 333 ! ----------------------------- 334 IF( nbghostcells == 1 ) THEN 351 IF (.NOT.lk_agrif_clp) THEN 335 352 DO jk = 1, jpkm1 ! Smooth 336 353 DO ji = i1, i2 … … 339 356 END DO 340 357 END DO 341 !342 zvb(:,nlcj-2) = 0._wp ! Correct transport343 DO jk = 1, jpkm1344 DO ji = 1, jpi345 zvb(ji,nlcj-2) = zvb(ji,nlcj-2) + e3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)346 END DO358 END IF 359 ! 360 zvb(:,nlcj-2) = 0._wp ! Correct transport 361 DO jk = 1, jpkm1 362 DO ji = 1, jpi 363 zvb(ji,nlcj-2) = zvb(ji,nlcj-2) + e3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk) 347 364 END DO 348 365 DO ji = 1, jpi … … 455 472 INTEGER :: ji, jj 456 473 LOGICAL :: ll_int_cons 457 REAL(wp) :: zrhot, zt458 474 !!---------------------------------------------------------------------- 459 475 ! … … 462 478 ll_int_cons = ln_bt_fw ! Assume conservative temporal integration in the forward case only 463 479 ! 464 zrhot = Agrif_rhot() 465 ! 466 ! "Central" time index for interpolation: 467 IF( ln_bt_fw ) THEN 468 zt = REAL( Agrif_NbStepint()+0.5_wp, wp ) / zrhot 469 ELSE 470 zt = REAL( Agrif_NbStepint() , wp ) / zrhot 471 ENDIF 472 ! 473 ! Linear interpolation of sea level 474 Agrif_SpecialValue = 0._wp 475 Agrif_UseSpecialValue = .TRUE. 476 CALL Agrif_Bc_variable( sshn_id, calledweight=zt, procname=interpsshn ) 477 Agrif_UseSpecialValue = .FALSE. 480 ! Enforce volume conservation if no time refinement: 481 IF ( Agrif_rhot()==1 ) ll_int_cons=.TRUE. 478 482 ! 479 483 ! Interpolate barotropic fluxes 480 Agrif_SpecialValue=0. 484 Agrif_SpecialValue=0._wp 481 485 Agrif_UseSpecialValue = ln_spc_dyn 482 486 ! … … 497 501 ubdy_n(:) = 0._wp ; vbdy_n(:) = 0._wp 498 502 ubdy_s(:) = 0._wp ; vbdy_s(:) = 0._wp 499 CALL Agrif_Bc_variable( unb_id, calledweight=zt,procname=interpunb )500 CALL Agrif_Bc_variable( vnb_id, calledweight=zt,procname=interpvnb )503 CALL Agrif_Bc_variable( unb_id, procname=interpunb ) 504 CALL Agrif_Bc_variable( vnb_id, procname=interpvnb ) 501 505 ENDIF 502 506 Agrif_UseSpecialValue = .FALSE. … … 507 511 SUBROUTINE Agrif_ssh( kt ) 508 512 !!---------------------------------------------------------------------- 509 !! *** ROUTINE Agrif_ DYN***513 !! *** ROUTINE Agrif_ssh *** 510 514 !!---------------------------------------------------------------------- 511 515 INTEGER, INTENT(in) :: kt 512 516 ! 513 517 INTEGER :: ji, jj, indx 518 INTEGER :: ji, jj 514 519 !!---------------------------------------------------------------------- 515 520 ! 516 521 IF( Agrif_Root() ) RETURN 517 !! clem ghost 518 ! --- West --- ! 522 ! 523 ! Linear interpolation in time of sea level 524 ! 525 Agrif_SpecialValue = 0._wp 526 Agrif_UseSpecialValue = .TRUE. 527 CALL Agrif_Bc_variable(sshn_id, procname=interpsshn ) 528 Agrif_UseSpecialValue = .FALSE. 529 ! 519 530 IF((nbondi == -1).OR.(nbondi == 2)) THEN 520 531 indx = 1+nbghostcells 521 532 DO jj = 1, jpj 522 533 DO ji = 2, indx 523 ssha(ji,jj)=ssha(indx+1,jj) 524 sshn(ji,jj)=sshn(indx+1,jj) 534 ssha(ji,jj) = hbdy_w(jj) 525 535 ENDDO 526 536 ENDDO … … 532 542 DO jj = 1, jpj 533 543 DO ji = indx, nlci-1 534 ssha(ji,jj)=ssha(indx-1,jj) 535 sshn(ji,jj)=sshn(indx-1,jj) 544 ssha(indx,jj) = hbdy_e(jj) 536 545 ENDDO 537 546 ENDDO … … 543 552 DO jj = 2, indx 544 553 DO ji = 1, jpi 545 ssha(ji,jj)=ssha(ji,indx+1) 546 sshn(ji,jj)=sshn(ji,indx+1) 554 ssha(ji,indx) = hbdy_s(ji) 547 555 ENDDO 548 556 ENDDO … … 554 562 DO jj = indx, nlcj-1 555 563 DO ji = 1, jpi 556 ssha(ji,jj)=ssha(ji,indx-1) 557 sshn(ji,jj)=sshn(ji,indx-1) 564 ssha(ji,indx) = hbdy_n(ji) 558 565 ENDDO 559 566 ENDDO … … 572 579 !!---------------------------------------------------------------------- 573 580 !! clem ghost (starting at i,j=1 is important I think otherwise you introduce a grad(ssh)/=0 at point 2) 581 ! 582 IF( Agrif_Root() ) RETURN 583 ! 574 584 IF((nbondi == -1).OR.(nbondi == 2)) THEN 575 585 DO jj = 1, jpj … … 598 608 END SUBROUTINE Agrif_ssh_ts 599 609 600 601 610 SUBROUTINE Agrif_avm 602 611 !!---------------------------------------------------------------------- … … 606 615 !!---------------------------------------------------------------------- 607 616 ! 608 zalpha = 1._wp ! proper time interpolation impossible ==> use last available value from parent 609 ! 610 Agrif_SpecialValue = 0._wp 617 IF( Agrif_Root() ) RETURN 618 ! 619 zalpha = 1._wp ! JC: proper time interpolation impossible 620 ! => use last available value from parent 621 ! 622 Agrif_SpecialValue = 0.e0 611 623 Agrif_UseSpecialValue = .TRUE. 612 624 ! … … 627 639 INTEGER , INTENT(in ) :: nb , ndir 628 640 ! 629 INTEGER :: ji, jj, jk, jn ! dummy loop indices630 INTEGER :: imin, imax, jmin, jmax 641 INTEGER :: ji, jj, jk, jn, iref, jref ! dummy loop indices 642 INTEGER :: imin, imax, jmin, jmax, N_in, N_out 631 643 REAL(wp) :: zrhox, z1, z2, z3, z4, z5, z6, z7 632 LOGICAL :: western_side, eastern_side,northern_side,southern_side 633 !!---------------------------------------------------------------------- 634 ! 644 LOGICAL :: western_side, eastern_side,northern_side,southern_side 645 ! vertical interpolation: 646 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: ptab_child 647 REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin 648 REAL(wp), DIMENSION(k1:k2) :: h_in 649 REAL(wp), DIMENSION(1:jpk) :: h_out(1:jpk) 650 REAL(wp) :: h_diff, zrhoxy 651 652 zrhoxy = Agrif_rhox()*Agrif_rhoy() 635 653 IF( before ) THEN 636 ptab(i1:i2,j1:j2,k1:k2,n1:n2) = tsn(i1:i2,j1:j2,k1:k2,n1:n2) 637 ELSE 638 ! 654 DO jn = 1,jpts 655 DO jk=k1,k2 656 DO jj=j1,j2 657 DO ji=i1,i2 658 ptab(ji,jj,jk,jn) = tsn(ji,jj,jk,jn) 659 END DO 660 END DO 661 END DO 662 END DO 663 664 # if defined key_vertical 665 DO jk=k1,k2 666 DO jj=j1,j2 667 DO ji=i1,i2 668 ptab(ji,jj,jk,jpts+1) = tmask(ji,jj,jk) * e3t_n(ji,jj,jk) 669 END DO 670 END DO 671 END DO 672 # endif 673 ELSE 674 639 675 western_side = (nb == 1).AND.(ndir == 1) ; eastern_side = (nb == 1).AND.(ndir == 2) 640 676 southern_side = (nb == 2).AND.(ndir == 1) ; northern_side = (nb == 2).AND.(ndir == 2) 677 678 # if defined key_vertical 679 DO jj=j1,j2 680 DO ji=i1,i2 681 iref = ji 682 jref = jj 683 if(western_side) iref=MAX(2,ji) 684 if(eastern_side) iref=MIN(nlci-1,ji) 685 if(southern_side) jref=MAX(2,jj) 686 if(northern_side) jref=MIN(nlcj-1,jj) 687 N_in = 0 688 DO jk=k1,k2 !k2 = jpk of parent grid 689 IF (ptab(ji,jj,jk,n2) == 0) EXIT 690 N_in = N_in + 1 691 tabin(jk,:) = ptab(ji,jj,jk,n1:n2-1) 692 h_in(N_in) = ptab(ji,jj,jk,n2) 693 END DO 694 N_out = 0 695 DO jk=1,jpk ! jpk of child grid 696 IF (tmask(iref,jref,jk) == 0) EXIT 697 N_out = N_out + 1 698 h_out(jk) = e3t_n(iref,jref,jk) 699 ENDDO 700 IF (N_in > 0) THEN 701 DO jn=1,jpts 702 call reconstructandremap(tabin(1:N_in,jn),h_in,ptab_child(ji,jj,1:N_out,jn),h_out,N_in,N_out) 703 ENDDO 704 ENDIF 705 ENDDO 706 ENDDO 707 # else 708 ptab_child(i1:i2,j1:j2,1:jpk,1:jpts) = ptab(i1:i2,j1:j2,1:jpk,1:jpts) 709 # endif 641 710 ! 642 711 IF( nbghostcells > 1 ) THEN ! no smoothing 643 tsa(i1:i2,j1:j2,k1:k2,n1:n2) = ptab (i1:i2,j1:j2,k1:k2,n1:n2)712 tsa(i1:i2,j1:j2,k1:k2,n1:n2) = ptab_child(i1:i2,j1:j2,k1:k2,n1:n2) 644 713 ELSE ! smoothing 645 714 ! … … 665 734 IF( eastern_side ) THEN 666 735 DO jn = 1, jpts 667 tsa(nlci,j1:j2,k1:k2,jn) = z1 * ptab (nlci,j1:j2,k1:k2,jn) + z2 * ptab(nlci-1,j1:j2,k1:k2,jn)736 tsa(nlci,j1:j2,k1:k2,jn) = z1 * ptab_child(nlci,j1:j2,k1:k2,jn) + z2 * ptab_child(nlci-1,j1:j2,k1:k2,jn) 668 737 DO jk = 1, jpkm1 669 738 DO jj = jmin,jmax … … 685 754 IF( northern_side ) THEN 686 755 DO jn = 1, jpts 687 tsa(i1:i2,nlcj,k1:k2,jn) = z1 * ptab (i1:i2,nlcj,k1:k2,jn) + z2 * ptab(i1:i2,nlcj-1,k1:k2,jn)756 tsa(i1:i2,nlcj,k1:k2,jn) = z1 * ptab_child(i1:i2,nlcj,k1:k2,jn) + z2 * ptab_child(i1:i2,nlcj-1,k1:k2,jn) 688 757 DO jk = 1, jpkm1 689 758 DO ji = imin,imax … … 705 774 IF( western_side ) THEN 706 775 DO jn = 1, jpts 707 tsa(1,j1:j2,k1:k2,jn) = z1 * ptab (1,j1:j2,k1:k2,jn) + z2 * ptab(2,j1:j2,k1:k2,jn)776 tsa(1,j1:j2,k1:k2,jn) = z1 * ptab_child(1,j1:j2,k1:k2,jn) + z2 * ptab_child(2,j1:j2,k1:k2,jn) 708 777 DO jk = 1, jpkm1 709 778 DO jj = jmin,jmax … … 724 793 IF( southern_side ) THEN 725 794 DO jn = 1, jpts 726 tsa(i1:i2,1,k1:k2,jn) = z1 * ptab (i1:i2,1,k1:k2,jn) + z2 * ptab(i1:i2,2,k1:k2,jn)795 tsa(i1:i2,1,k1:k2,jn) = z1 * ptab_child(i1:i2,1,k1:k2,jn) + z2 * ptab_child(i1:i2,2,k1:k2,jn) 727 796 DO jk = 1, jpk 728 797 DO ji=imin,imax … … 741 810 ENDIF 742 811 ! 812 ! 743 813 ! Treatment of corners 744 IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2))) tsa(nlci-1,2,:,:) = ptab(nlci-1,2,:,:) ! East south 745 IF ((eastern_side).AND.((nbondj == 1).OR.(nbondj == 2))) tsa(nlci-1,nlcj-1,:,:) = ptab(nlci-1,nlcj-1,:,:) ! East north 746 IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2))) tsa(2,2,:,:) = ptab(2,2,:,:) ! West south 747 IF ((western_side).AND.((nbondj == 1).OR.(nbondj == 2))) tsa(2,nlcj-1,:,:) = ptab(2,nlcj-1,:,:) ! West north 814 ! 815 ! East south 816 IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN 817 tsa(nlci-1,2,:,:) = ptab_child(nlci-1,2,:,1:jpts) 818 ENDIF 819 ! East north 820 IF ((eastern_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN 821 tsa(nlci-1,nlcj-1,:,:) = ptab_child(nlci-1,nlcj-1,:,1:jpts) 822 ENDIF 823 ! West south 824 IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN 825 tsa(2,2,:,:) = ptab_child(2,2,:,1:jpts) 826 ENDIF 827 ! West north 828 IF ((western_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN 829 tsa(2,nlcj-1,:,:) = ptab_child(2,nlcj-1,:,1:jpts) 830 ENDIF 748 831 ! 749 832 ENDIF … … 751 834 ! 752 835 END SUBROUTINE interptsn 753 754 836 755 837 SUBROUTINE interpsshn( ptab, i1, i2, j1, j2, before, nb, ndir ) … … 781 863 END SUBROUTINE interpsshn 782 864 783 784 SUBROUTINE interpun( ptab, i1, i2, j1, j2, k1, k2, before ) 865 SUBROUTINE interpun( ptab, i1, i2, j1, j2, k1, k2, m1, m2, before, nb, ndir ) 785 866 !!---------------------------------------------------------------------- 786 867 !! *** ROUTINE interpun *** 787 !!---------------------------------------------------------------------- 788 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2 789 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: ptab 790 LOGICAL , INTENT(in ) :: before 791 ! 792 INTEGER :: ji, jj, jk 793 REAL(wp) :: zrhoy 794 !!---------------------------------------------------------------------- 795 ! 796 IF( before ) THEN 797 DO jk = k1, jpk 798 ptab(i1:i2,j1:j2,jk) = e2u(i1:i2,j1:j2) * e3u_n(i1:i2,j1:j2,jk) * un(i1:i2,j1:j2,jk) 868 !!--------------------------------------------- 869 !! 870 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,m1,m2 871 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,m1:m2), INTENT(inout) :: ptab 872 LOGICAL, INTENT(in) :: before 873 INTEGER, INTENT(in) :: nb , ndir 874 !! 875 INTEGER :: ji,jj,jk 876 REAL(wp) :: zrhoy 877 ! vertical interpolation: 878 REAL(wp), DIMENSION(k1:k2) :: tabin, h_in 879 REAL(wp), DIMENSION(1:jpk) :: h_out 880 INTEGER :: N_in, N_out, iref 881 REAL(wp) :: h_diff 882 LOGICAL :: western_side, eastern_side 883 !!--------------------------------------------- 884 ! 885 zrhoy = Agrif_rhoy() 886 IF (before) THEN 887 DO jk=1,jpk 888 DO jj=j1,j2 889 DO ji=i1,i2 890 ptab(ji,jj,jk,1) = (e2u(ji,jj) * e3u_n(ji,jj,jk) * un(ji,jj,jk)*umask(ji,jj,jk)) 891 # if defined key_vertical 892 ptab(ji,jj,jk,2) = (umask(ji,jj,jk) * e2u(ji,jj) * e3u_n(ji,jj,jk)) 893 # endif 894 END DO 895 END DO 799 896 END DO 800 897 ELSE 801 zrhoy = Agrif_Rhoy() 898 zrhoy = Agrif_rhoy() 899 # if defined key_vertical 900 ! VERTICAL REFINEMENT BEGIN 901 western_side = (nb == 1).AND.(ndir == 1) 902 eastern_side = (nb == 1).AND.(ndir == 2) 903 904 DO ji=i1,i2 905 iref = ji 906 IF (western_side) iref = MAX(2,ji) 907 IF (eastern_side) iref = MIN(nlci-2,ji) 908 DO jj=j1,j2 909 N_in = 0 910 DO jk=k1,k2 911 IF (ptab(ji,jj,jk,2) == 0) EXIT 912 N_in = N_in + 1 913 tabin(jk) = ptab(ji,jj,jk,1)/ptab(ji,jj,jk,2) 914 h_in(N_in) = ptab(ji,jj,jk,2)/(e2u(ji,jj)*zrhoy) 915 ENDDO 916 917 IF (N_in == 0) THEN 918 ua(ji,jj,:) = 0._wp 919 CYCLE 920 ENDIF 921 922 N_out = 0 923 DO jk=1,jpk 924 if (umask(iref,jj,jk) == 0) EXIT 925 N_out = N_out + 1 926 h_out(N_out) = e3u_a(iref,jj,jk) 927 ENDDO 928 929 IF (N_out == 0) THEN 930 ua(ji,jj,:) = 0._wp 931 CYCLE 932 ENDIF 933 934 IF (N_in * N_out > 0) THEN 935 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 936 ! Should be able to remove the next IF/ELSEIF statement once scale factors are dealt with properly 937 if (h_diff < -1.e4) then 938 print *,'CHECK YOUR BATHY ...', h_diff, sum(h_out(1:N_out)), sum(h_in(1:N_in)) 939 ! stop 940 endif 941 ENDIF 942 call reconstructandremap(tabin(1:N_in),h_in(1:N_in),ua(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 943 ENDDO 944 ENDDO 945 946 # else 802 947 DO jk = 1, jpkm1 803 948 DO jj=j1,j2 804 ua(i1:i2,jj,jk) = ptab(i1:i2,jj,jk) / ( zrhoy * e2u(i1:i2,jj) * e3u_n(i1:i2,jj,jk) ) 805 END DO 806 END DO 949 ua(i1:i2,jj,jk) = ptab(i1:i2,jj,jk,1) / ( zrhoy * e2u(i1:i2,jj) * e3u_a(i1:i2,jj,jk) ) 950 END DO 951 END DO 952 # endif 953 807 954 ENDIF 808 955 ! 809 956 END SUBROUTINE interpun 810 957 811 812 SUBROUTINE interpvn( ptab, i1, i2, j1, j2, k1, k2, before ) 958 SUBROUTINE interpvn( ptab, i1, i2, j1, j2, k1, k2, m1, m2, before, nb, ndir ) 813 959 !!---------------------------------------------------------------------- 814 960 !! *** ROUTINE interpvn *** 815 961 !!---------------------------------------------------------------------- 816 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2 817 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: ptab 818 LOGICAL , INTENT(in ) :: before 819 ! 820 INTEGER :: ji, jj, jk 821 REAL(wp) :: zrhox 822 !!---------------------------------------------------------------------- 962 ! 963 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,m1,m2 964 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,m1:m2), INTENT(inout) :: ptab 965 LOGICAL, INTENT(in) :: before 966 INTEGER, INTENT(in) :: nb , ndir 967 ! 968 INTEGER :: ji,jj,jk 969 REAL(wp) :: zrhox 970 ! vertical interpolation: 971 REAL(wp), DIMENSION(k1:k2) :: tabin, h_in 972 REAL(wp), DIMENSION(1:jpk) :: h_out 973 INTEGER :: N_in, N_out, jref 974 REAL(wp) :: h_diff 975 LOGICAL :: northern_side,southern_side 976 !!--------------------------------------------- 823 977 ! 824 IF( before ) THEN !interpv entre 1 et k2 et interpv2d en jpkp1 825 DO jk = k1, jpk 826 ptab(i1:i2,j1:j2,jk) = e1v(i1:i2,j1:j2) * e3v_n(i1:i2,j1:j2,jk) * vn(i1:i2,j1:j2,jk) 827 END DO 828 ELSE 829 zrhox= Agrif_Rhox() 978 IF (before) THEN 979 DO jk=k1,k2 980 DO jj=j1,j2 981 DO ji=i1,i2 982 ptab(ji,jj,jk,1) = (e1v(ji,jj) * e3v_n(ji,jj,jk) * vn(ji,jj,jk)*vmask(ji,jj,jk)) 983 # if defined key_vertical 984 ptab(ji,jj,jk,2) = vmask(ji,jj,jk) * e1v(ji,jj) * e3v_n(ji,jj,jk) 985 # endif 986 END DO 987 END DO 988 END DO 989 ELSE 990 zrhox = Agrif_rhox() 991 # if defined key_vertical 992 993 southern_side = (nb == 2).AND.(ndir == 1) 994 northern_side = (nb == 2).AND.(ndir == 2) 995 996 DO jj=j1,j2 997 jref = jj 998 IF (southern_side) jref = MAX(2,jj) 999 IF (northern_side) jref = MIN(nlcj-2,jj) 1000 DO ji=i1,i2 1001 N_in = 0 1002 DO jk=k1,k2 1003 if (ptab(ji,jj,jk,2) == 0) EXIT 1004 N_in = N_in + 1 1005 tabin(jk) = ptab(ji,jj,jk,1)/ptab(ji,jj,jk,2) 1006 h_in(N_in) = ptab(ji,jj,jk,2)/(e1v(ji,jj)*zrhox) 1007 END DO 1008 IF (N_in == 0) THEN 1009 va(ji,jj,:) = 0._wp 1010 CYCLE 1011 ENDIF 1012 1013 N_out = 0 1014 DO jk=1,jpk 1015 if (vmask(ji,jref,jk) == 0) EXIT 1016 N_out = N_out + 1 1017 h_out(N_out) = e3v_a(ji,jref,jk) 1018 END DO 1019 IF (N_out == 0) THEN 1020 va(ji,jj,:) = 0._wp 1021 CYCLE 1022 ENDIF 1023 call reconstructandremap(tabin(1:N_in),h_in(1:N_in),va(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 1024 END DO 1025 END DO 1026 # else 830 1027 DO jk = 1, jpkm1 831 va(i1:i2,j1:j2,jk) = ptab(i1:i2,j1:j2,jk) / ( zrhox * e1v(i1:i2,j1:j2) * e3v_n(i1:i2,j1:j2,jk) ) 832 END DO 1028 va(i1:i2,j1:j2,jk) = ptab(i1:i2,j1:j2,jk,1) / ( zrhox * e1v(i1:i2,j1:j2) * e3v_a(i1:i2,j1:j2,jk) ) 1029 END DO 1030 # endif 833 1031 ENDIF 834 1032 ! 835 1033 END SUBROUTINE interpvn 836 837 1034 838 1035 SUBROUTINE interpunb( ptab, i1, i2, j1, j2, before, nb, ndir ) … … 955 1152 !!---------------------------------------------------------------------- 956 1153 IF( before ) THEN 957 ptab(i1:i2,j1:j2) = e2u(i1:i2,j1:j2) * ub2_b(i1:i2,j1:j2) 1154 IF ( ln_bt_fw ) THEN 1155 ptab(i1:i2,j1:j2) = e2u(i1:i2,j1:j2) * ub2_b(i1:i2,j1:j2) 1156 ELSE 1157 ptab(i1:i2,j1:j2) = e2u(i1:i2,j1:j2) * un_adv(i1:i2,j1:j2) 1158 ENDIF 958 1159 ELSE 959 1160 western_side = (nb == 1).AND.(ndir == 1) … … 993 1194 ! 994 1195 IF( before ) THEN 995 ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vb2_b(i1:i2,j1:j2) 1196 IF ( ln_bt_fw ) THEN 1197 ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vb2_b(i1:i2,j1:j2) 1198 ELSE 1199 ptab(i1:i2,j1:j2) = e1v(i1:i2,j1:j2) * vn_adv(i1:i2,j1:j2) 1200 ENDIF 996 1201 ELSE 997 1202 western_side = (nb == 1).AND.(ndir == 1) … … 1147 1352 1148 1353 1149 SUBROUTINE interpavm( ptab, i1, i2, j1, j2, k1, k2, before )1354 SUBROUTINE interpavm( ptab, i1, i2, j1, j2, k1, k2, m1, m2, before ) 1150 1355 !!---------------------------------------------------------------------- 1151 1356 !! *** ROUTINE interavm *** 1152 1357 !!---------------------------------------------------------------------- 1153 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2 1154 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2 ), INTENT(inout) :: ptab1358 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, m1, m2 1359 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,m1:m2), INTENT(inout) :: ptab 1155 1360 LOGICAL , INTENT(in ) :: before 1361 REAL(wp), DIMENSION(k1:k2) :: tabin 1362 REAL(wp) :: h_in(k1:k2) 1363 REAL(wp) :: h_out(1:jpk) 1364 REAL(wp) :: zrhoxy 1365 INTEGER :: N_in, N_out, ji, jj, jk 1156 1366 !!---------------------------------------------------------------------- 1157 1367 ! 1158 IF( before ) THEN ; ptab (i1:i2,j1:j2,k1:k2) = avm_k(i1:i2,j1:j2,k1:k2) 1159 ELSE ; avm_k(i1:i2,j1:j2,k1:k2) = ptab (i1:i2,j1:j2,k1:k2) 1368 zrhoxy = Agrif_rhox()*Agrif_rhoy() 1369 IF (before) THEN 1370 DO jk=k1,k2 1371 DO jj=j1,j2 1372 DO ji=i1,i2 1373 ptab(ji,jj,jk,1) = avm_k(ji,jj,jk) 1374 END DO 1375 END DO 1376 END DO 1377 #ifdef key_vertical 1378 DO jk=k1,k2 1379 DO jj=j1,j2 1380 DO ji=i1,i2 1381 ptab(ji,jj,jk,2) = wmask(ji,jj,jk) * e1e2t(ji,jj) * e3w_n(ji,jj,jk) 1382 END DO 1383 END DO 1384 END DO 1385 #else 1386 ptab(i1:i2,j1:j2,k1:k2,2) = 0._wp 1387 #endif 1388 ELSE 1389 #ifdef key_vertical 1390 avm_k(i1:i2,j1:j2,1:jpk) = 0. 1391 DO jj=j1,j2 1392 DO ji=i1,i2 1393 N_in = 0 1394 DO jk=k1,k2 !k2 = jpk of parent grid 1395 IF (ptab(ji,jj,jk,2) == 0) EXIT 1396 N_in = N_in + 1 1397 tabin(jk) = ptab(ji,jj,jk,1) 1398 h_in(N_in) = ptab(ji,jj,jk,2)/(e1e2t(ji,jj)*zrhoxy) 1399 END DO 1400 N_out = 0 1401 DO jk=1,jpk ! jpk of child grid 1402 IF (wmask(ji,jj,jk) == 0) EXIT 1403 N_out = N_out + 1 1404 h_out(jk) = e3t_n(ji,jj,jk) 1405 ENDDO 1406 IF (N_in > 0) THEN 1407 CALL reconstructandremap(tabin(1:N_in),h_in,avm_k(ji,jj,1:N_out),h_out,N_in,N_out) 1408 ENDIF 1409 ENDDO 1410 ENDDO 1411 #else 1412 avm_k(i1:i2,j1:j2,k1:k2) = ptab (i1:i2,j1:j2,k1:k2,1) 1413 #endif 1160 1414 ENDIF 1161 1415 ! -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90
r9019 r9031 44 44 ! 45 45 #if defined SPONGE 46 zcoef = REAL( Agrif_NbStepint(), wp ) / Agrif_rhot() 47 ! 46 !! Assume persistence: 47 timecoeff = REAL(Agrif_rhot()-1,wp)/REAL(Agrif_rhot()) 48 48 49 CALL Agrif_Sponge 49 50 Agrif_SpecialValue = 0._wp … … 67 68 ! 68 69 #if defined SPONGE 69 zcoef = REAL( Agrif_NbStepint(), wp ) / Agrif_rhot()70 ! 71 Agrif_SpecialValue = 0._wp70 timecoeff = REAL(Agrif_rhot()-1,wp)/REAL(Agrif_rhot()) 71 72 Agrif_SpecialValue=0. 72 73 Agrif_UseSpecialValue = ln_spc_dyn 73 74 ! … … 189 190 END SUBROUTINE Agrif_Sponge 190 191 191 192 192 SUBROUTINE interptsn_sponge( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 193 193 !!---------------------------------------------------------------------- … … 201 201 INTEGER :: iku, ikv 202 202 REAL(wp) :: ztsa, zabe1, zabe2, zbtr 203 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ztu, ztv 204 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2) ::tsbdiff 203 REAL(wp), DIMENSION(i1:i2,j1:j2,jpk) :: ztu, ztv 204 REAL(wp), DIMENSION(i1:i2,j1:j2,jpk,n1:n2) ::tsbdiff 205 ! vertical interpolation: 206 REAL(wp), DIMENSION(i1:i2,j1:j2,jpk,n1:n2) ::tabres_child 207 REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin 208 REAL(wp), DIMENSION(k1:k2) :: h_in 209 REAL(wp), DIMENSION(1:jpk) :: h_out 210 INTEGER :: N_in, N_out 211 REAL(wp) :: h_diff 205 212 !!---------------------------------------------------------------------- 206 213 ! 207 214 IF( before ) THEN 208 tabres(i1:i2,j1:j2,k1:k2,n1:n2) = tsn(i1:i2,j1:j2,k1:k2,n1:n2) 215 DO jn = 1, jpts 216 DO jk=k1,k2 217 DO jj=j1,j2 218 DO ji=i1,i2 219 tabres(ji,jj,jk,jn) = tsb(ji,jj,jk,jn) 220 END DO 221 END DO 222 END DO 223 END DO 224 225 # if defined key_vertical 226 DO jk=k1,k2 227 DO jj=j1,j2 228 DO ji=i1,i2 229 tabres(ji,jj,jk,jpts+1) = tmask(ji,jj,jk) * e3t_n(ji,jj,jk) 230 END DO 231 END DO 232 END DO 233 # endif 234 209 235 ELSE 210 236 ! 211 tsbdiff(:,:,:,:) = tsb(i1:i2,j1:j2,:,:) - tabres(:,:,:,:) 237 # if defined key_vertical 238 tabres_child(:,:,:,:) = 0. 239 DO jj=j1,j2 240 DO ji=i1,i2 241 N_in = 0 242 DO jk=k1,k2 !k2 = jpk of parent grid 243 IF (tabres(ji,jj,jk,n2) == 0) EXIT 244 N_in = N_in + 1 245 tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1) 246 h_in(N_in) = tabres(ji,jj,jk,n2) 247 END DO 248 N_out = 0 249 DO jk=1,jpk ! jpk of child grid 250 IF (tmask(ji,jj,jk) == 0) EXIT 251 N_out = N_out + 1 252 h_out(jk) = e3t_n(ji,jj,jk) !Child grid scale factors. Could multiply by e1e2t here instead of division above 253 ENDDO 254 IF (N_in > 0) THEN 255 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 256 tabres(ji,jj,k2,:) = tabres(ji,jj,k2-1,:) !what is this line for????? 257 DO jn=1,jpts 258 call reconstructandremap(tabin(1:N_in,jn),h_in,tabres_child(ji,jj,1:N_out,jn),h_out,N_in,N_out) 259 ENDDO 260 ENDIF 261 ENDDO 262 ENDDO 263 # endif 264 265 DO jj=j1,j2 266 DO ji=i1,i2 267 DO jk=1,jpkm1 268 # if defined key_vertical 269 tsbdiff(ji,jj,jk,1:jpts) = tsb(ji,jj,jk,1:jpts) - tabres_child(ji,jj,jk,1:jpts) 270 # else 271 tsbdiff(ji,jj,jk,1:jpts) = tsb(ji,jj,jk,1:jpts) - tabres(ji,jj,jk,1:jpts) 272 # endif 273 ENDDO 274 ENDDO 275 ENDDO 276 212 277 DO jn = 1, jpts 213 278 DO jk = 1, jpkm1 … … 256 321 END SUBROUTINE interptsn_sponge 257 322 258 259 SUBROUTINE interpun_sponge( tabres, i1, i2, j1, j2, k1, k2, before )260 !! ----------------------------------------------------------------------261 !! *** ROUTINE interpun_sponge ***262 !!----------------------------------------------------------------------263 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2264 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres265 LOGICAL , INTENT(in ) :: before 266 !!267 INTEGER :: ji, jj, jk 323 SUBROUTINE interpun_sponge(tabres,i1,i2,j1,j2,k1,k2,m1,m2, before) 324 !!--------------------------------------------- 325 !! *** ROUTINE interpun_sponge *** 326 !!--------------------------------------------- 327 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,m1,m2 328 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,m1:m2), INTENT(inout) :: tabres 329 LOGICAL, INTENT(in) :: before 330 331 INTEGER :: ji,jj,jk,jmax 332 268 333 ! sponge parameters 269 INTEGER :: jmax 270 REAL(wp) :: ze2u, ze1v, zua, zva, zbtr 271 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ubdiff 272 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: rotdiff, hdivdiff 273 !!---------------------------------------------------------------------- 334 REAL(wp) :: ze2u, ze1v, zua, zva, zbtr, h_diff 335 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: ubdiff 336 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: rotdiff, hdivdiff 337 ! vertical interpolation: 338 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: tabres_child 339 REAL(wp), DIMENSION(k1:k2) :: tabin, h_in 340 REAL(wp), DIMENSION(1:jpk) :: h_out 341 INTEGER ::N_in,N_out 342 !!--------------------------------------------- 274 343 ! 275 344 IF( before ) THEN 276 tabres = un(i1:i2,j1:j2,:) 345 DO jk=1,jpkm1 346 DO jj=j1,j2 347 DO ji=i1,i2 348 tabres(ji,jj,jk,m1) = ub(ji,jj,jk) 349 # if defined key_vertical 350 tabres(ji,jj,jk,m2) = e3u_n(ji,jj,jk)*umask(ji,jj,jk) 351 # endif 352 END DO 353 END DO 354 END DO 355 277 356 ELSE 278 ubdiff(i1:i2,j1:j2,:) = ( ub(i1:i2,j1:j2,:) - tabres(:,:,:) )*umask(i1:i2,j1:j2,:) 357 358 # if defined key_vertical 359 tabres_child(:,:,:) = 0._wp 360 DO jj=j1,j2 361 DO ji=i1,i2 362 N_in = 0 363 DO jk=k1,k2 364 IF (tabres(ji,jj,jk,m2) == 0) EXIT 365 N_in = N_in + 1 366 tabin(jk) = tabres(ji,jj,jk,m1) 367 h_in(N_in) = tabres(ji,jj,jk,m2) 368 ENDDO 369 ! 370 IF (N_in == 0) THEN 371 tabres_child(ji,jj,:) = 0. 372 CYCLE 373 ENDIF 374 375 N_out = 0 376 DO jk=1,jpk 377 if (umask(ji,jj,jk) == 0) EXIT 378 N_out = N_out + 1 379 h_out(N_out) = e3u_n(ji,jj,jk) 380 ENDDO 381 382 IF (N_out == 0) THEN 383 tabres_child(ji,jj,:) = 0. 384 CYCLE 385 ENDIF 386 387 IF (N_in * N_out > 0) THEN 388 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 389 if (h_diff < -1.e4) then 390 print *,'CHECK YOUR BATHY ...', h_diff, sum(h_out(1:N_out)), sum(h_in(1:N_in)) 391 endif 392 ENDIF 393 call reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 394 395 ENDDO 396 ENDDO 397 398 ubdiff(i1:i2,j1:j2,:) = (ub(i1:i2,j1:j2,:) - tabres_child(i1:i2,j1:j2,:))*umask(i1:i2,j1:j2,:) 399 #else 400 ubdiff(i1:i2,j1:j2,:) = (ub(i1:i2,j1:j2,:) - tabres(i1:i2,j1:j2,:,1))*umask(i1:i2,j1:j2,:) 401 #endif 402 >>>>>>> .merge-right.r9019 279 403 ! 280 404 DO jk = 1, jpkm1 ! Horizontal slab … … 352 476 END SUBROUTINE interpun_sponge 353 477 354 355 SUBROUTINE interpvn_sponge( tabres, i1, i2, j1, j2, k1, k2, before, nb, ndir ) 356 !!---------------------------------------------------------------------- 357 !! *** ROUTINE interpvn_sponge *** 358 !!---------------------------------------------------------------------- 359 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2 360 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres 361 LOGICAL , INTENT(in ) :: before 362 INTEGER , INTENT(in ) :: nb , ndir 478 SUBROUTINE interpvn_sponge(tabres,i1,i2,j1,j2,k1,k2,m1,m2, before,nb,ndir) 479 !!--------------------------------------------- 480 !! *** ROUTINE interpvn_sponge *** 481 !!--------------------------------------------- 482 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,m1,m2 483 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,m1:m2), INTENT(inout) :: tabres 484 LOGICAL, INTENT(in) :: before 485 INTEGER, INTENT(in) :: nb , ndir 363 486 ! 364 487 INTEGER :: ji, jj, jk … … 367 490 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: vbdiff, rotdiff, hdivdiff 368 491 !!---------------------------------------------------------------------- 369 492 INTEGER :: ji, jj, jk, imax 493 REAL(wp) :: ze2u, ze1v, zua, zva, zbtr, h_diff 494 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: vbdiff 495 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: rotdiff, hdivdiff 496 ! vertical interpolation: 497 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: tabres_child 498 REAL(wp), DIMENSION(k1:k2) :: tabin, h_in 499 REAL(wp), DIMENSION(1:jpk) :: h_out 500 INTEGER :: N_in, N_out 501 !!--------------------------------------------- 502 >>>>>>> .merge-right.r9019 503 370 504 IF( before ) THEN 371 tabres = vn(i1:i2,j1:j2,:) 505 DO jk=1,jpkm1 506 DO jj=j1,j2 507 DO ji=i1,i2 508 tabres(ji,jj,jk,m1) = vb(ji,jj,jk) 509 # if defined key_vertical 510 tabres(ji,jj,jk,m2) = vmask(ji,jj,jk) * e3v_n(ji,jj,jk) 511 # endif 512 END DO 513 END DO 514 END DO 372 515 ELSE 373 ! 374 vbdiff(i1:i2,j1:j2,:) = ( vb(i1:i2,j1:j2,:) - tabres(:,:,:) ) * vmask(i1:i2,j1:j2,:) 516 517 # if defined key_vertical 518 tabres_child(:,:,:) = 0._wp 519 DO jj=j1,j2 520 DO ji=i1,i2 521 N_in = 0 522 DO jk=k1,k2 523 IF (tabres(ji,jj,jk,m2) == 0) EXIT 524 N_in = N_in + 1 525 tabin(jk) = tabres(ji,jj,jk,m1) 526 h_in(N_in) = tabres(ji,jj,jk,m2) 527 ENDDO 528 529 IF (N_in == 0) THEN 530 tabres_child(ji,jj,:) = 0. 531 CYCLE 532 ENDIF 533 534 N_out = 0 535 DO jk=1,jpk 536 if (vmask(ji,jj,jk) == 0) EXIT 537 N_out = N_out + 1 538 h_out(N_out) = e3v_n(ji,jj,jk) 539 ENDDO 540 541 IF (N_in * N_out > 0) THEN 542 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 543 if (h_diff < -1.e4) then 544 print *,'CHECK YOUR BATHY ...', h_diff, sum(h_out(1:N_out)), sum(h_in(1:N_in)) 545 endif 546 ENDIF 547 call reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 548 ENDDO 549 ENDDO 550 551 vbdiff(i1:i2,j1:j2,:) = (vb(i1:i2,j1:j2,:) - tabres_child(i1:i2,j1:j2,:))*vmask(i1:i2,j1:j2,:) 552 # else 553 vbdiff(i1:i2,j1:j2,:) = (vb(i1:i2,j1:j2,:) - tabres(i1:i2,j1:j2,:,1))*vmask(i1:i2,j1:j2,:) 554 # endif 375 555 ! 376 556 DO jk = 1, jpkm1 ! Horizontal slab -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90
r9019 r9031 1 1 #define TWO_WAY /* TWO WAY NESTING */ 2 #undef DECAL_FEEDBACK /* SEPARATION of INTERFACES*/ 2 #define DECAL_FEEDBACK /* SEPARATION of INTERFACES*/ 3 #undef VOL_REFLUX /* VOLUME REFLUXING*/ 3 4 4 5 MODULE agrif_opa_update … … 23 24 USE in_out_manager ! I/O manager 24 25 USE lib_mpp ! MPP library 26 USE domvvl ! Need interpolation routines 25 27 26 28 IMPLICIT NONE … … 36 38 CONTAINS 37 39 38 RECURSIVESUBROUTINE Agrif_Update_Tra( )40 SUBROUTINE Agrif_Update_Tra( ) 39 41 !!---------------------------------------------------------------------- 40 42 !! *** ROUTINE Agrif_Update_Tra *** … … 44 46 ! 45 47 #if defined TWO_WAY 46 IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update tracers from grid Number',Agrif_Fixed() , 'nbcline', nbcline48 IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update tracers from grid Number',Agrif_Fixed() 47 49 48 50 Agrif_UseSpecialValueInUpdate = .TRUE. 49 51 Agrif_SpecialValueFineGrid = 0._wp 50 52 ! 51 IF (MOD(nbcline,nbclineupdate) == 0) THEN52 53 # if ! defined DECAL_FEEDBACK 53 CALL Agrif_Update_Variable(tsn_id, procname=updateTS) 54 CALL Agrif_Update_Variable(tsn_id, procname=updateTS) 55 ! near boundary update: 56 ! CALL Agrif_Update_Variable(tsn_id,locupdate=(/0,2/), procname=updateTS) 54 57 # else 55 CALL Agrif_Update_Variable(tsn_id, locupdate=(/1,0/),procname=updateTS) 58 CALL Agrif_Update_Variable(tsn_id, locupdate=(/1,0/),procname=updateTS) 59 ! near boundary update: 60 ! CALL Agrif_Update_Variable(tsn_id,locupdate=(/1,2/), procname=updateTS) 56 61 # endif 57 ELSE58 # if ! defined DECAL_FEEDBACK59 CALL Agrif_Update_Variable(tsn_id,locupdate=(/0,2/), procname=updateTS)60 # else61 CALL Agrif_Update_Variable(tsn_id,locupdate=(/1,2/), procname=updateTS)62 # endif63 ENDIF64 62 ! 65 63 Agrif_UseSpecialValueInUpdate = .FALSE. 66 64 ! 67 IF ( lk_agrif_doupd ) THEN ! Initialisation: do recursive update:68 CALL Agrif_ChildGrid_To_ParentGrid()69 CALL Agrif_Update_Tra()70 CALL Agrif_ParentGrid_To_ChildGrid()71 ENDIF72 !73 65 #endif 74 66 ! 75 67 END SUBROUTINE Agrif_Update_Tra 76 68 77 78 RECURSIVE SUBROUTINE Agrif_Update_Dyn( ) 69 SUBROUTINE Agrif_Update_Dyn( ) 79 70 !!---------------------------------------------------------------------- 80 71 !! *** ROUTINE Agrif_Update_Dyn *** … … 84 75 ! 85 76 #if defined TWO_WAY 86 IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update momentum from grid Number',Agrif_Fixed() , 'nbcline', nbcline77 IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update momentum from grid Number',Agrif_Fixed() 87 78 88 79 Agrif_UseSpecialValueInUpdate = .FALSE. 89 80 Agrif_SpecialValueFineGrid = 0. 90 81 ! 91 IF (mod(nbcline,nbclineupdate) == 0) THEN92 82 # if ! defined DECAL_FEEDBACK 93 CALL Agrif_Update_Variable(un_update_id,procname = updateU) 94 CALL Agrif_Update_Variable(vn_update_id,procname = updateV) 83 CALL Agrif_Update_Variable(un_update_id,procname = updateU) 84 CALL Agrif_Update_Variable(vn_update_id,procname = updateV) 85 ! near boundary update: 86 ! CALL Agrif_Update_Variable(un_update_id,locupdate=(/0,1/),procname = updateU) 87 ! CALL Agrif_Update_Variable(vn_update_id,locupdate=(/0,1/),procname = updateV) 95 88 # else 96 CALL Agrif_Update_Variable(un_update_id,locupdate1=(/0,-1/),locupdate2=(/1,-2/),procname = updateU) 97 CALL Agrif_Update_Variable(vn_update_id,locupdate1=(/1,-2/),locupdate2=(/0,-1/),procname = updateV) 89 CALL Agrif_Update_Variable(un_update_id,locupdate1=(/0,-1/),locupdate2=(/1,-2/),procname = updateU) 90 CALL Agrif_Update_Variable(vn_update_id,locupdate1=(/1,-2/),locupdate2=(/0,-1/),procname = updateV) 91 ! near boundary update: 92 ! CALL Agrif_Update_Variable(un_update_id,locupdate1=(/0,1/),locupdate2=(/1,1/),procname = updateU) 93 ! CALL Agrif_Update_Variable(vn_update_id,locupdate1=(/1,1/),locupdate2=(/0,1/),procname = updateV) 98 94 # endif 99 ELSE100 # if ! defined DECAL_FEEDBACK101 CALL Agrif_Update_Variable(un_update_id,locupdate=(/0,1/),procname = updateU)102 CALL Agrif_Update_Variable(vn_update_id,locupdate=(/0,1/),procname = updateV)103 # else104 CALL Agrif_Update_Variable(un_update_id,locupdate1=(/0,1/),locupdate2=(/1,1/),procname = updateU)105 CALL Agrif_Update_Variable(vn_update_id,locupdate1=(/1,1/),locupdate2=(/0,1/),procname = updateV)106 # endif107 ENDIF108 95 109 96 # if ! defined DECAL_FEEDBACK … … 114 101 CALL Agrif_Update_Variable(e2v_id,locupdate1=(/1,-2/),locupdate2=(/0,-1/),procname = updateV2d) 115 102 # endif 116 103 ! 104 # if ! defined DECAL_FEEDBACK 105 ! Account for updated thicknesses at boundary edges 106 IF (.NOT.ln_linssh) THEN 107 ! CALL Agrif_Update_Variable(un_update_id,locupdate1=(/0,0/),locupdate2=(/0,0/),procname = correct_u_bdy) 108 ! CALL Agrif_Update_Variable(vn_update_id,locupdate1=(/0,0/),locupdate2=(/0,0/),procname = correct_v_bdy) 109 ENDIF 110 # endif 111 ! 117 112 IF ( ln_dynspg_ts .AND. ln_bt_fw ) THEN 118 113 ! Update time integrated transports 119 IF (mod(nbcline,nbclineupdate) == 0) THEN120 114 # if ! defined DECAL_FEEDBACK 121 122 115 CALL Agrif_Update_Variable(ub2b_update_id,procname = updateub2b) 116 CALL Agrif_Update_Variable(vb2b_update_id,procname = updatevb2b) 123 117 # else 124 125 118 CALL Agrif_Update_Variable(ub2b_update_id,locupdate1=(/0,-1/),locupdate2=(/1,-2/),procname = updateub2b) 119 CALL Agrif_Update_Variable(vb2b_update_id,locupdate1=(/1,-2/),locupdate2=(/0,-1/),procname = updatevb2b) 126 120 # endif 127 ELSE128 # if ! defined DECAL_FEEDBACK129 CALL Agrif_Update_Variable(ub2b_update_id,locupdate=(/0,1/),procname = updateub2b)130 CALL Agrif_Update_Variable(vb2b_update_id,locupdate=(/0,1/),procname = updatevb2b)131 # else132 CALL Agrif_Update_Variable(ub2b_update_id,locupdate1=(/0,1/),locupdate2=(/1,1/),procname = updateub2b)133 CALL Agrif_Update_Variable(vb2b_update_id,locupdate1=(/1,1/),locupdate2=(/0,1/),procname = updatevb2b)134 # endif135 ENDIF136 121 END IF 137 ! 138 nbcline = nbcline + 1 122 #endif 123 ! 124 END SUBROUTINE Agrif_Update_Dyn 125 126 SUBROUTINE Agrif_Update_ssh( ) 127 !!--------------------------------------------- 128 !! *** ROUTINE Agrif_Update_ssh *** 129 !!--------------------------------------------- 130 ! 131 IF (Agrif_Root()) RETURN 132 ! 133 #if defined TWO_WAY 139 134 ! 140 135 Agrif_UseSpecialValueInUpdate = .TRUE. … … 145 140 CALL Agrif_Update_Variable(sshn_id,locupdate=(/1,0/),procname = updateSSH) 146 141 # endif 142 ! 147 143 Agrif_UseSpecialValueInUpdate = .FALSE. 148 ! 144 ! 145 # if defined DECAL_FEEDBACK && defined VOL_REFLUX 146 IF ( ln_dynspg_ts.AND.ln_bt_fw ) THEN 147 ! Refluxing on ssh: 148 CALL Agrif_Update_Variable(ub2b_update_id,locupdate1=(/0, 0/),locupdate2=(/1, 1/),procname = reflux_sshu) 149 CALL Agrif_Update_Variable(vb2b_update_id,locupdate1=(/1, 1/),locupdate2=(/0, 0/),procname = reflux_sshv) 150 END IF 151 # endif 152 ! 149 153 #endif 150 154 ! 151 ! Do recursive update: 152 IF ( lk_agrif_doupd ) THEN ! Initialisation: do recursive update: 153 CALL Agrif_ChildGrid_To_ParentGrid() 154 CALL Agrif_Update_Dyn() 155 CALL Agrif_ParentGrid_To_ChildGrid() 156 ENDIF 157 ! 158 END SUBROUTINE Agrif_Update_Dyn 159 155 END SUBROUTINE Agrif_Update_ssh 156 157 158 SUBROUTINE Agrif_Update_Tke( kt ) 159 !!--------------------------------------------- 160 !! *** ROUTINE Agrif_Update_Tke *** 161 !!--------------------------------------------- 162 !! 163 INTEGER, INTENT(in) :: kt 164 ! 165 IF (Agrif_Root()) RETURN 166 ! 167 IF( ( Agrif_NbStepint() .NE. 0 ) .AND. (kt /= 0) ) RETURN 168 # if defined TWO_WAY 169 170 Agrif_UseSpecialValueInUpdate = .TRUE. 171 Agrif_SpecialValueFineGrid = 0. 172 173 CALL Agrif_Update_Variable( en_id, locupdate=(/0,0/), procname=updateEN ) 174 CALL Agrif_Update_Variable(avt_id, locupdate=(/0,0/), procname=updateAVT ) 175 CALL Agrif_Update_Variable(avm_id, locupdate=(/0,0/), procname=updateAVM ) 176 177 Agrif_UseSpecialValueInUpdate = .FALSE. 178 179 # endif 180 181 END SUBROUTINE Agrif_Update_Tke 182 183 184 SUBROUTINE Agrif_Update_vvl( ) 185 !!--------------------------------------------- 186 !! *** ROUTINE Agrif_Update_vvl *** 187 !!--------------------------------------------- 188 ! 189 IF (Agrif_Root()) RETURN 190 ! 191 #if defined TWO_WAY 192 ! 193 IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update e3 from grid Number',Agrif_Fixed(), 'Step', Agrif_Nb_Step() 194 ! 195 Agrif_UseSpecialValueInUpdate = .TRUE. 196 Agrif_SpecialValueFineGrid = 0. 197 ! 198 ! No interface separation here, update vertical grid at T points 199 ! everywhere over the overlapping regions (one account for refluxing in that case): 200 CALL Agrif_Update_Variable(e3t_id, procname=updatee3t) 201 ! 202 Agrif_UseSpecialValueInUpdate = .FALSE. 203 ! 204 CALL Agrif_ChildGrid_To_ParentGrid() 205 CALL dom_vvl_update_UVF 206 CALL Agrif_ParentGrid_To_ChildGrid() 207 ! 208 #endif 209 ! 210 END SUBROUTINE Agrif_Update_vvl 211 212 SUBROUTINE dom_vvl_update_UVF 213 !!--------------------------------------------- 214 !! *** ROUTINE dom_vvl_update_UVF *** 215 !!--------------------------------------------- 216 !! 217 INTEGER :: jk 218 REAL(wp):: zcoef 219 !!--------------------------------------------- 220 221 IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Finalize e3 on grid Number', & 222 & Agrif_Fixed(), 'Step', Agrif_Nb_Step() 223 224 ! Save "old" scale factor (prior update) for subsequent asselin correction 225 ! of prognostic variables 226 ! ----------------------- 227 ! 228 e3u_a(:,:,:) = e3u_n(:,:,:) 229 e3v_a(:,:,:) = e3v_n(:,:,:) 230 ! ua(:,:,:) = e3u_b(:,:,:) 231 ! va(:,:,:) = e3v_b(:,:,:) 232 hu_a(:,:) = hu_n(:,:) 233 hv_a(:,:) = hv_n(:,:) 234 235 ! 1) NOW fields 236 !-------------- 237 238 ! Vertical scale factor interpolations 239 ! ------------------------------------ 240 CALL dom_vvl_interpol( e3t_n(:,:,:), e3u_n(:,:,:) , 'U' ) 241 CALL dom_vvl_interpol( e3t_n(:,:,:), e3v_n(:,:,:) , 'V' ) 242 CALL dom_vvl_interpol( e3u_n(:,:,:), e3f_n(:,:,:) , 'F' ) 243 244 CALL dom_vvl_interpol( e3u_n(:,:,:), e3uw_n(:,:,:), 'UW' ) 245 CALL dom_vvl_interpol( e3v_n(:,:,:), e3vw_n(:,:,:), 'VW' ) 246 247 ! Update total depths: 248 ! -------------------- 249 hu_n(:,:) = 0._wp ! Ocean depth at U-points 250 hv_n(:,:) = 0._wp ! Ocean depth at V-points 251 DO jk = 1, jpkm1 252 hu_n(:,:) = hu_n(:,:) + e3u_n(:,:,jk) * umask(:,:,jk) 253 hv_n(:,:) = hv_n(:,:) + e3v_n(:,:,jk) * vmask(:,:,jk) 254 END DO 255 ! ! Inverse of the local depth 256 r1_hu_n(:,:) = ssumask(:,:) / ( hu_n(:,:) + 1._wp - ssumask(:,:) ) 257 r1_hv_n(:,:) = ssvmask(:,:) / ( hv_n(:,:) + 1._wp - ssvmask(:,:) ) 258 259 260 ! 2) BEFORE fields: 261 !------------------ 262 ! IF ( (.NOT.(lk_agrif_fstep.AND.(neuler==0)).AND.(ln_dynspg_exp)) & 263 ! & .OR.(.NOT.(lk_agrif_fstep.AND.(neuler==0)).AND.(ln_dynspg_ts & 264 ! & .AND.(.NOT.ln_bt_fw)))) THEN 265 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0) )) THEN 266 ! 267 ! Vertical scale factor interpolations 268 ! ------------------------------------ 269 CALL dom_vvl_interpol( e3t_b(:,:,:), e3u_b(:,:,:), 'U' ) 270 CALL dom_vvl_interpol( e3t_b(:,:,:), e3v_b(:,:,:), 'V' ) 271 272 CALL dom_vvl_interpol( e3u_b(:,:,:), e3uw_b(:,:,:), 'UW' ) 273 CALL dom_vvl_interpol( e3v_b(:,:,:), e3vw_b(:,:,:), 'VW' ) 274 275 ! Update total depths: 276 ! -------------------- 277 hu_b(:,:) = 0._wp ! Ocean depth at U-points 278 hv_b(:,:) = 0._wp ! Ocean depth at V-points 279 DO jk = 1, jpkm1 280 hu_b(:,:) = hu_b(:,:) + e3u_b(:,:,jk) * umask(:,:,jk) 281 hv_b(:,:) = hv_b(:,:) + e3v_b(:,:,jk) * vmask(:,:,jk) 282 END DO 283 ! ! Inverse of the local depth 284 r1_hu_b(:,:) = ssumask(:,:) / ( hu_b(:,:) + 1._wp - ssumask(:,:) ) 285 r1_hv_b(:,:) = ssvmask(:,:) / ( hv_b(:,:) + 1._wp - ssvmask(:,:) ) 286 ENDIF 287 ! 288 END SUBROUTINE dom_vvl_update_UVF 289 290 #if defined key_vertical 160 291 161 292 SUBROUTINE updateTS( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 162 293 !!---------------------------------------------------------------------- 163 294 !! *** ROUTINE updateT *** 164 !!---------------------------------------------------------------------- 165 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 166 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 167 LOGICAL , INTENT(in ) :: before 168 ! 169 INTEGER :: ji, jj, jk, jn 170 !!---------------------------------------------------------------------- 171 ! 172 IF( before ) THEN 173 DO jn = n1, n2 174 DO jk = k1, k2 175 DO jj = j1, j2 176 DO ji = i1, i2 177 tabres(ji,jj,jk,jn) = tsn(ji,jj,jk,jn) 295 !!--------------------------------------------- 296 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,n1,n2 297 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 298 LOGICAL, INTENT(in) :: before 299 !! 300 INTEGER :: ji,jj,jk,jn 301 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: tabres_child 302 REAL(wp) :: h_in(k1:k2) 303 REAL(wp) :: h_out(1:jpk) 304 INTEGER :: N_in, N_out 305 REAL(wp) :: h_diff 306 REAL(wp) :: zrho_xy 307 REAL(wp) :: tabin(k1:k2,n1:n2) 308 !!--------------------------------------------- 309 ! 310 IF (before) THEN 311 AGRIF_SpecialValue = -999._wp 312 zrho_xy = Agrif_rhox() * Agrif_rhoy() 313 DO jn = n1,n2-1 314 DO jk=k1,k2 315 DO jj=j1,j2 316 DO ji=i1,i2 317 tabres(ji,jj,jk,jn) = (tsn(ji,jj,jk,jn) * e3t_n(ji,jj,jk) ) & 318 * tmask(ji,jj,jk) + (tmask(ji,jj,jk)-1)*999._wp 178 319 END DO 179 320 END DO 180 321 END DO 181 322 END DO 323 DO jk=k1,k2 324 DO jj=j1,j2 325 DO ji=i1,i2 326 tabres(ji,jj,jk,n2) = tmask(ji,jj,jk) * e3t_n(ji,jj,jk) & 327 + (tmask(ji,jj,jk)-1)*999._wp 328 END DO 329 END DO 330 END DO 182 331 ELSE 332 tabres_child(:,:,:,:) = 0. 333 AGRIF_SpecialValue = 0._wp 334 DO jj=j1,j2 335 DO ji=i1,i2 336 N_in = 0 337 DO jk=k1,k2 !k2 = jpk of child grid 338 IF (tabres(ji,jj,jk,n2) == 0 ) EXIT 339 N_in = N_in + 1 340 tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1)/tabres(ji,jj,jk,n2) 341 h_in(N_in) = tabres(ji,jj,jk,n2) 342 ENDDO 343 N_out = 0 344 DO jk=1,jpk ! jpk of parent grid 345 IF (tmask(ji,jj,jk) < -900) EXIT ! TODO: Will not work with ISF 346 N_out = N_out + 1 347 h_out(N_out) = e3t_n(ji,jj,jk) 348 ENDDO 349 IF (N_in > 0) THEN !Remove this? 350 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 351 IF (h_diff < -1.e-4) THEN 352 print *,'CHECK YOUR bathy T points ...',ji,jj,h_diff,sum(h_in(1:N_in)),sum(h_out(1:N_out)) 353 print *,h_in(1:N_in) 354 print *,h_out(1:N_out) 355 STOP 356 ENDIF 357 DO jn=n1,n2-1 358 CALL reconstructandremap(tabin(1:N_in,jn),h_in(1:N_in),tabres_child(ji,jj,1:N_out,jn),h_out(1:N_out),N_in,N_out) 359 ENDDO 360 ENDIF 361 ENDDO 362 ENDDO 363 183 364 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN 184 365 ! Add asselin part 185 DO jn = n1,n2 366 DO jn = n1,n2-1 367 DO jk=1,jpk 368 DO jj=j1,j2 369 DO ji=i1,i2 370 IF( tabres_child(ji,jj,jk,jn) .NE. 0. ) THEN 371 tsb(ji,jj,jk,jn) = tsb(ji,jj,jk,jn) & 372 & + atfp * ( tabres_child(ji,jj,jk,jn) & 373 & - tsn(ji,jj,jk,jn) ) * tmask(ji,jj,jk) 374 ENDIF 375 ENDDO 376 ENDDO 377 ENDDO 378 ENDDO 379 ENDIF 380 DO jn = n1,n2-1 381 DO jk=1,jpk 382 DO jj=j1,j2 383 DO ji=i1,i2 384 IF( tabres_child(ji,jj,jk,jn) .NE. 0. ) THEN 385 tsn(ji,jj,jk,jn) = tabres_child(ji,jj,jk,jn) * tmask(ji,jj,jk) 386 END IF 387 END DO 388 END DO 389 END DO 390 END DO 391 ENDIF 392 ! 393 END SUBROUTINE updateTS 394 395 # else 396 397 SUBROUTINE updateTS( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 398 !!--------------------------------------------- 399 !! *** ROUTINE updateT *** 400 !!--------------------------------------------- 401 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,n1,n2 402 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 403 LOGICAL, INTENT(in) :: before 404 !! 405 INTEGER :: ji,jj,jk,jn 406 REAL(wp) :: ztb, ztnu, ztno 407 !!--------------------------------------------- 408 ! 409 IF (before) THEN 410 DO jn = 1,jpts 411 DO jk=k1,k2 412 DO jj=j1,j2 413 DO ji=i1,i2 414 !> jc tmp 415 tabres(ji,jj,jk,jn) = tsn(ji,jj,jk,jn) * e3t_n(ji,jj,jk) / e3t_0(ji,jj,jk) 416 ! tabres(ji,jj,jk,jn) = tsn(ji,jj,jk,jn) * e3t_n(ji,jj,jk) 417 !< jc tmp 418 END DO 419 END DO 420 END DO 421 END DO 422 ELSE 423 !> jc tmp 424 DO jn = 1,jpts 425 tabres(i1:i2,j1:j2,k1:k2,jn) = tabres(i1:i2,j1:j2,k1:k2,jn) * e3t_0(i1:i2,j1:j2,k1:k2) & 426 & * tmask(i1:i2,j1:j2,k1:k2) 427 ENDDO 428 !< jc tmp 429 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN 430 ! Add asselin part 431 DO jn = 1,jpts 186 432 DO jk = k1, k2 187 433 DO jj = j1, j2 188 434 DO ji = i1, i2 189 435 IF( tabres(ji,jj,jk,jn) /= 0._wp ) THEN 190 tsb(ji,jj,jk,jn) = tsb(ji,jj,jk,jn) & 191 & + atfp * ( tabres(ji,jj,jk,jn) - tsn(ji,jj,jk,jn) ) * tmask(ji,jj,jk) 436 ztb = tsb(ji,jj,jk,jn) * e3t_b(ji,jj,jk) ! fse3t_b prior update should be used 437 ztnu = tabres(ji,jj,jk,jn) 438 ztno = tsn(ji,jj,jk,jn) * e3t_a(ji,jj,jk) 439 tsb(ji,jj,jk,jn) = ( ztb + atfp * ( ztnu - ztno) ) & 440 & * tmask(ji,jj,jk) / e3t_b(ji,jj,jk) 192 441 ENDIF 193 442 END DO … … 196 445 END DO 197 446 ENDIF 198 DO jn = n1,n2447 DO jn = 1,jpts 199 448 DO jk=k1,k2 200 449 DO jj=j1,j2 201 450 DO ji=i1,i2 202 451 IF( tabres(ji,jj,jk,jn) /= 0._wp ) THEN 203 tsn(ji,jj,jk,jn) = tabres(ji,jj,jk,jn) * tmask(ji,jj,jk)452 tsn(ji,jj,jk,jn) = tabres(ji,jj,jk,jn) / e3t_n(ji,jj,jk) 204 453 END IF 205 454 END DO … … 207 456 END DO 208 457 END DO 458 ! 459 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 460 tsb(i1:i2,j1:j2,k1:k2,1:jpts) = tsn(i1:i2,j1:j2,k1:k2,1:jpts) 461 ENDIF 462 ! 209 463 ENDIF 210 464 ! 211 465 END SUBROUTINE updateTS 212 466 213 214 SUBROUTINE updateu( tabres, i1, i2, j1, j2, k1, k2, before ) 467 # endif 468 469 # if defined key_vertical 470 471 SUBROUTINE updateu( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 215 472 !!--------------------------------------------- 216 473 !! *** ROUTINE updateu *** 217 474 !!--------------------------------------------- 218 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2219 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2 ), INTENT(inout) :: tabres220 LOGICAL , INTENT(in ) :: before475 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 476 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 477 LOGICAL , INTENT(in ) :: before 221 478 ! 222 479 INTEGER :: ji, jj, jk 223 480 REAL(wp):: zrhoy 481 ! VERTICAL REFINEMENT BEGIN 482 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: tabres_child 483 REAL(wp) :: h_in(k1:k2) 484 REAL(wp) :: h_out(1:jpk) 485 INTEGER :: N_in, N_out 486 REAL(wp) :: h_diff, excess, thick 487 REAL(wp) :: tabin(k1:k2) 488 ! VERTICAL REFINEMENT END 489 !!--------------------------------------------- 490 ! 491 IF( before ) THEN 492 zrhoy = Agrif_Rhoy() 493 AGRIF_SpecialValue = -999._wp 494 DO jk=k1,k2 495 DO jj=j1,j2 496 DO ji=i1,i2 497 tabres(ji,jj,jk,1) = zrhoy * e2u(ji,jj) * e3u_n(ji,jj,jk) * umask(ji,jj,jk) * un(ji,jj,jk) & 498 + (umask(ji,jj,jk)-1)*999._wp 499 tabres(ji,jj,jk,2) = zrhoy * umask(ji,jj,jk) * e2u(ji,jj) * e3u_n(ji,jj,jk) & 500 + (umask(ji,jj,jk)-1)*999._wp 501 END DO 502 END DO 503 END DO 504 ELSE 505 tabres_child(:,:,:) = 0. 506 AGRIF_SpecialValue = 0._wp 507 DO jj=j1,j2 508 DO ji=i1,i2 509 N_in = 0 510 h_in(:) = 0._wp 511 tabin(:) = 0._wp 512 DO jk=k1,k2 !k2=jpk of child grid 513 IF( tabres(ji,jj,jk,2) < -900) EXIT 514 N_in = N_in + 1 515 tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2) 516 h_in(N_in) = tabres(ji,jj,jk,2)/e2u(ji,jj) 517 ENDDO 518 N_out = 0 519 DO jk=1,jpk 520 IF (umask(ji,jj,jk) == 0) EXIT 521 N_out = N_out + 1 522 h_out(N_out) = e3u_n(ji,jj,jk) 523 ENDDO 524 IF (N_in * N_out > 0) THEN 525 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 526 IF (h_diff < -1.e-4) THEN 527 !Even if bathy at T points match it's possible for the U points to be deeper in the child grid. 528 !In this case we need to move transport from the child grid cells below bed of parent grid into the bottom cell. 529 excess = 0._wp 530 DO jk=N_in,1,-1 531 thick = MIN(-1*h_diff, h_in(jk)) 532 excess = excess + tabin(jk)*thick*e2u(ji,jj) 533 tabin(jk) = tabin(jk)*(1. - thick/h_in(jk)) 534 h_diff = h_diff + thick 535 IF ( h_diff == 0) THEN 536 N_in = jk 537 h_in(jk) = h_in(jk) - thick 538 EXIT 539 ENDIF 540 ENDDO 541 ENDIF 542 CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 543 tabres_child(ji,jj,N_out) = tabres_child(ji,jj,N_out) + excess/(e2u(ji,jj)*h_out(N_out)) 544 ENDIF 545 ENDDO 546 ENDDO 547 548 DO jk=1,jpk 549 DO jj=j1,j2 550 DO ji=i1,i2 551 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part 552 ub(ji,jj,jk) = ub(ji,jj,jk) & 553 & + atfp * ( tabres_child(ji,jj,jk) - un(ji,jj,jk) ) * umask(ji,jj,jk) 554 ENDIF 555 ! 556 un(ji,jj,jk) = tabres_child(ji,jj,jk) * umask(ji,jj,jk) 557 END DO 558 END DO 559 END DO 560 ENDIF 561 ! 562 END SUBROUTINE updateu 563 564 #else 565 566 SUBROUTINE updateu( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 567 !!--------------------------------------------- 568 !! *** ROUTINE updateu *** 569 !!--------------------------------------------- 570 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 571 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 572 LOGICAL , INTENT(in ) :: before 573 ! 574 INTEGER :: ji, jj, jk 575 REAL(wp) :: zrhoy, zub, zunu, zuno 224 576 !!--------------------------------------------- 225 577 ! … … 227 579 zrhoy = Agrif_Rhoy() 228 580 DO jk = k1, k2 229 tabres(i1:i2,j1:j2,jk ) = zrhoy * e2u(i1:i2,j1:j2) * e3u_n(i1:i2,j1:j2,jk) * un(i1:i2,j1:j2,jk)581 tabres(i1:i2,j1:j2,jk,1) = zrhoy * e2u(i1:i2,j1:j2) * e3u_n(i1:i2,j1:j2,jk) * un(i1:i2,j1:j2,jk) 230 582 END DO 231 583 ELSE … … 233 585 DO jj=j1,j2 234 586 DO ji=i1,i2 235 tabres(ji,jj,jk ) = tabres(ji,jj,jk) * r1_e2u(ji,jj) / e3u_n(ji,jj,jk)587 tabres(ji,jj,jk,1) = tabres(ji,jj,jk,1) * r1_e2u(ji,jj) 236 588 ! 237 589 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part 238 ub(ji,jj,jk) = ub(ji,jj,jk) & 239 & + atfp * ( tabres(ji,jj,jk) - un(ji,jj,jk) ) * umask(ji,jj,jk) 590 zub = ub(ji,jj,jk) * e3u_b(ji,jj,jk) ! fse3t_b prior update should be used 591 zuno = un(ji,jj,jk) * e3u_a(ji,jj,jk) 592 zunu = tabres(ji,jj,jk,1) 593 ub(ji,jj,jk) = ( zub + atfp * ( zunu - zuno) ) & 594 & * umask(ji,jj,jk) / e3u_b(ji,jj,jk) 240 595 ENDIF 241 596 ! 242 un(ji,jj,jk) = tabres(ji,jj,jk) * umask(ji,jj,jk) 243 END DO 244 END DO 245 END DO 597 un(ji,jj,jk) = tabres(ji,jj,jk,1) * umask(ji,jj,jk) / e3u_n(ji,jj,jk) 598 END DO 599 END DO 600 END DO 601 ! 602 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 603 ub(i1:i2,j1:j2,k1:k2) = un(i1:i2,j1:j2,k1:k2) 604 ENDIF 605 ! 246 606 ENDIF 247 607 ! 248 608 END SUBROUTINE updateu 249 609 250 251 SUBROUTINE updatev( tabres, i1, i2, j1, j2, k1, k2, before ) 252 !!---------------------------------------------------------------------- 253 !! *** ROUTINE updatev *** 254 !!---------------------------------------------------------------------- 255 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2 256 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres 257 LOGICAL , INTENT(in ) :: before 610 # endif 611 612 SUBROUTINE correct_u_bdy( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir ) 613 !!--------------------------------------------- 614 !! *** ROUTINE correct_u_bdy *** 615 !!--------------------------------------------- 616 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 617 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 618 LOGICAL , INTENT(in ) :: before 619 INTEGER , INTENT(in) :: nb, ndir 258 620 !! 621 LOGICAL :: western_side, eastern_side 622 ! 623 INTEGER :: jj, jk 624 REAL(wp) :: zcor 625 !!--------------------------------------------- 626 ! 627 IF( .NOT.before ) THEN 628 ! 629 western_side = (nb == 1).AND.(ndir == 1) 630 eastern_side = (nb == 1).AND.(ndir == 2) 631 ! 632 IF (western_side) THEN 633 DO jj=j1,j2 634 zcor = un_b(i1-1,jj) * hu_a(i1-1,jj) * r1_hu_n(i1-1,jj) - un_b(i1-1,jj) 635 un_b(i1-1,jj) = un_b(i1-1,jj) + zcor 636 DO jk=1,jpkm1 637 un(i1-1,jj,jk) = un(i1-1,jj,jk) + zcor * umask(i1-1,jj,jk) 638 END DO 639 END DO 640 ENDIF 641 ! 642 IF (eastern_side) THEN 643 DO jj=j1,j2 644 zcor = un_b(i2+1,jj) * hu_a(i2+1,jj) * r1_hu_n(i2+1,jj) - un_b(i2+1,jj) 645 un_b(i2+1,jj) = un_b(i2+1,jj) + zcor 646 DO jk=1,jpkm1 647 un(i2+1,jj,jk) = un(i2+1,jj,jk) + zcor * umask(i2+1,jj,jk) 648 END DO 649 END DO 650 ENDIF 651 ! 652 ENDIF 653 ! 654 END SUBROUTINE correct_u_bdy 655 656 # if defined key_vertical 657 658 SUBROUTINE updatev( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 659 !!--------------------------------------------- 660 !! *** ROUTINE updatev *** 661 !!--------------------------------------------- 662 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 663 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 664 LOGICAL , INTENT(in ) :: before 665 ! 259 666 INTEGER :: ji, jj, jk 260 667 REAL(wp) :: zrhox 261 !!---------------------------------------------------------------------- 668 ! VERTICAL REFINEMENT BEGIN 669 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: tabres_child 670 REAL(wp) :: h_in(k1:k2) 671 REAL(wp) :: h_out(1:jpk) 672 INTEGER :: N_in, N_out 673 REAL(wp) :: h_diff, excess, thick 674 REAL(wp) :: tabin(k1:k2) 675 ! VERTICAL REFINEMENT END 676 !!--------------------------------------------- 262 677 ! 263 678 IF( before ) THEN 264 679 zrhox = Agrif_Rhox() 265 DO jk = k1, k2 266 DO jj = j1, j2 267 DO ji = i1, i2 268 tabres(ji,jj,jk) = zrhox * e1v(ji,jj) * e3v_n(ji,jj,jk) * vn(ji,jj,jk) 680 AGRIF_SpecialValue = -999._wp 681 DO jk=k1,k2 682 DO jj=j1,j2 683 DO ji=i1,i2 684 tabres(ji,jj,jk,1) = zrhox * e1v(ji,jj) * e3v_n(ji,jj,jk) * vmask(ji,jj,jk) * vn(ji,jj,jk) & 685 + (vmask(ji,jj,jk)-1)*999._wp 686 tabres(ji,jj,jk,2) = vmask(ji,jj,jk) * zrhox * e1v(ji,jj) * e3v_n(ji,jj,jk) & 687 + (vmask(ji,jj,jk)-1)*999._wp 269 688 END DO 270 689 END DO 271 690 END DO 272 691 ELSE 273 DO jk = k1, k2 274 DO jj = j1, j2 275 DO ji = i1, i2 276 tabres(ji,jj,jk) = tabres(ji,jj,jk) * r1_e1v(ji,jj) / e3v_n(ji,jj,jk) 692 tabres_child(:,:,:) = 0. 693 AGRIF_SpecialValue = 0._wp 694 DO jj=j1,j2 695 DO ji=i1,i2 696 N_in = 0 697 DO jk=k1,k2 698 IF (tabres(ji,jj,jk,2) < -900) EXIT 699 N_in = N_in + 1 700 tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2) 701 h_in(N_in) = tabres(ji,jj,jk,2)/e1v(ji,jj) 702 ENDDO 703 N_out = 0 704 DO jk=1,jpk 705 IF (vmask(ji,jj,jk) == 0) EXIT 706 N_out = N_out + 1 707 h_out(N_out) = e3v_n(ji,jj,jk) 708 ENDDO 709 IF (N_in * N_out > 0) THEN 710 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 711 IF (h_diff < -1.e-4) then 712 !Even if bathy at T points match it's possible for the U points to be deeper in the child grid. 713 !In this case we need to move transport from the child grid cells below bed of parent grid into the bottom cell. 714 excess = 0._wp 715 DO jk=N_in,1,-1 716 thick = MIN(-1*h_diff, h_in(jk)) 717 excess = excess + tabin(jk)*thick*e2u(ji,jj) 718 tabin(jk) = tabin(jk)*(1. - thick/h_in(jk)) 719 h_diff = h_diff + thick 720 IF ( h_diff == 0) THEN 721 N_in = jk 722 h_in(jk) = h_in(jk) - thick 723 EXIT 724 ENDIF 725 ENDDO 726 ENDIF 727 CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 728 tabres_child(ji,jj,N_out) = tabres_child(ji,jj,N_out) + excess/(e1v(ji,jj)*h_out(N_out)) 729 ENDIF 730 ENDDO 731 ENDDO 732 733 DO jk=1,jpk 734 DO jj=j1,j2 735 DO ji=i1,i2 277 736 ! 278 737 IF( .NOT.(lk_agrif_fstep.AND.(neuler==0)) ) THEN ! Add asselin part 279 738 vb(ji,jj,jk) = vb(ji,jj,jk) & 280 & + atfp * ( tabres(ji,jj,jk) - vn(ji,jj,jk) ) * vmask(ji,jj,jk)739 & + atfp * ( tabres_child(ji,jj,jk) - vn(ji,jj,jk) ) * vmask(ji,jj,jk) 281 740 ENDIF 282 741 ! 283 vn(ji,jj,jk) = tabres (ji,jj,jk) * vmask(ji,jj,jk)742 vn(ji,jj,jk) = tabres_child(ji,jj,jk) * vmask(ji,jj,jk) 284 743 END DO 285 744 END DO … … 288 747 ! 289 748 END SUBROUTINE updatev 749 750 # else 751 752 SUBROUTINE updatev( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before) 753 !!--------------------------------------------- 754 !! *** ROUTINE updatev *** 755 !!--------------------------------------------- 756 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 757 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 758 LOGICAL , INTENT(in ) :: before 759 ! 760 INTEGER :: ji, jj, jk 761 REAL(wp) :: zrhox, zvb, zvnu, zvno 762 !!--------------------------------------------- 763 ! 764 IF (before) THEN 765 zrhox = Agrif_Rhox() 766 DO jk=k1,k2 767 DO jj=j1,j2 768 DO ji=i1,i2 769 tabres(ji,jj,jk,1) = zrhox * e1v(ji,jj) * e3v_n(ji,jj,jk) * vn(ji,jj,jk) 770 END DO 771 END DO 772 END DO 773 ELSE 774 DO jk=k1,k2 775 DO jj=j1,j2 776 DO ji=i1,i2 777 tabres(ji,jj,jk,1) = tabres(ji,jj,jk,1) * r1_e1v(ji,jj) 778 ! 779 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part 780 zvb = vb(ji,jj,jk) * e3v_b(ji,jj,jk) ! fse3t_b prior update should be used 781 zvno = vn(ji,jj,jk) * e3v_a(ji,jj,jk) 782 zvnu = tabres(ji,jj,jk,1) 783 vb(ji,jj,jk) = ( zvb + atfp * ( zvnu - zvno) ) & 784 & * vmask(ji,jj,jk) / e3v_b(ji,jj,jk) 785 ENDIF 786 ! 787 vn(ji,jj,jk) = tabres(ji,jj,jk,1) * vmask(ji,jj,jk) / e3v_n(ji,jj,jk) 788 END DO 789 END DO 790 END DO 791 ! 792 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 793 vb(i1:i2,j1:j2,k1:k2) = vn(i1:i2,j1:j2,k1:k2) 794 ENDIF 795 ! 796 ENDIF 797 ! 798 END SUBROUTINE updatev 799 800 # endif 801 802 SUBROUTINE correct_v_bdy( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir ) 803 !!--------------------------------------------- 804 !! *** ROUTINE correct_u_bdy *** 805 !!--------------------------------------------- 806 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 807 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 808 LOGICAL , INTENT(in ) :: before 809 INTEGER , INTENT(in) :: nb, ndir 810 !! 811 LOGICAL :: southern_side, northern_side 812 ! 813 INTEGER :: ji, jk 814 REAL(wp) :: zcor 815 !!--------------------------------------------- 816 ! 817 IF( .NOT.before ) THEN 818 ! 819 southern_side = (nb == 2).AND.(ndir == 1) 820 northern_side = (nb == 2).AND.(ndir == 2) 821 ! 822 IF (southern_side) THEN 823 DO ji=i1,i2 824 zcor = vn_b(ji,j1-1) * hv_a(ji,j1-1) * r1_hv_n(ji,j1-1) - vn_b(ji,j1-1) 825 vn_b(ji,j1-1) = vn_b(ji,j1-1) + zcor 826 DO jk=1,jpkm1 827 vn(ji,j1-1,jk) = vn(ji,j1-1,jk) + zcor * vmask(ji,j1-1,jk) 828 END DO 829 END DO 830 ENDIF 831 ! 832 IF (northern_side) THEN 833 DO ji=i1,i2 834 zcor = vn_b(ji,j2+1) * hv_a(ji,j2+1) * r1_hv_n(ji,j2+1) - vn_b(ji,j2+1) 835 vn_b(ji,j2+1) = vn_b(ji,j2+1) + zcor 836 DO jk=1,jpkm1 837 vn(ji,j2+1,jk) = vn(ji,j2+1,jk) + zcor * vmask(ji,j2+1,jk) 838 END DO 839 END DO 840 ENDIF 841 ! 842 ENDIF 843 ! 844 END SUBROUTINE correct_v_bdy 290 845 291 846 … … 298 853 LOGICAL , INTENT(in ) :: before 299 854 !! 300 INTEGER :: ji, jj, jk 301 REAL(wp):: zrhoy, zcorr 855 INTEGER :: ji, jj, jk 856 REAL(wp) :: zrhoy 857 REAL(wp) :: zcorr 302 858 !!--------------------------------------------- 303 859 ! … … 312 868 DO jj=j1,j2 313 869 DO ji=i1,i2 314 tabres(ji,jj) = tabres(ji,jj) * r1_ hu_n(ji,jj) * r1_e2u(ji,jj)870 tabres(ji,jj) = tabres(ji,jj) * r1_e2u(ji,jj) 315 871 ! 316 872 ! Update "now" 3d velocities: … … 319 875 spgu(ji,jj) = spgu(ji,jj) + e3u_n(ji,jj,jk) * un(ji,jj,jk) 320 876 END DO 321 spgu(ji,jj) = spgu(ji,jj) * r1_hu_n(ji,jj)322 877 ! 323 zcorr = tabres(ji,jj) - spgu(ji,jj)878 zcorr = (tabres(ji,jj) - spgu(ji,jj)) * r1_hu_n(ji,jj) 324 879 DO jk=1,jpkm1 325 880 un(ji,jj,jk) = un(ji,jj,jk) + zcorr * umask(ji,jj,jk) … … 329 884 IF ( .NOT.ln_dynspg_ts .OR. (ln_dynspg_ts.AND.(.NOT.ln_bt_fw)) ) THEN 330 885 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part 331 zcorr = tabres(ji,jj) - un_b(ji,jj)886 zcorr = (tabres(ji,jj) - un_b(ji,jj) * hu_a(ji,jj)) * r1_hu_b(ji,jj) 332 887 ub_b(ji,jj) = ub_b(ji,jj) + atfp * zcorr * umask(ji,jj,1) 333 888 END IF 334 ENDIF 335 un_b(ji,jj) = tabres(ji,jj) * umask(ji,jj,1)889 ENDIF 890 un_b(ji,jj) = tabres(ji,jj) * r1_hu_n(ji,jj) * umask(ji,jj,1) 336 891 ! 337 892 ! Correct "before" velocities to hold correct bt component: … … 340 895 spgu(ji,jj) = spgu(ji,jj) + e3u_b(ji,jj,jk) * ub(ji,jj,jk) 341 896 END DO 342 spgu(ji,jj) = spgu(ji,jj) * r1_hu_b(ji,jj)343 897 ! 344 zcorr = ub_b(ji,jj) - spgu(ji,jj) 898 zcorr = ub_b(ji,jj) - spgu(ji,jj) * r1_hu_b(ji,jj) 345 899 DO jk=1,jpkm1 346 900 ub(ji,jj,jk) = ub(ji,jj,jk) + zcorr * umask(ji,jj,jk) … … 349 903 END DO 350 904 END DO 905 ! 906 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 907 ub_b(i1:i2,j1:j2) = un_b(i1:i2,j1:j2) 908 ENDIF 351 909 ENDIF 352 910 ! … … 362 920 LOGICAL , INTENT(in ) :: before 363 921 ! 364 INTEGER :: ji, jj, jk922 INTEGER :: ji, jj, jk 365 923 REAL(wp) :: zrhox, zcorr 366 924 !!---------------------------------------------------------------------- … … 376 934 DO jj=j1,j2 377 935 DO ji=i1,i2 378 tabres(ji,jj) = tabres(ji,jj) * r1_ hv_n(ji,jj) * r1_e1v(ji,jj)936 tabres(ji,jj) = tabres(ji,jj) * r1_e1v(ji,jj) 379 937 ! 380 938 ! Update "now" 3d velocities: … … 383 941 spgv(ji,jj) = spgv(ji,jj) + e3v_n(ji,jj,jk) * vn(ji,jj,jk) 384 942 END DO 385 spgv(ji,jj) = spgv(ji,jj) * r1_hv_n(ji,jj)386 943 ! 387 zcorr = tabres(ji,jj) - spgv(ji,jj)944 zcorr = (tabres(ji,jj) - spgv(ji,jj)) * r1_hv_n(ji,jj) 388 945 DO jk=1,jpkm1 389 946 vn(ji,jj,jk) = vn(ji,jj,jk) + zcorr * vmask(ji,jj,jk) … … 393 950 IF ( .NOT.ln_dynspg_ts .OR. (ln_dynspg_ts.AND.(.NOT.ln_bt_fw)) ) THEN 394 951 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part 395 zcorr = tabres(ji,jj) - vn_b(ji,jj)952 zcorr = (tabres(ji,jj) - vn_b(ji,jj) * hv_a(ji,jj)) * r1_hv_b(ji,jj) 396 953 vb_b(ji,jj) = vb_b(ji,jj) + atfp * zcorr * vmask(ji,jj,1) 397 954 END IF 398 955 ENDIF 399 vn_b(ji,jj) = tabres(ji,jj) * vmask(ji,jj,1)956 vn_b(ji,jj) = tabres(ji,jj) * r1_hv_n(ji,jj) * vmask(ji,jj,1) 400 957 ! 401 958 ! Correct "before" velocities to hold correct bt component: … … 404 961 spgv(ji,jj) = spgv(ji,jj) + e3v_b(ji,jj,jk) * vb(ji,jj,jk) 405 962 END DO 406 spgv(ji,jj) = spgv(ji,jj) * r1_hv_b(ji,jj)407 963 ! 408 zcorr = vb_b(ji,jj) - spgv(ji,jj) 964 zcorr = vb_b(ji,jj) - spgv(ji,jj) * r1_hv_b(ji,jj) 409 965 DO jk=1,jpkm1 410 966 vb(ji,jj,jk) = vb(ji,jj,jk) + zcorr * vmask(ji,jj,jk) … … 413 969 END DO 414 970 END DO 971 ! 972 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 973 vb_b(i1:i2,j1:j2) = vn_b(i1:i2,j1:j2) 974 ENDIF 975 ! 415 976 ENDIF 416 977 ! … … 436 997 END DO 437 998 ELSE 438 IF( .NOT.ln_dynspg_ts .OR. ( ln_dynspg_ts .AND. .NOT.ln_bt_fw ) ) THEN 439 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN 440 DO jj=j1,j2 441 DO ji=i1,i2 442 sshb(ji,jj) = sshb(ji,jj) & 443 & + atfp * ( tabres(ji,jj) - sshn(ji,jj) ) * tmask(ji,jj,1) 444 END DO 445 END DO 446 ENDIF 999 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN 1000 DO jj=j1,j2 1001 DO ji=i1,i2 1002 sshb(ji,jj) = sshb(ji,jj) & 1003 & + atfp * ( tabres(ji,jj) - sshn(ji,jj) ) * tmask(ji,jj,1) 1004 END DO 1005 END DO 447 1006 ENDIF 448 1007 ! … … 452 1011 END DO 453 1012 END DO 1013 ! 1014 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 1015 sshb(i1:i2,j1:j2) = sshn(i1:i2,j1:j2) 1016 ENDIF 1017 ! 1018 454 1019 ENDIF 455 1020 ! … … 465 1030 LOGICAL , INTENT(in) :: before 466 1031 !! 467 INTEGER :: 468 REAL(wp) :: zrhoy469 !!--------------------------------------------- -------------------------1032 INTEGER :: ji, jj 1033 REAL(wp) :: zrhoy, za1, zcor 1034 !!--------------------------------------------- 470 1035 ! 471 1036 IF (before) THEN … … 478 1043 tabres = zrhoy * tabres 479 1044 ELSE 1045 ! 1046 tabres(i1:i2,j1:j2) = tabres(i1:i2,j1:j2) * r1_e2u(i1:i2,j1:j2) 1047 ! 1048 za1 = 1._wp / REAL(Agrif_rhot(), wp) 480 1049 DO jj=j1,j2 481 1050 DO ji=i1,i2 482 ub2_b(ji,jj) = tabres(ji,jj) / e2u(ji,jj) 1051 zcor=tabres(ji,jj) - ub2_b(ji,jj) 1052 ! Update time integrated fluxes also in case of multiply nested grids: 1053 ub2_i_b(ji,jj) = ub2_i_b(ji,jj) + za1 * zcor 1054 ! Update corrective fluxes: 1055 un_bf(ji,jj) = un_bf(ji,jj) + zcor 1056 ! Update half step back fluxes: 1057 ub2_b(ji,jj) = tabres(ji,jj) 483 1058 END DO 484 1059 END DO … … 487 1062 END SUBROUTINE updateub2b 488 1063 1064 SUBROUTINE reflux_sshu( tabres, i1, i2, j1, j2, before, nb, ndir ) 1065 !!--------------------------------------------- 1066 !! *** ROUTINE reflux_sshu *** 1067 !!--------------------------------------------- 1068 INTEGER, INTENT(in) :: i1, i2, j1, j2 1069 REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres 1070 LOGICAL, INTENT(in) :: before 1071 INTEGER, INTENT(in) :: nb, ndir 1072 !! 1073 LOGICAL :: western_side, eastern_side 1074 INTEGER :: ji, jj 1075 REAL(wp) :: zrhoy, za1, zcor 1076 !!--------------------------------------------- 1077 ! 1078 IF (before) THEN 1079 zrhoy = Agrif_Rhoy() 1080 DO jj=j1,j2 1081 DO ji=i1,i2 1082 tabres(ji,jj) = ub2_i_b(ji,jj) * e2u(ji,jj) 1083 END DO 1084 END DO 1085 tabres = zrhoy * tabres 1086 ELSE 1087 ! 1088 tabres(i1:i2,j1:j2) = tabres(i1:i2,j1:j2) * r1_e2u(i1:i2,j1:j2) 1089 ! 1090 western_side = (nb == 1).AND.(ndir == 1) 1091 eastern_side = (nb == 1).AND.(ndir == 2) 1092 ! 1093 IF (western_side) THEN 1094 DO jj=j1,j2 1095 zcor = rdt * r1_e1e2t(i1 ,jj) * e2u(i1,jj) * (ub2_b(i1,jj)-tabres(i1,jj)) 1096 sshn(i1 ,jj) = sshn(i1 ,jj) + zcor 1097 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) sshb(i1 ,jj) = sshb(i1 ,jj) + atfp * zcor 1098 END DO 1099 ENDIF 1100 IF (eastern_side) THEN 1101 DO jj=j1,j2 1102 zcor = - rdt * r1_e1e2t(i2+1,jj) * e2u(i2,jj) * (ub2_b(i2,jj)-tabres(i2,jj)) 1103 sshn(i2+1,jj) = sshn(i2+1,jj) + zcor 1104 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) sshb(i2+1,jj) = sshb(i2+1,jj) + atfp * zcor 1105 END DO 1106 ENDIF 1107 ! 1108 ENDIF 1109 ! 1110 END SUBROUTINE reflux_sshu 489 1111 490 1112 SUBROUTINE updatevb2b( tabres, i1, i2, j1, j2, before ) … … 496 1118 LOGICAL , INTENT(in ) :: before 497 1119 !! 498 INTEGER :: 499 REAL(wp) :: zrhox500 !!--------------------------------------------- -------------------------1120 INTEGER :: ji, jj 1121 REAL(wp) :: zrhox, za1, zcor 1122 !!--------------------------------------------- 501 1123 ! 502 1124 IF( before ) THEN … … 509 1131 tabres = zrhox * tabres 510 1132 ELSE 1133 ! 1134 tabres(i1:i2,j1:j2) = tabres(i1:i2,j1:j2) * r1_e1v(i1:i2,j1:j2) 1135 ! 1136 za1 = 1._wp / REAL(Agrif_rhot(), wp) 511 1137 DO jj=j1,j2 512 1138 DO ji=i1,i2 513 vb2_b(ji,jj) = tabres(ji,jj) / e1v(ji,jj) 1139 zcor=tabres(ji,jj) - vb2_b(ji,jj) 1140 ! Update time integrated fluxes also in case of multiply nested grids: 1141 vb2_i_b(ji,jj) = vb2_i_b(ji,jj) + za1 * zcor 1142 ! Update corrective fluxes: 1143 vn_bf(ji,jj) = vn_bf(ji,jj) + zcor 1144 ! Update half step back fluxes: 1145 vb2_b(ji,jj) = tabres(ji,jj) 514 1146 END DO 515 1147 END DO … … 518 1150 END SUBROUTINE updatevb2b 519 1151 1152 SUBROUTINE reflux_sshv( tabres, i1, i2, j1, j2, before, nb, ndir ) 1153 !!--------------------------------------------- 1154 !! *** ROUTINE reflux_sshv *** 1155 !!--------------------------------------------- 1156 INTEGER, INTENT(in) :: i1, i2, j1, j2 1157 REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres 1158 LOGICAL, INTENT(in) :: before 1159 INTEGER, INTENT(in) :: nb, ndir 1160 !! 1161 LOGICAL :: southern_side, northern_side 1162 INTEGER :: ji, jj 1163 REAL(wp) :: zrhox, za1, zcor 1164 !!--------------------------------------------- 1165 ! 1166 IF (before) THEN 1167 zrhox = Agrif_Rhox() 1168 DO jj=j1,j2 1169 DO ji=i1,i2 1170 tabres(ji,jj) = vb2_i_b(ji,jj) * e1v(ji,jj) 1171 END DO 1172 END DO 1173 tabres = zrhox * tabres 1174 ELSE 1175 ! 1176 tabres(i1:i2,j1:j2) = tabres(i1:i2,j1:j2) * r1_e1v(i1:i2,j1:j2) 1177 ! 1178 southern_side = (nb == 2).AND.(ndir == 1) 1179 northern_side = (nb == 2).AND.(ndir == 2) 1180 ! 1181 IF (southern_side) THEN 1182 DO ji=i1,i2 1183 zcor = rdt * r1_e1e2t(ji,j1 ) * e1v(ji,j1 ) * (vb2_b(ji,j1)-tabres(ji,j1)) 1184 sshn(ji,j1 ) = sshn(ji,j1 ) + zcor 1185 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) sshb(ji,j1 ) = sshb(ji,j1) + atfp * zcor 1186 END DO 1187 ENDIF 1188 IF (northern_side) THEN 1189 DO ji=i1,i2 1190 zcor = - rdt * r1_e1e2t(ji,j2+1) * e1v(ji,j2 ) * (vb2_b(ji,j2)-tabres(ji,j2)) 1191 sshn(ji,j2+1) = sshn(ji,j2+1) + zcor 1192 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) sshb(ji,j2+1) = sshb(ji,j2+1) + atfp * zcor 1193 END DO 1194 ENDIF 1195 ! 1196 ENDIF 1197 ! 1198 END SUBROUTINE reflux_sshv 520 1199 521 1200 SUBROUTINE update_scales( tabres, i1, i2, j1, j2, k1, k2, n1,n2, before ) … … 619 1298 END SUBROUTINE updateAVM 620 1299 1300 SUBROUTINE updatee3t(ptab_dum, i1, i2, j1, j2, k1, k2, before ) 1301 !!--------------------------------------------- 1302 !! *** ROUTINE updatee3t *** 1303 !!--------------------------------------------- 1304 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ptab_dum 1305 INTEGER, INTENT(in) :: i1, i2, j1, j2, k1, k2 1306 LOGICAL, INTENT(in) :: before 1307 ! 1308 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ptab 1309 INTEGER :: ji,jj,jk 1310 REAL(wp) :: zcoef 1311 !!--------------------------------------------- 1312 ! 1313 IF (.NOT.before) THEN 1314 ! 1315 ALLOCATE(ptab(i1:i2,j1:j2,1:jpk)) 1316 ! 1317 ! Update e3t from ssh (z* case only) 1318 DO jk = 1, jpkm1 1319 DO jj=j1,j2 1320 DO ji=i1,i2 1321 ptab(ji,jj,jk) = e3t_0(ji,jj,jk) * (1._wp + sshn(ji,jj) & 1322 & *ssmask(ji,jj)/(ht_0(ji,jj)-1._wp + ssmask(ji,jj))) 1323 END DO 1324 END DO 1325 END DO 1326 ! 1327 ! 1) Updates at BEFORE time step: 1328 ! ------------------------------- 1329 ! 1330 ! Save "old" scale factor (prior update) for subsequent asselin correction 1331 ! of prognostic variables 1332 e3t_a(i1:i2,j1:j2,1:jpkm1) = e3t_n(i1:i2,j1:j2,1:jpkm1) 1333 1334 ! One should also save e3t_b, but lacking of workspace... 1335 ! hdivn(i1:i2,j1:j2,1:jpkm1) = e3t_b(i1:i2,j1:j2,1:jpkm1) 1336 1337 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0) )) THEN 1338 DO jk = 1, jpkm1 1339 DO jj=j1,j2 1340 DO ji=i1,i2 1341 e3t_b(ji,jj,jk) = e3t_b(ji,jj,jk) & 1342 & + atfp * ( ptab(ji,jj,jk) - e3t_n(ji,jj,jk) ) 1343 END DO 1344 END DO 1345 END DO 1346 ! 1347 e3w_b (i1:i2,j1:j2,1) = e3w_0(i1:i2,j1:j2,1) + e3t_b(i1:i2,j1:j2,1) - e3t_0(i1:i2,j1:j2,1) 1348 gdepw_b(i1:i2,j1:j2,1) = 0.0_wp 1349 gdept_b(i1:i2,j1:j2,1) = 0.5_wp * e3w_b(i1:i2,j1:j2,1) 1350 ! 1351 DO jk = 2, jpk 1352 DO jj = j1,j2 1353 DO ji = i1,i2 1354 zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk)) 1355 e3w_b(ji,jj,jk) = e3w_0(ji,jj,jk) + ( 1.0_wp - 0.5_wp * tmask(ji,jj,jk) ) * & 1356 & ( e3t_b(ji,jj,jk-1) - e3t_0(ji,jj,jk-1) ) & 1357 & + 0.5_wp * tmask(ji,jj,jk) * & 1358 & ( e3t_b(ji,jj,jk ) - e3t_0(ji,jj,jk ) ) 1359 gdepw_b(ji,jj,jk) = gdepw_b(ji,jj,jk-1) + e3t_b(ji,jj,jk-1) 1360 gdept_b(ji,jj,jk) = zcoef * ( gdepw_b(ji,jj,jk ) + 0.5 * e3w_b(ji,jj,jk)) & 1361 & + (1-zcoef) * ( gdept_b(ji,jj,jk-1) + e3w_b(ji,jj,jk)) 1362 END DO 1363 END DO 1364 END DO 1365 ! 1366 ENDIF 1367 ! 1368 ! 2) Updates at NOW time step: 1369 ! ---------------------------- 1370 ! 1371 ! Update vertical scale factor at T-points: 1372 e3t_n(i1:i2,j1:j2,1:jpkm1) = ptab(i1:i2,j1:j2,1:jpkm1) 1373 ! 1374 ! Update total depth: 1375 ht_n(i1:i2,j1:j2) = 0._wp 1376 DO jk = 1, jpkm1 1377 ht_n(i1:i2,j1:j2) = ht_n(i1:i2,j1:j2) + e3t_n(i1:i2,j1:j2,jk) * tmask(i1:i2,j1:j2,jk) 1378 END DO 1379 ! 1380 ! Update vertical scale factor at W-points and depths: 1381 e3w_n (i1:i2,j1:j2,1) = e3w_0(i1:i2,j1:j2,1) + e3t_n(i1:i2,j1:j2,1) - e3t_0(i1:i2,j1:j2,1) 1382 gdept_n(i1:i2,j1:j2,1) = 0.5_wp * e3w_n(i1:i2,j1:j2,1) 1383 gdepw_n(i1:i2,j1:j2,1) = 0.0_wp 1384 gde3w_n(i1:i2,j1:j2,1) = gdept_n(i1:i2,j1:j2,1) - (ht_n(i1:i2,j1:j2)-ht_0(i1:i2,j1:j2)) ! Last term in the rhs is ssh 1385 ! 1386 DO jk = 2, jpk 1387 DO jj = j1,j2 1388 DO ji = i1,i2 1389 zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk)) 1390 e3w_n(ji,jj,jk) = e3w_0(ji,jj,jk) + ( 1.0_wp - 0.5_wp * tmask(ji,jj,jk) ) * ( e3t_n(ji,jj,jk-1) - e3t_0(ji,jj,jk-1) ) & 1391 & + 0.5_wp * tmask(ji,jj,jk) * ( e3t_n(ji,jj,jk ) - e3t_0(ji,jj,jk ) ) 1392 gdepw_n(ji,jj,jk) = gdepw_n(ji,jj,jk-1) + e3t_n(ji,jj,jk-1) 1393 gdept_n(ji,jj,jk) = zcoef * ( gdepw_n(ji,jj,jk ) + 0.5 * e3w_n(ji,jj,jk)) & 1394 & + (1-zcoef) * ( gdept_n(ji,jj,jk-1) + e3w_n(ji,jj,jk)) 1395 gde3w_n(ji,jj,jk) = gdept_n(ji,jj,jk) - (ht_n(ji,jj)-ht_0(ji,jj)) ! Last term in the rhs is ssh 1396 END DO 1397 END DO 1398 END DO 1399 ! 1400 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 1401 e3t_b (i1:i2,j1:j2,1:jpk) = e3t_n (i1:i2,j1:j2,1:jpk) 1402 e3w_b (i1:i2,j1:j2,1:jpk) = e3w_n (i1:i2,j1:j2,1:jpk) 1403 gdepw_b(i1:i2,j1:j2,1:jpk) = gdepw_n(i1:i2,j1:j2,1:jpk) 1404 gdept_b(i1:i2,j1:j2,1:jpk) = gdept_n(i1:i2,j1:j2,1:jpk) 1405 ENDIF 1406 ! 1407 DEALLOCATE(ptab) 1408 ENDIF 1409 ! 1410 END SUBROUTINE updatee3t 1411 621 1412 #else 622 1413 !!---------------------------------------------------------------------- -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90
r9019 r9031 64 64 !!---------------------------------------------------------------------- 65 65 ! 66 IF( before ) THEN 67 ptab(i1:i2,j1:j2,k1:k2,n1:n2) = trn(i1:i2,j1:j2,k1:k2,n1:n2) 66 INTEGER :: ji, jj, jk, jn ! dummy loop indices 67 INTEGER :: imin, imax, jmin, jmax, N_in, N_out 68 REAL(wp) :: zrhox , zalpha1, zalpha2, zalpha3 69 REAL(wp) :: zalpha4, zalpha5, zalpha6, zalpha7 70 LOGICAL :: western_side, eastern_side,northern_side,southern_side 71 ! vertical interpolation: 72 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: ptab_child 73 REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin 74 REAL(wp), DIMENSION(k1:k2) :: h_in 75 REAL(wp), DIMENSION(1:jpk) :: h_out(1:jpk) 76 REAL(wp) :: h_diff, zrhoxy 77 78 zrhoxy = Agrif_rhox()*Agrif_rhoy() 79 IF (before) THEN 80 DO jn = 1,jpts 81 DO jk=k1,k2 82 DO jj=j1,j2 83 DO ji=i1,i2 84 ptab(ji,jj,jk,jn) = trn(ji,jj,jk,jn) 85 END DO 86 END DO 87 END DO 88 END DO 89 # if defined key_vertical 90 DO jk=k1,k2 91 DO jj=j1,j2 92 DO ji=i1,i2 93 ptab(ji,jj,jk,jpts+1) = tmask(ji,jj,jk) * e3t_n(ji,jj,jk) 94 END DO 95 END DO 96 END DO 97 # endif 98 68 99 ELSE 69 100 ! 70 IF( nbghostcells > 1 ) THEN ! no smoothing 71 tra(i1:i2,j1:j2,k1:k2,n1:n2) = ptab(i1:i2,j1:j2,k1:k2,n1:n2) 72 ELSE ! smoothing 73 ! 74 ll_west = (nb == 1).AND.(ndir == 1) ; ll_east = (nb == 1).AND.(ndir == 2) 75 ll_south = (nb == 2).AND.(ndir == 1) ; ll_north = (nb == 2).AND.(ndir == 2) 76 ! 77 zrhox = Agrif_Rhox() 78 z1 = ( zrhox - 1. ) * 0.5 79 z3 = ( zrhox - 1. ) / ( zrhox + 1. ) 80 z6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. ) 81 z7 = - ( zrhox - 1. ) / ( zrhox + 3. ) 82 ! 83 z2 = 1. - z1 84 z4 = 1. - z3 85 z5 = 1. - z6 - z7 86 ! 87 imin = i1 ; imax = i2 88 jmin = j1 ; jmax = j2 89 ! 90 ! Remove CORNERS 91 IF((nbondj == -1).OR.(nbondj == 2)) jmin = 3 92 IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj-2 93 IF((nbondi == -1).OR.(nbondi == 2)) imin = 3 94 IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci-2 95 ! 96 IF( ll_east ) THEN !== eastern side ==! 97 DO jn = 1, jptra 98 tra(nlci,j1:j2,k1:k2,jn) = z1 * ptab(nlci,j1:j2,k1:k2,jn) + z2 * ptab(nlci-1,j1:j2,k1:k2,jn) 99 DO jk = 1, jpkm1 100 DO jj = jmin,jmax 101 IF( umask(nlci-2,jj,jk) == 0._wp ) THEN 102 tra(nlci-1,jj,jk,jn) = tra(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk) 103 ELSE 104 tra(nlci-1,jj,jk,jn) = ( z4*tra(nlci,jj,jk,jn)+z3*tra(nlci-2,jj,jk,jn) ) * tmask(nlci-1,jj,jk) 105 IF( un(nlci-2,jj,jk) > 0._wp ) THEN 106 tra(nlci-1,jj,jk,jn) = ( z6*tra(nlci-2,jj,jk,jn)+z5*tra(nlci,jj,jk,jn) & 107 & +z7*tra(nlci-3,jj,jk,jn) ) * tmask(nlci-1,jj,jk) 108 ENDIF 109 ENDIF 110 END DO 111 END DO 101 western_side = (nb == 1).AND.(ndir == 1) 102 eastern_side = (nb == 1).AND.(ndir == 2) 103 southern_side = (nb == 2).AND.(ndir == 1) 104 northern_side = (nb == 2).AND.(ndir == 2) 105 106 # if defined key_vertical 107 DO jj=j1,j2 108 DO ji=i1,i2 109 iref = ji 110 jref = jj 111 if(western_side) iref=MAX(2,ji) 112 if(eastern_side) iref=MIN(nlci-1,ji) 113 if(southern_side) jref=MAX(2,jj) 114 if(northern_side) jref=MIN(nlcj-1,jj) 115 N_in = 0 116 DO jk=k1,k2 !k2 = jpk of parent grid 117 IF (ptab(ji,jj,jk,n2) == 0) EXIT 118 N_in = N_in + 1 119 tabin(jk,:) = ptab(ji,jj,jk,n1:n2-1) 120 h_in(N_in) = ptab(ji,jj,jk,n2) 121 END DO 122 N_out = 0 123 DO jk=1,jpk ! jpk of child grid 124 IF (tmask(iref,jref,jk) == 0) EXIT 125 N_out = N_out + 1 126 h_out(jk) = e3t_n(iref,jref,jk) 112 127 ENDDO 113 ENDIF 114 ! 115 IF( ll_north ) THEN !== northern side ==! 116 DO jn = 1, jptra 117 tra(i1:i2,nlcj,k1:k2,jn) = z1 * ptab(i1:i2,nlcj,k1:k2,jn) + z2 * ptab(i1:i2,nlcj-1,k1:k2,jn) 118 DO jk = 1, jpkm1 119 DO ji = imin, imax 120 IF( vmask(ji,nlcj-2,jk) == 0._wp ) THEN 121 tra(ji,nlcj-1,jk,jn) = tra(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk) 122 ELSE 123 tra(ji,nlcj-1,jk,jn) = ( z4*tra(ji,nlcj,jk,jn)+z3*tra(ji,nlcj-2,jk,jn) ) * tmask(ji,nlcj-1,jk) 124 IF (vn(ji,nlcj-2,jk) > 0._wp ) THEN 125 tra(ji,nlcj-1,jk,jn) = ( z6*tra(ji,nlcj-2,jk,jn)+z5*tra(ji,nlcj,jk,jn) & 126 & +z7*tra(ji,nlcj-3,jk,jn) ) * tmask(ji,nlcj-1,jk) 127 ENDIF 128 ENDIF 129 END DO 130 END DO 131 END DO 132 ENDIF 133 ! 134 IF( ll_west ) THEN !== western side ==! 135 DO jn = 1, jptra 136 tra(1,j1:j2,k1:k2,jn) = z1 * ptab(1,j1:j2,k1:k2,jn) + z2 * ptab(2,j1:j2,k1:k2,jn) 137 DO jk = 1, jpkm1 138 DO jj = jmin,jmax 139 IF( umask(2,jj,jk) == 0._wp ) THEN 140 tra(2,jj,jk,jn) = tra(1,jj,jk,jn) * tmask(2,jj,jk) 141 ELSE 142 tra(2,jj,jk,jn) = ( z4*tra(1,jj,jk,jn)+z3*tra(3,jj,jk,jn) ) * tmask(2,jj,jk) 143 IF( un(2,jj,jk) < 0._wp ) THEN 144 tra(2,jj,jk,jn) = ( z6*tra(3,jj,jk,jn)+z5*tra(1,jj,jk,jn)+z7*tra(4,jj,jk,jn) ) * tmask(2,jj,jk) 145 ENDIF 146 ENDIF 147 END DO 148 END DO 149 END DO 150 ENDIF 151 ! 152 IF( ll_south ) THEN !== southern side ==! 153 DO jn = 1, jptra 154 tra(i1:i2,1,k1:k2,jn) = z1 * ptab(i1:i2,1,k1:k2,jn) + z2 * ptab(i1:i2,2,k1:k2,jn) 155 DO jk = 1, jpk 156 DO ji = imin, imax 157 IF( vmask(ji,2,jk) == 0._wp ) THEN 158 tra(ji,2,jk,jn) = tra(ji,1,jk,jn) * tmask(ji,2,jk) 159 ELSE 160 tra(ji,2,jk,jn) = ( z4*tra(ji,1,jk,jn)+z3*tra(ji,3,jk,jn) ) * tmask(ji,2,jk) 161 IF( vn(ji,2,jk) < 0._wp ) THEN 162 tra(ji,2,jk,jn) = ( z6*tra(ji,3,jk,jn)+z5*tra(ji,1,jk,jn)+z7*tra(ji,4,jk,jn) ) * tmask(ji,2,jk) 163 ENDIF 128 IF (N_in > 0) THEN 129 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 130 DO jn=1,jptra 131 call reconstructandremap(tabin(1:N_in,jn),h_in,ptab_child(ji,jj,1:N_out,jn),h_out,N_in,N_out) 132 ENDDO 133 ENDIF 134 ENDDO 135 ENDDO 136 # else 137 ptab_child(i1:i2,j1:j2,1:jpk,1:jptra) = ptab(i1:i2,j1:j2,1:jpk,1:jptra) 138 # endif 139 140 ! 141 zrhox = Agrif_Rhox() 142 ! 143 zalpha1 = ( zrhox - 1. ) * 0.5 144 zalpha2 = 1. - zalpha1 145 ! 146 zalpha3 = ( zrhox - 1. ) / ( zrhox + 1. ) 147 zalpha4 = 1. - zalpha3 148 ! 149 zalpha6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. ) 150 zalpha7 = - ( zrhox - 1. ) / ( zrhox + 3. ) 151 zalpha5 = 1. - zalpha6 - zalpha7 152 ! 153 imin = i1 154 imax = i2 155 jmin = j1 156 jmax = j2 157 ! 158 ! Remove CORNERS 159 IF((nbondj == -1).OR.(nbondj == 2)) jmin = 3 160 IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj-2 161 IF((nbondi == -1).OR.(nbondi == 2)) imin = 3 162 IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci-2 163 ! 164 IF( eastern_side) THEN 165 DO jn = 1, jptra 166 tra(nlci,j1:j2,1:jpk,jn) = zalpha1 * ptab_child(nlci,j1:j2,1:jpk,jn) + zalpha2 * ptab_child(nlci-1,j1:j2,1:jpk,jn) 167 DO jk = 1, jpkm1 168 DO jj = jmin,jmax 169 IF( umask(nlci-2,jj,jk) == 0.e0 ) THEN 170 tra(nlci-1,jj,jk,jn) = tra(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk) 171 ELSE 172 tra(nlci-1,jj,jk,jn)=(zalpha4*tra(nlci,jj,jk,jn)+zalpha3*tra(nlci-2,jj,jk,jn))*tmask(nlci-1,jj,jk) 173 IF( un(nlci-2,jj,jk) > 0.e0 ) THEN 174 tra(nlci-1,jj,jk,jn)=( zalpha6*tra(nlci-2,jj,jk,jn)+zalpha5*tra(nlci,jj,jk,jn) & 175 + zalpha7*tra(nlci-3,jj,jk,jn) ) * tmask(nlci-1,jj,jk) 176 ENDIF 177 END DO 178 END DO 179 END DO 180 ENDDO 181 ENDIF 182 ! 183 IF( northern_side ) THEN 184 DO jn = 1, jptra 185 tra(i1:i2,nlcj,1:jpk,jn) = zalpha1 * ptab_child(i1:i2,nlcj,1:jpk,jn) + zalpha2 * ptab_child(i1:i2,nlcj-1,1:jpk,jn) 186 DO jk = 1, jpkm1 187 DO ji = imin,imax 188 IF( vmask(ji,nlcj-2,jk) == 0.e0 ) THEN 189 tra(ji,nlcj-1,jk,jn) = tra(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk) 190 ELSE 191 tra(ji,nlcj-1,jk,jn)=(zalpha4*tra(ji,nlcj,jk,jn)+zalpha3*tra(ji,nlcj-2,jk,jn))*tmask(ji,nlcj-1,jk) 192 IF (vn(ji,nlcj-2,jk) > 0.e0 ) THEN 193 tra(ji,nlcj-1,jk,jn)=( zalpha6*tra(ji,nlcj-2,jk,jn)+zalpha5*tra(ji,nlcj,jk,jn) & 194 + zalpha7*tra(ji,nlcj-3,jk,jn) ) * tmask(ji,nlcj-1,jk) 195 ENDIF 196 END DO 197 END DO 198 END DO 199 ENDDO 200 ENDIF 201 ! 202 IF( western_side) THEN 203 DO jn = 1, jptra 204 tra(1,j1:j2,1:jpk,jn) = zalpha1 * ptab_child(1,j1:j2,1:jpk,jn) + zalpha2 * ptab_child(2,j1:j2,1:jpk,jn) 205 DO jk = 1, jpkm1 206 DO jj = jmin,jmax 207 IF( umask(2,jj,jk) == 0.e0 ) THEN 208 tra(2,jj,jk,jn) = tra(1,jj,jk,jn) * tmask(2,jj,jk) 209 ELSE 210 tra(2,jj,jk,jn)=(zalpha4*tra(1,jj,jk,jn)+zalpha3*tra(3,jj,jk,jn))*tmask(2,jj,jk) 211 IF( un(2,jj,jk) < 0.e0 ) THEN 212 tra(2,jj,jk,jn)=(zalpha6*tra(3,jj,jk,jn)+zalpha5*tra(1,jj,jk,jn)+zalpha7*tra(4,jj,jk,jn))*tmask(2,jj,jk) 213 ENDIF 214 END DO 215 END DO 216 END DO 217 END DO 218 ENDIF 219 ! 220 IF( southern_side ) THEN 221 DO jn = 1, jptra 222 tra(i1:i2,1,1:jpk,jn) = zalpha1 * ptab_child(i1:i2,1,1:jpk,jn) + zalpha2 * ptab_child(i1:i2,2,1:jpk,jn) 223 DO jk=1,jpkm1 224 DO ji=imin,imax 225 IF( vmask(ji,2,jk) == 0.e0 ) THEN 226 tra(ji,2,jk,jn)=tra(ji,1,jk,jn) * tmask(ji,2,jk) 227 ELSE 228 tra(ji,2,jk,jn)=(zalpha4*tra(ji,1,jk,jn)+zalpha3*tra(ji,3,jk,jn))*tmask(ji,2,jk) 229 IF( vn(ji,2,jk) < 0.e0 ) THEN 230 tra(ji,2,jk,jn)=(zalpha6*tra(ji,3,jk,jn)+zalpha5*tra(ji,1,jk,jn)+zalpha7*tra(ji,4,jk,jn))*tmask(ji,2,jk) 164 231 ENDIF 165 232 END DO … … 175 242 ! 176 243 ENDIF 244 ! 245 ! Treatment of corners 246 ! 247 ! East south 248 IF ((eastern_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN 249 tra(nlci-1,2,:,:) = ptab_child(nlci-1,2,:,:) 250 ENDIF 251 ! East north 252 IF ((eastern_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN 253 tra(nlci-1,nlcj-1,:,:) = ptab_child(nlci-1,nlcj-1,:,:) 254 ENDIF 255 ! West south 256 IF ((western_side).AND.((nbondj == -1).OR.(nbondj == 2))) THEN 257 tra(2,2,:,:) = ptab_child(2,2,:,:) 258 ENDIF 259 ! West north 260 IF ((western_side).AND.((nbondj == 1).OR.(nbondj == 2))) THEN 261 tra(2,nlcj-1,:,:) = ptab_child(2,nlcj-1,:,:) 262 ENDIF 263 ! 177 264 ENDIF 178 265 ! -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_top_sponge.F90
r9019 r9031 44 44 ! 45 45 #if defined SPONGE_TOP 46 zcoef = REAL( Agrif_NbStepint(), wp ) / Agrif_rhot() 46 !! Assume persistence 47 timecoeff = REAL(Agrif_rhot()-1,wp)/REAL(Agrif_rhot()) 47 48 CALL Agrif_sponge 48 49 Agrif_SpecialValue = 0._wp … … 68 69 REAL(wp), DIMENSION(i1:i2,j1:j2) :: ztu, ztv 69 70 REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2) :: trbdiff 71 ! vertical interpolation: 72 REAL(wp), DIMENSION(i1:i2,j1:j2,jpk,n1:n2) ::tabres_child 73 REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin 74 REAL(wp), DIMENSION(k1:k2) :: h_in 75 REAL(wp), DIMENSION(1:jpk) :: h_out 76 INTEGER :: N_in, N_out 77 REAL(wp) :: h_diff 70 78 !!---------------------------------------------------------------------- 71 79 ! 72 80 IF( before ) THEN 73 tabres(i1:i2,j1:j2,k1:k2,n1:n2) = trn(i1:i2,j1:j2,k1:k2,n1:n2) 81 DO jn = 1, jptra 82 DO jk=k1,k2 83 DO jj=j1,j2 84 DO ji=i1,i2 85 tabres(ji,jj,jk,jn) = trb(ji,jj,jk,jn) 86 END DO 87 END DO 88 END DO 89 END DO 90 91 # if defined key_vertical 92 DO jk=k1,k2 93 DO jj=j1,j2 94 DO ji=i1,i2 95 tabres(ji,jj,jk,jpts+1) = tmask(ji,jj,jk) * e3t_n(ji,jj,jk) 96 END DO 97 END DO 98 END DO 99 # endif 74 100 ELSE 75 !!gm line below use of :,: versus i1:i2,j1:j2 .... strange, not wrong. ===>> to be corrected 76 trbdiff(:,:,:,:) = trb(i1:i2,j1:j2,:,:) - tabres(:,:,:,:) 101 # if defined key_vertical 102 tabres_child(:,:,:,:) = 0. 103 DO jj=j1,j2 104 DO ji=i1,i2 105 N_in = 0 106 DO jk=k1,k2 !k2 = jpk of parent grid 107 IF (tabres(ji,jj,jk,n2) == 0) EXIT 108 N_in = N_in + 1 109 tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1) 110 h_in(N_in) = tabres(ji,jj,jk,n2) 111 END DO 112 N_out = 0 113 DO jk=1,jpk ! jpk of child grid 114 IF (tmask(ji,jj,jk) == 0) EXIT 115 N_out = N_out + 1 116 h_out(jk) = e3t_n(ji,jj,jk) !Child grid scale factors. Could multiply by e1e2t here instead of division above 117 ENDDO 118 IF (N_in > 0) THEN 119 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 120 tabres(ji,jj,k2,:) = tabres(ji,jj,k2-1,:) !what is this line for????? 121 DO jn=1,jptra 122 call reconstructandremap(tabin(1:N_in,jn),h_in,tabres_child(ji,jj,1:N_out,jn),h_out,N_in,N_out) 123 ENDDO 124 ENDIF 125 ENDDO 126 ENDDO 127 # endif 128 129 DO jj=j1,j2 130 DO ji=i1,i2 131 DO jk=1,jpkm1 132 # if defined key_vertical 133 trbdiff(ji,jj,jk,1:jptra) = trb(ji,jj,jk,1:jptra) - tabres_child(ji,jj,jk,1:jptra) 134 # else 135 trbdiff(ji,jj,jk,1:jptra) = trb(ji,jj,jk,1:jptra) - tabres(ji,jj,jk,1:jptra) 136 # endif 137 ENDDO 138 ENDDO 139 ENDDO 140 77 141 DO jn = 1, jptra 78 142 DO jk = 1, jpkm1 -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_top_update.F90
r9019 r9031 26 26 PUBLIC Agrif_Update_Trc 27 27 28 INTEGER, PUBLIC :: nbcline_trc = 0 !: ???29 30 28 !!---------------------------------------------------------------------- 31 29 !! NEMO/NST 4.0 , NEMO Consortium (2017) … … 35 33 CONTAINS 36 34 37 SUBROUTINE Agrif_Update_Trc( kt)35 SUBROUTINE Agrif_Update_Trc( ) 38 36 !!---------------------------------------------------------------------- 39 37 !! *** ROUTINE Agrif_Update_Trc *** 40 38 !!---------------------------------------------------------------------- 41 INTEGER, INTENT(in) :: kt 42 !!---------------------------------------------------------------------- 43 ! 44 IF((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) RETURN 39 ! 40 IF (Agrif_Root()) RETURN 41 ! 45 42 #if defined TWO_WAY 46 43 Agrif_UseSpecialValueInUpdate = .TRUE. 47 44 Agrif_SpecialValueFineGrid = 0._wp 48 45 ! 49 IF( MOD(nbcline_trc,nbclineupdate) == 0 ) THEN50 46 # if ! defined DECAL_FEEDBACK 51 CALL Agrif_Update_Variable(trn_id, procname=updateTRC ) 47 CALL Agrif_Update_Variable(trn_id, procname=updateTRC ) 48 ! CALL Agrif_Update_Variable( trn_id, locupdate=(/0,2/), procname=updateTRC ) 52 49 # else 53 CALL Agrif_Update_Variable(trn_id, locupdate=(/1,0/),procname=updateTRC ) 50 CALL Agrif_Update_Variable(trn_id, locupdate=(/1,0/),procname=updateTRC ) 51 ! CALL Agrif_Update_Variable( trn_id, locupdate=(/1,2/), procname=updateTRC ) 54 52 # endif 53 ! 54 Agrif_UseSpecialValueInUpdate = .FALSE. 55 ! 56 #endif 57 ! 58 END SUBROUTINE Agrif_Update_Trc 59 60 #ifdef key_vertical 61 SUBROUTINE updateTRC( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 62 !!--------------------------------------------- 63 !! *** ROUTINE updateT *** 64 !!--------------------------------------------- 65 INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,n1,n2 66 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 67 LOGICAL, INTENT(in) :: before 68 !! 69 INTEGER :: ji,jj,jk,jn 70 REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: tabres_child 71 REAL(wp) :: h_in(k1:k2) 72 REAL(wp) :: h_out(1:jpk) 73 INTEGER :: N_in, N_out 74 REAL(wp) :: h_diff 75 REAL(wp) :: zrho_xy 76 REAL(wp) :: tabin(k1:k2,n1:n2) 77 !!--------------------------------------------- 78 ! 79 IF (before) THEN 80 AGRIF_SpecialValue = -999._wp 81 zrho_xy = Agrif_rhox() * Agrif_rhoy() 82 DO jn = n1,n2-1 83 DO jk=k1,k2 84 DO jj=j1,j2 85 DO ji=i1,i2 86 tabres(ji,jj,jk,jn) = (trn(ji,jj,jk,jn) * e3t_n(ji,jj,jk) ) & 87 * tmask(ji,jj,jk) + (tmask(ji,jj,jk)-1)*999._wp 88 END DO 89 END DO 90 END DO 91 END DO 92 DO jk=k1,k2 93 DO jj=j1,j2 94 DO ji=i1,i2 95 tabres(ji,jj,jk,n2) = tmask(ji,jj,jk) * e3t_n(ji,jj,jk) & 96 + (tmask(ji,jj,jk)-1)*999._wp 97 END DO 98 END DO 99 END DO 55 100 ELSE 56 # if ! defined DECAL_FEEDBACK 57 CALL Agrif_Update_Variable( trn_id, locupdate=(/0,2/), procname=updateTRC ) 58 # else 59 CALL Agrif_Update_Variable( trn_id, locupdate=(/1,2/), procname=updateTRC ) 60 # endif 101 tabres_child(:,:,:,:) = 0. 102 AGRIF_SpecialValue = 0._wp 103 DO jj=j1,j2 104 DO ji=i1,i2 105 N_in = 0 106 DO jk=k1,k2 !k2 = jpk of child grid 107 IF (tabres(ji,jj,jk,n2) == 0 ) EXIT 108 N_in = N_in + 1 109 tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1)/tabres(ji,jj,jk,n2) 110 h_in(N_in) = tabres(ji,jj,jk,n2) 111 ENDDO 112 N_out = 0 113 DO jk=1,jpk ! jpk of parent grid 114 IF (tmask(ji,jj,jk) < -900) EXIT ! TODO: Will not work with ISF 115 N_out = N_out + 1 116 h_out(N_out) = e3t_n(ji,jj,jk) !Parent grid scale factors. Could multiply by e1e2t here instead of division above 117 ENDDO 118 IF (N_in > 0) THEN !Remove this? 119 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 120 IF (h_diff < -1.e-4) THEN 121 print *,'CHECK YOUR bathy T points ...',ji,jj,h_diff,sum(h_in(1:N_in)),sum(h_out(1:N_out)) 122 print *,h_in(1:N_in) 123 print *,h_out(1:N_out) 124 STOP 125 ENDIF 126 DO jn=1,jptra 127 CALL reconstructandremap(tabin(1:N_in,jn),h_in(1:N_in),tabres_child(ji,jj,1:N_out,jn),h_out(1:N_out),N_in,N_out) 128 ENDDO 129 ENDIF 130 ENDDO 131 ENDDO 132 133 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN 134 ! Add asselin part 135 DO jn = 1,jptra 136 DO jk=1,jpk 137 DO jj=j1,j2 138 DO ji=i1,i2 139 IF( tabres_child(ji,jj,jk,jn) .NE. 0. ) THEN 140 trb(ji,jj,jk,jn) = tsb(ji,jj,jk,jn) & 141 & + atfp * ( tabres_child(ji,jj,jk,jn) & 142 & - trn(ji,jj,jk,jn) ) * tmask(ji,jj,jk) 143 ENDIF 144 ENDDO 145 ENDDO 146 ENDDO 147 ENDDO 148 ENDIF 149 DO jn = 1,jptra 150 DO jk=1,jpk 151 DO jj=j1,j2 152 DO ji=i1,i2 153 IF( tabres_child(ji,jj,jk,jn) .NE. 0. ) THEN 154 trn(ji,jj,jk,jn) = tabres_child(ji,jj,jk,jn) * tmask(ji,jj,jk) 155 END IF 156 END DO 157 END DO 158 END DO 159 END DO 61 160 ENDIF 62 ! 63 Agrif_UseSpecialValueInUpdate = .FALSE. 64 nbcline_trc = nbcline_trc + 1 65 #endif 66 ! 67 END SUBROUTINE Agrif_Update_Trc 68 69 70 SUBROUTINE updateTRC( ptab, i1, i2, j1, j2, k1, k2, n1, n2, before ) 71 !!---------------------------------------------------------------------- 72 !! *** ROUTINE updateT *** 161 ! 162 END SUBROUTINE updateTRC 163 164 165 #else 166 SUBROUTINE updateTRC( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before ) 167 !!---------------------------------------------------------------------- 168 !! *** ROUTINE updateTRC *** 73 169 !!---------------------------------------------------------------------- 74 170 INTEGER , INTENT(in ) :: i1, i2, j1, j2, k1, k2, n1, n2 75 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: ptab171 REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres 76 172 LOGICAL , INTENT(in ) :: before 77 173 !! 78 INTEGER :: ji, jj, jk, jn 79 !!---------------------------------------------------------------------- 80 ! 81 IF( before ) THEN 82 ptab(i1:i2,j1:j2,k1:k2,n1:n2) = trn(i1:i2,j1:j2,k1:k2,n1:n2) 174 INTEGER :: ji,jj,jk,jn 175 REAL(wp) :: ztb, ztnu, ztno 176 !!---------------------------------------------------------------------- 177 ! 178 ! 179 IF (before) THEN 180 DO jn = n1,n2 181 DO jk=k1,k2 182 DO jj=j1,j2 183 DO ji=i1,i2 184 !> jc tmp 185 tabres(ji,jj,jk,jn) = trn(ji,jj,jk,jn) * e3t_n(ji,jj,jk) / e3t_0(ji,jj,jk) 186 ! tabres(ji,jj,jk,jn) = trn(ji,jj,jk,jn) * e3t_n(ji,jj,jk) 187 !< jc tmp 188 END DO 189 END DO 190 END DO 191 END DO 83 192 ELSE 84 IF( .NOT.(lk_agrif_fstep.AND.(neuler==0)) ) THEN 193 !> jc tmp 194 DO jn = n1,n2 195 tabres(i1:i2,j1:j2,k1:k2,jn) = tabres(i1:i2,j1:j2,k1:k2,jn) * e3t_0(i1:i2,j1:j2,k1:k2) & 196 & * tmask(i1:i2,j1:j2,k1:k2) 197 ENDDO 198 !< jc tmp 199 IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN 85 200 ! Add asselin part 86 201 DO jn = n1,n2 87 DO jk = k1, k2 88 DO jj = j1, j2 89 DO ji = i1, i2 90 IF( ptab(ji,jj,jk,jn) /= 0._wp ) THEN 91 trb(ji,jj,jk,jn) = trb(ji,jj,jk,jn) & 92 & + atfp * ( ptab(ji,jj,jk,jn) & 93 & - trn(ji,jj,jk,jn) ) * tmask(ji,jj,jk) 202 DO jk=k1,k2 203 DO jj=j1,j2 204 DO ji=i1,i2 205 IF( tabres(ji,jj,jk,jn) .NE. 0. ) THEN 206 ztb = trb(ji,jj,jk,jn) * e3t_b(ji,jj,jk) ! fse3t_b prior update should be used 207 ztnu = tabres(ji,jj,jk,jn) 208 ztno = trn(ji,jj,jk,jn) * e3t_a(ji,jj,jk) 209 trb(ji,jj,jk,jn) = ( ztb + atfp * ( ztnu - ztno) ) & 210 & * tmask(ji,jj,jk) / e3t_b(ji,jj,jk) 94 211 ENDIF 95 END 96 END 97 END 98 END 212 ENDDO 213 ENDDO 214 ENDDO 215 ENDDO 99 216 ENDIF 100 DO jn = n1, 101 DO jk = k1,k2102 DO jj = j1,j2103 DO ji = i1,i2104 IF( ptab(ji,jj,jk,jn) /= 0._wp) THEN105 trn(ji,jj,jk,jn) = ptab(ji,jj,jk,jn) * tmask(ji,jj,jk)217 DO jn = n1,n2 218 DO jk=k1,k2 219 DO jj=j1,j2 220 DO ji=i1,i2 221 IF( tabres(ji,jj,jk,jn) .NE. 0. ) THEN 222 trn(ji,jj,jk,jn) = tabres(ji,jj,jk,jn) / e3t_n(ji,jj,jk) 106 223 END IF 107 224 END DO … … 109 226 END DO 110 227 END DO 228 ! 229 IF ((neuler==0).AND.(Agrif_Nb_Step()==0) ) THEN 230 trb(i1:i2,j1:j2,k1:k2,n1:n2) = trn(i1:i2,j1:j2,k1:k2,n1:n2) 231 ENDIF 232 ! 111 233 ENDIF 112 234 ! 113 235 END SUBROUTINE updateTRC 236 #endif 114 237 115 238 #else -
branches/2017/dev_merge_2017/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
r9019 r9031 1 #define UPD_HIGH /* MIX HIGH UPDATE */ 1 2 #if defined key_agrif 2 3 !!---------------------------------------------------------------------- … … 88 89 # endif 89 90 ! 91 IF ( Agrif_Level().EQ.Agrif_MaxLevel() ) CALL agrif_Update_ini() 92 93 Agrif_UseSpecialValueInUpdate = .FALSE. 94 90 95 END SUBROUTINE Agrif_initvalues 91 96 … … 149 154 CALL Agrif_Set_bc(e2v_id,(/0,ind1-1/)) 150 155 151 ! 5. Update type156 ! 4. Update type 152 157 !--------------- 153 CALL Agrif_Set_Updatetype( e1u_id, update1=Agrif_Update_Copy , update2=Agrif_Update_Average ) 154 CALL Agrif_Set_Updatetype( e2v_id, update1=Agrif_Update_Average, update2=Agrif_Update_Copy ) 155 156 ! High order updates 157 ! CALL Agrif_Set_Updatetype( e1u_id, update1=Agrif_Update_Average , update2=Agrif_Update_Full_Weighting ) 158 ! CALL Agrif_Set_Updatetype( e2v_id, update1=Agrif_Update_Full_Weighting, update2=Agrif_Update_Average ) 159 ! 158 # if defined UPD_HIGH 159 CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Full_Weighting) 160 CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting, update2=Agrif_Update_Average) 161 #else 162 CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average) 163 CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy) 164 #endif 165 160 166 END SUBROUTINE agrif_declare_var_dom 161 167 … … 182 188 ! 183 189 LOGICAL :: check_namelist 184 CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3 190 CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 185 191 !!---------------------------------------------------------------------- 186 192 … … 212 218 Agrif_UseSpecialValue = .TRUE. 213 219 CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn ) 220 hbdy_w(:) = 0.e0 ; hbdy_e(:) = 0.e0 ; hbdy_n(:) = 0.e0 ; hbdy_s(:) = 0.e0 221 ssha(:,:) = 0.e0 214 222 215 223 IF ( ln_dynspg_ts ) THEN … … 219 227 CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b) 220 228 CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b) 221 ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 ; hbdy_w(:) =0.e0222 ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 ; hbdy_e(:) =0.e0223 ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 ; hbdy_n(:) =0.e0224 ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 ; hbdy_s(:) =0.e0229 ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 230 ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 231 ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 232 ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 225 233 ENDIF 226 234 … … 241 249 WRITE(cl_check2,*) NINT(rdt) 242 250 WRITE(cl_check3,*) NINT(Agrif_Parent(rdt)/Agrif_Rhot()) 243 CALL ctl_stop( ' incompatible time step between ocean grids', &251 CALL ctl_stop( 'Incompatible time step between ocean grids', & 244 252 & 'parent grid value : '//cl_check1 , & 245 253 & 'child grid value : '//cl_check2 , & … … 252 260 WRITE(cl_check1,*) (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 253 261 WRITE(cl_check2,*) Agrif_Parent(nitend) *Agrif_IRhot() 254 CALL ctl_warn( ' incompatible run length between grids', &255 & ' nit000 on fine grid will be changeto : '//cl_check1, &256 & ' nitend on fine grid will be changeto : '//cl_check2 )262 CALL ctl_warn( 'Incompatible run length between grids' , & 263 & 'nit000 on fine grid will be changed to : '//cl_check1, & 264 & 'nitend on fine grid will be changed to : '//cl_check2 ) 257 265 nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 258 266 nitend = Agrif_Parent(nitend) *Agrif_IRhot() 259 267 ENDIF 260 261 ! Check coordinates262 !SF IF( ln_zps ) THEN263 !SF ! check parameters for partial steps264 !SF IF( Agrif_Parent(e3zps_min) .NE. e3zps_min ) THEN265 !SF WRITE(*,*) 'incompatible e3zps_min between grids'266 !SF WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)267 !SF WRITE(*,*) 'child grid :',e3zps_min268 !SF WRITE(*,*) 'those values should be identical'269 !SF STOP270 !SF ENDIF271 !SF IF( Agrif_Parent(e3zps_rat) /= e3zps_rat ) THEN272 !SF WRITE(*,*) 'incompatible e3zps_rat between grids'273 !SF WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)274 !SF WRITE(*,*) 'child grid :',e3zps_rat275 !SF WRITE(*,*) 'those values should be identical'276 !SF STOP277 !SF ENDIF278 !SF ENDIF279 268 280 269 ! Check free surface scheme 281 270 IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.& 282 271 & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN 283 WRITE(*,*) 'incompatible free surface scheme between grids' 284 WRITE(*,*) 'parent grid ln_dynspg_ts :', Agrif_Parent(ln_dynspg_ts ) 285 WRITE(*,*) 'parent grid ln_dynspg_exp :', Agrif_Parent(ln_dynspg_exp) 286 WRITE(*,*) 'child grid ln_dynspg_ts :', ln_dynspg_ts 287 WRITE(*,*) 'child grid ln_dynspg_exp :', ln_dynspg_exp 288 WRITE(*,*) 'those logicals should be identical' 272 WRITE(cl_check1,*) Agrif_Parent( ln_dynspg_ts ) 273 WRITE(cl_check2,*) ln_dynspg_ts 274 WRITE(cl_check3,*) Agrif_Parent( ln_dynspg_exp ) 275 WRITE(cl_check4,*) ln_dynspg_exp 276 CALL ctl_stop( 'Incompatible free surface scheme between grids' , & 277 & 'parent grid ln_dynspg_ts :'//cl_check1 , & 278 & 'child grid ln_dynspg_ts :'//cl_check2 , & 279 & 'parent grid ln_dynspg_exp :'//cl_check3 , & 280 & 'child grid ln_dynspg_exp :'//cl_check4 , & 281 & 'those logicals should be identical' ) 282 STOP 283 ENDIF 284 285 ! Check if identical linear free surface option 286 IF ( ( Agrif_Parent(ln_linssh ).AND.(.NOT.ln_linssh )).OR.& 287 & ( (.NOT.Agrif_Parent(ln_linssh)).AND.ln_linssh ) ) THEN 288 WRITE(cl_check1,*) Agrif_Parent(ln_linssh ) 289 WRITE(cl_check2,*) ln_linssh 290 CALL ctl_stop( 'Incompatible linearized fs option between grids', & 291 & 'parent grid ln_linssh :'//cl_check1 , & 292 & 'child grid ln_linssh :'//cl_check2 , & 293 & 'those logicals should be identical' ) 289 294 STOP 290 295 ENDIF … … 313 318 ENDIF 314 319 ! 315 ! Do update at initialisation because not done before writing restarts316 ! This would indeed change boundary conditions values at initial time317 ! hence produce restartability issues.318 ! Note that update below is recursive (with lk_agrif_doupd=T):319 !320 ! JC: I am not sure if Agrif_MaxLevel() is the "relative"321 ! or the absolute maximum nesting level...TBC322 IF ( Agrif_Level().EQ.Agrif_MaxLevel() ) THEN323 ! NB: Do tracers first, dynamics after because nbcline incremented in dynamics324 CALL Agrif_Update_tra()325 CALL Agrif_Update_dyn()326 ENDIF327 !328 Agrif_UseSpecialValueInUpdate = .FALSE.329 nbcline = 0330 lk_agrif_doupd = .FALSE.331 !332 320 END SUBROUTINE Agrif_InitValues_cont 333 321 322 RECURSIVE SUBROUTINE Agrif_Update_ini( ) 323 !!---------------------------------------------------------------------- 324 !! *** ROUTINE agrif_Update_ini *** 325 !! 326 !! ** Purpose :: Recursive update done at initialization 327 !!---------------------------------------------------------------------- 328 USE dom_oce 329 USE agrif_opa_update 330 #if defined key_top 331 USE agrif_top_update 332 #endif 333 ! 334 IMPLICIT NONE 335 !!---------------------------------------------------------------------- 336 ! 337 IF (Agrif_Root()) RETURN 338 ! 339 IF (.NOT.ln_linssh) CALL Agrif_Update_vvl() 340 CALL Agrif_Update_tra() 341 #if defined key_top 342 CALL Agrif_Update_Trc() 343 #endif 344 CALL Agrif_Update_dyn() 345 ! JC remove update because this precludes from perfect restartability 346 !! CALL Agrif_Update_tke(0) 347 348 CALL Agrif_ChildGrid_To_ParentGrid() 349 CALL Agrif_Update_ini() 350 CALL Agrif_ParentGrid_To_ChildGrid() 351 352 END SUBROUTINE agrif_update_ini 334 353 335 354 SUBROUTINE agrif_declare_var … … 355 374 ind2 = 1 + nbghostcells 356 375 ind3 = 2 + nbghostcells 376 # if defined key_vertical 377 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts+1/),tsn_id) 378 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts+1/),tsn_sponge_id) 379 380 CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_interp_id) 381 CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_interp_id) 382 CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_update_id) 383 CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_update_id) 384 CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_sponge_id) 385 CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_sponge_id) 386 # else 357 387 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_id) 358 388 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_sponge_id) 359 389 360 CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_interp_id) 361 CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_interp_id) 362 CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_update_id) 363 CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_update_id) 364 CALL agrif_declare_variable((/1,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_sponge_id) 365 CALL agrif_declare_variable((/2,1,0/),(/ind3,ind2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_sponge_id) 390 CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_interp_id) 391 CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_interp_id) 392 CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_update_id) 393 CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_update_id) 394 CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),un_sponge_id) 395 CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),vn_sponge_id) 396 # endif 366 397 367 398 CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id) … … 383 414 CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id) 384 415 CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id) 385 CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id) 416 # if defined key_vertical 417 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),avm_id) 418 # else 419 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,1/),avm_id) 420 # endif 386 421 ENDIF 387 422 … … 433 468 IF( ln_zdftke ) CALL Agrif_Set_bc( avm_id, (/0,ind1/) ) 434 469 435 ! 5. Update type470 ! 4. Update type 436 471 !--------------- 472 CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average) 473 474 # if defined UPD_HIGH 475 CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) 476 CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 477 CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 478 479 CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 480 CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 481 CALL Agrif_Set_Updatetype(sshn_id, update = Agrif_Update_Full_Weighting) 482 CALL Agrif_Set_Updatetype(e3t_id, update = Agrif_Update_Full_Weighting) 483 484 IF( ln_zdftke) THEN 485 CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting) 486 CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting) 487 CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting) 488 ENDIF 489 490 #else 437 491 CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average) 438 439 CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average)440 441 492 CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average) 442 493 CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy) 443 494 444 CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average)445 446 495 CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average) 447 496 CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy) 497 CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average) 498 CALL Agrif_Set_Updatetype(e3t_id, update = AGRIF_Update_Average) 448 499 449 500 IF( ln_zdftke) THEN … … 453 504 ENDIF 454 505 455 ! High order updates 456 ! CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) 457 ! CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 458 ! CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 459 ! 460 ! CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 461 ! CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 462 ! CALL Agrif_Set_Updatetype(sshn_id, update = Agrif_Update_Full_Weighting) 463 506 #endif 464 507 ! 465 508 END SUBROUTINE agrif_declare_var … … 500 543 CALL ctl_stop('rhot * nn_fsbc(parent) /= N * nn_fsbc(child), therefore nn_fsbc(child) should be set to 1 or nn_fsbc(parent)') 501 544 ENDIF 502 503 ! stop if update frequency is different from nn_fsbc504 IF( nbclineupdate > nn_fsbc ) CALL ctl_stop('With ice model on child grid, nn_cln_update should be set to 1 or nn_fsbc')505 506 507 545 ! First Interpolations (using "after" ice subtime step => lim_nbstep=1) 508 546 !---------------------------------------------------------------------- … … 645 683 ENDIF 646 684 647 ! Check coordinates648 IF( ln_zps ) THEN649 ! check parameters for partial steps650 IF( Agrif_Parent(e3zps_min) .NE. e3zps_min ) THEN651 WRITE(*,*) 'incompatible e3zps_min between grids'652 WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)653 WRITE(*,*) 'child grid :',e3zps_min654 WRITE(*,*) 'those values should be identical'655 STOP656 ENDIF657 IF( Agrif_Parent(e3zps_rat) .NE. e3zps_rat ) THEN658 WRITE(*,*) 'incompatible e3zps_rat between grids'659 WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)660 WRITE(*,*) 'child grid :',e3zps_rat661 WRITE(*,*) 'those values should be identical'662 STOP663 ENDIF664 685 ENDIF 665 686 ! Check passive tracer cell … … 668 689 ENDIF 669 690 ENDIF 670 671 CALL Agrif_Update_trc(0)672 !673 Agrif_UseSpecialValueInUpdate = .FALSE.674 nbcline_trc = 0675 691 ! 676 692 END SUBROUTINE Agrif_InitValues_cont_top … … 698 714 ind2 = 1 + nbghostcells 699 715 ind3 = 2 + nbghostcells 700 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_id) 701 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_sponge_id) 716 # if defined key_vertical 717 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra+1/),trn_id) 718 CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra+1/),trn_sponge_id) 719 # else 720 CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_id) 721 CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_sponge_id) 722 # endif 702 723 703 724 ! 2. Type of interpolation … … 711 732 CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/)) 712 733 713 ! 5. Update type734 ! 4. Update type 714 735 !--------------- 736 # if defined UPD_HIGH 737 CALL Agrif_Set_Updatetype(trn_id, update = Agrif_Update_Full_Weighting) 738 #else 715 739 CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average) 716 717 ! Higher order update 718 ! CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) 719 740 #endif 720 741 ! 721 742 END SUBROUTINE agrif_declare_var_top … … 748 769 INTEGER :: ios ! Local integer output status for namelist read 749 770 INTEGER :: iminspon 750 NAMELIST/namagrif/ nn_cln_update,rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn, ln_chk_bathy771 NAMELIST/namagrif/ rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn, ln_chk_bathy 751 772 !!-------------------------------------------------------------------------------------- 752 773 ! … … 765 786 WRITE(numout,*) '~~~~~~~~~~~~~~~' 766 787 WRITE(numout,*) ' Namelist namagrif : set AGRIF parameters' 767 WRITE(numout,*) ' baroclinic update frequency nn_cln_update = ', nn_cln_update768 788 WRITE(numout,*) ' sponge coefficient for tracers rn_sponge_tra = ', rn_sponge_tra, ' s' 769 789 WRITE(numout,*) ' sponge coefficient for dynamics rn_sponge_tra = ', rn_sponge_dyn, ' s' … … 774 794 ! 775 795 ! convert DOCTOR namelist name into OLD names 776 nbclineupdate = nn_cln_update777 796 visc_tra = rn_sponge_tra 778 797 visc_dyn = rn_sponge_dyn … … 791 810 SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob ) 792 811 !!---------------------------------------------------------------------- 793 !! *** ROUTINE Agrif_ detect***812 !! *** ROUTINE Agrif_InvLoc *** 794 813 !!---------------------------------------------------------------------- 795 814 USE dom_oce
Note: See TracChangeset
for help on using the changeset viewer.