4#if defined FOUR_DVAR || defined VERIFICATION 
  153          integer , 
allocatable :: nobssurvey(:)
 
  154          integer , 
allocatable :: obscount(:)
 
  155          integer , 
allocatable :: obsreject(:)
 
  157          real(dp), 
allocatable :: backcost(:)
 
  158          real(dp), 
allocatable :: cost0(:)
 
  159          real(dp), 
allocatable :: costfun(:)
 
  160          real(dp), 
allocatable :: costfunold(:)
 
  161          real(dp), 
allocatable :: costnorm(:)
 
  162          real(dp), 
allocatable :: obscost(:)
 
  163          real(dp), 
allocatable :: datapenalty(:)
 
  164#   if defined DATALESS_LOOPS    || defined RBL4DVAR  || \ 
  165       defined sensitivity_4dvar || defined sp4dvar   || \
 
  167          real(dp), 
allocatable :: nlpenalty(:)
 
  169          real(dp), 
allocatable :: nlobscost(:)
 
  171#   if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC 
  172          real(r8), 
allocatable :: bc_ak(:)
 
  173          real(r8), 
allocatable :: bc_bk(:)
 
  175          real(r8), 
allocatable :: zdf1(:)
 
  176          real(r8), 
allocatable :: zdf2(:)
 
  177          real(r8), 
allocatable :: zdf3(:)
 
  179          real(r8), 
allocatable :: pc_r2d(:,:)
 
  180          real(r8), 
allocatable :: rhs_r2d(:,:)
 
  181          real(r8), 
allocatable :: r2d_ref(:,:)
 
  182          real(r8), 
allocatable :: zeta_ref(:,:)
 
  184          real(r8), 
allocatable :: p_r2d(:,:,:)
 
  185          real(r8), 
allocatable :: r_r2d(:,:,:)
 
  186          real(r8), 
allocatable :: bp_r2d(:,:,:)
 
  187          real(r8), 
allocatable :: br_r2d(:,:,:)
 
  189          real(r8), 
allocatable :: tl_rhs_r2d(:,:)
 
  190          real(r8), 
allocatable :: tl_r2d_ref(:,:)
 
  191          real(r8), 
allocatable :: tl_zeta_ref(:,:)
 
  193          real(r8), 
allocatable :: ad_rhs_r2d(:,:)
 
  194          real(r8), 
allocatable :: ad_r2d_ref(:,:)
 
  195          real(r8), 
allocatable :: ad_zeta_ref(:,:)
 
  198          real(r8), 
allocatable :: surveytime(:)
 
  201          real(dp), 
allocatable :: cg_pxout(:)
 
  202          real(dp), 
allocatable :: cg_pxsave(:)
 
  203          real(dp), 
allocatable :: cg_pxsum(:)
 
  204          real(dp), 
allocatable :: cg_dpxsum(:)
 
 
  228#  ifndef WEAK_CONSTRAINT 
  229        real(r8), 
allocatable :: obsscaleglobal(:)
 
  233        real(dp), 
allocatable :: 
tobs(:)
 
  234        real(r8), 
allocatable :: 
xobs(:)
 
  235        real(r8), 
allocatable :: 
yobs(:)
 
  237        real(r8), 
allocatable :: 
zobs(:)
 
  247        real(r8), 
allocatable :: ubgerr(:)
 
  248        real(r8), 
allocatable :: vbgerr(:)
 
  253        real(r8), 
allocatable :: 
gmze(:,:)
 
  255        real(r8), 
allocatable :: 
jobs(:,:)
 
  258        real(r8), 
allocatable :: tlmodval(:)
 
  259#   if defined ARRAY_MODES       || defined CLIPPING  || \ 
  260       defined rbl4dvar          || defined r4dvar    || \
 
  261       defined sensitivity_4dvar || defined sp4dvar   || \
 
  262       defined tl_rbl4dvar       || defined tl_r4dvar
 
  263        real(r8), 
