/[MITgcm]/MITgcm/optim/optim_numbmod.F
ViewVC logotype

Contents of /MITgcm/optim/optim_numbmod.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download)
Tue Feb 24 20:31:00 2015 UTC (9 years, 2 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint65j, checkpoint65k, checkpoint65l
Changes since 1.9: +4 -0 lines
Fix/update to main code (pkg/ctrl/)
Reported by Dan Amrhein

1
2 cph #ifdef TARGET_CRAY_VECTOR
3 cph # define NML_OPTIM ECCO_OPTIM
4 cph # define NML_ECCO ECCO_PARMS
5 cph #else
6 cph # define NML_OPTIM NML=ECCO_OPTIM
7 cph # define NML_ECCO NML=ECCO_PARMS
8 cph #endif
9
10 c ==================================================================
11 c
12 c optim.F: Routines for doing an off-line optimization after the
13 c ECCO forward and adjoint model have been run.
14 c
15 c numbmod - Returns number of variables.
16 c simul - Mid-level routine that calls the model and its
17 c adjoint
18 c model - Forward model.
19 c admodel - Modified forward model and adjoint model.
20 c initmod - Initialisation routine.
21 c postmod - Final routine that prints results.
22 c
23 c
24 c Documentation:
25 c
26 c The collection of these routines originated mainly from Ralf
27 c Giering. Patrick Heimbach improved and corrected some parts of
28 c the original code. Christian Eckert contributed the interface
29 c to the ECCO release of the MITgcmUV in order to get the off-
30 c line version going. The on-line optimisation uses a simple
31 c example, whereas the off-line version deals with the ECCO
32 c release output. The off-line version can, of course, only
33 c do one optimization step at a time.
34 c
35 c started: Christian Eckert eckert@mit.edu 15-Feb-2000
36 c
37 c - On-line and off-line capability and some cosmetic
38 c changes.
39 c
40 c changed: Patrick Heimbach heimbach@mit.edu 19-Jun-2000
41 c - finished, revised and debugged
42 c
43 c ==================================================================
44
45
46 subroutine optim_numbmod(
47 O nn
48 & )
49
50 c ==================================================================
51 c SUBROUTINE optim_numbmod
52 c ==================================================================
53 c
54 c o Set the number of control variables.
55 c
56 c started: Christian Eckert eckert@mit.edu 15-Feb-2000
57 c
58 c changed: Christian Eckert eckert@mit.edu 09-Mar-2000
59 c
60 c - Added ECCO layout.
61 c
62 c changed: Patrick Heimbach heimbach@mit.edu 19-Jun-2000
63 c - finished, revised and debugged
64 c
65 c ==================================================================
66 c SUBROUTINE optim_numbmod
67 c ==================================================================
68
69 IMPLICIT NONE
70
71 c == global variables ==
72
73 #include "EEPARAMS.h"
74 #include "SIZE.h"
75
76 cdfer#include "ecco.h"
77 #include "ctrl.h"
78 #include "optim.h"
79 #include "minimization.h"
80 #ifndef ECCO_CTRL_DEPRECATED
81 # include "ctrl_local_params.h"
82 # include "CTRL_OBCS.h"
83 #endif
84
85 c == routine arguments ==
86
87 integer nn
88
89 c == local variables ==
90
91 integer il
92 integer errio
93
94 _RL ff
95
96 #if defined (DYNAMIC)
97 _RL vv(nn)
98 #elif defined (USE_POINTER) || (MAX_INDEPEND == 0)
99 _RL vv
100 pointer (pvv,vv(1))
101 #else
102 integer nmax
103 parameter( nmax = MAX_INDEPEND )
104 _RL vv(nmax)
105 #endif
106
107 character*(max_len_prec) record
108
109 logical lheaderonly
110
111 c == external ==
112
113 integer ilnblnk
114
115 c == end of interface ==
116
117 namelist /CTRL_NML/
118 & xx_theta_file, xx_salt_file,
119 & xx_hflux_file, xx_hflux_remo_intercept, xx_hflux_remo_slope,
120 & xx_hfluxstartdate1, xx_hfluxstartdate2, xx_hfluxperiod,
121 & xx_sflux_file, xx_sflux_remo_intercept, xx_sflux_remo_slope,
122 & xx_sfluxstartdate1, xx_sfluxstartdate2, xx_sfluxperiod,
123 & xx_tauu_file, xx_tauu_remo_intercept, xx_tauu_remo_slope,
124 & xx_tauustartdate1, xx_tauustartdate2, xx_tauuperiod,
125 & xx_tauv_file, xx_tauv_remo_intercept, xx_tauv_remo_slope,
126 & xx_tauvstartdate1, xx_tauvstartdate2, xx_tauvperiod,
127 & xx_atemp_file, xx_atemp_remo_intercept, xx_atemp_remo_slope,
128 & xx_atempstartdate1, xx_atempstartdate2, xx_atempperiod,
129 & xx_aqh_file, xx_aqh_remo_intercept, xx_aqh_remo_slope,
130 & xx_aqhstartdate1, xx_aqhstartdate2, xx_aqhperiod,
131 & xx_precip_file, xx_precip_remo_intercept, xx_precip_remo_slope,
132 & xx_precipstartdate1, xx_precipstartdate2, xx_precipperiod,
133 & xx_swflux_file, xx_swflux_remo_intercept, xx_swflux_remo_slope,
134 & xx_swfluxstartdate1, xx_swfluxstartdate2, xx_swfluxperiod,
135 & xx_swdown_file, xx_swdown_remo_intercept, xx_swdown_remo_slope,
136 & xx_swdownstartdate1, xx_swdownstartdate2, xx_swdownperiod,
137 & xx_lwflux_file, xx_lwflux_remo_intercept, xx_lwflux_remo_slope,
138 & xx_lwfluxstartdate1, xx_lwfluxstartdate2, xx_lwfluxperiod,
139 & xx_lwdown_file, xx_lwdown_remo_intercept, xx_lwdown_remo_slope,
140 & xx_lwdownstartdate1, xx_lwdownstartdate2, xx_lwdownperiod,
141 & xx_evap_file, xx_evap_remo_intercept, xx_evap_remo_slope,
142 & xx_evapstartdate1, xx_evapstartdate2, xx_evapperiod,
143 & xx_snowprecip_file, xx_snowprecip_remo_intercept,
144 & xx_snowprecip_remo_slope, xx_snowprecipperiod,
145 & xx_snowprecipstartdate1, xx_snowprecipstartdate2,
146 & xx_apressure_file, xx_apressure_remo_intercept,
147 & xx_apressure_remo_slope, xx_apressureperiod,
148 & xx_apressurestartdate1, xx_apressurestartdate2,
149 & xx_runoff_file, xx_runoff_remo_intercept, xx_runoff_remo_slope,
150 & xx_runoffstartdate1, xx_runoffstartdate2, xx_runoffperiod,
151 & xx_uwind_file, xx_uwind_remo_intercept, xx_uwind_remo_slope,
152 & xx_uwindstartdate1, xx_uwindstartdate2, xx_uwindperiod,
153 & xx_vwind_file, xx_vwind_remo_intercept, xx_vwind_remo_slope,
154 & xx_vwindstartdate1, xx_vwindstartdate2, xx_vwindperiod,
155 & xx_obcsn_file, xx_obcss_file, xx_obcsw_file, xx_obcse_file,
156 & xx_obcsnstartdate1, xx_obcsnstartdate2, xx_obcsnperiod,
157 & xx_obcssstartdate1, xx_obcssstartdate2, xx_obcssperiod,
158 & xx_obcswstartdate1, xx_obcswstartdate2, xx_obcswperiod,
159 & xx_obcsestartdate1, xx_obcsestartdate2, xx_obcseperiod,
160 & xx_diffkr_file, xx_kapgm_file, xx_tr1_file,
161 & xx_sst_file, xx_sss_file,
162 & xx_sststartdate1, xx_sststartdate2, xx_sstperiod,
163 & xx_sssstartdate1, xx_sssstartdate2, xx_sssperiod,
164 & xx_depth_file, xx_efluxy_file, xx_efluxp_file,
165 & xx_bottomdrag_file, xx_edtaux_file, xx_edtauy_file,
166 & xx_uvel_file, xx_vvel_file, xx_etan_file,
167 & xx_shifwflx_file,
168 & xx_shifwflx_remo_intercept, xx_shifwflx_remo_slope,
169 & xx_shifwflxstartdate1, xx_shifwflxstartdate2, xx_shifwflxperiod,
170 & doInitXX, doPackDiag, doZscaleUnpack, doZscalePack,
171 & doMainUnpack, doMainPack, doAdmtlmBypassAD, delZexp
172 cdfer
173 & ,xx_hfluxm_file
174 cdfer
175
176 namelist /CTRL_PACKNAMES/
177 & yadmark, yctrlid, yctrlposunpack, yctrlpospack,
178 & ctrlname, costname, scalname, maskname, metaname
179
180 namelist /OPTIM/
181 & optimcycle,
182 & numiter, nfunc, fmin, iprint,
183 & epsf, epsx, epsg,
184 & nupdate, eps
185
186 c-- Preset the optimization parameters.
187 optimcycle = 0
188 nvars = 0
189 numiter = 1
190 nfunc = 1
191 fmin = 0.0
192 iprint = 10
193 epsx = 1.e-6
194 epsg = 1.e-6
195 eps = -1.e-6
196 nupdate = 1
197 ff = 0.
198 cdfer expId = 'MIT_CE_000'
199 yctrlid = 'MIT_CE_000'
200
201 modeldataunit = 14
202 scrunit1 = 11
203
204 c-- Read control parameters from file.
205 open(unit=scrunit1,status='scratch')
206
207 open(unit = modeldataunit,file = 'data.ctrl',
208 & status = 'old', iostat = errio)
209 if ( errio .lt. 0 ) then
210 stop ' stopped in optim_numbmod'
211 endif
212
213 do while ( .true. )
214 read(modeldataunit, fmt='(a)', end=21) record
215 il = max(ilnblnk(record),1)
216 if ( record(1:1) .ne. commentcharacter )
217 & write(unit=scrunit1, fmt='(a)') record(:il)
218 enddo
219 21 continue
220 close( modeldataunit )
221
222 rewind( scrunit1 )
223 read(unit = scrunit1, nml = ctrl_nml)
224 read(unit = scrunit1, nml = ctrl_packnames)
225 close( scrunit1 )
226 print*, ' OPTIM_NUMBMOD: Control options have been read.'
227
228 cph(
229 cdfer expId = yctrlid
230 cph)
231
232 c-- Read optimization parameters from file.
233 open(unit=scrunit1,status='scratch')
234
235 open(unit = modeldataunit,file = 'data.optim',
236 & status = 'old', iostat = errio)
237 if ( errio .lt. 0 ) then
238 stop ' stopped in optim_numbmod'
239 endif
240
241 do while ( .true. )
242 read(modeldataunit, fmt='(a)', end=22) record
243 il = max(ilnblnk(record),1)
244 if ( record(1:1) .ne. commentcharacter )
245 & write(unit=scrunit1, fmt='(a)') record(:il)
246 enddo
247 22 continue
248 close( modeldataunit )
249
250 rewind( scrunit1 )
251 read(unit = scrunit1, nml = optim)
252 close( scrunit1 )
253 print*, ' OPTIM_NUMBMOD: Minimization options have been read.'
254
255 if (eps .gt. 0.0) then
256 epsf = eps
257 epsx = eps
258 epsg = eps
259 endif
260
261 lheaderonly = .true.
262 call optim_readdata ( nn, ctrlname, lheaderonly, ff, vv)
263
264 c-- Do some final printout.
265 print*
266 print*, ' OPTIM_NUMBMOD: Iteration number = ', optimcycle
267 print*, ' number of control variables = ', nn
268 print*, ' Data will be read from the following files:'
269 print*
270
271 ce --> data.err file in case dimensional i/o is used.
272 ce --> scaling file in case dimensional i/o is used.
273
274 return
275 end

  ViewVC Help
Powered by ViewVC 1.1.22