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