[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 | |
---|
[13286] | 13 | |
---|
[12377] | 14 | SUBROUTINE agrif_before_regridding |
---|
| 15 | END SUBROUTINE agrif_before_regridding |
---|
[3680] | 16 | |
---|
[13286] | 17 | |
---|
[12377] | 18 | SUBROUTINE Agrif_InitWorkspace |
---|
| 19 | END SUBROUTINE Agrif_InitWorkspace |
---|
[1156] | 20 | |
---|
[13286] | 21 | |
---|
[12377] | 22 | SUBROUTINE Agrif_InitValues |
---|
[10068] | 23 | !!---------------------------------------------------------------------- |
---|
| 24 | !! *** ROUTINE Agrif_InitValues *** |
---|
| 25 | !!---------------------------------------------------------------------- |
---|
[12377] | 26 | USE nemogcm |
---|
[10068] | 27 | !!---------------------------------------------------------------------- |
---|
[12377] | 28 | ! |
---|
| 29 | CALL nemo_init !* Initializations of each fine grid |
---|
| 30 | Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices |
---|
| 31 | ! |
---|
| 32 | ! !* Agrif initialization |
---|
| 33 | CALL Agrif_InitValues_cont |
---|
[2715] | 34 | # if defined key_top |
---|
[12377] | 35 | CALL Agrif_InitValues_cont_top |
---|
[7646] | 36 | # endif |
---|
[9570] | 37 | # if defined key_si3 |
---|
[12377] | 38 | CALL Agrif_InitValues_cont_ice |
---|
[7761] | 39 | # endif |
---|
[12377] | 40 | ! |
---|
| 41 | END SUBROUTINE Agrif_initvalues |
---|
[2031] | 42 | |
---|
[13286] | 43 | |
---|
| 44 | SUBROUTINE Agrif_Istate( Kbb, Kmm, Kaa ) |
---|
| 45 | !!---------------------------------------------------------------------- |
---|
| 46 | !! *** ROUTINE agrif_istate *** |
---|
| 47 | !!---------------------------------------------------------------------- |
---|
| 48 | USE domvvl |
---|
| 49 | USE domain |
---|
| 50 | USE par_oce |
---|
| 51 | USE agrif_oce |
---|
| 52 | USE agrif_oce_interp |
---|
| 53 | USE oce |
---|
| 54 | USE lib_mpp |
---|
| 55 | USE lbclnk |
---|
| 56 | ! |
---|
| 57 | IMPLICIT NONE |
---|
| 58 | ! |
---|
[13216] | 59 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa |
---|
| 60 | INTEGER :: jn |
---|
[13286] | 61 | !!---------------------------------------------------------------------- |
---|
[13216] | 62 | IF(lwp) WRITE(numout,*) ' ' |
---|
| 63 | IF(lwp) WRITE(numout,*) 'AGRIF: interp child initial state from parent' |
---|
| 64 | IF(lwp) WRITE(numout,*) ' ' |
---|
| 65 | |
---|
[13286] | 66 | l_ini_child = .TRUE. |
---|
| 67 | Agrif_SpecialValue = 0.0_wp |
---|
[13216] | 68 | Agrif_UseSpecialValue = .TRUE. |
---|
[13286] | 69 | uu(:,:,:,:) = 0.0_wp ; vv(:,:,:,:) = 0.0_wp ; ts(:,:,:,:,:) = 0.0_wp |
---|
[13216] | 70 | |
---|
[13286] | 71 | Krhs_a = Kbb ; Kmm_a = Kbb |
---|
[13216] | 72 | |
---|
| 73 | ! Brutal fix to pas 1x1 refinment. |
---|
| 74 | ! IF(Agrif_Irhox() == 1) THEN |
---|
| 75 | ! CALL Agrif_Init_Variable(tsini_id, procname=agrif_initts) |
---|
| 76 | ! ELSE |
---|
| 77 | CALL Agrif_Init_Variable(tsini_id, procname=interptsn) |
---|
| 78 | |
---|
| 79 | ! ENDIF |
---|
| 80 | ! just for VORTEX because Parent velocities can actually be exactly zero |
---|
| 81 | ! Agrif_UseSpecialValue = .FALSE. |
---|
| 82 | Agrif_UseSpecialValue = ln_spc_dyn |
---|
| 83 | use_sign_north = .TRUE. |
---|
| 84 | sign_north = -1. |
---|
| 85 | CALL Agrif_Init_Variable(uini_id , procname=interpun ) |
---|
| 86 | CALL Agrif_Init_Variable(vini_id , procname=interpvn ) |
---|
| 87 | use_sign_north = .FALSE. |
---|
| 88 | |
---|
[13286] | 89 | Agrif_UseSpecialValue = .FALSE. |
---|
| 90 | l_ini_child = .FALSE. |
---|
[13216] | 91 | |
---|
[13286] | 92 | Krhs_a = Kaa ; Kmm_a = Kmm |
---|
[13216] | 93 | |
---|
| 94 | DO jn = 1, jpts |
---|
| 95 | ts(:,:,:,jn,Kbb) = ts(:,:,:,jn,Kbb)*tmask(:,:,:) |
---|
| 96 | END DO |
---|
[13286] | 97 | uu(:,:,:,Kbb) = uu(:,:,:,Kbb) * umask(:,:,:) |
---|
| 98 | vv(:,:,:,Kbb) = vv(:,:,:,Kbb) * vmask(:,:,:) |
---|
[13216] | 99 | |
---|
| 100 | |
---|
[13286] | 101 | CALL lbc_lnk_multi( 'agrif_istate', uu(:,:,: ,Kbb), 'U', -1.0_wp , vv(:,:,:,Kbb), 'V', -1.0_wp ) |
---|
| 102 | CALL lbc_lnk( 'agrif_istate', ts(:,:,:,:,Kbb), 'T', 1.0_wp ) |
---|
[13216] | 103 | |
---|
[13286] | 104 | END SUBROUTINE Agrif_Istate |
---|
[13216] | 105 | |
---|
[13286] | 106 | |
---|
[13216] | 107 | SUBROUTINE agrif_declare_var_ini |
---|
[10068] | 108 | !!---------------------------------------------------------------------- |
---|
[13286] | 109 | !! *** ROUTINE agrif_declare_var_ini *** |
---|
[10068] | 110 | !!---------------------------------------------------------------------- |
---|
[13216] | 111 | USE agrif_util |
---|
| 112 | USE agrif_oce |
---|
| 113 | USE par_oce |
---|
| 114 | USE zdf_oce |
---|
| 115 | USE oce |
---|
| 116 | USE dom_oce |
---|
[12377] | 117 | ! |
---|
| 118 | IMPLICIT NONE |
---|
| 119 | ! |
---|
| 120 | INTEGER :: ind1, ind2, ind3 |
---|
[13286] | 121 | INTEGER :: its |
---|
[13216] | 122 | External :: nemo_mapping |
---|
[10068] | 123 | !!---------------------------------------------------------------------- |
---|
[3680] | 124 | |
---|
[13216] | 125 | ! In case of East-West periodicity, prevent AGRIF interpolation at east and west boundaries |
---|
| 126 | ! The procnames will not be called at these boundaries |
---|
| 127 | IF (jperio == 1) THEN |
---|
| 128 | CALL Agrif_Set_NearCommonBorderX(.TRUE.) |
---|
| 129 | CALL Agrif_Set_DistantCommonBorderX(.TRUE.) |
---|
| 130 | ENDIF |
---|
| 131 | |
---|
| 132 | IF ( .NOT. lk_south ) THEN |
---|
| 133 | CALL Agrif_Set_NearCommonBorderY(.TRUE.) |
---|
| 134 | ENDIF |
---|
| 135 | |
---|
[10068] | 136 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 137 | !--------------------------------------------------------------------- |
---|
[13286] | 138 | ind1 = nbghostcells |
---|
| 139 | ind2 = nn_hls + 2 + nbghostcells_x |
---|
| 140 | ind3 = nn_hls + 2 + nbghostcells_y_s |
---|
[3680] | 141 | |
---|
[13286] | 142 | CALL agrif_declare_variable((/2,2,0 /),(/ind2 ,ind3,0 /),(/'x','y','N' /),(/1,1,1 /),(/jpi,jpj,jpk /), e3t_id) |
---|
| 143 | CALL agrif_declare_variable((/2,2 /),(/ind2 ,ind3 /),(/'x','y' /),(/1,1 /),(/jpi,jpj /), mbkt_id) |
---|
| 144 | CALL agrif_declare_variable((/2,2 /),(/ind2 ,ind3 /),(/'x','y' /),(/1,1 /),(/jpi,jpj /), ht0_id) |
---|
[13216] | 145 | |
---|
[13286] | 146 | CALL agrif_declare_variable((/1,2 /),(/ind2-1,ind3 /),(/'x','y' /),(/1,1 /),(/jpi,jpj /), e1u_id) |
---|
| 147 | CALL agrif_declare_variable((/2,1 /),(/ind2 ,ind3-1 /),(/'x','y' /),(/1,1 /),(/jpi,jpj /), e2v_id) |
---|
[13216] | 148 | |
---|
| 149 | ! Initial or restart velues |
---|
[13286] | 150 | its = jpts+1 |
---|
| 151 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2 ,ind3 ,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,its/), tsini_id) |
---|
| 152 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3 ,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2 /), uini_id) |
---|
| 153 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2 ,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2 /), vini_id) |
---|
| 154 | CALL agrif_declare_variable((/2,2 /),(/ind2 ,ind3 /),(/'x','y' /),(/1,1 /),(/jpi,jpj /),sshini_id) |
---|
[13216] | 155 | ! |
---|
| 156 | |
---|
[10068] | 157 | ! 2. Type of interpolation |
---|
| 158 | !------------------------- |
---|
[13286] | 159 | CALL Agrif_Set_bcinterp( e3t_id,interp =AGRIF_constant) |
---|
[13216] | 160 | |
---|
[13286] | 161 | CALL Agrif_Set_bcinterp( mbkt_id,interp =AGRIF_constant) |
---|
| 162 | CALL Agrif_Set_interp ( mbkt_id,interp =AGRIF_constant) |
---|
| 163 | CALL Agrif_Set_bcinterp( ht0_id,interp =AGRIF_constant) |
---|
| 164 | CALL Agrif_Set_interp ( ht0_id,interp =AGRIF_constant) |
---|
[13216] | 165 | |
---|
[13286] | 166 | CALL Agrif_Set_bcinterp( e1u_id,interp1=Agrif_linear, interp2=AGRIF_ppm ) |
---|
| 167 | CALL Agrif_Set_bcinterp( e2v_id,interp1=AGRIF_ppm , interp2=Agrif_linear ) |
---|
[3680] | 168 | |
---|
[13216] | 169 | ! Initial fields |
---|
[13286] | 170 | CALL Agrif_Set_bcinterp( tsini_id,interp =AGRIF_linear ) |
---|
| 171 | CALL Agrif_Set_interp ( tsini_id,interp =AGRIF_linear ) |
---|
| 172 | CALL Agrif_Set_bcinterp( uini_id,interp =AGRIF_linear ) |
---|
| 173 | CALL Agrif_Set_interp ( uini_id,interp =AGRIF_linear ) |
---|
| 174 | CALL Agrif_Set_bcinterp( vini_id,interp =AGRIF_linear ) |
---|
| 175 | CALL Agrif_Set_interp ( vini_id,interp =AGRIF_linear ) |
---|
| 176 | CALL Agrif_Set_bcinterp(sshini_id,interp =AGRIF_linear ) |
---|
| 177 | CALL Agrif_Set_interp (sshini_id,interp =AGRIF_linear ) |
---|
[13216] | 178 | |
---|
| 179 | ! 3. Location of interpolation |
---|
[10068] | 180 | !----------------------------- |
---|
[13216] | 181 | ! CALL Agrif_Set_bc( e3t_id, (/-nn_sponge_len*Agrif_irhox(),ind1-1/) ) |
---|
| 182 | ! JC: check near the boundary only until matching in sponge has been sorted out: |
---|
[13286] | 183 | CALL Agrif_Set_bc( e3t_id, (/0,ind1-1/) ) |
---|
[13216] | 184 | |
---|
| 185 | ! extend the interpolation zone by 1 more point than necessary: |
---|
| 186 | ! RB check here |
---|
[13286] | 187 | CALL Agrif_Set_bc( mbkt_id, (/-nn_sponge_len*Agrif_irhox()-2,ind1/) ) |
---|
| 188 | CALL Agrif_Set_bc( ht0_id, (/-nn_sponge_len*Agrif_irhox()-2,ind1/) ) |
---|
[13216] | 189 | |
---|
[13286] | 190 | CALL Agrif_Set_bc( e1u_id, (/0,ind1-1/) ) |
---|
| 191 | CALL Agrif_Set_bc( e2v_id, (/0,ind1-1/) ) |
---|
[3680] | 192 | |
---|
[13286] | 193 | CALL Agrif_Set_bc( tsini_id, (/0,ind1-1/) ) ! if west, rhox=3 and nbghost=3: columns 2 to 4 |
---|
| 194 | CALL Agrif_Set_bc( uini_id, (/0,ind1-1/) ) |
---|
| 195 | CALL Agrif_Set_bc( vini_id, (/0,ind1-1/) ) |
---|
[13216] | 196 | CALL Agrif_Set_bc( sshini_id, (/0,ind1-1/) ) |
---|
| 197 | |
---|
[10068] | 198 | ! 4. Update type |
---|
| 199 | !--------------- |
---|
[9031] | 200 | # if defined UPD_HIGH |
---|
[13286] | 201 | CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average , update2=Agrif_Update_Full_Weighting) |
---|
| 202 | CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting, update2=Agrif_Update_Average ) |
---|
[9031] | 203 | #else |
---|
[13286] | 204 | CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy , update2=Agrif_Update_Average ) |
---|
| 205 | CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average , update2=Agrif_Update_Copy ) |
---|
[9031] | 206 | #endif |
---|
[13216] | 207 | |
---|
| 208 | ! CALL Agrif_Set_ExternalMapping(nemo_mapping) |
---|
| 209 | ! |
---|
| 210 | END SUBROUTINE agrif_declare_var_ini |
---|
[3680] | 211 | |
---|
| 212 | |
---|
[13216] | 213 | SUBROUTINE Agrif_Init_Domain( Kbb, Kmm, Kaa ) |
---|
[10068] | 214 | !!---------------------------------------------------------------------- |
---|
[13286] | 215 | !! *** ROUTINE Agrif_Init_Domain *** |
---|
[10068] | 216 | !!---------------------------------------------------------------------- |
---|
[13216] | 217 | USE agrif_oce_update |
---|
[12377] | 218 | USE agrif_oce_interp |
---|
| 219 | USE agrif_oce_sponge |
---|
[13216] | 220 | USE Agrif_Util |
---|
| 221 | USE oce |
---|
[12377] | 222 | USE dom_oce |
---|
[13216] | 223 | USE zdf_oce |
---|
| 224 | USE nemogcm |
---|
| 225 | USE agrif_oce |
---|
| 226 | ! |
---|
| 227 | USE lbclnk |
---|
[12377] | 228 | USE lib_mpp |
---|
[13216] | 229 | USE in_out_manager |
---|
[12377] | 230 | ! |
---|
| 231 | IMPLICIT NONE |
---|
| 232 | ! |
---|
[13216] | 233 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa |
---|
| 234 | ! |
---|
[12377] | 235 | LOGICAL :: check_namelist |
---|
| 236 | CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 |
---|
| 237 | REAL(wp), DIMENSION(jpi,jpj) :: zk ! workspace |
---|
[13216] | 238 | INTEGER :: ji, jj, jk |
---|
[10068] | 239 | !!---------------------------------------------------------------------- |
---|
[13216] | 240 | |
---|
| 241 | ! CALL Agrif_Declare_Var_ini |
---|
[390] | 242 | |
---|
[13216] | 243 | IF( agrif_oce_alloc() > 0 ) CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed') |
---|
[636] | 244 | |
---|
[12377] | 245 | ! Build consistent parent bathymetry and number of levels |
---|
| 246 | ! on the child grid |
---|
| 247 | Agrif_UseSpecialValue = .FALSE. |
---|
[13286] | 248 | ht0_parent( :,:) = 0._wp |
---|
[12377] | 249 | mbkt_parent(:,:) = 0 |
---|
| 250 | ! |
---|
[13216] | 251 | ! CALL Agrif_Bc_variable(ht0_id ,calledweight=1.,procname=interpht0 ) |
---|
| 252 | ! CALL Agrif_Bc_variable(mbkt_id,calledweight=1.,procname=interpmbkt) |
---|
| 253 | CALL Agrif_Init_Variable(ht0_id , procname=interpht0 ) |
---|
| 254 | CALL Agrif_Init_Variable(mbkt_id, procname=interpmbkt) |
---|
[12377] | 255 | ! |
---|
| 256 | ! Assume step wise change of bathymetry near interface |
---|
| 257 | ! TODO: Switch to linear interpolation of bathymetry in the s-coordinate case |
---|
| 258 | ! and no refinement |
---|
[13295] | 259 | DO_2D( 1, 0, 1, 0 ) |
---|
[13286] | 260 | mbku_parent(ji,jj) = MIN( mbkt_parent(ji+1,jj ), mbkt_parent(ji,jj) ) |
---|
| 261 | mbkv_parent(ji,jj) = MIN( mbkt_parent(ji ,jj+1), mbkt_parent(ji,jj) ) |
---|
[12377] | 262 | END_2D |
---|
| 263 | IF ( ln_sco.AND.Agrif_Parent(ln_sco) ) THEN |
---|
[13295] | 264 | DO_2D( 1, 0, 1, 0 ) |
---|
[12377] | 265 | hu0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji+1,jj) ) |
---|
| 266 | hv0_parent(ji,jj) = 0.5_wp * ( ht0_parent(ji,jj)+ht0_parent(ji,jj+1) ) |
---|
| 267 | END_2D |
---|
| 268 | ELSE |
---|
[13295] | 269 | DO_2D( 1, 0, 1, 0 ) |
---|
[13286] | 270 | hu0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji+1,jj) ) |
---|
| 271 | hv0_parent(ji,jj) = MIN( ht0_parent(ji,jj), ht0_parent(ji,jj+1) ) |
---|
[12377] | 272 | END_2D |
---|
| 273 | ENDIF |
---|
| 274 | ! |
---|
[13286] | 275 | CALL lbc_lnk_multi( 'Agrif_Init_Domain', hu0_parent, 'U', 1.0_wp, hv0_parent, 'V', 1.0_wp ) |
---|
[13295] | 276 | DO_2D( 0, 0, 0, 0 ) |
---|
[13286] | 277 | zk(ji,jj) = REAL( mbku_parent(ji,jj), wp ) |
---|
| 278 | END_2D |
---|
| 279 | CALL lbc_lnk( 'Agrif_InitValues_cont', zk, 'U', 1.0_wp ) |
---|
| 280 | mbku_parent(:,:) = MAX( NINT( zk(:,:) ), 1 ) |
---|
[13295] | 281 | DO_2D( 0, 0, 0, 0 ) |
---|
[13286] | 282 | zk(ji,jj) = REAL( mbkv_parent(ji,jj), wp ) |
---|
| 283 | END_2D |
---|
| 284 | CALL lbc_lnk( 'Agrif_InitValues_cont', zk, 'V', 1.0_wp ) |
---|
[12377] | 285 | mbkv_parent(:,:) = MAX( NINT( zk(:,:) ), 1 ) |
---|
[628] | 286 | |
---|
[13216] | 287 | IF ( ln_init_chfrpar ) THEN |
---|
| 288 | CALL Agrif_Init_Variable(sshini_id, procname=agrif_initssh) |
---|
| 289 | CALL lbc_lnk( 'Agrif_Init_Domain', ssh(:,:,Kbb), 'T', 1. ) |
---|
| 290 | DO jk = 1, jpk |
---|
| 291 | e3t(:,:,jk,Kbb) = e3t_0(:,:,jk) * ( ht_0(:,:) + ssh(:,:,Kbb) ) & |
---|
| 292 | & / ( ht_0(:,:) + 1._wp - ssmask(:,:) ) * tmask(:,:,jk) & |
---|
| 293 | & + e3t_0(:,:,jk) * ( 1._wp - tmask(:,:,jk) ) |
---|
| 294 | END DO |
---|
| 295 | ENDIF |
---|
| 296 | |
---|
| 297 | ! check if masks and bathymetries match |
---|
| 298 | IF(ln_chk_bathy) THEN |
---|
| 299 | Agrif_UseSpecialValue = .FALSE. |
---|
| 300 | ! |
---|
| 301 | IF(lwp) WRITE(numout,*) ' ' |
---|
| 302 | IF(lwp) WRITE(numout,*) 'AGRIF: Check Bathymetry and masks near bdys. Level: ', Agrif_Level() |
---|
| 303 | ! |
---|
| 304 | kindic_agr = 0 |
---|
| 305 | IF( .NOT. l_vremap ) THEN |
---|
| 306 | ! |
---|
| 307 | ! check if tmask and vertical scale factors agree with parent in sponge area: |
---|
| 308 | CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t) |
---|
| 309 | ! |
---|
| 310 | ELSE |
---|
| 311 | ! |
---|
| 312 | ! In case of vertical interpolation, check only that total depths agree between child and parent: |
---|
| 313 | DO ji = 1, jpi |
---|
| 314 | DO jj = 1, jpj |
---|
| 315 | IF ((mbkt_parent(ji,jj)/=0).AND.(ABS(ht0_parent(ji,jj)-ht_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1 |
---|
| 316 | IF ((mbku_parent(ji,jj)/=0).AND.(ABS(hu0_parent(ji,jj)-hu_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1 |
---|
| 317 | IF ((mbkv_parent(ji,jj)/=0).AND.(ABS(hv0_parent(ji,jj)-hv_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1 |
---|
| 318 | END DO |
---|
| 319 | END DO |
---|
| 320 | |
---|
| 321 | CALL mpp_sum( 'agrif_user', kindic_agr ) |
---|
| 322 | IF( kindic_agr /= 0 ) THEN |
---|
| 323 | CALL ctl_stop('==> Child Bathymetry is NOT correct near boundaries.') |
---|
| 324 | ELSE |
---|
| 325 | IF(lwp) WRITE(numout,*) '==> Child Bathymetry is ok near boundaries.' |
---|
| 326 | IF(lwp) WRITE(numout,*) ' ' |
---|
| 327 | ENDIF |
---|
| 328 | ENDIF |
---|
| 329 | ENDIF |
---|
| 330 | |
---|
| 331 | IF( l_vremap ) THEN |
---|
| 332 | ! Additional constrain that should be removed someday: |
---|
| 333 | IF ( Agrif_Parent(jpk).GT.jpk ) THEN |
---|
| 334 | CALL ctl_stop( ' With l_vremap, child grids must have jpk greater or equal to the parent value' ) |
---|
| 335 | ENDIF |
---|
| 336 | ENDIF |
---|
| 337 | ! |
---|
| 338 | END SUBROUTINE Agrif_Init_Domain |
---|
| 339 | |
---|
| 340 | |
---|
| 341 | SUBROUTINE Agrif_InitValues_cont |
---|
[13286] | 342 | !!---------------------------------------------------------------------- |
---|
| 343 | !! *** ROUTINE Agrif_InitValues_cont *** |
---|
| 344 | !! |
---|
| 345 | !! ** Purpose :: Declaration of variables to be interpolated |
---|
| 346 | !!---------------------------------------------------------------------- |
---|
[13216] | 347 | USE agrif_oce_update |
---|
| 348 | USE agrif_oce_interp |
---|
| 349 | USE agrif_oce_sponge |
---|
| 350 | USE Agrif_Util |
---|
| 351 | USE oce |
---|
| 352 | USE dom_oce |
---|
| 353 | USE zdf_oce |
---|
| 354 | USE nemogcm |
---|
| 355 | USE agrif_oce |
---|
| 356 | ! |
---|
| 357 | USE lbclnk |
---|
| 358 | USE lib_mpp |
---|
| 359 | USE in_out_manager |
---|
| 360 | ! |
---|
| 361 | IMPLICIT NONE |
---|
| 362 | ! |
---|
| 363 | LOGICAL :: check_namelist |
---|
| 364 | CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 |
---|
| 365 | REAL(wp), DIMENSION(jpi,jpj) :: zk ! workspace |
---|
| 366 | INTEGER :: ji, jj |
---|
| 367 | |
---|
| 368 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 369 | !--------------------------------------------------------------------- |
---|
| 370 | CALL agrif_declare_var |
---|
| 371 | |
---|
| 372 | ! 2. First interpolations of potentially non zero fields |
---|
| 373 | !------------------------------------------------------- |
---|
[12377] | 374 | Agrif_SpecialValue = 0._wp |
---|
| 375 | Agrif_UseSpecialValue = .TRUE. |
---|
[13286] | 376 | CALL Agrif_Bc_variable( tsn_id,calledweight=1.,procname=interptsn) |
---|
[12377] | 377 | CALL Agrif_Sponge |
---|
| 378 | tabspongedone_tsn = .FALSE. |
---|
| 379 | CALL Agrif_Bc_variable(tsn_sponge_id,calledweight=1.,procname=interptsn_sponge) |
---|
[13216] | 380 | ! reset tsa to zero |
---|
[12377] | 381 | ts(:,:,:,:,Krhs_a) = 0._wp |
---|
| 382 | |
---|
[5930] | 383 | Agrif_UseSpecialValue = ln_spc_dyn |
---|
[13216] | 384 | use_sign_north = .TRUE. |
---|
| 385 | sign_north = -1. |
---|
[12377] | 386 | CALL Agrif_Bc_variable(un_interp_id,calledweight=1.,procname=interpun) |
---|
| 387 | CALL Agrif_Bc_variable(vn_interp_id,calledweight=1.,procname=interpvn) |
---|
| 388 | tabspongedone_u = .FALSE. |
---|
| 389 | tabspongedone_v = .FALSE. |
---|
| 390 | CALL Agrif_Bc_variable(un_sponge_id,calledweight=1.,procname=interpun_sponge) |
---|
| 391 | tabspongedone_u = .FALSE. |
---|
| 392 | tabspongedone_v = .FALSE. |
---|
| 393 | CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge) |
---|
[13216] | 394 | use_sign_north = .FALSE. |
---|
[12377] | 395 | uu(:,:,:,Krhs_a) = 0._wp |
---|
| 396 | vv(:,:,:,Krhs_a) = 0._wp |
---|
[5656] | 397 | |
---|
[12377] | 398 | Agrif_UseSpecialValue = .TRUE. |
---|
| 399 | CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn ) |
---|
| 400 | hbdy(:,:) = 0._wp |
---|
| 401 | ssh(:,:,Krhs_a) = 0._wp |
---|
[5656] | 402 | |
---|
[12377] | 403 | IF ( ln_dynspg_ts ) THEN |
---|
| 404 | Agrif_UseSpecialValue = ln_spc_dyn |
---|
[13216] | 405 | use_sign_north = .TRUE. |
---|
| 406 | sign_north = -1. |
---|
[13286] | 407 | CALL Agrif_Bc_variable( unb_id,calledweight=1.,procname=interpunb ) |
---|
| 408 | CALL Agrif_Bc_variable( vnb_id,calledweight=1.,procname=interpvnb ) |
---|
[12377] | 409 | CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b) |
---|
| 410 | CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b) |
---|
[13216] | 411 | use_sign_north = .FALSE. |
---|
[12377] | 412 | ubdy(:,:) = 0._wp |
---|
| 413 | vbdy(:,:) = 0._wp |
---|
| 414 | ENDIF |
---|
[13216] | 415 | Agrif_UseSpecialValue = .FALSE. |
---|
[3680] | 416 | |
---|
[12377] | 417 | !----------------- |
---|
| 418 | check_namelist = .TRUE. |
---|
[3680] | 419 | |
---|
[12377] | 420 | IF( check_namelist ) THEN |
---|
| 421 | ! Check free surface scheme |
---|
| 422 | IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.& |
---|
| 423 | & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN |
---|
| 424 | WRITE(cl_check1,*) Agrif_Parent( ln_dynspg_ts ) |
---|
| 425 | WRITE(cl_check2,*) ln_dynspg_ts |
---|
| 426 | WRITE(cl_check3,*) Agrif_Parent( ln_dynspg_exp ) |
---|
| 427 | WRITE(cl_check4,*) ln_dynspg_exp |
---|
| 428 | CALL ctl_stop( 'Incompatible free surface scheme between grids' , & |
---|
| 429 | & 'parent grid ln_dynspg_ts :'//cl_check1 , & |
---|
| 430 | & 'child grid ln_dynspg_ts :'//cl_check2 , & |
---|
| 431 | & 'parent grid ln_dynspg_exp :'//cl_check3 , & |
---|
| 432 | & 'child grid ln_dynspg_exp :'//cl_check4 , & |
---|
| 433 | & 'those logicals should be identical' ) |
---|
| 434 | STOP |
---|
| 435 | ENDIF |
---|
| 436 | |
---|
| 437 | ! Check if identical linear free surface option |
---|
| 438 | IF ( ( Agrif_Parent(ln_linssh ).AND.(.NOT.ln_linssh )).OR.& |
---|
| 439 | & ( (.NOT.Agrif_Parent(ln_linssh)).AND.ln_linssh ) ) THEN |
---|
| 440 | WRITE(cl_check1,*) Agrif_Parent(ln_linssh ) |
---|
| 441 | WRITE(cl_check2,*) ln_linssh |
---|
| 442 | CALL ctl_stop( 'Incompatible linearized fs option between grids', & |
---|
| 443 | & 'parent grid ln_linssh :'//cl_check1 , & |
---|
| 444 | & 'child grid ln_linssh :'//cl_check2 , & |
---|
| 445 | & 'those logicals should be identical' ) |
---|
| 446 | STOP |
---|
| 447 | ENDIF |
---|
[9031] | 448 | ENDIF |
---|
| 449 | |
---|
[12377] | 450 | END SUBROUTINE Agrif_InitValues_cont |
---|
| 451 | |
---|
| 452 | SUBROUTINE agrif_declare_var |
---|
[10068] | 453 | !!---------------------------------------------------------------------- |
---|
[12377] | 454 | !! *** ROUTINE agrif_declare_var *** |
---|
[10068] | 455 | !!---------------------------------------------------------------------- |
---|
[12377] | 456 | USE agrif_util |
---|
| 457 | USE agrif_oce |
---|
| 458 | USE par_oce |
---|
| 459 | USE zdf_oce |
---|
| 460 | USE oce |
---|
| 461 | ! |
---|
| 462 | IMPLICIT NONE |
---|
| 463 | ! |
---|
| 464 | INTEGER :: ind1, ind2, ind3 |
---|
[10068] | 465 | !!---------------------------------------------------------------------- |
---|
[2715] | 466 | |
---|
[12377] | 467 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 468 | !--------------------------------------------------------------------- |
---|
[13286] | 469 | ind1 = nbghostcells |
---|
| 470 | ind2 = nn_hls + 2 + nbghostcells_x |
---|
| 471 | ind3 = nn_hls + 2 + nbghostcells_y_s |
---|
[9031] | 472 | # if defined key_vertical |
---|
[13286] | 473 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsn_id) |
---|
| 474 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsn_sponge_id) |
---|
| 475 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_interp_id) |
---|
| 476 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_interp_id) |
---|
| 477 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_update_id) |
---|
| 478 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_update_id) |
---|
| 479 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_sponge_id) |
---|
| 480 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_sponge_id) |
---|
[9031] | 481 | # else |
---|
[13286] | 482 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts/),tsn_id) |
---|
| 483 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts/),tsn_sponge_id) |
---|
| 484 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_interp_id) |
---|
| 485 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_interp_id) |
---|
| 486 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_update_id) |
---|
| 487 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_update_id) |
---|
| 488 | CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_sponge_id) |
---|
| 489 | CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_sponge_id) |
---|
[9031] | 490 | # endif |
---|
[13286] | 491 | CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),unb_id) |
---|
| 492 | CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vnb_id) |
---|
| 493 | CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ub2b_interp_id) |
---|
| 494 | CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vb2b_interp_id) |
---|
| 495 | CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ub2b_update_id) |
---|
| 496 | CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vb2b_update_id) |
---|
[2715] | 497 | |
---|
[13286] | 498 | ! CALL agrif_declare_variable((/2,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),glamt_id) |
---|
| 499 | ! CALL agrif_declare_variable((/2,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),gphit_id) |
---|
| 500 | CALL agrif_declare_variable((/2,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),sshn_id) |
---|
[2715] | 501 | |
---|
[5656] | 502 | |
---|
[13216] | 503 | IF( ln_zdftke.OR.ln_zdfgls ) THEN ! logical not known at this point |
---|
[13286] | 504 | ! CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id) |
---|
| 505 | ! CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id) |
---|
[9031] | 506 | # if defined key_vertical |
---|
[13286] | 507 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),avm_id) |
---|
[9031] | 508 | # else |
---|
[13286] | 509 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),avm_id) |
---|
[9031] | 510 | # endif |
---|
[12377] | 511 | ENDIF |
---|
[13216] | 512 | |
---|
[12377] | 513 | ! 2. Type of interpolation |
---|
| 514 | !------------------------- |
---|
[13286] | 515 | CALL Agrif_Set_bcinterp( tsn_id,interp =AGRIF_linear) |
---|
| 516 | CALL Agrif_Set_bcinterp( un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm ) |
---|
| 517 | CALL Agrif_Set_bcinterp( vn_interp_id,interp1=AGRIF_ppm ,interp2=Agrif_linear) |
---|
[2715] | 518 | |
---|
[13286] | 519 | CALL Agrif_Set_bcinterp( tsn_sponge_id,interp =AGRIF_linear) |
---|
| 520 | CALL Agrif_Set_bcinterp( un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm ) |
---|
| 521 | CALL Agrif_Set_bcinterp( vn_sponge_id,interp1=AGRIF_ppm ,interp2=Agrif_linear) |
---|
[2715] | 522 | |
---|
[13286] | 523 | CALL Agrif_Set_bcinterp( sshn_id,interp =AGRIF_linear) |
---|
| 524 | CALL Agrif_Set_bcinterp( unb_id,interp1=Agrif_linear,interp2=AGRIF_ppm ) |
---|
| 525 | CALL Agrif_Set_bcinterp( vnb_id,interp1=AGRIF_ppm ,interp2=Agrif_linear) |
---|
| 526 | CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm ) |
---|
| 527 | CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_ppm ,interp2=Agrif_linear) |
---|
[12377] | 528 | ! |
---|
| 529 | ! > Divergence conserving alternative: |
---|
| 530 | ! CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_constant) |
---|
| 531 | ! CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_constant) |
---|
| 532 | ! CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_constant,interp2=Agrif_linear) |
---|
| 533 | ! CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_constant) |
---|
| 534 | ! CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_constant,interp2=Agrif_linear) |
---|
| 535 | !< |
---|
[4326] | 536 | |
---|
[13216] | 537 | IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear ) |
---|
| 538 | |
---|
[5656] | 539 | |
---|
[13286] | 540 | ! CALL Agrif_Set_bcinterp(gphit_id,interp=AGRIF_constant) |
---|
| 541 | ! CALL Agrif_Set_bcinterp(glamt_id,interp=AGRIF_constant) |
---|
| 542 | |
---|
| 543 | ! 3. Location of interpolation |
---|
[12377] | 544 | !----------------------------- |
---|
| 545 | CALL Agrif_Set_bc( tsn_id, (/0,ind1-1/) ) ! if west, rhox=3 and nbghost=3: columns 2 to 4 |
---|
| 546 | CALL Agrif_Set_bc( un_interp_id, (/0,ind1-1/) ) |
---|
| 547 | CALL Agrif_Set_bc( vn_interp_id, (/0,ind1-1/) ) |
---|
[2715] | 548 | |
---|
[12377] | 549 | CALL Agrif_Set_bc( tsn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) ) ! if west, rhox=3, nn_sponge_len=2 |
---|
| 550 | CALL Agrif_Set_bc( un_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) ) ! and nbghost=3: |
---|
| 551 | CALL Agrif_Set_bc( vn_sponge_id, (/-nn_sponge_len*Agrif_irhox()-1,0/) ) ! columns 4 to 11 |
---|
[4326] | 552 | |
---|
[12377] | 553 | CALL Agrif_Set_bc( sshn_id, (/0,ind1-1/) ) |
---|
| 554 | CALL Agrif_Set_bc( unb_id, (/0,ind1-1/) ) |
---|
| 555 | CALL Agrif_Set_bc( vnb_id, (/0,ind1-1/) ) |
---|
| 556 | CALL Agrif_Set_bc( ub2b_interp_id, (/0,ind1-1/) ) |
---|
| 557 | CALL Agrif_Set_bc( vb2b_interp_id, (/0,ind1-1/) ) |
---|
[2715] | 558 | |
---|
[13216] | 559 | IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bc( avm_id, (/0,ind1/) ) |
---|
[13286] | 560 | !!$ CALL Agrif_Set_bc(glamt_id, (/0,ind1-1/) ) |
---|
| 561 | !!$ CALL Agrif_Set_bc(gphit_id, (/0,ind1-1/) ) |
---|
[2715] | 562 | |
---|
[12377] | 563 | ! 4. Update type |
---|
| 564 | !--------------- |
---|
[2715] | 565 | |
---|
[9031] | 566 | # if defined UPD_HIGH |
---|
[13286] | 567 | CALL Agrif_Set_Updatetype( tsn_id,update = Agrif_Update_Full_Weighting) |
---|
| 568 | CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Average , update2 = Agrif_Update_Full_Weighting) |
---|
| 569 | CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average ) |
---|
[9031] | 570 | |
---|
[13286] | 571 | CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Average , update2 = Agrif_Update_Full_Weighting) |
---|
| 572 | CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average ) |
---|
| 573 | CALL Agrif_Set_Updatetype( sshn_id,update = Agrif_Update_Full_Weighting) |
---|
| 574 | CALL Agrif_Set_Updatetype( e3t_id,update = Agrif_Update_Full_Weighting) |
---|
[9031] | 575 | |
---|
[13216] | 576 | ! IF( ln_zdftke.OR.ln_zdfgls ) THEN |
---|
[12377] | 577 | ! CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting) |
---|
| 578 | ! CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting) |
---|
| 579 | ! CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting) |
---|
[13216] | 580 | ! ENDIF |
---|
[9031] | 581 | |
---|
| 582 | #else |
---|
[13286] | 583 | CALL Agrif_Set_Updatetype( tsn_id, update = AGRIF_Update_Average) |
---|
| 584 | CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy , update2 = Agrif_Update_Average) |
---|
| 585 | CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy ) |
---|
[3680] | 586 | |
---|
[13286] | 587 | CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy , update2 = Agrif_Update_Average) |
---|
| 588 | CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy ) |
---|
| 589 | CALL Agrif_Set_Updatetype( sshn_id,update = AGRIF_Update_Average) |
---|
| 590 | CALL Agrif_Set_Updatetype( e3t_id,update = AGRIF_Update_Average) |
---|
[5656] | 591 | |
---|
[13216] | 592 | ! IF( ln_zdftke.OR.ln_zdfgls ) THEN |
---|
[12377] | 593 | ! CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average) |
---|
| 594 | ! CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average) |
---|
| 595 | ! CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average) |
---|
[13216] | 596 | ! ENDIF |
---|
[5656] | 597 | |
---|
[9031] | 598 | #endif |
---|
[12377] | 599 | ! |
---|
| 600 | END SUBROUTINE agrif_declare_var |
---|
[3680] | 601 | |
---|
[9570] | 602 | #if defined key_si3 |
---|
[13286] | 603 | SUBROUTINE Agrif_InitValues_cont_ice |
---|
| 604 | !!---------------------------------------------------------------------- |
---|
| 605 | !! *** ROUTINE Agrif_InitValues_cont_ice *** |
---|
| 606 | !!---------------------------------------------------------------------- |
---|
[12377] | 607 | USE Agrif_Util |
---|
| 608 | USE sbc_oce, ONLY : nn_fsbc ! clem: necessary otherwise Agrif_Parent(nn_fsbc) = nn_fsbc |
---|
| 609 | USE ice |
---|
| 610 | USE agrif_ice |
---|
| 611 | USE in_out_manager |
---|
| 612 | USE agrif_ice_interp |
---|
| 613 | USE lib_mpp |
---|
[13286] | 614 | ! |
---|
| 615 | IMPLICIT NONE |
---|
| 616 | ! |
---|
[10068] | 617 | !!---------------------------------------------------------------------- |
---|
[12377] | 618 | ! Controls |
---|
[7761] | 619 | |
---|
[12377] | 620 | ! clem: For some reason, nn_fsbc(child)/=1 does not work properly (signal can be largely degraded by the agrif zoom) |
---|
| 621 | ! the run must satisfy CFL=Uice/(dx/dt) < 0.6/nn_fsbc(child) |
---|
| 622 | ! therefore, if nn_fsbc(child)>1 one must reduce the time-step in proportion to nn_fsbc(child), which is not acceptable |
---|
[13216] | 623 | ! If a solution is found, the following stop could be removed because the rest of the code take nn_fsbc(child) into account |
---|
[12377] | 624 | 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] | 625 | |
---|
[12377] | 626 | ! stop if rhot * nn_fsbc(parent) /= N * nn_fsbc(child) with N being integer |
---|
| 627 | IF( MOD( Agrif_irhot() * Agrif_Parent(nn_fsbc), nn_fsbc ) /= 0 ) THEN |
---|
| 628 | CALL ctl_stop('rhot * nn_fsbc(parent) /= N * nn_fsbc(child), therefore nn_fsbc(child) should be set to 1 or nn_fsbc(parent)') |
---|
| 629 | ENDIF |
---|
| 630 | ! First Interpolations (using "after" ice subtime step => nbstep_ice=1) |
---|
| 631 | !---------------------------------------------------------------------- |
---|
| 632 | 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) |
---|
| 633 | CALL agrif_interp_ice('U') ! interpolation of ice velocities |
---|
| 634 | CALL agrif_interp_ice('V') ! interpolation of ice velocities |
---|
| 635 | CALL agrif_interp_ice('T') ! interpolation of ice tracers |
---|
| 636 | nbstep_ice = 0 |
---|
| 637 | ! |
---|
| 638 | END SUBROUTINE Agrif_InitValues_cont_ice |
---|
[7646] | 639 | |
---|
[13286] | 640 | |
---|
[12377] | 641 | SUBROUTINE agrif_declare_var_ice |
---|
[10068] | 642 | !!---------------------------------------------------------------------- |
---|
| 643 | !! *** ROUTINE agrif_declare_var_ice *** |
---|
| 644 | !!---------------------------------------------------------------------- |
---|
[12377] | 645 | USE Agrif_Util |
---|
| 646 | USE ice |
---|
[13216] | 647 | USE par_oce, ONLY : nbghostcells, nbghostcells_x, nbghostcells_y_s |
---|
[12377] | 648 | ! |
---|
| 649 | IMPLICIT NONE |
---|
| 650 | ! |
---|
| 651 | INTEGER :: ind1, ind2, ind3 |
---|
[13286] | 652 | INTEGER :: ipl |
---|
| 653 | !!---------------------------------------------------------------------- |
---|
[12377] | 654 | ! |
---|
| 655 | ! 1. Declaration of the type of variable which have to be interpolated (parent=>child) |
---|
| 656 | ! agrif_declare_variable(position,1st point index,--,--,dimensions,name) |
---|
| 657 | ! ex.: position=> 1,1 = not-centered (in i and j) |
---|
| 658 | ! 2,2 = centered ( - ) |
---|
| 659 | ! index => 1,1 = one ghost line |
---|
| 660 | ! 2,2 = two ghost lines |
---|
| 661 | !------------------------------------------------------------------------------------- |
---|
[13286] | 662 | ind1 = nbghostcells |
---|
| 663 | ind2 = nn_hls + 2 + nbghostcells_x |
---|
| 664 | ind3 = nn_hls + 2 + nbghostcells_y_s |
---|
| 665 | ipl = jpl*(8+nlay_s+nlay_i) |
---|
| 666 | CALL agrif_declare_variable((/2,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,ipl/),tra_ice_id) |
---|
| 667 | CALL agrif_declare_variable((/1,2/) ,(/ind2-1,ind3/),(/'x','y' /),(/1,1 /),(/jpi,jpj /), u_ice_id) |
---|
| 668 | CALL agrif_declare_variable((/2,1/) ,(/ind2,ind3-1/),(/'x','y' /),(/1,1 /),(/jpi,jpj /), v_ice_id) |
---|
[13216] | 669 | |
---|
[13286] | 670 | CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,ipl/),tra_iceini_id) |
---|
| 671 | CALL agrif_declare_variable((/1,2/) ,(/ind2-1,ind3/),(/'x','y' /),(/1,1 /),(/jpi,jpj /), u_iceini_id) |
---|
| 672 | CALL agrif_declare_variable((/2,1/) ,(/ind2,ind3-1/),(/'x','y' /),(/1,1 /),(/jpi,jpj /), v_iceini_id) |
---|
[7646] | 673 | |
---|
[12377] | 674 | ! 2. Set interpolations (normal & tangent to the grid cell for velocities) |
---|
| 675 | !----------------------------------- |
---|
| 676 | CALL Agrif_Set_bcinterp(tra_ice_id, interp = AGRIF_linear) |
---|
| 677 | CALL Agrif_Set_bcinterp(u_ice_id , interp1 = Agrif_linear,interp2 = AGRIF_ppm ) |
---|
| 678 | CALL Agrif_Set_bcinterp(v_ice_id , interp1 = AGRIF_ppm ,interp2 = Agrif_linear) |
---|
[7646] | 679 | |
---|
[13216] | 680 | CALL Agrif_Set_bcinterp(tra_iceini_id, interp = AGRIF_linear) |
---|
| 681 | CALL Agrif_Set_interp (tra_iceini_id, interp = AGRIF_linear) |
---|
| 682 | CALL Agrif_Set_bcinterp(u_iceini_id , interp = AGRIF_linear ) |
---|
| 683 | CALL Agrif_Set_interp (u_iceini_id , interp = AGRIF_linear ) |
---|
| 684 | CALL Agrif_Set_bcinterp(v_iceini_id , interp = AGRIF_linear) |
---|
| 685 | CALL Agrif_Set_interp (v_iceini_id , interp = AGRIF_linear) |
---|
| 686 | |
---|
[12377] | 687 | ! 3. Set location of interpolations |
---|
| 688 | !---------------------------------- |
---|
| 689 | CALL Agrif_Set_bc(tra_ice_id,(/0,ind1/)) |
---|
| 690 | CALL Agrif_Set_bc(u_ice_id ,(/0,ind1/)) |
---|
| 691 | CALL Agrif_Set_bc(v_ice_id ,(/0,ind1/)) |
---|
[7646] | 692 | |
---|
[13216] | 693 | CALL Agrif_Set_bc(tra_iceini_id,(/0,ind1/)) |
---|
| 694 | CALL Agrif_Set_bc(u_iceini_id ,(/0,ind1/)) |
---|
| 695 | CALL Agrif_Set_bc(v_iceini_id ,(/0,ind1/)) |
---|
| 696 | |
---|
[12377] | 697 | ! 4. Set update type in case 2 ways (child=>parent) (normal & tangent to the grid cell for velocities) |
---|
| 698 | !-------------------------------------------------- |
---|
[9134] | 699 | # if defined UPD_HIGH |
---|
[12377] | 700 | CALL Agrif_Set_Updatetype(tra_ice_id, update = Agrif_Update_Full_Weighting) |
---|
| 701 | CALL Agrif_Set_Updatetype(u_ice_id , update1 = Agrif_Update_Average , update2 = Agrif_Update_Full_Weighting) |
---|
| 702 | CALL Agrif_Set_Updatetype(v_ice_id , update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average ) |
---|
[13216] | 703 | # else |
---|
[12377] | 704 | CALL Agrif_Set_Updatetype(tra_ice_id, update = AGRIF_Update_Average) |
---|
| 705 | CALL Agrif_Set_Updatetype(u_ice_id , update1 = Agrif_Update_Copy , update2 = Agrif_Update_Average) |
---|
| 706 | CALL Agrif_Set_Updatetype(v_ice_id , update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy ) |
---|
[13216] | 707 | # endif |
---|
[7646] | 708 | |
---|
[12377] | 709 | END SUBROUTINE agrif_declare_var_ice |
---|
[7646] | 710 | #endif |
---|
| 711 | |
---|
| 712 | |
---|
[2715] | 713 | # if defined key_top |
---|
[12377] | 714 | SUBROUTINE Agrif_InitValues_cont_top |
---|
[10068] | 715 | !!---------------------------------------------------------------------- |
---|
| 716 | !! *** ROUTINE Agrif_InitValues_cont_top *** |
---|
[12377] | 717 | !!---------------------------------------------------------------------- |
---|
| 718 | USE Agrif_Util |
---|
| 719 | USE oce |
---|
| 720 | USE dom_oce |
---|
| 721 | USE nemogcm |
---|
| 722 | USE par_trc |
---|
| 723 | USE lib_mpp |
---|
| 724 | USE trc |
---|
| 725 | USE in_out_manager |
---|
| 726 | USE agrif_oce_sponge |
---|
| 727 | USE agrif_top_update |
---|
| 728 | USE agrif_top_interp |
---|
| 729 | USE agrif_top_sponge |
---|
[13286] | 730 | ! |
---|
| 731 | IMPLICIT NONE |
---|
| 732 | ! |
---|
| 733 | CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3 |
---|
| 734 | LOGICAL :: check_namelist |
---|
[10068] | 735 | !!---------------------------------------------------------------------- |
---|
[1300] | 736 | |
---|
[13286] | 737 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 738 | !--------------------------------------------------------------------- |
---|
| 739 | CALL agrif_declare_var_top |
---|
[1300] | 740 | |
---|
[13286] | 741 | ! 2. First interpolations of potentially non zero fields |
---|
| 742 | !------------------------------------------------------- |
---|
| 743 | Agrif_SpecialValue=0._wp |
---|
| 744 | Agrif_UseSpecialValue = .TRUE. |
---|
| 745 | CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn) |
---|
| 746 | Agrif_UseSpecialValue = .FALSE. |
---|
| 747 | CALL Agrif_Sponge |
---|
| 748 | tabspongedone_trn = .FALSE. |
---|
| 749 | CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge) |
---|
| 750 | ! reset tsa to zero |
---|
| 751 | tra(:,:,:,:) = 0._wp |
---|
[3680] | 752 | |
---|
[13286] | 753 | ! 3. Some controls |
---|
| 754 | !----------------- |
---|
| 755 | check_namelist = .TRUE. |
---|
[3680] | 756 | |
---|
[13286] | 757 | IF( check_namelist ) THEN |
---|
| 758 | ! Check time steps |
---|
| 759 | IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN |
---|
| 760 | WRITE(cl_check1,*) Agrif_Parent(rdt) |
---|
| 761 | WRITE(cl_check2,*) rdt |
---|
| 762 | WRITE(cl_check3,*) rdt*Agrif_Rhot() |
---|
| 763 | CALL ctl_stop( 'incompatible time step between grids', & |
---|
[5656] | 764 | & 'parent grid value : '//cl_check1 , & |
---|
| 765 | & 'child grid value : '//cl_check2 , & |
---|
[7646] | 766 | & 'value on child grid should be changed to & |
---|
[5656] | 767 | & :'//cl_check3 ) |
---|
[13286] | 768 | ENDIF |
---|
[3680] | 769 | |
---|
[13286] | 770 | ! Check run length |
---|
| 771 | IF( Agrif_IRhot() * (Agrif_Parent(nitend)- & |
---|
[5656] | 772 | Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN |
---|
[13286] | 773 | WRITE(cl_check1,*) (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 |
---|
| 774 | WRITE(cl_check2,*) Agrif_Parent(nitend) *Agrif_IRhot() |
---|
| 775 | CALL ctl_warn( 'incompatible run length between grids' , & |
---|
[5656] | 776 | & ' nit000 on fine grid will be change to : '//cl_check1, & |
---|
| 777 | & ' nitend on fine grid will be change to : '//cl_check2 ) |
---|
[13286] | 778 | nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1 |
---|
| 779 | nitend = Agrif_Parent(nitend) *Agrif_IRhot() |
---|
| 780 | ENDIF |
---|
[3680] | 781 | ENDIF |
---|
[13286] | 782 | ! |
---|
[12377] | 783 | END SUBROUTINE Agrif_InitValues_cont_top |
---|
[2715] | 784 | |
---|
| 785 | |
---|
[12377] | 786 | SUBROUTINE agrif_declare_var_top |
---|
[10068] | 787 | !!---------------------------------------------------------------------- |
---|
| 788 | !! *** ROUTINE agrif_declare_var_top *** |
---|
[12377] | 789 | !!---------------------------------------------------------------------- |
---|
| 790 | USE agrif_util |
---|
| 791 | USE agrif_oce |
---|
| 792 | USE dom_oce |
---|
| 793 | USE trc |
---|
[10068] | 794 | !! |
---|
[12377] | 795 | IMPLICIT NONE |
---|
| 796 | ! |
---|
| 797 | INTEGER :: ind1, ind2, ind3 |
---|
[10068] | 798 | !!---------------------------------------------------------------------- |
---|
[13216] | 799 | !RB_CMEMS : declare here init for top |
---|
[12377] | 800 | ! 1. Declaration of the type of variable which have to be interpolated |
---|
| 801 | !--------------------------------------------------------------------- |
---|
[13286] | 802 | ind1 = nbghostcells |
---|
| 803 | ind2 = nn_hls + 2 + nbghostcells_x |
---|
| 804 | ind3 = nn_hls + 2 + nbghostcells_y_s |
---|
[9031] | 805 | # if defined key_vertical |
---|
[13286] | 806 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra+1/),trn_id) |
---|
| 807 | CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra+1/),trn_sponge_id) |
---|
[9031] | 808 | # else |
---|
[13216] | 809 | ! LAURENT: STRANGE why (3,3) here ? |
---|
[13286] | 810 | CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_id) |
---|
| 811 | CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_sponge_id) |
---|
[9031] | 812 | # endif |
---|
[2715] | 813 | |
---|
[12377] | 814 | ! 2. Type of interpolation |
---|
| 815 | !------------------------- |
---|
| 816 | CALL Agrif_Set_bcinterp(trn_id,interp=AGRIF_linear) |
---|
| 817 | CALL Agrif_Set_bcinterp(trn_sponge_id,interp=AGRIF_linear) |
---|
[3680] | 818 | |
---|
[12377] | 819 | ! 3. Location of interpolation |
---|
| 820 | !----------------------------- |
---|
| 821 | CALL Agrif_Set_bc(trn_id,(/0,ind1-1/)) |
---|
| 822 | CALL Agrif_Set_bc(trn_sponge_id,(/-nn_sponge_len*Agrif_irhox()-1,0/)) |
---|
[3680] | 823 | |
---|
[12377] | 824 | ! 4. Update type |
---|
| 825 | !--------------- |
---|
[9031] | 826 | # if defined UPD_HIGH |
---|
[12377] | 827 | CALL Agrif_Set_Updatetype(trn_id, update = Agrif_Update_Full_Weighting) |
---|
[9031] | 828 | #else |
---|
[12377] | 829 | CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average) |
---|
[9031] | 830 | #endif |
---|
[5656] | 831 | ! |
---|
[12377] | 832 | END SUBROUTINE agrif_declare_var_top |
---|
[2715] | 833 | # endif |
---|
[13286] | 834 | |
---|
[636] | 835 | |
---|
[12377] | 836 | SUBROUTINE Agrif_detect( kg, ksizex ) |
---|
[10068] | 837 | !!---------------------------------------------------------------------- |
---|
| 838 | !! *** ROUTINE Agrif_detect *** |
---|
| 839 | !!---------------------------------------------------------------------- |
---|
[12377] | 840 | INTEGER, DIMENSION(2) :: ksizex |
---|
| 841 | INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg |
---|
[10068] | 842 | !!---------------------------------------------------------------------- |
---|
[12377] | 843 | ! |
---|
| 844 | RETURN |
---|
| 845 | ! |
---|
| 846 | END SUBROUTINE Agrif_detect |
---|
[390] | 847 | |
---|
[13286] | 848 | |
---|
[12377] | 849 | SUBROUTINE agrif_nemo_init |
---|
[10068] | 850 | !!---------------------------------------------------------------------- |
---|
| 851 | !! *** ROUTINE agrif_init *** |
---|
| 852 | !!---------------------------------------------------------------------- |
---|
[13286] | 853 | USE agrif_oce |
---|
| 854 | USE agrif_ice |
---|
| 855 | USE dom_oce |
---|
| 856 | USE in_out_manager |
---|
| 857 | USE lib_mpp |
---|
| 858 | ! |
---|
[12377] | 859 | IMPLICIT NONE |
---|
| 860 | ! |
---|
| 861 | INTEGER :: ios ! Local integer output status for namelist read |
---|
[13216] | 862 | NAMELIST/namagrif/ ln_agrif_2way, ln_init_chfrpar, rn_sponge_tra, rn_sponge_dyn, rn_trelax_tra, rn_trelax_dyn, & |
---|
[12377] | 863 | & ln_spc_dyn, ln_chk_bathy |
---|
[10068] | 864 | !!-------------------------------------------------------------------------------------- |
---|
[12377] | 865 | ! |
---|
| 866 | READ ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901) |
---|
[11536] | 867 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namagrif in reference namelist' ) |
---|
[12377] | 868 | READ ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 ) |
---|
[11536] | 869 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namagrif in configuration namelist' ) |
---|
[12377] | 870 | IF(lwm) WRITE ( numond, namagrif ) |
---|
| 871 | ! |
---|
| 872 | IF(lwp) THEN ! control print |
---|
| 873 | WRITE(numout,*) |
---|
| 874 | WRITE(numout,*) 'agrif_nemo_init : AGRIF parameters' |
---|
| 875 | WRITE(numout,*) '~~~~~~~~~~~~~~~' |
---|
| 876 | WRITE(numout,*) ' Namelist namagrif : set AGRIF parameters' |
---|
| 877 | WRITE(numout,*) ' Two way nesting activated ln_agrif_2way = ', ln_agrif_2way |
---|
[13216] | 878 | WRITE(numout,*) ' child initial state from parent ln_init_chfrpar = ', ln_init_chfrpar |
---|
| 879 | WRITE(numout,*) ' ad. sponge coeft for tracers rn_sponge_tra = ', rn_sponge_tra |
---|
| 880 | WRITE(numout,*) ' ad. sponge coeft for dynamics rn_sponge_tra = ', rn_sponge_dyn |
---|
| 881 | WRITE(numout,*) ' ad. time relaxation for tracers rn_trelax_tra = ', rn_trelax_tra |
---|
| 882 | WRITE(numout,*) ' ad. time relaxation for dynamics rn_trelax_dyn = ', rn_trelax_dyn |
---|
[12377] | 883 | WRITE(numout,*) ' use special values for dynamics ln_spc_dyn = ', ln_spc_dyn |
---|
| 884 | WRITE(numout,*) ' check bathymetry ln_chk_bathy = ', ln_chk_bathy |
---|
| 885 | ENDIF |
---|
[13216] | 886 | |
---|
| 887 | lk_west = .NOT. ( Agrif_Ix() == 1 ) |
---|
| 888 | lk_east = .NOT. ( Agrif_Ix() + nbcellsx/AGRIF_Irhox() == Agrif_Parent(jpiglo) -1 ) |
---|
| 889 | lk_south = .NOT. ( Agrif_Iy() == 1 ) |
---|
| 890 | lk_north = .NOT. ( Agrif_Iy() + nbcellsy/AGRIF_Irhoy() == Agrif_Parent(jpjglo) -1 ) |
---|
| 891 | |
---|
[12377] | 892 | ! |
---|
[13216] | 893 | ! Set the number of ghost cells according to periodicity |
---|
[13286] | 894 | nbghostcells_x = nbghostcells |
---|
[13216] | 895 | nbghostcells_y_s = nbghostcells |
---|
| 896 | nbghostcells_y_n = nbghostcells |
---|
[12377] | 897 | ! |
---|
[13286] | 898 | IF( jperio == 1 ) nbghostcells_x = 0 |
---|
| 899 | IF( .NOT. lk_south ) nbghostcells_y_s = 0 |
---|
[13216] | 900 | ! Some checks |
---|
[13286] | 901 | IF( jpiglo /= nbcellsx + 2 + 2*nn_hls + nbghostcells_x + nbghostcells_x ) CALL ctl_stop( 'STOP', & |
---|
| 902 | & 'agrif_nemo_init: Agrif children requires jpiglo == nbcellsx + 2 + 2*nn_hls + 2*nbghostcells_x' ) |
---|
| 903 | IF( jpjglo /= nbcellsy + 2 + 2*nn_hls + nbghostcells_y_s + nbghostcells_y_n ) CALL ctl_stop( 'STOP', & |
---|
| 904 | & 'agrif_nemo_init: Agrif children requires jpjglo == nbcellsy + 2 + 2*nn_hls + nbghostcells_y_s + nbghostcells_y_n' ) |
---|
[13216] | 905 | IF( ln_use_jattr ) CALL ctl_stop( 'STOP', 'agrif_nemo_init:Agrif children requires ln_use_jattr = .false. ' ) |
---|
[12377] | 906 | ! |
---|
| 907 | END SUBROUTINE agrif_nemo_init |
---|
[3680] | 908 | |
---|
[13286] | 909 | |
---|
[1605] | 910 | # if defined key_mpp_mpi |
---|
[12377] | 911 | SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob ) |
---|
[10068] | 912 | !!---------------------------------------------------------------------- |
---|
| 913 | !! *** ROUTINE Agrif_InvLoc *** |
---|
| 914 | !!---------------------------------------------------------------------- |
---|
[12377] | 915 | USE dom_oce |
---|
| 916 | !! |
---|
| 917 | IMPLICIT NONE |
---|
| 918 | ! |
---|
| 919 | INTEGER :: indglob, indloc, nprocloc, i |
---|
[10068] | 920 | !!---------------------------------------------------------------------- |
---|
[12377] | 921 | ! |
---|
| 922 | SELECT CASE( i ) |
---|
[13286] | 923 | CASE(1) ; indglob = mig(indloc) |
---|
| 924 | CASE(2) ; indglob = mjg(indloc) |
---|
| 925 | CASE DEFAULT ; indglob = indloc |
---|
[12377] | 926 | END SELECT |
---|
| 927 | ! |
---|
| 928 | END SUBROUTINE Agrif_InvLoc |
---|
[390] | 929 | |
---|
[13286] | 930 | |
---|
[12377] | 931 | SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax ) |
---|
[10068] | 932 | !!---------------------------------------------------------------------- |
---|
| 933 | !! *** ROUTINE Agrif_get_proc_info *** |
---|
| 934 | !!---------------------------------------------------------------------- |
---|
[12377] | 935 | USE par_oce |
---|
| 936 | !! |
---|
| 937 | IMPLICIT NONE |
---|
| 938 | ! |
---|
| 939 | INTEGER, INTENT(out) :: imin, imax |
---|
| 940 | INTEGER, INTENT(out) :: jmin, jmax |
---|
[10068] | 941 | !!---------------------------------------------------------------------- |
---|
[12377] | 942 | ! |
---|
[13286] | 943 | imin = mig( 1 ) |
---|
| 944 | jmin = mjg( 1 ) |
---|
| 945 | imax = mig(jpi) |
---|
| 946 | jmax = mjg(jpj) |
---|
[12377] | 947 | ! |
---|
| 948 | END SUBROUTINE Agrif_get_proc_info |
---|
[5656] | 949 | |
---|
[13286] | 950 | |
---|
[12377] | 951 | SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost) |
---|
[10068] | 952 | !!---------------------------------------------------------------------- |
---|
| 953 | !! *** ROUTINE Agrif_estimate_parallel_cost *** |
---|
| 954 | !!---------------------------------------------------------------------- |
---|
[12377] | 955 | USE par_oce |
---|
| 956 | !! |
---|
| 957 | IMPLICIT NONE |
---|
| 958 | ! |
---|
| 959 | INTEGER, INTENT(in) :: imin, imax |
---|
| 960 | INTEGER, INTENT(in) :: jmin, jmax |
---|
| 961 | INTEGER, INTENT(in) :: nbprocs |
---|
| 962 | REAL(wp), INTENT(out) :: grid_cost |
---|
[10068] | 963 | !!---------------------------------------------------------------------- |
---|
[12377] | 964 | ! |
---|
| 965 | grid_cost = REAL(imax-imin+1,wp)*REAL(jmax-jmin+1,wp) / REAL(nbprocs,wp) |
---|
| 966 | ! |
---|
| 967 | END SUBROUTINE Agrif_estimate_parallel_cost |
---|
[5656] | 968 | |
---|
[1605] | 969 | # endif |
---|
| 970 | |
---|
[13216] | 971 | SUBROUTINE nemo_mapping(ndim,ptx,pty,bounds,bounds_chunks,correction_required,nb_chunks) |
---|
| 972 | !!---------------------------------------------------------------------- |
---|
| 973 | !! *** ROUTINE Nemo_mapping *** |
---|
| 974 | !!---------------------------------------------------------------------- |
---|
| 975 | USE dom_oce |
---|
| 976 | !! |
---|
| 977 | IMPLICIT NONE |
---|
| 978 | ! |
---|
| 979 | INTEGER :: ndim |
---|
| 980 | INTEGER :: ptx, pty |
---|
| 981 | INTEGER, DIMENSION(ndim,2,2) :: bounds |
---|
| 982 | INTEGER, DIMENSION(:,:,:,:), ALLOCATABLE :: bounds_chunks |
---|
| 983 | LOGICAL, DIMENSION(:), ALLOCATABLE :: correction_required |
---|
| 984 | INTEGER :: nb_chunks |
---|
| 985 | ! |
---|
| 986 | INTEGER :: i |
---|
| 987 | |
---|
| 988 | IF (agrif_debug_interp) THEN |
---|
| 989 | DO i=1,ndim |
---|
| 990 | WRITE(*,*) 'direction = ',i,bounds(i,1,2),bounds(i,2,2) |
---|
| 991 | ENDDO |
---|
| 992 | ENDIF |
---|
| 993 | |
---|
| 994 | IF( bounds(2,2,2) > jpjglo) THEN |
---|
| 995 | IF( bounds(2,1,2) <=jpjglo) THEN |
---|
| 996 | nb_chunks = 2 |
---|
| 997 | ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2)) |
---|
| 998 | ALLOCATE(correction_required(nb_chunks)) |
---|
| 999 | DO i = 1,nb_chunks |
---|
| 1000 | bounds_chunks(i,:,:,:) = bounds |
---|
| 1001 | END DO |
---|
| 1002 | |
---|
| 1003 | ! FIRST CHUNCK (for j<=jpjglo) |
---|
| 1004 | |
---|
| 1005 | ! Original indices |
---|
| 1006 | bounds_chunks(1,1,1,1) = bounds(1,1,2) |
---|
| 1007 | bounds_chunks(1,1,2,1) = bounds(1,2,2) |
---|
| 1008 | bounds_chunks(1,2,1,1) = bounds(2,1,2) |
---|
| 1009 | bounds_chunks(1,2,2,1) = jpjglo |
---|
| 1010 | |
---|
| 1011 | bounds_chunks(1,1,1,2) = bounds(1,1,2) |
---|
| 1012 | bounds_chunks(1,1,2,2) = bounds(1,2,2) |
---|
| 1013 | bounds_chunks(1,2,1,2) = bounds(2,1,2) |
---|
| 1014 | bounds_chunks(1,2,2,2) = jpjglo |
---|
| 1015 | |
---|
| 1016 | ! Correction required or not |
---|
| 1017 | correction_required(1)=.FALSE. |
---|
| 1018 | |
---|
| 1019 | ! SECOND CHUNCK (for j>jpjglo) |
---|
| 1020 | |
---|
| 1021 | ! Original indices |
---|
| 1022 | bounds_chunks(2,1,1,1) = bounds(1,1,2) |
---|
| 1023 | bounds_chunks(2,1,2,1) = bounds(1,2,2) |
---|
| 1024 | bounds_chunks(2,2,1,1) = jpjglo-2 |
---|
| 1025 | bounds_chunks(2,2,2,1) = bounds(2,2,2) |
---|
| 1026 | |
---|
| 1027 | ! Where to find them |
---|
| 1028 | ! We use the relation TAB(ji,jj)=TAB(jpiglo-ji+2,jpjglo-2-(jj-jpjglo)) |
---|
| 1029 | |
---|
| 1030 | IF( ptx == 2) THEN ! T, V points |
---|
| 1031 | bounds_chunks(2,1,1,2) = jpiglo-bounds(1,2,2)+2 |
---|
| 1032 | bounds_chunks(2,1,2,2) = jpiglo-bounds(1,1,2)+2 |
---|
| 1033 | ELSE ! U, F points |
---|
| 1034 | bounds_chunks(2,1,1,2) = jpiglo-bounds(1,2,2)+1 |
---|
| 1035 | bounds_chunks(2,1,2,2) = jpiglo-bounds(1,1,2)+1 |
---|
| 1036 | ENDIF |
---|
| 1037 | |
---|
| 1038 | IF( pty == 2) THEN ! T, U points |
---|
| 1039 | bounds_chunks(2,2,1,2) = jpjglo-2-(bounds(2,2,2) -jpjglo) |
---|
| 1040 | bounds_chunks(2,2,2,2) = jpjglo-2-(jpjglo-2 -jpjglo) |
---|
| 1041 | ELSE ! V, F points |
---|
| 1042 | bounds_chunks(2,2,1,2) = jpjglo-3-(bounds(2,2,2) -jpjglo) |
---|
| 1043 | bounds_chunks(2,2,2,2) = jpjglo-3-(jpjglo-2 -jpjglo) |
---|
| 1044 | ENDIF |
---|
| 1045 | ! Correction required or not |
---|
| 1046 | correction_required(2)=.TRUE. |
---|
| 1047 | |
---|
| 1048 | ELSE |
---|
| 1049 | nb_chunks = 1 |
---|
| 1050 | ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2)) |
---|
| 1051 | ALLOCATE(correction_required(nb_chunks)) |
---|
| 1052 | DO i=1,nb_chunks |
---|
| 1053 | bounds_chunks(i,:,:,:) = bounds |
---|
| 1054 | END DO |
---|
| 1055 | |
---|
| 1056 | bounds_chunks(1,1,1,1) = bounds(1,1,2) |
---|
| 1057 | bounds_chunks(1,1,2,1) = bounds(1,2,2) |
---|
| 1058 | bounds_chunks(1,2,1,1) = bounds(2,1,2) |
---|
| 1059 | bounds_chunks(1,2,2,1) = bounds(2,2,2) |
---|
| 1060 | |
---|
| 1061 | bounds_chunks(1,1,1,2) = jpiglo-bounds(1,2,2)+2 |
---|
| 1062 | bounds_chunks(1,1,2,2) = jpiglo-bounds(1,1,2)+2 |
---|
| 1063 | |
---|
| 1064 | bounds_chunks(1,2,1,2) = jpjglo-2-(bounds(2,2,2)-jpjglo) |
---|
| 1065 | bounds_chunks(1,2,2,2) = jpjglo-2-(bounds(2,1,2)-jpjglo) |
---|
| 1066 | |
---|
| 1067 | IF( ptx == 2) THEN ! T, V points |
---|
| 1068 | bounds_chunks(1,1,1,2) = jpiglo-bounds(1,2,2)+2 |
---|
| 1069 | bounds_chunks(1,1,2,2) = jpiglo-bounds(1,1,2)+2 |
---|
| 1070 | ELSE ! U, F points |
---|
| 1071 | bounds_chunks(1,1,1,2) = jpiglo-bounds(1,2,2)+1 |
---|
| 1072 | bounds_chunks(1,1,2,2) = jpiglo-bounds(1,1,2)+1 |
---|
| 1073 | ENDIF |
---|
| 1074 | |
---|
| 1075 | IF (pty == 2) THEN ! T, U points |
---|
| 1076 | bounds_chunks(1,2,1,2) = jpjglo-2-(bounds(2,2,2) -jpjglo) |
---|
| 1077 | bounds_chunks(1,2,2,2) = jpjglo-2-(bounds(2,1,2) -jpjglo) |
---|
| 1078 | ELSE ! V, F points |
---|
| 1079 | bounds_chunks(1,2,1,2) = jpjglo-3-(bounds(2,2,2) -jpjglo) |
---|
| 1080 | bounds_chunks(1,2,2,2) = jpjglo-3-(bounds(2,1,2) -jpjglo) |
---|
| 1081 | ENDIF |
---|
| 1082 | |
---|
| 1083 | correction_required(1)=.TRUE. |
---|
| 1084 | ENDIF |
---|
| 1085 | |
---|
| 1086 | ELSE IF (bounds(1,1,2) < 1) THEN |
---|
| 1087 | IF (bounds(1,2,2) > 0) THEN |
---|
| 1088 | nb_chunks = 2 |
---|
| 1089 | ALLOCATE(correction_required(nb_chunks)) |
---|
| 1090 | correction_required=.FALSE. |
---|
| 1091 | ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2)) |
---|
| 1092 | DO i=1,nb_chunks |
---|
| 1093 | bounds_chunks(i,:,:,:) = bounds |
---|
| 1094 | END DO |
---|
| 1095 | |
---|
| 1096 | bounds_chunks(1,1,1,2) = bounds(1,1,2)+jpiglo-2 |
---|
| 1097 | bounds_chunks(1,1,2,2) = 1+jpiglo-2 |
---|
| 1098 | |
---|
| 1099 | bounds_chunks(1,1,1,1) = bounds(1,1,2) |
---|
| 1100 | bounds_chunks(1,1,2,1) = 1 |
---|
| 1101 | |
---|
| 1102 | bounds_chunks(2,1,1,2) = 2 |
---|
| 1103 | bounds_chunks(2,1,2,2) = bounds(1,2,2) |
---|
| 1104 | |
---|
| 1105 | bounds_chunks(2,1,1,1) = 2 |
---|
| 1106 | bounds_chunks(2,1,2,1) = bounds(1,2,2) |
---|
| 1107 | |
---|
| 1108 | ELSE |
---|
| 1109 | nb_chunks = 1 |
---|
| 1110 | ALLOCATE(correction_required(nb_chunks)) |
---|
| 1111 | correction_required=.FALSE. |
---|
| 1112 | ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2)) |
---|
| 1113 | DO i=1,nb_chunks |
---|
| 1114 | bounds_chunks(i,:,:,:) = bounds |
---|
| 1115 | END DO |
---|
| 1116 | bounds_chunks(1,1,1,2) = bounds(1,1,2)+jpiglo-2 |
---|
| 1117 | bounds_chunks(1,1,2,2) = bounds(1,2,2)+jpiglo-2 |
---|
| 1118 | |
---|
| 1119 | bounds_chunks(1,1,1,1) = bounds(1,1,2) |
---|
| 1120 | bounds_chunks(1,1,2,1) = bounds(1,2,2) |
---|
| 1121 | ENDIF |
---|
| 1122 | ELSE |
---|
| 1123 | nb_chunks=1 |
---|
| 1124 | ALLOCATE(correction_required(nb_chunks)) |
---|
| 1125 | correction_required=.FALSE. |
---|
| 1126 | ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2)) |
---|
| 1127 | DO i=1,nb_chunks |
---|
| 1128 | bounds_chunks(i,:,:,:) = bounds |
---|
| 1129 | END DO |
---|
| 1130 | bounds_chunks(1,1,1,2) = bounds(1,1,2) |
---|
| 1131 | bounds_chunks(1,1,2,2) = bounds(1,2,2) |
---|
| 1132 | bounds_chunks(1,2,1,2) = bounds(2,1,2) |
---|
| 1133 | bounds_chunks(1,2,2,2) = bounds(2,2,2) |
---|
| 1134 | |
---|
| 1135 | bounds_chunks(1,1,1,1) = bounds(1,1,2) |
---|
| 1136 | bounds_chunks(1,1,2,1) = bounds(1,2,2) |
---|
| 1137 | bounds_chunks(1,2,1,1) = bounds(2,1,2) |
---|
| 1138 | bounds_chunks(1,2,2,1) = bounds(2,2,2) |
---|
| 1139 | ENDIF |
---|
| 1140 | |
---|
| 1141 | END SUBROUTINE nemo_mapping |
---|
| 1142 | |
---|
| 1143 | FUNCTION agrif_external_switch_index(ptx,pty,i1,isens) |
---|
| 1144 | |
---|
[13286] | 1145 | USE dom_oce |
---|
| 1146 | ! |
---|
| 1147 | IMPLICIT NONE |
---|
[13216] | 1148 | |
---|
[13286] | 1149 | INTEGER :: ptx, pty, i1, isens |
---|
| 1150 | INTEGER :: agrif_external_switch_index |
---|
| 1151 | !!---------------------------------------------------------------------- |
---|
[13216] | 1152 | |
---|
[13286] | 1153 | IF( isens == 1 ) THEN |
---|
| 1154 | IF( ptx == 2 ) THEN ! T, V points |
---|
| 1155 | agrif_external_switch_index = jpiglo-i1+2 |
---|
| 1156 | ELSE ! U, F points |
---|
| 1157 | agrif_external_switch_index = jpiglo-i1+1 |
---|
| 1158 | ENDIF |
---|
| 1159 | ELSE IF( isens ==2 ) THEN |
---|
| 1160 | IF ( pty == 2 ) THEN ! T, U points |
---|
| 1161 | agrif_external_switch_index = jpjglo-2-(i1 -jpjglo) |
---|
| 1162 | ELSE ! V, F points |
---|
| 1163 | agrif_external_switch_index = jpjglo-3-(i1 -jpjglo) |
---|
| 1164 | ENDIF |
---|
[13216] | 1165 | ENDIF |
---|
| 1166 | |
---|
| 1167 | END FUNCTION agrif_external_switch_index |
---|
| 1168 | |
---|
| 1169 | SUBROUTINE Correct_field(tab2d,i1,i2,j1,j2) |
---|
| 1170 | !!---------------------------------------------------------------------- |
---|
| 1171 | !! *** ROUTINE Correct_field *** |
---|
| 1172 | !!---------------------------------------------------------------------- |
---|
[13286] | 1173 | USE dom_oce |
---|
| 1174 | USE agrif_oce |
---|
| 1175 | ! |
---|
| 1176 | IMPLICIT NONE |
---|
| 1177 | ! |
---|
| 1178 | INTEGER :: i1,i2,j1,j2 |
---|
| 1179 | REAL(wp), DIMENSION(i1:i2,j1:j2) :: tab2d |
---|
| 1180 | ! |
---|
| 1181 | INTEGER :: i,j |
---|
| 1182 | REAL(wp), DIMENSION(i1:i2,j1:j2) :: tab2dtemp |
---|
| 1183 | !!---------------------------------------------------------------------- |
---|
[13216] | 1184 | |
---|
[13286] | 1185 | tab2dtemp = tab2d |
---|
[13216] | 1186 | |
---|
[13286] | 1187 | IF( .NOT. use_sign_north ) THEN |
---|
| 1188 | DO j=j1,j2 |
---|
| 1189 | DO i=i1,i2 |
---|
| 1190 | tab2d(i,j)=tab2dtemp(i2-(i-i1),j2-(j-j1)) |
---|
| 1191 | END DO |
---|
[13216] | 1192 | END DO |
---|
[13286] | 1193 | ELSE |
---|
| 1194 | DO j=j1,j2 |
---|
| 1195 | DO i=i1,i2 |
---|
| 1196 | tab2d(i,j)=sign_north * tab2dtemp(i2-(i-i1),j2-(j-j1)) |
---|
| 1197 | END DO |
---|
[13216] | 1198 | END DO |
---|
[13286] | 1199 | ENDIF |
---|
[13216] | 1200 | |
---|
| 1201 | END SUBROUTINE Correct_field |
---|
| 1202 | |
---|
[390] | 1203 | #else |
---|
[12377] | 1204 | SUBROUTINE Subcalledbyagrif |
---|
[10068] | 1205 | !!---------------------------------------------------------------------- |
---|
| 1206 | !! *** ROUTINE Subcalledbyagrif *** |
---|
| 1207 | !!---------------------------------------------------------------------- |
---|
[12377] | 1208 | WRITE(*,*) 'Impossible to be here' |
---|
| 1209 | END SUBROUTINE Subcalledbyagrif |
---|
[390] | 1210 | #endif |
---|