!-------------------------------------- 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 SPA2SPSV 2,3
#if defined (DOC)
*
***s/r SPA2SPSV - SV enhancement for SPA2SP
*
*Author : Mark Buehner *ARMA/AES August, 2002
*
* NOTE: Called after SPGD
*
*Arguments
* -NONE-
#endif
IMPLICIT NONE
*implicits
#include "comdim.cdk"
#include "comgd0.cdk"
#include "comgd1.cdk"
#include "comsv.cdk"
*
INTEGER JK1,jsv,JJ,JI
real*8 zfact1,zfact2
c
c MODE 0: DO NOTHING
c
IF(NSVMODE.eq.0) then
RETURN
ENDIF
c
c Set existing component to zero
c
IF(NSVMODE.eq.1) call transfer
('ZGD0')
call transfer
('ZGD1')
c
c Construct SV component
c
DO JSV=1,NSV
DO JI=1,NI
DO JK1 = 1,NKGDIM
DO JJ=1,NJ
GD1(JI,JK1,JJ)=GD1(JI,JK1,JJ)+SVGD(JI,JK1,JJ,JSV)*SVCONTR(JSV)
ENDDO
ENDDO
ENDDO
ENDDO
c
c Add SV component to homogeneous-isotropic component
c
ZFACT1=SCALEHI
IF(ZFACT1.gt.0.0) THEN
ZFACT1=sqrt(ZFACT1)
ELSE
ZFACT1=0.0
ENDIF
ZFACT2=SCALESV
IF(ZFACT2.gt.0.0) THEN
ZFACT2=sqrt(ZFACT2)
ELSE
ZFACT2=0.0
ENDIF
DO JI=1,NI
DO JK1 = 1,NKGDIM
DO JJ=1,NJ
GD(JI,JK1,JJ)=ZFACT1*GD(JI,JK1,JJ)+ZFACT2*GD1(JI,JK1,JJ)
ENDDO
ENDDO
ENDDO
c
CALL TRANSFER
('ZGD1')
c
RETURN
END