ROMS
Loading...
Searching...
No Matches
propagator_mod Module Reference

Functions/Subroutines

subroutine, public propagator_afte (runinterval, state, ad_state)
 
subroutine, public propagator_fsv (runinterval, state, ad_state)
 
subroutine, public propagator_fte (runinterval, state, tl_state)
 
subroutine, public propagator_hop (runinterval, state, ad_state)
 
subroutine, public propagator_hso (runinterval, iter, state, ad_state)
 
subroutine, public propagator_op (runinterval, state, ad_state)
 
subroutine, public propagator_so (runinterval, iter, state, ad_state)
 
subroutine, public propagator_so_semi (runinterval, state, ad_state)
 

Function/Subroutine Documentation

◆ propagator_afte()

subroutine, public propagator_mod::propagator_afte ( real(dp), intent(in) runinterval,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 36 of file propagator_afte.h.

37!***********************************************************************
38!
39 USE mod_param
40 USE mod_parallel
41#ifdef SOLVE3D
42 USE mod_coupling
43#endif
44 USE mod_iounits
45 USE mod_ocean
46 USE mod_scalars
47 USE mod_stepping
48!
49 USE close_io_mod, ONLY : close_inp
51 USE packing_mod, ONLY : ad_unpack, ad_pack
52#ifdef SOLVE3D
53 USE set_depth_mod, ONLY : set_depth
54#endif
55 USE strings_mod, ONLY : founderror
56!
57! Imported variable declarations.
58!
59 real(dp), intent(in) :: RunInterval
60!
61 TYPE (T_GST), intent(in) :: state(Ngrids)
62 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
63!
64! Local variable declarations.
65!
66#ifdef SOLVE3D
67 logical :: FirstPass = .true.
68#endif
69!
70 integer :: ng, tile
71!
72 real(r8) :: StateNorm(Ngrids)
73!
74 character (len=*), parameter :: MyFile = &
75 & __FILE__
76!
77!=======================================================================
78! Forward integration of the tangent linear model.
79!=======================================================================
80!
81 nrun=nrun+1
82 IF (master) THEN
83 DO ng=1,ngrids
84 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
85 & ', Iteration: ', nrun, &
86 & ', number converged RITZ values: ', &
87 & nconv(ng)
88 END DO
89 END IF
90!
91! Initialize time stepping indices and counters.
92!
93 DO ng=1,ngrids
94 iif(ng)=1
95 indx1(ng)=1
96 kstp(ng)=1
97 krhs(ng)=3
98 knew(ng)=2
99 predictor_2d_step(ng)=.false.
100!
101 iic(ng)=0
102 nstp(ng)=1
103 nrhs(ng)=1
104 nnew(ng)=2
105!
106 synchro_flag(ng)=.true.
107 tdays(ng)=dstart+dt(ng)*real(ntimes(ng),r8)*sec2day
108 time(ng)=tdays(ng)*day2sec
109 ntstart(ng)=ntimes(ng)+1
110 ntend(ng)=1
111 ntfirst(ng)=ntend(ng)
112 END DO
113!
114!-----------------------------------------------------------------------
115! Clear adjoint state variables. There is not need to clean the basic
116! state arrays since they were zeroth out at initialization and bottom
117! of previous iteration.
118!-----------------------------------------------------------------------
119!
120 DO ng=1,ngrids
121 DO tile=first_tile(ng),last_tile(ng),+1
122 CALL initialize_ocean (ng, tile, iadm)
123 END DO
124 END DO
125
126#ifdef SOLVE3D
127!
128!-----------------------------------------------------------------------
129! Compute basic state initial level thicknesses used for state norm
130! scaling. It uses zero time averaged free-surface (rest state).
131! Therefore, the norm scaling is time invariant.
132!-----------------------------------------------------------------------
133!
134 DO ng=1,ngrids
135 DO tile=last_tile(ng),first_tile(ng),-1
136 CALL set_depth (ng, tile, iadm)
137 END DO
138 END DO
139#endif
140!
141!-----------------------------------------------------------------------
142! Unpack adjoint initial conditions from state vector.
143!-----------------------------------------------------------------------
144!
145 DO ng=1,ngrids
146 DO tile=first_tile(ng),last_tile(ng),+1
147 CALL ad_unpack (ng, tile, nstr(ng), nend(ng), &
148 & state(ng)%vector)
149 END DO
150 END DO
151!
152!-----------------------------------------------------------------------
153! Compute initial adjoint state dot product norm.
154!-----------------------------------------------------------------------
155!
156 DO ng=1,ngrids
157 DO tile=last_tile(ng),first_tile(ng),-1
158 CALL ad_statenorm (ng, tile, knew(ng), nstp(ng), &
159 & statenorm(ng))
160 END DO
161 IF (master) THEN
162 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
163 & ', Adjoint Initial Norm: ', statenorm(ng)
164 END IF
165 END DO
166!
167!-----------------------------------------------------------------------
168! Read in initial forcing, climatology and assimilation data from
169! input NetCDF files. It loads the first relevant data record for
170! the time-interpolation between snapshots.
171!-----------------------------------------------------------------------
172!
173 DO ng=1,ngrids
174 CALL close_inp (ng, iadm)
175 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
176
177 CALL ad_get_idata (ng)
178 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
179
180 CALL ad_get_data (ng)
181 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
182 END DO
183!
184!-----------------------------------------------------------------------
185! Time-step the adjoint model backwards.
186!-----------------------------------------------------------------------
187!
188 DO ng=1,ngrids
189 IF (master) THEN
190 WRITE (stdout,30) 'AD', ng, ntstart(ng), ntend(ng)
191 END IF
192 time(ng)=time(ng)+dt(ng)
193 iic(ng)=ntstart(ng)+1
194 END DO
195
196#ifdef SOLVE3D
197 CALL ad_main3d (runinterval)
198#else
199 CALL ad_main2d (runinterval)
200#endif
201 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
202!
203!-----------------------------------------------------------------------
204! Clear nonlinear state (basic state) variables and insure that the
205! time averaged free-surface is zero for scaling below and next
206! iteration.
207!-----------------------------------------------------------------------
208!
209 DO ng=1,ngrids
210 DO tile=first_tile(ng),last_tile(ng),+1
211 CALL initialize_ocean (ng, tile, inlm)
212#ifdef SOLVE3D
213 CALL initialize_coupling (ng, tile, 0)
214#endif
215 END DO
216 END DO
217
218#ifdef SOLVE3D
219!
220!-----------------------------------------------------------------------
221! Compute basic state final level thicknesses used for state norm
222! scaling. It uses zero time averaged free-surface (rest state).
223! Therefore, the norm scaling is time invariant.
224!-----------------------------------------------------------------------
225!
226 DO ng=1,ngrids
227 DO tile=last_tile(ng),first_tile(ng),-1
228 CALL set_depth (ng, tile, iadm)
229 END DO
230 END DO
231#endif
232!
233!-----------------------------------------------------------------------
234! Compute final adjoint state dot product norm.
235!-----------------------------------------------------------------------
236!
237 DO ng=1,ngrids
238 DO tile=first_tile(ng),last_tile(ng),+1
239 CALL ad_statenorm (ng, tile, knew(ng), nstp(ng), &
240 & statenorm(ng))
241 END DO
242 IF (master) THEN
243 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
244 & ', Adjoint Final Norm: ', statenorm(ng)
245 END IF
246 END DO
247!
248!-----------------------------------------------------------------------
249! Pack final adjoint solution into adjoint state vector.
250!-----------------------------------------------------------------------
251!
252 DO ng=1,ngrids
253 DO tile=last_tile(ng),first_tile(ng),-1
254 CALL ad_pack (ng, tile, nstr(ng), nend(ng), &
255 & ad_state(ng)%vector)
256 END DO
257 END DO
258!
259 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
260 20 FORMAT (/,a,i2.2,a,1p,e15.6,/)
261 30 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
262 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
263!
264 RETURN
subroutine ad_get_data(ng)
Definition ad_get_data.F:4
subroutine ad_get_idata(ng)
Definition ad_get_idata.F:4
subroutine ad_main2d
Definition ad_main2d.F:586
subroutine ad_main3d(runinterval)
Definition ad_main3d.F:4
subroutine, public close_inp(ng, model)
Definition close_io.F:92
subroutine, public ad_statenorm(ng, tile, kinp, ninp, statenorm)
Definition dotproduct.F:383
subroutine, public initialize_coupling(ng, tile, model)
integer stdout
subroutine, public initialize_ocean(ng, tile, model)
Definition mod_ocean.F:1526
integer, dimension(:), allocatable first_tile
logical master
integer, dimension(:), allocatable last_tile
integer, parameter inlm
Definition mod_param.F:662
integer, dimension(:), allocatable nstr
Definition mod_param.F:646
integer, parameter iadm
Definition mod_param.F:665
integer ngrids
Definition mod_param.F:113
integer, dimension(:), allocatable nend
Definition mod_param.F:647
real(dp), parameter day2sec
integer, dimension(:), allocatable ntimes
integer, dimension(:), allocatable iic
real(dp), dimension(:), allocatable dt
integer, dimension(:), allocatable nconv
logical, dimension(:), allocatable synchro_flag
logical, dimension(:), allocatable predictor_2d_step
real(dp), dimension(:), allocatable tdays
real(dp) dstart
real(dp), parameter sec2day
integer, dimension(:), allocatable ntend
integer exit_flag
integer, dimension(:), allocatable indx1
integer, dimension(:), allocatable ntfirst
real(dp), dimension(:), allocatable time
integer, dimension(:), allocatable ntstart
integer nrun
integer, dimension(:), allocatable iif
integer noerror
integer, dimension(:), allocatable kstp
integer, dimension(:), allocatable knew
integer, dimension(:), allocatable nrhs
integer, dimension(:), allocatable nnew
integer, dimension(:), allocatable krhs
integer, dimension(:), allocatable nstp
subroutine, public set_depth(ng, tile, model)
Definition set_depth.F:34
logical function, public founderror(flag, noerr, line, routine)
Definition strings.F:52
subroutine ad_unpack(ng, tile, mstr, mend, state)
Definition packing.F:4712
subroutine ad_pack(ng, tile, mstr, mend, ad_state)
Definition packing.F:341

References ad_get_data(), ad_get_idata(), ad_main2d(), ad_main3d(), ad_pack(), dotproduct_mod::ad_statenorm(), ad_unpack(), close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_param::iadm, mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, mod_coupling::initialize_coupling(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, mod_kinds::r8, mod_scalars::sec2day, set_depth_mod::set_depth(), mod_iounits::stdout, mod_scalars::synchro_flag, mod_scalars::tdays, and mod_scalars::time.

Here is the call graph for this function:

◆ propagator_fsv()

subroutine, public propagator_mod::propagator_fsv ( real(dp), intent(in) runinterval,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 37 of file propagator_fsv.h.

38!***********************************************************************
39!
40 USE mod_param
41 USE mod_parallel
42#ifdef SOLVE3D
43 USE mod_coupling
44#endif
45 USE mod_iounits
46 USE mod_ocean
47 USE mod_scalars
48 USE mod_stepping
49!
50 USE close_io_mod, ONLY : close_inp
53 USE packing_mod, ONLY : tl_unpack, ad_pack
55#ifdef SOLVE3D
56 USE set_depth_mod, ONLY : set_depth
57#endif
58 USE strings_mod, ONLY : founderror
59!
60! Imported variable declarations.
61!
62 real(dp), intent(in) :: RunInterval
63!
64 TYPE (T_GST), intent(in) :: state(Ngrids)
65 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
66!
67! Local variable declarations.
68!
69 integer :: ng, tile
70 integer :: ktmp, ntmp
71!
72 real(r8) :: StateNorm(Ngrids)
73!
74 character (len=*), parameter :: MyFile = &
75 & __FILE__
76!
77!=======================================================================
78! Forward integration of the tangent linear model.
79!=======================================================================
80!
81 nrun=nrun+1
82 IF (master) THEN
83 DO ng=1,ngrids
84 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
85 & ', Iteration: ', nrun, &
86 & ', number converged RITZ values: ', &
87 & nconv(ng)
88 END DO
89 END IF
90!
91! Initialize time stepping indices and counters.
92!
93 DO ng=1,ngrids
94 iif(ng)=1
95 indx1(ng)=1
96 kstp(ng)=1
97 krhs(ng)=1
98 knew(ng)=1
99 predictor_2d_step(ng)=.false.
100!
101 iic(ng)=0
102 nstp(ng)=1
103 nrhs(ng)=1
104 nnew(ng)=1
105!
106 synchro_flag(ng)=.true.
107 tdays(ng)=dstart
108 time(ng)=tdays(ng)*day2sec
109 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
110 ntend(ng)=ntimes(ng)
111 ntfirst(ng)=ntstart(ng)
112 END DO
113!
114!-----------------------------------------------------------------------
115! Clear tangent linear state variables. There is not need to clean
116! the basic state arrays since they were zeroth out at initialization
117! and bottom of previous iteration.
118!-----------------------------------------------------------------------
119!
120 DO ng=1,ngrids
121 DO tile=first_tile(ng),last_tile(ng),+1
122 CALL initialize_ocean (ng, tile, itlm)
123 END DO
124 END DO
125
126#ifdef SOLVE3D
127!
128!-----------------------------------------------------------------------
129! Compute basic state initial level thicknesses used for state norm
130! scaling. It uses zero time-averaged free-surface (rest state).
131! Therefore, the norm scaling is time invariant.
132!-----------------------------------------------------------------------
133!
134 DO ng=1,ngrids
135 DO tile=last_tile(ng),first_tile(ng),-1
136 CALL set_depth (ng, tile, itlm)
137 END DO
138 END DO
139#endif
140!
141!-----------------------------------------------------------------------
142! Unpack tangent linear initial conditions from state vector.
143!-----------------------------------------------------------------------
144!
145 DO ng=1,ngrids
146 DO tile=first_tile(ng),last_tile(ng),+1
147 CALL tl_unpack (ng, tile, nstr(ng), nend(ng), &
148 & state(ng)%vector)
149 END DO
150 END DO
151!
152!-----------------------------------------------------------------------
153! Compute initial tangent linear state dot product norm.
154!-----------------------------------------------------------------------
155!
156 DO ng=1,ngrids
157 DO tile=last_tile(ng),first_tile(ng),-1
158 CALL tl_statenorm (ng, tile, kstp(ng), nstp(ng), &
159 & statenorm(ng))
160 END DO
161 IF (master) THEN
162 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
163 & ', Tangent Initial Norm: ', statenorm(ng)
164 END IF
165 END DO
166!
167!-----------------------------------------------------------------------
168! Read in initial forcing, climatology and assimilation data from
169! input NetCDF files. It loads the first relevant data record for
170! the time-interpolation between snapshots.
171!-----------------------------------------------------------------------
172!
173 DO ng=1,ngrids
174 CALL close_inp (ng, itlm)
175 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
176
177 CALL tl_get_idata (ng)
178 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
179
180 CALL tl_get_data (ng)
181 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
182 END DO
183!
184!-----------------------------------------------------------------------
185! Time-step the tangent linear model.
186!-----------------------------------------------------------------------
187!
188 DO ng=1,ngrids
189 IF (master) THEN
190 WRITE (stdout,30) 'TL', ng, ntstart(ng), ntend(ng)
191 END IF
192 time(ng)=time(ng)-dt(ng)
193 iic(ng)=ntstart(ng)-1
194 END DO
195
196#ifdef SOLVE3D
197 CALL tl_main3d (runinterval)
198#else
199 CALL tl_main2d (runinterval)
200#endif
201 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
202!
203!-----------------------------------------------------------------------
204! Clear nonlinear (basic state) and adjoint state variables.
205!-----------------------------------------------------------------------
206!
207 DO ng=1,ngrids
208 DO tile=first_tile(ng),last_tile(ng),+1
209 CALL initialize_ocean (ng, tile, inlm)
210 CALL initialize_ocean (ng, tile, iadm)
211#ifdef SOLVE3D
212 CALL initialize_coupling (ng, tile, 0)
213#endif
214 END DO
215 END DO
216
217#ifdef SOLVE3D
218!
219!-----------------------------------------------------------------------
220! Compute basic state final level thicknesses used for state norm
221! scaling. It uses zero time-averaged free-surface (rest state).
222! Therefore, the norm scaling is time invariant.
223!-----------------------------------------------------------------------
224!
225 DO ng=1,ngrids
226 DO tile=last_tile(ng),first_tile(ng),-1
227 CALL set_depth (ng, tile, iadm)
228 END DO
229 END DO
230#endif
231!
232!-----------------------------------------------------------------------
233! Compute final tangent linear state dot product norm.
234!-----------------------------------------------------------------------
235!
236 DO ng=1,ngrids
237 DO tile=first_tile(ng),last_tile(ng),+1
238 CALL tl_statenorm (ng, tile, knew(ng), nstp(ng), &
239 & statenorm(ng))
240 END DO
241 IF (master) THEN
242 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
243 & ', Tangent Final Norm: ', statenorm(ng)
244 END IF
245 END DO
246!
247!=======================================================================
248! Backward integration with the adjoint model.
249!=======================================================================
250!
251! Initialize time stepping indices and counters.
252!
253 DO ng=1,ngrids
254 iif(ng)=1
255 indx1(ng)=1
256 ktmp=knew(ng)
257 kstp(ng)=1
258 krhs(ng)=3
259 knew(ng)=2
260 predictor_2d_step(ng)=.false.
261!
262 iic(ng)=0
263 ntmp=nstp(ng)
264 nstp(ng)=1
265 nrhs(ng)=1
266 nnew(ng)=2
267!
268 synchro_flag(ng)=.true.
269 tdays(ng)=dstart+dt(ng)*real(ntimes(ng),r8)*sec2day
270 time(ng)=tdays(ng)*day2sec
271 ntstart(ng)=ntimes(ng)+1
272 ntend(ng)=1
273 ntfirst(ng)=ntend(ng)
274 END DO
275!
276!-----------------------------------------------------------------------
277! Initialize adjoint model with the final tangent linear solution
278! scaled by the energy norm.
279!-----------------------------------------------------------------------
280!
281 DO ng=1,ngrids
282 DO tile=last_tile(ng),first_tile(ng),-1
283 CALL ad_ini_perturb (ng, tile, &
284 & ktmp, knew(ng), ntmp, nstp(ng))
285 END DO
286 END DO
287!
288!-----------------------------------------------------------------------
289! Read in initial forcing, climatology and assimilation data from
290! input NetCDF files. It loads the first relevant data record for
291! the time-interpolation between snapshots.
292!-----------------------------------------------------------------------
293!
294 DO ng=1,ngrids
295 CALL close_inp (ng, iadm)
296 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
297
298 CALL ad_get_idata (ng)
299 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
300
301 CALL ad_get_data (ng)
302 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
303 END DO
304!
305!-----------------------------------------------------------------------
306! Time-step the adjoint model backwards.
307!-----------------------------------------------------------------------
308!
309 DO ng=1,ngrids
310 IF (master) THEN
311 WRITE (stdout,30) 'AD', ng, ntstart(ng), ntend(ng)
312 END IF
313 time(ng)=time(ng)+dt(ng)
314 iic(ng)=ntstart(ng)+1
315 END DO
316
317#ifdef SOLVE3D
318 CALL ad_main3d (runinterval)
319#else
320 CALL ad_main2d (runinterval)
321#endif
322 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
323!
324!-----------------------------------------------------------------------
325! Clear nonlinear state (basic state) variables for next iteration
326! and to insure a rest state time averaged free-surface before adjoint
327! state norm scaling.
328!-----------------------------------------------------------------------
329!
330 DO ng=1,ngrids
331 DO tile=first_tile(ng),last_tile(ng),+1
332 CALL initialize_ocean (ng, tile, inlm)
333#ifdef SOLVE3D
334 CALL initialize_coupling (ng, tile, 0)
335#endif
336 END DO
337 END DO
338
339#ifdef SOLVE3D
340!
341!-----------------------------------------------------------------------
342! Compute basic state initial level thicknesses used for state norm
343! scaling. It uses zero free-surface (rest state). Therefore, the
344! norm scaling is time invariant.
345!-----------------------------------------------------------------------
346!
347 DO ng=1,ngrids
348 DO tile=last_tile(ng),first_tile(ng),-1
349 CALL set_depth (ng, tile, iadm)
350 END DO
351 END DO
352#endif
353!
354!-----------------------------------------------------------------------
355! Pack final adjoint solution into adjoint state vector.
356!-----------------------------------------------------------------------
357!
358 DO ng=1,ngrids
359 DO tile=first_tile(ng),last_tile(ng),+1
360 CALL ad_pack (ng, tile, nstr(ng), nend(ng), &
361 & ad_state(ng)%vector)
362 END DO
363 END DO
364 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
365!
366!-----------------------------------------------------------------------
367! Clear forcing variables for next iteration.
368!-----------------------------------------------------------------------
369!
370 DO ng=1,ngrids
371 DO tile=first_tile(ng),last_tile(ng),+1
372 CALL initialize_forces (ng, tile, itlm)
373 CALL initialize_forces (ng, tile, iadm)
374 END DO
375 END DO
376!
377 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
378 20 FORMAT (/,a,i2.2,a,1p,e15.6,/)
379 30 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
380 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
381!
382 RETURN
subroutine, public tl_statenorm(ng, tile, kinp, ninp, statenorm)
Definition dotproduct.F:699
subroutine, public ad_ini_perturb(ng, tile, kinp, kout, ninp, nout)
subroutine, public initialize_forces(ng, tile, model)
integer, parameter itlm
Definition mod_param.F:663
subroutine tl_unpack(ng, tile, mstr, mend, state)
Definition packing.F:6561
subroutine tl_get_data(ng)
Definition tl_get_data.F:4
subroutine tl_get_idata(ng)
Definition tl_get_idata.F:4
subroutine tl_main2d
Definition tl_main2d.F:429
subroutine tl_main3d(runinterval)
Definition tl_main3d.F:4

References ad_get_data(), ad_get_idata(), ini_adjust_mod::ad_ini_perturb(), ad_main2d(), ad_main3d(), ad_pack(), close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_param::iadm, mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, mod_coupling::initialize_coupling(), mod_forces::initialize_forces(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_param::itlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, mod_kinds::r8, mod_scalars::sec2day, set_depth_mod::set_depth(), mod_iounits::stdout, mod_scalars::synchro_flag, mod_scalars::tdays, mod_scalars::time, tl_get_data(), tl_get_idata(), tl_main2d(), tl_main3d(), dotproduct_mod::tl_statenorm(), and tl_unpack().

Here is the call graph for this function:

◆ propagator_fte()

subroutine, public propagator_mod::propagator_fte ( real(dp), intent(in) runinterval,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) tl_state )

Definition at line 36 of file propagator_fte.h.

37!***********************************************************************
38!
39 USE mod_param
40 USE mod_parallel
41#ifdef SOLVE3D
42 USE mod_coupling
43#endif
44 USE mod_iounits
45 USE mod_ocean
46 USE mod_scalars
47 USE mod_stepping
48!
49 USE close_io_mod, ONLY : close_inp
51 USE packing_mod, ONLY : tl_unpack, tl_pack
52#ifdef SOLVE3D
53 USE set_depth_mod, ONLY : set_depth
54#endif
55 USE strings_mod, ONLY : founderror
56!
57! Imported variable declarations.
58!
59 real(dp), intent(in) :: RunInterval
60!
61 TYPE (T_GST), intent(in) :: state(Ngrids)
62 TYPE (T_GST), intent(inout) :: tl_state(Ngrids)
63!
64! Local variable declarations.
65!
66#ifdef SOLVE3D
67 logical :: FirstPass = .true.
68!
69#endif
70 integer :: ng, tile
71!
72 real(r8) :: StateNorm(Ngrids)
73!
74 character (len=*), parameter :: MyFile = &
75 & __FILE__
76!
77!=======================================================================
78! Forward integration of the tangent linear model.
79!=======================================================================
80!
81!$OMP MASTER
82 nrun=nrun+1
83 IF (master) THEN
84 DO ng=1,ngrids
85 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
86 & ', Iteration: ', nrun, &
87 & ', number converged RITZ values: ', &
88 & nconv(ng)
89 END DO
90 END IF
91!$OMP END MASTER
92!
93! Initialize time stepping indices and counters.
94!
95 DO ng=1,ngrids
96 iif(ng)=1
97 indx1(ng)=1
98 kstp(ng)=1
99 krhs(ng)=1
100 knew(ng)=1
101 predictor_2d_step(ng)=.false.
102!
103 iic(ng)=0
104 nstp(ng)=1
105 nrhs(ng)=1
106 nnew(ng)=1
107!
108 synchro_flag(ng)=.true.
109 tdays(ng)=dstart
110 time(ng)=tdays(ng)*day2sec
111!$OMP MASTER
112 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
113 ntend(ng)=ntimes(ng)
114 ntfirst(ng)=ntstart(ng)
115!$OMP END MASTER
116 END DO
117!$OMP BARRIER
118!
119!-----------------------------------------------------------------------
120! Clear tangent linear state variables. There is not need to clean
121! the basic state arrays since they were zeroth out at initialization
122! and bottom of previous iteration.
123!-----------------------------------------------------------------------
124!
125 DO ng=1,ngrids
126 DO tile=first_tile(ng),last_tile(ng),+1
127 CALL initialize_ocean (ng, tile, itlm)
128 END DO
129!$OMP BARRIER
130 END DO
131
132#ifdef SOLVE3D
133!
134!-----------------------------------------------------------------------
135! Compute basic state initial level thicknesses used for state norm
136! scaling. It uses zero time averaged free-surface (rest state).
137! Therefore, the norm scaling is time invariant.
138!-----------------------------------------------------------------------
139!
140 DO ng=1,ngrids
141 DO tile=last_tile(ng),first_tile(ng),-1
142 CALL set_depth (ng, tile, itlm)
143 END DO
144!$OMP BARRIER
145 END DO
146#endif
147!
148!-----------------------------------------------------------------------
149! Unpack tangent linear initial conditions from state vector.
150!-----------------------------------------------------------------------
151!
152 DO ng=1,ngrids
153 DO tile=first_tile(ng),last_tile(ng),+1
154 CALL tl_unpack (ng, tile, nstr(ng), nend(ng), &
155 & state(ng)%vector)
156 END DO
157!$OMP BARRIER
158 END DO
159!
160!-----------------------------------------------------------------------
161! Compute initial tangent linear state dot product norm.
162!-----------------------------------------------------------------------
163!
164 DO ng=1,ngrids
165 DO tile=last_tile(ng),first_tile(ng),-1
166 CALL tl_statenorm (ng, tile, kstp(ng), nstp(ng), &
167 & statenorm(ng))
168 END DO
169!$OMP BARRIER
170
171!$OMP MASTER
172 IF (master) THEN
173 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
174 & ', Tangent Initial Norm: ', statenorm(ng)
175 END IF
176!$OMP END MASTER
177 END DO
178!
179!-----------------------------------------------------------------------
180! Read in initial forcing, climatology and assimilation data from
181! input NetCDF files. It loads the first relevant data record for
182! the time-interpolation between snapshots.
183!-----------------------------------------------------------------------
184!
185 DO ng=1,ngrids
186!$OMP MASTER
187 CALL close_inp (ng, itlm)
188 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
189
190 CALL tl_get_idata (ng)
191 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
192
193 CALL tl_get_data (ng)
194!$OMP END MASTER
195!$OMP BARRIER
196 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
197 END DO
198!
199!-----------------------------------------------------------------------
200! Time-step the tangent linear model.
201!-----------------------------------------------------------------------
202!
203 DO ng=1,ngrids
204!$OMP MASTER
205 IF (master) THEN
206 WRITE (stdout,30) 'TL', ng, ntstart(ng), ntend(ng)
207 END IF
208 time(ng)=time(ng)-dt(ng)
209!$OMP END MASTER
210 iic(ng)=ntstart(ng)-1
211 END DO
212!$OMP BARRIER
213
214#ifdef SOLVE3D
215 CALL tl_main3d (runinterval)
216#else
217 CALL tl_main2d (runinterval)
218#endif
219!$OMP BARRIER
220 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
221!
222!-----------------------------------------------------------------------
223! Clear nonlinear state (basic state) variables and insure that the
224! time averaged free-surface is zero for scaling below and next
225! iteration.
226!-----------------------------------------------------------------------
227!
228 DO ng=1,ngrids
229 DO tile=first_tile(ng),last_tile(ng),+1
230 CALL initialize_ocean (ng, tile, inlm)
231#ifdef SOLVE3D
232 CALL initialize_coupling (ng, tile, 0)
233#endif
234 END DO
235!$OMP BARRIER
236 END DO
237
238#ifdef SOLVE3D
239!
240!-----------------------------------------------------------------------
241! Compute basic state final level thicknesses used for state norm
242! scaling. It uses zero time averaged free-surface (rest state).
243! Therefore, the norm scaling is time invariant.
244!-----------------------------------------------------------------------
245!
246 DO ng=1,ngrids
247 DO tile=last_tile(ng),first_tile(ng),-1
248 CALL set_depth (ng, tile, itlm)
249 END DO
250!$OMP BARRIER
251 END DO
252#endif
253!
254!-----------------------------------------------------------------------
255! Compute final tangent linear state dot product norm.
256!-----------------------------------------------------------------------
257!
258 DO ng=1,ngrids
259 DO tile=first_tile(ng),last_tile(ng),+1
260 CALL tl_statenorm (ng, tile, knew(ng), nstp(ng), &
261 & statenorm(ng))
262 END DO
263!$OMP BARRIER
264
265!$OMP MASTER
266 IF (master) THEN
267 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
268 & ', Tangent Final Norm: ', statenorm(ng)
269 END IF
270!$OMP END MASTER
271 END DO
272!
273!-----------------------------------------------------------------------
274! Pack final tangent linear solution into tangent state vector.
275!-----------------------------------------------------------------------
276!
277 DO ng=1,ngrids
278 DO tile=last_tile(ng),first_tile(ng),-1
279 CALL tl_pack (ng, tile, nstr(ng), nend(ng), &
280 & tl_state(ng)%vector)
281 END DO
282!$OMP BARRIER
283 END DO
284!
285 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
286 20 FORMAT (/,a,i2.2,a,1p,e15.6,/)
287 30 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
288 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
289
290 RETURN
subroutine tl_pack(ng, tile, mstr, mend, tl_state)
Definition packing.F:6015

References close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, mod_coupling::initialize_coupling(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_param::itlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, set_depth_mod::set_depth(), mod_iounits::stdout, mod_scalars::synchro_flag, mod_scalars::tdays, mod_scalars::time, tl_get_data(), tl_get_idata(), tl_main2d(), tl_main3d(), tl_pack(), dotproduct_mod::tl_statenorm(), and tl_unpack().

Here is the call graph for this function:

◆ propagator_hop()

subroutine, public propagator_mod::propagator_hop ( real(dp), intent(in) runinterval,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 42 of file propagator_hop.h.

43!***********************************************************************
44!
45 USE mod_param
46 USE mod_parallel
47#ifdef SOLVE3D
48 USE mod_coupling
49#endif
50 USE mod_iounits
51 USE mod_ocean
52 USE mod_scalars
53 USE mod_stepping
54!
55 USE close_io_mod, ONLY : close_inp
59 USE inner2state_mod, ONLY : ini_c_norm
60#ifdef SOLVE3D
61 USE set_depth_mod, ONLY : set_depth
62#endif
63 USE strings_mod, ONLY : founderror
64!
65! Imported variable declarations.
66!
67 real(dp), intent(in) :: RunInterval
68!
69 TYPE (T_GST), intent(in) :: state(Ngrids)
70 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
71!
72! Local variable declarations.
73!
74 integer :: ng, tile
75 integer :: ktmp, ntmp, Lini
76!
77 real(r8) :: StateNorm(Ngrids)
78!
79 character (len=*), parameter :: MyFile = &
80 & __FILE__
81!
82!=======================================================================
83! Forward integration of the tangent linear model.
84!=======================================================================
85!
86 nrun=nrun+1
87 IF (master) THEN
88 DO ng=1,ngrids
89 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
90 & ', Iteration: ', nrun, &
91 & ', number converged RITZ values: ', &
92 & nconv(ng)
93 END DO
94 END IF
95!
96! Initialize time stepping indices and counters.
97!
98 DO ng=1,ngrids
99 iif(ng)=1
100 indx1(ng)=1
101 kstp(ng)=1
102 krhs(ng)=1
103 knew(ng)=1
104 predictor_2d_step(ng)=.false.
105!
106 iic(ng)=0
107 nstp(ng)=1
108 nrhs(ng)=1
109 nnew(ng)=1
110!
111 synchro_flag(ng)=.true.
112 tdays(ng)=dstart
113 time(ng)=tdays(ng)*day2sec
114 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
115 ntend(ng)=ntimes(ng)
116 ntfirst(ng)=ntstart(ng)
117 END DO
118!
119 lini=1
120!
121!-----------------------------------------------------------------------
122! Clear tangent linear state variables. There is not need to clean
123! the basic state arrays since they were zeroth out at initialization
124! and bottom of previous iteration.
125!-----------------------------------------------------------------------
126!
127 DO ng=1,ngrids
128 DO tile=first_tile(ng),last_tile(ng),+1
129 CALL initialize_ocean (ng, tile, itlm)
130 END DO
131 END DO
132
133#ifdef SOLVE3D
134!
135!-----------------------------------------------------------------------
136! Compute basic state initial level thicknesses used for state norm
137! scaling. It uses zero time-averaged free-surface (rest state).
138! Therefore, the norm scaling is time invariant.
139!-----------------------------------------------------------------------
140!
141 DO ng=1,ngrids
142 DO tile=last_tile(ng),first_tile(ng),-1
143 CALL set_depth (ng, tile, itlm)
144 END DO
145 END DO
146#endif
147!
148!-----------------------------------------------------------------------
149! Compute tangent linear initial conditions from state vector.
150!-----------------------------------------------------------------------
151!
152 DO ng=1,ngrids
153 DO tile=first_tile(ng),last_tile(ng),+1
154 CALL tl_inner2state (ng, tile, lini, state(ng)%vector)
155 END DO
156 END DO
157!
158!-----------------------------------------------------------------------
159! Compute initial tangent linear state analysis error norm.
160!-----------------------------------------------------------------------
161!
162 DO ng=1,ngrids
163 DO tile=last_tile(ng),first_tile(ng),-1
164 CALL ini_c_norm (ng, tile, kstp(ng), nstp(ng), &
165 & statenorm(ng))
166 END DO
167 IF (master) THEN
168 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
169 & ', Tangent Initial Norm: ', statenorm(ng)
170 END IF
171 END DO
172!
173!-----------------------------------------------------------------------
174! Read in initial forcing, climatology and assimilation data from
175! input NetCDF files. It loads the first relevant data record for
176! the time-interpolation between snapshots.
177!-----------------------------------------------------------------------
178!
179 DO ng=1,ngrids
180 CALL close_inp (ng, itlm)
181 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
182
183 CALL tl_get_idata (ng)
184 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
185
186 CALL tl_get_data (ng)
187 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
188 END DO
189!
190!-----------------------------------------------------------------------
191! Time-step the tangent linear model.
192!-----------------------------------------------------------------------
193!
194 DO ng=1,ngrids
195 IF (master) THEN
196 WRITE (stdout,30) 'TL', ng, ntstart(ng), ntend(ng)
197 END IF
198 time(ng)=time(ng)-dt(ng)
199 iic(ng)=ntstart(ng)-1
200 END DO
201
202#ifdef SOLVE3D
203 CALL tl_main3d (runinterval)
204#else
205 CALL tl_main2d (runinterval)
206#endif
207 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
208!
209!-----------------------------------------------------------------------
210! Clear nonlinear (basic state) and adjoint state variables.
211!-----------------------------------------------------------------------
212!
213 DO ng=1,ngrids
214 DO tile=first_tile(ng),last_tile(ng),+1
215 CALL initialize_ocean (ng, tile, inlm)
216 CALL initialize_ocean (ng, tile, iadm)
217#ifdef SOLVE3D
218 CALL initialize_coupling (ng, tile, 0)
219#endif
220 END DO
221 END DO
222
223#ifdef SOLVE3D
224!
225!-----------------------------------------------------------------------
226! Compute basic state final level thicknesses used for state norm
227! scaling. It uses zero time-averaged free-surface (rest state).
228! Therefore, the norm scaling is time invariant.
229!-----------------------------------------------------------------------
230!
231 DO ng=1,ngrids
232 DO tile=last_tile(ng),first_tile(ng),-1
233 CALL set_depth (ng, tile, itlm)
234 END DO
235 END DO
236#endif
237!
238!-----------------------------------------------------------------------
239! Compute final tangent linear energy norm.
240!-----------------------------------------------------------------------
241!
242 DO ng=1,ngrids
243 DO tile=first_tile(ng),last_tile(ng),+1
244 CALL tl_statenorm (ng, tile, knew(ng), nstp(ng), &
245 & statenorm(ng))
246 END DO
247 IF (master) THEN
248 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
249 & ', Tangent Final Norm: ', statenorm(ng)
250 END IF
251 END DO
252!
253!=======================================================================
254! Backward integration with the adjoint model.
255!=======================================================================
256!
257! Initialize time stepping indices and counters.
258!
259 DO ng=1,ngrids
260 iif(ng)=1
261 indx1(ng)=1
262 ktmp=knew(ng)
263 kstp(ng)=1
264 krhs(ng)=3
265 knew(ng)=2
266 predictor_2d_step(ng)=.false.
267!
268 iic(ng)=0
269 ntmp=nstp(ng)
270 nstp(ng)=1
271 nrhs(ng)=1
272 nnew(ng)=2
273!
274 synchro_flag(ng)=.true.
275 tdays(ng)=dstart+dt(ng)*real(ntimes(ng),r8)*sec2day
276 time(ng)=tdays(ng)*day2sec
277 ntstart(ng)=ntimes(ng)+1
278 ntend(ng)=1
279 ntfirst(ng)=ntend(ng)
280 END DO
281!
282!-----------------------------------------------------------------------
283! Initialize adjoint model with the final tangent linear solution
284! scaled by the energy norm.
285!-----------------------------------------------------------------------
286!
287 DO ng=1,ngrids
288 DO tile=last_tile(ng),first_tile(ng),-1
289 CALL ad_ini_perturb (ng, tile, &
290 & ktmp, knew(ng), ntmp, nstp(ng))
291 END DO
292 END DO
293!
294!-----------------------------------------------------------------------
295! Read in initial forcing, climatology and assimilation data from
296! input NetCDF files. It loads the first relevant data record for
297! the time-interpolation between snapshots.
298!-----------------------------------------------------------------------
299!
300 DO ng=1,ngrids
301 CALL close_inp (ng, iadm)
302 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
303
304 CALL ad_get_idata (ng)
305 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
306
307 CALL ad_get_data (ng)
308 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
309 END DO
310!
311!-----------------------------------------------------------------------
312! Time-step the adjoint model backwards.
313!-----------------------------------------------------------------------
314!
315 DO ng=1,ngrids
316 IF (master) THEN
317 WRITE (stdout,30) 'AD', ng, ntstart(ng), ntend(ng)
318 END IF
319 time(ng)=time(ng)+dt(ng)
320 iic(ng)=ntstart(ng)+1
321 END DO
322
323#ifdef SOLVE3D
324 CALL ad_main3d (runinterval)
325#else
326 CALL ad_main2d (runinterval)
327#endif
328 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
329!
330!-----------------------------------------------------------------------
331! Clear nonlinear state (basic state) variables for next iteration
332! and to insure a rest state time averaged free-surface before adjoint
333! state norm scaling.
334!-----------------------------------------------------------------------
335!
336 DO ng=1,ngrids
337 DO tile=first_tile(ng),last_tile(ng),+1
338 CALL initialize_ocean (ng, tile, inlm)
339#ifdef SOLVE3D
340 CALL initialize_coupling (ng, tile, 0)
341#endif
342 END DO
343 END DO
344
345#ifdef SOLVE3D
346!
347!-----------------------------------------------------------------------
348! Compute basic state initial level thicknesses used for state norm
349! scaling. It uses zero free-surface (rest state). Therefore, the
350! norm scaling is time invariant.
351!-----------------------------------------------------------------------
352!
353 DO ng=1,ngrids
354 DO tile=last_tile(ng),first_tile(ng),-1
355 CALL set_depth (ng, tile, iadm)
356 END DO
357 END DO
358#endif
359!
360!-----------------------------------------------------------------------
361! Compute adjoint state vector.
362!-----------------------------------------------------------------------
363!
364 DO ng=1,ngrids
365 DO tile=first_tile(ng),last_tile(ng),+1
366 CALL ad_inner2state (ng, tile, lini, ad_state(ng)%vector)
367 END DO
368 END DO
369!
370 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
371 20 FORMAT (/,a,i2.2,a,1p,e15.6,/)
372 30 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
373 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
374!
375 RETURN
subroutine, public tl_inner2state(ng, tile, lini, state)
Definition inner2state.F:63
subroutine, public ad_inner2state(ng, tile, lini, ad_state)
subroutine, public ini_c_norm(ng, tile, kinp, ninp, statenorm)

References ad_get_data(), ad_get_idata(), ini_adjust_mod::ad_ini_perturb(), inner2state_mod::ad_inner2state(), ad_main2d(), ad_main3d(), close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_param::iadm, mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, inner2state_mod::ini_c_norm(), mod_coupling::initialize_coupling(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_param::itlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_parallel::master, mod_scalars::nconv, mod_param::ngrids, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, mod_kinds::r8, mod_scalars::sec2day, set_depth_mod::set_depth(), mod_iounits::stdout, mod_scalars::synchro_flag, mod_scalars::tdays, mod_scalars::time, tl_get_data(), tl_get_idata(), inner2state_mod::tl_inner2state(), tl_main2d(), tl_main3d(), and dotproduct_mod::tl_statenorm().

Here is the call graph for this function:

◆ propagator_hso()

subroutine, public propagator_mod::propagator_hso ( real(dp), intent(in) runinterval,
integer iter,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 35 of file propagator_hso.h.

36!***********************************************************************
37!
38 USE mod_param
39 USE mod_parallel
40 USE mod_netcdf
41#ifdef SOLVE3D
42 USE mod_coupling
43#endif
44 USE mod_iounits
45 USE mod_ocean
46 USE mod_scalars
47 USE mod_stepping
48 USE mod_storage
49!
50 USE close_io_mod, ONLY : close_inp
55 USE inner2state_mod, ONLY : ini_c_norm
56#ifdef STOCH_OPT_WHITE
57 USE packing_mod, ONLY : ad_so_pack, ad_unpack, tl_unpack
58#else
59 USE packing_mod, ONLY : ad_so_pack_red, ad_unpack, tl_unpack
60#endif
61#ifdef SOLVE3D
62 USE set_depth_mod, ONLY : set_depth
63#endif
64 USE strings_mod, ONLY : founderror
65!
66! Imported variable declarations.
67!
68 integer :: Iter
69!
70 real(dp), intent(in) :: RunInterval
71!
72 TYPE (T_GST), intent(in) :: state(Ngrids)
73 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
74!
75! Local variable declarations.
76!
77 logical :: SOrunTL
78#ifdef STOCH_OPT_WHITE
79 logical :: SOrunAD
80#endif
81!
82 integer :: ng, tile
83 integer :: ktmp, ntmp, Lini
84 integer :: kout, nout
85 integer :: Fcount, Interval, IntTrap
86!
87 real(r8) :: StateNorm(Ngrids)
88 real(r8) :: so_run_time
89!
90 character (len=*), parameter :: MyFile = &
91 & __FILE__
92!
93!=======================================================================
94! Forward integration of the tangent linear model.
95!=======================================================================
96!
97 nrun=nrun+1
98 IF (master) THEN
99 DO ng=1,ngrids
100 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
101 & ', Iteration: ', nrun, &
102 & ', number converged RITZ values: ', &
103 & nconv(ng)
104 END DO
105 END IF
106!
107! Loop over the required numger if trapezoidal intervals in time.
108!
109 interval_loop : DO interval=1,nintervals+1
110
111 soruntl=.true.
112#ifdef STOCH_OPT_WHITE
113 sorunad=.true.
114#endif
115 IF (interval.eq.nintervals+1) THEN
116 soruntl=.false.
117#ifdef STOCH_OPT_WHITE
118 sorunad=.false.
119#endif
120 END IF
121 inttrap=interval
122!
123 IF (master) THEN
124 WRITE (stdout,20) ' Stochastic Optimals Time Interval = ', &
125 & interval
126 END IF
127!
128! Initialize time stepping indices and counters.
129!
130 lini=1
131 DO ng=1,ngrids
132#ifndef STOCH_OPT_WHITE
133 IF (interval.eq.1) THEN
134 soinitial(ng)=.true.
135 ELSE
136 soinitial(ng)=.false.
137 END IF
138#endif
139 IF (interval.eq.1) THEN
140 lwrttlm(ng)=.true.
141 ELSE
142 lwrttlm(ng)=.false.
143 END IF
144 iif(ng)=1
145 indx1(ng)=1
146 kstp(ng)=1
147 krhs(ng)=1
148 knew(ng)=1
149 predictor_2d_step(ng)=.false.
150!
151 iic(ng)=0
152 nstp(ng)=1
153 nrhs(ng)=1
154 nnew(ng)=1
155!
156 synchro_flag(ng)=.true.
157 tdays(ng)=dstart+real(ntimes(ng),r8)*real(interval-1,r8)* &
158 & dt(ng)*sec2day/real(nintervals,r8)
159 time(ng)=tdays(ng)*day2sec
160 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
161 ntend(ng)=ntimes(ng)
162 ntfirst(ng)=ntstart(ng)
163 so_run_time=dt(ng)*real(ntend(ng)-ntstart(ng)+1,r8)
164 END DO
165!
166! Set switches and counters to manage output adjoint and tangent linear
167! history NetCDF files.
168!
169 DO ng=1,ngrids
170 IF (iter.gt.0) THEN ! Arnoldi iteration loop
171 IF ((iter.eq.1).and.(interval.eq.1)) THEN
172 ldefadj(ng)=.true.
173 ldeftlm(ng)=.true. ! NetCDF files are created
174 ELSE ! on the first pass
175 ldefadj(ng)=.false.
176 ldeftlm(ng)=.false.
177 END IF
178 fcount=adm(ng)%load
179 adm(ng)%Nrec(fcount)=0
180 adm(ng)%Rindex=0
181 fcount=tlm(ng)%load
182 tlm(ng)%Nrec(fcount)=0
183 tlm(ng)%Rindex=0
184 ELSE ! Computing eigenvectors
185 IF (lmultigst.and.(interval.eq.1)) THEN
186 ldeftlm(ng)=.true.
187 ELSE
188 ldeftlm(ng)=.false.
189 END IF
190#ifdef STOCH_OPT_WHITE
191 IF (interval.le.nintervals) THEN
192 fcount=adm(ng)%load
193 adm(ng)%Nrec(fcount)=0
194 adm(ng)%Rindex=0
195 END IF
196#else
197 fcount=adm(ng)%load
198 adm(ng)%Nrec(fcount)=0
199 adm(ng)%Rindex=0
200#endif
201 IF ((lmultigst.or.(abs(iter).eq.1)).and. &
202 & (interval.eq.1)) THEN
203 fcount=tlm(ng)%load
204 tlm(ng)%Nrec(fcount)=0
205 tlm(ng)%Rindex=0
206 END IF
207 END IF
208 END DO
209!
210!-----------------------------------------------------------------------
211! Clear tangent linear state variables. There is not need to clean
212! the basic state arrays since they were zeroth out at initialization
213! and bottom of previous iteration.
214!-----------------------------------------------------------------------
215!
216 DO ng=1,ngrids
217 DO tile=first_tile(ng),last_tile(ng),+1
218 CALL initialize_ocean (ng, tile, itlm)
219 END DO
220 END DO
221
222#ifdef SOLVE3D
223!
224!-----------------------------------------------------------------------
225! Compute basic state initial level thicknesses used for state norm
226! scaling. It uses zero time-averaged free-surface (rest state).
227! Therefore, the norm scaling is time invariant.
228!-----------------------------------------------------------------------
229!
230 DO ng=1,ngrids
231 DO tile=last_tile(ng),first_tile(ng),-1
232 CALL set_depth (ng, tile, itlm)
233 END DO
234 END DO
235#endif
236!
237!-----------------------------------------------------------------------
238! Compute tangent linear initial conditions from state vector.
239!-----------------------------------------------------------------------
240!
241 DO ng=1,ngrids
242 DO tile=first_tile(ng),last_tile(ng),+1
243 CALL tl_inner2state (ng, tile, lini, state(ng)%vector)
244 END DO
245 END DO
246!
247!-----------------------------------------------------------------------
248! Compute initial tangent linear state analysis error norm.
249!-----------------------------------------------------------------------
250!
251 IF (interval.eq.1) THEN
252 DO ng=1,ngrids
253 DO tile=last_tile(ng),first_tile(ng),-1
254 CALL ini_c_norm (ng, tile, kstp(ng), nstp(ng), &
255 & statenorm(ng))
256 END DO
257 IF (master) THEN
258 WRITE (stdout,30) ' PROPAGATOR - Grid: ', ng, &
259 & ', Tangent Initial Norm: ', &
260 & statenorm(ng)
261 END IF
262 END DO
263 END IF
264!
265!-----------------------------------------------------------------------
266! Read in initial forcing, climatology and assimilation data from
267! input NetCDF files. It loads the first relevant data record for
268! the time-interpolation between snapshots.
269!-----------------------------------------------------------------------
270!
271 IF (soruntl) THEN ! do not run TLM on last interval
272 DO ng=1,ngrids
273 CALL close_inp (ng, itlm)
274 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
275
276 CALL tl_get_idata (ng)
277 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
278
279 CALL tl_get_data (ng)
280 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
281 END DO
282!
283!-----------------------------------------------------------------------
284! Time-step the tangent linear model.
285!-----------------------------------------------------------------------
286!
287 DO ng=1,ngrids
288 IF (master) THEN
289 WRITE (stdout,40) 'TL', ng, ntstart(ng), ntend(ng)
290 END IF
291 time(ng)=time(ng)-dt(ng)
292 iic(ng)=ntstart(ng)-1
293 END DO
294
295#ifdef SOLVE3D
296 CALL tl_main3d (so_run_time)
297#else
298 CALL tl_main2d (so_run_time)
299#endif
300 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
301 END IF
302!
303!-----------------------------------------------------------------------
304! Clear nonlinear (basic state) and adjoint state variables.
305!-----------------------------------------------------------------------
306!
307 DO ng=1,ngrids
308 DO tile=first_tile(ng),last_tile(ng),+1
309 CALL initialize_ocean (ng, tile, inlm)
310 CALL initialize_ocean (ng, tile, iadm)
311#ifdef SOLVE3D
312 CALL initialize_coupling (ng, tile, 0)
313#endif
314 END DO
315 END DO
316
317#ifdef SOLVE3D
318!
319!-----------------------------------------------------------------------
320! Compute basic state final level thicknesses used for state norm
321! scaling. It uses zero time-averaged free-surface (rest state).
322! Therefore, the norm scaling is time invariant.
323!-----------------------------------------------------------------------
324!
325 DO ng=1,ngrids
326 DO tile=last_tile(ng),first_tile(ng),-1
327 CALL set_depth (ng, tile, itlm)
328 END DO
329 END DO
330#endif
331!
332!-----------------------------------------------------------------------
333! Compute final tangent linear energy norm.
334!-----------------------------------------------------------------------
335!
336 IF (interval.eq.nintervals+1) THEN
337 DO ng=1,ngrids
338 DO tile=first_tile(ng),last_tile(ng),+1
339 CALL tl_statenorm (ng, tile, kstp(ng), nstp(ng), &
340 & statenorm(ng))
341 END DO
342 IF (master) THEN
343 WRITE (stdout,30) ' PROPAGATOR - Grid: ', ng, &
344 & ', Tangent Final Norm: ', &
345 & statenorm(ng)
346 END IF
347 END DO
348 END IF
349!
350!=======================================================================
351! Backward integration with the adjoint model.
352!=======================================================================
353!
354! Initialize time stepping indices and counters.
355!
356 DO ng=1,ngrids
357#ifndef STOCH_OPT_WHITE
358 lwrtstate2d(ng)=.false.
359 lwrtstate3d(ng)=.false.
360#endif
361 iif(ng)=1
362 indx1(ng)=1
363 ktmp=knew(ng)
364 IF (inttrap.eq.nintervals+1) THEN
365 ktmp=kstp(ng)
366 END IF
367 kstp(ng)=1
368 krhs(ng)=3
369 knew(ng)=2
370 kout=knew(ng)
371#ifdef STOCH_OPT_WHITE
372 IF (inttrap.eq.nintervals+1) THEN
373 kout=kstp(ng)
374 END IF
375#endif
376 predictor_2d_step(ng)=.false.
377!
378 iic(ng)=0
379 ntmp=nstp(ng)
380 nstp(ng)=1
381 nrhs(ng)=1
382 nnew(ng)=2
383!
384 synchro_flag(ng)=.true.
385 tdays(ng)=dstart+dt(ng)*real(ntimes(ng),r8)*sec2day
386 time(ng)=tdays(ng)*day2sec
387 ntstart(ng)=ntimes(ng)+1
388# ifdef STOCH_OPT_WHITE
389 ntend(ng)=1+(interval-1)*ntimes(ng)/nintervals
390# else
391 ntend(ng)=1
392# endif
393 ntfirst(ng)=ntend(ng)
394 END DO
395!
396!-----------------------------------------------------------------------
397! Initialize adjoint model with the final tangent linear solution
398! scaled by the energy norm.
399!-----------------------------------------------------------------------
400!
401 DO ng=1,ngrids
402 DO tile=last_tile(ng),first_tile(ng),-1
403 CALL ad_ini_perturb (ng, tile, &
404 & ktmp, kout, ntmp, nstp(ng))
405 END DO
406 END DO
407!
408!-----------------------------------------------------------------------
409! Read in initial forcing, climatology and assimilation data from
410! input NetCDF files. It loads the first relevant data record for
411! the time-interpolation between snapshots.
412!-----------------------------------------------------------------------
413!
414#ifdef STOCH_OPT_WHITE
415 IF (sorunad) THEN ! do not run ADM on last interval
416#endif
417 DO ng=1,ngrids
418 CALL close_inp (ng, iadm)
419 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
420
421 CALL ad_get_idata (ng)
422 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
423
424 CALL ad_get_data (ng)
425 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
426 END DO
427!
428!-----------------------------------------------------------------------
429! Time-step the adjoint model backwards.
430!-----------------------------------------------------------------------
431!
432 DO ng=1,ngrids
433 IF (master) THEN
434 WRITE (stdout,40) 'AD', ng, ntstart(ng), ntend(ng)
435 END IF
436 time(ng)=time(ng)+dt(ng)
437 iic(ng)=ntstart(ng)+1
438 END DO
439
440#ifdef SOLVE3D
441# ifdef STOCH_OPT_WHITE
442 CALL ad_main3d (so_run_time)
443# else
444 CALL ad_main3d (runinterval)
445# endif
446#else
447# ifdef STOCH_OPT_WHITE
448 CALL ad_main2d (so_run_time)
449# else
450 CALL ad_main2d (runinterval)
451# endif
452#endif
453 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
454#ifdef STOCH_OPT_WHITE
455 END IF
456#endif
457!
458!-----------------------------------------------------------------------
459! Clear nonlinear state (basic state) variables for next iteration
460! and to insure a rest state time averaged free-surface before adjoint
461! state norm scaling.
462!-----------------------------------------------------------------------
463!
464 DO ng=1,ngrids
465 DO tile=first_tile(ng),last_tile(ng),+1
466 CALL initialize_ocean (ng, tile, inlm)
467#ifdef SOLVE3D
468 CALL initialize_coupling (ng, tile, 0)
469#endif
470 END DO
471 END DO
472
473#ifdef SOLVE3D
474!
475!-----------------------------------------------------------------------
476! Compute basic state initial level thicknesses used for state norm
477! scaling. It uses zero free-surface (rest state). Therefore, the
478! norm scaling is time invariant.
479!-----------------------------------------------------------------------
480!
481 DO ng=1,ngrids
482 DO tile=last_tile(ng),first_tile(ng),-1
483 CALL set_depth (ng, tile, iadm)
484 END DO
485 END DO
486#endif
487!
488!-----------------------------------------------------------------------
489! Pack final adjoint solution into adjoint state vector.
490!-----------------------------------------------------------------------
491!
492 DO ng=1,ngrids
493 DO tile=first_tile(ng),last_tile(ng),+1
494# ifdef STOCH_OPT_WHITE
495 CALL ad_so_pack (ng, tile, nstr(ng), nend(ng), inttrap, &
496 & storage(ng)%my_state)
497# else
498 CALL ad_so_pack_red (ng, tile, nstr(ng), nend(ng), &
499 & inttrap, storage(ng)%my_state)
500# endif
501 END DO
502 END DO
503 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
504!
505!-----------------------------------------------------------------------
506! Clear forcing variables for next iteration.
507!-----------------------------------------------------------------------
508!
509 DO ng=1,ngrids
510 DO tile=last_tile(ng),first_tile(ng),-1
511 CALL initialize_forces (ng, tile, itlm)
512 CALL initialize_forces (ng, tile, iadm)
513 END DO
514 END DO
515
516 END DO interval_loop
517!
518!-----------------------------------------------------------------------
519! Finally, unpack "my_state", and compute the adjoint state vector.
520!-----------------------------------------------------------------------
521!
522 DO ng=1,ngrids
523 DO tile=first_tile(ng),last_tile(ng),+1
524 CALL ad_unpack (ng, tile, nstr(ng), nend(ng), &
525 & storage(ng)%my_state)
526 END DO
527 END DO
528 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
529!
530 DO ng=1,ngrids
531 DO tile=last_tile(ng),first_tile(ng),-1
532 CALL ad_inner2state (ng, tile, lini, ad_state(ng)%vector)
533 END DO
534 END DO
535 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
536!
537 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
538 20 FORMAT (/,a,i2.2)
539 30 FORMAT (/,a,i2.2,a,1p,e15.6,/)
540 40 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
541 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
542!
543 RETURN
type(t_io), dimension(:), allocatable adm
type(t_io), dimension(:), allocatable tlm
logical lmultigst
logical, dimension(:), allocatable ldefadj
logical, dimension(:), allocatable lwrtstate2d
integer nintervals
logical, dimension(:), allocatable lwrttlm
logical, dimension(:), allocatable ldeftlm
type(t_storage), dimension(:), allocatable storage
Definition mod_storage.F:91

References ad_get_data(), ad_get_idata(), ini_adjust_mod::ad_ini_perturb(), inner2state_mod::ad_inner2state(), ad_main2d(), ad_main3d(), ad_unpack(), mod_iounits::adm, close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_param::iadm, mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, inner2state_mod::ini_c_norm(), mod_coupling::initialize_coupling(), mod_forces::initialize_forces(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_param::itlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_scalars::ldefadj, mod_scalars::ldeftlm, mod_scalars::lmultigst, mod_scalars::lwrtstate2d, mod_scalars::lwrttlm, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_scalars::nintervals, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, mod_kinds::r8, mod_scalars::sec2day, set_depth_mod::set_depth(), mod_iounits::stdout, mod_storage::storage, mod_scalars::synchro_flag, mod_scalars::tdays, mod_scalars::time, tl_get_data(), tl_get_idata(), inner2state_mod::tl_inner2state(), tl_main2d(), tl_main3d(), dotproduct_mod::tl_statenorm(), tl_unpack(), and mod_iounits::tlm.

Here is the call graph for this function:

◆ propagator_op()

subroutine, public propagator_mod::propagator_op ( real(dp), intent(in) runinterval,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 37 of file propagator_op.h.

38!***********************************************************************
39!
40 USE mod_param
41 USE mod_parallel
42#ifdef SOLVE3D
43 USE mod_coupling
44#endif
45 USE mod_iounits
46 USE mod_ocean
47 USE mod_scalars
48 USE mod_stepping
49!
50 USE close_io_mod, ONLY : close_inp
53 USE packing_mod, ONLY : tl_unpack, ad_pack
54#ifdef SOLVE3D
55 USE set_depth_mod, ONLY : set_depth
56#endif
57 USE strings_mod, ONLY : founderror
58!
59! Imported variable declarations.
60!
61 real(dp), intent(in) :: RunInterval
62!
63 TYPE (T_GST), intent(in) :: state(Ngrids)
64 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
65!
66! Local variable declarations.
67!
68 integer :: ng, tile
69 integer :: ktmp, ntmp
70!
71 real(r8) :: StateNorm(Ngrids)
72!
73 character (len=*), parameter :: MyFile = &
74 & __FILE__
75!
76!=======================================================================
77! Forward integration of the tangent linear model.
78!=======================================================================
79!
80 nrun=nrun+1
81 IF (master) THEN
82 DO ng=1,ngrids
83 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
84 & ', Iteration: ', nrun, &
85 & ', number converged RITZ values: ', &
86 & nconv(ng)
87 END DO
88 END IF
89!
90! Initialize time stepping indices and counters.
91!
92 DO ng=1,ngrids
93 iif(ng)=1
94 indx1(ng)=1
95 kstp(ng)=1
96 krhs(ng)=1
97 knew(ng)=1
98 predictor_2d_step(ng)=.false.
99!
100 iic(ng)=0
101 nstp(ng)=1
102 nrhs(ng)=1
103 nnew(ng)=1
104!
105 synchro_flag(ng)=.true.
106 tdays(ng)=dstart
107 time(ng)=tdays(ng)*day2sec
108 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
109 ntend(ng)=ntimes(ng)
110 ntfirst(ng)=ntstart(ng)
111 END DO
112!
113!-----------------------------------------------------------------------
114! Clear tangent linear state variables. There is not need to clean
115! the basic state arrays since they were zeroth out at initialization
116! and bottom of previous iteration.
117!-----------------------------------------------------------------------
118!
119 DO ng=1,ngrids
120 DO tile=first_tile(ng),last_tile(ng),+1
121 CALL initialize_ocean (ng, tile, itlm)
122 END DO
123 END DO
124
125#ifdef SOLVE3D
126!
127!-----------------------------------------------------------------------
128! Compute basic state initial level thicknesses used for state norm
129! scaling. It uses zero time-averaged free-surface (rest state).
130! Therefore, the norm scaling is time invariant.
131!-----------------------------------------------------------------------
132!
133 DO ng=1,ngrids
134 DO tile=last_tile(ng),first_tile(ng),-1
135 CALL set_depth (ng, tile, itlm)
136 END DO
137 END DO
138#endif
139!
140!-----------------------------------------------------------------------
141! Unpack tangent linear initial conditions from state vector.
142!-----------------------------------------------------------------------
143!
144 DO ng=1,ngrids
145 DO tile=first_tile(ng),last_tile(ng),+1
146 CALL tl_unpack (ng, tile, nstr(ng), nend(ng), &
147 & state(ng)%vector)
148 END DO
149 END DO
150!
151!-----------------------------------------------------------------------
152! Compute initial tangent linear state dot product norm.
153!-----------------------------------------------------------------------
154!
155 DO ng=1,ngrids
156 DO tile=last_tile(ng),first_tile(ng),-1
157 CALL tl_statenorm (ng, tile, kstp(ng), nstp(ng), &
158 & statenorm(ng))
159 END DO
160 IF (master) THEN
161 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
162 & ', Tangent Initial Norm: ', statenorm(ng)
163 END IF
164 END DO
165!
166!-----------------------------------------------------------------------
167! Read in initial forcing, climatology and assimilation data from
168! input NetCDF files. It loads the first relevant data record for
169! the time-interpolation between snapshots.
170!-----------------------------------------------------------------------
171!
172 DO ng=1,ngrids
173 CALL close_inp (ng, itlm)
174 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
175
176 CALL tl_get_idata (ng)
177 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
178
179 CALL tl_get_data (ng)
180 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
181 END DO
182!
183!-----------------------------------------------------------------------
184! Time-step the tangent linear model.
185!-----------------------------------------------------------------------
186!
187 DO ng=1,ngrids
188 IF (master) THEN
189 WRITE (stdout,30) 'TL', ng, ntstart(ng), ntend(ng)
190 END IF
191 time(ng)=time(ng)-dt(ng)
192 iic(ng)=ntstart(ng)-1
193 END DO
194
195#ifdef SOLVE3D
196 CALL tl_main3d (runinterval)
197#else
198 CALL tl_main2d (runinterval)
199#endif
200 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
201!
202!-----------------------------------------------------------------------
203! Clear nonlinear (basic state) and adjoint state variables.
204!-----------------------------------------------------------------------
205!
206 DO ng=1,ngrids
207 DO tile=first_tile(ng),last_tile(ng),+1
208 CALL initialize_ocean (ng, tile, inlm)
209 CALL initialize_ocean (ng, tile, iadm)
210#ifdef SOLVE3D
211 CALL initialize_coupling (ng, tile, 0)
212#endif
213 END DO
214 END DO
215
216#ifdef SOLVE3D
217!
218!-----------------------------------------------------------------------
219! Compute basic state final level thicknesses used for state norm
220! scaling. It uses zero time-averaged free-surface (rest state).
221! Therefore, the norm scaling is time invariant.
222!-----------------------------------------------------------------------
223!
224 DO ng=1,ngrids
225 DO tile=last_tile(ng),first_tile(ng),-1
226 CALL set_depth (ng, tile, itlm)
227 END DO
228 END DO
229#endif
230!
231!-----------------------------------------------------------------------
232! Compute final tangent linear state dot product norm.
233!-----------------------------------------------------------------------
234!
235 DO ng=1,ngrids
236 DO tile=first_tile(ng),last_tile(ng),+1
237 CALL tl_statenorm (ng, tile, knew(ng), nstp(ng), &
238 & statenorm(ng))
239 END DO
240 IF (master) THEN
241 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
242 & ', Tangent Final Norm: ', statenorm(ng)
243 END IF
244 END DO
245!
246!=======================================================================
247! Backward integration with the adjoint model.
248!=======================================================================
249!
250! Initialize time stepping indices and counters.
251!
252 DO ng=1,ngrids
253 iif(ng)=1
254 indx1(ng)=1
255 ktmp=knew(ng)
256 kstp(ng)=1
257 krhs(ng)=3
258 knew(ng)=2
259 predictor_2d_step(ng)=.false.
260!
261 iic(ng)=0
262 ntmp=nstp(ng)
263 nstp(ng)=1
264 nrhs(ng)=1
265 nnew(ng)=2
266!
267 synchro_flag(ng)=.true.
268 tdays(ng)=dstart+dt(ng)*real(ntimes(ng),r8)*sec2day
269 time(ng)=tdays(ng)*day2sec
270 ntstart(ng)=ntimes(ng)+1
271 ntend(ng)=1
272 ntfirst(ng)=ntend(ng)
273 END DO
274!
275!-----------------------------------------------------------------------
276! Initialize adjoint model with the final tangent linear solution
277! scaled by the energy norm.
278!-----------------------------------------------------------------------
279!
280 DO ng=1,ngrids
281 DO tile=last_tile(ng),first_tile(ng),-1
282 CALL ad_ini_perturb (ng, tile, &
283 & ktmp, knew(ng), ntmp, nstp(ng))
284 END DO
285 END DO
286!
287!-----------------------------------------------------------------------
288! Read in initial forcing, climatology and assimilation data from
289! input NetCDF files. It loads the first relevant data record for
290! the time-interpolation between snapshots.
291!-----------------------------------------------------------------------
292!
293 DO ng=1,ngrids
294 CALL close_inp (ng, iadm)
295 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
296
297 CALL ad_get_idata (ng)
298 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
299
300 CALL ad_get_data (ng)
301 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
302 END DO
303!
304!-----------------------------------------------------------------------
305! Time-step the adjoint model backwards.
306!-----------------------------------------------------------------------
307!
308 DO ng=1,ngrids
309 IF (master) THEN
310 WRITE (stdout,30) 'AD', ng, ntstart(ng), ntend(ng)
311 END IF
312 time(ng)=time(ng)+dt(ng)
313 iic(ng)=ntstart(ng)+1
314 END DO
315
316#ifdef SOLVE3D
317 CALL ad_main3d (runinterval)
318#else
319 CALL ad_main2d (runinterval)
320#endif
321 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
322!
323!-----------------------------------------------------------------------
324! Clear nonlinear state (basic state) variables for next iteration
325! and to insure a rest state time averaged free-surface before adjoint
326! state norm scaling.
327!-----------------------------------------------------------------------
328!
329 DO ng=1,ngrids
330 DO tile=first_tile(ng),last_tile(ng),+1
331 CALL initialize_ocean (ng, tile, inlm)
332#ifdef SOLVE3D
333 CALL initialize_coupling (ng, tile, 0)
334#endif
335 END DO
336 END DO
337
338#ifdef SOLVE3D
339!
340!-----------------------------------------------------------------------
341! Compute basic state initial level thicknesses used for state norm
342! scaling. It uses zero free-surface (rest state). Therefore, the
343! norm scaling is time invariant.
344!-----------------------------------------------------------------------
345!
346 DO ng=1,ngrids
347 DO tile=last_tile(ng),first_tile(ng),-1
348 CALL set_depth (ng, tile, iadm)
349 END DO
350 END DO
351#endif
352!
353!-----------------------------------------------------------------------
354! Pack final adjoint solution into adjoint state vector.
355!-----------------------------------------------------------------------
356!
357 DO ng=1,ngrids
358 DO tile=first_tile(ng),last_tile(ng),+1
359 CALL ad_pack (ng, tile, nstr(ng), nend(ng), &
360 & ad_state(ng)%vector)
361 END DO
362 END DO
363!
364 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
365 20 FORMAT (/,a,i2.2,a,1p,e15.6,/)
366 30 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
367 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
368!
369 RETURN

References ad_get_data(), ad_get_idata(), ini_adjust_mod::ad_ini_perturb(), ad_main2d(), ad_main3d(), ad_pack(), close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_param::iadm, mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, mod_coupling::initialize_coupling(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_param::itlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, mod_kinds::r8, mod_scalars::sec2day, set_depth_mod::set_depth(), mod_iounits::stdout, mod_scalars::synchro_flag, mod_scalars::tdays, mod_scalars::time, tl_get_data(), tl_get_idata(), tl_main2d(), tl_main3d(), dotproduct_mod::tl_statenorm(), and tl_unpack().

Here is the call graph for this function:

◆ propagator_so()

subroutine, public propagator_mod::propagator_so ( real(dp), intent(in) runinterval,
integer iter,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 30 of file propagator_so.h.

31!***********************************************************************
32!
33 USE mod_param
34 USE mod_parallel
35 USE mod_netcdf
36#ifdef SOLVE3D
37 USE mod_coupling
38#endif
39 USE mod_iounits
40 USE mod_ocean
41 USE mod_scalars
42 USE mod_stepping
43!
44 USE close_io_mod, ONLY : close_inp
48#ifdef STOCH_OPT_WHITE
49 USE packing_mod, ONLY : ad_so_pack, tl_unpack
50#else
51 USE packing_mod, ONLY : ad_so_pack_red, tl_unpack
52#endif
53#ifdef SOLVE3D
54 USE set_depth_mod, ONLY : set_depth
55#endif
56 USE strings_mod, ONLY : founderror
57!
58! Imported variable declarations.
59!
60 integer :: Iter
61!
62 real(dp), intent(in) :: RunInterval
63!
64 TYPE (T_GST), intent(in) :: state(Ngrids)
65 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
66!
67! Local variable declarations.
68!
69 logical :: SOrunTL
70#ifdef STOCH_OPT_WHITE
71 logical :: SOrunAD
72#endif
73!
74 integer :: ng, tile
75 integer :: ktmp, ntmp
76 integer :: kout, nout
77 integer :: Fcount, Interval, IntTrap
78!
79 real(r8) :: StateNorm(Ngrids)
80 real(r8) :: so_run_time
81!
82 character (len=*), parameter :: MyFile = &
83 & __FILE__
84!
85!=======================================================================
86! Forward integration of the tangent linear model.
87!=======================================================================
88!
89 nrun=nrun+1
90 IF (master) THEN
91 DO ng=1,ngrids
92 WRITE (stdout,10) ' PROPAGATOR - Grid: ', ng, &
93 & ', Iteration: ', nrun, &
94 & ', number converged RITZ values: ', &
95 & nconv(ng)
96 END DO
97 END IF
98!
99! Loop over the required numger if trapezoidal intervals in time.
100!
101 interval_loop : DO interval=1,nintervals+1
102
103 soruntl=.true.
104#ifdef STOCH_OPT_WHITE
105 sorunad=.true.
106#endif
107 IF (interval.eq.nintervals+1) THEN
108 soruntl=.false.
109#ifdef STOCH_OPT_WHITE
110 sorunad=.false.
111#endif
112 END IF
113 inttrap=interval
114!
115 IF (master) THEN
116 WRITE (stdout,20) ' Stochastic Optimals Time Interval = ', &
117 & interval
118 END IF
119!
120! Initialize time stepping indices and counters.
121!
122 DO ng=1,ngrids
123#ifndef STOCH_OPT_WHITE
124 IF (interval.eq.1) THEN
125 soinitial(ng)=.true.
126 ELSE
127 soinitial(ng)=.false.
128 END IF
129#endif
130 IF (interval.eq.1) THEN
131 lwrttlm(ng)=.true.
132 ELSE
133 lwrttlm(ng)=.false.
134 END IF
135 iif(ng)=1
136 indx1(ng)=1
137 kstp(ng)=1
138 krhs(ng)=1
139 knew(ng)=1
140 predictor_2d_step(ng)=.false.
141!
142 iic(ng)=0
143 nstp(ng)=1
144 nrhs(ng)=1
145 nnew(ng)=1
146!
147 synchro_flag(ng)=.true.
148 tdays(ng)=dstart+real(ntimes(ng),r8)*real(interval-1,r8)* &
149 & dt(ng)*sec2day/real(nintervals,r8)
150 time(ng)=tdays(ng)*day2sec
151 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
152 ntend(ng)=ntimes(ng)
153 ntfirst(ng)=ntstart(ng)
154 so_run_time=dt(ng)*real(ntend(ng)-ntstart(ng)+1,r8)
155 END DO
156!
157! Set switches and counters to manage output adjoint and tangent linear
158! history NetCDF files.
159!
160 DO ng=1,ngrids
161 IF (iter.gt.0) THEN ! Arnoldi iteration loop
162 IF ((iter.eq.1).and.(interval.eq.1)) THEN
163 ldefadj(ng)=.true.
164 ldeftlm(ng)=.true. ! NetCDF files are created
165 ELSE ! on the first pass
166 ldefadj(ng)=.false.
167 ldeftlm(ng)=.false.
168 END IF
169 fcount=adm(ng)%load
170 adm(ng)%Nrec(fcount)=0
171 adm(ng)%Rindex=0
172 fcount=tlm(ng)%load
173 tlm(ng)%Nrec(fcount)=0
174 tlm(ng)%Rindex=0
175 ELSE ! Computing eigenvectors
176 IF (lmultigst.and.(interval.eq.1)) THEN
177 ldeftlm(ng)=.true.
178 ELSE
179 ldeftlm(ng)=.false.
180 END IF
181#ifdef STOCH_OPT_WHITE
182 IF (interval.le.nintervals) THEN
183 fcount=adm(ng)%load
184 adm(ng)%Nrec(fcount)=0
185 adm(ng)%Rindex=0
186 END IF
187#else
188 fcount=adm(ng)%load
189 adm(ng)%Nrec(fcount)=0
190 adm(ng)%Rindex=0
191#endif
192 IF ((lmultigst.or.(abs(iter).eq.1)).and. &
193 & (interval.eq.1)) THEN
194 fcount=tlm(ng)%load
195 tlm(ng)%Nrec(fcount)=0
196 tlm(ng)%Rindex=0
197 END IF
198 END IF
199 END DO
200!
201!-----------------------------------------------------------------------
202! Clear tangent linear state variables. There is not need to clean
203! the basic state arrays since they were zeroth out at initialization
204! and bottom of previous iteration.
205!-----------------------------------------------------------------------
206!
207 DO ng=1,ngrids
208 DO tile=first_tile(ng),last_tile(ng),+1
209 CALL initialize_ocean (ng, tile, itlm)
210 END DO
211 END DO
212
213#ifdef SOLVE3D
214!
215!-----------------------------------------------------------------------
216! Compute basic state initial level thicknesses used for state norm
217! scaling. It uses zero time-averaged free-surface (rest state).
218! Therefore, the norm scaling is time invariant.
219!-----------------------------------------------------------------------
220!
221 DO ng=1,ngrids
222 DO tile=last_tile(ng),first_tile(ng),-1
223 CALL set_depth (ng, tile, itlm)
224 END DO
225 END DO
226#endif
227!
228!-----------------------------------------------------------------------
229! Unpack tangent linear initial conditions from state vector.
230!-----------------------------------------------------------------------
231!
232 DO ng=1,ngrids
233 DO tile=first_tile(ng),last_tile(ng),+1
234 CALL tl_unpack (ng, tile, nstr(ng), nend(ng), &
235 & state(ng)%vector)
236 END DO
237 END DO
238!
239!-----------------------------------------------------------------------
240! Compute initial tangent linear state dot product norm.
241!-----------------------------------------------------------------------
242!
243 IF (interval.eq.nintervals+1) THEN
244 DO ng=1,ngrids
245 DO tile=last_tile(ng),first_tile(ng),-1
246 CALL tl_statenorm (ng, tile, kstp(ng), nstp(ng), &
247 & statenorm(ng))
248 END DO
249 IF (master) THEN
250 WRITE (stdout,30) ' PROPAGATOR - Grid: ', ng, &
251 & ', Tangent Initial Norm: ', &
252 & statenorm(ng)
253 END IF
254 END DO
255 END IF
256!
257!-----------------------------------------------------------------------
258! Read in initial forcing, climatology and assimilation data from
259! input NetCDF files. It loads the first relevant data record for
260! the time-interpolation between snapshots.
261!-----------------------------------------------------------------------
262!
263 IF (soruntl) THEN ! do not run TLM on last interval
264 DO ng=1,ngrids
265 CALL close_inp (ng, itlm)
266 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
267
268 CALL tl_get_idata (ng)
269 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
270
271 CALL tl_get_data (ng)
272 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
273 END DO
274!
275!-----------------------------------------------------------------------
276! Time-step the tangent linear model.
277!-----------------------------------------------------------------------
278!
279 DO ng=1,ngrids
280 IF (master) THEN
281 WRITE (stdout,40) 'TL', ng, ntstart(ng), ntend(ng)
282 END IF
283 time(ng)=time(ng)-dt(ng)
284 iic(ng)=ntstart(ng)-1
285 END DO
286
287#ifdef SOLVE3D
288 CALL tl_main3d (so_run_time)
289#else
290 CALL tl_main2d (so_run_time)
291#endif
292 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
293 END IF
294!
295!-----------------------------------------------------------------------
296! Clear nonlinear (basic state) and adjoint state variables.
297!-----------------------------------------------------------------------
298!
299 DO ng=1,ngrids
300 DO tile=first_tile(ng),last_tile(ng),+1
301 CALL initialize_ocean (ng, tile, inlm)
302 CALL initialize_ocean (ng, tile, iadm)
303#ifdef SOLVE3D
304 CALL initialize_coupling (ng, tile, 0)
305#endif
306 END DO
307 END DO
308
309#ifdef SOLVE3D
310!
311!-----------------------------------------------------------------------
312! Compute basic state final level thicknesses used for state norm
313! scaling. It uses zero time-averaged free-surface (rest state).
314! Therefore, the norm scaling is time invariant.
315!-----------------------------------------------------------------------
316!
317 DO ng=1,ngrids
318 DO tile=last_tile(ng),first_tile(ng),-1
319 CALL set_depth (ng, tile, itlm)
320 END DO
321 END DO
322#endif
323!
324!-----------------------------------------------------------------------
325! Compute final tangent linear state dot product norm.
326!-----------------------------------------------------------------------
327!
328 IF (interval.eq.nintervals+1) THEN
329 DO ng=1,ngrids
330 DO tile=first_tile(ng),last_tile(ng),+1
331 CALL tl_statenorm (ng, tile, kstp(ng), nstp(ng), &
332 & statenorm(ng))
333 END DO
334 IF (master) THEN
335 WRITE (stdout,30) ' PROPAGATOR - Grid: ', ng, &
336 & ', Tangent Final Norm: ', &
337 & statenorm(ng)
338 END IF
339 END DO
340 END IF
341!
342!=======================================================================
343! Backward integration with the adjoint model.
344!=======================================================================
345!
346! Initialize time stepping indices and counters.
347!
348 DO ng=1,ngrids
349#ifndef STOCH_OPT_WHITE
350 lwrtstate2d(ng)=.false.
351 lwrtstate3d(ng)=.false.
352#endif
353 iif(ng)=1
354 indx1(ng)=1
355 ktmp=knew(ng)
356 IF (inttrap.eq.nintervals+1) THEN
357 ktmp=kstp(ng)
358 END IF
359 kstp(ng)=1
360 krhs(ng)=3
361 knew(ng)=2
362 kout=knew(ng)
363#ifdef STOCH_OPT_WHITE
364 IF (inttrap.eq.nintervals+1) THEN
365 kout=kstp(ng)
366 END IF
367#endif
368 predictor_2d_step(ng)=.false.
369!
370 iic(ng)=0
371 ntmp=nstp(ng)
372 nstp(ng)=1
373 nrhs(ng)=1
374 nnew(ng)=2
375!
376 synchro_flag(ng)=.true.
377 tdays(ng)=dstart+dt(ng)*real(ntimes(ng),r8)*sec2day
378 time(ng)=tdays(ng)*day2sec
379 ntstart(ng)=ntimes(ng)+1
380# ifdef STOCH_OPT_WHITE
381 ntend(ng)=1+(interval-1)*ntimes(ng)/nintervals
382# else
383 ntend(ng)=1
384# endif
385 ntfirst(ng)=ntend(ng)
386 END DO
387!
388!-----------------------------------------------------------------------
389! Initialize adjoint model with the final tangent linear solution
390! scaled by the energy norm.
391!-----------------------------------------------------------------------
392!
393 DO ng=1,ngrids
394 DO tile=last_tile(ng),first_tile(ng),-1
395 CALL ad_ini_perturb (ng, tile, &
396 & ktmp, kout, ntmp, nstp(ng))
397 END DO
398 END DO
399!
400!-----------------------------------------------------------------------
401! Read in initial forcing, climatology and assimilation data from
402! input NetCDF files. It loads the first relevant data record for
403! the time-interpolation between snapshots.
404!-----------------------------------------------------------------------
405!
406#ifdef STOCH_OPT_WHITE
407 IF (sorunad) THEN ! do not run ADM on last interval
408#endif
409 DO ng=1,ngrids
410 CALL close_inp (ng, iadm)
411 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
412
413 CALL ad_get_idata (ng)
414 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
415
416 CALL ad_get_data (ng)
417 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
418 END DO
419!
420!-----------------------------------------------------------------------
421! Time-step the adjoint model backwards.
422!-----------------------------------------------------------------------
423!
424 DO ng=1,ngrids
425 IF (master) THEN
426 WRITE (stdout,40) 'AD', ng, ntstart(ng), ntend(ng)
427 END IF
428 time(ng)=time(ng)+dt(ng)
429 iic(ng)=ntstart(ng)+1
430 END DO
431
432#ifdef SOLVE3D
433# ifdef STOCH_OPT_WHITE
434 CALL ad_main3d (so_run_time)
435# else
436 CALL ad_main3d (runinterval)
437# endif
438#else
439# ifdef STOCH_OPT_WHITE
440 CALL ad_main2d (so_run_time)
441# else
442 CALL ad_main2d (runinterval)
443# endif
444#endif
445 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
446#ifdef STOCH_OPT_WHITE
447 END IF
448#endif
449!
450!-----------------------------------------------------------------------
451! Clear nonlinear state (basic state) variables for next iteration
452! and to insure a rest state time averaged free-surface before adjoint
453! state norm scaling.
454!-----------------------------------------------------------------------
455!
456 DO ng=1,ngrids
457 DO tile=first_tile(ng),last_tile(ng),+1
458 CALL initialize_ocean (ng, tile, inlm)
459#ifdef SOLVE3D
460 CALL initialize_coupling (ng, tile, 0)
461#endif
462 END DO
463 END DO
464
465#ifdef SOLVE3D
466!
467!-----------------------------------------------------------------------
468! Compute basic state initial level thicknesses used for state norm
469! scaling. It uses zero free-surface (rest state). Therefore, the
470! norm scaling is time invariant.
471!-----------------------------------------------------------------------
472!
473 DO ng=1,ngrids
474 DO tile=last_tile(ng),first_tile(ng),-1
475 CALL set_depth (ng, tile, iadm)
476 END DO
477 END DO
478#endif
479!
480!-----------------------------------------------------------------------
481! Pack final adjoint solution into adjoint state vector.
482!-----------------------------------------------------------------------
483!
484 DO ng=1,ngrids
485 DO tile=first_tile(ng),last_tile(ng),+1
486# ifdef STOCH_OPT_WHITE
487 CALL ad_so_pack (ng, tile, nstr(ng), nend(ng), inttrap, &
488 & ad_state(ng)%vector)
489# else
490 CALL ad_so_pack_red (ng, tile, nstr(ng), nend(ng), &
491 & inttrap, ad_state(ng)%vector)
492# endif
493 END DO
494 END DO
495 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
496!
497!-----------------------------------------------------------------------
498! Clear forcing variables for next iteration.
499!-----------------------------------------------------------------------
500!
501 DO ng=1,ngrids
502 DO tile=first_tile(ng),last_tile(ng),+1
503 CALL initialize_forces (ng, tile, itlm)
504 CALL initialize_forces (ng, tile, iadm)
505 END DO
506 END DO
507
508 END DO interval_loop
509!
510 10 FORMAT (/,a,i2.2,a,i3.3,a,i3.3/)
511 20 FORMAT (/,a,i2.2)
512 30 FORMAT (/,a,i2.2,a,1p,e15.6,/)
513 40 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
514 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
515!
516 RETURN

References ad_get_data(), ad_get_idata(), ini_adjust_mod::ad_ini_perturb(), ad_main2d(), ad_main3d(), mod_iounits::adm, close_io_mod::close_inp(), mod_scalars::day2sec, mod_scalars::dstart, mod_scalars::dt, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_param::iadm, mod_scalars::iic, mod_scalars::iif, mod_scalars::indx1, mod_coupling::initialize_coupling(), mod_forces::initialize_forces(), mod_ocean::initialize_ocean(), mod_param::inlm, mod_param::itlm, mod_stepping::knew, mod_stepping::krhs, mod_stepping::kstp, mod_parallel::last_tile, mod_scalars::ldefadj, mod_scalars::ldeftlm, mod_scalars::lmultigst, mod_scalars::lwrtstate2d, mod_scalars::lwrttlm, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_scalars::nintervals, mod_stepping::nnew, mod_scalars::noerror, mod_stepping::nrhs, mod_scalars::nrun, mod_stepping::nstp, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntfirst, mod_scalars::ntimes, mod_scalars::ntstart, mod_scalars::predictor_2d_step, mod_kinds::r8, mod_scalars::sec2day, set_depth_mod::set_depth(), mod_iounits::stdout, mod_scalars::synchro_flag, mod_scalars::tdays, mod_scalars::time, tl_get_data(), tl_get_idata(), tl_main2d(), tl_main3d(), dotproduct_mod::tl_statenorm(), tl_unpack(), and mod_iounits::tlm.

Here is the call graph for this function:

◆ propagator_so_semi()

subroutine, public propagator_mod::propagator_so_semi ( real(dp), intent(in) runinterval,
type (t_gst), dimension(ngrids), intent(in) state,
type (t_gst), dimension(ngrids), intent(inout) ad_state )

Definition at line 34 of file propagator_so_semi.h.

35!***********************************************************************
36!
37 USE mod_param
38 USE mod_parallel
39 USE mod_iounits
40 USE mod_ocean
41 USE mod_scalars
42 USE mod_stepping
43!
44#ifdef SO_SEMI_WHITE
45 USE packing_mod, ONLY : so_semi_white
46#else
47 USE packing_mod, ONLY : so_semi_red
48#endif
49 USE strings_mod, ONLY : founderror
50!
51! Imported variable declarations.
52!
53 real(dp), intent(in) :: RunInterval
54!
55 TYPE (T_GST), intent(in) :: state(Ngrids)
56 TYPE (T_GST), intent(inout) :: ad_state(Ngrids)
57!
58! Local variable declarations.
59!
60 logical, save :: FirstPass = .true.
61!
62 integer :: ng, tile
63!
64 character (len=*), parameter :: MyFile = &
65 & __FILE__
66!
67!=======================================================================
68! Backward integration of adjoint model forced with the seminorm of
69! the chosen functional. The adjoint model is run only only once in
70! the first iteration.
71!=======================================================================
72!
73 nrun=nrun+1
74 DO ng=1,ngrids
75 sorec(ng)=0
76 END DO
77!
78 first_pass : IF (firstpass) THEN
79 firstpass=.false.
80!
81! Initialize the adjoint model always from rest.
82!
83 DO ng=1,ngrids
84 CALL ad_initial (ng)
85 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
86 END DO
87!
88! Activate adjoint output.
89!
90 DO ng=1,ngrids
91 ldefadj(ng)=.true.
92 lwrtadj(ng)=.true.
93 lcycleadj(ng)=.false.
94 END DO
95!
96! Time-step adjoint model forced with chosen functional at initial
97! time only.
98!
99 DO ng=1,ngrids
100 IF (master) THEN
101 WRITE (stdout,10) 'AD', ng, ntstart(ng), ntend(ng)
102 END IF
103 dstrs(ng)=tdays(ng)
104 dends(ng)=dstrs(ng)
105 END DO
106
107#ifdef SOLVE3D
108 CALL ad_main3d (runinterval)
109#else
110 CALL ad_main2d (runinterval)
111#endif
112 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
113
114 END IF first_pass
115!
116!-----------------------------------------------------------------------
117! Compute new packed adjoint state vector containing surface forcing
118! variables.
119!-----------------------------------------------------------------------
120!
121 DO ng=1,ngrids
122 DO tile=first_tile(ng),last_tile(ng),+1
123# ifdef SO_SEMI_WHITE
124 CALL so_semi_white (ng, tile, nstr(ng), nend(ng), &
125 & state(ng)%vector, &
126 & ad_state(ng)%vector)
127# else
128 CALL so_semi_red (ng, tile, nstr(ng), nend(ng), &
129 & state(ng)%vector, &
130 & ad_state(ng)%vector)
131# endif
132 END DO
133 END DO
134!
135!-----------------------------------------------------------------------
136! Report iteration and trace or stochastic optimals matrix.
137!-----------------------------------------------------------------------
138!
139 IF (master) THEN
140 DO ng=1,ngrids
141 WRITE (stdout,20) ' PROPAGATOR - Grid: ', ng, &
142 & ', Iteration: ', nrun, &
143 & ', number converged RITZ values: ', &
144 & nconv(ng), 'TRnorm = ', trnorm(ng)
145 END DO
146 END IF
147!
148 10 FORMAT (/,1x,a,1x,'ROMS: started time-stepping:', &
149 & ' (Grid: ',i2.2,' TimeSteps: ',i8.8,' - ',i8.8,')')
150 20 FORMAT (/,a,i2.2,a,i3.3,a,i3.3,/,42x,a,1p,e15.8)
151!
152 RETURN
subroutine ad_initial(ng)
Definition ad_initial.F:4
integer, dimension(:), allocatable sorec
real(r8), dimension(:), allocatable dends
logical, dimension(:), allocatable lcycleadj
logical, dimension(:), allocatable lwrtadj
real(r8), dimension(:), allocatable dstrs
real(r8), dimension(:), allocatable trnorm
subroutine so_semi_white(ng, tile, mstr, mend, state, ad_state)
Definition packing.F:8788
subroutine so_semi_red(ng, tile, mstr, mend, state, ad_state)
Definition packing.F:8981

References ad_initial(), ad_main2d(), ad_main3d(), mod_scalars::dends, mod_scalars::dstrs, mod_scalars::exit_flag, mod_parallel::first_tile, strings_mod::founderror(), mod_parallel::last_tile, mod_scalars::lcycleadj, mod_scalars::ldefadj, mod_scalars::lwrtadj, mod_parallel::master, mod_scalars::nconv, mod_param::nend, mod_param::ngrids, mod_scalars::noerror, mod_scalars::nrun, mod_param::nstr, mod_scalars::ntend, mod_scalars::ntstart, so_semi_red(), so_semi_white(), mod_scalars::sorec, mod_iounits::stdout, mod_scalars::tdays, and mod_scalars::trnorm.

Here is the call graph for this function: