!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
! version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!
subroutine oda_sqrtBT(da_v,na_vdim) 5,12
use modstag
, only : lstagwinds
USE procs_topo
implicit none
! Dummies
integer :: na_vdim ! dimension of the model state in error covariance space
real*8, dimension(na_vdim) :: da_v ! model state in error covariance space
!
!Purpose:
!Transforms model state from grid point space to error covariance space.
!
!Author : S. Pellerin *ARMA/MRB January 2009
! Based on transformations involved in evaljo.ftn
! as written by P. Gauthier *ARMA/AES in June, 1993
!
!Revision:
! Luc Fillion - ARMA/EC - 9 May 2009 - 3dvar GU/LU Upgrade to v_10_2_2.
! Luc Fillion - ARMA/EC - 13 Jul 2009 - Hemispheric mode implementation.
! Luc Fillion - ARMA/EC - 11 May 2010 - Limit printout to processor 0.
!
#include "comlun.cdk"
#include "comdim.cdk"
#include "comcva.cdk"
#include "comsv.cdk"
#include "comgrd_param.cdk"
#include "comin.cdk"
! Local declarations
real*8, dimension(na_vdim) :: dl_v
real*8 zdlgnorm
dl_v = 0.d0
call tmg_start(51,'VAR_CH') !
IF(NSVMODE.gt.0) CALL SPA2SPADSV
if(grd_typ.eq.'GU') then
if(nanalvar.eq.4) then
CALL SPA2GDAD
else
if(lcva_hemis) then
call tmg_start(54,'acv2spgl') !
call acv2gdgl
call tmg_stop(54) !
else
if (lstagwinds) then
call tmg_start(52,'stagwinds_ad') !
call stagwinds_ad
(nulout)
call tmg_stop(52) !
else
call tmg_start(53,'SPGDA') !
CALL SPGDA
call tmg_stop(53) !
end if
CALL SPA2SPAD
endif
endif
else if (grd_typ.eq.'LU') then
call acv2gd
endif
call tmg_start(55,'CAINAD') !
IF(NPRECON.ge.1) THEN
CALL CAINAD
(na_vdim,dl_v)
CALL CAINAD2
(na_vdim,dl_v,da_v)
ELSE
CALL CAINAD
(na_vdim,da_v)
ENDIF
call tmg_stop(55) !
!cluc if(lmin) then
! miter=miter+1
! call prscal(na_vdim,da_v,da_v,zdlgnorm)
! zdlgnorm = sqrt(zdlgnorm)
! rgradj(miter)=zdlgnorm
! IF(myid == 0) THEN
! write(nulout,*) 'oda_sqrtBT: miter, |Grad J| = ',miter,zdlgnorm
! endif
!cluc else
!cluc miter=0
!cluc endif
call tmg_stop(51) !
end subroutine oda_sqrtBT