!-------------------------------------- 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 PTOT1 1,5
#if defined (DOC)
*
***s/r PTOT1  - Control of Pb -> T,Ps operator Estimation at level 1
*               Use same setup as for correlations
*
*Author: Mark Buehner  1998
*
*Revision:
*     . M. Buehner  May 2008
*     .             Added call to ptot2_2 when using new approach
*                   for PtoT with localized Tb correlations (NANALVAR=4)
*
*Arguments:  NONE
*
#endif
      IMPLICIT NONE
*implicits
#include "comlun.cdk"
#include "comdim.cdk"
#include "comcva.cdk"
*
      INTEGER IULSTAT, IULCORNS, IULSTDEV, INPTS
C
      WRITE(NULOUT,FMT=9000)
 9000 FORMAT(//,3(" *****************"),/,6X
     S     ," PTOT1- COMPUTATION OF PB->T,LNPS OPERATOR",/
     S     ,3(" *****************"),/
     S     ,"  -- REVISED VERSION 8.02 --")
C
C        1. PRELIMINARY INITIALIZATIONS
C     .  (READ THE NAMELISTS NAMCSE1 AND NAMCVA)
C        THIS INCLUDES ALL THE INPUT FILENAMES FOR REGRESSION
 100  CONTINUE
C
      IULSTAT   = 54
      IULCORNS  = 55
      IULSTDEV  = 56
C
C     USE SAME SETUP AS FOR ESTIMATING THE CORRELATIONS
C
      CALL SU1CSE1(IULSTAT,IULCORNS,IULSTDEV)
C
 200  CONTINUE
C
C     .  2.1  ESTIMATE THE OPERATOR FOR THE ENSEMBLE
C
 210  CONTINUE
      if(nanalvar.eq.4) then
        CALL SUMASKLAT
        CALL PTOT2_2(IULSTAT,IULCORNS,IULSTDEV)
      else
        CALL PTOT2(IULSTAT,IULCORNS,IULSTDEV)
      endif
C
C     .  2.2  WRITE OUT THE OPERATOR
C     .
      CALL WRITEPTOT
C
      RETURN
      END