3#if (defined TANGENT || defined TL_IOMS) && defined FOUR_DVAR
30# ifdef ADJUST_BOUNDARY
33# if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
42# if defined SEDIMENT_NOT_YET || defined BBL_MODEL_NOT_YET
51# ifdef ADJUST_BOUNDARY
56# ifdef ADJUST_BOUNDARY
66# if defined PIO_LIB && defined DISTRIBUTE
78 integer,
intent(in) :: ng, tile, tindex, outrec
82# ifdef ADJUST_BOUNDARY
85 integer :: lbi, ubi, lbj, ubj
87 character (len=*),
parameter :: myfile = &
94# ifdef ADJUST_BOUNDARY
103 SELECT CASE (
itl(ng)%IOtype)
106# ifdef ADJUST_BOUNDARY
109 & lbi, ubi, lbj, ubj)
111# if defined PIO_LIB && defined DISTRIBUTE
114# ifdef ADJUST_BOUNDARY
117 & lbi, ubi, lbj, ubj)
125 10
FORMAT (
' TL_WRT_INI - Illegal output file type, io_type = ',i0, &
126 & /,14x,
'Check KeyWord ''OUT_LIB'' in ''roms.in''.')
133# ifdef ADJUST_BOUNDARY
136 & LBi, UBi, LBj, UBj)
143 integer,
intent(in) :: ng, tile, tindex, outrec
144# ifdef ADJUST_BOUNDARY
145 integer,
intent(in) :: lbij, ubij
147 integer,
intent(in) :: lbi, ubi, lbj, ubj
151 integer :: gfactor, gtype, i, itrc, status, varid
153 real(dp) :: my_time, scale
156 character (len=35) :: string
157# elif defined SP4DVAR
158 character (len=31) :: string
160 character (len=15) :: string
162 character (len=*),
parameter :: myfile = &
163 & __FILE__//
", tl_wrt_ini_nf90"
177 IF (outrec.eq.1)
THEN
178 string=
'inner-loop initial fields '
179 ELSE IF (outrec.eq.2)
THEN
180 string=
'final outer-loop increments '
181 ELSE IF (outrec.eq.3)
THEN
182 string=
'sum of final outer-loop increments '
183 ELSE IF (outrec.eq.4)
THEN
184 string=
'sum of adjoint solutions '
185 ELSE IF (outrec.eq.5)
THEN
186 string=
'augmented correction term '
188# elif defined SP4DVAR
189 IF (outrec.eq.1)
THEN
190 string=
'TLM initial fields '
191 ELSE IF ((2.le.outrec).and.(outrec.le.
nsaddle+1))
THEN
192 string=
'TLM saddle-point starting field'
194 string=
'ADM saddle-point starting field'
197 IF (outrec.eq.1)
THEN
198 string=
'initial fields'
199 ELSE IF (outrec.eq.2)
THEN
200 string=
'v-increments '
201 ELSE IF (outrec.eq.3)
THEN
202 string=
'v-increments '
203 ELSE IF (outrec.eq.4)
THEN
204 string=
'v-summations '
205 ELSE IF (outrec.eq.5)
THEN
206 string=
'x-increments '
219# if defined WRITE_WATER && defined MASKING
232 & (/outrec/), (/1/), &
233 & ncid =
itl(ng)%ncid, &
244 & lbi, ubi, lbj, ubj, scale, &
246 &
grid(ng) % rmask, &
249 &
ocean(ng) % tl_zeta(:,:,tindex), &
250 & setfillval = .false.)
252 &
ocean(ng) % tl_zeta(:,:,tindex))
254 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
263# ifdef ADJUST_BOUNDARY
273 & lbij, ubij,
nbrec(ng), scale, &
274 &
boundary(ng) % tl_zeta_obc(lbij:,:,:, &
276 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
294 & lbi, ubi, lbj, ubj, scale, &
296 &
grid(ng) % umask_full, &
298 &
ocean(ng) % tl_ubar(:,:,tindex))
299 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
308# ifdef ADJUST_BOUNDARY
318 & lbij, ubij,
nbrec(ng), scale, &
319 &
boundary(ng) % tl_ubar_obc(lbij:,:,:, &
321 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
339 & lbi, ubi, lbj, ubj, scale, &
341 &
grid(ng) % vmask_full, &
343 &
ocean(ng) % tl_vbar(:,:,tindex))
344 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
353# ifdef ADJUST_BOUNDARY
363 & lbij, ubij,
nbrec(ng), scale, &
364 &
boundary(ng) % tl_vbar_obc(lbij:,:,:, &
366 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
376# ifdef ADJUST_WSTRESS
387 & lbi, ubi, lbj, ubj, 1,
nfrec(ng), scale, &
389 &
grid(ng) % umask, &
391 &
forces(ng) % tl_ustr(:,:,:,tindex))
392 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
408 & lbi, ubi, lbj, ubj, 1,
nfrec(ng), scale, &
410 &
grid(ng) % vmask, &
412 &
forces(ng) % tl_vstr(:,:,:,tindex))
413 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
431 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
433 &
grid(ng) % umask_full, &
435 &
ocean(ng) % tl_u(:,:,:,tindex))
436 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
445# ifdef ADJUST_BOUNDARY
455 & lbij, ubij, 1,
n(ng),
nbrec(ng), scale, &
456 &
boundary(ng) % tl_u_obc(lbij:,:,:,:, &
458 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
476 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
478 &
grid(ng) % vmask_full, &
480 &
ocean(ng) % tl_v(:,:,:,tindex))
481 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
490# ifdef ADJUST_BOUNDARY
500 & lbij, ubij, 1,
n(ng),
nbrec(ng), scale, &
501 &
boundary(ng) % tl_v_obc(lbij:,:,:,:, &
503 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
520 &
itl(ng)%Tid(itrc), &
522 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
524 &
grid(ng) % rmask, &
526 &
ocean(ng) % tl_t(:,:,:,tindex,itrc))
527 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
537# ifdef ADJUST_BOUNDARY
548 & lbij, ubij, 1,
n(ng),
nbrec(ng), &
550 &
boundary(ng) % tl_t_obc(lbij:,:,:,:, &
552 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
577 & lbi, ubi, lbj, ubj, 1,
nfrec(ng), scale, &
579 &
grid(ng) % rmask, &
581 &
forces(ng) % tl_tflux(:,:,:,tindex,itrc))
582 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
596# if defined I4DVAR || defined BACKGROUND
610 &
'TLcost_function', &
613 & ncid =
dav(ng)%ncid)
628 & ncid =
dav(ng)%ncid)
643 & ncid =
dav(ng)%ncid)
657# if defined I4DVAR || defined BACKGROUND
66210
FORMAT (2x,
'TL_WRT_INI_NF90 - writing ',a, &
663 &
' (Outer=',i2.2,
', Inner=',i3.3,
', Index=',i0, &
665 &
',',i0,
', Rec=',i0,
')')
669 20
FORMAT (/,
' TL_WRT_INI_NF90 - error while writing variable: ',a, &
670 & /,14x,
'into tangent initial file for time record: ',i0)
675# if defined PIO_LIB && defined DISTRIBUTE
679# ifdef ADJUST_BOUNDARY
682 & LBi, UBi, LBj, UBj)
689 integer,
intent(in) :: ng, tile, tindex, outrec
690# ifdef ADJUST_BOUNDARY
691 integer,
intent(in) :: lbij, ubij
693 integer,
intent(in) :: lbi, ubi, lbj, ubj
697 integer :: i, ifield, itrc, status
699 real(dp) :: my_time, scale
702 character (len=35) :: string
703# elif defined SP4DVAR
704 character (len=31) :: string
706 character (len=15) :: string
708 character (len=*),
parameter :: myfile = &
709 & __FILE__//
", tl_wrt_ini_pio"
711 TYPE (io_desc_t),
pointer :: iodesc
725 IF (outrec.eq.1)
THEN
726 string=
'inner-loop initial fields '
727 ELSE IF (outrec.eq.2)
THEN
728 string=
'final outer-loop increments '
729 ELSE IF (outrec.eq.3)
THEN
730 string=
'sum of final outer-loop increments '
731 ELSE IF (outrec.eq.4)
THEN
732 string=
'sum of adjoint solutions '
733 ELSE IF (outrec.eq.5)
THEN
734 string=
'augmented correction term '
736# elif defined SP4DVAR
737 IF (outrec.eq.1)
THEN
738 string=
'TLM initial fields '
739 ELSE IF ((2.le.outrec).and.(outrec.le.
nsaddle+1))
THEN
740 string=
'TLM saddle-point starting field'
742 string=
'ADM saddle-point starting field'
745 IF (outrec.eq.1)
THEN
746 string=
'initial fields'
747 ELSE IF (outrec.eq.2)
THEN
748 string=
'v-increments '
749 ELSE IF (outrec.eq.3)
THEN
750 string=
'v-increments '
751 ELSE IF (outrec.eq.4)
THEN
752 string=
'v-summations '
753 ELSE IF (outrec.eq.5)
THEN
754 string=
'x-increments '
771 & (/outrec/), (/1/), &
772 & piofile =
itl(ng)%pioFile, &
779 IF (
itl(ng)%pioVar(
idfsur)%dkind.eq.pio_double)
THEN
788 & lbi, ubi, lbj, ubj, scale, &
790 &
grid(ng) % rmask, &
793 &
ocean(ng) % tl_zeta(:,:,tindex), &
794 & setfillval = .false.)
796 &
ocean(ng) % tl_zeta(:,:,tindex))
798 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
807# ifdef ADJUST_BOUNDARY
824 & lbij, ubij,
nbrec(ng), scale, &
825 &
boundary(ng) % tl_zeta_obc(lbij:,:,:, &
827 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
841 IF (
itl(ng)%pioVar(
idubar)%dkind.eq.pio_double)
THEN
850 & lbi, ubi, lbj, ubj, scale, &
852 &
grid(ng) % umask_full, &
854 &
ocean(ng) % tl_ubar(:,:,tindex))
855 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
864# ifdef ADJUST_BOUNDARY
881 & lbij, ubij,
nbrec(ng), scale, &
882 &
boundary(ng) % tl_ubar_obc(lbij:,:,:, &
884 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
898 IF (
itl(ng)%pioVar(
idvbar)%dkind.eq.pio_double)
THEN
907 & lbi, ubi, lbj, ubj, scale, &
909 &
grid(ng) % vmask_full, &
911 &
ocean(ng) % tl_vbar(:,:,tindex))
912 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
921# ifdef ADJUST_BOUNDARY
938 & lbij, ubij,
nbrec(ng), scale, &
939 &
boundary(ng) % tl_vbar_obc(lbij:,:,:, &
941 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
951# ifdef ADJUST_WSTRESS
958 IF (
itl(ng)%pioVar(
idusms)%dkind.eq.pio_double)
THEN
967 & lbi, ubi, lbj, ubj, 1,
nfrec(ng), scale, &
969 &
grid(ng) % umask, &
971 &
forces(ng) % tl_ustr(:,:,:,tindex))
972 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
984 IF (
itl(ng)%pioVar(
idvsms)%dkind.eq.pio_double)
THEN
993 & lbi, ubi, lbj, ubj, 1,
nfrec(ng), scale, &
995 &
grid(ng) % vmask, &
997 &
forces(ng) % tl_vstr(:,:,:,tindex))
998 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1012 IF (
itl(ng)%pioVar(
iduvel)%dkind.eq.pio_double)
THEN
1021 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1023 &
grid(ng) % umask_full, &
1025 &
ocean(ng) % tl_u(:,:,:,tindex))
1026 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1035# ifdef ADJUST_BOUNDARY
1048 &
itl(ng)%pioFile, &
1052 & lbij, ubij, 1,
n(ng),
nbrec(ng), scale, &
1053 &
boundary(ng) % tl_u_obc(lbij:,:,:,:, &
1055 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1069 IF (
itl(ng)%pioVar(
idvvel)%dkind.eq.pio_double)
THEN
1078 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1080 &
grid(ng) % vmask_full, &
1082 &
ocean(ng) % tl_v(:,:,:,tindex))
1083 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1092# ifdef ADJUST_BOUNDARY
1105 &
itl(ng)%pioFile, &
1109 & lbij, ubij, 1,
n(ng),
nbrec(ng), scale, &
1110 &
boundary(ng) % tl_v_obc(lbij:,:,:,:, &
1112 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1127 IF (
itl(ng)%pioTrc(itrc)%dkind.eq.pio_double)
THEN
1134 &
itl(ng)%pioTrc(itrc), &
1136 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1138 &
grid(ng) % rmask, &
1140 &
ocean(ng) % tl_t(:,:,:,tindex,itrc))
1141 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1151# ifdef ADJUST_BOUNDARY
1159 IF (
itl(ng)%pioVar(ifield)%dkind.eq.pio_double)
THEN
1166 &
itl(ng)%pioFile, &
1167 &
vname(1,ifield), &
1168 &
itl(ng)%pioVar(ifield), &
1170 & lbij, ubij, 1,
n(ng),
nbrec(ng), &
1172 &
boundary(ng) % tl_t_obc(lbij:,:,:,:, &
1174 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1185# ifdef ADJUST_STFLUX
1194 IF (
itl(ng)%pioVar(
idtsur(itrc))%dkind.eq.pio_double)
THEN
1203 & lbi, ubi, lbj, ubj, 1,
nfrec(ng), scale, &
1205 &
grid(ng) % rmask, &
1207 &
forces(ng) % tl_tflux(:,:,:,tindex,itrc))
1208 IF (
founderror(status, pio_noerr, __line__, myfile))
THEN
1222# if defined I4DVAR || defined BACKGROUND
1236 &
'TLcost_function', &
1238 & (/
nrun/), (/1/), &
1239 & piofile =
dav(ng)%pioFile)
1251 &
'back_function', &
1253 & (/
nrun/), (/1/), &
1254 & piofile =
dav(ng)%pioFile)
1268 & (/
nrun/), (/1/), &
1269 & piofile =
dav(ng)%pioFile)
1283# if defined I4DVAR || defined BACKGROUND
1288 10
FORMAT (2x,
'TL_WRT_INI_PIO - writing ',a, &
1289 &
' (Outer=',i2.2,
', Inner=',i3.3,
', Index=',i0, &
1291 &
',',i0,
', Rec=',i0,
')')
1295 20
FORMAT (/,
' TL_WRT_INI_PIO - error while writing variable: ',a, &
1296 & /,14x,
'into tangent initial file for time record: ',i0)
type(t_boundary), dimension(:), allocatable boundary
type(t_forces), dimension(:), allocatable forces
type(t_fourdvar), dimension(:), allocatable fourdvar
real(r8), dimension(:), allocatable optimality
type(t_grid), dimension(:), allocatable grid
type(t_io), dimension(:), allocatable itl
type(t_io), dimension(:), allocatable dav
character(len=256) sourcefile
integer, parameter io_nf90
integer, dimension(:), allocatable idsbry
integer, parameter io_pio
integer, dimension(:), allocatable idtsur
integer, dimension(:), allocatable idtvar
integer, dimension(:), allocatable istvar
character(len=maxlen), dimension(6, 0:nv) vname
subroutine, public netcdf_sync(ng, model, ncname, ncid)
type(t_ocean), dimension(:), allocatable ocean
integer, dimension(:), allocatable n
type(t_bounds), dimension(:), allocatable bounds
integer, parameter r3dvar
integer, parameter u3dvar
integer, parameter u2dvar
integer, dimension(:), allocatable nt
integer, parameter r2dvar
integer, parameter v2dvar
integer, parameter v3dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_v2dobc
type(io_desc_t), dimension(:), pointer iodesc_dp_r3dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_u3dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_v2dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_u2dfrc
type(io_desc_t), dimension(:), pointer iodesc_dp_v3dobc
subroutine, public pio_netcdf_sync(ng, model, ncname, piofile)
type(io_desc_t), dimension(:), pointer iodesc_sp_u2dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_u3dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_r3dobc
type(io_desc_t), dimension(:), pointer iodesc_dp_u3dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_u2dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_r2dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_r2dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_u3dobc
type(io_desc_t), dimension(:), pointer iodesc_dp_u2dfrc
type(io_desc_t), dimension(:), pointer iodesc_dp_r2dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_u2dobc
type(io_desc_t), dimension(:), pointer iodesc_dp_u2dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_v2dfrc
type(io_desc_t), dimension(:), pointer iodesc_dp_v3dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_v2dfrc
type(io_desc_t), dimension(:), pointer iodesc_dp_r2dfrc
type(io_desc_t), dimension(:), pointer iodesc_dp_v2dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_v3dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_r3dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_r2dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_r3dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_v3dobc
type(io_desc_t), dimension(:), pointer iodesc_sp_v2dvar
type(io_desc_t), dimension(:), pointer iodesc_sp_r2dfrc
real(dp), parameter day2sec
logical, dimension(:,:,:), allocatable lobc
logical, dimension(:,:), allocatable lstflux
integer, dimension(:), allocatable nfrec
real(dp), dimension(:), allocatable tdays
logical, dimension(:), allocatable lwrtcost
integer, dimension(:), allocatable nbrec
logical function, public founderror(flag, noerr, line, routine)
subroutine, public tl_wrt_ini(ng, tile, tindex, outrec)
subroutine, private tl_wrt_ini_pio(ng, tile, tindex, outrec, lbij, ubij, lbi, ubi, lbj, ubj)
subroutine, private tl_wrt_ini_nf90(ng, tile, tindex, outrec, lbij, ubij, lbi, ubi, lbj, ubj)