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