1 |
gforget |
1.4 |
C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_map_ini_gentim2d.F,v 1.3 2014/12/04 22:44:57 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 |
gforget |
1.2 |
#ifndef ALLOW_OPENAD |
26 |
gforget |
1.1 |
#include "SIZE.h" |
27 |
|
|
#include "EEPARAMS.h" |
28 |
|
|
#include "PARAMS.h" |
29 |
|
|
#include "GRID.h" |
30 |
|
|
#include "DYNVARS.h" |
31 |
|
|
#include "FFIELDS.h" |
32 |
|
|
#include "CTRL_SIZE.h" |
33 |
|
|
#include "ctrl.h" |
34 |
|
|
#include "optim.h" |
35 |
|
|
#include "ctrl_dummy.h" |
36 |
|
|
#include "CTRL_GENARR.h" |
37 |
|
|
#ifdef ALLOW_PTRACERS |
38 |
|
|
# include "PTRACERS_SIZE.h" |
39 |
|
|
# include "PTRACERS_FIELDS.h" |
40 |
|
|
#endif |
41 |
gforget |
1.3 |
#ifdef ALLOW_AUTODIFF |
42 |
|
|
#include "tamc.h" |
43 |
|
|
#endif |
44 |
gforget |
1.2 |
#endif |
45 |
gforget |
1.1 |
|
46 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
47 |
|
|
C == routine arguments == |
48 |
|
|
INTEGER myThid |
49 |
|
|
|
50 |
gforget |
1.2 |
#ifndef ALLOW_OPENAD |
51 |
gforget |
1.1 |
#ifdef ALLOW_GENTIM2D_CONTROL |
52 |
|
|
C !LOCAL VARIABLES: |
53 |
|
|
C == local variables == |
54 |
|
|
integer iarr |
55 |
|
|
integer smoothOpNb |
56 |
|
|
character*(80) fnamegenIn |
57 |
|
|
character*(80) fnamegenOut |
58 |
|
|
integer startrec |
59 |
|
|
integer endrec |
60 |
|
|
integer diffrec |
61 |
|
|
integer irec, jrec, krec |
62 |
|
|
integer replicated_nrec |
63 |
|
|
integer replicated_ntimes |
64 |
|
|
logical doglobalread |
65 |
|
|
logical ladinit |
66 |
|
|
_RL xx_gen(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
67 |
|
|
integer bi,bj |
68 |
|
|
integer i,j,k2 |
69 |
|
|
INTEGER ILNBLNK |
70 |
|
|
EXTERNAL ILNBLNK |
71 |
|
|
integer ilgen |
72 |
|
|
CEOP |
73 |
|
|
|
74 |
|
|
c-- Now, read the control vector. |
75 |
|
|
doglobalread = .false. |
76 |
|
|
ladinit = .false. |
77 |
|
|
|
78 |
|
|
C-- generic 2D control variables |
79 |
|
|
DO iarr = 1, maxCtrlTim2D |
80 |
|
|
|
81 |
gforget |
1.3 |
diffrec=0 |
82 |
|
|
startrec=0 |
83 |
|
|
endrec=0 |
84 |
|
|
|
85 |
gforget |
1.1 |
if (xx_gentim2d_weight(iarr).NE.' ') then |
86 |
|
|
|
87 |
|
|
call ctrl_init_rec ( xx_gentim2d_file(iarr)(1:MAX_LEN_FNAM), |
88 |
|
|
I xx_gentim2d_startdate1(iarr), |
89 |
|
|
I xx_gentim2d_startdate2(iarr), |
90 |
|
|
I xx_gentim2d_period(iarr), |
91 |
|
|
I 1, |
92 |
|
|
O xx_gentim2d_startdate(1,iarr), |
93 |
|
|
O diffrec, startrec, endrec, |
94 |
|
|
I myThid ) |
95 |
|
|
|
96 |
|
|
ilgen=ilnblnk( xx_gentim2d_file(iarr) ) |
97 |
|
|
write(fnamegenIn(1:80),'(2a,i10.10)') |
98 |
|
|
& xx_gentim2d_file(iarr)(1:ilgen), '.', optimcycle |
99 |
|
|
write(fnamegenOut(1:80),'(2a,i10.10)') |
100 |
|
|
& xx_gentim2d_file(iarr)(1:ilgen),'.effective.',optimcycle |
101 |
|
|
|
102 |
|
|
smoothOpNb=1 |
103 |
|
|
do k2 = 1, maxCtrlProc |
104 |
|
|
if (xx_gentim2d_preproc(k2,iarr).EQ.'smooth') then |
105 |
|
|
if (xx_gentim2d_preproc_i(k2,iarr).NE.0) |
106 |
|
|
& smoothOpNb=xx_gentim2d_preproc_i(k2,iarr) |
107 |
|
|
endif |
108 |
|
|
enddo |
109 |
|
|
|
110 |
|
|
replicated_nrec=endrec |
111 |
|
|
replicated_ntimes=0 |
112 |
|
|
do k2 = 1, maxCtrlProc |
113 |
|
|
if (xx_gentim2d_preproc(k2,iarr).EQ.'replicate') then |
114 |
|
|
if (xx_gentim2d_preproc_i(k2,iarr).NE.0) then |
115 |
|
|
replicated_nrec=min(endrec,xx_gentim2d_preproc_i(k2,iarr)) |
116 |
|
|
replicated_ntimes= |
117 |
|
|
& int(float(endrec)/float(replicated_nrec)) |
118 |
|
|
if (replicated_ntimes*replicated_nrec.LT.endrec) |
119 |
|
|
& replicated_ntimes=replicated_ntimes+1 |
120 |
|
|
if (replicated_ntimes*replicated_nrec.GT.endrec) |
121 |
|
|
& replicated_ntimes=replicated_ntimes-1 |
122 |
|
|
endif |
123 |
|
|
endif |
124 |
|
|
enddo |
125 |
|
|
|
126 |
|
|
DO irec = 1, replicated_nrec |
127 |
gforget |
1.3 |
#ifdef ALLOW_AUTODIFF |
128 |
|
|
CADJ STORE xx_gentim2d_dummy = ctrltape, key = 1 , kind = isbyte |
129 |
|
|
#endif |
130 |
gforget |
1.1 |
|
131 |
|
|
call active_read_xy( fnamegenIn, xx_gen, irec, |
132 |
|
|
& doglobalread, ladinit, optimcycle, |
133 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
134 |
|
|
|
135 |
|
|
do k2 = 1, maxCtrlProc |
136 |
|
|
if (xx_gentim2d_preproc(k2,iarr).EQ.'variaweight') |
137 |
|
|
& call mdsreadfield( xx_gentim2d_weight(iarr), ctrlprec, 'RL', |
138 |
|
|
& 1, wgentim2d(1-Olx,1-Oly,1,1,iarr), irec, myThid ) |
139 |
|
|
enddo |
140 |
|
|
|
141 |
|
|
#ifdef ALLOW_SMOOTH |
142 |
|
|
IF ( ctrlSmoothCorrel2D ) THEN |
143 |
|
|
IF ( useSMOOTH ) THEN |
144 |
|
|
call smooth_correl2D(xx_gen,maskC,smoothOpNb,mythid) |
145 |
|
|
|
146 |
|
|
DO bj=myByLo(myThid), myByHi(myThid) |
147 |
|
|
DO bi=myBxLo(myThid), myBxHi(myThid) |
148 |
|
|
DO j = 1,sNy |
149 |
|
|
DO i = 1,sNx |
150 |
|
|
if ((maskC(i,j,1,bi,bj).NE.0.).AND. |
151 |
|
|
& (wgentim2d(i,j,bi,bj,iarr).GT.0.)) then |
152 |
|
|
xx_gen(i,j,bi,bj)=xx_gen(i,j,bi,bj) |
153 |
|
|
& /sqrt(wgentim2d(i,j,bi,bj,iarr)) |
154 |
|
|
else |
155 |
|
|
xx_gen(i,j,bi,bj)=0. _d 0 |
156 |
|
|
endif |
157 |
|
|
ENDDO |
158 |
|
|
ENDDO |
159 |
|
|
ENDDO |
160 |
|
|
ENDDO |
161 |
|
|
|
162 |
gforget |
1.4 |
CALL EXCH_XY_RL ( xx_gen , myThid ) |
163 |
gforget |
1.1 |
ENDIF |
164 |
|
|
ENDIF |
165 |
|
|
#endif /* ALLOW_SMOOTH */ |
166 |
|
|
|
167 |
|
|
call active_write_xy( fnamegenOut, xx_gen, irec, optimcycle, |
168 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
169 |
|
|
|
170 |
|
|
c-- end irec loop |
171 |
|
|
ENDDO |
172 |
|
|
|
173 |
|
|
DO jrec = 1, replicated_ntimes |
174 |
|
|
DO irec = 1, replicated_nrec |
175 |
gforget |
1.3 |
#ifdef ALLOW_AUTODIFF |
176 |
|
|
CADJ STORE xx_gentim2d_dummy = ctrltape, key = 1 , kind = isbyte |
177 |
|
|
#endif |
178 |
gforget |
1.1 |
krec=replicated_nrec*(jrec-1)+irec |
179 |
|
|
IF (krec.LE.endrec) THEN |
180 |
|
|
call active_read_xy( fnamegenOut, xx_gen, irec, |
181 |
|
|
& doglobalread, ladinit, optimcycle, |
182 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
183 |
|
|
call active_write_xy( fnamegenOut, xx_gen, krec, optimcycle, |
184 |
|
|
& mythid, xx_gentim2d_dummy(iarr) ) |
185 |
|
|
ENDIF |
186 |
|
|
ENDDO |
187 |
|
|
ENDDO |
188 |
|
|
|
189 |
|
|
endif |
190 |
|
|
|
191 |
|
|
c-- end iarr loop |
192 |
|
|
ENDDO |
193 |
|
|
|
194 |
|
|
#endif /* ALLOW_GENTIM2D_CONTROL */ |
195 |
gforget |
1.2 |
#endif /* ALLOW_OPENAD */ |
196 |
gforget |
1.1 |
|
197 |
|
|
RETURN |
198 |
|
|
END |
199 |
|
|
|