63#if defined PIO_LIB && defined DISTRIBUTE
99#if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
122 logical,
intent(inout) :: first
124 integer,
intent(in),
optional :: mpiCOMM
128 logical :: allocate_vars = .true.
131 integer :: MyError, MySize
133 integer :: STDrec, Tindex
134 integer :: chunk_size, ng, thread
136 integer :: my_threadnum
139 character (len=*),
parameter :: MyFile = &
140 & __FILE__//
", ROMS_initialize"
148 IF (
PRESENT(mpicomm))
THEN
198#elif defined DISTRIBUTE
215 10
FORMAT (/,
' Process Information:',/)
219 DO thread=thread_range
232#if defined MCT_LIB && (defined ATM_COUPLING || defined WAV_COUPLING)
240 CALL initialize_ocn2atm_coupling (ng,
myrank)
243 CALL initialize_ocn2wav_coupling (ng,
myrank)
248#if !defined RECOMPUTE_4DVAR
258 SELECT CASE (
lcz(ng)%IOtype)
289 &
'TLmodVal_S', tlmodval_s, &
290 & broadcast = .false.)
293# if defined PIO_LIB && defined DISTRIBUTE
324 &
'TLmodVal_S', tlmodval_s)
357#ifdef ADJUST_BOUNDARY
368#if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
394 real(dp),
intent(in) :: RunInterval
398 logical :: Lcgini, Linner, Lposterior
400 integer :: my_inner, my_outer
401 integer :: Lbck, Lini, Rec, Rec1, Rec2
402 integer :: i, lstr, ng, status, tile
403 integer :: Fcount, NRMrec
405 integer,
dimension(Ngrids) :: Nrec
407 real(r8) :: str_day, end_day
409 character (len=14) :: driver
410 character (len=20) :: string
412 character (len=*),
parameter :: MyFile = &
413 & __FILE__//
", ROMS_run"
422#if defined ADJUST_STFLUX || defined ADJUST_WSTRESS
426#ifdef ADJUST_BOUNDARY
442 driver=
'obs_sen_w4dvar'
474 ini(ng)%Nrec(fcount)=1
490 lstr=len_trim(
his(ng)%name)
491 his(ng)%base=
his(ng)%name(1:lstr-3)
513#ifdef ADJUST_BOUNDARY
518#if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
538#ifdef ADJUST_BOUNDARY
543#if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
550#if !defined RECOMPUTE_4DVAR && defined BALANCE_OPERATOR && \
551 defined zeta_elliptic
599 SELECT CASE (
dav(ng)%IOtype)
604 & ncid =
dav(ng)%ncid)
606#if defined PIO_LIB && defined DISTRIBUTE
611 & piofile =
dav(ng)%pioFile)
665#ifdef RECOMPUTE_4DVAR
701 outer_loop :
DO my_outer=1,1
716 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
717 lstr=len_trim(
fwd(ng)%name)
718 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
745 lstr=len_trim(
tlm(ng)%name)
746 tlm(ng)%base=
tlm(ng)%name(1:lstr-3)
758# ifndef DATALESS_LOOPS
796 IF (
fourdvar(ng)%DataPenalty(i).ne.0.0_r8)
THEN
807 SELECT CASE (
dav(ng)%IOtype)
810 &
'RP_iDataPenalty', &
814 & ncid =
dav(ng)%ncid)
815# if defined PIO_LIB && defined DISTRIBUTE
818 &
'RP_iDataPenalty', &
822 & piofile =
dav(ng)%pioFile)
848# ifdef ADJUST_BOUNDARY
854# if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
873 inner_loop :
DO my_inner=0,
ninner
897 inner_compute :
IF (linner)
THEN
910 & __line__, myfile))
RETURN
914# ifdef RPM_RELAXATION
931 adm(ng)%Nrec(fcount)=0
961 & __line__, myfile))
RETURN
975 & __line__, myfile))
RETURN
983 & rec1, rec2, lposterior)
1000 CALL wrt_impulse (ng, -1,
iadm,
adm(ng)%name)
1004 & __line__, myfile))
RETURN
1022 IF (
frcrec(ng).gt.3)
THEN
1033 & __line__, myfile))
RETURN
1052 tlm(ng)%Nrec(fcount)=0
1088 & __line__, myfile))
RETURN
1091 END IF inner_compute
1119# ifdef RPM_RELAXATION
1136 adm(ng)%Nrec(fcount)=0
1187 & rec1, rec2, lposterior)
1204 CALL wrt_impulse (ng, -1,
iadm,
adm(ng)%name)
1209# endif /* !DATALESS_LOOPS */
1226 lstr=len_trim(
tlm(ng)%name)
1227 tlm(ng)%base=
tlm(ng)%name(1:lstr-3)
1234 IF (
frcrec(ng).gt.3)
THEN
1242# ifdef DATALESS_LOOPS
1286 IF (
fourdvar(ng)%DataPenalty(i).ne.0.0_r8)
THEN
1290# ifdef DATALESS_LOOPS
1304 SELECT CASE (
dav(ng)%IOtype)
1307 &
'RP_fDataPenalty', &
1311 & ncid =
dav(ng)%ncid)
1313# if defined PIO_LIB && defined DISTRIBUTE
1316 &
'RP_fDataPenalty', &
1320 & piofile =
dav(ng)%pioFile)
1330# ifdef DATALESS_LOOPS
1345#if defined PIO_LIB && defined DISTRIBUTE
1347 his(ng)%pioFile%fh=-1
1354#endif /* RECOMPUTE_4DVAR */
1375 IF ((
dstrs(ng).eq.0.0_r8).and.(
dends(ng).eq.0.0_r8))
THEN
1389 ad_outer_loop :
DO my_outer=1,1,-1
1401 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
1402 lstr=len_trim(
fwd(ng)%name)
1403 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
1426 adm(ng)%Nrec(fcount)=0
1479 & rec1, rec2, lposterior)
1522#ifdef ADJUST_BOUNDARY
1531 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
1532 lstr=len_trim(
fwd(ng)%name)
1533 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
1540 IF (
frcrec(ng).gt.3)
THEN
1553#ifdef RPM_RELAXATION
1596 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
1597 lstr=len_trim(
fwd(ng)%name)
1598 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
1609# ifdef ADJUST_BOUNDARY
1615 ad_inner_loop :
DO my_inner=
ninner,1,-1
1640# ifdef RPM_RELAXATION
1657 adm(ng)%Nrec(fcount)=0
1707 & rec1, rec2, lposterior)
1739 tlm(ng)%name=trim(
tlm(ng)%base)//
'.nc'
1748 IF (
frcrec(ng).gt.3)
THEN
1761# ifdef RPM_RELAXATION
1786 tlm(ng)%Nrec(fcount)=0
1812 END DO ad_inner_loop
1822#endif /* !OBS_IMPACT */
1828 IF (
outer.eq.1)
THEN
1831 SELECT CASE (
dav(ng)%IOtype)
1835 & (/1/), (/
mobs/), &
1836 & ncid =
dav(ng)%ncid)
1838 & __line__, myfile))
RETURN
1842 & __line__, myfile))
RETURN
1844# if defined PIO_LIB && defined DISTRIBUTE
1848 & (/1/), (/
mobs/), &
1849 & piofile =
dav(ng)%pioFile)
1851 & __line__, myfile))
RETURN
1856 & __line__, myfile))
RETURN
1865 IF (
outer.eq.1)
THEN
1868 SELECT CASE (
dav(ng)%IOtype)
1872 & (/1/), (/
mobs/), &
1873 & ncid =
dav(ng)%ncid)
1875 & __line__, myfile))
RETURN
1879 & __line__, myfile))
RETURN
1881# if defined PIO_LIB && defined DISTRIBUTE
1885 & (/1/), (/
mobs/), &
1886 & piofile =
dav(ng)%pioFile)
1888 & __line__, myfile))
RETURN
1893 & __line__, myfile))
RETURN
1908#if defined OBS_IMPACT && defined OBS_IMPACT_SPLIT
1930# ifdef ADJUST_BOUNDARY
1939 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
1940 lstr=len_trim(
fwd(ng)%name)
1941 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
1948 IF (
frcrec(ng).gt.3)
THEN
1967# ifdef ADJUST_BOUNDARY
1973# ifdef RPM_RELAXATION
2012 IF (
outer.eq.1)
THEN
2015 SELECT CASE (
dav(ng)%IOtype)
2019 & (/1/), (/
mobs/), &
2020 & ncid =
dav(ng)%ncid)
2022 & __line__, myfile))
RETURN
2026 & __line__, myfile))
RETURN
2028# if defined PIO_LIB && defined DISTRIBUTE
2032 & (/1/), (/
mobs/), &
2033 & piofile =
dav(ng)%pioFile)
2035 & __line__, myfile))
RETURN
2040 & __line__, myfile))
RETURN
2046# if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
2068# ifdef ADJUST_BOUNDARY
2077 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
2078 lstr=len_trim(
fwd(ng)%name)
2079 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
2086 IF (
frcrec(ng).gt.3)
THEN
2105# ifdef ADJUST_BOUNDARY
2111# ifdef RPM_RELAXATION
2150 IF (
outer.eq.1)
THEN
2153 SELECT CASE (
dav(ng)%IOtype)
2157 & (/1/), (/
mobs/), &
2158 & ncid =
dav(ng)%ncid)
2160 & __line__, myfile))
RETURN
2164 & __line__, myfile))
RETURN
2166# if defined PIO_LIB && defined DISTRIBUTE
2170 & (/1/), (/
mobs/), &
2171 & piofile =
dav(ng)%pioFile)
2173 & __line__, myfile))
RETURN
2178 & __line__, myfile))
RETURN
2185# if defined ADJUST_BOUNDARY
2207# ifdef ADJUST_BOUNDARY
2216 WRITE (
fwd(ng)%name,10) trim(
fwd(ng)%head),
outer-1
2217 lstr=len_trim(
fwd(ng)%name)
2218 fwd(ng)%base=
fwd(ng)%name(1:lstr-3)
2225 IF (
frcrec(ng).gt.3)
THEN
2248# ifdef RPM_RELAXATION
2287 IF (
outer.eq.1)
THEN
2290 SELECT CASE (
dav(ng)%IOtype)
2294 & (/1/), (/
mobs/), &
2295 & ncid =
dav(ng)%ncid)
2297 & __line__, myfile))
RETURN
2301 & __line__, myfile))
RETURN
2303# if defined PIO_LIB && defined DISTRIBUTE
2307 & (/1/), (/
mobs/), &
2308 & piofile =
dav(ng)%pioFile)
2310 & __line__, myfile))
RETURN
2315 & __line__, myfile))
RETURN
2321#endif /* OBS_IMPACT_SPLIT */
2332#if defined PIO_LIB && defined DISTRIBUTE
2334 his(ng)%pioFile%fh=-1
2339 END DO ad_outer_loop
2341 10
FORMAT (a,
'_outer',i0,
'.nc')
2342 20
FORMAT (/,1x,a,1x,
'ROMS: started time-stepping:', &
2343 &
' (Grid: ',i2.2,
' TimeSteps: ',i8.8,
' - ',i8.8,
')',/)
2344 30
FORMAT (
' (',i3.3,
',',i3.3,
'): ',a,
' data penalty, Jdata = ', &
2345 & 1p,e17.10,0p,t68,a)
2346 40
FORMAT (/,
' Converting Convolved Adjoint Trajectory to', &
2347 &
' Impulses: Outer = ',i3.3,
' Inner = ',i3.3,/)
2348 50
FORMAT (/,
'ROMS: Started adjoint Sensitivity calculation', &
2350 60
FORMAT (/,
'ROMS: ',a,1x,a,
', Outer = ',i3.3, &
2351 &
' Inner = ',i3.3,/)
2352 70
FORMAT (/,1x,a,1x,
'ROMS: adjoint forcing time range: ', &
2353 & f12.4,
' - ',f12.4 ,/)
2375 integer :: Fcount, ng, thread
2377 character (len=*),
parameter :: MyFile = &
2378 & __FILE__//
", ROMS_finalize"
2402 10
FORMAT (/,
' Blowing-up: Saving latest model state into ', &
2403 &
' RESTART file',/)
2405 IF (
lcyclerst(ng).and.(
rst(ng)%Nrec(fcount).ge.2))
THEN
2429 20
FORMAT (/,
'Elapsed wall CPU time for each process (seconds):',/)
2433 DO thread=thread_range
subroutine ad_initial(ng)
subroutine ad_main3d(runinterval)
subroutine edit_multifile(task)
subroutine main3d(runinterval)
subroutine, public ad_wrt_his(ng, tile)
subroutine, public close_out
subroutine, public close_file(ng, model, s, ncname, lupdate)
subroutine, public close_inp(ng, model)
subroutine, public congrad(ng, model, outloop, innloop, ninnloop, lcgini)
subroutine, public error_covariance(model, driver, outloop, innloop, rbck, rini, rold, rnew, rec1, rec2, lposterior)
subroutine, public def_impulse(ng)
subroutine, public def_mod(ng)
subroutine, public def_norm(ng, model, ifile)
subroutine, public get_state(ng, model, msg, s, inirec, tindex)
subroutine, public inp_par(model)
subroutine, public roms_initialize_arrays
subroutine, public roms_allocate_arrays(allocate_vars)
subroutine, public initialize_boundary(ng, tile, model)
subroutine, public initialize_forces(ng, tile, model)
real(dp), dimension(:), allocatable cg_gnorm_v
type(t_fourdvar), dimension(:), allocatable fourdvar
real(dp), dimension(:,:), allocatable cg_beta
real(r8), dimension(:,:), allocatable cg_dla
real(dp), dimension(:,:), allocatable cg_qg
logical, dimension(:), allocatable wrtmisfit
logical, dimension(:), allocatable wrtrpmod
logical, dimension(:), allocatable lsen4dvar
real(r8), dimension(:,:), allocatable ad_obsval
logical, dimension(:), allocatable wrttlmod
logical, dimension(:), allocatable wrtnlmod
logical, dimension(:), allocatable wrtforce
real(r8), dimension(:,:,:), allocatable zcglwk
logical, dimension(:), allocatable wrtobsscale
real(dp), dimension(:,:), allocatable cg_delta
logical, dimension(:), allocatable lweakrelax
logical, dimension(:), allocatable wrtzetaref
integer, dimension(:), allocatable nstatevar
real(r8), dimension(:,:), allocatable zgrad0
type(t_io), dimension(:), allocatable lcz
type(t_io), dimension(:,:), allocatable std
type(t_io), dimension(:), allocatable his
type(t_io), dimension(:,:), allocatable nrm
type(t_io), dimension(:), allocatable adm
type(t_io), dimension(:), allocatable irp
type(t_io), dimension(:), allocatable tlf
type(t_io), dimension(:), allocatable tlm
type(t_io), dimension(:), allocatable itl
type(t_io), dimension(:), allocatable dav
type(t_io), dimension(:), allocatable fwd
type(t_io), dimension(:), allocatable rst
type(t_io), dimension(:), allocatable ini
character(len=256) sourcefile
integer, parameter io_nf90
integer, parameter io_pio
integer, dimension(:), allocatable ideftlm
character(len=maxlen), dimension(6, 0:nv) vname
integer, dimension(:), allocatable idsvar
subroutine, public netcdf_sync(ng, model, ncname, ncid)
subroutine, public initialize_ocean(ng, tile, model)
subroutine, public initialize_parallel
integer, dimension(:), allocatable first_tile
integer, dimension(:), allocatable last_tile
integer, dimension(:), allocatable ntilex
integer, dimension(:), allocatable ntilee
subroutine, public pio_netcdf_sync(ng, model, ncname, piofile)
logical, dimension(:,:), allocatable lwrtnrm
logical, dimension(:), allocatable lreadqck
integer, dimension(:), allocatable ntimes
logical, dimension(:), allocatable ldefitl
real(dp), dimension(:), allocatable dt
logical, dimension(:), allocatable balance
logical, dimension(:), allocatable ldeftlf
integer, dimension(:), allocatable frcrec
logical, dimension(:), allocatable lreadfrc
real(dp), dimension(:), allocatable tdays
real(r8), dimension(:), allocatable dends
logical, dimension(:), allocatable ldefadj
logical, dimension(:), allocatable frequentimpulse
logical, dimension(:), allocatable ldefhis
real(dp), parameter sec2day
integer, dimension(:), allocatable ntend
logical, dimension(:), allocatable ldefmod
logical, dimension(:,:), allocatable ldefnrm
logical, dimension(:), allocatable sporadicimpulse
real(r8), dimension(:), allocatable dstrs
logical, dimension(:), allocatable lwrthis
logical, dimension(:), allocatable lwrttlm
logical, dimension(:), allocatable lwrtrst
logical, dimension(:), allocatable ldeftlm
integer, dimension(:), allocatable ntstart
logical, dimension(:), allocatable lreadfwd
logical, dimension(:), allocatable lcyclerst
logical, dimension(:), allocatable lreadblk
integer, dimension(:), allocatable lold
integer, dimension(:), allocatable lbout
integer, dimension(:), allocatable lfinp
integer, dimension(:), allocatable lbinp
integer, dimension(:), allocatable lnew
integer, dimension(:), allocatable lfout
subroutine, public normalization(ng, tile, ifac)
subroutine, public roms_finalize
subroutine, public roms_run(runinterval)
subroutine, public roms_initialize(first, mpicomm)
subroutine, public stats_modobs(ng, tile)
integer function, public stdout_unit(mymaster)
logical, save set_stdoutunit
character(len(sinp)) function, public uppercase(sinp)
logical function, public founderror(flag, noerr, line, routine)
subroutine, public tl_def_ini(ng)
subroutine, public wrt_ini(ng, tile, tindex, outrec)
subroutine, public wrt_rst(ng, tile)
subroutine, public biconj(ng, tile, model, lbck)
subroutine, public balance_ref(ng, tile, lbck)
subroutine rep_matrix(ng, model, outloop, ninnloop)
subroutine rp_initial(ng)
subroutine rp_main3d(runinterval)
recursive subroutine wclock_off(ng, model, region, line, routine)
recursive subroutine wclock_on(ng, model, region, line, routine)
subroutine tl_initial(ng)
subroutine tl_main3d(runinterval)