[9096] | 1 | #undef UPD_HIGH /* MIX HIGH UPDATE */ |
---|
[393] | 2 | #if defined key_agrif |
---|
[12377] | 3 | !! * Substitutions |
---|
| 4 | # include "do_loop_substitute.h90" |
---|
[10068] | 5 | !!---------------------------------------------------------------------- |
---|
| 6 | !! NEMO/NST 4.0 , NEMO Consortium (2018) |
---|
| 7 | !! $Id$ |
---|
| 8 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
| 9 | !!---------------------------------------------------------------------- |
---|
[12377] | 10 | SUBROUTINE agrif_user |
---|
| 11 | END SUBROUTINE agrif_user |
---|
[3680] | 12 | |
---|
[12377] | 13 | SUBROUTINE agrif_before_regridding |
---|
| 14 | END SUBROUTINE agrif_before_regridding |
---|
[3680] | 15 | |
---|
[12377] | 16 | SUBROUTINE Agrif_InitWorkspace |
---|
| 17 | END SUBROUTINE Agrif_InitWorkspace |
---|
[1156] | 18 | |
---|
[12377] | 19 | SUBROUTINE Agrif_InitValues |
---|
[10068] | 20 | !!---------------------------------------------------------------------- |
---|
| 21 | !! *** ROUTINE Agrif_InitValues *** |
---|
| 22 | !!---------------------------------------------------------------------- |
---|
[12377] | 23 | USE nemogcm |
---|
[10068] | 24 | !!---------------------------------------------------------------------- |
---|
[12377] | 25 | ! |
---|
| 26 | CALL nemo_init !* Initializations of each fine grid |
---|
| 27 | Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices |
---|
| 28 | ! |
---|
| 29 | ! !* Agrif initialization |
---|
| 30 | CALL agrif_nemo_init |
---|
| 31 | CALL Agrif_InitValues_cont_dom |
---|
| 32 | CALL Agrif_InitValues_cont |
---|
[2715] | 33 | # if defined key_top |
---|
[12377] | 34 | CALL Agrif_InitValues_cont_top |
---|
[7646] | 35 | # endif |
---|
[9570] | 36 | # if defined key_si3 |
---|
[12377] | 37 | CALL Agrif_InitValues_cont_ice |
---|
[7761] | 38 | # endif |
---|
[12377] | 39 | ! |
---|
| 40 | END SUBROUTINE Agrif_initvalues |
---|
[2031] | 41 | |
---|
[12377] | 42 | SUBROUTINE Agrif_InitValues_cont_dom |
---|
[10068] | 43 | !!---------------------------------------------------------------------- |
---|
[12377] | 44 | !! *** ROUTINE Agrif_InitValues_cont_dom *** |
---|
[10068] | 45 | !!---------------------------------------------------------------------- |
---|
[12377] | 46 | ! |
---|
| 47 | CALL agrif_declare_var_dom |
---|
| 48 | ! |
---|
| 49 | END SUBROUTINE Agrif_InitValues_cont_dom |
---|
[3680] | 50 | |
---|
[12377] | 51 | SUBROUTINE agrif_declare_var_dom |
---|
[10068] | 52 | !!---------------------------------------------------------------------- |
---|
[12377] | 53 | !! *** ROUTINE agrif_declare_var_dom *** |
---|
[10068] | 54 | !!---------------------------------------------------------------------- |
---|
[12377] | 55 | USE par_oce, ONLY: nbghostcells |
---|
| 56 | ! |
---|
| 57 | IMPLICIT NONE |
---|
| 58 | ! |
---|
| 59 | INTEGER :: ind1, ind2, ind3 |
---|
[10068] | 60 | !!---------------------------------------------------------------------- |
---|
[3680] | 61 | |
---|
[10068] | 62 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 63 | !--------------------------------------------------------------------- |
---|
[12377] | 64 | ind1 = nbghostcells |
---|
| 65 | ind2 = 1 + nbghostcells |
---|
| 66 | ind3 = 2 + nbghostcells |
---|
| 67 | CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e1u_id) |
---|
| 68 | CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e2v_id) |
---|
[3680] | 69 | |
---|
[10068] | 70 | ! 2. Type of interpolation |
---|
| 71 | !------------------------- |
---|
[12377] | 72 | CALL Agrif_Set_bcinterp( e1u_id, interp1=Agrif_linear, interp2=AGRIF_ppm ) |
---|
| 73 | CALL Agrif_Set_bcinterp( e2v_id, interp1=AGRIF_ppm , interp2=Agrif_linear ) |
---|
[3680] | 74 | |
---|
[10068] | 75 | ! 3. Location of interpolation |
---|
| 76 | !----------------------------- |
---|
[12377] | 77 | CALL Agrif_Set_bc(e1u_id,(/0,ind1-1/)) |
---|
| 78 | CALL Agrif_Set_bc(e2v_id,(/0,ind1-1/)) |
---|
[3680] | 79 | |
---|
[10068] | 80 | ! 4. Update type |
---|
| 81 | !--------------- |
---|
[9031] | 82 | # if defined UPD_HIGH |
---|
[12377] | 83 | CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Full_Weighting) |
---|
| 84 | CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting, update2=Agrif_Update_Average) |
---|
[9031] | 85 | #else |
---|
[12377] | 86 | CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average) |
---|
| 87 | CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy) |
---|
[9031] | 88 | #endif |
---|
[3680] | 89 | |
---|
[12377] | 90 | END SUBROUTINE agrif_declare_var_dom |
---|
[3680] | 91 | |
---|
[12377] | 92 | SUBROUTINE Agrif_InitValues_cont |
---|
[10068] | 93 | !!---------------------------------------------------------------------- |
---|
| 94 | !! *** ROUTINE Agrif_InitValues_cont *** |
---|
| 95 | !!---------------------------------------------------------------------- |
---|
[12377] | 96 | USE agrif_oce |
---|
| 97 | USE agrif_oce_interp |
---|
| 98 | USE agrif_oce_sponge |
---|
| 99 | USE dom_oce |
---|
| 100 | USE oce |
---|
| 101 | USE lib_mpp |
---|
| 102 | USE lbclnk |
---|
| 103 | ! |
---|
| 104 | IMPLICIT NONE |
---|
| 105 | ! |
---|
| 106 | INTEGER :: ji, jj |
---|
| 107 | LOGICAL :: check_namelist |
---|
| 108 | CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 |
---|
| 109 | #if defined key_vertical |
---|
| 110 | REAL(wp), DIMENSION(jpi,jpj) :: zk ! workspace |
---|
| 111 | #endif |
---|
[10068] | 112 | !!---------------------------------------------------------------------- |
---|
[390] | 113 | |
---|
[12377] | 114 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 115 | !--------------------------------------------------------------------- |
---|
| 116 | CALL agrif_declare_var |
---|
[636] | 117 | |
---|
[12377] | 118 | ! 2. First interpolations of potentially non zero fields |
---|
| 119 | !------------------------------------------------------- |
---|
[390] | 120 | |
---|
[12377] | 121 | #if defined key_vertical |
---|
| 122 | ! Build consistent parent bathymetry and number of levels |
---|
| 123 | ! on the child grid |
---|
| 124 | Agrif_UseSpecialValue = .FALSE. |
---|
| 125 | ht0_parent(:,:) = 0._wp |
---|
| 126 | mbkt_parent(:,:) = 0 |
---|
| 127 | ! |
---|
| 128 | CALL Agrif_Bc_variable(ht0_id ,calledweight=1.,procname=interpht0 ) |
---|
| 129 | CALL Agrif_Bc_variable(mbkt_id,calledweight=1.,procname=interpmbkt) |
---|
| 130 | ! |
---|
| 131 | ! Assume step wise change of bathymetry near interface |
---|
| 132 | ! TODO: Switch to linear interpolation of bathymetry in the s-coordinate case |
---|
| 133 | ! and no refinement |
---|
| 134 | DO_2D_10_10 |
---|
| 135 | mbku_parent(ji,jj) = MIN( mbkt_parent(ji+1,jj ) , mbkt_parent(ji,jj) ) |
---|
| 136 | mbkv_parent(ji,jj) = MIN( mbkt_parent(ji ,jj+1) , mbkt_parent(ji,jj) ) |
---|
| 137 | END_2D |
---|
| 138 | IF ( ln_sco.AND.Agrif_Parent(ln_sco) ) THEN |
---|
| 139 | DO_2D_10_10 |
---|
| 140 | hu0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji+1,jj) ) |
---|
| 141 | hv0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji,jj+1) ) |
---|
| 142 | END_2D |
---|
| 143 | ELSE |
---|
| 144 | DO_2D_10_10 |
---|
| 145 | hu0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji+1,jj)) |
---|
| 146 | hv0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji,jj+1)) |
---|
| 147 | END_2D |
---|
[4326] | 148 | |
---|
[12377] | 149 | ENDIF |
---|
| 150 | ! |
---|
[12546] | 151 | CALL lbc_lnk( 'Agrif_InitValues_cont', hu0_parent, 'U', 1.0_wp ) |
---|
| 152 | CALL lbc_lnk( 'Agrif_InitValues_cont', hv0_parent, 'V', 1.0_wp ) |
---|
| 153 | zk(:,:) = REAL( mbku_parent(:,:), wp ) ; CALL lbc_lnk( 'Agrif_InitValues_cont', zk, 'U', 1.0_wp ) |
---|
[12377] | 154 | mbku_parent(:,:) = MAX( NINT( zk(:,:) ), 1 ) |
---|
[12546] | 155 | zk(:,:) = REAL( mbkv_parent(:,:), wp ) ; CALL lbc_lnk( 'Agrif_InitValues_cont', zk, 'V', 1.0_wp ) |
---|
[12377] | 156 | mbkv_parent(:,:) = MAX( NINT( zk(:,:) ), 1 ) |
---|
| 157 | #endif |
---|
[628] | 158 | |
---|
[12377] | 159 | Agrif_SpecialValue = 0._wp |
---|
| 160 | Agrif_UseSpecialValue = .TRUE. |
---|
| 161 | CALL Agrif_Bc_variable(tsn_id,calledweight=1.,procname=interptsn) |
---|
| 162 | CALL Agrif_Sponge |
---|
| 163 | tabspongedone_tsn = .FALSE. |
---|
| 164 | CALL Agrif_Bc_variable(tsn_sponge_id,calledweight=1.,procname=interptsn_sponge) |
---|
| 165 | ! reset ts(:,:,:,:,Krhs_a) to zero |
---|
| 166 | ts(:,:,:,:,Krhs_a) = 0._wp |
---|
| 167 | |
---|
[5930] | 168 | Agrif_UseSpecialValue = ln_spc_dyn |
---|
[12377] | 169 | CALL Agrif_Bc_variable(un_interp_id,calledweight=1.,procname=interpun) |
---|
| 170 | CALL Agrif_Bc_variable(vn_interp_id,calledweight=1.,procname=interpvn) |
---|
| 171 | tabspongedone_u = .FALSE. |
---|
| 172 | tabspongedone_v = .FALSE. |
---|
| 173 | CALL Agrif_Bc_variable(un_sponge_id,calledweight=1.,procname=interpun_sponge) |
---|
| 174 | tabspongedone_u = .FALSE. |
---|
| 175 | tabspongedone_v = .FALSE. |
---|
| 176 | CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge) |
---|
| 177 | uu(:,:,:,Krhs_a) = 0._wp |
---|
| 178 | vv(:,:,:,Krhs_a) = 0._wp |
---|
[5656] | 179 | |
---|
[12377] | 180 | Agrif_UseSpecialValue = .TRUE. |
---|
| 181 | CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn ) |
---|
| 182 | hbdy(:,:) = 0._wp |
---|
| 183 | ssh(:,:,Krhs_a) = 0._wp |
---|
[5656] | 184 | |
---|
[12377] | 185 | IF ( ln_dynspg_ts ) THEN |
---|
| 186 | Agrif_UseSpecialValue = ln_spc_dyn |
---|
| 187 | CALL Agrif_Bc_variable(unb_id,calledweight=1.,procname=interpunb) |
---|
| 188 | CALL Agrif_Bc_variable(vnb_id,calledweight=1.,procname=interpvnb) |
---|
| 189 | CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b) |
---|
| 190 | CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b) |
---|
| 191 | ubdy(:,:) = 0._wp |
---|
| 192 | vbdy(:,:) = 0._wp |
---|
| 193 | ENDIF |
---|
[3680] | 194 | |
---|
[12377] | 195 | Agrif_UseSpecialValue = .FALSE. |
---|
[3680] | 196 | |
---|
[12377] | 197 | ! 3. Some controls |
---|
| 198 | !----------------- |
---|
| 199 | check_namelist = .TRUE. |
---|
[3680] | 200 | |
---|
[12377] | 201 | IF( check_namelist ) THEN |
---|
[3680] | 202 | |
---|
[12377] | 203 | ! Check time steps |
---|
[12489] | 204 | IF( NINT(Agrif_Rhot()) * NINT(rn_Dt) .NE. Agrif_Parent(rn_Dt) ) THEN |
---|
| 205 | WRITE(cl_check1,*) NINT(Agrif_Parent(rn_Dt)) |
---|
| 206 | WRITE(cl_check2,*) NINT(rn_Dt) |
---|
| 207 | WRITE(cl_check3,*) NINT(Agrif_Parent(rn_Dt)/Agrif_Rhot()) |
---|
[12377] | 208 | CALL ctl_stop( 'Incompatible time step between ocean grids', & |
---|
| 209 | & 'parent grid value : '//cl_check1 , & |
---|
| 210 | & 'child grid value : '//cl_check2 , & |
---|
| 211 | & 'value on child grid should be changed to : '//cl_check3 ) |
---|
| 212 | ENDIF |
---|
[5930] | 213 | |
---|
[12377] | 214 | ! Check run length |
---|
| 215 | IF( Agrif_IRhot() * (Agrif_Parent(nitend)- & |
---|
| 216 | Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN |
---|
| 217 | WRITE(cl_check1,*) (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 |
---|
| 218 | WRITE(cl_check2,*) Agrif_Parent(nitend) *Agrif_IRhot() |
---|
| 219 | CALL ctl_warn( 'Incompatible run length between grids' , & |
---|
| 220 | & 'nit000 on fine grid will be changed to : '//cl_check1, & |
---|
| 221 | & 'nitend on fine grid will be changed to : '//cl_check2 ) |
---|
| 222 | nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 |
---|
| 223 | nitend = Agrif_Parent(nitend) *Agrif_IRhot() |
---|
| 224 | ENDIF |
---|
| 225 | |
---|
| 226 | ! Check free surface scheme |
---|
| 227 | IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.& |
---|
| 228 | & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN |
---|
| 229 | WRITE(cl_check1,*) Agrif_Parent( ln_dynspg_ts ) |
---|
| 230 | WRITE(cl_check2,*) ln_dynspg_ts |
---|
| 231 | WRITE(cl_check3,*) Agrif_Parent( ln_dynspg_exp ) |
---|
| 232 | WRITE(cl_check4,*) ln_dynspg_exp |
---|
| 233 | CALL ctl_stop( 'Incompatible free surface scheme between grids' , & |
---|
| 234 | & 'parent grid ln_dynspg_ts :'//cl_check1 , & |
---|
| 235 | & 'child grid ln_dynspg_ts :'//cl_check2 , & |
---|
| 236 | & 'parent grid ln_dynspg_exp :'//cl_check3 , & |
---|
| 237 | & 'child grid ln_dynspg_exp :'//cl_check4 , & |
---|
| 238 | & 'those logicals should be identical' ) |
---|
| 239 | STOP |
---|
| 240 | ENDIF |
---|
| 241 | |
---|
| 242 | ! Check if identical linear free surface option |
---|
| 243 | IF ( ( Agrif_Parent(ln_linssh ).AND.(.NOT.ln_linssh )).OR.& |
---|
| 244 | & ( (.NOT.Agrif_Parent(ln_linssh)).AND.ln_linssh ) ) THEN |
---|
| 245 | WRITE(cl_check1,*) Agrif_Parent(ln_linssh ) |
---|
| 246 | WRITE(cl_check2,*) ln_linssh |
---|
| 247 | CALL ctl_stop( 'Incompatible linearized fs option between grids', & |
---|
| 248 | & 'parent grid ln_linssh :'//cl_check1 , & |
---|
| 249 | & 'child grid ln_linssh :'//cl_check2 , & |
---|
| 250 | & 'those logicals should be identical' ) |
---|
| 251 | STOP |
---|
| 252 | ENDIF |
---|
| 253 | |
---|
[9031] | 254 | ENDIF |
---|
| 255 | |
---|
[5656] | 256 | ! check if masks and bathymetries match |
---|
| 257 | IF(ln_chk_bathy) THEN |
---|
[12377] | 258 | Agrif_UseSpecialValue = .FALSE. |
---|
[5656] | 259 | ! |
---|
[12377] | 260 | IF(lwp) WRITE(numout,*) ' ' |
---|
[5656] | 261 | IF(lwp) WRITE(numout,*) 'AGRIF: Check Bathymetry and masks near bdys. Level: ', Agrif_Level() |
---|
| 262 | ! |
---|
| 263 | kindic_agr = 0 |
---|
[12377] | 264 | # if ! defined key_vertical |
---|
| 265 | ! |
---|
| 266 | ! check if tmask and vertical scale factors agree with parent in sponge area: |
---|
[5656] | 267 | CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t) |
---|
| 268 | ! |
---|
[12377] | 269 | # else |
---|
| 270 | ! |
---|
| 271 | ! In case of vertical interpolation, check only that total depths agree between child and parent: |
---|
| 272 | DO ji = 1, jpi |
---|
| 273 | DO jj = 1, jpj |
---|
| 274 | IF ((mbkt_parent(ji,jj)/=0).AND.(ABS(ht0_parent(ji,jj)-ht_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1 |
---|
| 275 | IF ((mbku_parent(ji,jj)/=0).AND.(ABS(hu0_parent(ji,jj)-hu_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1 |
---|
| 276 | IF ((mbkv_parent(ji,jj)/=0).AND.(ABS(hv0_parent(ji,jj)-hv_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1 |
---|
| 277 | END DO |
---|
| 278 | END DO |
---|
| 279 | # endif |
---|
[10425] | 280 | CALL mpp_sum( 'agrif_user', kindic_agr ) |
---|
[7761] | 281 | IF( kindic_agr /= 0 ) THEN |
---|
[12377] | 282 | CALL ctl_stop('==> Child Bathymetry is NOT correct near boundaries.') |
---|
[5656] | 283 | ELSE |
---|
[12377] | 284 | IF(lwp) WRITE(numout,*) '==> Child Bathymetry is ok near boundaries.' |
---|
| 285 | IF(lwp) WRITE(numout,*) ' ' |
---|
| 286 | END IF |
---|
| 287 | ! |
---|
[5656] | 288 | ENDIF |
---|
[9031] | 289 | |
---|
[12377] | 290 | # if defined key_vertical |
---|
| 291 | ! Additional constrain that should be removed someday: |
---|
| 292 | IF ( Agrif_Parent(jpk).GT.jpk ) THEN |
---|
| 293 | CALL ctl_stop( ' With key_vertical, child grids must have jpk greater or equal to the parent value' ) |
---|
| 294 | ENDIF |
---|
| 295 | # endif |
---|
| 296 | ! |
---|
| 297 | END SUBROUTINE Agrif_InitValues_cont |
---|
| 298 | |
---|
| 299 | SUBROUTINE agrif_declare_var |
---|
[10068] | 300 | !!---------------------------------------------------------------------- |
---|
[12377] | 301 | !! *** ROUTINE agrif_declare_var *** |
---|
[10068] | 302 | !!---------------------------------------------------------------------- |
---|
[12377] | 303 | USE agrif_util |
---|
| 304 | USE agrif_oce |
---|
| 305 | USE par_oce |
---|
| 306 | USE zdf_oce |
---|
| 307 | USE oce |
---|
| 308 | ! |
---|
| 309 | IMPLICIT NONE |
---|
| 310 | ! |
---|
| 311 | INTEGER :: ind1, ind2, ind3 |
---|
[10068] | 312 | !!---------------------------------------------------------------------- |
---|
[2715] | 313 | |
---|
[12377] | 314 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 315 | !--------------------------------------------------------------------- |
---|
| 316 | ind1 = nbghostcells |
---|
| 317 | ind2 = 1 + nbghostcells |
---|
| 318 | ind3 = 2 + nbghostcells |
---|
[9031] | 319 | # if defined key_vertical |
---|
[12377] | 320 | 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) |
---|
| 321 | 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) |
---|
[9031] | 322 | |
---|
[12377] | 323 | 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) |
---|
| 324 | 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) |
---|
| 325 | 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) |
---|
| 326 | 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) |
---|
| 327 | 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) |
---|
| 328 | 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) |
---|
[9031] | 329 | # else |
---|
[12377] | 330 | 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) |
---|
| 331 | 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) |
---|
[2715] | 332 | |
---|
[12377] | 333 | 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) |
---|
| 334 | 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) |
---|
| 335 | 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) |
---|
| 336 | 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) |
---|
| 337 | 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) |
---|
| 338 | 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) |
---|
[9031] | 339 | # endif |
---|
[2715] | 340 | |
---|
[12377] | 341 | CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id) |
---|
[2715] | 342 | |
---|
[12377] | 343 | # if defined key_vertical |
---|
| 344 | CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),mbkt_id) |
---|
| 345 | CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ht0_id) |
---|
| 346 | # endif |
---|
[5656] | 347 | |
---|
[12377] | 348 | CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,3/),scales_t_id) |
---|
[5656] | 349 | |
---|
[12377] | 350 | CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),unb_id) |
---|
| 351 | CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vnb_id) |
---|
| 352 | CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_interp_id) |
---|
| 353 | CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_interp_id) |
---|
| 354 | CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_update_id) |
---|
| 355 | CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_update_id) |
---|
[5656] | 356 | |
---|
[12377] | 357 | CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id) |
---|
| 358 | |
---|
| 359 | IF( ln_zdftke.OR.ln_zdfgls ) THEN |
---|
| 360 | ! CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/), en_id) |
---|
| 361 | ! CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),avt_id) |
---|
[9031] | 362 | # if defined key_vertical |
---|
[12377] | 363 | CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),avm_id) |
---|
[9031] | 364 | # else |
---|
[12377] | 365 | 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) |
---|
[9031] | 366 | # endif |
---|
[12377] | 367 | ENDIF |
---|
[5656] | 368 | |
---|
[12377] | 369 | ! 2. Type of interpolation |
---|
| 370 | !------------------------- |
---|
| 371 | CALL Agrif_Set_bcinterp(tsn_id,interp=AGRIF_linear) |
---|
[2715] | 372 | |
---|
[12377] | 373 | CALL Agrif_Set_bcinterp(un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm) |
---|
| 374 | CALL Agrif_Set_bcinterp(vn_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear) |
---|
[2715] | 375 | |
---|
[12377] | 376 | CALL Agrif_Set_bcinterp(tsn_sponge_id,interp=AGRIF_linear) |
---|
[2715] | 377 | |
---|
[12377] | 378 | CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_linear) |
---|
| 379 | CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_ppm) |
---|
| 380 | CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_ppm,interp2=Agrif_linear) |
---|
| 381 | CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm) |
---|
| 382 | CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear) |
---|
| 383 | ! |
---|
| 384 | ! > Divergence conserving alternative: |
---|
| 385 | ! CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_constant) |
---|
| 386 | ! CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_constant) |
---|
| 387 | ! CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_constant,interp2=Agrif_linear) |
---|
| 388 | ! CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_constant) |
---|
| 389 | ! CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_constant,interp2=Agrif_linear) |
---|
| 390 | !< |
---|
[4326] | 391 | |
---|
[12377] | 392 | CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm) |
---|
| 393 | CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear) |
---|
[5656] | 394 | |
---|
[12377] | 395 | CALL Agrif_Set_bcinterp(e3t_id,interp=AGRIF_constant) |
---|
[5656] | 396 | |
---|
[12377] | 397 | # if defined key_vertical |
---|
| 398 | CALL Agrif_Set_bcinterp(mbkt_id,interp=AGRIF_constant) |
---|
| 399 | CALL Agrif_Set_bcinterp(ht0_id ,interp=AGRIF_constant) |
---|
| 400 | # endif |
---|
[5656] | 401 | |
---|
[12377] | 402 | IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear ) |
---|
[5656] | 403 | |
---|
[12377] | 404 | ! 3. Location of interpolation |
---|
| 405 | !----------------------------- |
---|
| 406 | CALL Agrif_Set_bc( tsn_id, (/0,ind1-1/) ) ! if west, rhox=3 and nbghost=3: columns 2 to 4 |
---|
| 407 | CALL Agrif_Set_bc( un_interp_id, (/0,ind1-1/) ) |
---|
| 408 | CALL Agrif_Set_bc( vn_interp_id, (/0,ind1-1/) ) |
---|
[2715] | 409 | |
---|
[12377] | 410 | CALL Agrif_Set_bc( tsn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) ) ! if west, rhox=3, nn_sponge_len=2 |
---|
| 411 | CALL Agrif_Set_bc( un_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) ) ! and nbghost=3: |
---|
| 412 | CALL Agrif_Set_bc( vn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) ) ! columns 4 to 11 |
---|
[4326] | 413 | |
---|
[12377] | 414 | CALL Agrif_Set_bc( sshn_id, (/0,ind1-1/) ) |
---|
| 415 | CALL Agrif_Set_bc( unb_id, (/0,ind1-1/) ) |
---|
| 416 | CALL Agrif_Set_bc( vnb_id, (/0,ind1-1/) ) |
---|
| 417 | CALL Agrif_Set_bc( ub2b_interp_id, (/0,ind1-1/) ) |
---|
| 418 | CALL Agrif_Set_bc( vb2b_interp_id, (/0,ind1-1/) ) |
---|
[2715] | 419 | |
---|
[12377] | 420 | ! CALL Agrif_Set_bc( e3t_id, (/-nn_sponge_len*Agrif_irhox(),ind1-1/) ) |
---|
| 421 | ! JC: check near the boundary only until matching in sponge has been sorted out: |
---|
| 422 | CALL Agrif_Set_bc( e3t_id, (/0,ind1-1/) ) |
---|
[2715] | 423 | |
---|
[12377] | 424 | # if defined key_vertical |
---|
| 425 | ! extend the interpolation zone by 1 more point than necessary: |
---|
| 426 | CALL Agrif_Set_bc( mbkt_id, (/-nn_sponge_len*Agrif_irhox()-2,ind1/) ) |
---|
| 427 | CALL Agrif_Set_bc( ht0_id, (/-nn_sponge_len*Agrif_irhox()-2,ind1/) ) |
---|
| 428 | # endif |
---|
[9748] | 429 | |
---|
[12377] | 430 | IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bc( avm_id, (/0,ind1/) ) |
---|
[5656] | 431 | |
---|
[12377] | 432 | ! 4. Update type |
---|
| 433 | !--------------- |
---|
| 434 | CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average) |
---|
[2715] | 435 | |
---|
[9031] | 436 | # if defined UPD_HIGH |
---|
[12377] | 437 | CALL Agrif_Set_Updatetype(tsn_id, update = Agrif_Update_Full_Weighting) |
---|
| 438 | CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) |
---|
| 439 | CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) |
---|
[9031] | 440 | |
---|
[12377] | 441 | CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Full_Weighting) |
---|
| 442 | CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average) |
---|
| 443 | CALL Agrif_Set_Updatetype(sshn_id,update = Agrif_Update_Full_Weighting) |
---|
| 444 | CALL Agrif_Set_Updatetype(e3t_id, update = Agrif_Update_Full_Weighting) |
---|
[9031] | 445 | |
---|
[12377] | 446 | IF( ln_zdftke.OR.ln_zdfgls ) THEN |
---|
| 447 | ! CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting) |
---|
| 448 | ! CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting) |
---|
| 449 | ! CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting) |
---|
| 450 | ENDIF |
---|
[9031] | 451 | |
---|
| 452 | #else |
---|
[12377] | 453 | CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average) |
---|
| 454 | CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average) |
---|
| 455 | CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy) |
---|
[3680] | 456 | |
---|
[12377] | 457 | CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average) |
---|
| 458 | CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy) |
---|
| 459 | CALL Agrif_Set_Updatetype(sshn_id,update = AGRIF_Update_Average) |
---|
| 460 | CALL Agrif_Set_Updatetype(e3t_id, update = AGRIF_Update_Average) |
---|
[5656] | 461 | |
---|
[12377] | 462 | IF( ln_zdftke.OR.ln_zdfgls ) THEN |
---|
| 463 | ! CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average) |
---|
| 464 | ! CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average) |
---|
| 465 | ! CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average) |
---|
| 466 | ENDIF |
---|
[5656] | 467 | |
---|
[9031] | 468 | #endif |
---|
[12377] | 469 | ! |
---|
| 470 | END SUBROUTINE agrif_declare_var |
---|
[3680] | 471 | |
---|
[9570] | 472 | #if defined key_si3 |
---|
[9610] | 473 | SUBROUTINE Agrif_InitValues_cont_ice |
---|
[10068] | 474 | !!---------------------------------------------------------------------- |
---|
| 475 | !! *** ROUTINE Agrif_InitValues_cont_ice *** |
---|
| 476 | !!---------------------------------------------------------------------- |
---|
[12377] | 477 | USE Agrif_Util |
---|
| 478 | USE sbc_oce, ONLY : nn_fsbc ! clem: necessary otherwise Agrif_Parent(nn_fsbc) = nn_fsbc |
---|
| 479 | USE ice |
---|
| 480 | USE agrif_ice |
---|
| 481 | USE in_out_manager |
---|
| 482 | USE agrif_ice_interp |
---|
| 483 | USE lib_mpp |
---|
| 484 | ! |
---|
| 485 | IMPLICIT NONE |
---|
[10068] | 486 | !!---------------------------------------------------------------------- |
---|
[12377] | 487 | ! |
---|
| 488 | ! Declaration of the type of variable which have to be interpolated (parent=>child) |
---|
| 489 | !---------------------------------------------------------------------------------- |
---|
| 490 | CALL agrif_declare_var_ice |
---|
[3680] | 491 | |
---|
[12377] | 492 | ! Controls |
---|
[7761] | 493 | |
---|
[12377] | 494 | ! clem: For some reason, nn_fsbc(child)/=1 does not work properly (signal can be largely degraded by the agrif zoom) |
---|
| 495 | ! the run must satisfy CFL=Uice/(dx/dt) < 0.6/nn_fsbc(child) |
---|
| 496 | ! therefore, if nn_fsbc(child)>1 one must reduce the time-step in proportion to nn_fsbc(child), which is not acceptable |
---|
| 497 | ! If a solution is found, the following stop could be removed because the rest of the code take nn_fsbc(child) into account |
---|
| 498 | IF( nn_fsbc > 1 ) CALL ctl_stop('nn_fsbc(child) must be set to 1 otherwise agrif and sea-ice may not work properly') |
---|
[7761] | 499 | |
---|
[12377] | 500 | ! stop if rhot * nn_fsbc(parent) /= N * nn_fsbc(child) with N being integer |
---|
| 501 | IF( MOD( Agrif_irhot() * Agrif_Parent(nn_fsbc), nn_fsbc ) /= 0 ) THEN |
---|
| 502 | CALL ctl_stop('rhot * nn_fsbc(parent) /= N * nn_fsbc(child), therefore nn_fsbc(child) should be set to 1 or nn_fsbc(parent)') |
---|
| 503 | ENDIF |
---|
| 504 | ! First Interpolations (using "after" ice subtime step => nbstep_ice=1) |
---|
| 505 | !---------------------------------------------------------------------- |
---|
| 506 | nbstep_ice = ( Agrif_irhot() * Agrif_Parent(nn_fsbc) / nn_fsbc ) ! clem: to have calledweight=1 in interp (otherwise the western border of the zoom is wrong) |
---|
| 507 | CALL agrif_interp_ice('U') ! interpolation of ice velocities |
---|
| 508 | CALL agrif_interp_ice('V') ! interpolation of ice velocities |
---|
| 509 | CALL agrif_interp_ice('T') ! interpolation of ice tracers |
---|
| 510 | nbstep_ice = 0 |
---|
| 511 | ! |
---|
| 512 | END SUBROUTINE Agrif_InitValues_cont_ice |
---|
[7646] | 513 | |
---|
[12377] | 514 | SUBROUTINE agrif_declare_var_ice |
---|
[10068] | 515 | !!---------------------------------------------------------------------- |
---|
| 516 | !! *** ROUTINE agrif_declare_var_ice *** |
---|
| 517 | !!---------------------------------------------------------------------- |
---|
[12377] | 518 | USE Agrif_Util |
---|
| 519 | USE ice |
---|
| 520 | USE par_oce, ONLY : nbghostcells |
---|
| 521 | ! |
---|
| 522 | IMPLICIT NONE |
---|
| 523 | ! |
---|
| 524 | INTEGER :: ind1, ind2, ind3 |
---|
[10068] | 525 | !!---------------------------------------------------------------------- |
---|
[12377] | 526 | ! |
---|
| 527 | ! 1. Declaration of the type of variable which have to be interpolated (parent=>child) |
---|
| 528 | ! agrif_declare_variable(position,1st point index,--,--,dimensions,name) |
---|
| 529 | ! ex.: position=> 1,1 = not-centered (in i and j) |
---|
| 530 | ! 2,2 = centered ( - ) |
---|
| 531 | ! index => 1,1 = one ghost line |
---|
| 532 | ! 2,2 = two ghost lines |
---|
| 533 | !------------------------------------------------------------------------------------- |
---|
| 534 | ind1 = nbghostcells |
---|
| 535 | ind2 = 1 + nbghostcells |
---|
| 536 | ind3 = 2 + nbghostcells |
---|
| 537 | CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpl*(8+nlay_s+nlay_i)/),tra_ice_id) |
---|
| 538 | CALL agrif_declare_variable((/1,2/) ,(/ind2,ind3/) ,(/'x','y'/) ,(/1,1/) ,(/nlci,nlcj/) ,u_ice_id ) |
---|
| 539 | CALL agrif_declare_variable((/2,1/) ,(/ind3,ind2/) ,(/'x','y'/) ,(/1,1/) ,(/nlci,nlcj/) ,v_ice_id ) |
---|
[7646] | 540 | |
---|
[12377] | 541 | ! 2. Set interpolations (normal & tangent to the grid cell for velocities) |
---|
| 542 | !----------------------------------- |
---|
| 543 | CALL Agrif_Set_bcinterp(tra_ice_id, interp = AGRIF_linear) |
---|
| 544 | CALL Agrif_Set_bcinterp(u_ice_id , interp1 = Agrif_linear,interp2 = AGRIF_ppm ) |
---|
| 545 | CALL Agrif_Set_bcinterp(v_ice_id , interp1 = AGRIF_ppm ,interp2 = Agrif_linear) |
---|
[7646] | 546 | |
---|
[12377] | 547 | ! 3. Set location of interpolations |
---|
| 548 | !---------------------------------- |
---|
| 549 | CALL Agrif_Set_bc(tra_ice_id,(/0,ind1/)) |
---|
| 550 | CALL Agrif_Set_bc(u_ice_id ,(/0,ind1/)) |
---|
| 551 | CALL Agrif_Set_bc(v_ice_id ,(/0,ind1/)) |
---|
[7646] | 552 | |
---|
[12377] | 553 | ! 4. Set update type in case 2 ways (child=>parent) (normal & tangent to the grid cell for velocities) |
---|
| 554 | !-------------------------------------------------- |
---|
[9134] | 555 | # if defined UPD_HIGH |
---|
[12377] | 556 | CALL Agrif_Set_Updatetype(tra_ice_id, update = Agrif_Update_Full_Weighting) |
---|
| 557 | CALL Agrif_Set_Updatetype(u_ice_id , update1 = Agrif_Update_Average , update2 = Agrif_Update_Full_Weighting) |
---|
| 558 | CALL Agrif_Set_Updatetype(v_ice_id , update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average ) |
---|
[9134] | 559 | #else |
---|
[12377] | 560 | CALL Agrif_Set_Updatetype(tra_ice_id, update = AGRIF_Update_Average) |
---|
| 561 | CALL Agrif_Set_Updatetype(u_ice_id , update1 = Agrif_Update_Copy , update2 = Agrif_Update_Average) |
---|
| 562 | CALL Agrif_Set_Updatetype(v_ice_id , update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy ) |
---|
[9134] | 563 | #endif |
---|
[7646] | 564 | |
---|
[12377] | 565 | END SUBROUTINE agrif_declare_var_ice |
---|
[7646] | 566 | #endif |
---|
| 567 | |
---|
| 568 | |
---|
[2715] | 569 | # if defined key_top |
---|
[12377] | 570 | SUBROUTINE Agrif_InitValues_cont_top |
---|
[10068] | 571 | !!---------------------------------------------------------------------- |
---|
| 572 | !! *** ROUTINE Agrif_InitValues_cont_top *** |
---|
[12377] | 573 | !!---------------------------------------------------------------------- |
---|
| 574 | USE Agrif_Util |
---|
| 575 | USE oce |
---|
| 576 | USE dom_oce |
---|
| 577 | USE nemogcm |
---|
| 578 | USE par_trc |
---|
| 579 | USE lib_mpp |
---|
| 580 | USE trc |
---|
| 581 | USE in_out_manager |
---|
| 582 | USE agrif_oce_sponge |
---|
| 583 | USE agrif_top_update |
---|
| 584 | USE agrif_top_interp |
---|
| 585 | USE agrif_top_sponge |
---|
[10068] | 586 | !! |
---|
[12377] | 587 | IMPLICIT NONE |
---|
| 588 | ! |
---|
| 589 | CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3 |
---|
| 590 | LOGICAL :: check_namelist |
---|
[10068] | 591 | !!---------------------------------------------------------------------- |
---|
[1300] | 592 | |
---|
[12377] | 593 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 594 | !--------------------------------------------------------------------- |
---|
| 595 | CALL agrif_declare_var_top |
---|
[1300] | 596 | |
---|
[12377] | 597 | ! 2. First interpolations of potentially non zero fields |
---|
| 598 | !------------------------------------------------------- |
---|
| 599 | Agrif_SpecialValue=0._wp |
---|
| 600 | Agrif_UseSpecialValue = .TRUE. |
---|
| 601 | CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn) |
---|
| 602 | Agrif_UseSpecialValue = .FALSE. |
---|
| 603 | CALL Agrif_Sponge |
---|
| 604 | tabspongedone_trn = .FALSE. |
---|
| 605 | CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge) |
---|
| 606 | ! reset ts(:,:,:,:,Krhs_a) to zero |
---|
| 607 | tr(:,:,:,:,Krhs_a) = 0._wp |
---|
[3680] | 608 | |
---|
[12377] | 609 | ! 3. Some controls |
---|
| 610 | !----------------- |
---|
| 611 | check_namelist = .TRUE. |
---|
[3680] | 612 | |
---|
[12377] | 613 | IF( check_namelist ) THEN |
---|
| 614 | ! Check time steps |
---|
[12489] | 615 | IF( NINT(Agrif_Rhot()) * NINT(rn_Dt) .NE. Agrif_Parent(rn_Dt) ) THEN |
---|
| 616 | WRITE(cl_check1,*) Agrif_Parent(rn_Dt) |
---|
| 617 | WRITE(cl_check2,*) rn_Dt |
---|
| 618 | WRITE(cl_check3,*) rn_Dt*Agrif_Rhot() |
---|
[7646] | 619 | CALL ctl_stop( 'incompatible time step between grids', & |
---|
[5656] | 620 | & 'parent grid value : '//cl_check1 , & |
---|
| 621 | & 'child grid value : '//cl_check2 , & |
---|
[7646] | 622 | & 'value on child grid should be changed to & |
---|
[5656] | 623 | & :'//cl_check3 ) |
---|
[3680] | 624 | ENDIF |
---|
| 625 | |
---|
| 626 | ! Check run length |
---|
| 627 | IF( Agrif_IRhot() * (Agrif_Parent(nitend)- & |
---|
[5656] | 628 | Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN |
---|
| 629 | WRITE(cl_check1,*) (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 |
---|
| 630 | WRITE(cl_check2,*) Agrif_Parent(nitend) *Agrif_IRhot() |
---|
| 631 | CALL ctl_warn( 'incompatible run length between grids' , & |
---|
| 632 | & ' nit000 on fine grid will be change to : '//cl_check1, & |
---|
| 633 | & ' nitend on fine grid will be change to : '//cl_check2 ) |
---|
| 634 | nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 |
---|
| 635 | nitend = Agrif_Parent(nitend) *Agrif_IRhot() |
---|
[3680] | 636 | ENDIF |
---|
| 637 | |
---|
| 638 | ENDIF |
---|
[5656] | 639 | ! |
---|
[12377] | 640 | END SUBROUTINE Agrif_InitValues_cont_top |
---|
[2715] | 641 | |
---|
| 642 | |
---|
[12377] | 643 | SUBROUTINE agrif_declare_var_top |
---|
[10068] | 644 | !!---------------------------------------------------------------------- |
---|
| 645 | !! *** ROUTINE agrif_declare_var_top *** |
---|
[12377] | 646 | !!---------------------------------------------------------------------- |
---|
| 647 | USE agrif_util |
---|
| 648 | USE agrif_oce |
---|
| 649 | USE dom_oce |
---|
| 650 | USE trc |
---|
[10068] | 651 | !! |
---|
[12377] | 652 | IMPLICIT NONE |
---|
| 653 | ! |
---|
| 654 | INTEGER :: ind1, ind2, ind3 |
---|
[10068] | 655 | !!---------------------------------------------------------------------- |
---|
[2715] | 656 | |
---|
[12377] | 657 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 658 | !--------------------------------------------------------------------- |
---|
| 659 | ind1 = nbghostcells |
---|
| 660 | ind2 = 1 + nbghostcells |
---|
| 661 | ind3 = 2 + nbghostcells |
---|
[9031] | 662 | # if defined key_vertical |
---|
[12377] | 663 | 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) |
---|
| 664 | 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) |
---|
[9031] | 665 | # else |
---|
[12377] | 666 | 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) |
---|
| 667 | 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) |
---|
[9031] | 668 | # endif |
---|
[2715] | 669 | |
---|
[12377] | 670 | ! 2. Type of interpolation |
---|
| 671 | !------------------------- |
---|
| 672 | CALL Agrif_Set_bcinterp(trn_id,interp=AGRIF_linear) |
---|
| 673 | CALL Agrif_Set_bcinterp(trn_sponge_id,interp=AGRIF_linear) |
---|
[3680] | 674 | |
---|
[12377] | 675 | ! 3. Location of interpolation |
---|
| 676 | !----------------------------- |
---|
| 677 | CALL Agrif_Set_bc(trn_id,(/0,ind1-1/)) |
---|
| 678 | CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/)) |
---|
[3680] | 679 | |
---|
[12377] | 680 | ! 4. Update type |
---|
| 681 | !--------------- |
---|
[9031] | 682 | # if defined UPD_HIGH |
---|
[12377] | 683 | CALL Agrif_Set_Updatetype(trn_id, update = Agrif_Update_Full_Weighting) |
---|
[9031] | 684 | #else |
---|
[12377] | 685 | CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average) |
---|
[9031] | 686 | #endif |
---|
[5656] | 687 | ! |
---|
[12377] | 688 | END SUBROUTINE agrif_declare_var_top |
---|
[2715] | 689 | # endif |
---|
[636] | 690 | |
---|
[12377] | 691 | SUBROUTINE Agrif_detect( kg, ksizex ) |
---|
[10068] | 692 | !!---------------------------------------------------------------------- |
---|
| 693 | !! *** ROUTINE Agrif_detect *** |
---|
| 694 | !!---------------------------------------------------------------------- |
---|
[12377] | 695 | INTEGER, DIMENSION(2) :: ksizex |
---|
| 696 | INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg |
---|
[10068] | 697 | !!---------------------------------------------------------------------- |
---|
[12377] | 698 | ! |
---|
| 699 | RETURN |
---|
| 700 | ! |
---|
| 701 | END SUBROUTINE Agrif_detect |
---|
[390] | 702 | |
---|
[12377] | 703 | SUBROUTINE agrif_nemo_init |
---|
[10068] | 704 | !!---------------------------------------------------------------------- |
---|
| 705 | !! *** ROUTINE agrif_init *** |
---|
| 706 | !!---------------------------------------------------------------------- |
---|
[12377] | 707 | USE agrif_oce |
---|
| 708 | USE agrif_ice |
---|
| 709 | USE in_out_manager |
---|
| 710 | USE lib_mpp |
---|
| 711 | !! |
---|
| 712 | IMPLICIT NONE |
---|
| 713 | ! |
---|
| 714 | INTEGER :: ios ! Local integer output status for namelist read |
---|
| 715 | NAMELIST/namagrif/ ln_agrif_2way, rn_sponge_tra, rn_sponge_dyn, rn_trelax_tra, rn_trelax_dyn, & |
---|
| 716 | & ln_spc_dyn, ln_chk_bathy |
---|
[10068] | 717 | !!-------------------------------------------------------------------------------------- |
---|
[12377] | 718 | ! |
---|
| 719 | READ ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901) |
---|
[11536] | 720 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namagrif in reference namelist' ) |
---|
[12377] | 721 | READ ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 ) |
---|
[11536] | 722 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namagrif in configuration namelist' ) |
---|
[12377] | 723 | IF(lwm) WRITE ( numond, namagrif ) |
---|
| 724 | ! |
---|
| 725 | IF(lwp) THEN ! control print |
---|
| 726 | WRITE(numout,*) |
---|
| 727 | WRITE(numout,*) 'agrif_nemo_init : AGRIF parameters' |
---|
| 728 | WRITE(numout,*) '~~~~~~~~~~~~~~~' |
---|
| 729 | WRITE(numout,*) ' Namelist namagrif : set AGRIF parameters' |
---|
| 730 | WRITE(numout,*) ' Two way nesting activated ln_agrif_2way = ', ln_agrif_2way |
---|
| 731 | WRITE(numout,*) ' sponge coefficient for tracers rn_sponge_tra = ', rn_sponge_tra, ' m^2/s' |
---|
| 732 | WRITE(numout,*) ' sponge coefficient for dynamics rn_sponge_tra = ', rn_sponge_dyn, ' m^2/s' |
---|
| 733 | WRITE(numout,*) ' time relaxation for tracers rn_trelax_tra = ', rn_trelax_tra, ' ad.' |
---|
| 734 | WRITE(numout,*) ' time relaxation for dynamics rn_trelax_dyn = ', rn_trelax_dyn, ' ad.' |
---|
| 735 | WRITE(numout,*) ' use special values for dynamics ln_spc_dyn = ', ln_spc_dyn |
---|
| 736 | WRITE(numout,*) ' check bathymetry ln_chk_bathy = ', ln_chk_bathy |
---|
| 737 | ENDIF |
---|
| 738 | ! |
---|
| 739 | ! |
---|
| 740 | IF( agrif_oce_alloc() > 0 ) CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed') |
---|
| 741 | ! |
---|
| 742 | END SUBROUTINE agrif_nemo_init |
---|
[3680] | 743 | |
---|
[1605] | 744 | # if defined key_mpp_mpi |
---|
| 745 | |
---|
[12377] | 746 | SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob ) |
---|
[10068] | 747 | !!---------------------------------------------------------------------- |
---|
| 748 | !! *** ROUTINE Agrif_InvLoc *** |
---|
| 749 | !!---------------------------------------------------------------------- |
---|
[12377] | 750 | USE dom_oce |
---|
| 751 | !! |
---|
| 752 | IMPLICIT NONE |
---|
| 753 | ! |
---|
| 754 | INTEGER :: indglob, indloc, nprocloc, i |
---|
[10068] | 755 | !!---------------------------------------------------------------------- |
---|
[12377] | 756 | ! |
---|
| 757 | SELECT CASE( i ) |
---|
| 758 | CASE(1) ; indglob = indloc + nimppt(nprocloc+1) - 1 |
---|
| 759 | CASE(2) ; indglob = indloc + njmppt(nprocloc+1) - 1 |
---|
| 760 | CASE DEFAULT |
---|
| 761 | indglob = indloc |
---|
| 762 | END SELECT |
---|
| 763 | ! |
---|
| 764 | END SUBROUTINE Agrif_InvLoc |
---|
[390] | 765 | |
---|
[12377] | 766 | SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax ) |
---|
[10068] | 767 | !!---------------------------------------------------------------------- |
---|
| 768 | !! *** ROUTINE Agrif_get_proc_info *** |
---|
| 769 | !!---------------------------------------------------------------------- |
---|
[12377] | 770 | USE par_oce |
---|
| 771 | !! |
---|
| 772 | IMPLICIT NONE |
---|
| 773 | ! |
---|
| 774 | INTEGER, INTENT(out) :: imin, imax |
---|
| 775 | INTEGER, INTENT(out) :: jmin, jmax |
---|
[10068] | 776 | !!---------------------------------------------------------------------- |
---|
[12377] | 777 | ! |
---|
| 778 | imin = nimppt(Agrif_Procrank+1) ! ????? |
---|
| 779 | jmin = njmppt(Agrif_Procrank+1) ! ????? |
---|
| 780 | imax = imin + jpi - 1 |
---|
| 781 | jmax = jmin + jpj - 1 |
---|
| 782 | ! |
---|
| 783 | END SUBROUTINE Agrif_get_proc_info |
---|
[5656] | 784 | |
---|
[12377] | 785 | SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost) |
---|
[10068] | 786 | !!---------------------------------------------------------------------- |
---|
| 787 | !! *** ROUTINE Agrif_estimate_parallel_cost *** |
---|
| 788 | !!---------------------------------------------------------------------- |
---|
[12377] | 789 | USE par_oce |
---|
| 790 | !! |
---|
| 791 | IMPLICIT NONE |
---|
| 792 | ! |
---|
| 793 | INTEGER, INTENT(in) :: imin, imax |
---|
| 794 | INTEGER, INTENT(in) :: jmin, jmax |
---|
| 795 | INTEGER, INTENT(in) :: nbprocs |
---|
| 796 | REAL(wp), INTENT(out) :: grid_cost |
---|
[10068] | 797 | !!---------------------------------------------------------------------- |
---|
[12377] | 798 | ! |
---|
| 799 | grid_cost = REAL(imax-imin+1,wp)*REAL(jmax-jmin+1,wp) / REAL(nbprocs,wp) |
---|
| 800 | ! |
---|
| 801 | END SUBROUTINE Agrif_estimate_parallel_cost |
---|
[5656] | 802 | |
---|
[1605] | 803 | # endif |
---|
| 804 | |
---|
[390] | 805 | #else |
---|
[12377] | 806 | SUBROUTINE Subcalledbyagrif |
---|
[10068] | 807 | !!---------------------------------------------------------------------- |
---|
| 808 | !! *** ROUTINE Subcalledbyagrif *** |
---|
| 809 | !!---------------------------------------------------------------------- |
---|
[12377] | 810 | WRITE(*,*) 'Impossible to be here' |
---|
| 811 | END SUBROUTINE Subcalledbyagrif |
---|
[390] | 812 | #endif |
---|