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