[396] | 1 | ! |
---|
| 2 | ! $Id$ |
---|
| 3 | ! |
---|
| 4 | C AGRIF (Adaptive Grid Refinement In Fortran) |
---|
| 5 | C |
---|
| 6 | C Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr) |
---|
| 7 | C Christophe Vouland (Christophe.Vouland@imag.fr) |
---|
| 8 | C |
---|
| 9 | C This program is free software; you can redistribute it and/or modify |
---|
| 10 | C it under the terms of the GNU General Public License as published by |
---|
| 11 | C the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | C (at your option) any later version. |
---|
| 13 | C |
---|
| 14 | C This program is distributed in the hope that it will be useful, |
---|
| 15 | C but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | C GNU General Public License for more details. |
---|
| 18 | C |
---|
| 19 | C You should have received a copy of the GNU General Public License |
---|
| 20 | C along with this program; if not, write to the Free Software |
---|
| 21 | C Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | C |
---|
| 23 | C |
---|
| 24 | C |
---|
| 25 | CCC Module Agrif_Boundary |
---|
| 26 | C |
---|
| 27 | Module Agrif_Boundary |
---|
| 28 | C |
---|
| 29 | CCC Description: |
---|
| 30 | CCC Module to calculate the boundary conditions on the child grids from their |
---|
| 31 | CCC parent grids. |
---|
| 32 | C |
---|
| 33 | C Modules used: |
---|
| 34 | C |
---|
| 35 | Use Agrif_Interpolation |
---|
| 36 | C |
---|
| 37 | IMPLICIT NONE |
---|
| 38 | C |
---|
| 39 | CONTAINS |
---|
| 40 | C Define procedures contained in this module |
---|
| 41 | C |
---|
| 42 | C |
---|
| 43 | C |
---|
| 44 | C ************************************************************************** |
---|
| 45 | CCC Subroutine Agrif_Interp_bc_1d |
---|
| 46 | C ************************************************************************** |
---|
| 47 | C |
---|
| 48 | Subroutine Agrif_Interp_bc_1d(TypeInterp,parent,child,tab,deb,fin, |
---|
| 49 | & weight,pweight) |
---|
| 50 | C |
---|
| 51 | CCC Description: |
---|
| 52 | CCC Subroutine to calculate the boundary conditions on a fine grid for a 1D |
---|
| 53 | CCC grid variable. |
---|
| 54 | C |
---|
| 55 | C Declarations: |
---|
| 56 | C |
---|
| 57 | |
---|
| 58 | C |
---|
| 59 | C Arguments |
---|
| 60 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation |
---|
| 61 | ! (linear,...) |
---|
| 62 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 63 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 64 | TYPE(AGRIF_PVariable) :: childtemp ! Temporary variable on the child |
---|
| 65 | ! grid |
---|
| 66 | INTEGER :: deb,fin ! Positions of the interpolations |
---|
| 67 | REAL, DIMENSION( |
---|
| 68 | & lbound(child%var%array1,1):ubound(child%var%array1,1) |
---|
| 69 | & ), Target :: tab ! Values of the grid variable |
---|
| 70 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 71 | ! the temporal interpolation |
---|
| 72 | REAL :: weight ! Coefficient for the time |
---|
| 73 | ! interpolation |
---|
| 74 | C |
---|
| 75 | C |
---|
| 76 | C Definition of a temporary AGRIF_PVariable data TYPE representing the grid |
---|
| 77 | C variable. |
---|
| 78 | C |
---|
| 79 | allocate(childtemp % var) |
---|
| 80 | C |
---|
| 81 | childtemp % var % root_var => child % var % root_var |
---|
| 82 | C |
---|
| 83 | C Values of the grid variable |
---|
| 84 | childtemp % var % array1 => tab |
---|
| 85 | C |
---|
| 86 | C Temporary results for the time interpolation before and after the space |
---|
| 87 | C interpolation |
---|
| 88 | childtemp % var % oldvalues2D => child % var % oldvalues2D |
---|
| 89 | C |
---|
| 90 | C Index indicating if a space interpolation is necessary |
---|
| 91 | childtemp % var % interpIndex => child % var % interpIndex |
---|
| 92 | childtemp % var % Interpolationshouldbemade = |
---|
| 93 | & child % var % Interpolationshouldbemade |
---|
| 94 | C |
---|
| 95 | C Call to the procedure for the calculations of the boundary conditions |
---|
| 96 | Call Agrif_CorrectVariable |
---|
| 97 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight) |
---|
| 98 | C |
---|
| 99 | child % var % oldvalues2D => childtemp % var % oldvalues2D |
---|
| 100 | C |
---|
| 101 | deallocate(childtemp % var) |
---|
| 102 | C |
---|
| 103 | C |
---|
| 104 | End Subroutine Agrif_Interp_bc_1D |
---|
| 105 | C |
---|
| 106 | C |
---|
| 107 | C |
---|
| 108 | C ************************************************************************** |
---|
| 109 | CCC Subroutine Agrif_Interp_bc_2d |
---|
| 110 | C ************************************************************************** |
---|
| 111 | C |
---|
| 112 | Subroutine Agrif_Interp_bc_2d(TypeInterp,parent,child,tab,deb,fin, |
---|
| 113 | & weight,pweight,procname) |
---|
| 114 | C |
---|
| 115 | CCC Description: |
---|
| 116 | CCC Subroutine to calculate the boundary conditions on a fine grid for a 2D |
---|
| 117 | CCC grid variable. |
---|
| 118 | C |
---|
| 119 | C Declarations: |
---|
| 120 | C |
---|
| 121 | |
---|
| 122 | C |
---|
| 123 | C Arguments |
---|
| 124 | External :: procname |
---|
| 125 | Optional :: procname |
---|
| 126 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation (linear, |
---|
| 127 | ! lagrange, spline, ... ) |
---|
| 128 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 129 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 130 | TYPE(AGRIF_PVariable) :: childtemp ! Temporary variable on the child |
---|
| 131 | ! grid |
---|
| 132 | INTEGER :: deb,fin ! Positions where interpolations are |
---|
| 133 | ! done on the fine grid |
---|
| 134 | REAL, DIMENSION( |
---|
| 135 | & lbound(child%var%array2,1): ubound(child%var%array2,1), |
---|
| 136 | & lbound(child%var%array2,2): ubound(child%var%array2,2)), |
---|
| 137 | & Target :: tab ! Values of the grid variable |
---|
| 138 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 139 | ! the temporal interpolation |
---|
| 140 | REAL :: weight ! Coefficient for the time |
---|
| 141 | ! interpolation |
---|
| 142 | C |
---|
| 143 | C |
---|
| 144 | C Definition of a temporary AGRIF_PVariable data TYPE representing the grid |
---|
| 145 | C variable. |
---|
| 146 | C |
---|
| 147 | allocate(childtemp % var) |
---|
| 148 | C |
---|
| 149 | childtemp % var % root_var => child % var % root_var |
---|
| 150 | C |
---|
| 151 | C Values of the grid variable |
---|
| 152 | childtemp % var % array2 => tab |
---|
| 153 | C |
---|
| 154 | C Temporary results for the time interpolation before and after the space |
---|
| 155 | C interpolation |
---|
| 156 | childtemp % var % oldvalues2D => child % var % oldvalues2D |
---|
| 157 | C |
---|
| 158 | C Index indicating if a space interpolation is necessary |
---|
| 159 | childtemp % var % interpIndex => child % var % interpIndex |
---|
| 160 | childtemp % var % Interpolationshouldbemade = |
---|
| 161 | & child % var % Interpolationshouldbemade |
---|
| 162 | C |
---|
| 163 | C Call to the procedure for the calculations of the boundary conditions |
---|
| 164 | IF (present(procname)) THEN |
---|
| 165 | Call Agrif_CorrectVariable |
---|
| 166 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname) |
---|
| 167 | ELSE |
---|
| 168 | Call Agrif_CorrectVariable |
---|
| 169 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight) |
---|
| 170 | ENDIF |
---|
| 171 | |
---|
| 172 | C |
---|
| 173 | child % var % oldvalues2D => childtemp % var % oldvalues2D |
---|
| 174 | C |
---|
| 175 | deallocate(childtemp % var) |
---|
| 176 | C |
---|
| 177 | C |
---|
| 178 | End Subroutine Agrif_Interp_bc_2D |
---|
| 179 | C |
---|
| 180 | C |
---|
| 181 | C |
---|
| 182 | C ************************************************************************** |
---|
| 183 | CCC Subroutine Agrif_Interp_bc_3d |
---|
| 184 | C ************************************************************************** |
---|
| 185 | C |
---|
| 186 | Subroutine Agrif_Interp_bc_3d(TypeInterp,parent,child,tab,deb,fin, |
---|
| 187 | & weight,pweight,procname) |
---|
| 188 | C |
---|
| 189 | CCC Description: |
---|
| 190 | CCC Subroutine to calculate the boundary conditions on a fine grid for a 3D |
---|
| 191 | CCC variable. |
---|
| 192 | C |
---|
| 193 | C Declarations: |
---|
| 194 | C |
---|
| 195 | |
---|
| 196 | C |
---|
| 197 | C Arguments |
---|
| 198 | External :: procname |
---|
| 199 | Optional :: procname |
---|
| 200 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation (linear, |
---|
| 201 | ! lagrange, spline, ... ) |
---|
| 202 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 203 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 204 | TYPE(AGRIF_PVariable) :: childtemp ! Temporary variable on the child |
---|
| 205 | ! grid |
---|
| 206 | INTEGER :: deb,fin ! Positions where interpolations |
---|
| 207 | ! are done on the fine grid |
---|
| 208 | REAL, DIMENSION( |
---|
| 209 | & lbound(child%var%array3,1):ubound(child%var%array3,1), |
---|
| 210 | & lbound(child%var%array3,2):ubound(child%var%array3,2), |
---|
| 211 | & lbound(child%var%array3,3):ubound(child%var%array3,3) |
---|
| 212 | & ), Target :: tab ! Values of the grid variable |
---|
| 213 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 214 | ! the temporal interpolation |
---|
| 215 | REAL :: weight ! Coefficient for the time |
---|
| 216 | ! interpolation |
---|
| 217 | C |
---|
| 218 | C |
---|
| 219 | C Definition of a temporary AGRIF_PVariable data TYPE representing the grid |
---|
| 220 | C variable. |
---|
| 221 | C |
---|
| 222 | allocate(childtemp % var) |
---|
| 223 | C |
---|
| 224 | childtemp % var % root_var => child % var % root_var |
---|
| 225 | C |
---|
| 226 | C Values of the grid variable |
---|
| 227 | childtemp % var % array3 => tab |
---|
| 228 | C |
---|
| 229 | C Temporary results for the time interpolation before and after the space |
---|
| 230 | C interpolation |
---|
| 231 | childtemp % var % oldvalues2D => child % var % oldvalues2D |
---|
| 232 | C |
---|
| 233 | C Index indicating if a space interpolation is necessary |
---|
| 234 | childtemp % var % interpIndex => child % var % interpIndex |
---|
| 235 | childtemp % var % Interpolationshouldbemade = |
---|
| 236 | & child % var % Interpolationshouldbemade |
---|
| 237 | C |
---|
| 238 | C Call to the procedure for the calculations of the boundary conditions |
---|
| 239 | IF (present(procname)) THEN |
---|
| 240 | Call Agrif_CorrectVariable |
---|
| 241 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname) |
---|
| 242 | ELSE |
---|
| 243 | Call Agrif_CorrectVariable |
---|
| 244 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight) |
---|
| 245 | ENDIF |
---|
| 246 | C |
---|
| 247 | child % var % oldvalues2D => childtemp % var % oldvalues2D |
---|
| 248 | C |
---|
| 249 | deallocate(childtemp % var) |
---|
| 250 | C |
---|
| 251 | C |
---|
| 252 | End Subroutine Agrif_Interp_bc_3D |
---|
| 253 | C |
---|
| 254 | C |
---|
| 255 | C |
---|
| 256 | C |
---|
| 257 | C ************************************************************************** |
---|
| 258 | CCC Subroutine Agrif_Interp_bc_4d |
---|
| 259 | C ************************************************************************** |
---|
| 260 | C |
---|
| 261 | Subroutine Agrif_Interp_bc_4d(TypeInterp,parent,child,tab,deb,fin, |
---|
| 262 | & weight,pweight,procname) |
---|
| 263 | C |
---|
| 264 | CCC Description: |
---|
| 265 | CCC Subroutine to calculate the boundary conditions on a fine grid for a 4D |
---|
| 266 | CCC grid variable. |
---|
| 267 | C |
---|
| 268 | C Declarations: |
---|
| 269 | C |
---|
| 270 | |
---|
| 271 | C |
---|
| 272 | C Arguments |
---|
| 273 | External :: procname |
---|
| 274 | Optional :: procname |
---|
| 275 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation (linear, |
---|
| 276 | ! lagrange, spline, ... ) |
---|
| 277 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 278 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 279 | TYPE(AGRIF_PVariable) :: childtemp ! Temporary varaiable on the child |
---|
| 280 | ! grid |
---|
| 281 | INTEGER :: deb,fin ! Positions where interpolations |
---|
| 282 | ! are done on the fine grid |
---|
| 283 | REAL, DIMENSION( |
---|
| 284 | & lbound(child%var%array4,1):ubound(child%var%array4,1), |
---|
| 285 | & lbound(child%var%array4,2):ubound(child%var%array4,2), |
---|
| 286 | & lbound(child%var%array4,3):ubound(child%var%array4,3), |
---|
| 287 | & lbound(child%var%array4,4):ubound(child%var%array4,4) |
---|
| 288 | & ), Target :: tab ! Values of the grid variable |
---|
| 289 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 290 | ! the temporal interpolation |
---|
| 291 | REAL :: weight ! Coefficient for the time |
---|
| 292 | ! interpolation |
---|
| 293 | C |
---|
| 294 | C |
---|
| 295 | C Definition of a temporary AGRIF_PVariable data TYPE representing the grid |
---|
| 296 | C variable. |
---|
| 297 | C |
---|
| 298 | allocate(childtemp % var) |
---|
| 299 | C |
---|
| 300 | childtemp % var % root_var => child % var % root_var |
---|
| 301 | C |
---|
| 302 | C Values of the grid variable |
---|
| 303 | childtemp % var % array4 => tab |
---|
| 304 | C |
---|
| 305 | C Temporary results for the time interpolation before and after the space |
---|
| 306 | C interpolation |
---|
| 307 | childtemp % var % oldvalues2D => child % var % oldvalues2D |
---|
| 308 | C |
---|
| 309 | C Index indicating if a space interpolation is necessary |
---|
| 310 | childtemp % var % interpIndex => child % var % interpIndex |
---|
| 311 | childtemp % var % Interpolationshouldbemade = |
---|
| 312 | & child % var % Interpolationshouldbemade |
---|
| 313 | C |
---|
| 314 | C Call to the procedure for the calculations of the boundary conditions |
---|
| 315 | IF (present(procname)) THEN |
---|
| 316 | Call Agrif_CorrectVariable |
---|
| 317 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname) |
---|
| 318 | ELSE |
---|
| 319 | Call Agrif_CorrectVariable |
---|
| 320 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight) |
---|
| 321 | ENDIF |
---|
| 322 | C |
---|
| 323 | child % var % oldvalues2D => childtemp % var % oldvalues2D |
---|
| 324 | C |
---|
| 325 | deallocate(childtemp % var) |
---|
| 326 | C |
---|
| 327 | C |
---|
| 328 | End Subroutine Agrif_Interp_bc_4D |
---|
| 329 | C |
---|
| 330 | C |
---|
| 331 | C |
---|
| 332 | C ************************************************************************** |
---|
| 333 | CCC Subroutine Agrif_Interp_bc_5d |
---|
| 334 | C ************************************************************************** |
---|
| 335 | C |
---|
| 336 | Subroutine Agrif_Interp_bc_5d(TypeInterp,parent,child,tab,deb,fin, |
---|
| 337 | & weight,pweight,procname) |
---|
| 338 | C |
---|
| 339 | CCC Description: |
---|
| 340 | CCC Subroutine to calculate the boundary conditions on a fine grid for a 5D |
---|
| 341 | CCC grid variable. |
---|
| 342 | C |
---|
| 343 | C Declarations: |
---|
| 344 | C |
---|
| 345 | |
---|
| 346 | C |
---|
| 347 | C Arguments |
---|
| 348 | External :: procname |
---|
| 349 | Optional :: procname |
---|
| 350 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation (linear, |
---|
| 351 | ! lagrange, spline, ... ) |
---|
| 352 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 353 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 354 | TYPE(AGRIF_PVariable) :: childtemp ! Temporary varaiable on the child |
---|
| 355 | ! grid |
---|
| 356 | INTEGER :: deb,fin ! Positions where interpolations |
---|
| 357 | ! are done on the fine grid |
---|
| 358 | REAL, DIMENSION( |
---|
| 359 | & lbound(child%var%array5,1):ubound(child%var%array5,1), |
---|
| 360 | & lbound(child%var%array5,2):ubound(child%var%array5,2), |
---|
| 361 | & lbound(child%var%array5,3):ubound(child%var%array5,3), |
---|
| 362 | & lbound(child%var%array5,4):ubound(child%var%array5,4), |
---|
| 363 | & lbound(child%var%array5,5):ubound(child%var%array5,5) |
---|
| 364 | & ), Target :: tab ! Values of the grid variable |
---|
| 365 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 366 | ! the temporal interpolation |
---|
| 367 | REAL :: weight ! Coefficient for the time |
---|
| 368 | ! interpolation |
---|
| 369 | C |
---|
| 370 | C |
---|
| 371 | C Definition of a temporary AGRIF_PVariable data TYPE representing the grid |
---|
| 372 | C variable. |
---|
| 373 | C |
---|
| 374 | allocate(childtemp % var) |
---|
| 375 | C |
---|
| 376 | childtemp % var % root_var => child % var % root_var |
---|
| 377 | C |
---|
| 378 | C Values of the grid variable |
---|
| 379 | childtemp % var % array5 => tab |
---|
| 380 | C |
---|
| 381 | C Temporary results for the time interpolation before and after the space |
---|
| 382 | C interpolation |
---|
| 383 | childtemp % var % oldvalues2D => child % var % oldvalues2D |
---|
| 384 | C |
---|
| 385 | C Index indicating if a space interpolation is necessary |
---|
| 386 | childtemp % var % interpIndex => child % var % interpIndex |
---|
| 387 | childtemp % var % Interpolationshouldbemade = |
---|
| 388 | & child % var % Interpolationshouldbemade |
---|
| 389 | C |
---|
| 390 | C Call to the procedure for the calculations of the boundary conditions |
---|
| 391 | IF (present(procname)) THEN |
---|
| 392 | Call Agrif_CorrectVariable |
---|
| 393 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname) |
---|
| 394 | ELSE |
---|
| 395 | Call Agrif_CorrectVariable |
---|
| 396 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight) |
---|
| 397 | ENDIF |
---|
| 398 | C |
---|
| 399 | child % var % oldvalues2D => childtemp % var % oldvalues2D |
---|
| 400 | C |
---|
| 401 | deallocate(childtemp % var) |
---|
| 402 | C |
---|
| 403 | C |
---|
| 404 | End Subroutine Agrif_Interp_bc_5D |
---|
| 405 | C |
---|
| 406 | C |
---|
| 407 | C |
---|
| 408 | C |
---|
| 409 | C ************************************************************************** |
---|
| 410 | CCC Subroutine Agrif_Interp_bc_6d |
---|
| 411 | C ************************************************************************** |
---|
| 412 | C |
---|
| 413 | Subroutine Agrif_Interp_bc_6d(TypeInterp,parent,child,tab,deb,fin, |
---|
| 414 | & weight,pweight) |
---|
| 415 | C |
---|
| 416 | CCC Description: |
---|
| 417 | CCC Subroutine to calculate the boundary conditions on a fine grid for a 6D |
---|
| 418 | CCC grid variable. |
---|
| 419 | C |
---|
| 420 | C Declarations: |
---|
| 421 | C |
---|
| 422 | |
---|
| 423 | C |
---|
| 424 | C Arguments |
---|
| 425 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation (linear, |
---|
| 426 | ! lagrange, spline, ... ) |
---|
| 427 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 428 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 429 | TYPE(AGRIF_PVariable) :: childtemp ! Temporary varaiable on the child |
---|
| 430 | ! grid |
---|
| 431 | INTEGER :: deb,fin ! Positions where interpolations |
---|
| 432 | ! are done on the fine grid |
---|
| 433 | REAL, DIMENSION( |
---|
| 434 | & lbound(child%var%array6,1):ubound(child%var%array6,1), |
---|
| 435 | & lbound(child%var%array6,2):ubound(child%var%array6,2), |
---|
| 436 | & lbound(child%var%array6,3):ubound(child%var%array6,3), |
---|
| 437 | & lbound(child%var%array6,4):ubound(child%var%array6,4), |
---|
| 438 | & lbound(child%var%array6,5):ubound(child%var%array6,5), |
---|
| 439 | & lbound(child%var%array6,6):ubound(child%var%array6,6) |
---|
| 440 | & ), Target :: tab ! Values of the grid variable |
---|
| 441 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 442 | ! the temporal interpolation |
---|
| 443 | REAL :: weight ! Coefficient for the time |
---|
| 444 | ! interpolation |
---|
| 445 | C |
---|
| 446 | C |
---|
| 447 | C Definition of a temporary AGRIF_PVariable data TYPE representing the grid |
---|
| 448 | C variable. |
---|
| 449 | C |
---|
| 450 | allocate(childtemp % var) |
---|
| 451 | C |
---|
| 452 | childtemp % var % root_var => child % var % root_var |
---|
| 453 | C |
---|
| 454 | C Values of the grid variable |
---|
| 455 | childtemp % var % array6 => tab |
---|
| 456 | C |
---|
| 457 | C Temporary results for the time interpolation before and after the space |
---|
| 458 | C interpolation |
---|
| 459 | childtemp % var % oldvalues2D => child % var % oldvalues2D |
---|
| 460 | C |
---|
| 461 | C Index indicating if a space interpolation is necessary |
---|
| 462 | childtemp % var % interpIndex => child % var % interpIndex |
---|
| 463 | childtemp % var % Interpolationshouldbemade = |
---|
| 464 | & child % var % Interpolationshouldbemade |
---|
| 465 | C |
---|
| 466 | C Call to the procedure for the calculations of the boundary conditions |
---|
| 467 | Call Agrif_CorrectVariable |
---|
| 468 | & (TypeInterp,parent,childtemp,deb,fin,pweight,weight) |
---|
| 469 | C |
---|
| 470 | child % var % oldvalues2D => childtemp % var % oldvalues2D |
---|
| 471 | C |
---|
| 472 | deallocate(childtemp % var) |
---|
| 473 | C |
---|
| 474 | C |
---|
| 475 | End Subroutine Agrif_Interp_bc_6D |
---|
| 476 | C |
---|
| 477 | C |
---|
| 478 | C ************************************************************************** |
---|
| 479 | CCC Subroutine Agrif_CorrectVariable |
---|
| 480 | C ************************************************************************** |
---|
| 481 | C |
---|
| 482 | Subroutine AGRIF_CorrectVariable(TypeInterp,parent,child,deb,fin, |
---|
| 483 | & pweight,weight,procname) |
---|
| 484 | C |
---|
| 485 | CCC Description: |
---|
| 486 | CCC Subroutine to calculate the boundary conditions on a fine grid. |
---|
| 487 | C |
---|
| 488 | C Declarations: |
---|
| 489 | C |
---|
| 490 | |
---|
| 491 | C |
---|
| 492 | C Arguments |
---|
| 493 | External :: procname |
---|
| 494 | Optional :: procname |
---|
| 495 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 496 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 497 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation |
---|
| 498 | ! (linear,lagrange,...) |
---|
| 499 | INTEGER :: deb,fin ! Positions where boundary |
---|
| 500 | ! conditions are calculated |
---|
| 501 | LOGICAL :: pweight ! Indicates if weight is used |
---|
| 502 | ! for the time interpolation |
---|
| 503 | REAL :: weight ! Coefficient for the time |
---|
| 504 | ! interpolation |
---|
| 505 | C |
---|
| 506 | C Local scalars |
---|
| 507 | TYPE(Agrif_Grid) , Pointer :: Agrif_Child_Gr,Agrif_Parent_Gr |
---|
| 508 | TYPE(AGRIF_Variable), Pointer :: root ! Variable on the root grid |
---|
| 509 | INTEGER :: nbdim ! Number of dimensions of |
---|
| 510 | ! the grid variable |
---|
| 511 | INTEGER :: n |
---|
| 512 | INTEGER,DIMENSION(6) :: pttab_child ! Index of the first point |
---|
| 513 | ! inside the domain for |
---|
| 514 | ! the child grid variable |
---|
| 515 | INTEGER,DIMENSION(6) :: pttab_parent ! Index of the first point |
---|
| 516 | ! inside the domain for |
---|
| 517 | ! the parent grid |
---|
| 518 | ! variable |
---|
| 519 | INTEGER,DIMENSION(6) :: nbtab_Child ! Number of the cells |
---|
| 520 | INTEGER,DIMENSION(6) :: posvartab_Child ! Position of the |
---|
| 521 | ! variable on the cell |
---|
| 522 | INTEGER,DIMENSION(6) :: loctab_Child ! Indicates if the child |
---|
| 523 | ! grid has a common |
---|
| 524 | ! border with the root |
---|
| 525 | ! grid |
---|
| 526 | REAL, DIMENSION(6) :: s_child,s_parent ! Positions of the |
---|
| 527 | ! parent and child grids |
---|
| 528 | REAL, DIMENSION(6) :: ds_child,ds_parent ! Space steps of the |
---|
| 529 | ! parent and child grids |
---|
| 530 | C |
---|
| 531 | C |
---|
| 532 | loctab_child(:) = 0 |
---|
| 533 | C |
---|
| 534 | Agrif_Child_Gr => Agrif_Curgrid |
---|
| 535 | Agrif_Parent_Gr => Agrif_Curgrid % parent |
---|
| 536 | root => child % var % root_var |
---|
| 537 | nbdim = root % nbdim |
---|
| 538 | C |
---|
| 539 | do n = 1,nbdim |
---|
| 540 | posvartab_child(n) = root % posvar(n) |
---|
| 541 | enddo |
---|
| 542 | C |
---|
| 543 | C |
---|
| 544 | do n = 1,nbdim |
---|
| 545 | C |
---|
| 546 | Select case(root % interptab(n)) |
---|
| 547 | C |
---|
| 548 | case('x') ! x DIMENSION |
---|
| 549 | C |
---|
| 550 | nbtab_Child(n) = Agrif_Child_Gr % nb(1) |
---|
| 551 | pttab_Child(n) = root % point(1) |
---|
| 552 | pttab_Parent(n) = root % point(1) |
---|
| 553 | s_Child(n) = Agrif_Child_Gr % Agrif_x(1) |
---|
| 554 | s_Parent(n) = Agrif_Parent_Gr % Agrif_x(1) |
---|
| 555 | ds_Child(n) = Agrif_Child_Gr % Agrif_d(1) |
---|
| 556 | ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(1) |
---|
| 557 | if (root % posvar(n) == 2) then |
---|
| 558 | s_Child(n) = s_Child(n) + ds_Child(n)/2. |
---|
| 559 | s_Parent(n) = s_Parent(n) + ds_Parent(n)/2. |
---|
| 560 | endif |
---|
| 561 | C |
---|
| 562 | if (Agrif_CURGRID % NearRootBorder(1)) |
---|
| 563 | & loctab_child(n) = -1 |
---|
| 564 | if (Agrif_CURGRID % DistantRootBorder(1)) |
---|
| 565 | & loctab_child(n) = -2 |
---|
| 566 | if ((Agrif_CURGRID % NearRootBorder(1)) .AND. |
---|
| 567 | & (Agrif_CURGRID % DistantRootBorder(1))) |
---|
| 568 | & loctab_child(n) = -3 |
---|
| 569 | C |
---|
| 570 | case('y') ! y DIMENSION |
---|
| 571 | C |
---|
| 572 | nbtab_Child(n) = Agrif_Child_Gr % nb(2) |
---|
| 573 | pttab_Child(n) = root % point(2) |
---|
| 574 | pttab_Parent(n) = root % point(2) |
---|
| 575 | s_Child(n) = Agrif_Child_Gr % Agrif_x(2) |
---|
| 576 | s_Parent(n) = Agrif_Parent_Gr % Agrif_x(2) |
---|
| 577 | ds_Child(n) = Agrif_Child_Gr % Agrif_d(2) |
---|
| 578 | ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(2) |
---|
| 579 | if (root % posvar(n) == 2) then |
---|
| 580 | s_Child(n) = s_Child(n) + ds_Child(n)/2. |
---|
| 581 | s_Parent(n) = s_Parent(n) + ds_Parent(n)/2. |
---|
| 582 | endif |
---|
| 583 | C |
---|
| 584 | if (Agrif_CURGRID % NearRootBorder(2)) |
---|
| 585 | & loctab_child(n) = -1 |
---|
| 586 | if (Agrif_CURGRID % DistantRootBorder(2)) |
---|
| 587 | & loctab_child(n) = -2 |
---|
| 588 | if ((Agrif_CURGRID % NearRootBorder(2)) .AND. |
---|
| 589 | & (Agrif_CURGRID % DistantRootBorder(2))) |
---|
| 590 | & loctab_child(n) = -3 |
---|
| 591 | C |
---|
| 592 | case('z') ! z DIMENSION |
---|
| 593 | C |
---|
| 594 | nbtab_Child(n) = Agrif_Child_Gr % nb(3) |
---|
| 595 | pttab_Child(n) = root % point(3) |
---|
| 596 | pttab_Parent(n) = root % point(3) |
---|
| 597 | s_Child(n) = Agrif_Child_Gr % Agrif_x(3) |
---|
| 598 | s_Parent(n) = Agrif_Parent_Gr % Agrif_x(3) |
---|
| 599 | ds_Child(n) = Agrif_Child_Gr % Agrif_d(3) |
---|
| 600 | ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(3) |
---|
| 601 | if (root % posvar(n) == 2) then |
---|
| 602 | s_Child(n) = s_Child(n) + ds_Child(n)/2. |
---|
| 603 | s_Parent(n) = s_Parent(n) + ds_Parent(n)/2. |
---|
| 604 | endif |
---|
| 605 | C |
---|
| 606 | if (Agrif_CURGRID % NearRootBorder(3)) |
---|
| 607 | & loctab_child(n) = -1 |
---|
| 608 | if (Agrif_CURGRID % DistantRootBorder(3)) |
---|
| 609 | & loctab_child(n) = -2 |
---|
| 610 | if ((Agrif_CURGRID % NearRootBorder(3)) .AND. |
---|
| 611 | & (Agrif_CURGRID % DistantRootBorder(3))) |
---|
| 612 | & loctab_child(n) = -3 |
---|
| 613 | C |
---|
| 614 | case('N') ! No space DIMENSION |
---|
| 615 | C |
---|
| 616 | select case (nbdim) |
---|
| 617 | C |
---|
| 618 | case(1) |
---|
| 619 | nbtab_Child(n) = SIZE(child % var % array1,n) - 1 |
---|
| 620 | pttab_Child(n) = lbound(child % var % array1,n) |
---|
| 621 | case(2) |
---|
| 622 | nbtab_Child(n) = SIZE(child % var % array2,n) - 1 |
---|
| 623 | pttab_Child(n) = lbound(child % var % array2,n) |
---|
| 624 | case(3) |
---|
| 625 | nbtab_Child(n) = SIZE(child % var % array3,n) - 1 |
---|
| 626 | pttab_Child(n) = lbound(child % var % array3,n) |
---|
| 627 | case(4) |
---|
| 628 | nbtab_Child(n) = SIZE(child % var % array4,n) - 1 |
---|
| 629 | pttab_Child(n) = lbound(child % var % array4,n) |
---|
| 630 | case(5) |
---|
| 631 | nbtab_Child(n) = SIZE(child % var % array5,n) - 1 |
---|
| 632 | pttab_Child(n) = lbound(child % var % array5,n) |
---|
| 633 | case(6) |
---|
| 634 | nbtab_Child(n) = SIZE(child % var % array6,n) - 1 |
---|
| 635 | pttab_Child(n) = lbound(child % var % array6,n) |
---|
| 636 | C |
---|
| 637 | end select |
---|
| 638 | C |
---|
| 639 | C No interpolation but only a copy of the values of the grid variable |
---|
| 640 | C |
---|
| 641 | posvartab_child(n) = 1 |
---|
| 642 | pttab_Parent(n)= pttab_Child(n) |
---|
| 643 | s_Child(n)=0. |
---|
| 644 | s_Parent(n)=0. |
---|
| 645 | ds_Child(n)=1. |
---|
| 646 | ds_Parent(n)=1. |
---|
| 647 | loctab_child(n) = -3 |
---|
| 648 | C |
---|
| 649 | End select |
---|
| 650 | C |
---|
| 651 | enddo |
---|
| 652 | C |
---|
| 653 | IF (present(procname)) THEN |
---|
| 654 | Call AGRIF_CorrectnD |
---|
| 655 | & (TypeInterp,parent,child,deb,fin,pweight,weight, |
---|
| 656 | & pttab_Child(1:nbdim),pttab_Parent(1:nbdim), |
---|
| 657 | & nbtab_Child(1:nbdim),posvartab_Child(1:nbdim), |
---|
| 658 | & loctab_Child(1:nbdim), |
---|
| 659 | & s_Child(1:nbdim),s_Parent(1:nbdim), |
---|
| 660 | & ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim,procname) |
---|
| 661 | ELSE |
---|
| 662 | Call AGRIF_CorrectnD |
---|
| 663 | & (TypeInterp,parent,child,deb,fin,pweight,weight, |
---|
| 664 | & pttab_Child(1:nbdim),pttab_Parent(1:nbdim), |
---|
| 665 | & nbtab_Child(1:nbdim),posvartab_Child(1:nbdim), |
---|
| 666 | & loctab_Child(1:nbdim), |
---|
| 667 | & s_Child(1:nbdim),s_Parent(1:nbdim), |
---|
| 668 | & ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim) |
---|
| 669 | ENDIF |
---|
| 670 | C |
---|
| 671 | C |
---|
| 672 | End subroutine AGRIF_CorrectVariable |
---|
| 673 | C |
---|
| 674 | C ************************************************************************** |
---|
| 675 | CCC Subroutine Agrif_Correctnd |
---|
| 676 | C ************************************************************************** |
---|
| 677 | C |
---|
| 678 | Subroutine AGRIF_Correctnd(TypeInterp,parent,child,deb,fin, |
---|
| 679 | & pweight,weight, |
---|
| 680 | & pttab_child,pttab_Parent, |
---|
| 681 | & nbtab_Child,posvartab_Child, |
---|
| 682 | & loctab_Child, |
---|
| 683 | & s_Child,s_Parent, |
---|
| 684 | & ds_Child,ds_Parent,nbdim,procname) |
---|
| 685 | C |
---|
| 686 | CCC Description: |
---|
| 687 | CCC Subroutine to calculate the boundary conditions for a nD grid variable on |
---|
| 688 | CCC a fine grid by using a space and time interpolations; it is called by the |
---|
| 689 | CCC Agrif_CorrectVariable procedure. |
---|
| 690 | C |
---|
| 691 | C |
---|
| 692 | C Declarations: |
---|
| 693 | C |
---|
| 694 | |
---|
| 695 | C |
---|
| 696 | #ifdef AGRIF_MPI |
---|
| 697 | C |
---|
| 698 | #include "mpif.h" |
---|
| 699 | C |
---|
| 700 | #endif |
---|
| 701 | C |
---|
| 702 | C Arguments |
---|
| 703 | External :: procname |
---|
| 704 | Optional :: procname |
---|
| 705 | INTEGER,DIMENSION(6) :: TypeInterp ! TYPE of interpolation (linear, |
---|
| 706 | ! spline,...) |
---|
| 707 | TYPE(AGRIF_PVariable) :: parent ! Variable on the parent grid |
---|
| 708 | TYPE(AGRIF_PVariable) :: child ! Variable on the child grid |
---|
| 709 | INTEGER :: deb,fin ! Positions where interpolations |
---|
| 710 | ! are done |
---|
| 711 | LOGICAL :: pweight ! Indicates if weight is used for |
---|
| 712 | ! the temporal interpolation |
---|
| 713 | REAL :: weight ! Coefficient for the temporal |
---|
| 714 | ! interpolation |
---|
| 715 | INTEGER :: nbdim ! Number of dimensions of the grid |
---|
| 716 | ! variable |
---|
| 717 | INTEGER,DIMENSION(nbdim) :: pttab_child ! Index of the first point inside |
---|
| 718 | ! the domain for the parent |
---|
| 719 | ! grid variable |
---|
| 720 | INTEGER,DIMENSION(nbdim) :: pttab_Parent ! Index of the first point |
---|
| 721 | ! inside the domain for the |
---|
| 722 | ! child grid variable |
---|
| 723 | INTEGER,DIMENSION(nbdim) :: nbtab_Child ! Number of cells of the child |
---|
| 724 | ! grid |
---|
| 725 | INTEGER,DIMENSION(nbdim) :: posvartab_Child ! Position of the grid |
---|
| 726 | ! variable (1 or 2) |
---|
| 727 | INTEGER,DIMENSION(nbdim) :: loctab_Child ! Indicates if the child |
---|
| 728 | ! grid has a common border with |
---|
| 729 | ! the root grid |
---|
| 730 | REAL ,DIMENSION(nbdim) :: s_Child,s_Parent ! Positions of the parent |
---|
| 731 | ! and child grids |
---|
| 732 | REAL ,DIMENSION(nbdim) :: ds_Child,ds_Parent ! Space steps of the |
---|
| 733 | ! parent and child grids |
---|
| 734 | C |
---|
| 735 | C Local variables |
---|
| 736 | TYPE(AGRIF_PVariable) :: restore ! Variable on the parent |
---|
| 737 | INTEGER,DIMENSION(nbdim,2) :: lubglob |
---|
| 738 | INTEGER :: i |
---|
| 739 | INTEGER :: kindex ! Index used for safeguard |
---|
| 740 | ! and time interpolation |
---|
| 741 | INTEGER,DIMENSION(nbdim,2,2) :: indtab ! Arrays indicating the limits |
---|
| 742 | ! of the child |
---|
| 743 | INTEGER,DIMENSION(nbdim,2,2) :: indtruetab ! grid variable where |
---|
| 744 | ! boundary conditions are |
---|
| 745 | INTEGER,DIMENSION(nbdim,2,2,nbdim) :: ptres,ptres2 ! calculated |
---|
| 746 | INTEGER :: nb,ndir,n,sizetab |
---|
| 747 | REAL, DIMENSION(:), Allocatable :: tab ! Array used for the interpolation |
---|
| 748 | REAL :: c1t,c2t ! Coefficients for the time interpolation |
---|
| 749 | ! (c2t=1-c1t) |
---|
| 750 | C |
---|
| 751 | #ifdef AGRIF_MPI |
---|
| 752 | C |
---|
| 753 | INTEGER,DIMENSION(nbdim) :: lower,upper |
---|
| 754 | INTEGER,DIMENSION(nbdim) :: ltab,utab |
---|
| 755 | INTEGER,DIMENSION(nbdim) :: lb,ub |
---|
| 756 | INTEGER,DIMENSION(nbdim,2) :: iminmaxg |
---|
| 757 | INTEGER :: code |
---|
| 758 | C |
---|
| 759 | #endif |
---|
| 760 | C |
---|
| 761 | C |
---|
| 762 | indtab(1:nbdim,2,1) = pttab_child(1:nbdim) + nbtab_child(1:nbdim) |
---|
| 763 | & + deb |
---|
| 764 | indtab(1:nbdim,2,2) = indtab(1:nbdim,2,1) + ( fin - deb ) |
---|
| 765 | |
---|
| 766 | indtab(1:nbdim,1,1) = pttab_child(1:nbdim) - fin |
---|
| 767 | indtab(1:nbdim,1,2) = pttab_child(1:nbdim) - deb |
---|
| 768 | |
---|
| 769 | WHERE (posvartab_child(1:nbdim) == 2) |
---|
| 770 | indtab(1:nbdim,1,1) = indtab(1:nbdim,1,1) - 1 |
---|
| 771 | indtab(1:nbdim,1,2) = indtab(1:nbdim,1,2) - 1 |
---|
| 772 | END WHERE |
---|
| 773 | |
---|
| 774 | #if !defined AGRIF_MPI |
---|
| 775 | Call Agrif_nbdim_Get_bound_dimension(child%var,lubglob(:,1), |
---|
| 776 | & lubglob(:,2),nbdim) |
---|
| 777 | C |
---|
| 778 | #else |
---|
| 779 | C |
---|
| 780 | Call Agrif_nbdim_Get_bound_dimension(child%var,lb,ub,nbdim) |
---|
| 781 | |
---|
| 782 | DO i = 1,nbdim |
---|
| 783 | C |
---|
| 784 | Call Agrif_Invloc(lb(i),Agrif_Procrank,i,iminmaxg(i,1)) |
---|
| 785 | Call Agrif_Invloc(ub(i),Agrif_Procrank,i,iminmaxg(i,2)) |
---|
| 786 | C |
---|
| 787 | ENDDO |
---|
| 788 | C |
---|
| 789 | iminmaxg(1:nbdim,2) = - iminmaxg(1:nbdim,2) |
---|
| 790 | |
---|
| 791 | CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN, |
---|
| 792 | & MPI_COMM_WORLD,code) |
---|
| 793 | |
---|
| 794 | lubglob(1:nbdim,2) = - lubglob(1:nbdim,2) |
---|
| 795 | C |
---|
| 796 | #endif |
---|
| 797 | C |
---|
| 798 | indtruetab(1:nbdim,1,1) = max(indtab(1:nbdim,1,1), |
---|
| 799 | & lubglob(1:nbdim,1)) |
---|
| 800 | indtruetab(1:nbdim,1,2) = max(indtab(1:nbdim,1,2), |
---|
| 801 | & lubglob(1:nbdim,1)) |
---|
| 802 | indtruetab(1:nbdim,2,1) = min(indtab(1:nbdim,2,1), |
---|
| 803 | & lubglob(1:nbdim,2)) |
---|
| 804 | indtruetab(1:nbdim,2,2) = min(indtab(1:nbdim,2,2), |
---|
| 805 | & lubglob(1:nbdim,2)) |
---|
| 806 | |
---|
| 807 | C |
---|
| 808 | C |
---|
| 809 | do nb = 1,nbdim |
---|
| 810 | C |
---|
| 811 | do ndir = 1,2 |
---|
| 812 | C |
---|
| 813 | if (loctab_child(nb) /= (-ndir) |
---|
| 814 | & .AND. loctab_child(nb) /= -3) then |
---|
| 815 | C |
---|
| 816 | do n = 1,2 |
---|
| 817 | C |
---|
| 818 | ptres(nb,n,ndir,nb) = indtruetab(nb,ndir,n) |
---|
| 819 | C |
---|
| 820 | enddo |
---|
| 821 | C |
---|
| 822 | do i = 1,nbdim |
---|
| 823 | C |
---|
| 824 | if (i .NE. nb) then |
---|
| 825 | C |
---|
| 826 | if (loctab_child(i) == -1 |
---|
| 827 | & .OR. loctab_child(i) == -3) then |
---|
| 828 | C |
---|
| 829 | ptres(i,1,ndir,nb) = pttab_child(i) |
---|
| 830 | C |
---|
| 831 | else |
---|
| 832 | C |
---|
| 833 | ptres(i,1,ndir,nb) = indtruetab(i,1,1) |
---|
| 834 | C |
---|
| 835 | endif |
---|
| 836 | C |
---|
| 837 | if (loctab_child(i) == -2 |
---|
| 838 | & .OR. loctab_child(i) == -3) then |
---|
| 839 | C |
---|
| 840 | if (posvartab_child(i) == 1) then |
---|
| 841 | C |
---|
| 842 | ptres(i,2,ndir,nb) = pttab_child(i) |
---|
| 843 | & + nbtab_child(i) |
---|
| 844 | C |
---|
| 845 | else |
---|
| 846 | C |
---|
| 847 | ptres(i,2,ndir,nb) = pttab_child(i) |
---|
| 848 | & + nbtab_child(i) - 1 |
---|
| 849 | C |
---|
| 850 | endif |
---|
| 851 | C |
---|
| 852 | else |
---|
| 853 | C |
---|
| 854 | ptres(i,2,ndir,nb) = indtruetab(i,2,2) |
---|
| 855 | C |
---|
| 856 | endif |
---|
| 857 | C |
---|
| 858 | endif |
---|
| 859 | C |
---|
| 860 | enddo |
---|
| 861 | |
---|
| 862 | C |
---|
| 863 | #if defined AGRIF_MPI |
---|
| 864 | Call Agrif_nbdim_Get_bound_dimension |
---|
| 865 | & (child%var,lower,upper,nbdim) |
---|
| 866 | |
---|
| 867 | do i = 1,nbdim |
---|
| 868 | C |
---|
| 869 | Call GetLocalBoundaries(ptres(i,1,ndir,nb), |
---|
| 870 | & ptres(i,2,ndir,nb),i, |
---|
| 871 | & lower(i),upper(i), |
---|
| 872 | & ltab(i),utab(i)) |
---|
| 873 | ptres2(i,1,ndir,nb) = max(ltab(i),lower(i)) |
---|
| 874 | ptres2(i,2,ndir,nb) = min(utab(i),upper(i)) |
---|
| 875 | if ((i == nb) .AND. (ndir == 1)) then |
---|
| 876 | ptres2(i,2,ndir,nb) = max(utab(i),lower(i)) |
---|
| 877 | elseif ((i == nb) .AND. (ndir == 2)) then |
---|
| 878 | ptres2(i,1,ndir,nb) = min(ltab(i),upper(i)) |
---|
| 879 | endif |
---|
| 880 | C |
---|
| 881 | enddo |
---|
| 882 | #else |
---|
| 883 | ptres2(:,:,ndir,nb) = ptres(:,:,ndir,nb) |
---|
| 884 | #endif |
---|
| 885 | |
---|
| 886 | endif |
---|
| 887 | |
---|
| 888 | enddo |
---|
| 889 | enddo |
---|
| 890 | C |
---|
| 891 | if (child % var % interpIndex |
---|
| 892 | & /= Agrif_Curgrid % parent % ngridstep .OR. |
---|
| 893 | & child%var%Interpolationshouldbemade ) then |
---|
| 894 | C |
---|
| 895 | C Space interpolation |
---|
| 896 | C |
---|
| 897 | kindex = 1 |
---|
| 898 | C |
---|
| 899 | do nb = 1,nbdim |
---|
| 900 | C |
---|
| 901 | do ndir = 1,2 |
---|
| 902 | C |
---|
| 903 | if (loctab_child(nb) /= (-ndir) |
---|
| 904 | & .AND. loctab_child(nb) /= -3) then |
---|
| 905 | C |
---|
| 906 | IF (present(procname)) THEN |
---|
| 907 | Call Agrif_InterpnD |
---|
| 908 | & (TYPEInterp,parent,child, |
---|
| 909 | & ptres(1:nbdim,1,ndir,nb),ptres(1:nbdim,2,ndir,nb), |
---|
| 910 | & pttab_child(1:nbdim),pttab_Parent(1:nbdim), |
---|
| 911 | & s_Child(1:nbdim),s_Parent(1:nbdim), |
---|
| 912 | & ds_Child(1:nbdim),ds_Parent(1:nbdim), |
---|
| 913 | & restore,.FALSE.,nbdim,procname) |
---|
| 914 | ELSE |
---|
| 915 | Call Agrif_InterpnD |
---|
| 916 | & (TYPEInterp,parent,child, |
---|
| 917 | & ptres(1:nbdim,1,ndir,nb),ptres(1:nbdim,2,ndir,nb), |
---|
| 918 | & pttab_child(1:nbdim),pttab_Parent(1:nbdim), |
---|
| 919 | & s_Child(1:nbdim),s_Parent(1:nbdim), |
---|
| 920 | & ds_Child(1:nbdim),ds_Parent(1:nbdim), |
---|
| 921 | & restore,.FALSE.,nbdim) |
---|
| 922 | ENDIF |
---|
| 923 | |
---|
| 924 | IF (.NOT. child%var%interpolationshouldbemade) THEN |
---|
| 925 | C |
---|
| 926 | C Safeguard of the values of the grid variable (at times n and n+1 |
---|
| 927 | C on the parent grid) |
---|
| 928 | C |
---|
| 929 | sizetab = 1 |
---|
| 930 | C |
---|
| 931 | do i = 1,nbdim |
---|
| 932 | C |
---|
| 933 | sizetab = sizetab |
---|
| 934 | & * (ptres2(i,2,ndir,nb)-ptres2(i,1,ndir,nb)+1) |
---|
| 935 | C |
---|
| 936 | enddo |
---|
| 937 | C |
---|
| 938 | allocate(tab(sizetab)) |
---|
| 939 | C |
---|
| 940 | Call Agrif_vector2array( |
---|
| 941 | & tab,child%var, |
---|
| 942 | & ptres2(:,:,ndir,nb), |
---|
| 943 | & nbdim) |
---|
| 944 | |
---|
| 945 | C |
---|
| 946 | Call saveAfterInterp |
---|
| 947 | & (child,tab,kindex) |
---|
| 948 | C |
---|
| 949 | C |
---|
| 950 | deallocate(tab) |
---|
| 951 | ENDIF |
---|
| 952 | C |
---|
| 953 | endif |
---|
| 954 | C |
---|
| 955 | enddo |
---|
| 956 | C |
---|
| 957 | enddo |
---|
| 958 | C |
---|
| 959 | C |
---|
| 960 | child % var % interpIndex = Agrif_Curgrid % parent % ngridstep |
---|
| 961 | C |
---|
| 962 | C |
---|
| 963 | endif |
---|
| 964 | |
---|
| 965 | IF (.NOT. child%var%interpolationshouldbemade) THEN |
---|
| 966 | C |
---|
| 967 | C |
---|
| 968 | C Calculation of the coefficients c1t and c2t for the temporary |
---|
| 969 | C interpolation |
---|
| 970 | if (pweight) then |
---|
| 971 | C |
---|
| 972 | c1t = weight |
---|
| 973 | C |
---|
| 974 | else |
---|
| 975 | C |
---|
| 976 | c1t = (REAL(AGRIF_Nbstepint()) + 1.) / Agrif_Rhot() |
---|
| 977 | C |
---|
| 978 | endif |
---|
| 979 | C |
---|
| 980 | c2t = 1. - c1t |
---|
| 981 | C |
---|
| 982 | C Time interpolation |
---|
| 983 | C |
---|
| 984 | kindex = 1 |
---|
| 985 | C |
---|
| 986 | do nb = 1,nbdim |
---|
| 987 | C |
---|
| 988 | do ndir = 1,2 |
---|
| 989 | C |
---|
| 990 | if (loctab_child(nb) /= (-ndir) |
---|
| 991 | & .AND. loctab_child(nb) /= -3) then |
---|
| 992 | C |
---|
| 993 | sizetab=1 |
---|
| 994 | C |
---|
| 995 | do i = 1,nbdim |
---|
| 996 | C |
---|
| 997 | sizetab = sizetab |
---|
| 998 | & * (ptres2(i,2,ndir,nb)-ptres2(i,1,ndir,nb)+1) |
---|
| 999 | C |
---|
| 1000 | enddo |
---|
| 1001 | C |
---|
| 1002 | allocate(tab(sizetab)) |
---|
| 1003 | C |
---|
| 1004 | Call Agrif_vector2array( |
---|
| 1005 | & tab,child%var, |
---|
| 1006 | & ptres2(:,:,ndir,nb), |
---|
| 1007 | & nbdim) |
---|
| 1008 | C |
---|
| 1009 | C |
---|
| 1010 | Call timeInterpolation |
---|
| 1011 | & (child,tab,kindex,c1t,c2t) |
---|
| 1012 | C |
---|
| 1013 | C |
---|
| 1014 | Call Agrif_array2vector( |
---|
| 1015 | & child%var, |
---|
| 1016 | & ptres2(:,:,ndir,nb), |
---|
| 1017 | & tab,nbdim) |
---|
| 1018 | C |
---|
| 1019 | C |
---|
| 1020 | deallocate(tab) |
---|
| 1021 | C |
---|
| 1022 | endif |
---|
| 1023 | C |
---|
| 1024 | enddo |
---|
| 1025 | C |
---|
| 1026 | enddo |
---|
| 1027 | C |
---|
| 1028 | |
---|
| 1029 | ENDIF |
---|
| 1030 | C |
---|
| 1031 | End Subroutine Agrif_Correctnd |
---|
| 1032 | C |
---|
| 1033 | C |
---|
| 1034 | C ************************************************************************** |
---|
| 1035 | CCC Subroutine saveAfterInterp |
---|
| 1036 | C ************************************************************************** |
---|
| 1037 | C |
---|
| 1038 | Subroutine saveAfterInterp(child,tab,kindex) |
---|
| 1039 | C |
---|
| 1040 | CCC Descritpion: |
---|
| 1041 | CCC Subroutine used to save the values of the grid variable on the fine grid |
---|
| 1042 | CCC after the space interpolation. |
---|
| 1043 | C |
---|
| 1044 | C Declarations: |
---|
| 1045 | C |
---|
| 1046 | |
---|
| 1047 | C |
---|
| 1048 | C argument |
---|
| 1049 | TYPE (AGRIF_PVariable) :: child ! The fine grid variable |
---|
| 1050 | REAL, DIMENSION(:) :: tab ! Values on the fine grid variable |
---|
| 1051 | ! after the space interpolation |
---|
| 1052 | INTEGER :: kindex ! Index indicating where this safeguard |
---|
| 1053 | ! is done on the fine grid |
---|
| 1054 | C |
---|
| 1055 | C Local scalars |
---|
| 1056 | INTEGER :: newsize ! Size of the domain where boundary |
---|
| 1057 | ! conditions are calculated |
---|
| 1058 | INTEGER :: i |
---|
| 1059 | C |
---|
| 1060 | C |
---|
| 1061 | C Allocation of the array oldvalues2d |
---|
| 1062 | newsize = size(tab) |
---|
| 1063 | C |
---|
| 1064 | if (newsize .LE. 0) return |
---|
| 1065 | C |
---|
| 1066 | Call checkSize |
---|
| 1067 | & (child,kindex+newsize) |
---|
| 1068 | C |
---|
| 1069 | C |
---|
| 1070 | C Safeguard in the oldvalues2d array |
---|
| 1071 | C |
---|
| 1072 | if (child % var % interpIndex |
---|
| 1073 | & /= Agrif_Curgrid % parent % ngridstep ) then |
---|
| 1074 | do i = 1,newsize |
---|
| 1075 | child % var % oldvalues2d(kindex,1) = child % var % |
---|
| 1076 | & oldvalues2d(kindex,2) |
---|
| 1077 | child % var % oldvalues2d(kindex,2) = tab(i) |
---|
| 1078 | kindex = kindex + 1 |
---|
| 1079 | enddo |
---|
| 1080 | else |
---|
| 1081 | do i = 1,newsize |
---|
| 1082 | child % var % oldvalues2d(kindex,2) = tab(i) |
---|
| 1083 | kindex = kindex + 1 |
---|
| 1084 | enddo |
---|
| 1085 | endif |
---|
| 1086 | |
---|
| 1087 | |
---|
| 1088 | C |
---|
| 1089 | C |
---|
| 1090 | End subroutine saveAfterInterp |
---|
| 1091 | C |
---|
| 1092 | C |
---|
| 1093 | C |
---|
| 1094 | C ************************************************************************** |
---|
| 1095 | CCC Subroutine timeInterpolation |
---|
| 1096 | C ************************************************************************** |
---|
| 1097 | C |
---|
| 1098 | Subroutine timeInterpolation(child,tab,kindex,c1t,c2t) |
---|
| 1099 | C |
---|
| 1100 | CCC Descritpion: |
---|
| 1101 | CCC Subroutine for a linear time interpolation on the child grid. |
---|
| 1102 | C |
---|
| 1103 | C Declarations: |
---|
| 1104 | C |
---|
| 1105 | |
---|
| 1106 | C |
---|
| 1107 | C argument |
---|
| 1108 | TYPE (AGRIF_PVariable) :: child ! The fine grid variable |
---|
| 1109 | REAL, DIMENSION(:) :: tab |
---|
| 1110 | INTEGER :: kindex ! Index indicating the values of the fine |
---|
| 1111 | ! grid got before and after the space |
---|
| 1112 | ! interpolation and used for the time |
---|
| 1113 | ! interpolation |
---|
| 1114 | REAL :: c1t,c2t! coefficients for the time interpolation |
---|
| 1115 | ! (c2t=1-c1t) |
---|
| 1116 | C |
---|
| 1117 | C Local aruments |
---|
| 1118 | INTEGER :: i |
---|
| 1119 | C |
---|
| 1120 | C |
---|
| 1121 | do i = 1,size(tab) |
---|
| 1122 | tab(i) = c2t*child % var % oldvalues2d(kindex,1) |
---|
| 1123 | & + c1t*child % var % oldvalues2d(kindex,2) |
---|
| 1124 | kindex = kindex + 1 |
---|
| 1125 | enddo |
---|
| 1126 | C |
---|
| 1127 | C |
---|
| 1128 | End subroutine timeInterpolation |
---|
| 1129 | C |
---|
| 1130 | C |
---|
| 1131 | C |
---|
| 1132 | C ************************************************************************** |
---|
| 1133 | CCC Subroutine checkSize |
---|
| 1134 | C ************************************************************************** |
---|
| 1135 | C |
---|
| 1136 | Subroutine checkSize(child,newsize) |
---|
| 1137 | C |
---|
| 1138 | CCC Descritpion: |
---|
| 1139 | CCC Subroutine used in the saveAfterInterp procedure to allocate the |
---|
| 1140 | CCC oldvalues2d array. |
---|
| 1141 | C |
---|
| 1142 | C Declarations: |
---|
| 1143 | C |
---|
| 1144 | |
---|
| 1145 | C |
---|
| 1146 | C TYPE argument |
---|
| 1147 | TYPE (AGRIF_PVariable) :: child ! The fine grid variable |
---|
| 1148 | C |
---|
| 1149 | C Scalar arguments |
---|
| 1150 | INTEGER :: newsize ! Size of the domains where the boundary |
---|
| 1151 | ! conditions are calculated |
---|
| 1152 | C |
---|
| 1153 | C Local arrays |
---|
| 1154 | REAL, DIMENSION(:,:), Allocatable :: tempoldvalues ! Temporary array |
---|
| 1155 | C |
---|
| 1156 | C |
---|
| 1157 | if (.NOT. associated(child % var % oldvalues2d)) then |
---|
| 1158 | C |
---|
| 1159 | allocate(child % var % oldvalues2d(newsize,2)) |
---|
| 1160 | C |
---|
| 1161 | child % var % oldvalues2d=0. |
---|
| 1162 | C |
---|
| 1163 | else |
---|
| 1164 | C |
---|
| 1165 | if (SIZE(child % var % oldvalues2d,1) < newsize) then |
---|
| 1166 | C |
---|
| 1167 | allocate(tempoldvalues(SIZE(child % var % |
---|
| 1168 | & oldvalues2d,1),2)) |
---|
| 1169 | C |
---|
| 1170 | tempoldvalues = child % var % oldvalues2d |
---|
| 1171 | C |
---|
| 1172 | deallocate(child % var % oldvalues2d) |
---|
| 1173 | C |
---|
| 1174 | allocate(child % var % oldvalues2d(newsize,2)) |
---|
| 1175 | C |
---|
| 1176 | child%var%oldvalues2d=0. |
---|
| 1177 | C |
---|
| 1178 | child % var % oldvalues2d(1:SIZE(tempoldvalues,1),:) = |
---|
| 1179 | & tempoldvalues(:,:) |
---|
| 1180 | C |
---|
| 1181 | deallocate(tempoldvalues) |
---|
| 1182 | C |
---|
| 1183 | endif |
---|
| 1184 | C |
---|
| 1185 | endif |
---|
| 1186 | C |
---|
| 1187 | C |
---|
| 1188 | End Subroutine checkSize |
---|
| 1189 | C |
---|
| 1190 | C |
---|
| 1191 | C |
---|
| 1192 | C |
---|
| 1193 | End Module AGRIF_boundary |
---|
| 1194 | |
---|