3#if (defined FOUR_DVAR || defined VERIFICATION) && defined OBSERVATIONS
38# if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
48# if defined PIO_LIB && defined DISTRIBUTE
60 integer,
intent(in) :: ng, tile, model
65 integer :: lbi, ubi, lbj, ubj
66 integer :: obssum, obsvoid
67 integer :: i, ie, is, iobs, itrc
69 character (len=50) :: string
70 character (len=*),
parameter :: myfile = &
85 & lbi, ubi, lbj, ubj, &
93 SELECT CASE (
dav(ng)%IOtype)
96 & lbi, ubi, lbj, ubj, &
99# if defined PIO_LIB && defined DISTRIBUTE
102 & lbi, ubi, lbj, ubj, &
169 IF (
fourdvar(ng)%ObsCount(i).gt.0)
THEN
172 & ie-is+1,
fourdvar(ng)%ObsReject(i)
174 obssum=obssum+
fourdvar(ng)%ObsCount(i)
175 obsvoid=obsvoid+
fourdvar(ng)%ObsReject(i)
178 WRITE (
stdout,30) obssum, obsvoid, &
184 string=
'Wrote NLM state at observation locations, '
186# ifdef WEAK_CONSTRAINT
188 string=
'Wrote TLM state at observation locations, '
190 string=
'Wrote RPM state at observation locations, '
192# ifdef I4DVAR_ANA_SENSITIVITY
194 string=
'Wrote 4DVAR observation sensitivity, '
197 string=
'Wrote TLM increments at observation locations, '
210 10
FORMAT (
' OBS_WRITE - Illegal output file type, io_type = ',i0, &
211 & /,13x,
'Check KeyWord ''OUT_LIB'' in ''roms.in''.')
212 20
FORMAT (10x,a,t25,4(1x,i10))
213 30
FORMAT (/,10x,
'Total',t47,2(1x,i10), &
214 & /,10x,
'Obs Tally',t47,2(1x,i10),/)
215 40
FORMAT (1x,a,
' datum = ',i0,
' - ',i0,/)
222 & LBi, UBi, LBj, UBj, &
228 integer,
intent(in) :: ng, tile, model
229 integer,
intent(in) :: lbi, ubi, lbj, ubj
231 integer,
intent(out) :: mstr, mend
235 integer :: i, ic, iobs, itrc
243 real(r8),
parameter :: inival = 0.0_r8
247 real(r8) :: df1, df2, thresh
252 real(r8) :: ubgerr(
mobs), vbgerr(
mobs)
255 character (len=*),
parameter :: myfile = &
256 & __FILE__//
", obs_operator"
258# include "set_bounds.h"
266# ifdef WEAK_CONSTRAINT
293# ifndef I4DVAR_ANA_SENSITIVITY
341# if defined TLM_OBS && !defined SP4DVAR
344 tlmodval(iobs)=inival
354# ifndef I4DVAR_ANA_SENSITIVITY
360 & lbi, ubi, lbj, ubj, &
362 &
mobs, mstr, mend, &
368 &
ocean(ng)%zeta(:,:,kout), &
379 & lbi, ubi, lbj, ubj, &
381 &
mobs, mstr, mend, &
387 &
ocean(ng)%e_zeta(:,:,1), &
403 & lbi, ubi, lbj, ubj, &
405 &
mobs, mstr, mend, &
411 &
ocean(ng)%tl_zeta(:,:,kout), &
423# ifndef I4DVAR_ANA_SENSITIVITY
429 & lbi, ubi, lbj, ubj, &
431 &
mobs, mstr, mend, &
437 &
ocean(ng)%ubar(:,:,kout), &
449 & lbi, ubi, lbj, ubj, &
451 &
mobs, mstr, mend, &
457 &
ocean(ng)%e_ubar(:,:,1), &
473 & lbi, ubi, lbj, ubj, &
475 &
mobs, mstr, mend, &
481 &
ocean(ng)%tl_ubar(:,:,kout), &
493# ifndef I4DVAR_ANA_SENSITIVITY
499 & lbi, ubi, lbj, ubj, &
501 &
mobs, mstr, mend, &
507 &
ocean(ng)%vbar(:,:,kout), &
519 & lbi, ubi, lbj, ubj, &
521 &
mobs, mstr, mend, &
527 &
ocean(ng)%e_vbar(:,:,1), &
543 & lbi, ubi, lbj, ubj, &
545 &
mobs, mstr, mend, &
551 &
ocean(ng)%tl_vbar(:,:,kout), &
565# ifndef I4DVAR_ANA_SENSITIVITY
573 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i-1,j,k)+ &
574 &
grid(ng)%z_r(i ,j,k))
579 & lbi, ubi, lbj, ubj, 1,
n(ng), &
581 &
mobs, mstr, mend, &
587 &
ocean(ng)%u(:,:,:,nout), &
600 & lbi, ubi, lbj, ubj, 1,
n(ng), &
602 &
mobs, mstr, mend, &
608 &
ocean(ng)%e_u(:,:,:,1), &
627 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i-1,j,k)+ &
628 &
grid(ng)%z_r(i ,j,k))
633 & lbi, ubi, lbj, ubj, 1,
n(ng), &
635 &
mobs, mstr, mend, &
641 &
ocean(ng)%tl_u(:,:,:,nout), &
654# ifndef I4DVAR_ANA_SENSITIVITY
662 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i,j-1,k)+ &
663 &
grid(ng)%z_r(i,j ,k))
668 & lbi, ubi, lbj, ubj, 1,
n(ng), &
670 &
mobs, mstr, mend, &
676 &
ocean(ng)%v(:,:,:,nout), &
689 & lbi, ubi, lbj, ubj, 1,
n(ng), &
691 &
mobs, mstr, mend, &
697 &
ocean(ng)%e_v(:,:,:,1), &
716 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i,j-1,k)+ &
717 &
grid(ng)%z_r(i,j ,k))
722 & lbi, ubi, lbj, ubj, 1,
n(ng), &
724 &
mobs, mstr, mend, &
730 &
ocean(ng)%tl_v(:,:,:,nout), &
743# ifdef RADIAL_ANGLE_CCW_EAST
762# ifndef I4DVAR_ANA_SENSITIVITY
776 & lbi, ubi, lbj, ubj, &
778 &
mobs, mstr, mend, &
796 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i-1,j,k)+ &
797 &
grid(ng)%z_r(i ,j,k))
802 & lbi, ubi, lbj, ubj, 1,
n(ng), &
804 &
mobs, mstr, mend, &
810 &
ocean(ng)%u(:,:,:,nout), &
823 & lbi, ubi, lbj, ubj, 1,
n(ng), &
825 &
mobs, mstr, mend, &
831 &
ocean(ng)%e_u(:,:,:,1), &
844 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i,j-1,k)+ &
845 &
grid(ng)%z_r(i,j ,k))
850 & lbi, ubi, lbj, ubj, 1,
n(ng), &
852 &
mobs, mstr, mend, &
858 &
ocean(ng)%v(:,:,:,nout), &
871 & lbi, ubi, lbj, ubj, 1,
n(ng), &
873 &
mobs, mstr, mend, &
879 &
ocean(ng)%e_v(:,:,:,1), &
891# ifdef RADIAL_ANGLE_CCW_EAST
911 bgerr(iobs)=max(ubgerr(iobs), vbgerr(iobs))
935 & lbi, ubi, lbj, ubj, &
937 &
mobs, mstr, mend, &
955 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i-1,j,k)+ &
956 &
grid(ng)%z_r(i ,j,k))
961 & lbi, ubi, lbj, ubj, 1,
n(ng), &
963 &
mobs, mstr, mend, &
969 &
ocean(ng)%tl_u(:,:,:,nout), &
981 grid(ng)%z_v(i,j,k)=0.5_r8*(
grid(ng)%z_r(i,j-1,k)+ &
982 &
grid(ng)%z_r(i,j ,k))
987 & lbi, ubi, lbj, ubj, 1,
n(ng), &
989 &
mobs, mstr, mend, &
995 &
ocean(ng)%tl_v(:,:,:,nout), &
1006# ifdef RADIAL_ANGLE_CCW_EAST
1009 tlmodval(iobs)=
uradial(iobs)*cos(angle)+ &
1018 tlmodval(iobs)=
uradial(iobs)*sin(angle)+ &
1036# ifndef I4DVAR_ANA_SENSITIVITY
1043 & lbi, ubi, lbj, ubj, 1,
n(ng), &
1045 &
mobs, mstr, mend, &
1051 &
ocean(ng)%t(:,:,:,nout,itrc), &
1058# ifndef VERIFICATION
1063 & lbi, ubi, lbj, ubj, 1,
n(ng), &
1065 &
mobs, mstr, mend, &
1071 &
ocean(ng)%e_t(:,:,:,1,itrc), &
1088 & lbi, ubi, lbj, ubj, 1,
n(ng), &
1090 &
mobs, mstr, mend, &
1096 &
ocean(ng)%tl_t(:,:,:,nout,itrc), &
1121# if defined BGQC && !defined I4DVAR_ANA_SENSITIVITY
1135# elif defined WEAK_CONSTRAINT
1145 IF (df1*df1.gt.thresh)
THEN
1159# ifdef WEAK_CONSTRAINT
1160 ncollect=mend-mstr+1
1165 CALL mp_collect (ng, model, ncollect, inival, &
1166# ifdef WEAK_CONSTRAINT
1174# ifndef WEAK_CONSTRAINT
1226# ifdef I4DVAR_ANA_SENSITIVITY
1229 tlmodval(iobs)=
obsscale(iobs)*tlmodval(iobs)
1241# ifndef I4DVAR_ANA_SENSITIVITY
1246 CALL mp_collect (ng, model, ncollect, inival, &
1247# if defined WEAK_CONSTRAINT
1253 CALL mp_collect (ng, model, ncollect, inival, &
1254# if defined WEAK_CONSTRAINT
1261# ifndef VERIFICATION
1266 CALL mp_collect (ng, model, ncollect, inival, &
1267# if defined WEAK_CONSTRAINT
1281 CALL mp_collect (ng, model, ncollect, inival, &
1282# if defined WEAK_CONSTRAINT
1295 CALL mp_collect (ng, model, ncollect, inival, &
1296# ifdef WEAK_CONSTRAINT
1310 & LBi, UBi, LBj, UBj, &
1318 integer,
intent(in) :: ng, tile, model
1319 integer,
intent(in) :: lbi, ubi, lbj, ubj
1320 integer,
intent(in) :: mstr, mend
1326 integer :: tindex, iobs, status
1330 character (len=*),
parameter :: myfile = &
1331 & __FILE__//
", obs_write_nf90"
1335# if defined FOUR_DVAR && !defined I4DVAR_ANA_SENSITIVITY
1348# elif defined WEAK_CONSTRAINT
1351 & (tlmodval(iobs)-
obsval(iobs))
1366 & ncid =
dav(ng)%ncid, &
1374 & ncid =
dav(ng)%ncid, &
1382 & ncid =
dav(ng)%ncid, &
1390 & ncid =
dav(ng)%ncid, &
1405 & ncid =
dav(ng)%ncid, &
1412# if defined FOUR_DVAR && !defined I4DVAR_ANA_SENSITIVITY
1428 & ncid =
dav(ng)%ncid, &
1447 & ncid =
dav(ng)%ncid, &
1467 & ncid =
dav(ng)%ncid, &
1475 & ncid =
dav(ng)%ncid, &
1486# if defined I4DVAR || defined WEAK_CONSTRAINT && \
1493 &
outer, (/0/), (/0/), &
1494 & ncid =
dav(ng)%ncid)
1498 &
inner, (/0/), (/0/), &
1499 & ncid =
dav(ng)%ncid)
1511 & ncid =
dav(ng)%ncid, &
1516# ifndef I4DVAR_ANA_SENSITIVITY
1525# if defined VERIFICATION || defined TLM_CHECK
1531 & ncid =
dav(ng)%ncid, &
1536# elif defined I4DVAR || defined WEAK_CONSTRAINT
1542 & ncid =
dav(ng)%ncid, &
1554 & ncid =
dav(ng)%ncid, &
1561# if !defined I4DVAR_ANA_SENSITIVITY && \
1562 (defined i4dvar || defined weak_constraint)
1572 & ncid =
dav(ng)%ncid, &
1577# if defined I4DVAR || defined I4DVAR_ANA_SENSITIVITY || \
1578 defined weak_constraint
1585 & tlmodval(mstr:), &
1587 & ncid =
dav(ng)%ncid, &
1594# ifdef I4DVAR_ANA_SENSITIVITY
1601 &
'ObsImpact_total', &
1602 & tlmodval(mstr:), &
1604 & ncid =
dav(ng)%ncid)
1609# ifdef OBS_IMPACT_SPLIT
1616 & tlmodval(mstr:), &
1618 & ncid =
dav(ng)%ncid)
1622# if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
1629 & tlmodval(mstr:), &
1631 & ncid =
dav(ng)%ncid)
1636# if defined ADJUST_BOUNDARY
1643 & tlmodval(mstr:), &
1645 & ncid =
dav(ng)%ncid)
1653# if defined R4DVAR || defined R4DVAR_ANA_SENSITIVITY || \
1660 &
'RPmodel_initial', &
1661 & tlmodval(mstr:), &
1663 & ncid =
dav(ng)%ncid)
1673 IF ((
nrun.eq.1).and. &
1679 & ncid =
dav(ng)%ncid, &
1691 IF ((
nrun.eq.1).and. &
1697 & ncid =
obs(ng)%ncid, &
1701 IF (model.eq.
iadm)
THEN
1710# if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
1719 & lbi, ubi, lbj, ubj, scale, &
1721 &
grid(ng) % rmask, &
1724 & setfillval = .false.)
1749# if defined PIO_LIB && defined DISTRIBUTE
1753 & LBi, UBi, LBj, UBj, &
1761 integer,
intent(in) :: ng, tile, model
1762 integer,
intent(in) :: lbi, ubi, lbj, ubj
1763 integer,
intent(in) :: mstr, mend
1769 integer :: tindex, iobs, status
1773 character (len=*),
parameter :: myfile = &
1774 & __FILE__//
", obs_write_pio"
1776# if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
1778 TYPE (io_desc_t),
pointer :: iodesc
1783# if defined FOUR_DVAR && !defined I4DVAR_ANA_SENSITIVITY
1796# elif defined WEAK_CONSTRAINT
1799 & (tlmodval(iobs)-
obsval(iobs))
1814 & piofile =
dav(ng)%pioFile, &
1822 & piofile =
dav(ng)%pioFile, &
1830 & piofile =
dav(ng)%pioFile, &
1838 & piofile =
dav(ng)%pioFile, &
1853 & piofile =
dav(ng)%pioFile, &
1860# if defined FOUR_DVAR && !defined I4DVAR_ANA_SENSITIVITY
1874 &
bgerr(mstr:mend), &
1876 & piofile =
dav(ng)%pioFile, &
1895 & piofile =
dav(ng)%pioFile, &
1915 & piofile =
dav(ng)%pioFile, &
1923 & piofile =
dav(ng)%pioFile, &
1934# if defined I4DVAR || defined WEAK_CONSTRAINT && \
1941 &
outer, (/0/), (/0/), &
1942 & piofile =
dav(ng)%pioFile)
1946 &
inner, (/0/), (/0/), &
1947 & piofile =
dav(ng)%pioFile)
1959 & piofile =
dav(ng)%pioFile, &
1964# ifndef I4DVAR_ANA_SENSITIVITY
1973# if defined VERIFICATION || defined TLM_CHECK
1979 & piofile =
dav(ng)%pioFile, &
1984# elif defined I4DVAR || defined WEAK_CONSTRAINT
1990 & piofile =
dav(ng)%pioFile, &
2002 & piofile =
dav(ng)%pioFile, &
2009# if !defined I4DVAR_ANA_SENSITIVITY && \
2010 (defined i4dvar || defined weak_constraint)
2020 & piofile =
dav(ng)%pioFile, &
2025# if defined I4DVAR || defined I4DVAR_ANA_SENSITIVITY || \
2026 defined weak_constraint
2033 & tlmodval(mstr:mend), &
2035 & piofile =
dav(ng)%pioFile, &
2042# ifdef I4DVAR_ANA_SENSITIVITY
2049 &
'ObsImpact_total', &
2050 & tlmodval(mstr:mend), &
2052 & piofile =
dav(ng)%pioFile)
2057# ifdef OBS_IMPACT_SPLIT
2064 & tlmodval(mstr:mend), &
2066 & piofile =
dav(ng)%pioFile)
2070# if defined ADJUST_WSTRESS || defined ADJUST_STFLUX
2077 & tlmodval(mstr:mend), &
2079 & piofile =
dav(ng)%pioFile)
2084# if defined ADJUST_BOUNDARY
2091 & tlmodval(mstr:mend), &
2093 & piofile =
dav(ng)%pioFile)
2101# if defined R4DVAR || defined R4DVAR_ANA_SENSITIVITY || \
2108 &
'RPmodel_initial', &
2109 & tlmodval(mstr:mend), &
2111 & piofile =
dav(ng)%pioFile)
2121 IF ((
nrun.eq.1).and. &
2125 &
zobs(mstr:mend), &
2127 & piofile =
dav(ng)%pioFile, &
2139 IF ((
nrun.eq.1).and. &
2143 &
zobs(mstr:mend), &
2145 & piofile =
obs(ng)%pioFile, &
2149 IF (model.eq.
iadm)
THEN
2158# if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
2163 IF (
dav(ng)%pioVar(
idfsur)%dkind.eq.pio_double)
THEN
2173 & lbi, ubi, lbj, ubj, scale, &
2175 &
grid(ng) % rmask, &
2178 & setfillval = .false.)
type(t_fourdvar), dimension(:), allocatable fourdvar
real(r8), dimension(:), allocatable vradial
logical, dimension(:), allocatable wrtimpact_bc
integer, dimension(:), allocatable obsprov
logical, dimension(:), allocatable wrtimpact_fc
logical, dimension(:), allocatable wrtmisfit
logical, dimension(:), allocatable wrtrpmod
integer, dimension(:), allocatable nobs
real(r8), dimension(:), allocatable obsvetting
logical, dimension(:), allocatable wrtimpact_ic
integer, dimension(:), allocatable nobsvar
real(r8), dimension(:), allocatable obsval
real(r8), dimension(:), allocatable uradial
real(r8), dimension(:), allocatable misfit
logical, dimension(:), allocatable havenlmod
real(r8), dimension(:), allocatable bgerr
logical, dimension(:), allocatable wrote_zobs
real(r8), dimension(:), allocatable obsangler
logical, dimension(:), allocatable wrttlmod
real(r8), dimension(:), allocatable innovation
logical, dimension(:), allocatable wrtnlmod
real(r8), dimension(:), allocatable obsscale
real(r8), dimension(:), allocatable obserr
real(r8), dimension(:), allocatable obsmeta
logical, dimension(:), allocatable load_zobs
integer, dimension(:), allocatable obstype
logical, dimension(:), allocatable wrtimpact_tot
real(r8), dimension(:), allocatable bgthresh
logical, dimension(:), allocatable havetlmod
integer, dimension(:), allocatable nsurvey
real(r8), dimension(:), allocatable zobs
logical, dimension(:), allocatable wrtobsscale
real(r8), dimension(:), allocatable nlmodval
real(r8), dimension(:), allocatable residual
real(r8), dimension(:), allocatable nlincrement
real(dp), dimension(:), allocatable tobs
real(r8), dimension(:), allocatable unvetted
integer, dimension(:), allocatable obssurvey
real(r8), dimension(:), allocatable xobs
integer, dimension(:), allocatable obsstate2type
real(r8), dimension(:), allocatable yobs
character(len=40), dimension(:), allocatable obsname
logical, dimension(:), allocatable wrtzetaref
integer, dimension(:), allocatable nstrobs
logical, dimension(:), allocatable processobs
integer, dimension(:), allocatable nendobs
type(t_grid), dimension(:), allocatable grid
type(t_io), dimension(:), allocatable obs
type(t_io), dimension(:), allocatable dav
character(len=256) sourcefile
integer, parameter io_nf90
real(r8), dimension(:), allocatable rymin
integer, parameter io_pio
real(r8), dimension(:), allocatable vymin
real(r8), dimension(:), allocatable rymax
real(r8), dimension(:), allocatable uymin
real(r8), dimension(:), allocatable vymax
real(r8), dimension(:), allocatable uxmin
real(r8), dimension(:), allocatable uxmax
real(r8), dimension(:), allocatable rxmax
integer, dimension(:), allocatable istvar
real(r8), dimension(:), allocatable uymax
real(r8), dimension(:), allocatable vxmin
character(len=maxlen), dimension(6, 0:nv) vname
real(r8), dimension(:), allocatable vxmax
real(r8), dimension(:), allocatable rxmin
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, dimension(:), allocatable lm
integer, dimension(:), allocatable nt
integer, dimension(:), allocatable mm
integer, parameter r2dvar
subroutine, public pio_netcdf_sync(ng, model, ncname, piofile)
type(io_desc_t), dimension(:), pointer iodesc_sp_r2dvar
type(io_desc_t), dimension(:), pointer iodesc_dp_r2dvar
real(dp), dimension(:), allocatable dt
logical, dimension(:), allocatable balance
real(r8), dimension(:,:), allocatable s_bgqc
real(r8), dimension(:,:), allocatable p_bgqc
integer, dimension(:), allocatable bgqc_type
real(dp), dimension(:), allocatable time
integer, dimension(:), allocatable nprovenance
integer, dimension(:,:), allocatable iprovenance
subroutine, private obs_write_nf90(ng, tile, model, lbi, ubi, lbj, ubj, mstr, mend)
subroutine, private obs_write_pio(ng, tile, model, lbi, ubi, lbj, ubj, mstr, mend)
subroutine, private obs_operator(ng, tile, model, lbi, ubi, lbj, ubj, mstr, mend)
subroutine, public obs_write(ng, tile, model)
logical function, public founderror(flag, noerr, line, routine)