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

Contents of /MITgcm/pkg/fizhi/CtoA.F

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


Revision 1.6 - (show annotations) (download)
Thu Feb 24 16:44:25 2005 UTC (19 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint58l_post, checkpoint64z, checkpoint57t_post, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint57o_post, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint58e_post, checkpoint57v_post, checkpoint58u_post, checkpoint58w_post, checkpoint57m_post, checkpoint57s_post, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint57k_post, checkpoint57g_post, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint58r_post, checkpoint57i_post, checkpoint57y_post, checkpoint57e_post, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint58n_post, checkpoint58x_post, checkpoint57g_pre, checkpoint58t_post, checkpoint58h_post, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint57y_pre, checkpoint57f_pre, checkpoint58q_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint58j_post, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint59j, checkpoint57r_post, checkpoint59, 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, checkpoint58o_post, checkpoint57z_post, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint58k_post, checkpoint58v_post, checkpoint58s_post, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint58p_post, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint57j_post, checkpoint61z, checkpoint61x, checkpoint61y, checkpoint58b_post, checkpoint57h_pre, checkpoint58m_post, checkpoint57l_post, checkpoint57h_post, HEAD
Changes since 1.5: +31 -17 lines
use a local copy of the input array: this fix the Pb when called with
 the same input & output array.

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

  ViewVC Help
Powered by ViewVC 1.1.22