1 |
cnh |
1.14 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/calc_common_factors.F,v 1.13 2001/02/02 21:04:47 adcroft Exp $ |
2 |
|
|
C $Name: $ |
3 |
cnh |
1.1 |
|
4 |
cnh |
1.10 |
#include "CPP_OPTIONS.h" |
5 |
cnh |
1.1 |
|
6 |
|
|
CStartOfInterFace |
7 |
|
|
SUBROUTINE CALC_COMMON_FACTORS( |
8 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
9 |
cnh |
1.7 |
O xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp, |
10 |
cnh |
1.1 |
I myThid) |
11 |
|
|
|
12 |
|
|
C /==========================================================\ |
13 |
|
|
C | SUBROUTINE CALC_COMMON_FACTORS | |
14 |
|
|
C | o Calculate common data (such as volume flux) for use | |
15 |
|
|
C | by "Right hand side" subroutines. | |
16 |
|
|
C |==========================================================| |
17 |
|
|
C | Here, we calculate terms or spatially varying factors | |
18 |
|
|
C | that are used at various points in the "RHS" subroutines.| |
19 |
|
|
C | This reduces the amount of total work, total memory | |
20 |
|
|
C | and therefore execution time and is generally a good | |
21 |
|
|
C | idea. | |
22 |
|
|
C \==========================================================/ |
23 |
|
|
IMPLICIT NONE |
24 |
|
|
|
25 |
|
|
C == GLobal variables == |
26 |
|
|
#include "SIZE.h" |
27 |
|
|
#include "DYNVARS.h" |
28 |
|
|
#include "EEPARAMS.h" |
29 |
|
|
#include "PARAMS.h" |
30 |
|
|
#include "GRID.h" |
31 |
adcroft |
1.11 |
#ifdef ALLOW_NONHYDROSTATIC |
32 |
|
|
#include "GW.h" |
33 |
|
|
#endif |
34 |
cnh |
1.1 |
|
35 |
|
|
C == Routine arguments == |
36 |
|
|
C bi, bj, iMin, iMax, jMin, jMax - Range of points for which calculation |
37 |
|
|
C results will be set. |
38 |
|
|
C xA - Tracer cell face area normal to X |
39 |
|
|
C yA - Tracer cell face area normal to X |
40 |
|
|
C uTrans - Zonal volume transport through cell face |
41 |
|
|
C vTrans - Meridional volume transport through cell face |
42 |
cnh |
1.7 |
C rTrans - R-direction volume transport through cell face |
43 |
|
|
C rVel - R-direction velocity at cell upper and lower faces |
44 |
cnh |
1.1 |
C maskC - land/water mask for tracer points |
45 |
|
|
C maskUp - land/water mask for Wvel points (above tracer level) |
46 |
|
|
C myThid - Instance number for this innvocation of CALC_COMMON_FACTORS |
47 |
|
|
C |
48 |
|
|
INTEGER bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown |
49 |
|
|
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
50 |
|
|
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
51 |
|
|
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
52 |
|
|
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
53 |
cnh |
1.7 |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
54 |
|
|
_RL rVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
55 |
cnh |
1.1 |
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
56 |
|
|
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
57 |
|
|
C |
58 |
|
|
INTEGER myThid |
59 |
|
|
CEndOfInterface |
60 |
|
|
|
61 |
|
|
C == Local variables == |
62 |
|
|
C I, J, K - Loop counters |
63 |
|
|
C kUp, kDown, kM1 - Index for layer above and below. K_UP and K_DOWN |
64 |
|
|
C are switched with layer to be the appropriate index |
65 |
|
|
C into fluxUD. |
66 |
|
|
INTEGER i,j |
67 |
cnh |
1.6 |
LOGICAL TOP_LAYER |
68 |
heimbach |
1.12 |
|
69 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
70 |
|
|
C-- rvel(:,:kDown) is still required |
71 |
|
|
rVel(1,1,kDown) = rVel(1,1,kDown) |
72 |
|
|
#endif |
73 |
cnh |
1.1 |
|
74 |
cnh |
1.6 |
TOP_LAYER = K .EQ. 1 |
75 |
|
|
|
76 |
adcroft |
1.11 |
C-- Calculate mask for tracer cells (0 => land, 1 => water) |
77 |
|
|
DO j=jMin,jMax |
78 |
|
|
DO i=iMin,iMax |
79 |
|
|
maskC(i,j) = 1. |
80 |
|
|
IF (_hFacC(i,j,k,bi,bj).eq.0.) maskC(i,j)=0. |
81 |
|
|
maskUp(i,j) = 1. |
82 |
|
|
IF (_hFacC(i,j,k,bi,bj).eq.0. .OR. TOP_LAYER ) |
83 |
|
|
& maskUp(i,j)=0. |
84 |
|
|
ENDDO |
85 |
|
|
ENDDO |
86 |
|
|
|
87 |
cnh |
1.6 |
C-- Calculate tracer cell face open areas |
88 |
cnh |
1.1 |
DO j=jMin,jMax |
89 |
|
|
DO i=iMin,iMax |
90 |
cnh |
1.9 |
xA(i,j) = _dyG(i,j,bi,bj) |
91 |
|
|
& *drF(k)*_hFacW(i,j,k,bi,bj) |
92 |
|
|
yA(i,j) = _dxG(i,j,bi,bj) |
93 |
|
|
& *drF(k)*_hFacS(i,j,k,bi,bj) |
94 |
cnh |
1.1 |
ENDDO |
95 |
|
|
ENDDO |
96 |
|
|
|
97 |
cnh |
1.6 |
C-- Calculate velocity field "volume transports" through |
98 |
|
|
C-- tracer cell faces. |
99 |
cnh |
1.1 |
DO j=jMin,jMax |
100 |
|
|
DO i=iMin,iMax |
101 |
|
|
uTrans(i,j) = uVel(i,j,k,bi,bj)*xA(i,j) |
102 |
|
|
vTrans(i,j) = vVel(i,j,k,bi,bj)*yA(i,j) |
103 |
|
|
ENDDO |
104 |
|
|
ENDDO |
105 |
|
|
|
106 |
adcroft |
1.13 |
C-- Vertical velocity at upper face |
107 |
|
|
DO j=jMin,jMax |
108 |
|
|
DO i=iMin,iMax |
109 |
|
|
rVel(i,j,kUp) = wVel(i,j,k,bi,bj) |
110 |
|
|
ENDDO |
111 |
|
|
ENDDO |
112 |
|
|
|
113 |
cnh |
1.6 |
C-- Calculate vertical "volume transport" through |
114 |
|
|
C-- tracer cell face *above* this level. |
115 |
adcroft |
1.13 |
DO j=jMin,jMax |
116 |
adcroft |
1.11 |
DO i=iMin,iMax |
117 |
adcroft |
1.13 |
rTrans(i,j) = rVel(i,j,kUp)*rA(i,j,bi,bj) |
118 |
adcroft |
1.11 |
ENDDO |
119 |
cnh |
1.6 |
ENDDO |
120 |
cnh |
1.1 |
|
121 |
|
|
RETURN |
122 |
|
|
END |