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