1 |
molod |
1.1 |
subroutine AtoC(myThid,fieldin1,fieldin2,mask,im1,im2,jm1,jm2, |
2 |
|
|
. numlevs,Nsx,Nsy,idim1,idim2,jdim1,jdim2,fieldout1,fieldout2) |
3 |
|
|
c---------------------------------------------------------------------- |
4 |
|
|
c Subroutine AtoC - Routine to map a velocity component quantity |
5 |
|
|
c from the A-Grid to the C-Grid. |
6 |
|
|
c This includes doing an exchange to fill the halo region, and |
7 |
|
|
c then a linear average with the appropriate topography mask. |
8 |
|
|
c Also: Set up "bi, bj loop" here. |
9 |
|
|
c |
10 |
|
|
c Input: myThid |
11 |
|
|
c fieldin1 Field on a-grid to move to a-grid (1st component) |
12 |
|
|
c fieldin2 Field on a-grid to move to a-grid (2nd component) |
13 |
|
|
c mask Topography [0,1] mask - 1 to indicate above ground |
14 |
|
|
c im1,im2,jm1,jm2 Indeces in x and y for computations |
15 |
|
|
c numlevs Number of vertical levels |
16 |
|
|
c Nsx, Nsy |
17 |
|
|
c idim1,idim2,jdim1,jdim2 Span of fields in x and y |
18 |
|
|
c |
19 |
|
|
c Output: fieldout1 Field mapped to C-Grid (1st component) |
20 |
|
|
c fieldout2 Field mapped to C-Grid (2nd component) |
21 |
|
|
c |
22 |
|
|
c Call: exch_uv_agrid_xyz_RL - exchange on a-grid |
23 |
|
|
c----------------------------------------------------------------------- |
24 |
|
|
implicit none |
25 |
|
|
#include "CPP_OPTIONS.h" |
26 |
|
|
#include "EEPARAMS.h" |
27 |
|
|
|
28 |
|
|
integer myThid, numlevs |
29 |
|
|
integer Nsx, Nsy |
30 |
|
|
integer im1, im2, jm1, jm2, idim1, idim2, jdim1, jdim2 |
31 |
|
|
_RS mask(im1:im2,jm1:jm2,numlevs,Nsx,Nsy) |
32 |
|
|
_RL fieldin1(im1:im2,jm1:jm2,numlevs,Nsx,Nsy) |
33 |
|
|
_RL fieldin2(im1:im2,jm1:jm2,numlevs,Nsx,Nsy) |
34 |
|
|
_RL fieldout1(im1:im2,jm1:jm2,numlevs,Nsx,Nsy) |
35 |
|
|
_RL fieldout2(im1:im2,jm1:jm2,numlevs,Nsx,Nsy) |
36 |
|
|
|
37 |
|
|
integer i, j, L, bi, bj |
38 |
|
|
|
39 |
|
|
c Call the exchange routine to fill in the halo regions |
40 |
|
|
call exch_uv_agrid_xyz_RL (fieldin1,fieldin2,myThid) |
41 |
|
|
|
42 |
|
|
c Now take average |
43 |
|
|
do bj = myByLo(myThid), myByHi(myThid) |
44 |
|
|
do bi = myBxLo(myThid), myBxHi(myThid) |
45 |
|
|
|
46 |
|
|
do L = 1,numlevs |
47 |
molod |
1.2 |
do j = jdim1,jdim2 |
48 |
|
|
do i = idim1,idim2 |
49 |
molod |
1.1 |
if( (mask(i-1,j,L,bi,bj).ne.0.) .or. |
50 |
|
|
. (mask(i,j,L,bi,bj).ne.0.) ) then |
51 |
|
|
fieldout1(i,j,L,bi,bj) = |
52 |
|
|
. ( fieldin1(i-1,j,L,bi,bj)*mask(i-1,j,L,bi,bj) + |
53 |
|
|
. fieldin1(i,j,L,bi,bj)*mask(i,j,L,bi,bj) ) / |
54 |
|
|
. ( mask(i-1,j,L,bi,bj) + mask(i,j,L,bi,bj) ) |
55 |
|
|
else |
56 |
|
|
fieldout1(i,j,L,bi,bj) = 0. |
57 |
|
|
endif |
58 |
|
|
if( (mask(i,j-1,L,bi,bj).ne.0.) .or. |
59 |
|
|
. (mask(i,j,L,bi,bj).ne.0.) ) then |
60 |
|
|
fieldout2(i,j,L,bi,bj) = |
61 |
|
|
. ( fieldin2(i,j-1,L,bi,bj)*mask(i,j-1,L,bi,bj) + |
62 |
|
|
. fieldin2(i,j,L,bi,bj)*mask(i,j,L,bi,bj) ) / |
63 |
|
|
. ( mask(i,j,L,bi,bj) + mask(i,j-1,L,bi,bj) ) |
64 |
|
|
else |
65 |
|
|
fieldout2(i,j,L,bi,bj) = 0. |
66 |
|
|
endif |
67 |
|
|
enddo |
68 |
|
|
enddo |
69 |
|
|
enddo |
70 |
|
|
|
71 |
|
|
enddo |
72 |
|
|
enddo |
73 |
|
|
|
74 |
|
|
return |
75 |
|
|
end |