allocatable :: tlmodval_s(:,:,:)
 
  264#    if defined RPCG              && \ 
  265       (defined sensitivity_4dvar || defined tl_rbl4dvar || \
 
  267        real(r8), 
allocatable :: tl_tlmodval_s(:,:,:)
 
  268        real(r8), 
allocatable :: ad_tlmodval_s(:,:,:)
 
  271#   if defined ARRAY_MODES       || defined RBL4DVAR    || \ 
  272       defined sensitivity_4dvar || defined tl_rbl4dvar
 
  273        real(r8), 
allocatable :: bckmodval(:)
 
  276        real(r8), 
allocatable :: hbk(:,:)
 
  277#     if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR || \ 
  279        real(r8), 
allocatable :: tl_bckmodval(:)
 
  280        real(r8), 
allocatable :: tl_hbk(:)
 
  281        real(r8), 
allocatable :: ad_bckmodval(:)
 
  282        real(r8), 
allocatable :: ad_hbk(:)
 
  287#  ifdef WEAK_CONSTRAINT 
  291        real(r8), 
allocatable :: 
jb0(:)
 
  297        real(r8), 
allocatable :: 
gdgw(:)
 
  302        real(r8), 
allocatable :: cg_pxsave(:)
 
  304#   if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR || \ 
  308#    if defined RPCG              && \ 
  309       (defined sensitivity_4dvar || defined tl_rbl4dvar || \
 
  392        integer, 
parameter, 
dimension(Nweights) :: 
ioffset =            &
 
  393     &                      (/ 0, 1, 0, 1, 0, 1, 0, 1 /)
 
 
  394        integer, 
parameter, 
dimension(Nweights) :: 
joffset =            &
 
  395     &                      (/ 0, 0, 1, 1, 0, 0, 1, 1 /)
 
 
  396        integer, 
parameter, 
dimension(Nweights) :: 
koffset =            &
 
  397     &                      (/ 0, 0, 0, 0, 1, 1, 1, 1 /)
 
 
  401        integer, 
parameter, 
dimension(Nweights) :: 
ioffset =            &
 
  403        integer, 
parameter, 
dimension(Nweights) :: 
joffset =            &
 
  421        integer, 
allocatable :: 
nobs(:)
 
  517# if defined I4DVAR_ANA_SENSITIVITY 
  525#  ifdef OBS_IMPACT_SPLIT 
  531#   if defined ADJUST_WSTRESS || defined ADJUST_STFLUX 
  538#   if defined ADJUST_BOUNDARY 
  639# if defined I4DVAR || defined WEAK_CONSTRAINT 
  647#  if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR  || \ 
  664        real(dp), 
allocatable :: 
ritz(:)
 
  668#  ifdef WEAK_CONSTRAINT 
  669        real(dp), 
allocatable :: 
cg_zv(:,:,:)
 
  671        real(dp), 
allocatable :: 
cg_zv(:,:)
 
  676#  if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR  || \ 
  688        real(dp), 
allocatable :: tl_cg_gnorm(:)
 
  719# if defined BALANCE_OPERATOR 
  729# if defined POSTERIOR_EOFS    || defined POSTERIOR_ERROR_I || \ 
  730     defined posterior_error_f
 
  758#  if defined POSTERIOR_ERROR_I || defined POSTERIOR_ERROR_F 
  768# if defined HESSIAN_SV || defined HESSIAN_SO || defined HESSIAN_FSV 
  776# if defined I4DVAR_ANA_SENSITIVITY 
  787        real(r8), 
allocatable :: 
cg_beta(:,:)
 
  788        real(r8), 
allocatable :: 
cg_delta(:,:)
 
  789        real(r8), 
allocatable :: 
cg_zu(:,:)
 
  791# if defined HESSIAN_SV || defined HESSIAN_SO || defined HESSIAN_FSV 
  802        real(r8), 
allocatable :: 
cg_beta(:,:)
 
  803        real(r8), 
allocatable :: 
cg_delta(:,:)
 
  876        real(r8), 
dimension(1000) :: 
g1 
  877        real(r8), 
dimension(1000) :: 
g2 
  879# ifdef WEAK_CONSTRAINT 
  889#  ifdef RPM_RELAXATION 
  892#  ifdef RBL4DVAR_FCT_SENSITIVITY 
  895#  if defined RBL4DVAR_ANA_SENSITIVITY || \ 
  896      defined rbl4dvar_fct_sensitivity || \
 
  897      defined r4dvar_ana_sensitivity
 
  906        logical, 
allocatable :: ladjvar(:)
 
  910#  ifdef RBL4DVAR_FCT_SENSITIVITY 
  949      IF (.not.
allocated(
nobsvar)) 
THEN 
  953      IF (.not.
allocated(
ndatum)) 
THEN 
  957      IF (.not.
allocated(
nsurvey)) 
THEN 
  965      IF (.not.
allocated(
nobs)) 
THEN 
  970      IF (.not.
allocated(
nstrobs)) 
THEN 
  974      IF (.not.
allocated(
nendobs)) 
THEN 
  979      IF (.not.
allocated(
nmethod)) 
THEN 
  983      IF (.not.
allocated(
rscheme)) 
THEN 
  998      IF (.not.
allocated(
lsadd)) 
THEN 
 1025# if defined I4DVAR_ANA_SENSITIVITY 
 1032#  ifdef OBS_IMPACT_SPLIT 
 1037#   if defined ADJUST_WSTRESS || defined ADJUST_STFLUX 
 1043#   if defined ADJUST_BOUNDARY 
 1069      IF (.not.
allocated(
khmin)) 
THEN 
 1073      IF (.not.
allocated(
khmax)) 
THEN 
 1077      IF (.not.
allocated(
kvmin)) 
THEN 
 1081      IF (.not.
allocated(
kvmax)) 
THEN 
 1086# if defined BALANCE_OPERATOR 
 1093# ifdef WEAK_CONSTRAINT 
 1098#  ifdef RPM_RELAXATION 
 1104#  ifdef RBL4DVAR_FCT_SENSITIVITY 
 1105      IF (.not.
allocated(
lsenfct)) 
THEN 
 1110#  if defined RBL4DVAR_ANA_SENSITIVITY || \ 
 1111      defined rbl4dvar_fct_sensitivity || \
 
 1112      defined r4dvar_ana_sensitivity
 
 1123      IF (.not.
allocated(ladjvar)) 
THEN 
 1124        allocate ( ladjvar(
ngrids) )
 
 1130#  ifdef RBL4DVAR_FCT_SENSITIVITY 
 
 1186      IF (
allocated(
obserr)) 
THEN 
 1198#  ifndef WEAK_CONSTRAINT 
 1199      IF (
allocated(obsscaleglobal)) 
THEN 
 1200        deallocate (obsscaleglobal)
 
 1208      IF (
allocated(
obsval)) 
THEN 
 1212      IF (
allocated(
tobs)) 
THEN 
 1216      IF (
allocated(
xobs)) 
THEN 
 1220      IF (
allocated(
yobs)) 
THEN 
 1225      IF (
allocated(
zobs)) 
THEN 
 1238      IF (
allocated(
misfit)) 
THEN 
 1254#  ifndef VERIFICATION 
 1255      IF (
allocated(ubgerr)) 
THEN 
 1259      IF (
allocated(vbgerr)) 
THEN 
 1265      IF (
allocated(
bgerr)) 
THEN 
 1289      IF (
allocated(tlmodval)) 
THEN 
 1290        deallocate (tlmodval)
 
 1293#   if defined ARRAY_MODES       || defined CLIPPING    || \ 
 1294       defined rbl4dvar          || defined r4dvar      || \
 
 1295       defined sensitivity_4dvar || defined tl_rbl4dvar || \
 
 1297      IF (
allocated(tlmodval_s)) 
THEN 
 1298        deallocate (tlmodval_s)
 
 1301#    if defined RPCG              && \ 
 1302       (defined sensitivity_4dvar || defined tl_rbl4dvar || \
 
 1305      IF (
allocated(tl_tlmodval_s)) 
THEN 
 1306        deallocate (tl_tlmodval_s)
 
 1309      IF (
allocated(ad_tlmodval_s)) 
THEN 
 1310        deallocate (ad_tlmodval_s)
 
 1316#   if defined SENSITIVITY_4DVAR || defined RBL4DVAR || \ 
 1319      IF (
allocated(bckmodval)) 
THEN 
 1320        deallocate (bckmodval)
 
 1324      IF (
allocated(hbk)) 
THEN 
 1327#     if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR || \ 
 1330      IF (
allocated(tl_bckmodval)) 
THEN 
 1331        deallocate (tl_bckmodval)
 
 1333      IF (
allocated(ad_bckmodval)) 
THEN 
 1334        deallocate (ad_bckmodval)
 
 1336      IF (
allocated(tl_hbk)) 
THEN 
 1339      IF (
allocated(ad_hbk)) 
THEN 
 1347#  ifdef WEAK_CONSTRAINT 
 1351#   if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR || \ 
 1401      IF (
allocated(
zcglwk)) 
THEN 
 1405      IF (
allocated(
vcglwk)) 
THEN 
 1409      IF (
allocated(
vcglev)) 
THEN 
 1413      IF (
allocated(
zgrad0)) 
THEN 
 1417      IF (
allocated(
vgrad0)) 
THEN 
 1429#    if defined RBL4DVAR_ANA_SENSITIVITY || \ 
 1430        defined rbl4dvar_fct_sensitivity || \
 
 1431        defined r4dvar_ana_sensitivity   || \
 
 1432        defined tl_rbl4dvar              || \
 
 1447      IF (
allocated(
ad_jb0)) 
THEN 
 1475      IF (
allocated(
tl_jb0)) 
THEN 
 1502      IF (
allocated(cg_pxsave)) 
THEN 
 1503        deallocate (cg_pxsave)
 
 1506      IF (
allocated(
zcglwk)) 
THEN 
 1510      IF (
allocated(
vcglev)) 
THEN 
 1514      IF (
allocated(
zgrad0)) 
THEN 
 1518      IF (
allocated(
vgrad0)) 
THEN 
 1526      IF (
allocated(
gdgw)) 
THEN 
 1534      IF (
allocated(cg_pxsave)) 
THEN 
 1535        deallocate (cg_pxsave)
 
 
 1559# if defined PIO_LIB && defined DISTRIBUTE 
 1568      integer :: my_nobsvar, i, icount, ng
 
 1569# if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC 
 1570      integer :: lbi, ubi, lbj, ubj
 
 1575      real(r8), 
parameter :: inival = 0.0_r8
 
 1577      character (len=*), 
parameter :: myfile =                          &
 
 1578     &  __FILE__//
", initialize_fourdvar" 
 1593        SELECT CASE (
obs(ng)%IOtype)
 
 1596#  if defined PIO_LIB && defined DISTRIBUTE 
 1609          IF (trim(
dim_name(i)).eq.
'datum') 
then 
 1611          ELSE IF (trim(
dim_name(i)).eq.
'survey') 
THEN 
 1613          ELSE IF (trim(
dim_name(i)).eq.
'state_variable') 
THEN 
 1617        IF (
ndatum(ng).eq.0) 
THEN 
 1618          WRITE (
stdout,20) 
'datum', trim(
obs(ng)%name)
 
 1623          WRITE (
stdout,20) 
'survey', trim(
obs(ng)%name)
 
 1633#  if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC 
 1643      IF (.not.
allocated( 
fourdvar)) 
THEN 
 1651#  if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC 
 1657        size2d=real((ubi-lbi+1)*(ubj-lbj+1),r8)
 
 1669#   ifdef ADJUST_STFLUX 
 1675#  ifdef ADJUST_WSTRESS 
 1681        IF (.not.
allocated(
fourdvar(ng) % NobsSurvey)) 
THEN 
 1687        IF (.not.
allocated(
fourdvar(ng) % SurveyTime)) 
THEN 
 1694        IF (.not.
allocated(
fourdvar(ng) % BackCost)) 
THEN 
 1700        IF (.not.
allocated(
fourdvar(ng) % Cost0)) 
THEN 
 1706        IF (.not.
allocated(
fourdvar(ng) % CostFun)) 
THEN 
 1712        IF (.not.
allocated(
fourdvar(ng) % CostFunOld)) 
THEN 
 1718        IF (.not.
allocated(
fourdvar(ng) % CostNorm)) 
THEN 
 1724        IF (.not.
allocated(
fourdvar(ng) % ObsCost)) 
THEN 
 1730        IF (.not.
allocated(
fourdvar(ng) % DataPenalty)) 
THEN 
 1733          fourdvar(ng) % DataPenalty = inival
 
 1736#   if defined DATALESS_LOOPS    || defined RBL4DVAR || \ 
 1737       defined sensitivity_4dvar || defined sp4dvar  || \
 
 1740        IF (.not.
allocated(
fourdvar(ng) % NLPenalty)) 
THEN 
 1747        IF (.not.
allocated(
fourdvar(ng) % NLobsCost)) 
THEN 
 1753#   if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC 
 1754        IF (.not.
allocated(
fourdvar(ng) % bc_ak)) 
THEN 
 1760        IF (.not.
allocated(
fourdvar(ng) % bc_bk)) 
THEN 
 1766        IF (.not.
allocated(
fourdvar(ng) % zdf1)) 
THEN 
 1772        IF (.not.
allocated(
fourdvar(ng) % zdf2)) 
THEN 
 1778        IF (.not.
allocated(
fourdvar(ng) % zdf3)) 
THEN 
 1784        IF (.not.
allocated(
fourdvar(ng) % pc_r2d)) 
THEN 
 1785          allocate ( 
fourdvar(ng) % pc_r2d(lbi:ubi,lbj:ubj) )
 
 1790        IF (.not.
allocated(
fourdvar(ng) % rhs_r2d)) 
THEN 
 1791          allocate ( 
fourdvar(ng) % rhs_r2d(lbi:ubi,lbj:ubj) )
 
 1796        IF (.not.
allocated(
fourdvar(ng) % r2d_ref)) 
THEN 
 1797          allocate ( 
fourdvar(ng) % r2d_ref(lbi:ubi,lbj:ubj) )
 
 1802        IF (.not.
allocated(
fourdvar(ng) % zeta_ref)) 
THEN 
 1803          allocate ( 
fourdvar(ng) % zeta_ref(lbi:ubi,lbj:ubj) )
 
 1808        IF (.not.
allocated(
fourdvar(ng) % p_r2d)) 
THEN 
 1809          allocate ( 
fourdvar(ng) % p_r2d(lbi:ubi,lbj:ubj,
nbico(ng)) )
 
 1814        IF (.not.
allocated(
fourdvar(ng) % r_r2d)) 
THEN 
 1815          allocate ( 
fourdvar(ng) % r_r2d(lbi:ubi,lbj:ubj,
nbico(ng)) )
 
 1820        IF (.not.
allocated(
fourdvar(ng) % bp_r2d)) 
THEN 
 1821          allocate ( 
fourdvar(ng) % bp_r2d(lbi:ubi,lbj:ubj,
nbico(ng)) )
 
 1826        IF (.not.
allocated(
fourdvar(ng) % br_r2d)) 
THEN 
 1827          allocate ( 
fourdvar(ng) % br_r2d(lbi:ubi,lbj:ubj,
nbico(ng)) )
 
 1832        IF (.not.
allocated(
fourdvar(ng) % tl_rhs_r2d)) 
THEN 
 1833          allocate ( 
fourdvar(ng) % tl_rhs_r2d(lbi:ubi,lbj:ubj) )
 
 1838        IF (.not.
allocated(
fourdvar(ng) % tl_r2d_ref)) 
THEN 
 1839          allocate ( 
fourdvar(ng) % tl_r2d_ref(lbi:ubi,lbj:ubj) )
 
 1844        IF (.not.
allocated(
fourdvar(ng) % tl_zeta_ref)) 
THEN 
 1845          allocate ( 
fourdvar(ng) % tl_zeta_ref(lbi:ubi,lbj:ubj) )
 
 1847          fourdvar(ng) % tl_zeta_ref = inival
 
 1850        IF (.not.
allocated(
fourdvar(ng) % ad_rhs_r2d)) 
THEN 
 1851          allocate ( 
fourdvar(ng) % ad_rhs_r2d(lbi:ubi,lbj:ubj) )
 
 1856        IF (.not.
allocated(
fourdvar(ng) % ad_r2d_ref)) 
THEN 
 1857          allocate ( 
fourdvar(ng) % ad_r2d_ref(lbi:ubi,lbj:ubj) )
 
 1862        IF (.not.
allocated(
fourdvar(ng) % ad_zeta_ref)) 
THEN 
 1863          allocate ( 
fourdvar(ng) % ad_zeta_ref(lbi:ubi,lbj:ubj) )
 
 1865          fourdvar(ng) % ad_zeta_ref = inival
 
 1870        IF (.not.
allocated(
fourdvar(ng) % ObsCount)) 
THEN 
 1876        IF (.not.
allocated(
fourdvar(ng) % ObsReject)) 
THEN 
 1883        IF (.not.
allocated(
fourdvar(ng) % cg_pxout)) 
THEN 
 1889        IF (.not.
allocated(
fourdvar(ng) % cg_pxsave)) 
THEN 
 1895        IF (.not.
allocated(
fourdvar(ng) % cg_pxsum)) 
THEN 
 1901        IF (.not.
allocated(
fourdvar(ng) % cg_Dpxsum)) 
THEN 
 1907        IF (.not.
allocated(
fourdvar(ng) % tl_cg_pxsave)) 
THEN 
 1910          fourdvar(ng) % tl_cg_pxsave = inival
 
 1913        IF (.not.
allocated(
fourdvar(ng) % ad_cg_pxsave)) 
THEN 
 1916          fourdvar(ng) % ad_cg_pxsave = inival
 
 1931        SELECT CASE (
obs(ng)%IOtype)
 
 1947#  if defined PIO_LIB && defined DISTRIBUTE 
 1967#  ifdef WEAK_CONSTRAINT 
 1989      IF (.not.
allocated(
obstype)) 
THEN 
 2001      IF (.not.
allocated(
obsprov)) 
THEN 
 2007      IF (.not.
allocated(
obserr)) 
THEN 
 2013      IF (.not.
allocated(
obsmeta)) 
THEN 
 2025#  ifndef WEAK_CONSTRAINT 
 2026      IF (.not.
allocated(obsscaleglobal)) 
THEN 
 2027        allocate ( obsscaleglobal(maxval(
ndatum)) )
 
 2030      obsscaleglobal = inival
 
 2039      IF (.not.
allocated(
obsval)) 
THEN 
 2045      IF (.not.
allocated(
tobs)) 
THEN 
 2051      IF (.not.
allocated(
xobs)) 
THEN 
 2057      IF (.not.
allocated(
yobs)) 
THEN 
 2064      IF (.not.
allocated(
zobs)) 
THEN 
 2083      IF (.not.
allocated(
misfit)) 
THEN 
 2095      IF (.not.
allocated(
uradial)) 
THEN 
 2101      IF (.not.
allocated(
vradial)) 
THEN 
 2107#  ifndef VERIFICATION 
 2108      IF (.not.
allocated(ubgerr)) 
THEN 
 2109        allocate ( ubgerr(
mobs) )
 
 2114      IF (.not.
allocated(vbgerr)) 
THEN 
 2115        allocate ( vbgerr(
mobs) )
 
 2134      IF (.not.
allocated(
gmze)) 
THEN 
 2146      IF (.not.
allocated(
jobs)) 
THEN 
 2154      IF (.not.
allocated(
bgerr)) 
THEN 
 2186      IF (.not.
allocated(
jact_s)) 
THEN 
 2194      IF (.not.
allocated(tlmodval)) 
THEN 
 2195        allocate ( tlmodval(
mobs) )
 
 2200#   if defined ARRAY_MODES       || defined CLIPPING  || \ 
 2201       defined rbl4dvar          || defined r4dvar    || \
 
 2202       defined sensitivity_4dvar || defined sp4dvar   || \
 
 2203       defined tl_rbl4dvar       || defined tl_r4dvar
 
 2209      IF (.not.
allocated(tlmodval_s)) 
THEN 
 2215#    if defined RPCG              && \ 
 2216       (defined sensitivity_4dvar || defined tl_rbl4dvar || \
 
 2219        IF (.not.
allocated(tl_tlmodval_s)) 
THEN 
 2223        tl_tlmodval_s = inival
 
 2225        IF (.not.
allocated(ad_tlmodval_s)) 
THEN 
 2229        ad_tlmodval_s = inival
 
 2234#   if defined ARRAY_MODES       || defined RBL4DVAR    || \ 
 2235       defined sensitivity_4dvar || defined tl_rbl4dvar
 
 2237      IF (.not.
allocated(bckmodval)) 
THEN 
 2238        allocate ( bckmodval(
mobs) )
 
 2245      IF (.not.
allocated(hbk)) 
THEN 
 2251#     if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR || \ 
 2254      IF (.not.
allocated(tl_bckmodval)) 
THEN 
 2255        allocate ( tl_bckmodval(
mobs) )
 
 2258      tl_bckmodval = inival
 
 2260      IF (.not.
allocated(tl_hbk)) 
THEN 
 2261        allocate ( tl_hbk(
mobs) )
 
 2266      IF (.not.
allocated(ad_bckmodval)) 
THEN 
 2267        allocate ( ad_bckmodval(
mobs) )
 
 2270      ad_bckmodval = inival
 
 2272      IF (.not.
allocated(ad_hbk)) 
THEN 
 2273        allocate ( ad_hbk(
mobs) )
 
 2304      IF (.not.
allocated(
obsname)) 
THEN 
 2347#  ifdef WEAK_CONSTRAINT 
 2352#    define MyMobs Mobs+1 
 2357      IF (.not.
allocated(
zcglwk)) 
THEN 
 2364      IF (.not.
allocated(
vcglwk)) 
THEN 
 2370      IF (.not.
allocated(
jb0)) 
THEN 
 2377      IF (.not.
allocated(
vcglev)) 
THEN 
 2383      IF (.not.
allocated(
zgrad0)) 
THEN 
 2389      IF (.not.
allocated(
vgrad0)) 
THEN 
 2390        allocate ( 
vgrad0(mymobs) )
 
 2395     IF (.not.
allocated(
vgrad0s)) 
THEN 
 2401      IF (.not.
allocated(
gdgw)) 
THEN 
 2407      IF (.not.
allocated(
vgnorm)) 
THEN 
 2419      IF (.not.
allocated(
cg_dla)) 
THEN 
 2427      IF (.not.
allocated(cg_pxsave)) 
THEN 
 2428        allocate ( cg_pxsave(
mobs) )
 
 2435#   if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR || \ 
 2450#    if defined RPCG              && \ 
 2451       (defined sensitivity_4dvar || defined tl_rbl4dvar || \
 
 2472      IF (.not.
allocated(
ad_jb0)) 
THEN 
 2560      IF (.not.
allocated(
tl_jb0)) 
THEN 
 2618#   ifdef ADJUST_STFLUX 
 2624#  ifdef ADJUST_WSTRESS 
 2632      IF (.not.
allocated(
nhsteps)) 
THEN 
 2638      IF (.not.
allocated(
nvsteps)) 
THEN 
 2644      IF (.not.
allocated(
dtsizeh)) 
THEN 
 2650      IF (.not.
allocated(
dtsizev)) 
THEN 
 2681# if defined I4DVAR || defined WEAK_CONSTRAINT 
 2685#  if defined SENSITIVITY_4DVAR || defined TL_RBL4DVAR  || \ 
 2743      IF (.not.
allocated(tl_cg_gnorm)) 
THEN 
 2744        allocate ( tl_cg_gnorm(
nouter) )
 
 2747      tl_cg_gnorm = inival
 
 2758      IF (.not.
allocated(
cg_beta)) 
THEN 
 2764      IF (.not.
allocated(
cg_tau)) 
THEN 
 2770      IF (.not.
allocated(
ritz)) 
THEN 
 2776#  if defined POSTERIOR_EOFS    || defined POSTERIOR_ERROR_I || \ 
 2777      defined posterior_error_f
 
 2779      IF (.not.
allocated(
ae_beta)) 
THEN 
 2785      IF (.not.
allocated(
ae_zv)) 
THEN 
 2815      IF (.not.
allocated(
ae_ritz)) 
THEN 
 2827#   if defined POSTERIOR_ERROR_I || defined POSTERIOR_ERROR_F 
 2848#  ifdef WEAK_CONSTRAINT 
 2849      IF (.not.
allocated(
cg_zv)) 
THEN 
 2854      IF (.not.
allocated(
cg_zv)) 
THEN 
 2897      IF (.not.
allocated(
cg_qg)) 
THEN 
 2909      IF (.not.
allocated(
cg_ritz)) 
THEN 
 2921      IF (.not.
allocated(
cg_zu)) 
THEN 
 2928# if defined I4DVAR_ANA_SENSITIVITY 
 2932      IF (.not.
allocated(
cg_beta)) 
THEN 
 2944      IF (.not.
allocated(
cg_zu)) 
THEN 
 2950# if defined HESSIAN_SV || defined HESSIAN_SO || defined HESSIAN_FSV 
 2954      IF (.not.
allocated(
cg_beta)) 
THEN 
 3010# ifdef BALANCE_OPERATOR 
 3013# ifdef I4DVAR_ANA_SENSITIVITY 
 3017#  ifdef OBS_IMPACT_SPLIT 
 3019#   if defined ADJUST_WSTRESS || defined ADJUST_STFLUX 
 3022#   if defined ADJUST_BOUNDARY 
 3032# ifdef WEAK_CONSTRAINT 
 3039 10   
FORMAT (/,
' INITIALIZE_FOURDVAR - Illegal output type,',          &
 
 3041 20   
FORMAT (/,
' INITIALIZE_FOURDVAR - error inquiring dimension:',    &
 
 3042     &        1x,a,2x,
'in input NetCDF file: ',a)
 
 
real(r8), dimension(:,:,:), allocatable harnoldi
 
integer, dimension(:,:), allocatable nhsteps
 
real(r8), dimension(:,:), allocatable tl_vcglwk
 
real(dp), dimension(:), allocatable cg_gnorm_v
 
real(r8), dimension(:,:,:), allocatable vcglwk
 
real(r8), dimension(:), allocatable kvmax
 
real(r8), dimension(:), allocatable jact_s
 
logical, dimension(:), allocatable haveadmod
 
real(r8), dimension(:), allocatable gdgw
 
real(r8), dimension(:), allocatable ad_obserr
 
type(t_fourdvar), dimension(:), allocatable fourdvar
 
real(dp), dimension(:,:), allocatable cg_beta
 
real(r8), dimension(:), allocatable vradial
 
real(r8), dimension(:), allocatable ad_obsscale
 
logical, dimension(:), allocatable wrtimpact_bc
 
real(r8), dimension(:,:), allocatable ad_zcglwk
 
real(r8), dimension(1000) g2
 
real(r8), dimension(:), allocatable tl_obsval
 
subroutine, public deallocate_fourdvar
 
real(r8), dimension(:), allocatable optimality
 
real(dp), dimension(:,:), allocatable cg_ritz
 
integer, dimension(:), allocatable nmethod
 
integer, dimension(:), allocatable ndatum
 
real(r8), dimension(:,:), allocatable cg_dla
 
real(r8), dimension(:), allocatable tl_cg_pxout
 
integer, dimension(:,:), allocatable nvsteps
 
integer, dimension(:), allocatable obsprov
 
logical, dimension(:), allocatable wrtimpact_fc
 
real(dp), dimension(:,:), allocatable cg_tmatrix
 
real(dp), dimension(:,:), allocatable cg_qg
 
logical, dimension(:), allocatable wrtmisfit
 
real(dp), dimension(:), allocatable ritz
 
integer, dimension(:), allocatable extraindex
 
real(r8), dimension(:), allocatable zlanczos_diag
 
integer, dimension(:), allocatable ntimes_fct
 
integer, dimension(nweights), parameter koffset
 
real(r8), dimension(:,:), allocatable dtsizehb
 
integer, dimension(:), allocatable obstype2state
 
logical, dimension(:), allocatable wrtrpmod
 
logical, dimension(:), allocatable lsenfct
 
real(r8), dimension(:), allocatable tl_vgrad0s
 
integer, dimension(:), allocatable nobs
 
character(len=40), dimension(:), allocatable extraname
 
real(r8), dimension(:), allocatable ad_vgrad0
 
real(r8), dimension(:), allocatable ae_gnorm
 
real(r8), dimension(:), allocatable obsvetting
 
logical, dimension(:), allocatable wrtimpact_ic
 
integer, dimension(:), allocatable nobsvar
 
real(r8), dimension(:), allocatable obsval
 
real(r8), dimension(:), allocatable khmin
 
real(r8), dimension(:), allocatable uradial
 
real(r8), dimension(:), allocatable misfit
 
real(r8), dimension(:), allocatable cg_innov
 
logical, dimension(:), allocatable lsadd
 
real(dp), dimension(:,:), allocatable cg_zu
 
logical, dimension(:), allocatable lsen4dvar
 
real(r8), dimension(:,:), allocatable ad_obsval
 
logical, dimension(:), allocatable havenlmod
 
real(r8), dimension(:), allocatable bgerr
 
real(r8), dimension(:,:), allocatable ae_beta
 
real(r8), dimension(1000) g1
 
logical, dimension(:), allocatable wrote_zobs
 
real(dp), dimension(:,:), allocatable cg_ritzerr
 
real(r8), dimension(:,:), allocatable ae_zu
 
real(r8), dimension(:), allocatable obsangler
 
real(r8), dimension(:), allocatable tl_cg_innov
 
real(dp), dimension(:), allocatable tl_cg_qg
 
real(r8), dimension(:,:), allocatable ae_delta
 
logical, dimension(:), allocatable wrttlmod
 
real(r8), dimension(:), allocatable innovation
 
logical, dimension(:), allocatable wrtnlmod
 
real(dp), dimension(:), allocatable ad_cg_gnorm_v
 
real(r8), dimension(:), allocatable ad_zgrad0
 
real(r8), dimension(:), allocatable ad_jb0
 
logical, dimension(:), allocatable wrtforce
 
real(r8), dimension(:,:,:), allocatable vcglev
 
real(dp), dimension(:,:), allocatable cg_tau
 
real(r8), dimension(:), allocatable cg_beta0
 
real(r8), dimension(:), allocatable obsscale
 
real(r8), dimension(:), allocatable obserr
 
real(r8), dimension(:), allocatable tl_zgrad0
 
real(r8), dimension(:), allocatable obsmeta
 
real(dp), dimension(:,:), allocatable cg_greduc
 
logical, dimension(:), allocatable load_zobs
 
integer, dimension(:), allocatable obstype
 
real(r8), dimension(:,:), allocatable gsmatrix
 
real(r8), dimension(:,:), allocatable dtsizeh
 
real(r8), dimension(:), allocatable jb0
 
real(dp), dimension(:,:,:), allocatable cg_zv
 
real(dp), dimension(:), allocatable tl_cg_delta
 
real(dp), dimension(:), allocatable cg_gnorm
 
logical, dimension(:), allocatable wrtimpact_tot
 
integer, dimension(:,:), allocatable nvstepsb
 
logical, dimension(:), allocatable haveobsmeta
 
real(r8), dimension(:), allocatable bgthresh
 
real(dp), dimension(:), allocatable ad_cg_gnorm
 
real(r8), dimension(:), allocatable vgrad0s
 
real(r8), dimension(:,:), allocatable tl_zcglwk
 
real(dp), dimension(:), allocatable tl_cg_beta
 
logical, dimension(:), allocatable havetlmod
 
real(r8), dimension(:), allocatable ad_vgrad0s
 
real(r8), dimension(:), allocatable ad_cg_pxsave
 
real(r8), dimension(:), allocatable forcetime
 
subroutine, public allocate_fourdvar
 
real(r8), dimension(:), allocatable tl_obsscale
 
integer, dimension(nweights), parameter joffset
 
integer, dimension(:), allocatable nsurvey
 
real(r8), dimension(:), allocatable kvmin
 
real(r8), dimension(:), allocatable admodval
 
subroutine, public initialize_fourdvar
 
real(r8), dimension(:), allocatable zobs
 
real(dp), dimension(:,:), allocatable cg_alpha
 
real(dp), dimension(:), allocatable ad_cg_qg
 
real(r8), dimension(:), allocatable ae_trace
 
real(r8), dimension(:,:,:), allocatable zcglwk
 
real(r8), dimension(:,:), allocatable dtsizevb
 
real(r8), dimension(:), allocatable tl_jb0
 
logical, dimension(:), allocatable wrtobsscale
 
real(r8), dimension(:), allocatable vgrad0
 
real(r8), dimension(:,:), allocatable ae_tmatrix
 
real(r8), dimension(:), allocatable nlmodval
 
real(r8), dimension(:,:), allocatable gsmatinv
 
real(r8), dimension(:), allocatable ad_cg_innov
 
real(r8), dimension(:), allocatable residual
 
real(r8), dimension(:), allocatable nlincrement
 
real(dp), dimension(:,:), allocatable cg_delta
 
real(dp), dimension(:,:), allocatable cg_gamma
 
logical, dimension(:), allocatable lobspace
 
real(r8), dimension(:), allocatable tl_obserr
 
real(dp), dimension(:), allocatable tobs
 
integer, dimension(:), allocatable ntimes_ana
 
real(r8), dimension(:), allocatable zlanczos_offdiag
 
real(r8), dimension(:), allocatable khmax
 
real(r8), dimension(:), allocatable unvetted
 
integer, dimension(nweights), parameter ioffset
 
real(dp), dimension(:), allocatable ad_cg_beta
 
real(r8), dimension(:,:), allocatable ae_ritz
 
integer, dimension(:), allocatable obssurvey
 
real(dp), dimension(:), allocatable ad_cg_delta
 
real(r8), dimension(:), allocatable xobs
 
real(r8), dimension(:,:), allocatable ae_ritzerr
 
integer, dimension(:), allocatable obsstate2type
 
real(r8), dimension(:,:), allocatable dtsizev
 
real(r8), dimension(:), allocatable vgnorm
 
real(r8), dimension(:), allocatable yobs
 
real(r8), dimension(:,:), allocatable gmze
 
real(dp), dimension(:), allocatable cg_gnorm_y
 
logical, dimension(:), allocatable lweakrelax
 
character(len=40), dimension(:), allocatable obsname
 
logical, dimension(:), allocatable wrtzetaref
 
real(r8), dimension(:,:), allocatable ae_zv
 
real(r8), dimension(:), allocatable ad_cg_pxout
 
real(r8), dimension(:), allocatable tl_cg_pxsave
 
real(r8), dimension(:,:), allocatable ad_vcglwk
 
integer, dimension(:), allocatable nstatevar
 
integer, dimension(:), allocatable nstrobs
 
real(r8), dimension(:), allocatable tl_vgrad0
 
real(r8), dimension(:,:), allocatable admodval_s
 
integer, dimension(:), allocatable rscheme
 
real(r8), dimension(:,:), allocatable zlanczos_inv
 
real(dp), dimension(:), allocatable tl_cg_gnorm_v
 
real(r8), dimension(:,:), allocatable jobs
 
logical, dimension(:), allocatable processobs
 
real(r8), dimension(:,:), allocatable zlanczos_err
 
real(r8), dimension(:,:), allocatable zlanczos_coef
 
integer, parameter nweights
 
real(r8), dimension(:,:), allocatable zgrad0
 
integer, dimension(:,:), allocatable nhstepsb
 
integer, dimension(:), allocatable nendobs
 
type(t_io), dimension(:), allocatable obs
 
character(len=256) sourcefile
 
integer, parameter io_nf90
 
integer, parameter io_pio
 
character(len=maxlen), dimension(6, 0:nv) vname
 
integer, dimension(:), allocatable idsvar
 
character(len=100), dimension(mdims) dim_name
 
integer, dimension(mdims) dim_size
 
subroutine, public netcdf_get_dim(ng, model, ncname, ncid, dimname, dimsize, dimid)
 
integer, dimension(:), allocatable nbico
 
type(t_bounds), dimension(:), allocatable bounds
 
real(r8), dimension(:), allocatable dmem
 
integer, dimension(:), allocatable nt
 
subroutine, public pio_netcdf_get_dim(ng, model, ncname, piofile, dimname, dimsize, dimid)
 
character(len(sinp)) function, public uppercase(sinp)
 
logical function, public founderror(flag, noerr, line, routine)