1 |
C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_getsurfacefluxes.F,v 1.22 2014/11/02 21:23:30 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "EXF_OPTIONS.h" |
5 |
#ifdef ALLOW_CTRL |
6 |
# include "CTRL_OPTIONS.h" |
7 |
#endif |
8 |
#ifdef ALLOW_ECCO |
9 |
# include "ECCO_OPTIONS.h" |
10 |
#endif |
11 |
|
12 |
subroutine exf_GetSurfaceFluxes( |
13 |
I mytime, |
14 |
I myiter, |
15 |
I mythid |
16 |
& ) |
17 |
|
18 |
c ================================================================== |
19 |
c SUBROUTINE exf_GetSurfaceFluxes |
20 |
c ================================================================== |
21 |
c |
22 |
c o Mid-level routine for enabling the use of flux fields as control |
23 |
c variables. |
24 |
c |
25 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
26 |
c |
27 |
c changed: Christian Eckert eckert@mit.edu 14-Jan-2000 |
28 |
c - Restructured the code in order to create a package |
29 |
c for the MITgcmUV. |
30 |
c |
31 |
c Christian Eckert eckert@mit.edu 12-Feb-2000 |
32 |
c - Changed Routine names (package prefix: exf_) |
33 |
c |
34 |
c mods for pkg/seaice: menemenlis@jpl.nasa.gov 20-Dec-2002 |
35 |
c |
36 |
c ================================================================== |
37 |
c SUBROUTINE exf_GetSurfaceFluxes |
38 |
c ================================================================== |
39 |
|
40 |
implicit none |
41 |
|
42 |
c == global variables == |
43 |
#include "EEPARAMS.h" |
44 |
#include "SIZE.h" |
45 |
#include "PARAMS.h" |
46 |
#include "GRID.h" |
47 |
|
48 |
#include "EXF_FIELDS.h" |
49 |
#include "EXF_PARAM.h" |
50 |
#ifdef ALLOW_CTRL |
51 |
# include "CTRL_SIZE.h" |
52 |
# include "ctrl.h" |
53 |
# include "ctrl_dummy.h" |
54 |
# include "CTRL_GENARR.h" |
55 |
#endif |
56 |
#if (defined (ALLOW_ECCO) && defined (ECCO_CTRL_DEPRECATED)) |
57 |
# include "ecco_cost.h" |
58 |
#endif |
59 |
|
60 |
c == routine arguments == |
61 |
|
62 |
_RL mytime |
63 |
integer myiter |
64 |
integer mythid |
65 |
|
66 |
c == global variables == |
67 |
|
68 |
#ifdef ALLOW_CTRL |
69 |
|
70 |
#ifdef ALLOW_ROTATE_UV_CONTROLS |
71 |
_RL tmpUE(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
72 |
_RL tmpVN(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
73 |
_RL tmpUX(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
74 |
_RL tmpVY(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
75 |
#endif |
76 |
|
77 |
#ifdef ALLOW_GENTIM2D_CONTROL |
78 |
integer iarr |
79 |
#endif |
80 |
|
81 |
#if (defined (ALLOW_ROTATE_UV_CONTROLS) || defined (ALLOW_GENTIM2D_CONTROL)) |
82 |
integer i,j,bi,bj |
83 |
#endif |
84 |
|
85 |
c == end of interface == |
86 |
|
87 |
#ifdef ALLOW_ROTATE_UV_CONTROLS |
88 |
if ( useCTRL ) then |
89 |
do bj = mybylo(mythid),mybyhi(mythid) |
90 |
do bi = mybxlo(mythid),mybxhi(mythid) |
91 |
do j = 1-oly,sny+oly |
92 |
do i = 1-olx,snx+olx |
93 |
tmpUE(i,j,bi,bj) = 0. _d 0 |
94 |
tmpVN(i,j,bi,bj) = 0. _d 0 |
95 |
tmpUX(i,j,bi,bj) = 0. _d 0 |
96 |
tmpVY(i,j,bi,bj) = 0. _d 0 |
97 |
enddo |
98 |
enddo |
99 |
enddo |
100 |
enddo |
101 |
endif |
102 |
#endif |
103 |
|
104 |
#if (defined (ALLOW_CTRL) && \ |
105 |
defined (ALLOW_GENTIM2D_CONTROL)) |
106 |
if ( useCTRL.AND.ctrlUseGen) then |
107 |
DO bj = myByLo(myThid),myByHi(myThid) |
108 |
DO bi = myBxLo(myThid),mybxhi(myThid) |
109 |
DO j = 1,sNy |
110 |
DO i = 1,sNx |
111 |
do iarr = 1, maxCtrlTim2D |
112 |
#ifndef ALLOW_ROTATE_UV_CONTROLS |
113 |
if (xx_gentim2d_file(iarr).EQ.'xx_tauu') |
114 |
& ustress(i,j,bi,bj)=ustress(i,j,bi,bj)+ |
115 |
& xx_gentim2d(i,j,bi,bj,iarr) |
116 |
if (xx_gentim2d_file(iarr).EQ.'xx_tauv') |
117 |
& vstress(i,j,bi,bj)=vstress(i,j,bi,bj)+ |
118 |
& xx_gentim2d(i,j,bi,bj,iarr) |
119 |
#else |
120 |
if (xx_gentim2d_file(iarr).EQ.'xx_tauu') |
121 |
& tmpUE(i,j,bi,bj)=tmpUE(i,j,bi,bj) |
122 |
& +xx_gentim2d(i,j,bi,bj,iarr) |
123 |
if (xx_gentim2d_file(iarr).EQ.'xx_tauv') |
124 |
& tmpVN(i,j,bi,bj)=tmpVN(i,j,bi,bj) |
125 |
& +xx_gentim2d(i,j,bi,bj,iarr) |
126 |
#endif |
127 |
enddo |
128 |
ENDDO |
129 |
ENDDO |
130 |
ENDDO |
131 |
ENDDO |
132 |
endif !if (ctrlUseGen) then |
133 |
#endif |
134 |
|
135 |
#if (!defined (ALLOW_ECCO) || defined (ECCO_CTRL_DEPRECATED)) |
136 |
|
137 |
#ifdef ALLOW_HFLUX_CONTROL |
138 |
call ctrl_get_gen ( |
139 |
& xx_hflux_file, xx_hfluxstartdate, xx_hfluxperiod, |
140 |
& maskc, hflux, xx_hflux0, xx_hflux1, xx_hflux_dummy, |
141 |
& xx_hflux_remo_intercept, xx_hflux_remo_slope, |
142 |
& whflux, mytime, myiter, mythid ) |
143 |
#endif |
144 |
|
145 |
#ifdef ALLOW_SFLUX_CONTROL |
146 |
call ctrl_get_gen ( |
147 |
& xx_sflux_file, xx_sfluxstartdate, xx_sfluxperiod, |
148 |
& maskc, sflux, xx_sflux0, xx_sflux1, xx_sflux_dummy, |
149 |
& xx_sflux_remo_intercept, xx_sflux_remo_slope, |
150 |
& wsflux, mytime, myiter, mythid ) |
151 |
#endif |
152 |
|
153 |
IF ( .NOT.useAtmWind ) THEN |
154 |
|
155 |
IF ( .NOT.ctrlUseGen ) THEN |
156 |
#ifndef ALLOW_ROTATE_UV_CONTROLS |
157 |
|
158 |
#ifdef ALLOW_USTRESS_CONTROL |
159 |
call ctrl_get_gen ( |
160 |
& xx_tauu_file, xx_tauustartdate, xx_tauuperiod, |
161 |
& maskw, ustress, xx_tauu0, xx_tauu1, xx_tauu_dummy, |
162 |
& xx_tauu_remo_intercept, xx_tauu_remo_slope, |
163 |
& wtauu, mytime, myiter, mythid ) |
164 |
#endif |
165 |
|
166 |
#ifdef ALLOW_VSTRESS_CONTROL |
167 |
call ctrl_get_gen ( |
168 |
& xx_tauv_file, xx_tauvstartdate, xx_tauvperiod, |
169 |
& masks, vstress, xx_tauv0, xx_tauv1, xx_tauv_dummy, |
170 |
& xx_tauv_remo_intercept, xx_tauv_remo_slope, |
171 |
& wtauv, mytime, myiter, mythid ) |
172 |
#endif |
173 |
|
174 |
#else |
175 |
|
176 |
#if (defined (ALLOW_USTRESS_CONTROL) && defined (ALLOW_VSTRESS_CONTROL)) |
177 |
|
178 |
call ctrl_get_gen ( |
179 |
& xx_tauu_file, xx_tauustartdate, xx_tauuperiod, |
180 |
& maskc, tmpUE, xx_tauu0, xx_tauu1, xx_tauu_dummy, |
181 |
& xx_tauu_remo_intercept, xx_tauu_remo_slope, |
182 |
& wtauu, mytime, myiter, mythid ) |
183 |
|
184 |
call ctrl_get_gen ( |
185 |
& xx_tauv_file, xx_tauvstartdate, xx_tauvperiod, |
186 |
& maskc, tmpVN, xx_tauv0, xx_tauv1, xx_tauv_dummy, |
187 |
& xx_tauv_remo_intercept, xx_tauv_remo_slope, |
188 |
& wtauv, mytime, myiter, mythid ) |
189 |
|
190 |
#endif /* ALLOW_USTRESS_CONTROL and ALLOW_VSTRESS_CONTROL */ |
191 |
|
192 |
#endif /* ALLOW_ROTATE_UV_CONTROLS */ |
193 |
ENDIF ! (.NOT.ctrlUseGen) |
194 |
|
195 |
#else |
196 |
IF ( (useCTRL).AND.(.NOT.useAtmWind) ) THEN |
197 |
#endif /* undef ALLOW_ECCO || def ECCO_CTRL_DEPRECATED */ |
198 |
|
199 |
#ifdef ALLOW_ROTATE_UV_CONTROLS |
200 |
_EXCH_XY_RL(tmpUE,myThid) |
201 |
_EXCH_XY_RL(tmpVN,myThid) |
202 |
|
203 |
call rotate_uv2en_rl(tmpUX,tmpVY,tmpUE,tmpVN, |
204 |
& .FALSE.,stressIsOnCgrid,.TRUE.,1,mythid) |
205 |
|
206 |
IF ( stressIsOnCgrid ) THEN |
207 |
CALL EXCH_UV_XY_RL( tmpUX, tmpVY, .TRUE., myThid ) |
208 |
ELSE |
209 |
CALL EXCH_UV_AGRID_3D_RL( tmpUX, tmpVY, .TRUE., 1, myThid) |
210 |
ENDIF |
211 |
|
212 |
do bj = mybylo(mythid),mybyhi(mythid) |
213 |
do bi = mybxlo(mythid),mybxhi(mythid) |
214 |
do j = 1-oly,sny+oly |
215 |
do i = 1-olx,snx+olx |
216 |
ustress(i,j,bi,bj)=ustress(i,j,bi,bj)+tmpUX(i,j,bi,bj) |
217 |
vstress(i,j,bi,bj)=vstress(i,j,bi,bj)+tmpVY(i,j,bi,bj) |
218 |
enddo |
219 |
enddo |
220 |
enddo |
221 |
enddo |
222 |
#endif /* ALLOW_ROTATE_UV_CONTROLS */ |
223 |
|
224 |
ENDIF !( .NOT.useAtmWind ) |
225 |
|
226 |
#endif /* ALLOW_CTRL */ |
227 |
|
228 |
end |