1 |
jmc |
1.1 |
C $Header: /u/gcmpack/MITgcm/model/src/update_r_star.F,v 1.7 2008/08/12 22:42:33 jmc Exp $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "PACKAGES_CONFIG.h" |
5 |
|
|
#include "CPP_OPTIONS.h" |
6 |
|
|
|
7 |
|
|
CBOP |
8 |
|
|
C !ROUTINE: UPDATE_SIGMA |
9 |
|
|
C !INTERFACE: |
10 |
|
|
SUBROUTINE UPDATE_SIGMA( etaHc, myTime, myIter, myThid ) |
11 |
|
|
C !DESCRIPTION: \bv |
12 |
|
|
C *==========================================================* |
13 |
|
|
C | SUBROUTINE UPDATE_SIGMA |
14 |
|
|
C | o Update the thickness fractions (hFacC,W,S) |
15 |
|
|
C | according to the surface r-position = Non-Linear FrSurf |
16 |
|
|
C *==========================================================* |
17 |
|
|
C \ev |
18 |
|
|
|
19 |
|
|
C !USES: |
20 |
|
|
IMPLICIT NONE |
21 |
|
|
C == Global variables |
22 |
|
|
#include "SIZE.h" |
23 |
|
|
#include "EEPARAMS.h" |
24 |
|
|
#include "PARAMS.h" |
25 |
|
|
c #include "DYNVARS.h" |
26 |
|
|
#include "GRID.h" |
27 |
|
|
#include "SURFACE.h" |
28 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
29 |
|
|
# include "tamc.h" |
30 |
|
|
# include "tamc_keys.h" |
31 |
|
|
#endif |
32 |
|
|
|
33 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
34 |
|
|
C == Routine arguments == |
35 |
|
|
C etaHc :: surface r-anomaly at grid cell center |
36 |
|
|
C myTime :: Current time in simulation |
37 |
|
|
C myIter :: Current iteration number in simulation |
38 |
|
|
C myThid :: my Thread Id. number |
39 |
|
|
_RL etaHc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
40 |
|
|
_RL myTime |
41 |
|
|
INTEGER myIter |
42 |
|
|
INTEGER myThid |
43 |
|
|
|
44 |
|
|
#ifdef NONLIN_FRSURF |
45 |
|
|
c#ifndef DISABLE_SIGMA_CODE |
46 |
|
|
C !LOCAL VARIABLES: |
47 |
|
|
C Local variables |
48 |
|
|
C bi, bj :: tile indices |
49 |
|
|
C i, j, k :: Loop counters |
50 |
|
|
C rEmpty :: empty column r-position |
51 |
|
|
C rFullDepth :: maximum depth of a full column |
52 |
|
|
C tmpFld :: Temporary array used to compute & write Total Depth |
53 |
|
|
C msgBuf :: Informational/error message buffer |
54 |
|
|
INTEGER bi, bj |
55 |
|
|
INTEGER i, j, k |
56 |
|
|
_RL rFullDepth |
57 |
|
|
_RL tmpFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
58 |
|
|
c _RL hFactmp |
59 |
|
|
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
60 |
|
|
CEOP |
61 |
|
|
|
62 |
|
|
rFullDepth = rF(1)-rF(Nr+1) |
63 |
|
|
|
64 |
|
|
DO bj=myByLo(myThid), myByHi(myThid) |
65 |
|
|
DO bi=myBxLo(myThid), myBxHi(myThid) |
66 |
|
|
|
67 |
|
|
c#ifdef ALLOW_AUTODIFF_TAMC |
68 |
|
|
c act1 = bi - myBxLo(myThid) |
69 |
|
|
c max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
70 |
|
|
c act2 = bj - myByLo(myThid) |
71 |
|
|
c max2 = myByHi(myThid) - myByLo(myThid) + 1 |
72 |
|
|
c act3 = myThid - 1 |
73 |
|
|
c max3 = nTx*nTy |
74 |
|
|
c act4 = ikey_dynamics - 1 |
75 |
|
|
c idynkey = (act1 + 1) + act2*max1 |
76 |
|
|
c & + act3*max1*max2 |
77 |
|
|
c & + act4*max1*max2*max3 |
78 |
|
|
c#endif /* ALLOW_AUTODIFF_TAMC */ |
79 |
|
|
|
80 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
81 |
|
|
|
82 |
|
|
c#ifdef ALLOW_OBCS |
83 |
|
|
c# ifdef ALLOW_AUTODIFF_TAMC |
84 |
|
|
cCADJ STORE rStarFacC(:,:,bi,bj) = |
85 |
|
|
cCADJ & comlev1_bibj, key = idynkey, byte = isbyte |
86 |
|
|
cCADJ STORE rStarFacS(:,:,bi,bj) = |
87 |
|
|
cCADJ & comlev1_bibj, key = idynkey, byte = isbyte |
88 |
|
|
cCADJ STORE rStarFacW(:,:,bi,bj) = |
89 |
|
|
cCADJ & comlev1_bibj, key = idynkey, byte = isbyte |
90 |
|
|
c# endif /* ALLOW_AUTODIFF_TAMC */ |
91 |
|
|
cC-- Apply OBC to rStar_Factor_W,S before updating hFacW,S |
92 |
|
|
c IF (useOBCS) THEN |
93 |
|
|
c CALL OBCS_APPLY_R_STAR( |
94 |
|
|
c I bi, bj, |
95 |
|
|
c U rStarFacC, rStarFacW, rStarFacS, |
96 |
|
|
c I myTime, myIter, myThid ) |
97 |
|
|
c ENDIF |
98 |
|
|
c#endif /* ALLOW_OBCS */ |
99 |
|
|
|
100 |
|
|
C-- Update the fractional thickness hFacC (& "recip_hFac") : |
101 |
|
|
DO j=1-Oly,sNy+Oly |
102 |
|
|
DO i=1-Olx,sNx+Olx |
103 |
|
|
IF ( kSurfC(i,j,bi,bj).LE.Nr ) THEN |
104 |
|
|
tmpFld(i,j) = etaHc(i,j,bi,bj) |
105 |
|
|
& + ( Ro_surf(i,j,bi,bj)-R_low(i,j,bi,bj) ) |
106 |
|
|
ELSE |
107 |
|
|
tmpFld(i,j) = rFullDepth |
108 |
|
|
ENDIF |
109 |
|
|
ENDDO |
110 |
|
|
ENDDO |
111 |
|
|
DO k=1,Nr |
112 |
|
|
DO j=1-Oly,sNy+Oly |
113 |
|
|
DO i=1-Olx,sNx+Olx |
114 |
|
|
hFacC(i,j,k,bi,bj) = maskC(i,j,k,bi,bj) |
115 |
|
|
& *( dAHybSigF(k)*rFullDepth |
116 |
|
|
& +dBHybSigF(k)*tmpFld(i,j) |
117 |
|
|
& )*recip_drF(k) |
118 |
|
|
recip_hFacC(i,j,k,bi,bj) = maskC(i,j,k,bi,bj)*drF(k) |
119 |
|
|
& /( dAHybSigF(k)*rFullDepth |
120 |
|
|
& +dBHybSigF(k)*tmpFld(i,j) |
121 |
|
|
& ) |
122 |
|
|
ENDDO |
123 |
|
|
ENDDO |
124 |
|
|
ENDDO |
125 |
|
|
|
126 |
|
|
C-- Update the fractional thickness hFacW (& "recip_hFac") : |
127 |
|
|
DO j=1-Oly,sNy+Oly |
128 |
|
|
DO i=1-Olx,sNx+Olx |
129 |
|
|
IF ( kSurfW(i,j,bi,bj).LE.Nr ) THEN |
130 |
|
|
tmpFld(i,j) = etaHw(i,j,bi,bj) |
131 |
|
|
& + ( rSurfW(i,j,bi,bj)-rLowW(i,j,bi,bj) ) |
132 |
|
|
ELSE |
133 |
|
|
tmpFld(i,j) = rFullDepth |
134 |
|
|
ENDIF |
135 |
|
|
ENDDO |
136 |
|
|
ENDDO |
137 |
|
|
DO k=1,Nr |
138 |
|
|
DO j=1-Oly,sNy+Oly |
139 |
|
|
DO i=1-Olx,sNx+Olx |
140 |
|
|
hFacW(i,j,k,bi,bj) = maskW(i,j,k,bi,bj) |
141 |
|
|
& *( dAHybSigF(k)*rFullDepth |
142 |
|
|
& +dBHybSigF(k)*tmpFld(i,j) |
143 |
|
|
& )*recip_drF(k) |
144 |
|
|
recip_hFacW(i,j,k,bi,bj) = maskW(i,j,k,bi,bj)*drF(k) |
145 |
|
|
& /( dAHybSigF(k)*rFullDepth |
146 |
|
|
& +dBHybSigF(k)*tmpFld(i,j) |
147 |
|
|
& ) |
148 |
|
|
ENDDO |
149 |
|
|
ENDDO |
150 |
|
|
ENDDO |
151 |
|
|
|
152 |
|
|
C-- Update the fractional thickness hFacS (& "recip_hFac") : |
153 |
|
|
DO j=1-Oly,sNy+Oly |
154 |
|
|
DO i=1-Olx,sNx+Olx |
155 |
|
|
IF ( kSurfS(i,j,bi,bj).LE.Nr ) THEN |
156 |
|
|
tmpFld(i,j) = etaHs(i,j,bi,bj) |
157 |
|
|
& + ( rSurfS(i,j,bi,bj)-rLowS(i,j,bi,bj) ) |
158 |
|
|
ELSE |
159 |
|
|
tmpFld(i,j) = rFullDepth |
160 |
|
|
ENDIF |
161 |
|
|
ENDDO |
162 |
|
|
ENDDO |
163 |
|
|
DO k=1,Nr |
164 |
|
|
DO j=1-Oly,sNy+Oly |
165 |
|
|
DO i=1-Olx,sNx+Olx |
166 |
|
|
hFacS(i,j,k,bi,bj) = maskS(i,j,k,bi,bj) |
167 |
|
|
& *( dAHybSigF(k)*rFullDepth |
168 |
|
|
& +dBHybSigF(k)*tmpFld(i,j) |
169 |
|
|
& )*recip_drF(k) |
170 |
|
|
recip_hFacS(i,j,k,bi,bj) = maskS(i,j,k,bi,bj)*drF(k) |
171 |
|
|
& /( dAHybSigF(k)*rFullDepth |
172 |
|
|
& +dBHybSigF(k)*tmpFld(i,j) |
173 |
|
|
& ) |
174 |
|
|
ENDDO |
175 |
|
|
ENDDO |
176 |
|
|
ENDDO |
177 |
|
|
|
178 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
179 |
|
|
|
180 |
|
|
C- end bi,bj loop |
181 |
|
|
ENDDO |
182 |
|
|
ENDDO |
183 |
|
|
|
184 |
|
|
c _EXCH_XYZ_RS( hFacC, myThid ) |
185 |
|
|
c _EXCH_XYZ_RS( recip_hFacC, myThid ) |
186 |
|
|
c CALL EXCH_UV_XYZ_RS(hFacW,hFacS,.FALSE.,myThid) |
187 |
|
|
c CALL EXCH_UV_XYZ_RS(recip_hFacW,recip_hFacS,.FALSE.,myThid) |
188 |
|
|
|
189 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
190 |
|
|
c#endif /* ndef DISABLE_SIGMA_CODE */ |
191 |
|
|
#endif /* NONLIN_FRSURF */ |
192 |
|
|
|
193 |
|
|
RETURN |
194 |
|
|
END |