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