ROMS
Loading...
Searching...
No Matches
initial.F
Go to the documentation of this file.
1#include "cppdefs.h"
2 SUBROUTINE initial
3!
4!git $Id$
5!================================================== Hernan G. Arango ===
6! Copyright (c) 2002-2025 The ROMS Group !
7! Licensed under a MIT/X style license !
8! See License_ROMS.md !
9!=======================================================================
10! !
11! This routine initializes all model variables. !
12! !
13!=======================================================================
14!
15 USE mod_param
16 USE mod_parallel
17#ifdef BBL_MODEL
18 USE mod_bbl
19#endif
20#ifdef FOUR_DVAR
21 USE mod_fourdvar
22#endif
23 USE mod_grid
24 USE mod_iounits
25 USE mod_ncparam
26#ifdef NESTING
27 USE mod_nesting
28#endif
29 USE mod_ocean
30 USE mod_scalars
31 USE mod_stepping
32!
34 USE close_io_mod, ONLY : close_inp
35 USE dateclock_mod, ONLY : time_string
36#if defined FOUR_DVAR && !defined CORRELATION
37 USE def_ini_mod, ONLY : def_ini
38#endif
39#ifdef DISTRIBUTE
40 USE distribute_mod, ONLY : mp_bcasti
41#endif
42 USE get_state_mod, ONLY : get_state
43#ifdef WET_DRY
44 USE get_wetdry_mod, ONLY : get_wetdry
45#endif
46#ifdef TLM_CHECK
47 USE ini_adjust_mod, ONLY : ini_perturb
48#endif
49#if defined SOLVE3D && defined NONLINEAR
51#endif
53#if defined WAV_COUPLING && defined MCT_LIB
54 USE mct_coupler_mod, ONLY : ocn2wav_coupling
55#endif
56#ifdef NESTING
57 USE nesting_mod, ONLY : nesting
58#endif
59#ifdef SOLVE3D
61 USE omega_mod, ONLY : omega
62 USE rho_eos_mod, ONLY : rho_eos
64#endif
65#if defined OBSERVATIONS && !defined RBL4DVAR_FCT_SENSITIVITY
67#endif
68#ifdef MASKING
69 USE set_masks_mod, ONLY : set_masks
70#endif
71 USE stiffness_mod, ONLY : stiffness
72 USE strings_mod, ONLY : founderror
73#ifdef WET_DRY
74 USE wetdry_mod, ONLY : wetdry
75#endif
76#if defined PROPAGATOR || \
77 (defined masking && (defined read_water || defined write_water))
78 USE wpoints_mod, ONLY : wpoints
79#endif
80!
81 implicit none
82!
83! Local variable declarations.
84!
85 logical :: update = .false.
86!
87 integer :: Fcount
88 integer :: ng, thread, tile
89#ifdef NESTING
90 integer :: ig, nl
91 integer :: cr, i, m
92#endif
93
94 integer, dimension(Ngrids) :: IniRec, Tindex
95
96#if defined ADJUST_BOUNDARY || \
97 defined adjust_stflux || defined adjust_wstress
98 integer :: irec
99#endif
100!
101#ifdef SP4DVAR
102 real(dp) :: my_dstart
103!
104#endif
105!
106 character (len=*), parameter :: MyFile = &
107 & __FILE__
108!
109!=======================================================================
110! Initialize model variables.
111!=======================================================================
112!
113!$OMP MASTER
114 IF (master) THEN
115#if defined PERTURBATION
116 WRITE (stdout,10) nrun
117 10 FORMAT (/,' <<<< Ensemble/Perturbation Run: ',i5.5,' >>>>',/)
118#elif defined I4DVAR || defined RBL4DVAR || \
119 defined r4dvar || defined sensitivity_4dvar || \
120 defined tl_rbl4dvar || defined tl_r4dvar
121 WRITE (stdout,10) outer, inner
122 10 FORMAT (/,' <<<< 4D Variational Data Assimilation, ', &
123 & 'Outer = ',i3.3, ', Inner = ',i3.3,' >>>>',/)
124#endif
125 WRITE (stdout,20) 'INITIAL: Configuring and initializing ', &
126 & 'forward nonlinear model ...'
127 20 FORMAT (/,1x,a,a,/,1x,'*******')
128 END IF
129!$OMP END MASTER
130!
131!-----------------------------------------------------------------------
132! Initialize time stepping indices and counters.
133!-----------------------------------------------------------------------
134!
135 DO ng=1,ngrids
136 iif(ng)=1
137 indx1(ng)=1
138 next_kstp(ng)=1
139 kstp(ng)=1
140 krhs(ng)=1
141 knew(ng)=1
142 predictor_2d_step(ng)=.false.
143!
144 iic(ng)=0
145 nstp(ng)=1
146 nrhs(ng)=1
147 nnew(ng)=1
148#ifdef FLOATS
149 nf(ng)=0
150 nfp1(ng)=1
151 nfm1(ng)=4
152 nfm2(ng)=3
153 nfm3(ng)=2
154#endif
155!
156 inirec(ng)=nrrec(ng)
157 tindex(ng)=1
158!
159 synchro_flag(ng)=.true.
160 first_time(ng)=0
161#ifdef SP4DVAR
162 IF (initime(ng).lt.0.0_dp) THEN
163 my_dstart=dstart
164 ELSE
165 my_dstart=initime(ng)/86400.0_dp
166 END IF
167#else
168 tdays(ng)=dstart
169#endif
170 time(ng)=tdays(ng)*day2sec
171!$OMP MASTER
172 ntstart(ng)=int((time(ng)-dstart*day2sec)/dt(ng))+1
173 ntend(ng)=ntstart(ng)+ntimes(ng)-1
174 ntfirst(ng)=ntstart(ng)
175!$OMP END MASTER
176!$OMP BARRIER
177 step_counter(ng)=0
178 END DO
179!
180! Initialize global diagnostics variables.
181!
182 avgke=0.0_dp
183 avgpe=0.0_dp
184 avgkp=0.0_dp
185 volume=0.0_dp
186
187#ifdef PROFILE
188!
189!-----------------------------------------------------------------------
190! Start time wall clocks.
191!-----------------------------------------------------------------------
192!
193 DO ng=1,ngrids
194 DO thread=thread_range
195 CALL wclock_on (ng, inlm, 2, __line__, myfile)
196 END DO
197 END DO
198!$OMP BARRIER
199#endif
200
201#ifdef FOUR_DVAR
202!
203!-----------------------------------------------------------------------
204! If variational data assimilation, reset several IO switches and
205! variables.
206!-----------------------------------------------------------------------
207!
208! Set initial conditions record to process. If applicable open existing
209! nonlinear model initial conditions NetCDF file and, if needed, define
210! new variables. Then, inquire about available variables.
211!
212 DO ng=1,ngrids
213 IF (ldefini(ng)) THEN
214 ldefini(ng)=.false. ! needed to inquire variables IDs
215# ifndef CORRELATION
216 CALL def_ini (ng)
217# endif
218# ifdef DISTRIBUTE
219 CALL mp_bcasti (ng, inlm, exit_flag)
220# endif
221 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
222 inirec(ng)=nrrec(ng)
223 ini(ng)%Rindex=inirec(ng)
224 ELSE
225 inirec(ng)=ini(ng)%Rindex
226 END IF
227 END DO
228
229# ifdef ADJUST_BOUNDARY
230!
231! Initialize open boundary counter for storage arrays.
232!
233 DO ng=1,ngrids
234 obccount(ng)=0
235 END DO
236# endif
237# if defined ADJUST_STFLUX || defined ADJUST_WSTRESS
238!
239! Initialize surface forcing counter for storage arrays.
240!
241 DO ng=1,ngrids
242 sfcount(ng)=0
243 END DO
244# endif
245!
246! Reset nonlinear history time record counters. These counters are
247! reset on every iteration pass. This file is created on the first
248! iteration pass.
249!
250 DO ng=1,ngrids
251 his(ng)%Rindex=0
252 fcount=his(ng)%Fcount
253 his(ng)%Nrec(fcount)=0
254 END DO
255
256# ifdef I4DVAR
257!
258! Activate switches to writting data into average, history and
259! restart files.
260!
261 DO ng=1,ngrids
262 lwrtavg(ng)=.true.
263 lwrthis(ng)=.true.
264 lwrtrst(ng)=.true.
265 END DO
266# endif
267!$OMP BARRIER
268#endif
269!
270!-----------------------------------------------------------------------
271! Set application grid, metrics, and associated variables and
272! parameters.
273!-----------------------------------------------------------------------
274!
275 DO ng=1,ngrids
276 IF (setgridconfig(ng)) THEN
277 CALL set_grid (ng, inlm)
278 setgridconfig(ng)=.false.
279 END IF
280 END DO
281!
282!-----------------------------------------------------------------------
283! Initialize horizontal mixing coefficients. If applicable, scale
284! mixing coefficients according to the grid size (smallest area).
285#ifndef ANA_SPONGE
286! Also increase their values in sponge areas using the "visc_factor"
287! and/or "diff_factor" read from input Grid NetCDF file.
288#endif
289!-----------------------------------------------------------------------
290!
291 DO ng=1,ngrids
292 DO tile=first_tile(ng),last_tile(ng),+1
293 CALL ini_hmixcoef (ng, tile, inlm)
294 END DO
295!$OMP BARRIER
296 END DO
297
298#ifdef ANA_SPONGE
299!
300!-----------------------------------------------------------------------
301! Increase horizontal mixing coefficients in sponge areas using
302! analytical functions.
303!-----------------------------------------------------------------------
304!
305 DO ng=1,ngrids
306 IF (lsponge(ng)) THEN
307 DO tile=first_tile(ng),last_tile(ng),+1
308 CALL ana_sponge (ng, tile, inlm)
309 END DO
310!$OMP BARRIER
311 END IF
312 END DO
313#endif
314!
315!=======================================================================
316! Initialize model state variables and forcing. This part is
317! executed for each ensemble/perturbation/iteration run.
318!=======================================================================
319
320#ifdef TLM_CHECK
321!
322! Clear state variables.
323!
324 DO ng=1,ngrids
325 DO tile=first_tile(ng),last_tile(ng),+1
326 CALL initialize_ocean (ng, tile, inlm)
327 END DO
328!$OMP BARRIER
329 END DO
330#endif
331
332#if defined SOLVE3D && !defined INI_FILE
333!
334!-----------------------------------------------------------------------
335! If analytical initial conditions, compute initial time-evolving
336! depths with zero free-surface.
337!-----------------------------------------------------------------------
338!
339 DO ng=1,ngrids
340 DO tile=first_tile(ng),last_tile(ng),+1
341 CALL set_depth (ng, tile, inlm)
342 END DO
343!$OMP BARRIER
344 END DO
345#endif
346!
347!-----------------------------------------------------------------------
348! Set primitive variables initial conditions.
349!-----------------------------------------------------------------------
350
351#ifdef ANA_INITIAL
352!
353! Analytical initial conditions for momentum and active tracers.
354!
355 DO ng=1,ngrids
356 IF (nrrec(ng).eq.0) THEN
357 DO tile=first_tile(ng),last_tile(ng),+1
358 CALL ana_initial (ng, tile, inlm)
359 END DO
360!$OMP BARRIER
361 END IF
362 END DO
363#endif
364
365#if defined ANA_PASSIVE && defined SOLVE3D
366!
367! Analytical initial conditions for inert passive tracers.
368!
369 DO ng=1,ngrids
370 IF (nrrec(ng).eq.0) THEN
371 DO tile=first_tile(ng),last_tile(ng),+1
372 CALL ana_passive (ng, tile, inlm)
373 END DO
374!$OMP BARRIER
375 END IF
376 END DO
377#endif
378
379#if defined ANA_BIOLOGY && defined SOLVE3D
380!
381! Analytical initial conditions for biology tracers.
382!
383 DO ng=1,ngrids
384 IF (nrrec(ng).eq.0) THEN
385 DO tile=first_tile(ng),last_tile(ng),+1
386 CALL ana_biology (ng, tile, inlm)
387 END DO
388!$OMP BARRIER
389 END IF
390 END DO
391#endif
392
393#if defined ANA_SEDIMENT && defined SOLVE3D
394!
395! Analytical initial conditions for sediment tracers.
396!
397
398 DO ng=1,ngrids
399 IF (nrrec(ng).eq.0) THEN
400 DO tile=first_tile(ng),last_tile(ng),+1
401 CALL ana_sediment (ng, tile, inlm)
402 END DO
403!$OMP BARRIER
404 END IF
405 END DO
406#endif
407
408#if defined INI_FILE && !defined RBL4DVAR_FCT_SENSITIVITY
409!
410! Read in initial conditions from initial NetCDF file.
411!
412 DO ng=1,ngrids
413!$OMP MASTER
414 CALL get_state (ng, inlm, 1, ini(ng), inirec(ng), tindex(ng))
415!$OMP END MASTER
416# ifdef DISTRIBUTE
417 CALL mp_bcasti (ng, inlm, exit_flag)
418# endif
419!$OMP BARRIER
420 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
421 time(ng)=io_time ! needed for shared-memory
422 END DO
423#else
424!
425! If restart, read in initial conditions restart NetCDF file.
426!
427 DO ng=1,ngrids
428 IF (nrrec(ng).ne.0) THEN
429!$OMP MASTER
430 CALL get_state (ng, 0, 1, ini(ng), inirec(ng), tindex(ng))
431!$OMP END MASTER
432# ifdef DISTRIBUTE
433 CALL mp_bcasti (ng, inlm, exit_flag)
434# endif
435!$OMP BARRIER
436 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
437 time(ng)=io_time ! needed for shared-memory
438 END IF
439 END DO
440#endif
441
442#ifdef WET_DRY
443!
444!-----------------------------------------------------------------------
445! Process initial wet/dry masks.
446!-----------------------------------------------------------------------
447!
448 DO ng=1,ngrids
449!
450! If restart, read in wet/dry masks.
451!
452 IF (nrrec(ng).ne.0) THEN
453!$OMP MASTER
454# ifdef DISTRIBUTE
455 CALL get_wetdry (ng, myrank, inlm, inirec(ng))
456# else
457 CALL get_wetdry (ng, -1, inlm, inirec(ng))
458# endif
459!$OMP END MASTER
460# ifdef DISTRIBUTE
461 CALL mp_bcasti (ng, inlm, exit_flag)
462# endif
463!$OMP BARRIER
464 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
465 ELSE
466 DO tile=first_tile(ng),last_tile(ng),+1
467 CALL wetdry (ng, tile, tindex(ng), .true.)
468 END DO
469!$OMP BARRIER
470 END IF
471 END DO
472#endif
473
474#if defined OBSERVATIONS && !defined RBL4DVAR_FCT_SENSITIVITY
475!
476!-----------------------------------------------------------------------
477! Open observations NetCDF file and initialize various variables
478! needed for processing the nonlinear state solution at observation
479! locations. Need to be done after processing initial conditions since
480! the correct initial time is needed to determine the first "ObsTime"
481! to process.
482!-----------------------------------------------------------------------
483!
484 DO ng=1,ngrids
485!$OMP MASTER
486 CALL obs_initial (ng, inlm, .false.)
487!$OMP END MASTER
488 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
489 END DO
490!$OMP BARRIER
491#endif
492
493#if (defined ADJUST_BOUNDARY || \
494 defined adjust_stflux || \
495 defined adjust_wstress) && \
496 (defined rbl4dvar || \
497 defined rbl4dvar_ana_sensitivity || \
498 defined rbl4dvar_fct_sensitivity || \
499 defined tl_rbl4dvar)
500!
501!-----------------------------------------------------------------------
502! Read in the surface forcing and or open boundary conditions
503! increments for RBL4D-Var from record IniRec of the NLM initial
504! NetCDF file.
505!-----------------------------------------------------------------------
506!
507 IF (nrun.gt.1) THEN
508 DO ng=1,ngrids
509!$OMP MASTER
510 CALL get_state (ng, 5, 5, ini(ng), inirec(ng), tindex(ng))
511!$OMP END MASTER
512# ifdef DISTRIBUTE
513 CALL mp_bcasti (ng, inlm, exit_flag)
514# endif
515!$OMP BARRIER
516 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
517 END DO
518 END IF
519#endif
520
521#ifdef TLM_CHECK
522!
523!-----------------------------------------------------------------------
524! Add a perturbation to nonlinear state variable according to the outer
525! loop iteration with the steepest descent direction of the gradient
526! (adjoint state).
527!-----------------------------------------------------------------------
528!
529 IF (outer.ge.1) THEN
530 DO ng=1,ngrids
531 DO tile=first_tile(ng),last_tile(ng),+1
532 CALL ini_perturb (ng, tile, lnew(ng), tindex(ng))
533 END DO
534!$OMP BARRIER
535 END DO
536 END IF
537#endif
538
539#ifdef SOLVE3D
540!
541!-----------------------------------------------------------------------
542! Compute time independent (Zt_avg1=0). Set Zt_avg1 to the initial
543! free-surface value (no lateral boundary conditions applied). Then,
544! set initial time dependent depths and level thicknesses.
545!-----------------------------------------------------------------------
546!
547 DO ng=1,ngrids
548 DO tile=first_tile(ng),last_tile(ng),+1
549 CALL set_depth0 (ng, tile, inlm)
550 CALL set_zeta_timeavg (ng, tile, inlm)
551 CALL set_depth (ng, tile, inlm)
552 END DO
553!$OMP BARRIER
554 END DO
555!
556!-----------------------------------------------------------------------
557! Compute initial horizontal mass fluxes, Hz*u/n and Hz*v/m.
558!-----------------------------------------------------------------------
559!
560 DO ng=1,ngrids
561 DO tile=first_tile(ng),last_tile(ng),+1
562 CALL set_massflux (ng, tile, inlm)
563 END DO
564!$OMP BARRIER
565 END DO
566!
567!-----------------------------------------------------------------------
568! Compute initial S-coordinates vertical velocity. Compute initial
569! density anomaly from potential temperature and salinity via equation
570! of state for seawater. Also compute other equation of state related
571! quatities.
572!-----------------------------------------------------------------------
573!
574 DO ng=1,ngrids
575 DO tile=first_tile(ng),last_tile(ng),+1
576 CALL omega (ng, tile, inlm)
577 CALL rho_eos (ng, tile, inlm)
578 END DO
579!$OMP BARRIER
580 END DO
581#endif
582
583#ifdef ANA_PSOURCE
584!
585!-----------------------------------------------------------------------
586! Set point Sources/Sinks position, direction, special flag, and mass
587! transport nondimensional shape profile with analytcal expressions.
588! Point sources are at U- and V-points. We need to get their positions
589! to process internal Land/Sea masking arrays during initialization.
590!-----------------------------------------------------------------------
591!
592 DO ng=1,ngrids
593 IF (luvsrc(ng).or.lwsrc(ng).or.any(ltracersrc(:,ng))) THEN
594 DO tile=first_tile(ng),last_tile(ng),+1
595 CALL ana_psource (ng, tile, inlm)
596 END DO
597 END IF
598!$OMP BARRIER
599 END DO
600#endif
601
602#if defined FOUR_DVAR || !defined TANGENT || !defined ADJOINT
603!
604!-----------------------------------------------------------------------
605! Read in initial forcing, climatology and assimilation data from
606! input NetCDF files. It loads the first relevant data record for
607! the time-interpolation between snapshots.
608!-----------------------------------------------------------------------
609
610# ifdef ADJUST_BOUNDARY
611!
612! If first pass of iteration loop, set time of open boundary
613! adjustment.
614!
615!$OMP MASTER
616 IF (nrun.eq.erstr) THEN
617 DO ng=1,ngrids
618 obc_time(1,ng)=time(ng)
619 DO irec=2,nbrec(ng)
620 obc_time(irec,ng)=obc_time(irec-1,ng)+nobc(ng)*dt(ng)
621 END DO
622 END DO
623 END IF
624!$OMP END MASTER
625!$OMP BARRIER
626# endif
627# if defined ADJUST_STFLUX || defined ADJUST_WSTRESS
628!
629! If first pass of iteration loop, set time of surface forcing
630! adjustment.
631!
632!$OMP MASTER
633 IF (nrun.eq.erstr) THEN
634 DO ng=1,ngrids
635 sf_time(1,ng)=time(ng)
636 DO irec=2,nfrec(ng)
637 sf_time(irec,ng)=sf_time(irec-1,ng)+nsff(ng)*dt(ng)
638 END DO
639 END DO
640 END IF
641!$OMP END MASTER
642!$OMP BARRIER
643# endif
644# if !defined CORRELATION
645!
646! If applicable, close all input boundary, climatology, and forcing
647! NetCDF files and set associated parameters to the closed state. This
648! step is essential in iterative algorithms that run the full TLM
649! repetitively. Then, Initialize several parameters in their file
650! structure, so the appropriate input single or multi-file is selected
651! during initialization/restart.
652!
653 DO ng=1,ngrids
654!$OMP MASTER
655 CALL close_inp (ng, inlm)
656 CALL check_multifile (ng, inlm)
657!$OMP END MASTER
658# ifdef DISTRIBUTE
659 CALL mp_bcasti (ng, inlm, exit_flag)
660# endif
661!$OMP BARRIER
662 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
663 END DO
664!
665! If applicable, read in input data.
666!
667 DO ng=1,ngrids
668!$OMP MASTER
669 CALL get_idata (ng)
670 CALL get_data (ng)
671!$OMP END MASTER
672# ifdef DISTRIBUTE
673 CALL mp_bcasti (ng, inlm, exit_flag)
674# endif
675!$OMP BARRIER
676 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
677 END DO
678# endif
679#endif
680
681#ifdef MASKING
682!
683!-----------------------------------------------------------------------
684! Set internal I/O mask arrays.
685!-----------------------------------------------------------------------
686!
687 DO ng=1,ngrids
688 DO tile=first_tile(ng),last_tile(ng),+1
689 CALL set_masks (ng, tile, inlm)
690 END DO
691!$OMP BARRIER
692 END DO
693#endif
694
695#if !defined CORRELATION
696# ifdef NESTING
697# if defined MASKING || defined WET_DRY
698!
699!-----------------------------------------------------------------------
700! If nesting and Land/Sea masking, scale horizontal interpolation
701! weights to account for land contact points.
702!-----------------------------------------------------------------------
703!
704 DO ng=1,ngrids
705 CALL nesting (ng, inlm, nmask)
706 END DO
707# endif
708!
709!-----------------------------------------------------------------------
710! If nesting, process state fields initial conditions in the contact
711! regions.
712!-----------------------------------------------------------------------
713!
714! Free-surface and 2D-momentum.
715!
716 DO nl=1,nestlayers
717 DO ig=1,gridsinlayer(nl)
718 ng=gridnumber(ig,nl)
719 IF (any(compositegrid(:,ng))) THEN
720 CALL nesting (ng, inlm, nfsic) ! free-surface
721# ifndef SOLVE3D
722 CALL nesting (ng, inlm, n2dic) ! 2d momentum
723# endif
724 END IF
725 END DO
726 END DO
727
728# ifdef SOLVE3D
729!
730! Determine vertical indices and vertical interpolation weights in
731! the contact zone using initial unperturbed depth arrays.
732!
733 DO ng=1,ngrids
734 CALL nesting (ng, inlm, nzwgt)
735 END DO
736!
737! 3D-momentum and tracers.
738!
739 DO nl=1,nestlayers
740 DO ig=1,gridsinlayer(nl)
741 ng=gridnumber(ig,nl)
742 IF (any(compositegrid(:,ng))) THEN
743 CALL nesting (ng, inlm, n3dic) ! 3D momentum
744 CALL nesting (ng, inlm, ntvic) ! Tracer variables
745 END IF
746 END DO
747 END DO
748# endif
749# endif
750#endif
751
752#if defined PROPAGATOR || \
753 (defined masking && (defined read_water || defined write_water ))
754!
755!-----------------------------------------------------------------------
756! Set variables associated with the processing water points and/or
757! size of packed state arrays.
758!-----------------------------------------------------------------------
759!
760 DO ng=1,ngrids
761 DO tile=first_tile(ng),last_tile(ng),+1
762 CALL wpoints (ng, tile, inlm)
763 END DO
764!$OMP BARRIER
765 END DO
766#endif
767
768#if defined NLM_OUTER || \
769 defined rbl4dvar || \
770 defined rbl4dvar_ana_sensitivity || \
771 defined rbl4dvar_fct_sensitivity || \
772 defined tl_rbl4dvar
773!
774!-----------------------------------------------------------------------
775! Read in convolved adjoint impulse forcing (first record) and its
776! application time.
777!-----------------------------------------------------------------------
778!
779 DO ng=1,ngrids
780 IF (sporadicimpulse(ng)) THEN
781 frcrec(ng)=1
782!$OMP MASTER
783 CALL get_state (ng, 7, 7, tlf(ng), frcrec(ng), 1)
784!$OMP END MASTER
785!$OMP BARRIER
786# ifdef DISTRIBUTE
787 CALL mp_bcasti (ng, itlm, exit_flag)
788# endif
789 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
790 END IF
791 END DO
792#endif
793
794#if defined ANA_DRAG && defined UV_DRAG_GRID
795!
796!-----------------------------------------------------------------------
797! Set analytical spatially varying bottom friction parameter.
798!-----------------------------------------------------------------------
799!
800 IF (nrun.eq.erstr) THEN
801 DO ng=1,ngrids
802 DO tile=first_tile(ng),last_tile(ng),+1
803 CALL ana_drag (ng, tile, inlm)
804 END DO
805!$OMP BARRIER
806 END DO
807 END IF
808#endif
809!
810!-----------------------------------------------------------------------
811! Compute grid stiffness.
812!-----------------------------------------------------------------------
813!
814 IF (lstiffness) THEN
815 lstiffness=.false.
816 DO ng=1,ngrids
817 DO tile=first_tile(ng),last_tile(ng),+1
818 CALL stiffness (ng, tile, inlm)
819 END DO
820!$OMP BARRIER
821 END DO
822 END IF
823
824#if defined FLOATS || defined STATIONS
825!
826!-----------------------------------------------------------------------
827! If applicable, convert initial locations to fractional grid
828! coordinates.
829!-----------------------------------------------------------------------
830!
831 DO ng=1,ngrids
832!$OMP MASTER
833 CALL grid_coords (ng, inlm)
834!$OMP END MASTER
835!$OMP BARRIER
836 END DO
837#endif
838
839# if defined WAV_COUPLING && defined MCT_LIB
840!
841!-----------------------------------------------------------------------
842! Read in initial forcing from coupled wave model.
843!-----------------------------------------------------------------------
844!
845 DO ng=1,ngrids
846 DO tile=first_tile(ng),last_tile(ng),+1
847 CALL ocn2wav_coupling (ng, tile)
848 END DO
849!$OMP BARRIER
850 IF (master) WRITE (stdout,'(/)')
851 END DO
852# endif
853!
854!-----------------------------------------------------------------------
855! Initialize time-stepping counter and date/time string. Save NLM
856! initial conditions time.
857!-----------------------------------------------------------------------
858!
859 DO ng=1,ngrids
860 initime(ng)=time(ng)
861 iic(ng)=ntstart(ng)
862 CALL time_string (time(ng), time_code(ng))
863 END DO
864
865#ifdef PROFILE
866!
867!-----------------------------------------------------------------------
868! Turn off initialization time wall clock.
869!-----------------------------------------------------------------------
870!
871 DO ng=1,ngrids
872 DO thread=thread_range
873 CALL wclock_off (ng, inlm, 2, __line__, myfile)
874 END DO
875!$OMP BARRIER
876 END DO
877#endif
878!
879 RETURN
880 END SUBROUTINE initial
subroutine check_multifile(ng, model)
subroutine get_data(ng)
Definition get_data.F:3
subroutine get_idata(ng)
Definition get_idata.F:3
subroutine grid_coords(ng, model)
Definition grid_coords.F:4
subroutine initial
Definition initial.F:3
subroutine ana_sediment(ng, tile, model)
Definition ana_sediment.h:3
subroutine ana_initial(ng, tile, model)
Definition ana_initial.h:3
subroutine ana_sponge(ng, tile, model)
Definition ana_hmixcoef.h:3
subroutine ana_drag(ng, tile, model)
Definition ana_drag.h:3
subroutine ana_psource(ng, tile, model)
Definition ana_psource.h:3
subroutine ana_biology(ng, tile, model)
Definition ana_biology.h:3
subroutine ana_passive(ng, tile, model)
Definition ana_passive.h:3
subroutine, public close_inp(ng, model)
Definition close_io.F:92
subroutine, public time_string(mytime, date_string)
Definition dateclock.F:1272
subroutine, public def_ini(ng)
Definition def_ini.F:41
subroutine, public get_state(ng, model, msg, s, inirec, tindex)
Definition get_state.F:90
subroutine, public get_wetdry(ng, tile, model, inirec)
Definition get_wetdry.F:45
subroutine, public ini_perturb(ng, tile, linp, lout)
subroutine, public set_zeta_timeavg(ng, tile, model)
Definition ini_fields.F:986
subroutine, public ini_hmixcoef(ng, tile, model)
type(t_io), dimension(:), allocatable his
type(t_io), dimension(:), allocatable tlf
type(t_io), dimension(:), allocatable ini
integer stdout
integer, parameter ntvic
Definition mod_nesting.F:85
integer, parameter nzwgt
Definition mod_nesting.F:89
integer, parameter nfsic
Definition mod_nesting.F:82
integer, parameter n3dic
Definition mod_nesting.F:84
integer, parameter nmask
Definition mod_nesting.F:78
integer, parameter n2dic
Definition mod_nesting.F:83
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 gridnumber
Definition mod_param.F:127
integer nestlayers
Definition mod_param.F:118
integer ngrids
Definition mod_param.F:113
integer, parameter itlm
Definition mod_param.F:663
integer, dimension(:), allocatable gridsinlayer
Definition mod_param.F:122
logical, dimension(:), allocatable luvsrc
real(dp), parameter day2sec
integer, dimension(:), allocatable obccount
integer, dimension(:), allocatable nrrec
logical, dimension(:,:), allocatable ltracersrc
integer, dimension(:), allocatable ntimes
integer, dimension(:), allocatable iic
real(dp), dimension(:), allocatable dt
integer, dimension(:), allocatable nobc
logical, dimension(:), allocatable lsponge
logical, dimension(:), allocatable setgridconfig
logical lstiffness
real(dp) avgke
real(dp) avgpe
integer, dimension(:), allocatable next_kstp
logical, dimension(:), allocatable synchro_flag
integer, dimension(:), allocatable frcrec
logical, dimension(:), allocatable predictor_2d_step
integer, dimension(:), allocatable nfrec
logical, dimension(:), allocatable ldefini
real(dp), dimension(:), allocatable tdays
logical, dimension(:), allocatable lwrtavg
real(dp) dstart
logical, dimension(:), allocatable lwsrc
integer, dimension(:), allocatable ntend
real(dp) volume
integer, dimension(:), allocatable first_time
character(len=22), dimension(:), allocatable time_code
integer exit_flag
integer, dimension(:), allocatable indx1
logical, dimension(:,:), allocatable compositegrid
integer, dimension(:), allocatable sfcount
real(dp), dimension(:,:), allocatable obc_time
logical, dimension(:), allocatable sporadicimpulse
integer erstr
real(dp) avgkp
logical, dimension(:), allocatable lwrthis
integer, dimension(:), allocatable ntfirst
logical, dimension(:), allocatable lwrtrst
real(dp), dimension(:), allocatable time
integer, dimension(:), allocatable nsff
integer, dimension(:), allocatable ntstart
integer nrun
integer, dimension(:), allocatable step_counter
real(dp), dimension(:,:), allocatable sf_time
integer, dimension(:), allocatable nbrec
integer inner
integer, dimension(:), allocatable iif
real(dp) io_time
real(dp), dimension(:), allocatable initime
integer noerror
integer outer
integer, dimension(:), allocatable nfm2
integer, dimension(:), allocatable kstp
integer, dimension(:), allocatable knew
integer, dimension(:), allocatable nfm1
integer, dimension(:), allocatable nrhs
integer, dimension(:), allocatable nf
integer, dimension(:), allocatable nfm3
integer, dimension(:), allocatable nnew
integer, dimension(:), allocatable nfp1
integer, dimension(:), allocatable lnew
integer, dimension(:), allocatable krhs
integer, dimension(:), allocatable nstp
subroutine, public nesting(ng, model, isection)
Definition nesting.F:140
subroutine, public obs_initial(ng, model, backward)
Definition obs_initial.F:41
subroutine, public omega(ng, tile, model)
Definition omega.F:42
subroutine, public rho_eos(ng, tile, model)
Definition rho_eos.F:48
subroutine, public set_depth(ng, tile, model)
Definition set_depth.F:34
subroutine, public set_depth0(ng, tile, model)
Definition set_depth.F:281
subroutine, public set_masks(ng, tile, model)
Definition set_masks.F:44
subroutine, public set_massflux(ng, tile, model)
subroutine, public stiffness(ng, tile, model)
Definition stiffness.F:32
logical function, public founderror(flag, noerr, line, routine)
Definition strings.F:52
subroutine wetdry(ng, tile, tindex, linitialize)
Definition wetdry.F:22
subroutine set_grid(ng, model)
Definition set_grid.F:3
recursive subroutine wclock_off(ng, model, region, line, routine)
Definition timers.F:148
recursive subroutine wclock_on(ng, model, region, line, routine)
Definition timers.F:3
subroutine wpoints(ng, tile, model)
Definition wpoints.F:40