!-------------------------------------- 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 DIAG3DLA,1
#if defined (DOC)
*
***s/r DIAG3DLA - diagnostics in the post-processing of the model state
* . and analysis increments for Mesovar LAM analysis.
*
*Author : L. Fillion *ARMA/EC Feb 2005.
* .
*Revision:
*
*Arguments
* i- CDPPTYP : type of post-processing
* .
* . 'STAT' Model state contained in COMSP
* . 'GRID' Grid-point fields contained in COMGD
* .
* . 'XMXG' Total analysis increment
* . (COMSP - COMSPG)
* . 'XMXK' Analysis increment with respect to
* . a given reference state kept on file
* . (Current model state is assumed to be in
* . COMSP)
#endif
C
IMPLICIT NONE
#include "taglam4d.cdk"
#include "pardim.cdk"
#include "comdim.cdk"
#include "comlun.cdk"
#include "comgrd_param.cdk"
#include "comcst.cdk"
#include "comcva.cdk"
#include "comgd0.cdk"
#include "comgd1.cdk"
#include "comgem.cdk"
#include "comleg.cdk"
#include "comsp.cdk"
#include "comsp1.cdk"
#include "localpost.cdk"
#include "comstate.cdk"
!#include "comweight.cdk"
*
* Arguments
*
CHARACTER*4 CDPPTYP
*
* Local variables
*
logical llhelm
INTEGER JLEV, JLA, ILEV,ILEN, JLAT, ILON, JLON, IERR
integer ji,jj
INTEGER IKTOP,IKTTG
REAL*8 ZRA2, ZCORIOLIS
real*8 zetae1, ztfac, zcon, zttgcon
C
WRITE(NULOUT,FMT='(/,4X,"Starting DIAG3DLA",//)')
C
C 1. Obtain streamfunction and velocity potential in physical space
C --------------------------------------------------------------
C
! call sp2pcgd(zpsi,zuc,zttu) ! Get Psi, Chi_u, T_u
!
! do jj = 1, nj
! do ji = 1, ni
! zpsu(ji,jj) = gps0(ji,1,jj)
! enddo
! enddo
C
C 2 Obtain Vorticity and Divergence in physical space
C -------------------------------------------------
C
! call pc2zd_c(zqr,zdd,zpsi,zuc)
c
c *** ES ***
c
! if (chum .eq. 'LQ') then
! call lq2esgd(zes,zttg,zhug,zpsg,zpt,ni,nj,nflev)
! endif
c
c *** VT ***
c
c Use "b" fields as work array for the moment
c
do jj = 1, nj
do ji = 1, ni
do jlev = 1, nflev
zttb(ji,jlev,jj) = tt0(ji,jlev,jj)
enddo
zpsb(ji,jj) = gps0(ji,1,jj)
enddo
enddo
call lt2tvgd
(ztv,zttb,zhug,ni,nj,nflev)
c
c *** GZ ***
c
!
! call ltt2phigd(zgz,ztv,zpsb,zpsg) ! Total GZ
!
! *** Balanced T and ps ***** - zttu(ji,jlev,jj)
!
! do jj = 1, nj
! do ji = 1, ni
! do jlev = 1, nflev
! zttb(ji,jlev,jj) = tt0(ji,jlev,jj) - zttu(ji,jlev,jj)
! enddo
! zpsb(ji,jj) = gps0(ji,1,jj) - zpsu(ji,jj)
! enddo
! enddo
c
c *** GZ (Balanced, Unbalanced) ***
c
c ETA coordinates
c ---------------
c
! call ltt2phigd(zgzb,zttb,zpsb,zpsg) ! Balanced GZ
! call ltt2phigd(zgzu,zttu,zpsu,zpsg) ! Unbalanced GZ
C
LVARDIAG=.true.
C
RETURN
END