[4777] | 1 | ! |
---|
| 2 | ! $Id$ |
---|
| 3 | ! |
---|
| 4 | ! AGRIF (Adaptive Grid Refinement In Fortran) |
---|
| 5 | ! |
---|
| 6 | ! Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr) |
---|
| 7 | ! Christophe Vouland (Christophe.Vouland@imag.fr) |
---|
| 8 | ! |
---|
| 9 | ! This program is free software; you can redistribute it and/or modify |
---|
| 10 | ! it under the terms of the GNU General Public License as published by |
---|
| 11 | ! the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | ! (at your option) any later version. |
---|
| 13 | ! |
---|
| 14 | ! This program is distributed in the hope that it will be useful, |
---|
| 15 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | ! GNU General Public License for more details. |
---|
| 18 | ! |
---|
| 19 | ! You should have received a copy of the GNU General Public License |
---|
| 20 | ! along with this program; if not, write to the Free Software |
---|
| 21 | ! Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | ! |
---|
| 23 | !> Module to define some procedures concerning the current grid |
---|
| 24 | ! |
---|
| 25 | module Agrif_CurgridFunctions |
---|
| 26 | ! |
---|
| 27 | use Agrif_Init |
---|
| 28 | ! |
---|
| 29 | implicit none |
---|
| 30 | ! |
---|
[13027] | 31 | |
---|
| 32 | interface Agrif_Parent |
---|
| 33 | module procedure Agrif_Parent_Real_4, & |
---|
| 34 | Agrif_Parent_Real_8, & |
---|
| 35 | Agrif_Parent_Array2_Real_8, & |
---|
| 36 | Agrif_Parent_Integer, & |
---|
| 37 | Agrif_Parent_Character, & |
---|
| 38 | Agrif_Parent_Logical |
---|
| 39 | end interface |
---|
| 40 | interface Agrif_Child |
---|
| 41 | module procedure Agrif_Child_Logical |
---|
| 42 | end interface |
---|
| 43 | |
---|
[4777] | 44 | contains |
---|
| 45 | ! |
---|
| 46 | !=================================================================================================== |
---|
| 47 | ! function Agrif_rel_dt |
---|
| 48 | ! |
---|
| 49 | !> Returns the time step of the current grid, relatively to the root grid (for which dt=1.). |
---|
| 50 | !--------------------------------------------------------------------------------------------------- |
---|
| 51 | function Agrif_rel_dt ( ) result( rel_dt ) |
---|
| 52 | !--------------------------------------------------------------------------------------------------- |
---|
| 53 | integer :: i |
---|
| 54 | real :: rel_dt |
---|
| 55 | ! |
---|
| 56 | rel_dt = 1. |
---|
| 57 | ! |
---|
| 58 | do i = 1,Agrif_Probdim |
---|
| 59 | rel_dt = min(rel_dt, Agrif_Curgrid % Agrif_dt(i)) |
---|
| 60 | enddo |
---|
| 61 | !--------------------------------------------------------------------------------------------------- |
---|
| 62 | end function Agrif_rel_dt |
---|
| 63 | !=================================================================================================== |
---|
| 64 | ! |
---|
| 65 | !=================================================================================================== |
---|
| 66 | ! function Agrif_rel_idt |
---|
| 67 | ! |
---|
| 68 | !> Returns the time refinement factor of the current grid, relatively to the root grid (for which idt=1). |
---|
| 69 | !--------------------------------------------------------------------------------------------------- |
---|
| 70 | function Agrif_rel_idt ( ) result( rel_idt ) |
---|
| 71 | !--------------------------------------------------------------------------------------------------- |
---|
| 72 | integer :: rel_idt |
---|
| 73 | ! |
---|
| 74 | rel_idt = nint(1./Agrif_rel_dt()) |
---|
| 75 | !--------------------------------------------------------------------------------------------------- |
---|
| 76 | end function Agrif_rel_idt |
---|
| 77 | !=================================================================================================== |
---|
| 78 | ! |
---|
| 79 | !=================================================================================================== |
---|
| 80 | ! function Agrif_IRhot |
---|
| 81 | ! |
---|
| 82 | !> Returns the time refinement factor of the current grid. |
---|
| 83 | !--------------------------------------------------------------------------------------------------- |
---|
| 84 | function Agrif_IRhot ( ) result( irhot ) |
---|
| 85 | !--------------------------------------------------------------------------------------------------- |
---|
| 86 | integer :: i, irhot |
---|
| 87 | ! |
---|
| 88 | irhot = 1 |
---|
| 89 | ! |
---|
| 90 | do i = 1,Agrif_Probdim |
---|
| 91 | irhot = max(irhot, Agrif_Curgrid % timeref(i)) |
---|
| 92 | enddo |
---|
| 93 | !--------------------------------------------------------------------------------------------------- |
---|
| 94 | end function Agrif_IRhot |
---|
| 95 | !=================================================================================================== |
---|
| 96 | ! |
---|
| 97 | !=================================================================================================== |
---|
| 98 | ! function Agrif_Rhot |
---|
| 99 | ! |
---|
| 100 | !> Returns the time refinement factor of the current grid. |
---|
| 101 | !--------------------------------------------------------------------------------------------------- |
---|
| 102 | function Agrif_Rhot ( ) result( rhot ) |
---|
| 103 | !--------------------------------------------------------------------------------------------------- |
---|
| 104 | real :: rhot |
---|
| 105 | ! |
---|
| 106 | rhot = float(Agrif_IRhot()) |
---|
| 107 | !--------------------------------------------------------------------------------------------------- |
---|
| 108 | end function Agrif_Rhot |
---|
| 109 | !=================================================================================================== |
---|
| 110 | ! |
---|
| 111 | !=================================================================================================== |
---|
| 112 | ! function Agrif_Parent_IRhot |
---|
| 113 | ! |
---|
| 114 | !> Returns the time refinement factor of the parent of the current grid. |
---|
| 115 | !--------------------------------------------------------------------------------------------------- |
---|
| 116 | function Agrif_Parent_IRhot ( ) result( irhot ) |
---|
| 117 | !--------------------------------------------------------------------------------------------------- |
---|
| 118 | integer :: i, irhot |
---|
| 119 | ! |
---|
| 120 | irhot = 1 |
---|
| 121 | ! |
---|
| 122 | do i = 1,Agrif_Probdim |
---|
| 123 | irhot = max(irhot, Agrif_Curgrid % parent % timeref(i)) |
---|
| 124 | enddo |
---|
| 125 | !--------------------------------------------------------------------------------------------------- |
---|
| 126 | end function Agrif_Parent_IRhot |
---|
| 127 | !=================================================================================================== |
---|
| 128 | ! |
---|
| 129 | !=================================================================================================== |
---|
| 130 | ! function Agrif_Parent_Rhot |
---|
| 131 | ! |
---|
| 132 | !> Returns the time refinement factor of the parent of the current grid. |
---|
| 133 | !--------------------------------------------------------------------------------------------------- |
---|
| 134 | function Agrif_Parent_Rhot ( ) result( rhot ) |
---|
| 135 | !--------------------------------------------------------------------------------------------------- |
---|
| 136 | real :: rhot |
---|
| 137 | ! |
---|
| 138 | rhot = float(Agrif_Parent_IRhot()) |
---|
| 139 | !--------------------------------------------------------------------------------------------------- |
---|
| 140 | end function Agrif_Parent_Rhot |
---|
| 141 | !=================================================================================================== |
---|
| 142 | ! |
---|
| 143 | !=================================================================================================== |
---|
| 144 | ! function Agrif_Nbstepint |
---|
| 145 | ! |
---|
| 146 | !> function for the calculation of the coefficients used for the time interpolation |
---|
| 147 | !! (module #Agrif_Boundary). |
---|
| 148 | !--------------------------------------------------------------------------------------------------- |
---|
| 149 | function Agrif_Nbstepint ( ) |
---|
| 150 | !--------------------------------------------------------------------------------------------------- |
---|
| 151 | integer :: Agrif_nbstepint ! result |
---|
| 152 | ! |
---|
| 153 | Agrif_nbstepint = mod(Agrif_Curgrid % ngridstep, Agrif_iRhot()) |
---|
| 154 | !--------------------------------------------------------------------------------------------------- |
---|
| 155 | end function Agrif_Nbstepint |
---|
| 156 | !=================================================================================================== |
---|
| 157 | ! |
---|
| 158 | !=================================================================================================== |
---|
| 159 | ! function Agrif_Parent_Nbstepint |
---|
| 160 | ! |
---|
| 161 | !> function for the calculation of the coefficients used for the time interpolation |
---|
| 162 | !! (module #Agrif_Boundary). |
---|
| 163 | !--------------------------------------------------------------------------------------------------- |
---|
| 164 | function Agrif_Parent_Nbstepint ( ) |
---|
| 165 | !--------------------------------------------------------------------------------------------------- |
---|
| 166 | integer :: Agrif_Parent_Nbstepint ! result |
---|
| 167 | ! |
---|
| 168 | Agrif_Parent_Nbstepint = mod(Agrif_Curgrid % parent % ngridstep, int(Agrif_Parent_Rhot())) |
---|
| 169 | !--------------------------------------------------------------------------------------------------- |
---|
| 170 | end function Agrif_Parent_Nbstepint |
---|
| 171 | !=================================================================================================== |
---|
| 172 | ! |
---|
| 173 | !=================================================================================================== |
---|
| 174 | ! subroutine Agrif_InterpNearBorderX |
---|
| 175 | ! |
---|
| 176 | !> Allows to interpolate (in the x direction) on a near border of the current grid if this one |
---|
| 177 | !! has a common border with the root coarse grid. |
---|
| 178 | !--------------------------------------------------------------------------------------------------- |
---|
| 179 | subroutine Agrif_InterpNearBorderX ( ) |
---|
| 180 | !--------------------------------------------------------------------------------------------------- |
---|
| 181 | Agrif_Curgrid % NearRootBorder(1) = .FALSE. |
---|
| 182 | !--------------------------------------------------------------------------------------------------- |
---|
| 183 | end subroutine Agrif_InterpNearBorderX |
---|
| 184 | !=================================================================================================== |
---|
| 185 | ! |
---|
| 186 | !=================================================================================================== |
---|
| 187 | ! subroutine Agrif_InterpDistantBorderX |
---|
| 188 | ! |
---|
| 189 | !> Allows to interpolate (in the x direction) on a distant border of the current grid if this one |
---|
| 190 | !! has a common border with the root coarse grid. |
---|
| 191 | !--------------------------------------------------------------------------------------------------- |
---|
| 192 | subroutine Agrif_InterpDistantBorderX ( ) |
---|
| 193 | !--------------------------------------------------------------------------------------------------- |
---|
| 194 | Agrif_Curgrid % DistantRootBorder(1) = .FALSE. |
---|
| 195 | !--------------------------------------------------------------------------------------------------- |
---|
| 196 | end subroutine Agrif_InterpDistantBorderX |
---|
| 197 | !=================================================================================================== |
---|
| 198 | ! |
---|
| 199 | !=================================================================================================== |
---|
| 200 | ! subroutine Agrif_InterpNearBorderY |
---|
| 201 | ! |
---|
| 202 | !> Allows to interpolate (in the y direction) on a near border of the current grid if this one |
---|
| 203 | !! has a common border with the root coarse grid. |
---|
| 204 | !--------------------------------------------------------------------------------------------------- |
---|
| 205 | subroutine Agrif_InterpNearBorderY ( ) |
---|
| 206 | !--------------------------------------------------------------------------------------------------- |
---|
| 207 | Agrif_Curgrid % NearRootBorder(2) = .FALSE. |
---|
| 208 | !--------------------------------------------------------------------------------------------------- |
---|
| 209 | end subroutine Agrif_InterpNearBorderY |
---|
| 210 | !=================================================================================================== |
---|
| 211 | ! |
---|
| 212 | !=================================================================================================== |
---|
| 213 | ! subroutine Agrif_InterpDistantBorderY |
---|
| 214 | ! |
---|
| 215 | !> Allows to interpolate (in the y direction) on a distant border of the current grid if this one |
---|
| 216 | !! has a common border with the root coarse grid. |
---|
| 217 | !--------------------------------------------------------------------------------------------------- |
---|
| 218 | subroutine Agrif_InterpDistantBorderY ( ) |
---|
| 219 | !--------------------------------------------------------------------------------------------------- |
---|
| 220 | Agrif_Curgrid % DistantRootBorder(2) = .FALSE. |
---|
| 221 | !--------------------------------------------------------------------------------------------------- |
---|
| 222 | end subroutine Agrif_InterpDistantBorderY |
---|
| 223 | !=================================================================================================== |
---|
| 224 | ! |
---|
| 225 | !=================================================================================================== |
---|
| 226 | ! subroutine Agrif_InterpNearBorderZ |
---|
| 227 | ! |
---|
| 228 | !> Allows to interpolate (in the z direction) on a near border of the current grid if this one |
---|
| 229 | !! has a common border with the root coarse grid. |
---|
| 230 | !--------------------------------------------------------------------------------------------------- |
---|
| 231 | subroutine Agrif_InterpNearBorderZ ( ) |
---|
| 232 | !--------------------------------------------------------------------------------------------------- |
---|
| 233 | Agrif_Curgrid % NearRootBorder(3) = .FALSE. |
---|
| 234 | !--------------------------------------------------------------------------------------------------- |
---|
| 235 | end subroutine Agrif_InterpNearBorderZ |
---|
| 236 | !=================================================================================================== |
---|
| 237 | ! |
---|
| 238 | !=================================================================================================== |
---|
| 239 | ! subroutine Agrif_InterpDistantBorderZ |
---|
| 240 | ! |
---|
| 241 | !> Allows to interpolate (in the z direction) on a distant border of the current grid if this one |
---|
| 242 | !! has a common border with the root coarse grid. |
---|
| 243 | !--------------------------------------------------------------------------------------------------- |
---|
| 244 | subroutine Agrif_InterpDistantBorderZ() |
---|
| 245 | !--------------------------------------------------------------------------------------------------- |
---|
| 246 | Agrif_Curgrid % DistantRootBorder(3) = .FALSE. |
---|
| 247 | !--------------------------------------------------------------------------------------------------- |
---|
| 248 | end subroutine Agrif_InterpDistantBorderZ |
---|
| 249 | !=================================================================================================== |
---|
| 250 | ! |
---|
| 251 | !=================================================================================================== |
---|
| 252 | ! function Agrif_Parent_Nb_Step |
---|
| 253 | ! |
---|
| 254 | !> Returns the number of time steps of the parent of the current grid. |
---|
| 255 | !--------------------------------------------------------------------------------------------------- |
---|
| 256 | function Agrif_Parent_Nb_Step ( ) |
---|
| 257 | !--------------------------------------------------------------------------------------------------- |
---|
| 258 | integer :: Agrif_Parent_Nb_Step ! Result |
---|
| 259 | ! |
---|
| 260 | if (Agrif_Root()) then |
---|
| 261 | Agrif_Parent_Nb_Step = -1 |
---|
| 262 | else |
---|
| 263 | Agrif_Parent_Nb_Step = Agrif_Curgrid % parent % ngridstep |
---|
| 264 | endif |
---|
| 265 | !--------------------------------------------------------------------------------------------------- |
---|
| 266 | end function Agrif_Parent_Nb_Step |
---|
| 267 | !=================================================================================================== |
---|
| 268 | ! |
---|
| 269 | !=================================================================================================== |
---|
| 270 | ! function Agrif_Root |
---|
| 271 | ! |
---|
| 272 | !> Indicates if the current grid is or not the root grid. |
---|
| 273 | !--------------------------------------------------------------------------------------------------- |
---|
| 274 | function Agrif_Root ( ) |
---|
| 275 | !--------------------------------------------------------------------------------------------------- |
---|
| 276 | logical :: Agrif_Root ! Result |
---|
| 277 | ! |
---|
| 278 | Agrif_Root = (Agrif_Curgrid % fixedrank == 0) |
---|
| 279 | !--------------------------------------------------------------------------------------------------- |
---|
| 280 | end function Agrif_Root |
---|
| 281 | !=================================================================================================== |
---|
| 282 | ! |
---|
| 283 | !=================================================================================================== |
---|
| 284 | ! function Agrif_GrandMother |
---|
| 285 | ! |
---|
| 286 | !> Indicates if the current grid is or not the root grid. |
---|
| 287 | !--------------------------------------------------------------------------------------------------- |
---|
| 288 | function Agrif_GrandMother ( ) |
---|
| 289 | !--------------------------------------------------------------------------------------------------- |
---|
| 290 | logical :: Agrif_GrandMother ! Result |
---|
| 291 | ! |
---|
| 292 | Agrif_GrandMother = Agrif_Curgrid % grand_mother_grid |
---|
| 293 | !--------------------------------------------------------------------------------------------------- |
---|
| 294 | end function Agrif_GrandMother |
---|
| 295 | !=================================================================================================== |
---|
| 296 | ! |
---|
| 297 | !=================================================================================================== |
---|
| 298 | ! function Agrif_Parent_Root |
---|
| 299 | ! |
---|
| 300 | !> Indicates if the parent of the current grid is or not the root grid. |
---|
| 301 | !--------------------------------------------------------------------------------------------------- |
---|
| 302 | function Agrif_Parent_Root ( ) |
---|
| 303 | !--------------------------------------------------------------------------------------------------- |
---|
| 304 | logical :: Agrif_Parent_Root ! Result |
---|
| 305 | ! |
---|
| 306 | Agrif_Parent_Root = (Agrif_Curgrid % parent % fixedrank == 0) |
---|
| 307 | !--------------------------------------------------------------------------------------------------- |
---|
| 308 | end function Agrif_Parent_Root |
---|
| 309 | !=================================================================================================== |
---|
| 310 | ! |
---|
| 311 | !=================================================================================================== |
---|
| 312 | ! function Agrif_Fixed |
---|
| 313 | ! |
---|
| 314 | !> Returns the number of the current grid. |
---|
| 315 | !--------------------------------------------------------------------------------------------------- |
---|
| 316 | function Agrif_Fixed ( ) |
---|
| 317 | !--------------------------------------------------------------------------------------------------- |
---|
| 318 | integer :: Agrif_Fixed ! Result |
---|
| 319 | ! |
---|
| 320 | if (Agrif_Curgrid % fixed) then |
---|
| 321 | Agrif_Fixed = Agrif_Curgrid % fixedrank |
---|
| 322 | else |
---|
| 323 | Agrif_Fixed = -1 |
---|
| 324 | endif |
---|
| 325 | !--------------------------------------------------------------------------------------------------- |
---|
| 326 | end function Agrif_Fixed |
---|
| 327 | !=================================================================================================== |
---|
| 328 | ! |
---|
| 329 | !=================================================================================================== |
---|
| 330 | ! function Agrif_Parent_Fixed |
---|
| 331 | ! |
---|
| 332 | !> Returns the number of the parent of the current grid. |
---|
| 333 | !--------------------------------------------------------------------------------------------------- |
---|
| 334 | function Agrif_Parent_Fixed ( ) |
---|
| 335 | !--------------------------------------------------------------------------------------------------- |
---|
| 336 | integer :: Agrif_Parent_Fixed ! Result |
---|
| 337 | ! |
---|
| 338 | if (Agrif_Curgrid % parent % fixed) then |
---|
| 339 | Agrif_Parent_Fixed = Agrif_Curgrid % parent % fixedrank |
---|
| 340 | else |
---|
| 341 | Agrif_Parent_Fixed = 0 |
---|
| 342 | endif |
---|
| 343 | !--------------------------------------------------------------------------------------------------- |
---|
| 344 | end function Agrif_Parent_Fixed |
---|
| 345 | !=================================================================================================== |
---|
| 346 | ! |
---|
| 347 | !=================================================================================================== |
---|
| 348 | ! function Agrif_Is_Fixed |
---|
| 349 | ! |
---|
| 350 | !> Returns .TRUE. if the current grid is fixed. |
---|
| 351 | !--------------------------------------------------------------------------------------------------- |
---|
| 352 | function Agrif_Is_Fixed ( ) |
---|
| 353 | !--------------------------------------------------------------------------------------------------- |
---|
| 354 | logical :: Agrif_Is_Fixed ! Result |
---|
| 355 | ! |
---|
| 356 | Agrif_Is_Fixed = Agrif_Curgrid % fixed |
---|
| 357 | !--------------------------------------------------------------------------------------------------- |
---|
| 358 | end function Agrif_Is_Fixed |
---|
| 359 | !=================================================================================================== |
---|
| 360 | ! |
---|
| 361 | !=================================================================================================== |
---|
| 362 | ! function Agrif_Parent_Is_Fixed |
---|
| 363 | ! |
---|
| 364 | !> Returns .TRUE. if the parent of the current grid is fixed. |
---|
| 365 | !--------------------------------------------------------------------------------------------------- |
---|
| 366 | function Agrif_Parent_Is_Fixed ( ) |
---|
| 367 | !--------------------------------------------------------------------------------------------------- |
---|
| 368 | logical :: Agrif_Parent_Is_Fixed ! Result |
---|
| 369 | ! |
---|
| 370 | Agrif_Parent_Is_Fixed = Agrif_Curgrid % parent % fixed |
---|
| 371 | !--------------------------------------------------------------------------------------------------- |
---|
| 372 | end function Agrif_Parent_Is_Fixed |
---|
| 373 | !=================================================================================================== |
---|
| 374 | ! |
---|
| 375 | !=================================================================================================== |
---|
| 376 | ! function Agrif_CFixed |
---|
| 377 | ! |
---|
| 378 | !> Returns the number of the current grid. |
---|
| 379 | !--------------------------------------------------------------------------------------------------- |
---|
| 380 | function Agrif_CFixed ( ) |
---|
| 381 | !--------------------------------------------------------------------------------------------------- |
---|
| 382 | character(3) :: Agrif_CFixed ! Result |
---|
| 383 | ! |
---|
| 384 | character(3) :: cfixed |
---|
| 385 | integer :: fixed |
---|
| 386 | ! |
---|
| 387 | fixed = Agrif_Fixed() |
---|
| 388 | ! |
---|
| 389 | if (fixed /= -1) then |
---|
| 390 | ! |
---|
| 391 | if (fixed <= 9) then |
---|
| 392 | write(cfixed,'(i1)') fixed |
---|
| 393 | else |
---|
| 394 | write(cfixed,'(i2)') fixed |
---|
| 395 | endif |
---|
| 396 | ! |
---|
| 397 | Agrif_CFixed = cfixed |
---|
| 398 | |
---|
| 399 | if (associated(agrif_curgrid,agrif_coarsegrid)) then |
---|
| 400 | Agrif_CFixed = 'gm' |
---|
| 401 | endif |
---|
| 402 | ! |
---|
| 403 | else |
---|
| 404 | print*,'Call to Agrif_CFixed() on a moving grid' |
---|
| 405 | stop |
---|
| 406 | endif |
---|
| 407 | !--------------------------------------------------------------------------------------------------- |
---|
| 408 | end function Agrif_CFixed |
---|
| 409 | !=================================================================================================== |
---|
| 410 | ! |
---|
| 411 | !=================================================================================================== |
---|
| 412 | ! function Agrid_Parent_CFixed |
---|
| 413 | ! |
---|
| 414 | !> Returns the number of the parent of the current grid. |
---|
| 415 | !--------------------------------------------------------------------------------------------------- |
---|
| 416 | function Agrid_Parent_CFixed ( ) |
---|
| 417 | !--------------------------------------------------------------------------------------------------- |
---|
| 418 | character(3) :: Agrid_Parent_CFixed ! Result |
---|
| 419 | ! |
---|
| 420 | character(3) :: cfixed |
---|
| 421 | integer :: fixed |
---|
| 422 | ! |
---|
| 423 | fixed = Agrif_Parent_Fixed() |
---|
| 424 | ! |
---|
| 425 | if(fixed /= -1) then |
---|
| 426 | ! |
---|
| 427 | if (fixed <= 9) then |
---|
| 428 | write(cfixed,'(i1)')fixed |
---|
| 429 | else |
---|
| 430 | write(cfixed,'(i2)')fixed |
---|
| 431 | endif |
---|
| 432 | ! |
---|
| 433 | Agrid_Parent_CFixed=cfixed |
---|
| 434 | ! |
---|
| 435 | else |
---|
| 436 | print*,'Illegal call to Agrid_Parent_CFixed()' |
---|
| 437 | stop |
---|
| 438 | endif |
---|
| 439 | !--------------------------------------------------------------------------------------------------- |
---|
| 440 | end function Agrid_Parent_CFixed |
---|
| 441 | !=================================================================================================== |
---|
| 442 | ! |
---|
| 443 | !=================================================================================================== |
---|
| 444 | ! subroutine Agrif_ChildGrid_to_ParentGrid |
---|
| 445 | ! |
---|
| 446 | !> Make the pointer #Agrif_Curgrid point on the parent grid of the current grid. |
---|
| 447 | !--------------------------------------------------------------------------------------------------- |
---|
| 448 | subroutine Agrif_ChildGrid_to_ParentGrid ( ) |
---|
| 449 | !--------------------------------------------------------------------------------------------------- |
---|
| 450 | Agrif_Curgrid % parent % save_grid => Agrif_Curgrid |
---|
| 451 | call Agrif_Instance(Agrif_Curgrid%parent) |
---|
| 452 | !--------------------------------------------------------------------------------------------------- |
---|
| 453 | end subroutine Agrif_ChildGrid_to_ParentGrid |
---|
| 454 | !=================================================================================================== |
---|
| 455 | ! |
---|
| 456 | !=================================================================================================== |
---|
| 457 | ! subroutine Agrif_ParentGrid_to_ChildGrid |
---|
| 458 | ! |
---|
| 459 | !> Make the pointer #Agrif_Curgrid point on the child grid after having called the |
---|
| 460 | !! #Agrif_ChildGrid_to_ParentGrid subroutine. |
---|
| 461 | !--------------------------------------------------------------------------------------------------- |
---|
| 462 | subroutine Agrif_ParentGrid_to_ChildGrid ( ) |
---|
| 463 | !--------------------------------------------------------------------------------------------------- |
---|
| 464 | call Agrif_Instance(Agrif_Curgrid%save_grid) |
---|
| 465 | !--------------------------------------------------------------------------------------------------- |
---|
| 466 | end subroutine Agrif_ParentGrid_to_ChildGrid |
---|
| 467 | !=================================================================================================== |
---|
| 468 | ! |
---|
| 469 | !=================================================================================================== |
---|
| 470 | ! function Agrif_Get_Unit |
---|
| 471 | ! |
---|
| 472 | !> Returns a unit not connected to any file. |
---|
| 473 | !--------------------------------------------------------------------------------------------------- |
---|
| 474 | function Agrif_Get_Unit ( ) |
---|
| 475 | !--------------------------------------------------------------------------------------------------- |
---|
| 476 | integer :: Agrif_Get_Unit ! Result |
---|
| 477 | ! |
---|
| 478 | integer :: n |
---|
| 479 | logical :: op |
---|
| 480 | ! |
---|
| 481 | integer :: nunit |
---|
| 482 | integer :: iii, out, iiimax |
---|
| 483 | logical :: bexist |
---|
| 484 | integer,dimension(1:1000) :: forbiddenunit |
---|
| 485 | ! |
---|
| 486 | ! Load forbidden Unit if the file Agrif_forbidenUnit exist |
---|
| 487 | ! |
---|
| 488 | INQUIRE(file='Agrif_forbiddenUnit.txt', exist=bexist) |
---|
| 489 | ! |
---|
| 490 | if (.not. bexist) then |
---|
| 491 | ! File Agrif_forbiddenUnit.txt not found |
---|
| 492 | else |
---|
| 493 | nunit = 777 |
---|
| 494 | OPEN(nunit,file='Agrif_forbiddenUnit.txt', form='formatted', status="old") |
---|
| 495 | iii = 1 |
---|
| 496 | do while ( .TRUE. ) |
---|
| 497 | READ(nunit,*, end=99) forbiddenunit(iii) |
---|
| 498 | iii = iii + 1 |
---|
| 499 | enddo |
---|
| 500 | 99 continue |
---|
| 501 | iiimax = iii |
---|
| 502 | close(nunit) |
---|
| 503 | endif |
---|
| 504 | ! |
---|
| 505 | do n = 7,1000 |
---|
| 506 | ! |
---|
| 507 | INQUIRE(Unit=n,Opened=op) |
---|
| 508 | ! |
---|
| 509 | out = 0 |
---|
| 510 | if ( bexist .AND. (.NOT.op) ) then |
---|
| 511 | do iii = 1,iiimax |
---|
| 512 | if ( n == forbiddenunit(iii) ) out = 1 |
---|
| 513 | enddo |
---|
| 514 | endif |
---|
| 515 | ! |
---|
| 516 | if ( (.NOT.op) .AND. (out == 0) ) exit |
---|
| 517 | ! |
---|
| 518 | enddo |
---|
| 519 | ! |
---|
| 520 | Agrif_Get_Unit = n |
---|
| 521 | !--------------------------------------------------------------------------------------------------- |
---|
| 522 | end function Agrif_Get_Unit |
---|
| 523 | !=================================================================================================== |
---|
| 524 | ! |
---|
| 525 | !=================================================================================================== |
---|
| 526 | ! subroutine Agrif_Set_Extra_Boundary_Cells |
---|
| 527 | !--------------------------------------------------------------------------------------------------- |
---|
| 528 | subroutine Agrif_Set_Extra_Boundary_Cells ( nb_extra_cells ) |
---|
| 529 | !--------------------------------------------------------------------------------------------------- |
---|
| 530 | integer, intent(in) :: nb_extra_cells |
---|
| 531 | ! |
---|
| 532 | Agrif_Extra_Boundary_Cells = nb_extra_cells |
---|
| 533 | !--------------------------------------------------------------------------------------------------- |
---|
| 534 | end subroutine Agrif_Set_Extra_Boundary_Cells |
---|
| 535 | !=================================================================================================== |
---|
| 536 | ! |
---|
| 537 | !=================================================================================================== |
---|
| 538 | ! subroutine Agrif_Set_Efficiency |
---|
| 539 | !--------------------------------------------------------------------------------------------------- |
---|
| 540 | subroutine Agrif_Set_Efficiency ( eff ) |
---|
| 541 | !--------------------------------------------------------------------------------------------------- |
---|
| 542 | real, intent(in) :: eff |
---|
| 543 | ! |
---|
| 544 | if ( (eff < 0.) .OR. (eff > 1) ) then |
---|
| 545 | write(*,*) 'Error Efficiency should be between 0 and 1' |
---|
| 546 | stop |
---|
| 547 | else |
---|
| 548 | Agrif_Efficiency = eff |
---|
| 549 | endif |
---|
| 550 | !--------------------------------------------------------------------------------------------------- |
---|
| 551 | end subroutine Agrif_Set_Efficiency |
---|
| 552 | !=================================================================================================== |
---|
| 553 | ! |
---|
| 554 | !=================================================================================================== |
---|
| 555 | ! subroutine Agrif_Set_Regridding |
---|
| 556 | !--------------------------------------------------------------------------------------------------- |
---|
| 557 | subroutine Agrif_Set_Regridding ( regfreq ) |
---|
| 558 | !--------------------------------------------------------------------------------------------------- |
---|
| 559 | integer, intent(in) :: regfreq |
---|
| 560 | ! |
---|
| 561 | if (regfreq < 0) then |
---|
| 562 | write(*,*) 'Regridding frequency should be positive' |
---|
| 563 | stop |
---|
| 564 | else |
---|
| 565 | Agrif_Regridding = regfreq |
---|
| 566 | endif |
---|
| 567 | !--------------------------------------------------------------------------------------------------- |
---|
| 568 | end subroutine Agrif_Set_Regridding |
---|
| 569 | !=================================================================================================== |
---|
| 570 | ! |
---|
| 571 | !=================================================================================================== |
---|
| 572 | ! subroutine Agrif_Set_coeffref_x |
---|
| 573 | !--------------------------------------------------------------------------------------------------- |
---|
| 574 | subroutine Agrif_Set_coeffref_x ( coeffref ) |
---|
| 575 | !--------------------------------------------------------------------------------------------------- |
---|
| 576 | integer, intent(in) :: coeffref |
---|
| 577 | |
---|
| 578 | if (coeffref < 0) then |
---|
| 579 | write(*,*) 'Coefficient of raffinement should be positive' |
---|
| 580 | stop |
---|
| 581 | else |
---|
| 582 | Agrif_coeffref(1) = coeffref |
---|
| 583 | endif |
---|
| 584 | !--------------------------------------------------------------------------------------------------- |
---|
| 585 | end subroutine Agrif_Set_coeffref_x |
---|
| 586 | !=================================================================================================== |
---|
| 587 | ! |
---|
| 588 | !=================================================================================================== |
---|
| 589 | ! subroutine Agrif_Set_coeffref_y |
---|
| 590 | !--------------------------------------------------------------------------------------------------- |
---|
| 591 | subroutine Agrif_Set_coeffref_y ( coeffref ) |
---|
| 592 | !--------------------------------------------------------------------------------------------------- |
---|
| 593 | integer, intent(in) :: coeffref |
---|
| 594 | |
---|
| 595 | if (coeffref < 0) then |
---|
| 596 | write(*,*) 'Coefficient of raffinement should be positive' |
---|
| 597 | stop |
---|
| 598 | else |
---|
| 599 | Agrif_coeffref(2) = coeffref |
---|
| 600 | endif |
---|
| 601 | !--------------------------------------------------------------------------------------------------- |
---|
| 602 | end subroutine Agrif_Set_coeffref_y |
---|
| 603 | !=================================================================================================== |
---|
| 604 | ! |
---|
| 605 | !=================================================================================================== |
---|
| 606 | ! subroutine Agrif_Set_coeffref_z |
---|
| 607 | !--------------------------------------------------------------------------------------------------- |
---|
| 608 | subroutine Agrif_Set_coeffref_z ( coeffref ) |
---|
| 609 | !--------------------------------------------------------------------------------------------------- |
---|
| 610 | integer, intent(in) :: coeffref |
---|
| 611 | ! |
---|
| 612 | if (coeffref < 0) then |
---|
| 613 | write(*,*) 'Coefficient of raffinement should be positive' |
---|
| 614 | stop |
---|
| 615 | else |
---|
| 616 | Agrif_coeffref(3) = coeffref |
---|
| 617 | endif |
---|
| 618 | !--------------------------------------------------------------------------------------------------- |
---|
| 619 | end subroutine Agrif_Set_coeffref_z |
---|
| 620 | !=================================================================================================== |
---|
| 621 | ! |
---|
| 622 | !=================================================================================================== |
---|
| 623 | ! subroutine Agrif_Set_coeffreft_x |
---|
| 624 | !--------------------------------------------------------------------------------------------------- |
---|
| 625 | subroutine Agrif_Set_coeffreft_x ( coeffref ) |
---|
| 626 | !--------------------------------------------------------------------------------------------------- |
---|
| 627 | integer, intent(in) :: coeffref |
---|
| 628 | |
---|
| 629 | if (coeffref < 0) then |
---|
| 630 | write(*,*) 'Coefficient of time raffinement should be positive' |
---|
| 631 | stop |
---|
| 632 | else |
---|
| 633 | Agrif_coeffreft(1) = coeffref |
---|
| 634 | endif |
---|
| 635 | !--------------------------------------------------------------------------------------------------- |
---|
| 636 | end subroutine Agrif_Set_coeffreft_x |
---|
| 637 | !=================================================================================================== |
---|
| 638 | ! |
---|
| 639 | !=================================================================================================== |
---|
| 640 | ! subroutine Agrif_Set_coeffreft_y |
---|
| 641 | !--------------------------------------------------------------------------------------------------- |
---|
| 642 | subroutine Agrif_Set_coeffreft_y ( coeffref ) |
---|
| 643 | !--------------------------------------------------------------------------------------------------- |
---|
| 644 | integer, intent(in) :: coeffref |
---|
| 645 | ! |
---|
| 646 | if (coeffref < 0) then |
---|
| 647 | write(*,*) 'Coefficient of time raffinement should be positive' |
---|
| 648 | stop |
---|
| 649 | else |
---|
| 650 | Agrif_coeffreft(2) = coeffref |
---|
| 651 | endif |
---|
| 652 | !--------------------------------------------------------------------------------------------------- |
---|
| 653 | end subroutine Agrif_Set_coeffreft_y |
---|
| 654 | !=================================================================================================== |
---|
| 655 | ! |
---|
| 656 | !=================================================================================================== |
---|
| 657 | ! subroutine Agrif_Set_coeffreft_z |
---|
| 658 | !--------------------------------------------------------------------------------------------------- |
---|
| 659 | subroutine Agrif_Set_coeffreft_z ( coeffref ) |
---|
| 660 | !--------------------------------------------------------------------------------------------------- |
---|
| 661 | integer, intent(in) :: coeffref |
---|
| 662 | |
---|
| 663 | if (coeffref < 0) then |
---|
| 664 | write(*,*)'Coefficient of time raffinement should be positive' |
---|
| 665 | stop |
---|
| 666 | else |
---|
| 667 | Agrif_coeffreft(3) = coeffref |
---|
| 668 | endif |
---|
| 669 | !--------------------------------------------------------------------------------------------------- |
---|
| 670 | end subroutine Agrif_Set_coeffreft_z |
---|
| 671 | !=================================================================================================== |
---|
[13027] | 672 | ! subroutine Agrif_Set_coeffreft |
---|
| 673 | !--------------------------------------------------------------------------------------------------- |
---|
| 674 | subroutine Agrif_Set_coeffreft ( coeffref ) |
---|
| 675 | !--------------------------------------------------------------------------------------------------- |
---|
| 676 | integer, intent(in) :: coeffref |
---|
| 677 | integer :: i |
---|
| 678 | |
---|
| 679 | if (coeffref < 0) then |
---|
| 680 | write(*,*)'Coefficient of time raffinement should be positive' |
---|
| 681 | stop |
---|
| 682 | else |
---|
| 683 | do i=1,Agrif_Probdim |
---|
| 684 | Agrif_coeffreft(i) = coeffref |
---|
| 685 | Agrif_Curgrid % timeref(i) = coeffref |
---|
| 686 | enddo |
---|
| 687 | endif |
---|
| 688 | !--------------------------------------------------------------------------------------------------- |
---|
| 689 | end subroutine Agrif_Set_coeffreft |
---|
| 690 | !=================================================================================================== |
---|
[4777] | 691 | ! |
---|
| 692 | !=================================================================================================== |
---|
| 693 | ! subroutine Agrif_Set_Minwidth |
---|
| 694 | !--------------------------------------------------------------------------------------------------- |
---|
| 695 | subroutine Agrif_Set_Minwidth ( coefminwidth ) |
---|
| 696 | !--------------------------------------------------------------------------------------------------- |
---|
| 697 | integer, intent(in) :: coefminwidth |
---|
| 698 | ! |
---|
| 699 | if (coefminwidth < 0) then |
---|
| 700 | write(*,*)'Coefficient of Minwidth should be positive' |
---|
| 701 | stop |
---|
| 702 | else |
---|
| 703 | Agrif_Minwidth = coefminwidth |
---|
| 704 | endif |
---|
| 705 | !--------------------------------------------------------------------------------------------------- |
---|
| 706 | end subroutine Agrif_Set_Minwidth |
---|
| 707 | !=================================================================================================== |
---|
| 708 | ! |
---|
| 709 | !=================================================================================================== |
---|
| 710 | ! subroutine Agrif_Set_Rafmax |
---|
| 711 | !--------------------------------------------------------------------------------------------------- |
---|
| 712 | subroutine Agrif_Set_Rafmax ( coefrafmax ) |
---|
| 713 | !--------------------------------------------------------------------------------------------------- |
---|
| 714 | integer, intent(in) :: coefrafmax |
---|
| 715 | ! |
---|
| 716 | integer :: i |
---|
| 717 | real :: res |
---|
| 718 | ! |
---|
| 719 | if (coefrafmax < 0) then |
---|
| 720 | write(*,*)'Coefficient of should be positive' |
---|
| 721 | stop |
---|
| 722 | else |
---|
| 723 | res = 1. |
---|
| 724 | do i = 1,coefrafmax-1 |
---|
| 725 | res = res * FLOAT(Agrif_coeffref(1)) |
---|
| 726 | enddo |
---|
| 727 | if ( res == 0 ) res = 1 |
---|
| 728 | Agrif_Mind(1) = 1. / res |
---|
| 729 | ! |
---|
| 730 | res = 1. |
---|
| 731 | do i = 1,coefrafmax-1 |
---|
| 732 | res = res * FLOAT(Agrif_coeffref(2)) |
---|
| 733 | enddo |
---|
| 734 | if ( res == 0 ) res = 1 |
---|
| 735 | Agrif_Mind(2) = 1. / res |
---|
| 736 | ! |
---|
| 737 | res = 1. |
---|
| 738 | do i = 1,coefrafmax-1 |
---|
| 739 | res = res * FLOAT(Agrif_coeffref(3)) |
---|
| 740 | enddo |
---|
| 741 | if ( res == 0 ) res = 1 |
---|
| 742 | Agrif_Mind(3) = 1. / res |
---|
| 743 | ! |
---|
| 744 | endif |
---|
| 745 | !--------------------------------------------------------------------------------------------------- |
---|
| 746 | end subroutine Agrif_Set_Rafmax |
---|
| 747 | !=================================================================================================== |
---|
| 748 | ! |
---|
| 749 | !=================================================================================================== |
---|
| 750 | ! subroutine Agrif_Set_MaskMaxSearch |
---|
| 751 | !--------------------------------------------------------------------------------------------------- |
---|
| 752 | subroutine Agrif_Set_MaskMaxSearch ( mymaxsearch ) |
---|
| 753 | !--------------------------------------------------------------------------------------------------- |
---|
| 754 | integer, intent(in) :: mymaxsearch |
---|
| 755 | ! |
---|
| 756 | MaxSearch = mymaxsearch |
---|
| 757 | !--------------------------------------------------------------------------------------------------- |
---|
| 758 | end subroutine Agrif_Set_MaskMaxSearch |
---|
| 759 | !=================================================================================================== |
---|
| 760 | ! |
---|
| 761 | !=================================================================================================== |
---|
| 762 | ! function Agrif_Level |
---|
| 763 | !--------------------------------------------------------------------------------------------------- |
---|
| 764 | function Agrif_Level ( ) |
---|
| 765 | !--------------------------------------------------------------------------------------------------- |
---|
| 766 | integer :: Agrif_Level ! Result |
---|
| 767 | ! |
---|
| 768 | Agrif_Level = Agrif_Curgrid % level |
---|
| 769 | !--------------------------------------------------------------------------------------------------- |
---|
| 770 | end function Agrif_Level |
---|
| 771 | !=================================================================================================== |
---|
[13027] | 772 | !=================================================================================================== |
---|
| 773 | ! subroutine Agrif_set_periodicity |
---|
| 774 | !--------------------------------------------------------------------------------------------------- |
---|
| 775 | |
---|
| 776 | subroutine Agrif_set_periodicity(i,decal) |
---|
| 777 | !--------------------------------------------------------------------------------------------------- |
---|
| 778 | integer :: i, decal |
---|
| 779 | |
---|
| 780 | Agrif_curgrid%periodicity(i)=.TRUE. |
---|
| 781 | Agrif_curgrid%periodicity_decal(i)=decal |
---|
| 782 | |
---|
| 783 | !--------------------------------------------------------------------------------------------------- |
---|
| 784 | end subroutine Agrif_set_periodicity |
---|
[4777] | 785 | ! |
---|
| 786 | !=================================================================================================== |
---|
| 787 | ! function Agrif_MaxLevel |
---|
| 788 | !--------------------------------------------------------------------------------------------------- |
---|
| 789 | function Agrif_MaxLevel ( ) |
---|
| 790 | !--------------------------------------------------------------------------------------------------- |
---|
| 791 | integer :: Agrif_MaxLevel ! Result |
---|
| 792 | ! |
---|
| 793 | Agrif_MaxLevel = Agrif_MaxLevelLoc |
---|
| 794 | !--------------------------------------------------------------------------------------------------- |
---|
| 795 | end function Agrif_MaxLevel |
---|
| 796 | !=================================================================================================== |
---|
| 797 | ! |
---|
| 798 | !=================================================================================================== |
---|
| 799 | ! function Agrif_GridAllocation_is_done |
---|
| 800 | !--------------------------------------------------------------------------------------------------- |
---|
| 801 | function Agrif_GridAllocation_is_done ( ) result(isdone) |
---|
| 802 | !--------------------------------------------------------------------------------------------------- |
---|
| 803 | logical :: isdone |
---|
| 804 | ! |
---|
| 805 | isdone = Agrif_Curgrid % allocation_is_done |
---|
| 806 | !--------------------------------------------------------------------------------------------------- |
---|
| 807 | end function Agrif_GridAllocation_is_done |
---|
| 808 | !=================================================================================================== |
---|
| 809 | ! |
---|
[13027] | 810 | |
---|
| 811 | function Agrif_Parent_Real_4(real_variable) result(real_variable_parent) |
---|
| 812 | real(KIND=4) :: real_variable |
---|
| 813 | real(KIND=4) :: real_variable_parent |
---|
| 814 | |
---|
| 815 | integer :: i |
---|
| 816 | logical :: i_found |
---|
| 817 | |
---|
| 818 | i_found = .FALSE. |
---|
| 819 | |
---|
| 820 | do i=1,Agrif_NbVariables(2) |
---|
| 821 | if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%array0)) then |
---|
| 822 | real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%array0 |
---|
| 823 | i_found = .TRUE. |
---|
| 824 | EXIT |
---|
| 825 | endif |
---|
| 826 | enddo |
---|
| 827 | |
---|
| 828 | IF (.NOT.i_found) THEN |
---|
| 829 | do i=1,Agrif_NbVariables(2) |
---|
| 830 | if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%sarray0)) then |
---|
| 831 | real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%sarray0 |
---|
| 832 | i_found = .TRUE. |
---|
| 833 | EXIT |
---|
| 834 | endif |
---|
| 835 | enddo |
---|
| 836 | ENDIF |
---|
| 837 | |
---|
| 838 | if (.NOT.i_found) STOP 'Agrif_Parent_Real_4 : Variable not found' |
---|
| 839 | |
---|
| 840 | end function Agrif_Parent_Real_4 |
---|
| 841 | |
---|
| 842 | function Agrif_Parent_Real_8(real_variable) result(real_variable_parent) |
---|
| 843 | real(KIND=8) :: real_variable |
---|
| 844 | real(KIND=8) :: real_variable_parent |
---|
| 845 | |
---|
| 846 | integer :: i |
---|
| 847 | logical :: i_found |
---|
| 848 | |
---|
| 849 | i_found = .FALSE. |
---|
| 850 | |
---|
| 851 | do i=1,Agrif_NbVariables(2) |
---|
| 852 | if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%array0)) then |
---|
| 853 | real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%array0 |
---|
| 854 | i_found = .TRUE. |
---|
| 855 | EXIT |
---|
| 856 | endif |
---|
| 857 | enddo |
---|
| 858 | |
---|
| 859 | IF (.NOT.i_found) THEN |
---|
| 860 | do i=1,Agrif_NbVariables(2) |
---|
| 861 | if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%darray0)) then |
---|
| 862 | real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%darray0 |
---|
| 863 | i_found = .TRUE. |
---|
| 864 | EXIT |
---|
| 865 | endif |
---|
| 866 | enddo |
---|
| 867 | ENDIF |
---|
| 868 | |
---|
| 869 | if (.NOT.i_found) STOP 'Agrif_Parent_Real_8 : Variable not found' |
---|
| 870 | |
---|
| 871 | end function Agrif_Parent_Real_8 |
---|
| 872 | |
---|
| 873 | function Agrif_Parent_Array2_Real_8(real_variable,ji,jj) result(real_variable_parent) |
---|
| 874 | real(KIND=8), DIMENSION(:,:) :: real_variable |
---|
| 875 | real(KIND=8) :: real_variable_parent |
---|
| 876 | integer :: ji,jj |
---|
| 877 | |
---|
| 878 | integer :: i |
---|
| 879 | logical :: i_found |
---|
| 880 | |
---|
| 881 | i_found = .FALSE. |
---|
| 882 | |
---|
| 883 | do i=1,Agrif_NbVariables(0) |
---|
| 884 | if (LOC(real_variable) == LOC(agrif_curgrid%tabvars(i)%array2)) then |
---|
| 885 | real_variable_parent = agrif_curgrid%tabvars(i)%parent_var%array2(ji,jj) |
---|
| 886 | i_found = .TRUE. |
---|
| 887 | EXIT |
---|
| 888 | endif |
---|
| 889 | enddo |
---|
| 890 | |
---|
| 891 | if (.NOT.i_found) STOP 'Agrif_Parent_Array2_Real_8 : Variable not found' |
---|
| 892 | |
---|
| 893 | end function Agrif_Parent_Array2_Real_8 |
---|
| 894 | |
---|
| 895 | |
---|
| 896 | function Agrif_Parent_Integer(integer_variable) result(integer_variable_parent) |
---|
| 897 | integer :: integer_variable |
---|
| 898 | integer :: integer_variable_parent |
---|
| 899 | |
---|
| 900 | integer :: i |
---|
| 901 | logical :: i_found |
---|
| 902 | |
---|
| 903 | i_found = .FALSE. |
---|
| 904 | |
---|
| 905 | do i=1,Agrif_NbVariables(4) |
---|
| 906 | if (LOC(integer_variable) == LOC(agrif_curgrid%tabvars_i(i)%iarray0)) then |
---|
| 907 | integer_variable_parent = agrif_curgrid%tabvars_i(i)%parent_var%iarray0 |
---|
| 908 | i_found = .TRUE. |
---|
| 909 | EXIT |
---|
| 910 | endif |
---|
| 911 | enddo |
---|
| 912 | |
---|
| 913 | if (.NOT.i_found) STOP 'Agrif_Parent : Variable not found' |
---|
| 914 | |
---|
| 915 | end function Agrif_Parent_Integer |
---|
| 916 | |
---|
| 917 | function Agrif_Parent_Character(character_variable) result(character_variable_parent) |
---|
| 918 | character(*) :: character_variable |
---|
| 919 | character(len(character_variable)) :: character_variable_parent |
---|
| 920 | |
---|
| 921 | integer :: i |
---|
| 922 | logical :: i_found |
---|
| 923 | |
---|
| 924 | i_found = .FALSE. |
---|
| 925 | |
---|
| 926 | do i=1,Agrif_NbVariables(1) |
---|
| 927 | if (LOC(character_variable) == LOC(agrif_curgrid%tabvars_c(i)%carray0)) then |
---|
| 928 | character_variable_parent = agrif_curgrid%tabvars_c(i)%parent_var%carray0 |
---|
| 929 | i_found = .TRUE. |
---|
| 930 | EXIT |
---|
| 931 | endif |
---|
| 932 | enddo |
---|
| 933 | |
---|
| 934 | if (.NOT.i_found) STOP 'Agrif_Parent : Variable not found' |
---|
| 935 | |
---|
| 936 | end function Agrif_Parent_Character |
---|
| 937 | |
---|
| 938 | function Agrif_Parent_Logical(logical_variable) result(logical_variable_parent) |
---|
| 939 | logical :: logical_variable |
---|
| 940 | logical :: logical_variable_parent |
---|
| 941 | |
---|
| 942 | integer :: i |
---|
| 943 | logical :: i_found |
---|
| 944 | |
---|
| 945 | i_found = .FALSE. |
---|
| 946 | |
---|
| 947 | do i=1,Agrif_NbVariables(3) |
---|
| 948 | if (LOC(logical_variable) == LOC(agrif_curgrid%tabvars_l(i)%larray0)) then |
---|
| 949 | logical_variable_parent = agrif_curgrid%tabvars_l(i)%parent_var%larray0 |
---|
| 950 | i_found = .TRUE. |
---|
| 951 | EXIT |
---|
| 952 | endif |
---|
| 953 | enddo |
---|
| 954 | |
---|
| 955 | if (.NOT.i_found) STOP 'Agrif_Parent : Variable not found' |
---|
| 956 | |
---|
| 957 | end function Agrif_Parent_Logical |
---|
| 958 | |
---|
| 959 | function Agrif_Child_Logical(logical_variable) result(logical_variable_child) |
---|
| 960 | logical :: logical_variable |
---|
| 961 | logical :: logical_variable_child |
---|
| 962 | |
---|
| 963 | integer :: i |
---|
| 964 | logical :: i_found |
---|
| 965 | |
---|
| 966 | i_found = .FALSE. |
---|
| 967 | |
---|
| 968 | do i=1,Agrif_NbVariables(3) |
---|
| 969 | if (LOC(logical_variable) == LOC(agrif_curgrid%tabvars_l(i)%larray0)) then |
---|
| 970 | logical_variable_child = Agrif_CurChildgrid%tabvars_l(i)%larray0 |
---|
| 971 | i_found = .TRUE. |
---|
| 972 | EXIT |
---|
| 973 | endif |
---|
| 974 | enddo |
---|
| 975 | |
---|
| 976 | if (.NOT.i_found) STOP 'Agrif_Child : Variable not found' |
---|
| 977 | |
---|
| 978 | end function Agrif_Child_Logical |
---|
| 979 | |
---|
| 980 | function Agrif_Irhox() result(i_val) |
---|
| 981 | integer :: i_val |
---|
| 982 | i_val = agrif_curgrid%spaceref(1) |
---|
| 983 | end function Agrif_Irhox |
---|
| 984 | |
---|
| 985 | function Agrif_Irhoy() result(i_val) |
---|
| 986 | integer :: i_val |
---|
| 987 | i_val = agrif_curgrid%spaceref(2) |
---|
| 988 | end function Agrif_Irhoy |
---|
| 989 | |
---|
| 990 | function Agrif_Irhoz() result(i_val) |
---|
| 991 | integer :: i_val |
---|
| 992 | i_val = agrif_curgrid%spaceref(3) |
---|
| 993 | end function Agrif_Irhoz |
---|
| 994 | |
---|
| 995 | function Agrif_NearCommonBorderX() result(l_val) |
---|
| 996 | logical :: l_val |
---|
| 997 | l_val = agrif_curgrid%nearRootBorder(1) |
---|
| 998 | end function Agrif_NearCommonBorderX |
---|
| 999 | |
---|
| 1000 | subroutine Agrif_Set_NearCommonBorderX(l_val) |
---|
| 1001 | logical,intent(in) :: l_val |
---|
| 1002 | agrif_curgrid%nearRootBorder(1)=l_val |
---|
| 1003 | end subroutine Agrif_Set_NearCommonBorderX |
---|
| 1004 | |
---|
| 1005 | function Agrif_NearCommonBorderY() result(l_val) |
---|
| 1006 | logical :: l_val |
---|
| 1007 | l_val = agrif_curgrid%nearRootBorder(2) |
---|
| 1008 | end function Agrif_NearCommonBorderY |
---|
| 1009 | |
---|
| 1010 | subroutine Agrif_Set_NearCommonBorderY(l_val) |
---|
| 1011 | logical,intent(in) :: l_val |
---|
| 1012 | agrif_curgrid%nearRootBorder(2)=l_val |
---|
| 1013 | end subroutine Agrif_Set_NearCommonBorderY |
---|
| 1014 | |
---|
| 1015 | function Agrif_NearCommonBorderZ() result(l_val) |
---|
| 1016 | logical :: l_val |
---|
| 1017 | l_val = agrif_curgrid%nearRootBorder(3) |
---|
| 1018 | end function Agrif_NearCommonBorderZ |
---|
| 1019 | |
---|
| 1020 | subroutine Agrif_Set_NearCommonBorderZ(l_val) |
---|
| 1021 | logical,intent(in) :: l_val |
---|
| 1022 | agrif_curgrid%nearRootBorder(3)=l_val |
---|
| 1023 | end subroutine Agrif_Set_NearCommonBorderZ |
---|
| 1024 | |
---|
| 1025 | function Agrif_DistantCommonBorderX() result(l_val) |
---|
| 1026 | logical :: l_val |
---|
| 1027 | l_val = agrif_curgrid%DistantRootBorder(1) |
---|
| 1028 | end function Agrif_DistantCommonBorderX |
---|
| 1029 | |
---|
| 1030 | subroutine Agrif_Set_DistantCommonBorderX(l_val) |
---|
| 1031 | logical,intent(in) :: l_val |
---|
| 1032 | agrif_curgrid%DistantRootBorder(1)=l_val |
---|
| 1033 | end subroutine Agrif_Set_DistantCommonBorderX |
---|
| 1034 | |
---|
| 1035 | function Agrif_DistantCommonBorderY() result(l_val) |
---|
| 1036 | logical :: l_val |
---|
| 1037 | l_val = agrif_curgrid%DistantRootBorder(2) |
---|
| 1038 | end function Agrif_DistantCommonBorderY |
---|
| 1039 | |
---|
| 1040 | subroutine Agrif_Set_DistantCommonBorderY(l_val) |
---|
| 1041 | logical,intent(in) :: l_val |
---|
| 1042 | agrif_curgrid%DistantRootBorder(2)=l_val |
---|
| 1043 | end subroutine Agrif_Set_DistantCommonBorderY |
---|
| 1044 | |
---|
| 1045 | function Agrif_DistantCommonBorderZ() result(l_val) |
---|
| 1046 | logical :: l_val |
---|
| 1047 | l_val = agrif_curgrid%DistantRootBorder(3) |
---|
| 1048 | end function Agrif_DistantCommonBorderZ |
---|
| 1049 | |
---|
| 1050 | subroutine Agrif_Set_DistantCommonBorderZ(l_val) |
---|
| 1051 | logical,intent(in) :: l_val |
---|
| 1052 | agrif_curgrid%DistantRootBorder(3)=l_val |
---|
| 1053 | end subroutine Agrif_Set_DistantCommonBorderZ |
---|
| 1054 | |
---|
| 1055 | function Agrif_Ix() result(i_val) |
---|
| 1056 | integer :: i_val |
---|
| 1057 | i_val = agrif_curgrid%ix(1) |
---|
| 1058 | end function Agrif_Ix |
---|
| 1059 | |
---|
| 1060 | function Agrif_Iy() result(i_val) |
---|
| 1061 | integer :: i_val |
---|
| 1062 | i_val = agrif_curgrid%ix(2) |
---|
| 1063 | end function Agrif_Iy |
---|
| 1064 | |
---|
| 1065 | function Agrif_Iz() result(i_val) |
---|
| 1066 | integer :: i_val |
---|
| 1067 | i_val = agrif_curgrid%ix(3) |
---|
| 1068 | end function Agrif_Iz |
---|
| 1069 | |
---|
| 1070 | function Agrif_Get_grid_id() result(i_val) |
---|
| 1071 | integer :: i_val |
---|
| 1072 | i_val = agrif_curgrid % grid_id |
---|
| 1073 | end function Agrif_Get_grid_id |
---|
| 1074 | |
---|
| 1075 | function Agrif_Get_parent_id() result(i_val) |
---|
| 1076 | integer :: i_val |
---|
| 1077 | i_val = agrif_curgrid % parent % grid_id |
---|
| 1078 | end function Agrif_Get_parent_id |
---|
| 1079 | |
---|
| 1080 | function Agrif_rhox() result(r_val) |
---|
| 1081 | real :: r_val |
---|
| 1082 | r_val = real(agrif_curgrid%spaceref(1)) |
---|
| 1083 | end function Agrif_rhox |
---|
| 1084 | |
---|
| 1085 | function Agrif_rhoy() result(r_val) |
---|
| 1086 | real :: r_val |
---|
| 1087 | r_val = real(agrif_curgrid%spaceref(2)) |
---|
| 1088 | end function Agrif_rhoy |
---|
| 1089 | |
---|
| 1090 | function Agrif_rhoz() result(r_val) |
---|
| 1091 | real :: r_val |
---|
| 1092 | r_val = real(agrif_curgrid%spaceref(3)) |
---|
| 1093 | end function Agrif_rhoz |
---|
| 1094 | |
---|
| 1095 | function Agrif_Nb_Step() result(i_val) |
---|
| 1096 | integer :: i_val |
---|
| 1097 | i_val = agrif_curgrid%ngridstep |
---|
| 1098 | end function Agrif_Nb_Step |
---|
| 1099 | |
---|
| 1100 | function Agrif_Nb_Fine_Grids() result(i_val) |
---|
| 1101 | integer :: i_val |
---|
| 1102 | i_val = Agrif_nbfixedgrids |
---|
| 1103 | end function Agrif_Nb_Fine_Grids |
---|
| 1104 | |
---|
| 1105 | ! Set the name of the External mapping subroutine (if needed) |
---|
| 1106 | subroutine Agrif_Set_ExternalMapping(external_mapping) |
---|
| 1107 | Procedure(mapping) :: external_mapping |
---|
| 1108 | |
---|
| 1109 | agrif_external_mapping => external_mapping |
---|
| 1110 | |
---|
| 1111 | end subroutine Agrif_Set_ExternalMapping |
---|
| 1112 | |
---|
| 1113 | ! Set the name of the user linear interp function (if needed) |
---|
| 1114 | subroutine Agrif_Set_external_linear_interp(external_linear_interp) |
---|
| 1115 | Procedure(linear_interp) :: external_linear_interp |
---|
| 1116 | |
---|
| 1117 | agrif_external_linear_interp => external_linear_interp |
---|
| 1118 | |
---|
| 1119 | end subroutine Agrif_Set_external_linear_interp |
---|
| 1120 | |
---|
| 1121 | subroutine Agrif_UnSet_external_linear_interp() |
---|
| 1122 | |
---|
| 1123 | nullify(agrif_external_linear_interp) |
---|
| 1124 | |
---|
| 1125 | end subroutine Agrif_UnSet_external_linear_interp |
---|
| 1126 | |
---|
[4777] | 1127 | end module Agrif_CurgridFunctions |
---|