1 |
gforget |
1.7 |
C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_map_ini_gentim2d.F,v 1.6 2015/03/23 21:07:37 gforget Exp $ |
2 |
gforget |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "CTRL_OPTIONS.h" |
5 |
gforget |
1.3 |
#ifdef ALLOW_AUTODIFF |
6 |
|
|
# include "AUTODIFF_OPTIONS.h" |
7 |
|
|
#endif |
8 |
gforget |
1.1 |
|
9 |
|
|
CBOP |
10 |
|
|
C !ROUTINE: CTRL_MAP_INI_GENTIM2D |
11 |
|
|
C !INTERFACE: |
12 |
|
|
SUBROUTINE CTRL_MAP_INI_GENTIM2D( myThid ) |
13 |
|
|
|
14 |
|
|
C !DESCRIPTION: \bv |
15 |
|
|
C *================================================================= |
16 |
|
|
C | SUBROUTINE CTRL_MAP_INI_GENTIM2D |
17 |
|
|
C | Dimensionalize and preprocess time variable controls. |
18 |
|
|
C *================================================================= |
19 |
|
|
C \ev |
20 |
|
|
|
21 |
|
|
C !USES: |
22 |
|
|
IMPLICIT NONE |
23 |
|
|
|
24 |
|
|
C == global variables == |
25 |
|
|
#include "SIZE.h" |
26 |
|
|
#include "EEPARAMS.h" |
27 |
|
|
#include "PARAMS.h" |
28 |
|
|
#include "GRID.h" |
29 |
|
|
#include "DYNVARS.h" |
30 |
|
|
#include "FFIELDS.h" |
31 |
|
|
#include "CTRL_SIZE.h" |
32 |
|
|
#include "ctrl.h" |
33 |
|
|
#include "optim.h" |
34 |
|
|
#include "ctrl_dummy.h" |
35 |
|
|
#include "CTRL_GENARR.h" |
36 |
|
|
#ifdef ALLOW_PTRACERS |
37 |
|
|
# include "PTRACERS_SIZE.h" |
38 |
|
|
# include "PTRACERS_FIELDS.h" |
39 |
|
|
#endif |
40 |
gforget |
1.3 |
#ifdef ALLOW_AUTODIFF |
41 |
|
|
#include "tamc.h" |
42 |
|
|
#endif |
43 |
gforget |
1.1 |
|
44 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
45 |
|
|
C == routine arguments == |
46 |
|
|
INTEGER myThid |
47 |
|
|
|
48 |
|
|
#ifdef ALLOW_GENTIM2D_CONTROL |
49 |
|
|
C !LOCAL VARIABLES: |
50 |
|
|
C == local variables == |
51 |
|
|
integer iarr |
52 |
|
|
integer smoothOpNb |
53 |
|
|
character*(80) fnamegenIn |
54 |
|
|
character*(80) fnamegenOut |
55 |
heimbach |
1.5 |
character*(80) fnamebase |
56 |
gforget |
1.1 |
integer startrec |
57 |
|
|
integer endrec |
58 |
|
|
integer diffrec |
59 |
|
|
integer irec, jrec, krec |
60 |
|
|
integer replicated_nrec |
61 |
|
|
integer replicated_ntimes |
62 |
|
|
logical doglobalread |
63 |
|
|
logical ladinit |
64 |
|
|
_RL xx_gen(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
65 |
|
|
integer bi,bj |
66 |
|
|
integer i,j,k2 |
67 |
|
|
INTEGER ILNBLNK |
68 |
|
|
EXTERNAL ILNBLNK |
69 |
|
|
integer ilgen |
70 |
|
|
CEOP |
71 |
|
|
|
72 |
|
|
c-- Now, read the control vector. |
73 |
|
|
doglobalread = .false. |
74 |
|
|
ladinit = .false. |
75 |
|
|
|
76 |
|
|
C-- generic 2D control variables |
77 |
|
|
DO iarr = 1, maxCtrlTim2D |
78 |
|
|
|
79 |
gforget |
1.3 |
diffrec=0 |
80 |
|
|
startrec=0 |
81 |
|
|
endrec=0 |
82 |
|
|
|
83 |
heimbach |
1.5 |
#ifndef ALLOW_OPENAD |
84 |
gforget |
1.1 |
if (xx_gentim2d_weight(iarr).NE.' ') then |
85 |
heimbach |
1.5 |
#endif |
86 |
gforget |
1.1 |
|
87 |
heimbach |
1.5 |
fnamebase = xx_gentim2d_file(iarr) |
88 |
|
|
call ctrl_init_rec ( fnamebase, |
89 |
gforget |
1.1 |
I xx_gentim2d_startdate1(iarr), |
90 |
|
|
I xx_gentim2d_startdate2(iarr), |
91 |
|
|
I xx_gentim2d_period(iarr), |
92 |
|
|
I 1, |
93 |
|
|
O xx_gentim2d_startdate(1,iarr), |
94 |
|
|
O diffrec, startrec, endrec, |
95 |
|
|
I myThid ) |
96 |
|
|
|
97 |
|
|
smoothOpNb=1 |
98 |
|
|
do k2 = 1, maxCtrlProc |
99 |
|
|
if (xx_gentim2d_preproc(k2,iarr).EQ.'smooth') then |
100 |
|
|
if (xx_gentim2d_preproc_i(k2,iarr).NE.0) |
101 |
|
|
& smoothOpNb=xx_gentim2d_preproc_i(k2,iarr) |
102 |
|
|
endif |
103 |
|
|
enddo |
104 |
|
|
|
105 |
|
|
replicated_nrec=endrec |
106 |
|
|
replicated_ntimes=0 |
107 |
|
|
do k2 = 1, maxCtrlProc |
108 |
|
|
if (xx_gentim2d_preproc(k2,iarr).EQ.'replicate') then |
109 |
|
|
if (xx_gentim2d_preproc_i(k2,iarr).NE.0) then |
110 |
|
|
replicated_nrec=min(endrec,xx_gentim2d_preproc_i(k2,iarr)) |
111 |
|
|
replicated_ntimes= |
112 |
|
|
& int(float(endrec)/float(replicated_nrec)) |
113 |
|
|
if (replicated_ntimes*replicated_nrec.LT.endrec) |
114 |
|
|
& replicated_ntimes=replicated_ntimes+1 |
115 |
|
|
if (replicated_ntimes*replicated_nrec.GT.endrec) |
116 |
|
|
& replicated_ntimes=replicated_ntimes-1 |
117 |
|
|
endif |
118 |
|
|
endif |
119 |
|
|
enddo |
120 |
|
|
|
121 |
gforget |
1.7 |
fnamebase = xx_gentim2d_file(iarr) |
122 |
|
|
ilgen=ilnblnk( fnamebase ) |
123 |
|
|
write(fnamegenIn(1:80),'(2a,i10.10)') |
124 |
|
|
& fnamebase(1:ilgen),'.',optimcycle |
125 |
|
|
write(fnamegenOut(1:80),'(2a,i10.10)') |
126 |
|
|
& fnamebase(1:ilgen),'.effective.',optimcycle |
127 |
|
|
|
128 |
|
|
DO jrec = 1, replicated_ntimes+1 |
129 |
gforget |
1.1 |
DO irec = 1, replicated_nrec |
130 |
gforget |
1.3 |
#ifdef ALLOW_AUTODIFF |
131 |
|
|
CADJ STORE xx_gentim2d_dummy = ctrltape, key = 1 , kind = isbyte |
132 |
|
|
#endif |
133 |
gforget |
1.7 |
krec=replicated_nrec*(jrec-1)+irec |
134 |
|
|
IF (krec.LE.endrec) THEN |
135 |
|
|
#ifdef ALLOW_AUTODIFF |
136 |
|
|
call active_read_xy( fnamegenIn, xx_gen, irec, |
137 |
|
|
& doglobalread, ladinit, optimcycle, |
138 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
139 |
|
|
#else |
140 |
|
|
CALL READ_REC_XY_RL( fnamegenIn, xx_gen, iRec, 1, myThid ) |
141 |
|
|
#endif |
142 |
|
|
#ifdef ALLOW_AUTODIFF |
143 |
|
|
call active_write_xy( fnamegenOut, xx_gen, krec, optimcycle, |
144 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
145 |
|
|
#else |
146 |
|
|
CALL WRITE_REC_XY_RL( fnamegenOut, xx_gen, iRec, 1, myThid ) |
147 |
|
|
#endif |
148 |
|
|
ENDIF |
149 |
|
|
ENDDO |
150 |
|
|
ENDDO |
151 |
|
|
|
152 |
|
|
fnamebase = xx_gentim2d_file(iarr) |
153 |
|
|
ilgen=ilnblnk( fnamebase ) |
154 |
|
|
write(fnamegenIn(1:80),'(2a,i10.10)') |
155 |
|
|
& fnamebase(1:ilgen),'.effective.',optimcycle |
156 |
|
|
write(fnamegenOut(1:80),'(2a,i10.10)') |
157 |
|
|
& fnamebase(1:ilgen),'.effective.',optimcycle |
158 |
|
|
|
159 |
|
|
DO irec = 1, endrec |
160 |
|
|
#ifdef ALLOW_AUTODIFF |
161 |
|
|
CADJ STORE xx_gentim2d_dummy = ctrltape, key = 1 , kind = isbyte |
162 |
|
|
#endif |
163 |
gforget |
1.1 |
|
164 |
gforget |
1.6 |
#ifdef ALLOW_AUTODIFF |
165 |
gforget |
1.1 |
call active_read_xy( fnamegenIn, xx_gen, irec, |
166 |
|
|
& doglobalread, ladinit, optimcycle, |
167 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
168 |
gforget |
1.6 |
#else |
169 |
|
|
CALL READ_REC_XY_RL( fnamegenIn, xx_gen, iRec, 1, myThid ) |
170 |
|
|
#endif |
171 |
gforget |
1.1 |
|
172 |
heimbach |
1.5 |
#ifndef ALLOW_OPENAD |
173 |
gforget |
1.7 |
jrec=1 |
174 |
gforget |
1.1 |
do k2 = 1, maxCtrlProc |
175 |
gforget |
1.7 |
if (xx_gentim2d_preproc(k2,iarr).EQ.'variaweight') jrec=irec |
176 |
gforget |
1.1 |
enddo |
177 |
gforget |
1.7 |
call mdsreadfield( xx_gentim2d_weight(iarr), ctrlprec, 'RL', |
178 |
|
|
& 1, wgentim2d(1-Olx,1-Oly,1,1,iarr), jrec, myThid ) |
179 |
heimbach |
1.5 |
#endif |
180 |
gforget |
1.1 |
|
181 |
|
|
#ifdef ALLOW_SMOOTH |
182 |
|
|
IF ( ctrlSmoothCorrel2D ) THEN |
183 |
|
|
IF ( useSMOOTH ) THEN |
184 |
|
|
call smooth_correl2D(xx_gen,maskC,smoothOpNb,mythid) |
185 |
|
|
|
186 |
|
|
DO bj=myByLo(myThid), myByHi(myThid) |
187 |
|
|
DO bi=myBxLo(myThid), myBxHi(myThid) |
188 |
|
|
DO j = 1,sNy |
189 |
|
|
DO i = 1,sNx |
190 |
|
|
if ((maskC(i,j,1,bi,bj).NE.0.).AND. |
191 |
|
|
& (wgentim2d(i,j,bi,bj,iarr).GT.0.)) then |
192 |
|
|
xx_gen(i,j,bi,bj)=xx_gen(i,j,bi,bj) |
193 |
|
|
& /sqrt(wgentim2d(i,j,bi,bj,iarr)) |
194 |
|
|
else |
195 |
|
|
xx_gen(i,j,bi,bj)=0. _d 0 |
196 |
|
|
endif |
197 |
|
|
ENDDO |
198 |
|
|
ENDDO |
199 |
|
|
ENDDO |
200 |
|
|
ENDDO |
201 |
|
|
|
202 |
gforget |
1.4 |
CALL EXCH_XY_RL ( xx_gen , myThid ) |
203 |
gforget |
1.1 |
ENDIF |
204 |
|
|
ENDIF |
205 |
|
|
#endif /* ALLOW_SMOOTH */ |
206 |
|
|
|
207 |
gforget |
1.6 |
|
208 |
|
|
#ifdef ALLOW_AUTODIFF |
209 |
gforget |
1.1 |
call active_write_xy( fnamegenOut, xx_gen, irec, optimcycle, |
210 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
211 |
gforget |
1.6 |
#else |
212 |
|
|
CALL WRITE_REC_XY_RL( fnamegenOut, xx_gen, iRec, 1, myThid ) |
213 |
|
|
#endif |
214 |
gforget |
1.1 |
|
215 |
|
|
c-- end irec loop |
216 |
|
|
ENDDO |
217 |
|
|
|
218 |
heimbach |
1.5 |
#ifndef ALLOW_OPENAD |
219 |
gforget |
1.1 |
endif |
220 |
heimbach |
1.5 |
#endif |
221 |
gforget |
1.1 |
|
222 |
|
|
c-- end iarr loop |
223 |
|
|
ENDDO |
224 |
|
|
|
225 |
|
|
#endif /* ALLOW_GENTIM2D_CONTROL */ |
226 |
|
|
|
227 |
|
|
RETURN |
228 |
|
|
END |
229 |
|
|
|