1 |
dimitri |
1.9 |
c $Header: /usr/local/gcmpack/MITgcm/pkg/exf/exf_mapfields.F,v 1.8 2003/11/06 22:11:03 heimbach Exp $ |
2 |
heimbach |
1.1 |
|
3 |
edhill |
1.7 |
#include "EXF_OPTIONS.h" |
4 |
heimbach |
1.1 |
|
5 |
heimbach |
1.2 |
subroutine exf_mapfields( mythid ) |
6 |
heimbach |
1.1 |
|
7 |
|
|
c ================================================================== |
8 |
heimbach |
1.2 |
c SUBROUTINE exf_mapfields |
9 |
heimbach |
1.1 |
c ================================================================== |
10 |
|
|
c |
11 |
dimitri |
1.5 |
c o Map external forcing fields (ustress, vstress, hflux, sflux, |
12 |
|
|
c swflux, apressure, climsss, climsst, etc.) onto ocean model |
13 |
|
|
c arrays (fu, fv, Qnet, EmPmR, Qsw, pload, sss, sst, etc.). |
14 |
|
|
c This routine is included to separate the ocean state estimation |
15 |
|
|
c tool as much as possible from the ocean model. Unit and sign |
16 |
|
|
c conventions can be customized using variables exf_outscal_*, |
17 |
|
|
c which are set in exf_readparms.F. See the header files |
18 |
|
|
c exf_fields.h and FFIELDS.h for definitions of the various input |
19 |
|
|
c and output fields and for default unit and sign convetions. |
20 |
heimbach |
1.1 |
c |
21 |
|
|
c started: Christian Eckert eckert@mit.edu 09-Aug-1999 |
22 |
|
|
c |
23 |
|
|
c changed: Christian Eckert eckert@mit.edu 11-Jan-2000 |
24 |
|
|
c - Restructured the code in order to create a package |
25 |
|
|
c for the MITgcmUV. |
26 |
|
|
c |
27 |
|
|
c Christian Eckert eckert@mit.edu 12-Feb-2000 |
28 |
|
|
c - Changed Routine names (package prefix: exf_) |
29 |
|
|
c |
30 |
|
|
c Patrick Heimbach, heimbach@mit.edu 06-May-2000 |
31 |
|
|
c - added and changed CPP flag structure for |
32 |
|
|
c ALLOW_BULKFORMULAE, ALLOW_ATM_TEMP |
33 |
|
|
c |
34 |
|
|
c Patrick Heimbach, heimbach@mit.edu 23-May-2000 |
35 |
|
|
c - sign change of ustress/vstress incorporated into |
36 |
dimitri |
1.5 |
c scaling factors exf_outscal_ust, exf_outscal_vst |
37 |
dimitri |
1.4 |
c |
38 |
dimitri |
1.5 |
c mods for pkg/seaice: menemenlis@jpl.nasa.gov 20-Dec-2002 |
39 |
dimitri |
1.4 |
c |
40 |
heimbach |
1.1 |
c ================================================================== |
41 |
heimbach |
1.2 |
c SUBROUTINE exf_mapfields |
42 |
heimbach |
1.1 |
c ================================================================== |
43 |
|
|
|
44 |
|
|
implicit none |
45 |
|
|
|
46 |
|
|
c == global variables == |
47 |
|
|
|
48 |
|
|
#include "EEPARAMS.h" |
49 |
|
|
#include "SIZE.h" |
50 |
|
|
#include "FFIELDS.h" |
51 |
heimbach |
1.8 |
#include "GRID.h" |
52 |
|
|
|
53 |
heimbach |
1.2 |
#include "exf_param.h" |
54 |
heimbach |
1.1 |
#include "exf_constants.h" |
55 |
|
|
#include "exf_fields.h" |
56 |
|
|
#include "exf_clim_fields.h" |
57 |
heimbach |
1.2 |
#ifdef ALLOW_AUTODIFF_TAMC |
58 |
|
|
# include "tamc.h" |
59 |
|
|
# include "tamc_keys.h" |
60 |
|
|
#endif |
61 |
heimbach |
1.1 |
c == routine arguments == |
62 |
|
|
|
63 |
|
|
c mythid - thread number for this instance of the routine. |
64 |
|
|
|
65 |
|
|
integer mythid |
66 |
|
|
|
67 |
|
|
c == local variables == |
68 |
|
|
|
69 |
|
|
integer bi,bj |
70 |
|
|
integer i,j |
71 |
|
|
integer jtlo |
72 |
|
|
integer jthi |
73 |
|
|
integer itlo |
74 |
|
|
integer ithi |
75 |
|
|
integer jmin |
76 |
|
|
integer jmax |
77 |
|
|
integer imin |
78 |
|
|
integer imax |
79 |
|
|
|
80 |
|
|
c == end of interface == |
81 |
|
|
|
82 |
|
|
jtlo = mybylo(mythid) |
83 |
|
|
jthi = mybyhi(mythid) |
84 |
|
|
itlo = mybxlo(mythid) |
85 |
|
|
ithi = mybxhi(mythid) |
86 |
|
|
jmin = 1-oly |
87 |
|
|
jmax = sny+oly |
88 |
|
|
imin = 1-olx |
89 |
|
|
imax = snx+olx |
90 |
|
|
|
91 |
|
|
do bj = jtlo,jthi |
92 |
|
|
do bi = itlo,ithi |
93 |
heimbach |
1.2 |
|
94 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
95 |
|
|
act1 = bi - myBxLo(myThid) |
96 |
|
|
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
97 |
|
|
act2 = bj - myByLo(myThid) |
98 |
|
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
99 |
|
|
act3 = myThid - 1 |
100 |
|
|
max3 = nTx*nTy |
101 |
|
|
act4 = ikey_dynamics - 1 |
102 |
|
|
ikey = (act1 + 1) + act2*max1 |
103 |
|
|
& + act3*max1*max2 |
104 |
|
|
& + act4*max1*max2*max3 |
105 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
106 |
|
|
|
107 |
heimbach |
1.1 |
do j = jmin,jmax |
108 |
|
|
do i = imin,imax |
109 |
dimitri |
1.5 |
c Heat flux. |
110 |
heimbach |
1.6 |
qnet(i,j,bi,bj) = exf_outscal_hflux*hflux(i,j,bi,bj) |
111 |
heimbach |
1.2 |
enddo |
112 |
|
|
enddo |
113 |
heimbach |
1.1 |
|
114 |
heimbach |
1.2 |
|
115 |
|
|
do j = jmin,jmax |
116 |
|
|
do i = imin,imax |
117 |
dimitri |
1.5 |
c Salt flux. |
118 |
heimbach |
1.6 |
empmr(i,j,bi,bj)= exf_outscal_sflux*sflux(i,j,bi,bj) |
119 |
heimbach |
1.2 |
enddo |
120 |
|
|
enddo |
121 |
heimbach |
1.1 |
|
122 |
heimbach |
1.2 |
#ifdef ALLOW_AUTODIFF_TAMC |
123 |
|
|
CADJ STORE ustress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte |
124 |
|
|
#endif |
125 |
|
|
do j = jmin,jmax |
126 |
|
|
do i = imin,imax |
127 |
heimbach |
1.1 |
c Zonal wind stress. |
128 |
heimbach |
1.2 |
if (ustress(i,j,bi,bj).gt.2.0D0) then |
129 |
|
|
ustress(i,j,bi,bj)=2.0D0 |
130 |
|
|
endif |
131 |
|
|
enddo |
132 |
|
|
enddo |
133 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
134 |
|
|
CADJ STORE ustress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte |
135 |
|
|
#endif |
136 |
|
|
do j = jmin,jmax |
137 |
|
|
do i = imin,imax |
138 |
|
|
if (ustress(i,j,bi,bj).lt.-2.0D0) then |
139 |
|
|
ustress(i,j,bi,bj)=-2.0D0 |
140 |
|
|
endif |
141 |
|
|
enddo |
142 |
|
|
enddo |
143 |
|
|
do j = jmin,jmax |
144 |
heimbach |
1.8 |
do i = imin+1,imax |
145 |
dimitri |
1.9 |
#if (defined (ALLOW_BULKFORMULAE) || defined (USE_EXF_INTERPOLATION)) |
146 |
heimbach |
1.8 |
c Shift wind stresses calculated at C-points to W/S points |
147 |
|
|
fu(i,j,bi,bj) = exf_outscal_ustress* |
148 |
|
|
& (ustress(i,j,bi,bj)+ustress(i-1,j,bi,bj))/2.* |
149 |
|
|
& maskW(i,j,1,bi,bj) |
150 |
|
|
#else |
151 |
|
|
fu(i,j,bi,bj) = exf_outscal_ustress*ustress(i,j,bi,bj) |
152 |
|
|
#endif |
153 |
heimbach |
1.2 |
enddo |
154 |
|
|
enddo |
155 |
heimbach |
1.1 |
|
156 |
heimbach |
1.2 |
#ifdef ALLOW_AUTODIFF_TAMC |
157 |
|
|
CADJ STORE vstress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte |
158 |
|
|
#endif |
159 |
|
|
do j = jmin,jmax |
160 |
|
|
do i = imin,imax |
161 |
heimbach |
1.1 |
c Meridional wind stress. |
162 |
heimbach |
1.2 |
if (vstress(i,j,bi,bj).gt.2.0D0) then |
163 |
|
|
vstress(i,j,bi,bj)=2.0D0 |
164 |
|
|
endif |
165 |
|
|
enddo |
166 |
|
|
enddo |
167 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
168 |
|
|
CADJ STORE vstress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte |
169 |
|
|
#endif |
170 |
|
|
do j = jmin,jmax |
171 |
|
|
do i = imin,imax |
172 |
|
|
if (vstress(i,j,bi,bj).lt.-2.0D0) then |
173 |
|
|
vstress(i,j,bi,bj)=-2.0D0 |
174 |
|
|
endif |
175 |
|
|
enddo |
176 |
|
|
enddo |
177 |
heimbach |
1.8 |
do j = jmin+1,jmax |
178 |
heimbach |
1.2 |
do i = imin,imax |
179 |
dimitri |
1.9 |
#if (defined (ALLOW_BULKFORMULAE) || defined (USE_EXF_INTERPOLATION)) |
180 |
heimbach |
1.8 |
c Shift wind stresses calculated at C-points to W/S points |
181 |
|
|
fv(i,j,bi,bj) = exf_outscal_vstress* |
182 |
|
|
& (vstress(i,j,bi,bj)+vstress(i,j-1,bi,bj))/2.* |
183 |
|
|
& maskS(i,j,1,bi,bj) |
184 |
|
|
#else |
185 |
|
|
fv(i,j,bi,bj) = exf_outscal_vstress*vstress(i,j,bi,bj) |
186 |
|
|
#endif |
187 |
heimbach |
1.2 |
enddo |
188 |
|
|
enddo |
189 |
heimbach |
1.1 |
|
190 |
dimitri |
1.5 |
#ifdef SHORTWAVE_HEATING |
191 |
heimbach |
1.1 |
c Short wave radiative flux. |
192 |
heimbach |
1.2 |
do j = jmin,jmax |
193 |
|
|
do i = imin,imax |
194 |
heimbach |
1.6 |
qsw(i,j,bi,bj) = exf_outscal_swflux*swflux(i,j,bi,bj) |
195 |
heimbach |
1.2 |
enddo |
196 |
|
|
enddo |
197 |
heimbach |
1.1 |
#endif |
198 |
|
|
|
199 |
|
|
#ifdef ALLOW_CLIMSST_RELAXATION |
200 |
heimbach |
1.2 |
do j = jmin,jmax |
201 |
|
|
do i = imin,imax |
202 |
dimitri |
1.5 |
sst(i,j,bi,bj) = exf_outscal_sst*climsst(i,j,bi,bj) |
203 |
heimbach |
1.2 |
enddo |
204 |
|
|
enddo |
205 |
heimbach |
1.1 |
#endif |
206 |
|
|
|
207 |
|
|
#ifdef ALLOW_CLIMSSS_RELAXATION |
208 |
heimbach |
1.2 |
do j = jmin,jmax |
209 |
|
|
do i = imin,imax |
210 |
dimitri |
1.5 |
sss(i,j,bi,bj) = exf_outscal_sss*climsss(i,j,bi,bj) |
211 |
heimbach |
1.2 |
enddo |
212 |
|
|
enddo |
213 |
heimbach |
1.1 |
#endif |
214 |
|
|
|
215 |
heimbach |
1.2 |
#ifdef ATMOSPHERIC_LOADING |
216 |
|
|
do j = jmin,jmax |
217 |
|
|
do i = imin,imax |
218 |
dimitri |
1.5 |
pload(i,j,bi,bj)=exf_outscal_apressure*apressure(i,j,bi,bj) |
219 |
heimbach |
1.1 |
enddo |
220 |
|
|
enddo |
221 |
heimbach |
1.2 |
#endif |
222 |
|
|
|
223 |
heimbach |
1.1 |
enddo |
224 |
|
|
enddo |
225 |
|
|
|
226 |
|
|
c Update the tile edges. |
227 |
|
|
|
228 |
|
|
_EXCH_XY_R4( qnet, mythid ) |
229 |
|
|
_EXCH_XY_R4( empmr, mythid ) |
230 |
cheisey |
1.3 |
c _EXCH_XY_R4( fu, mythid ) |
231 |
|
|
c _EXCH_XY_R4( fv, mythid ) |
232 |
|
|
CALL EXCH_UV_XY_RS(fu, fv, .TRUE., myThid) |
233 |
dimitri |
1.5 |
#ifdef SHORTWAVE_HEATING |
234 |
heimbach |
1.1 |
_EXCH_XY_R4( qsw, mythid ) |
235 |
|
|
#endif |
236 |
|
|
#ifdef ALLOW_CLIMSST_RELAXATION |
237 |
|
|
_EXCH_XY_R4( sst, mythid ) |
238 |
|
|
#endif |
239 |
|
|
#ifdef ALLOW_CLIMSSS_RELAXATION |
240 |
|
|
_EXCH_XY_R4( sss, mythid ) |
241 |
heimbach |
1.2 |
#endif |
242 |
|
|
#ifdef ATMOSPHERIC_LOADING |
243 |
|
|
_EXCH_XY_R4( pload, mythid ) |
244 |
heimbach |
1.1 |
#endif |
245 |
|
|
|
246 |
|
|
end |