[92fab65] | 1 | ! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt |
---|
| 2 | ! SPDX-License-Identifier: GPL-3.0-or-later |
---|
[332fbbd] | 3 | |
---|
[e200b7a] | 4 | subroutine shift_field(field,nxf,nyf,nzfmax,nzf,nmax,n) |
---|
| 5 | ! i/o i i i i i i |
---|
| 6 | !***************************************************************************** |
---|
| 7 | ! * |
---|
| 8 | ! This subroutine shifts global fields by nxshift grid cells, in order to * |
---|
| 9 | ! facilitate all sorts of nested wind fields, or output grids, which, * |
---|
| 10 | ! without shifting, would overlap with the domain "boundary". * |
---|
| 11 | ! * |
---|
| 12 | ! Author: A. Stohl * |
---|
| 13 | ! * |
---|
| 14 | ! 3 July 2002 * |
---|
| 15 | ! * |
---|
| 16 | !***************************************************************************** |
---|
| 17 | ! * |
---|
| 18 | ! Variables: * |
---|
| 19 | ! * |
---|
| 20 | ! Constants: * |
---|
| 21 | ! * |
---|
| 22 | !***************************************************************************** |
---|
| 23 | |
---|
| 24 | use par_mod |
---|
| 25 | |
---|
| 26 | implicit none |
---|
| 27 | |
---|
| 28 | integer :: nxf,nyf,nzf,n,ix,jy,kz,ixs,nzfmax,nmax |
---|
| 29 | real :: field(0:nxmax-1,0:nymax-1,nzfmax,nmax),xshiftaux(0:nxmax-1) |
---|
| 30 | |
---|
| 31 | ! Loop over y and z |
---|
| 32 | !****************** |
---|
| 33 | |
---|
| 34 | do kz=1,nzf |
---|
| 35 | do jy=0,nyf-1 |
---|
| 36 | |
---|
| 37 | ! Shift the data |
---|
| 38 | !*************** |
---|
| 39 | |
---|
| 40 | if (nxshift.ne.0) then |
---|
| 41 | do ix=0,nxf-1 |
---|
| 42 | if (ix.ge.nxshift) then |
---|
| 43 | ixs=ix-nxshift |
---|
| 44 | else |
---|
| 45 | ixs=nxf-nxshift+ix |
---|
| 46 | endif |
---|
| 47 | xshiftaux(ixs)=field(ix,jy,kz,n) |
---|
| 48 | end do |
---|
| 49 | do ix=0,nxf-1 |
---|
| 50 | field(ix,jy,kz,n)=xshiftaux(ix) |
---|
| 51 | end do |
---|
| 52 | endif |
---|
| 53 | |
---|
| 54 | ! Repeat the westernmost grid cells at the easternmost domain "boundary" |
---|
| 55 | !*********************************************************************** |
---|
| 56 | |
---|
| 57 | field(nxf,jy,kz,n)=field(0,jy,kz,n) |
---|
| 58 | end do |
---|
| 59 | end do |
---|
| 60 | |
---|
| 61 | end subroutine shift_field |
---|