/[MITgcm]/MITgcm/pkg/fizhi/AtoC.F
ViewVC logotype

Annotation of /MITgcm/pkg/fizhi/AtoC.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (hide annotations) (download)
Thu Feb 24 16:44:25 2005 UTC (19 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58l_post, checkpoint57t_post, checkpoint57o_post, checkpoint58e_post, checkpoint57v_post, checkpoint57m_post, checkpoint57s_post, checkpoint57k_post, checkpoint57g_post, checkpoint57i_post, checkpoint57y_post, checkpoint57e_post, checkpoint58n_post, checkpoint57g_pre, checkpoint58h_post, checkpoint57y_pre, checkpoint57f_pre, checkpoint58j_post, checkpoint57r_post, checkpoint58, eckpoint57e_pre, checkpoint57h_done, checkpoint58f_post, checkpoint57x_post, checkpoint57n_post, checkpoint58d_post, checkpoint58c_post, checkpoint57w_post, checkpoint57p_post, checkpint57u_post, checkpoint57f_post, checkpoint58a_post, checkpoint58i_post, checkpoint57q_post, checkpoint58g_post, checkpoint57z_post, checkpoint58k_post, checkpoint57j_post, checkpoint58b_post, checkpoint57h_pre, checkpoint58m_post, checkpoint57l_post, checkpoint57h_post
Changes since 1.6: +32 -16 lines
use a local copy of the input array: this fix the Pb when called with
 the same input & output array.

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

  ViewVC Help
Powered by ViewVC 1.1.22