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

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 8741 for branches/2017/dev_r8624_AGRIF3_VVL/NEMOGCM/NEMO/NST_SRC/agrif_user.F90 – NEMO

Ignore:
Timestamp:
2017-11-17T17:19:55+01:00 (6 years ago)
Author:
jchanut
Message:

AGRIF + vvl Main changes - #1965

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_r8624_AGRIF3_VVL/NEMOGCM/NEMO/NST_SRC/agrif_user.F90

    r7761 r8741  
     1#undef UPD_HIGH   /* MIX HIGH UPDATE */ 
    12#if defined key_agrif 
    23!!---------------------------------------------------------------------- 
     
    8889# endif 
    8990   ! 
     91   nbcline     = 0 
     92#if defined key_top 
     93   nbcline_trc = 0 
     94#endif 
     95   ! 
     96   IF ( Agrif_Level().EQ.Agrif_MaxLevel() ) CALL agrif_Update_ini() 
     97 
     98   Agrif_UseSpecialValueInUpdate = .FALSE.      
     99 
    90100END SUBROUTINE Agrif_initvalues 
    91101 
     
    144154   CALL Agrif_Set_bc(e2v_id,(/0,0/)) 
    145155 
    146    ! 5. Update type 
     156   ! 4. Update type 
    147157   !---------------  
     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 
    148162   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average) 
    149163   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy) 
    150  
    151 ! High order updates 
    152 !   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average,            update2=Agrif_Update_Full_Weighting) 
    153 !   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting,     update2=Agrif_Update_Average) 
    154     ! 
     164#endif 
     165 
    155166END SUBROUTINE agrif_declare_var_dom 
    156167 
     
    175186   ! 
    176187   LOGICAL :: check_namelist 
    177    CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3 
     188   CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4  
    178189   !!---------------------------------------------------------------------- 
    179190 
     
    205216   Agrif_UseSpecialValue = .TRUE. 
    206217   CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn ) 
     218   hbdy_w(:) = 0.e0 ; hbdy_e(:) = 0.e0 ; hbdy_n(:) = 0.e0 ; hbdy_s(:) = 0.e0 
     219   ssha(:,:) = 0.e0 
    207220 
    208221   IF ( ln_dynspg_ts ) THEN 
     
    212225      CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b) 
    213226      CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b) 
    214       ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 ; hbdy_w(:) =0.e0 
    215       ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 ; hbdy_e(:) =0.e0  
    216       ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 ; hbdy_n(:) =0.e0  
    217       ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 ; hbdy_s(:) =0.e0 
     227      ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 
     228      ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 
     229      ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 
     230      ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 
    218231   ENDIF 
    219232 
     
    234247         WRITE(cl_check2,*)  NINT(rdt) 
    235248         WRITE(cl_check3,*)  NINT(Agrif_Parent(rdt)/Agrif_Rhot()) 
    236          CALL ctl_stop( 'incompatible time step between ocean grids',   & 
     249         CALL ctl_stop( 'Incompatible time step between ocean grids',   & 
    237250               &               'parent grid value : '//cl_check1    ,   &  
    238251               &               'child  grid value : '//cl_check2    ,   &  
     
    245258         WRITE(cl_check1,*)  (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 
    246259         WRITE(cl_check2,*)   Agrif_Parent(nitend)   *Agrif_IRhot() 
    247          CALL ctl_warn( 'incompatible run length between grids'               ,   & 
    248                &              ' nit000 on fine grid will be change to : '//cl_check1,   & 
    249                &              ' nitend on fine grid will be change to : '//cl_check2    ) 
     260         CALL ctl_warn( 'Incompatible run length between grids'                      ,   & 
     261               &               'nit000 on fine grid will be changed to : '//cl_check1,   & 
     262               &               'nitend on fine grid will be changed to : '//cl_check2    ) 
    250263         nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 
    251264         nitend =  Agrif_Parent(nitend)   *Agrif_IRhot() 
    252265      ENDIF 
    253266 
    254       ! Check coordinates 
    255      !SF  IF( ln_zps ) THEN 
    256      !SF     ! check parameters for partial steps  
    257      !SF     IF( Agrif_Parent(e3zps_min) .NE. e3zps_min ) THEN 
    258      !SF        WRITE(*,*) 'incompatible e3zps_min between grids' 
    259      !SF        WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min) 
    260      !SF        WRITE(*,*) 'child grid  :',e3zps_min 
    261      !SF        WRITE(*,*) 'those values should be identical' 
    262      !SF        STOP 
    263      !SF     ENDIF 
    264      !SF     IF( Agrif_Parent(e3zps_rat) /= e3zps_rat ) THEN 
    265      !SF        WRITE(*,*) 'incompatible e3zps_rat between grids' 
    266      !SF        WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat) 
    267      !SF        WRITE(*,*) 'child grid  :',e3zps_rat 
    268      !SF        WRITE(*,*) 'those values should be identical'                   
    269      !SF        STOP 
    270      !SF     ENDIF 
    271      !SF  ENDIF 
    272  
    273267      ! Check free surface scheme 
    274268      IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.& 
    275269         & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN 
    276          WRITE(*,*) 'incompatible free surface scheme between grids' 
    277          WRITE(*,*) 'parent grid ln_dynspg_ts  :', Agrif_Parent(ln_dynspg_ts ) 
    278          WRITE(*,*) 'parent grid ln_dynspg_exp :', Agrif_Parent(ln_dynspg_exp) 
    279          WRITE(*,*) 'child grid  ln_dynspg_ts  :', ln_dynspg_ts 
    280          WRITE(*,*) 'child grid  ln_dynspg_exp :', ln_dynspg_exp 
    281          WRITE(*,*) 'those logicals should be identical'                   
     270         WRITE(cl_check1,*)  Agrif_Parent( ln_dynspg_ts ) 
     271         WRITE(cl_check2,*)  ln_dynspg_ts 
     272         WRITE(cl_check3,*)  Agrif_Parent( ln_dynspg_exp ) 
     273         WRITE(cl_check4,*)  ln_dynspg_exp 
     274         CALL ctl_stop( 'Incompatible free surface scheme between grids' ,  & 
     275               &               'parent grid ln_dynspg_ts  :'//cl_check1  ,  &  
     276               &               'child  grid ln_dynspg_ts  :'//cl_check2  ,  & 
     277               &               'parent grid ln_dynspg_exp :'//cl_check3  ,  & 
     278               &               'child  grid ln_dynspg_exp :'//cl_check4  ,  & 
     279               &               'those logicals should be identical' )                  
     280         STOP 
     281      ENDIF 
     282 
     283      ! Check if identical linear free surface option 
     284      IF ( ( Agrif_Parent(ln_linssh ).AND.(.NOT.ln_linssh )).OR.& 
     285         & ( (.NOT.Agrif_Parent(ln_linssh)).AND.ln_linssh ) ) THEN 
     286         WRITE(cl_check1,*)  Agrif_Parent(ln_linssh ) 
     287         WRITE(cl_check2,*)  ln_linssh 
     288         CALL ctl_stop( 'Incompatible linearized fs option between grids',  & 
     289               &               'parent grid ln_linssh  :'//cl_check1     ,  & 
     290               &               'child  grid ln_linssh  :'//cl_check2     ,  & 
     291               &               'those logicals should be identical' )                   
    282292         STOP 
    283293      ENDIF 
     
    306316   ENDIF 
    307317   !  
    308    ! Do update at initialisation because not done before writing restarts 
    309    ! This would indeed change boundary conditions values at initial time 
    310    ! hence produce restartability issues. 
    311    ! Note that update below is recursive (with lk_agrif_doupd=T): 
    312    !  
    313 ! JC: I am not sure if Agrif_MaxLevel() is the "relative" 
    314 !     or the absolute maximum nesting level...TBC                         
    315    IF ( Agrif_Level().EQ.Agrif_MaxLevel() ) THEN  
    316       ! NB: Do tracers first, dynamics after because nbcline incremented in dynamics 
    317       CALL Agrif_Update_tra() 
    318       CALL Agrif_Update_dyn() 
    319    ENDIF 
    320    ! 
     318END SUBROUTINE Agrif_InitValues_cont 
     319 
     320RECURSIVE SUBROUTINE Agrif_Update_ini( ) 
     321   !!---------------------------------------------------------------------- 
     322   !!                 *** ROUTINE agrif_Update_ini *** 
     323   !! 
     324   !! ** Purpose :: Recursive update done at initialization 
     325   !!---------------------------------------------------------------------- 
     326   USE dom_oce 
     327   USE agrif_opa_update 
     328#if defined key_top 
     329   USE agrif_top_update 
     330#endif 
     331   ! 
     332   IMPLICIT NONE 
     333   !!---------------------------------------------------------------------- 
     334   ! 
     335   IF (Agrif_Root()) RETURN 
     336   ! 
     337   IF (.NOT.ln_linssh) CALL Agrif_Update_vvl() 
     338   CALL Agrif_Update_tra() 
     339#if defined key_top 
     340   CALL Agrif_Update_Trc() 
     341#endif 
     342   CALL Agrif_Update_dyn() 
    321343# if defined key_zdftke 
    322    CALL Agrif_Update_tke(0) 
    323 # endif 
    324    ! 
    325    Agrif_UseSpecialValueInUpdate = .FALSE. 
    326    nbcline = 0 
    327    lk_agrif_doupd = .FALSE. 
    328    ! 
    329 END SUBROUTINE Agrif_InitValues_cont 
    330  
     344! JC remove update because this precludes from perfect restartability 
     345!!   CALL Agrif_Update_tke() 
     346# endif 
     347 
     348   CALL Agrif_ChildGrid_To_ParentGrid() 
     349   CALL Agrif_Update_ini() 
     350   CALL Agrif_ParentGrid_To_ChildGrid() 
     351 
     352END SUBROUTINE agrif_update_ini 
    331353 
    332354SUBROUTINE agrif_declare_var 
     
    371393   CALL agrif_declare_variable((/2,2/),(/3,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id) 
    372394 
    373 # if defined key_zdftke 
    374    CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id) 
    375    CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id) 
    376    CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id) 
     395# if defined key_zdftke || defined key_zdfgls 
     396   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/), en_id) 
     397   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),avt_id) 
     398   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),avm_id) 
    377399# endif 
    378400 
     
    400422   CALL Agrif_Set_bcinterp(vmsk_id,interp=AGRIF_constant) 
    401423 
    402 # if defined key_zdftke 
     424# if defined key_zdftke || defined key_zdfgls 
    403425   CALL Agrif_Set_bcinterp(avm_id ,interp=AGRIF_linear) 
    404426# endif 
     
    411433   CALL Agrif_Set_bc(vn_interp_id,(/0,1/)) 
    412434 
    413 !   CALL Agrif_Set_bc(tsn_sponge_id,(/-3*Agrif_irhox(),0/)) 
    414 !   CALL Agrif_Set_bc(un_sponge_id,(/-2*Agrif_irhox()-1,0/)) 
    415 !   CALL Agrif_Set_bc(vn_sponge_id,(/-2*Agrif_irhox()-1,0/)) 
    416435   CALL Agrif_Set_bc(tsn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/)) 
    417436   CALL Agrif_Set_bc(un_sponge_id ,(/-nn_sponge_len*Agrif_irhox()-1,0/)) 
     
    428447   CALL Agrif_Set_bc(vmsk_id,(/0,0/)) 
    429448 
     449# if defined key_zdftke || defined key_zdfgls 
     450   CALL Agrif_Set_bc(avm_id ,(/0,1/)) 
     451# endif 
     452 
     453   ! 4. Update type 
     454   !---------------  
     455   CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average) 
     456 
     457# if defined UPD_HIGH 
     458   CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) 
     459   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 
     460   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 
     461 
     462   CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 
     463   CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 
     464   CALL Agrif_Set_Updatetype(sshn_id, update = Agrif_Update_Full_Weighting) 
     465   CALL Agrif_Set_Updatetype(e3t_id, update = Agrif_Update_Full_Weighting) 
     466 
    430467# if defined key_zdftke 
    431    CALL Agrif_Set_bc(avm_id ,(/0,1/)) 
    432 # endif 
    433  
    434    ! 5. Update type 
    435    !---------------  
     468   CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting) 
     469   CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting) 
     470   CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting) 
     471# endif 
     472 
     473#else 
    436474   CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average) 
    437  
    438    CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average) 
    439  
    440475   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average) 
    441476   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy) 
    442477 
    443    CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average) 
    444  
    445478   CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average) 
    446479   CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy) 
     480   CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average) 
     481   CALL Agrif_Set_Updatetype(e3t_id, update = AGRIF_Update_Average) 
    447482 
    448483# if defined key_zdftke 
     
    452487# endif 
    453488 
    454 ! High order updates 
    455 !   CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) 
    456 !   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 
    457 !   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 
    458 ! 
    459 !   CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) 
    460 !   CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) 
    461 !   CALL Agrif_Set_Updatetype(sshn_id, update = Agrif_Update_Full_Weighting) 
    462  
     489#endif 
    463490   ! 
    464491END SUBROUTINE agrif_declare_var 
     
    733760      ENDIF 
    734761 
    735       ! Check coordinates 
    736       IF( ln_zps ) THEN 
    737          ! check parameters for partial steps  
    738          IF( Agrif_Parent(e3zps_min) .NE. e3zps_min ) THEN 
    739             WRITE(*,*) 'incompatible e3zps_min between grids' 
    740             WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min) 
    741             WRITE(*,*) 'child grid  :',e3zps_min 
    742             WRITE(*,*) 'those values should be identical' 
    743             STOP 
    744          ENDIF 
    745          IF( Agrif_Parent(e3zps_rat) .NE. e3zps_rat ) THEN 
    746             WRITE(*,*) 'incompatible e3zps_rat between grids' 
    747             WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat) 
    748             WRITE(*,*) 'child grid  :',e3zps_rat 
    749             WRITE(*,*) 'those values should be identical'                   
    750             STOP 
    751          ENDIF 
    752762      ENDIF 
    753763      ! Check passive tracer cell 
     
    756766      ENDIF 
    757767   ENDIF 
    758  
    759    CALL Agrif_Update_trc(0) 
    760    ! 
    761    Agrif_UseSpecialValueInUpdate = .FALSE. 
    762    nbcline_trc = 0 
    763768   ! 
    764769END SUBROUTINE Agrif_InitValues_cont_top 
     
    792797   !----------------------------- 
    793798   CALL Agrif_Set_bc(trn_id,(/0,1/)) 
    794 !   CALL Agrif_Set_bc(trn_sponge_id,(/-3*Agrif_irhox(),0/)) 
    795799   CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/)) 
    796800 
    797    ! 5. Update type 
     801   ! 4. Update type 
    798802   !---------------  
     803# if defined UPD_HIGH 
     804   CALL Agrif_Set_Updatetype(trn_id, update = Agrif_Update_Full_Weighting) 
     805#else 
    799806   CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average) 
    800  
    801 !   Higher order update 
    802 !   CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) 
    803  
     807#endif 
    804808   ! 
    805809END SUBROUTINE agrif_declare_var_top 
     
    866870   IF (lk_mpp) iminspon = MIN(iminspon,FLOOR(REAL(jpi-2)/REAL(Agrif_irhox())), FLOOR(REAL(jpj-2)/REAL(Agrif_irhox())) ) 
    867871   IF (nn_sponge_len > iminspon)  CALL ctl_stop('agrif sponge length is too large') 
     872   ! Check update frequency 
     873   IF (MOD((nitend-nit000+1), nbclineupdate).NE.0 ) CALL ctl_stop('number of time steps should be a multiple of nn_cln_update') 
    868874   ! 
    869875   IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed') 
     
    878884SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob ) 
    879885   !!---------------------------------------------------------------------- 
    880    !!                     *** ROUTINE Agrif_detect *** 
     886   !!                     *** ROUTINE Agrif_InvLoc *** 
    881887   !!---------------------------------------------------------------------- 
    882888   USE dom_oce 
Note: See TracChangeset for help on using the changeset viewer.