SUBROUTINE DEFRUN

!**** SUBROUTINE DEFRUN - DEFINE RUN CONTROL PARAMETERS

!        D. VASILJEVIC   ECMWF     27/02/90

!     PURPOSE
!     -------
!        DEFINE ANALYSIS RUN CONTROL PARAMETERS

!**   INTERFACE
!     ---------
!        DEFRUN IS CALLED FROM SUBROUTINE SUOBS

!     METHOD
!     ------
!        DEFAULT VALUES ARE ASSIGNED TO THE RUN CONTROL PARAMETERS.

!     EXTERNALS
!     ---------

!     MODIFICATIONS
!     -------------
!     97-10-30 Per Unden - add variational quality control for TEMP T
!     98-05-11 Elias Holm - add variational quality control for ozone thickness
!     98-05-15 Erik Andersson - Changed BgQC limits, in namelist.
!     99-04-25 Rose Munro - Changed BgQC for 1C Radiances (only Geos so far)
!     99-04-26 Rose Munro - Added screening parameters for Geos
!     99-01-15 Elisabeth Gerard - SSM/I PWC and WSP have a different thinning
!     99-02-26 Elisabeth Gerard - SSM/I Wind Speed VarQC
!     99-07-15 Wafaa.Sadiki, C.Soci - move the thinning parameters for moving platforms in namelist
!     00-06-15 g.kelly  rad1c   Added screening parameters
!     00-04-04 P. Moll : change thresholds for SATOBS and AIREPS
!     01-11-29 Antje Dethof: turn on varqc for total ozone and change parameters
!     02-05-03 Zahra Sahlaoui - NTSLVSTST initialisation for 3dvar
!     03-07-03 Christophe Payan : MF thinning for SATAMs (GEOWINDs or AMVs or SATOBs in BUFR format)
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        T.McNally     01-Apr-2004 Supply AIRS obs error from file
!     03-11-25 David Tan - Variables for Analysis Ensembles
!     04-04-13 Dick Dee : change obs errors for activated screening channels
!     04-08-06 Antje Dethof: Add lreo3thin_no_sq
!     04-10-27 Sean Healy : Introduce the GPS RO information
!     04-12-23 Niels Bormann : RARAD becomes LIMB; introduce limb radiances
!     05-03-23 Matt Szyndel: Add MTSAT and FY-2
!     05-04    Chris Payan: NICESEAMASK initialisation (default, MF and ECMWF)
!                            controlled by NAMSCC
!     06-02-05 P Bauer, G Kelly, N Bormann: Add AMSRE, SSMIS, TMI
!     05-05-09 Antje Dethof: Introduce GRG variables
!     06-03-27 Paul Poli: Introduce thinning for GPSRO
!     07-04    Chris Payan: LMKCMARPL becomes a 2D array
!     07-04    Chris Payan: merge with dal_CY32_ASCAT branch
!     07-04    Chris Payan: L_SCAT_BIASSIG, NSCAT5_RQC and WSCAT5_FAC added
!     09-05-07 F. Karbou, read emissivity atlases (files are to be replaced by a dynamical update)
!     05-06-20 Richard Engelen: Introduce GHG variables
!     06-11-01 Andrew Collard : Add IASI
!     06-12-01 Andrew Collard: Define AIRS/IASI cloud detection parameters here
!     06-03-24 David Tan: Introduce Aeolus (Doppler Wind Lidar)
!     07-02-23 Vincent Guidard: Add IASI (after Andrew Collard)
!     07-10-04 Samuel Westrelin - activate variational QC for PAOB wind
!     07-11-15 Hans Hersbach: NSCAWSOLMAX - max number of scatt ambiguities
!                             LQSCATAZI   - T perform QC on azimuth diversity for QuikSCAT
!     08-04-16 Hans Hersbach : add switch for assimilation of scatt as neutral wind
!     29-Jan-2009 B.Krzeminski: added initialization of mw surface emissivity Kalman Filter
!     08-11    Chris Payan: LSCATT_NEUTRAL added (Neutral Obs. Op., for Scatt)
!     09-01    Chris Payan: old thinning pruning (>=CY35T2)
!     09-02-05 W. Bell : Introduce Windsat information
!     09-03-09 Qifeng Lu     : add FY3A instrument (IRAS, MWTS, MWHS, and MWRI)
!     09-12    H.Hersbach: LVDFTRAJ/LVDFMIN - get surf info/perts in 4dvar from vdfmain in ec_phys
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE PARCMA   , ONLY : JPMXOTP  ,JPMXOCT  ,JPMXVAR
USE PARDIMO  , ONLY : JPNOTP   ,JPXVAR   ,JPHUBLEV
USE PARERR   , ONLY : JPMXESLV
USE YOMDIMO  , ONLY : NACTIM
USE YOMDIM   , ONLY : NFLEVG
USE YOMCT0   , ONLY : NCONF    ,LCANARI  ,LSCREEN  ,NSTART   ,NSTOP    ,NPROC
USE YOMDYN   , ONLY : TSTEP
USE YOMCT0B  , ONLY : LECMWF
USE YOMLUN   , ONLY : NULOUT   ,NULNAM   ,NULUSR3
USE YOMANCS  , ONLY : RMDI     ,RSQRT2PI ,RDEGREES
USE YOMOBS
USE YOMCOSJO , ONLY : NOTVAR   ,NITERQC  ,&
 & NGCVVAR  ,RBGQC_RAD1C,RAQC_RAD1C,RLQC_RAD1C      ,&
 & ROERR_RAD1C,ROERR_QSCAT,ROERR_OSCAT, LOW_MODIS_AMV_ERR,&
 & RAQC     ,RLQC     ,&
 & RTCEFT   ,RTCPART  ,LVARQCG  ,LQVARQC  ,LVARQC   ,&
 & LQSCATT  ,LTC      ,NTCOBS   ,NTCOBS_L ,NTCLOC   ,&
 & LOBSCOR  , LOBSCORDIAG, LPRINT_OBSCOR_MATR,   NBCORBLK, NOVERTRUN, NSMAX_OBSCOR, EIGMIN, &
 & LRANDOM_OBSCOR,  OBSLATDIAG, OBSLONDIAG, OBSHSCALE, LOBSCOR_SATOB, &
 & LOBSCOR_AMSUA, LOBSCOR_SPLIT, RBGQC    ,NVAR , &
 & LVARQC_RAD1C, LHUBERMINQC, LHUBERMINQCG, LHUBERBGQCG   ,&
 & LHUBERBGQC, &
 & NHLSFGOPT, ZHLSFGOPT, &
 & NVAR_HLS ,&
 & NVAR_U   ,NVAR_U10 ,NVAR_T   ,NVAR_Z   ,NVAR_PS  ,&
 & NVAR_H   ,NVAR_H2  ,NVAR_Q   ,NVAR_DZ  ,NVAR_PWC ,NVAR_TO3 ,&
 & NVAR_FF  ,NVAR_RAD ,NVAR_APD ,NVAR_RO  ,NVAR_AOD, NVAR_LRA ,&
 & NVAR_GHG,NVAR_GRG, NVAR_RFL , NVAR_DOW, &
 & NVAR_COD, NVAR_RAO, NVAR_RFA, NVAR_ODA, WSCAT5_FAC, WSCAT6_FAC,&
 & NBDLAYER, NTROPOP, &
 & CVAR_GRG, &
 & RHUBEROETUNING, RHUBERLEFT, RHUBERRIGHT, RHUBERBGQC, &
 & RHUBERBGQC_SONDEGOOD, RHUBERBGQC_SONDEOK, NPRTBINS
USE YOMSCC   , ONLY : LSCDPR   ,LSCRE4D  ,RMIND_TOV,RFIND_TOV,&
 & RMIND_SSMI,RFIND_SSMI_PWC,RFIND_SSMI_WSP,&
 & RMIND_SATOB,RFIND_SATOB,RFIND_AIREP,RMIND_SATAM,&
 & RFIND_SATAM,RMIND_RAD1C,RFIND_RAD1C,&
 & RMIND_SCATT_ERS, RFIND_SCATT_ERS,NTHINSCA,&
 & RMIND_GPSRO,RFIND_GPSRO,&
 & RMIND_RADAR, RFIND_RADAR,&
 & FL_MAXSPEED,LTARGDROP, NICESEAMASK, NSCAT5_RQC, NSCAWSOLMAX,LQSCATAZI,&
 & LOSCATAZI,LPERTURB, NAENSEMBLE, NAEMEMBER, SELAIREPPRE, &
 & RAIREPTHIN, RAIREPPCENTTHIN, RAIREPTOPPRES
USE YOMVAR   , ONLY : LAVCGL , LCO2,  LTSCV, L3DFGAT
USE YOMTVRAD , ONLY : MSENSOR_METEOSAT,MSENSOR_HIRS,MSENSOR_MSU,&
 & MSENSOR_SSU,MSENSOR_AMSUA,MSENSOR_AMSUB,MSENSOR_SSMI,MSENSOR_SSMIS,&
 & MSENSOR_IRAS,MSENSOR_MWTS,MSENSOR_MWHS,MSENSOR_MWRI,&
 & MSENSOR_AMSRE,MSENSOR_TMI,MSENSOR_MHS, &
 & MSENSOR_VTPR1,MSENSOR_VTPR2,MSENSOR_GOESIMG, &
 & MSENSOR_AIRS,MSENSOR_IASI, &
 & MSENSOR_MSG,MSENSOR_MSG_HR,MSENSOR_MTSATIMG, MSENSOR_VISSR, &
 & MSENSOR_WINDSAT, &
 & M__NumAIRSChans, IASICHAN, MXSENSOR, MSENSOR_CHANCOUNT

USE YOMCOCTP , ONLY :  NSYNOP   ,NSRSCD   ,NATSCD   ,&
 & NSHSCD   ,NABSCD   ,NSHRED   ,NATSHS   ,NAIREP   ,&
 & NAIRCD   ,NSATOB   ,NDRIBU   ,NDRICT   ,NDRBCD   ,&
 & NTEMP    ,NTEMCT   ,NLDTCD   ,NPILOT   ,NPILCT   ,&
 & NLDPCD   ,NSATEM   ,NPAOB    ,NSCATT   ,NLIMB    ,&
 & NRADAR   ,NMETAR   ,NAMDAR   ,NACARS   ,MNOCTP   ,&
 & NCOLBA   ,NCODAR   ,NSYRCD   ,NRADOH   ,&
 & NTEMPSQ  ,NSCATTSQ ,NSCAT2SQ ,NTDROP
USE YOMCST   , ONLY : RA
USE YOMMKODB
USE YOMANA   , ONLY : NANDAT   ,NANTIM   ,NANMIN
USE YOMECTAB , ONLY : NTSLVSTST,NTSLOTNOS,NTSLOTNOE
USE YOMMP    , ONLY : MYPROC 
USE YOM_YGFL , ONLY : JPGRG, JPGHG
USE YOMSTA   , ONLY : STPRE 
USE MPL_MODULE
USE YOMTS    , ONLY : TSCVER
USE GOMS_MIX     , ONLY : NUSE_ECCI
USE PARERSCA , ONLY : JPQCELL,JPICELL
USE YOMPHY   , ONLY : LBLVAR
USE YOMEMIS  , ONLY : LATLAS_EMIS, LDYN_EMIS, LDYN_TSKIN, MEMIS_CHAN, &
                    & DATA_EMIS_AN1, DATA_EMIS_AN2, DATA_MODEL, ATLAS_SSMI, &
                    & TOT_EM_AN1, TOT_EM_AN2, TOT_EM_SSMI

IMPLICIT NONE

!     EXTERNAL INTEGER FUNCTIONS
INTEGER(KIND=JPIM), EXTERNAL :: IYMD2CD

#include "namobs.h"
#include "namjo.h"
#include "namscc.h"
#include "nammkodb.h"
#include "namts.h"

!     VARQC Statement Functions to obtain A-Parameter from
!     dimension-less rejection limit (ZREJLIM from namelist), AND L.
!     RAW_VARQC is for wind data, RA_VARQC for all else.
REAL(KIND=JPRB) :: RA_VARQC,RAW_VARQC,ZREJLIM,ZL,ZTBERROR
REAL(KIND=JPRB) :: ZAIREP(NFLEVG),ZHUB

INTEGER(KIND=JPIM) :: IPRT,ICHAN,IVAR,IOBTYP,IRET
INTEGER(KIND=JPIM) :: IOMASTER, ITAG, IOS, IERR
INTEGER(KIND=JPIM) :: JOTP,JVAR,JCT,J1,J2,J3,JJ,IAIREPLEV,IBOT,JGRG,JGHG, &
                       & JLEV,JOCT,JOBT,JCTP
INTEGER(KIND=JPIM) :: INIU1,IKCHAN,INCHAN,JCHAN,IOBT,ICDT,ICTP(JPMXOCT), &
                       & IOBTTEMP, IOBTPILOT, INOCTP, IOBSTYP, ICODETYP
INTEGER(KIND=JPIM) :: IHUB, IIOBT, IICTP

CHARACTER(LEN=120) :: clrmtberr_text ,CLFMT_LMKCMARPL
INTEGER(KIND=JPIM) :: INIEMIS1, ISENSOR
LOGICAL            :: llatlas1, llatlas2
   
REAL(KIND=JPRB) :: ZHOOK_HANDLE

RA_VARQC(ZREJLIM,ZL)=1.0_JPRB/((RSQRT2PI/(2.0_JPRB*ZL))/3._JPRB &
 & *EXP(ZREJLIM*ZREJLIM/2.0_JPRB)+1.0_JPRB)  
RAW_VARQC(ZREJLIM,ZL)=1.0_JPRB-SQRT(1.0_JPRB-1.0_JPRB/((RSQRT2PI/(2.0_JPRB*ZL))**2.0_JPRB/ &
 & 3._JPRB *EXP(ZREJLIM*ZREJLIM/2.0_JPRB)+1.0_JPRB))  

!     HUBERQC Observation error reduction statement function
!     Observation errors are reduced to represent the gaussian part of the
!     huber distribution. It is a function of (HUBERLEFT+HUBERRIGHT)/2.
REAL(KIND=JPRB) :: ROE_HUBER,ZHUBERLEFT,ZHUBERRIGHT
ROE_HUBER(ZHUBERLEFT,ZHUBERRIGHT)=min(1.0_JPRB,0.5_JPRB+ &
 & 0.25_JPRB*((ZHUBERLEFT+ZHUBERRIGHT)/2.0_JPRB))

#include "abor1.intfb.h"
#include "cloud_detect_setup.intfb.h"
#include "posnam.intfb.h"
#include "read_iasichans.intfb.h"
#include "suemis_conf.intfb.h"
#include "tslvstst.intfb.h"
#include "cmoctmap.intfb.h"

!     ------------------------------------------------------------------
!*       1.       DEFINE DEFAULT VALUES
!                 ---------------------

!*         1.2   DEFINE DEPARTURES/UPDATES TO BE SAVED

IF (LHOOK) CALL DR_HOOK('DEFRUN',0,ZHOOK_HANDLE)
OBNLATE= 90._JPRB
OBSLATE=-90._JPRB
OBWLONE=-180._JPRB
OBELONE= 180._JPRB
EXNLAT=  90._JPRB
EXSLAT= -90._JPRB
EXWLON=-180._JPRB
EXELON= 180._JPRB

!     LCAPACH  USE APACHE in HOP for TEMP and PILOT
LCAPACH=.NOT. LECMWF .AND. (NCONF /= 131)

!     LCACHMT  USE ACHMT in HOP 
LCACHMT=.NOT. LECMWF

!     LOBCLN : CLEANING OF OBF FOR MF
LOBCLN=.NOT. LECMWF .AND. (NCONF /= 131)

!*         1.5   OBSERVATION INTERPOLATION TECHNIQUE

NOBSHOR = 203

!*         1.6   SEA/LAND REJECTION SWITCH

LHDREJ=.TRUE.
LHDRW10=.TRUE.
LHDRT2=.FALSE.
LHDRRH2=.FALSE.
IF (LCANARI) THEN
  LSLREJ=.FALSE.
ELSE
  LSLREJ=.TRUE.
ENDIF
LSLRW10=.TRUE.
LSOE=.FALSE.
LSLRT2=.FALSE.
LSLRRH2=.FALSE.

!*          1.7 USE OF QUADRATIC COST FUNCTION FOR SCATT
!               WEIGHT REDUCTION FACTOR FOR SCAT5 (QSCAT)

LQSCATT = .FALSE.
WSCAT5_FAC=0.25_JPRB
WSCAT6_FAC=0.25_JPRB

!*         1.8  LVARQCG : VAR-QC GLOBAL SWITCH,
!*              LQVARQC : QUADRATIC VAR-QC SWITCH, AND
!*              LVARQC  : SWITCH, BY VARIABLE AND OBS. TYPES
!*              RAQC    : GROSS ERR PROB. BY VARIABLE AND OBS. TYPES
!*              RLQC    : RANGE OF POSSIBLE VALUES, IN STD DEVIATIONS
!*              RBGQC :  Background check limits. Flag 1,2,3
!*              RBGQC_RAD1C : Background check limits - 1c radiances. 

LVARQCG=LECMWF
LQVARQC=.TRUE.
LVARQC(:,:) = .FALSE.
RAQC  (:,:) = RMDI
RLQC  (:,:) = RMDI
RBGQC (:,:,:) = RMDI

LVARQC_RAD1C(:)   = .FALSE.
RAQC_RAD1C(:,:) = RMDI
RLQC_RAD1C(:,:) = RMDI
RBGQC_RAD1C(:,:,:) = RMDI
ROERR_RAD1C(:,:) = RMDI


!*              LHUBERMINQC : HUBER-SWITCH, BY VARIABLE AND OBS. TYPES
LHUBERMINQC(:,:) = .FALSE.
LHUBERMINQCG = LECMWF
LHUBERBGQC(:,:) = .FALSE.
LHUBERBGQCG = LECMWF

!* Default limits for the Background check.
DO JOTP=1,JPNOTP
  RBGQC (NVAR_U,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_U10,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_T,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_Z,JOTP,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)
  RBGQC (NVAR_PS,JOTP,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)
  RBGQC (NVAR_H,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_H2,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_Q,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_DZ,JOTP,1:3) = (/2.25_JPRB,5.06_JPRB,7.56_JPRB/)
  RBGQC (NVAR_PWC,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_TO3,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_AOD,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_HLS,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_RFL,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_DOW,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  DO JGRG=1,JPGRG
    RBGQC (NVAR_GRG(JGRG),JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  ENDDO
  DO JGHG=1,JPGHG
    RBGQC (NVAR_GHG(JGHG),JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  ENDDO
  RBGQC (NVAR_COD,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_RAO,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_RFA,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_ODA,JOTP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
ENDDO

RHUBERLEFT (:,:,:,:) = 99.9_JPRB 
RHUBERRIGHT(:,:,:,:) = 99.9_JPRB
RHUBERBGQC (:,:,:,:,1) = 9.0_JPRB
RHUBERBGQC (:,:,:,:,2) = 16.0_JPRB
RHUBERBGQC (:,:,:,:,3) = 25.0_JPRB
RHUBEROETUNING(:,:,:,:) = 1.0_JPRB

!*          1.8.1 SYNOP

!* Wind surface and upper-air
DO JLEV=1,JPHUBLEV
  !*          'SYNOP Land Manual Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NSRSCD,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB 
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
  !*          'SYNOP Shred Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NSHRED,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
  !*          'SYNOP Land Automatic Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NATSCD,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)
  !*          'French SYNOP Land Automatic Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NSYRCD,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)
  !*          'SYNOP French Radome Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NRADOH,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)
  !*          'SYNOP Ship Manual Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NSHSCD,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 0.9_JPRB 
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 0.9_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
 !*          'SYNOP Ship abbreviated               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NABSCD,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 0.9_JPRB
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 0.9_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
  !*          'SYNOP Ship Automatic Report               '
  CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NATSHS,IOBT,ICDT)
  RHUBERLEFT (NVAR_U,ICDT,IOBT,JLEV) = 0.9_JPRB 
  RHUBERRIGHT(NVAR_U,ICDT,IOBT,JLEV) = 1.1_JPRB
  RHUBERBGQC (NVAR_U,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_U10,ICDT,IOBT,JLEV) = 1.1_JPRB 
  RHUBERRIGHT(NVAR_U10,ICDT,IOBT,JLEV) = 1.2_JPRB
  RHUBERBGQC (NVAR_U10,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB 
  RHUBERRIGHT(NVAR_T,ICDT,IOBT,JLEV) = 1.0_JPRB
  RHUBERBGQC (NVAR_T,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.2_JPRB 
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.4_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
ENDDO

LVARQC(NVAR_U,NSYNOP) =.TRUE.
RAQC  (NVAR_U,NSYNOP) = 0.00001_JPRB
RLQC  (NVAR_U,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_U,NSYNOP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
LVARQC(NVAR_U10,NSYNOP) =.TRUE.
RAQC  (NVAR_U10,NSYNOP) = 0.00001_JPRB
RLQC  (NVAR_U10,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_U10,NSYNOP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
!* Temperature
IF (LBLVAR) THEN
RBGQC (NVAR_T,NSYNOP,1:3) = (/18.0_JPRB,32.0_JPRB,50.0_JPRB/)
ELSE
RBGQC (NVAR_T,NSYNOP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
ENDIF

!* Height
LVARQC(NVAR_Z,NSYNOP) = .TRUE.
RAQC  (NVAR_Z,NSYNOP) = 0.001_JPRB
RLQC  (NVAR_Z,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_Z,NSYNOP,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)

!* Relative Humidity
LVARQC(NVAR_H,NSYNOP) = .TRUE.
RAQC  (NVAR_H,NSYNOP) = 0.01_JPRB
RLQC  (NVAR_H,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_H,NSYNOP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* 2m Relative Humidity
LVARQC(NVAR_H2,NSYNOP) = .TRUE.
RAQC  (NVAR_H2,NSYNOP) = 0.01_JPRB
RLQC  (NVAR_H2,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_H2,NSYNOP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Surface Pressure
!*          'SYNOP METAR              '
CALL CMOCTMAP('CODETOSQ',NULOUT,NSYNOP,NMETAR,IOBT,ICDT)
DO JLEV=1,JPHUBLEV
  RHUBERLEFT (NVAR_PS,ICDT,IOBT,JLEV) = 1.6_JPRB 
  RHUBERRIGHT(NVAR_PS,ICDT,IOBT,JLEV) = 1.6_JPRB
  RHUBERBGQC (NVAR_PS,ICDT,IOBT,JLEV,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
ENDDO

LVARQC(NVAR_PS,NSYNOP) =.TRUE.
RAQC  (NVAR_PS,NSYNOP) = 0.001_JPRB
RLQC  (NVAR_PS,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_PS,NSYNOP,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)

!* Atm. Path Delay
LVARQC(NVAR_APD,NSYNOP) = .TRUE.
RAQC  (NVAR_APD,NSYNOP) = 0.01_JPRB
RLQC  (NVAR_APD,NSYNOP) = 5.0_JPRB
RBGQC (NVAR_APD,NSYNOP,1:3) = (/9.0_JPRB,4.0_JPRB,25.0_JPRB/)

!*          1.8.2 AIREP

!* Wind upper-air and temperature
!*          'AIREP, Aircraft data            '
!*          'AIREP, Aircraft data stratosphere  '
CALL CMOCTMAP('CODETOSQ',NULOUT,NAIREP,NAIRCD,IOBT,ICDT)
RHUBERLEFT (NVAR_U,ICDT,IOBT,1) = 1.3_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,1) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,1,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,1) = 1.2_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,1) = 0.9_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,1,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'AIREP, Aircraft data troposphere  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,2) = 1.3_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,2,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,2) = 1.5_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,2) = 1.5_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,2,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'AIREP, Aircraft data boundary layer  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,3) = 1.6_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,3) = 1.5_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,3,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,3) = 0.8_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,3) = 1.2_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,3,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'CODAR, Aircraft data stratosphere  '
CALL CMOCTMAP('CODETOSQ',NULOUT,NAIREP,NCODAR,IOBT,ICDT)
RHUBERLEFT (NVAR_U,ICDT,IOBT,1) = 1.3_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBT,1) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,1,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,1) = 1.2_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBT,1) = 0.9_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,1,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'CODAR, Aircraft data troposphere  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,2,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,2) = 1.5_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBT,2) = 1.5_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,2,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'CODAR, Aircraft data boundary layer  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,3) = 1.6_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBT,3) = 1.5_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,3,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,3) = 0.8_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBT,3) = 1.2_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,3,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'COLBA, Aircraft data stratosphere  '
CALL CMOCTMAP('CODETOSQ',NULOUT,NAIREP,NCOLBA,IOBT,ICDT)
RHUBERLEFT (NVAR_U,ICDT,IOBT,1) = 1.3_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBT,1) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,1,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,1) = 1.2_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBT,1) = 0.9_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,1,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'COLBA, Aircraft data troposphere  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,2,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,2) = 1.5_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBT,2) = 1.5_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,2,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'COLBA, Aircraft data boundary layer  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,3) = 1.6_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBT,3) = 1.5_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,3,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,3) = 0.8_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBT,3) = 1.2_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,3,1:3) = (/9.0_JPRB,196.0_JPRB,400.0_JPRB/)
!*          'AMDAR, Aircraft data            '
!*          'AMDAR, Aircraft data stratosphere  '
CALL CMOCTMAP('CODETOSQ',NULOUT,NAIREP,NAMDAR,IOBT,ICDT)
RHUBERLEFT (NVAR_U,ICDT,IOBT,1) = 0.7_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,1) = 0.7_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,1) = 1.5_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,1) = 1.2_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,1,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)
!*          'AMDAR, Aircraft data troposphere  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,2) = 1.2_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,2,1:3) = (/9.0_JPRB,484.0_JPRB,576.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,2) = 1.5_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,2) = 1.4_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
!*          'AMDAR, Aircraft data boundary layer  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,3) = 1.1_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,3) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,3) = 0.4_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,3) = 0.7_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,3,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)
!*          'ACARS, Aircraft data            '
!*          'ACARS, Aircraft data stratosphere  '
CALL CMOCTMAP('CODETOSQ',NULOUT,NAIREP,NACARS,IOBT,ICDT)
RHUBERLEFT (NVAR_U,ICDT,IOBT,1) = 1.4_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,1) = 1.4_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,1) = 1.4_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,1) = 1.3_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,1,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)
!*          'ACARS, Aircraft data troposphere  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,2) = 1.3_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,2) = 1.3_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,2,1:3) = (/9.0_JPRB,484.0_JPRB,576.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,2) = 1.3_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,2) = 1.3_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
!*          'ACARS, Aircraft data boundary layer  '
RHUBERLEFT (NVAR_U,ICDT,IOBT,3) = 1.6_JPRB 
RHUBERRIGHT(NVAR_U,ICDT,IOBT,3) = 1.5_JPRB
RHUBERBGQC (NVAR_U,ICDT,IOBT,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERLEFT (NVAR_T,ICDT,IOBT,3) = 1.0_JPRB 
RHUBERRIGHT(NVAR_T,ICDT,IOBT,3) = 1.2_JPRB
RHUBERBGQC (NVAR_T,ICDT,IOBT,3,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)

LVARQC(NVAR_U,NAIREP) = .TRUE.
RAQC  (NVAR_U,NAIREP) = 0.00006_JPRB
RLQC  (NVAR_U,NAIREP) = 5.0_JPRB
RBGQC (NVAR_U,NAIREP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Temperature
LVARQC(NVAR_T,NAIREP) = .TRUE.
RAQC  (NVAR_T,NAIREP) = 0.004_JPRB
RLQC  (NVAR_T,NAIREP) = 5.0_JPRB
RBGQC (NVAR_T,NAIREP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!*          1.8.3 SATOB

!* Wind upper-air
LVARQC(NVAR_U,NSATOB) = .TRUE.
RAQC  (NVAR_U,NSATOB) = 0.05_JPRB
RLQC  (NVAR_U,NSATOB) = 2.00_JPRB
RBGQC (NVAR_U,NSATOB,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)*0.1_JPRB
LOW_MODIS_AMV_ERR = .TRUE.

!*          1.8.4 DRIBU

!* Wind surface and upper-air
!*          'DRIBU  '
CALL CMOCTMAP('CODETOSQ',NULOUT,NDRIBU,NDRBCD,IOBT,ICDT)
DO JLEV=1,JPHUBLEV
  DO JOCT=1,NDRICT
    RHUBERLEFT (NVAR_U,JOCT,IOBT,JLEV) = 0.8_JPRB 
    RHUBERRIGHT(NVAR_U,JOCT,IOBT,JLEV) = 0.9_JPRB
    RHUBERBGQC (NVAR_U,JOCT,IOBT,JLEV,1:3) = (/9.0_JPRB,144.0_JPRB,196.0_JPRB/)
    RHUBERLEFT (NVAR_U10,JOCT,IOBT,JLEV) = 0.9_JPRB 
    RHUBERRIGHT(NVAR_U10,JOCT,IOBT,JLEV) = 1.0_JPRB
    RHUBERBGQC (NVAR_U10,JOCT,IOBT,JLEV,1:3) = (/9.0_JPRB,144.0_JPRB,196.0_JPRB/)
    RHUBERLEFT (NVAR_PS,JOCT,IOBT,JLEV) = 1.1_JPRB 
    RHUBERRIGHT(NVAR_PS,JOCT,IOBT,JLEV) = 1.2_JPRB
    RHUBERBGQC (NVAR_PS,JOCT,IOBT,JLEV,1:3) = (/12.25_JPRB,144.0_JPRB,196.0_JPRB/)
  ENDDO
ENDDO

LVARQC(NVAR_U,NDRIBU) = .TRUE.
RAQC  (NVAR_U,NDRIBU) = 0.005_JPRB
RLQC  (NVAR_U,NDRIBU) = 5.0_JPRB
RBGQC (NVAR_U,NDRIBU,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
LVARQC(NVAR_U10,NDRIBU) = .TRUE.
RAQC  (NVAR_U10,NDRIBU) = 0.005_JPRB
RLQC  (NVAR_U10,NDRIBU) = 5.0_JPRB
RBGQC (NVAR_U10,NDRIBU,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Temperature
RBGQC (NVAR_T,NDRIBU,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Height
LVARQC(NVAR_Z,NDRIBU) = .TRUE.
RAQC  (NVAR_Z,NDRIBU) = 0.1_JPRB
RLQC  (NVAR_Z,NDRIBU) = 5.0_JPRB
RBGQC (NVAR_Z,NDRIBU,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)*0.9_JPRB

!* Surface Pressure
LVARQC(NVAR_PS,NDRIBU) = .TRUE.
RAQC  (NVAR_PS,NDRIBU) = 0.001_JPRB
RLQC  (NVAR_PS,NDRIBU) = 5.0_JPRB
RBGQC (NVAR_PS,NDRIBU,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)

!*          1.8.5 TEMP

!* Wind upper-air
!* call function to get IOBTTEMP for NTEMP
CALL CMOCTMAP('CODETOSQ',NULOUT,NTEMP,NLDTCD,IOBTTEMP,ICDT)
!*          'Temp good/ok quality    '
DO JOCT=1,NTEMCT
  RHUBERLEFT (NVAR_U,JOCT,IOBTTEMP,1) = 1.6_JPRB
  RHUBERRIGHT(NVAR_U,JOCT,IOBTTEMP,1) = 1.6_JPRB
  RHUBERLEFT (NVAR_U,JOCT,IOBTTEMP,2) = 1.3_JPRB
  RHUBERRIGHT(NVAR_U,JOCT,IOBTTEMP,2) = 1.3_JPRB
  RHUBERLEFT (NVAR_U,JOCT,IOBTTEMP,3) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U,JOCT,IOBTTEMP,3) = 1.0_JPRB
ENDDO

! Relaxed QC for Dropsondes
CALL CMOCTMAP('CODETOSQ',NULOUT,NTEMP,NTDROP,IOBTTEMP,ICDT)
RHUBERLEFT(NVAR_U,ICDT,IOBTTEMP,1:3)  = 5.0_JPRB
RHUBERRIGHT(NVAR_U,ICDT,IOBTTEMP,1:3) = 5.0_JPRB

RHUBERBGQC_SONDEGOOD (NVAR_U,NTEMP,1,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEOK   (NVAR_U,NTEMP,1,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEGOOD (NVAR_U,NTEMP,2,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEOK   (NVAR_U,NTEMP,2,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEGOOD (NVAR_U,NTEMP,3,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEOK   (NVAR_U,NTEMP,3,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)

LVARQC(NVAR_U,NTEMP) = .TRUE.
RAQC  (NVAR_U,NTEMP) = 0.00006_JPRB
RLQC  (NVAR_U,NTEMP) = 5.0_JPRB
RBGQC (NVAR_U,NTEMP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Wind surface
!*          'Temp good/ok quality    '
DO JOCT=1,NTEMCT
  RHUBERLEFT (NVAR_U10,JOCT,IOBTTEMP,1) = 1.6_JPRB
  RHUBERRIGHT(NVAR_U10,JOCT,IOBTTEMP,1) = 1.6_JPRB
  RHUBERLEFT (NVAR_U10,JOCT,IOBTTEMP,2) = 1.3_JPRB
  RHUBERRIGHT(NVAR_U10,JOCT,IOBTTEMP,2) = 1.3_JPRB
  RHUBERLEFT (NVAR_U10,JOCT,IOBTTEMP,3) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U10,JOCT,IOBTTEMP,3) = 1.0_JPRB
ENDDO
RHUBERBGQC_SONDEGOOD(NVAR_U10,NTEMP,1,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U10,NTEMP,1,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_U10,NTEMP,2,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U10,NTEMP,2,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_U10,NTEMP,3,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U10,NTEMP,3,1:3) = (/9.0_JPRB,144.0_JPRB,256.0_JPRB/)

LVARQC(NVAR_U10,NTEMP) = .TRUE.
RAQC  (NVAR_U10,NTEMP) = 0.00001_JPRB
RLQC  (NVAR_U10,NTEMP) = 5.0_JPRB
RBGQC (NVAR_U10,NTEMP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Temperature
!*          'Temp good/ok quality    '
DO JOCT=1,NTEMCT
  RHUBERLEFT (NVAR_T,JOCT,IOBTTEMP,1) = 1.8_JPRB
  RHUBERRIGHT(NVAR_T,JOCT,IOBTTEMP,1) = 1.5_JPRB
  RHUBERLEFT (NVAR_T,JOCT,IOBTTEMP,2) = 1.2_JPRB
  RHUBERRIGHT(NVAR_T,JOCT,IOBTTEMP,2) = 1.2_JPRB
  RHUBERLEFT (NVAR_T,JOCT,IOBTTEMP,3) = 0.8_JPRB
  RHUBERRIGHT(NVAR_T,JOCT,IOBTTEMP,3) = 0.9_JPRB
ENDDO

! Relaxed QC for Dropsondes
CALL CMOCTMAP('CODETOSQ',NULOUT,NTEMP,NTDROP,IOBTTEMP,ICDT)
RHUBERLEFT(NVAR_T,ICDT,IOBTTEMP,1:3)  = 5.0_JPRB
RHUBERRIGHT(NVAR_T,ICDT,IOBTTEMP,1:3) = 5.0_JPRB

RHUBERBGQC_SONDEGOOD(NVAR_T,NTEMP,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_T,NTEMP,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_T,NTEMP,2,1:3) = (/9.0_JPRB,484.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_T,NTEMP,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_T,NTEMP,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_T,NTEMP,3,1:3) = (/9.0_JPRB,256.0_JPRB,400.0_JPRB/)

LVARQC(NVAR_T,NTEMP) = .TRUE.
RAQC  (NVAR_T,NTEMP) = 0.004_JPRB
RLQC  (NVAR_T,NTEMP) = 5.0_JPRB
RBGQC (NVAR_T,NTEMP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Height
LVARQC(NVAR_Z,NTEMP) = .TRUE.
RAQC  (NVAR_Z,NTEMP) = 0.001_JPRB
RLQC  (NVAR_Z,NTEMP) = 5.0_JPRB
RBGQC (NVAR_Z,NTEMP,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)

!* Relative Humidity
LVARQC(NVAR_H,NTEMP) = .TRUE.
RAQC  (NVAR_H,NTEMP) = 0.01_JPRB
RLQC  (NVAR_H,NTEMP) = 5.0_JPRB
RBGQC (NVAR_H,NTEMP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Specific Humidity
LVARQC(NVAR_Q,NTEMP) = .TRUE.
RAQC  (NVAR_Q,NTEMP) = 0.01_JPRB
RLQC  (NVAR_Q,NTEMP) = 5.0_JPRB
RBGQC (NVAR_Q,NTEMP,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!*          1.8.6 PILOT

!* call function to get IOBTPILOT for NPILOT
CALL CMOCTMAP('CODETOSQ',NULOUT,NPILOT,NLDPCD,IOBTPILOT,ICDT)
!* Wind upper-air
!*          'Pilot good/ok quality    '
DO JOCT=1,NPILCT
  RHUBERLEFT (NVAR_U,JOCT,IOBTPILOT,1) = 1.6_JPRB
  RHUBERRIGHT(NVAR_U,JOCT,IOBTPILOT,1) = 1.6_JPRB
  RHUBERLEFT (NVAR_U,JOCT,IOBTPILOT,2) = 1.3_JPRB
  RHUBERRIGHT(NVAR_U,JOCT,IOBTPILOT,2) = 1.3_JPRB
  RHUBERLEFT (NVAR_U,JOCT,IOBTPILOT,3) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U,JOCT,IOBTPILOT,3) = 1.0_JPRB
ENDDO
RHUBERBGQC_SONDEGOOD(NVAR_U,NPILOT,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U,NPILOT,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_U,NPILOT,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U,NPILOT,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_U,NPILOT,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U,NPILOT,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

LVARQC(NVAR_U,NPILOT) = .TRUE.
RAQC  (NVAR_U,NPILOT) = 0.00006_JPRB
RLQC  (NVAR_U,NPILOT) = 5.0_JPRB
RBGQC (NVAR_U,NPILOT,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Wind surface
!*          'Pilot good/ok quality    '

DO JOCT=1,NPILCT
  RHUBERLEFT (NVAR_U10,JOCT,IOBTPILOT,1) = 1.6_JPRB
  RHUBERRIGHT(NVAR_U10,JOCT,IOBTPILOT,1) = 1.6_JPRB
  RHUBERLEFT (NVAR_U10,JOCT,IOBTPILOT,2) = 1.3_JPRB
  RHUBERRIGHT(NVAR_U10,JOCT,IOBTPILOT,2) = 1.3_JPRB
  RHUBERLEFT (NVAR_U10,JOCT,IOBTPILOT,3) = 1.0_JPRB
  RHUBERRIGHT(NVAR_U10,JOCT,IOBTPILOT,3) = 1.0_JPRB
ENDDO
RHUBERBGQC_SONDEGOOD(NVAR_U10,NPILOT,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U10,NPILOT,1,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_U10,NPILOT,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U10,NPILOT,2,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEGOOD(NVAR_U10,NPILOT,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)
RHUBERBGQC_SONDEOK  (NVAR_U10,NPILOT,3,1:3) = (/9.0_JPRB,324.0_JPRB,484.0_JPRB/)

LVARQC(NVAR_U10,NPILOT) = .TRUE.
RAQC  (NVAR_U10,NPILOT) = 0.00001_JPRB
RLQC  (NVAR_U10,NPILOT) = 5.0_JPRB
RBGQC (NVAR_U10,NPILOT,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* LOS Wind component
LVARQC(NVAR_HLS,NPILOT) = .TRUE.
RAQC  (NVAR_HLS,NPILOT) = 0.00006_JPRB
RLQC  (NVAR_HLS,NPILOT) = 5.0_JPRB
RBGQC (NVAR_HLS,NPILOT,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!*          1.8.7 SATEM/TOVS

!* Thickness
RBGQC (NVAR_DZ,NSATEM,1:3) = (/2.25_JPRB,5.06_JPRB,7.56_JPRB/)

!* SSMI 10-m wind speed
LVARQC(NVAR_FF,NSATEM)=.TRUE.
RAQC  (NVAR_FF,NSATEM)=0.35_JPRB
RLQC  (NVAR_FF,NSATEM)=2.28_JPRB

!* AMSUB in full resolution
LAMSUB_FULL=.FALSE.

!* Radiances
IF (.NOT.LCANARI) THEN

  IF ((LSCREEN)) THEN

    ! Set up switches for emissivity calculation
    CALL SUEMIS_CONF

    IF (LECMWF) THEN  ! Activate land emissivity Kalman Filter.

      ! initialize KF module

      CALL EMISKF_INIT ( NULOUT,  &  !print unit
                       & NULUSR3, &  !read unit
                       & NULUSR3, &  !write unit
                       &.TRUE.,   &  !use MPL
                       & MYPROC   )  !myproc

      ! initialize KF atlases

      DO ISENSOR = 0, MXSENSOR
        IF (      LATLAS_EMIS(ISENSOR)  &
           & .OR. LDYN_EMIS(ISENSOR)    &
           & .OR. LDYN_TSKIN(ISENSOR)) THEN
          CALL EMISKF_INIT_SENSOR (ISENSOR, &
                  & MSENSOR_CHANCOUNT(ISENSOR), MEMIS_CHAN(ISENSOR,:))
        ENDIF
      ENDDO

    ELSE ! Static land emissivity atlases

      !* read emissivities from a climatology

      IF(      LDYN_EMIS(MSENSOR_AMSUA) .OR. LATLAS_EMIS(MSENSOR_AMSUA) &
       &                                .OR. LDYN_TSKIN(MSENSOR_AMSUA)  &
       &  .OR. LDYN_EMIS(MSENSOR_AMSUB) .OR. LATLAS_EMIS(MSENSOR_AMSUB) &
       &                                .OR. LDYN_TSKIN(MSENSOR_AMSUB)  &
       &  .OR. LDYN_EMIS(MSENSOR_MHS)   .OR. LATLAS_EMIS(MSENSOR_MHS)   &
       &                                .OR. LDYN_TSKIN(MSENSOR_MHS) )THEN

        ALLOCATE(DATA_EMIS_AN1(12,TOT_EM_AN1))
        ALLOCATE(DATA_EMIS_AN2(12,TOT_EM_AN2))

        INQUIRE( FILE = 'ATLAS_AN1.DAT', EXIST = LLATLAS1) 
        INQUIRE( FILE = 'ATLAS_AN2.DAT', EXIST = LLATLAS2) 

        IF( LLATLAS1 .AND. LLATLAS2 )THEN
          WRITE(NULOUT,*)'read EMIS atlas high and low zenith angles '

          IOMASTER=1
          IF(MYPROC == IOMASTER) THEN

            INIEMIS1=NULUSR3
            WRITE(NULOUT,*)'UNIT NUMBER',INIEMIS1
            WRITE(NULOUT,*)'READING MEAN AMSU EMISSIVITIES1 :'
            OPEN(INIEMIS1,STATUS='OLD',FILE='ATLAS_AN1.DAT')
            READ(INIEMIS1,*)DATA_EMIS_AN1
            CLOSE(INIEMIS1)
            WRITE(NULOUT,*)'READ AMSU EMISSIVITIES1, OK:'

            INIEMIS1=NULUSR3
            WRITE(NULOUT,*)'UNIT NUMBER',INIEMIS1
            WRITE(NULOUT,*)'READING MEAN AMSU EMISSIVITIES2 :'
            OPEN(INIEMIS1,STATUS='OLD',FILE='ATLAS_AN2.DAT')
            READ(INIEMIS1,*)DATA_EMIS_AN2
            CLOSE(INIEMIS1)
            WRITE(NULOUT,*)'READ AMSU EMISSIVITIES2, OK:'

            INIEMIS1=NULUSR3
            WRITE(NULOUT,*)'UNIT NUMBER',INIEMIS1
            WRITE(NULOUT,*)'READING MODEL COEFFICIENTS :'
            OPEN(INIEMIS1,STATUS='OLD',FILE='COEF_MODEL.DAT')
            READ(INIEMIS1,*)DATA_MODEL
            CLOSE(INIEMIS1)
            WRITE(NULOUT,*)'READ MODEL COEFFICIENTS, OK:'

          ENDIF

          IF(NPROC > 1) THEN
            WRITE(NULOUT,*)'MPL_BROADCAST1:'
            ITAG=5555
            CALL MPL_BROADCAST(DATA_EMIS_AN1(:,:),KROOT=IOMASTER,KTAG=ITAG,&
            & CDSTRING='DEFRUN:')
            WRITE(NULOUT,*)'MPL_BROADCAST1, OK:'

            ITAG=5555
            WRITE(NULOUT,*)'MPL_BROADCAST2:'
            CALL MPL_BROADCAST(DATA_EMIS_AN2(:,:),KROOT=IOMASTER,KTAG=ITAG,&
            & CDSTRING='DEFRUN:')
            WRITE(NULOUT,*)'MPL_BROADCAST2, OK:'

            ITAG=5555
            WRITE(NULOUT,*)'MPL_BROADCAST2:'
            CALL MPL_BROADCAST(DATA_MODEL(:,:),KROOT=IOMASTER,KTAG=ITAG,&
              & CDSTRING='DEFRUN:')
            WRITE(NULOUT,*)'MPL_BROADCAST2, OK: '

          ENDIF
        ELSE
          IF(       LATLAS_EMIS(MSENSOR_AMSUA) .OR. LDYN_TSKIN(MSENSOR_AMSUA)  &
            &  .OR. LATLAS_EMIS(MSENSOR_AMSUB) .OR. LDYN_TSKIN(MSENSOR_AMSUB)  &
            &  .OR. LATLAS_EMIS(MSENSOR_MHS)   .OR. LDYN_TSKIN(MSENSOR_MHS) )THEN
            CALL ABOR1('DEFRUN: No emissivity atlas provided for AMSUA/B/MHS')
          ELSE
            DATA_EMIS_AN1 = RMDI
            DATA_EMIS_AN2 = RMDI
            DATA_MODEL = 0.0_JPRB
          ENDIF
        ENDIF
      ENDIF !AMSUA/AMSUB

      IF(      LDYN_EMIS(MSENSOR_SSMI) .OR. LATLAS_EMIS(MSENSOR_SSMI) &
       &  .OR. LDYN_TSKIN(MSENSOR_SSMI)) THEN

        ALLOCATE(ATLAS_SSMI(18,TOT_EM_SSMI))

        INQUIRE( FILE = 'ATLAS_SSMI.DAT', EXIST = llatlas1) 

        IF( LLATLAS1 )THEN
          WRITE(NULOUT,*)'read SSMI emissivity atlas '

          IOMASTER=1
          IF(MYPROC == IOMASTER) THEN

            INIEMIS1=NULUSR3
            WRITE(NULOUT,*)'UNIT NUMBER',INIEMIS1
            WRITE(NULOUT,*)'READING MEAN SSMI EMISSIVITIES1 :'
            OPEN(INIEMIS1,STATUS='OLD',FILE='ATLAS_SSMI.DAT')
            READ(INIEMIS1,*)ATLAS_SSMI
            CLOSE(INIEMIS1)
            WRITE(NULOUT,*)'READ SSMIS EMISSIVITIES, OK:'

          ENDIF

          IF(NPROC > 1) THEN
            WRITE(NULOUT,*)'MPL_BROADCAST1:'
            ITAG=5555
            CALL MPL_BROADCAST(ATLAS_SSMI(:,:),KROOT=IOMASTER,KTAG=ITAG,&
                & CDSTRING='DEFRUN:')
            WRITE(NULOUT,*)'MPL_BROADCAST1, OK:'
          ENDIF
        ELSE
          IF( LATLAS_EMIS(MSENSOR_SSMI) .OR. LDYN_TSKIN(MSENSOR_SSMI) )THEN
            CALL ABOR1('DEFRUN: No emissivity atlas provided for SSMI')
          ELSE
            ATLAS_SSMI = RMDI
          ENDIF
        ENDIF
      ENDIF !SSMI

    ENDIF !LECMWF

  ENDIF !LSCREEN


  LVARQC(NVAR_RAD,NSATEM)=.TRUE.
  RAQC  (NVAR_RAD,NSATEM)=0.01_JPRB
  RLQC  (NVAR_RAD,NSATEM)=5.0_JPRB
  RBGQC (NVAR_RAD,NSATEM,1:3) = (/9.00_JPRB,16.0_JPRB,6.25_JPRB/)

!* 1C Radiances - Indexed by sensor and channel
  LVARQC_RAD1C(MSENSOR_HIRS)=.TRUE.
  RAQC_RAD1C(MSENSOR_HIRS,1:20)= &
   & (/0.50_JPRB,0.15_JPRB,0.15_JPRB,0.05_JPRB,0.37_JPRB &
   & ,0.20_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   & ,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.25_JPRB,0.05_JPRB &
   & ,RMDI     ,RMDI     ,RMDI     ,RMDI     ,RMDI      /)  
  ROERR_RAD1C(MSENSOR_HIRS,1:20)= &
   & (/2.00_JPRB,0.60_JPRB,0.60_JPRB,0.60_JPRB,0.60_JPRB &
   & ,0.60_JPRB,0.75_JPRB,1.00_JPRB,1.00_JPRB,0.80_JPRB &
   & ,1.00_JPRB,2.00_JPRB,0.60_JPRB,0.50_JPRB,0.60_JPRB &
   & ,1.00_JPRB,1.00_JPRB,1.00_JPRB,1.00_JPRB,1.00_JPRB /)

  LVARQC_RAD1C(MSENSOR_MSU)=.TRUE.
  RAQC_RAD1C(MSENSOR_MSU,1:4)= &
   & (/RMDI     ,0.05_JPRB,0.05_JPRB,0.05_JPRB           /)  
  ROERR_RAD1C(MSENSOR_MSU,1:4)= &
   & (/10.0_JPRB,0.35_JPRB,0.35_JPRB,0.35_JPRB           /)  

  LVARQC_RAD1C(MSENSOR_SSU)=.TRUE.
  RAQC_RAD1C(MSENSOR_SSU,1:3)= &
   & (/0.15_JPRB,0.15_JPRB,0.15_JPRB                     /)  
  ROERR_RAD1C(MSENSOR_SSU,1:3)= &
   & (/0.80_JPRB,1.40_JPRB,1.40_JPRB                     /)  
! pre-ERA (/0.80_JPRB,0.80_JPRB,1.20_JPRB                     /)

  LVARQC_RAD1C(MSENSOR_IRAS)=.TRUE.
  RAQC_RAD1C(MSENSOR_IRAS,1:20)= &
   & (/0.50_JPRB,0.15_JPRB,0.15_JPRB,0.15_JPRB,0.40_JPRB &
   & ,0.25_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   & ,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.30_JPRB,0.15_JPRB &
   & ,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)
  ROERR_RAD1C(MSENSOR_IRAS,1:20)= &
   & (/2.00_JPRB,0.60_JPRB,0.60_JPRB,1.1_JPRB,0.99_JPRB &
   & ,0.81_JPRB,0.83_JPRB,1.00_JPRB,1.00_JPRB,0.80_JPRB &
   & ,0.98_JPRB,1.86_JPRB,0.60_JPRB,0.80_JPRB,1.20_JPRB &
   & ,1.00_JPRB,1.00_JPRB,1.00_JPRB,1.00_JPRB,1.00_JPRB /)

  LVARQC_RAD1C(MSENSOR_MWTS)=.TRUE.
  RAQC_RAD1C(MSENSOR_MWTS,1:4)= &
   & (/0.15_JPRB     ,0.4_JPRB,0.5_JPRB,0.5_JPRB           /)
  ROERR_RAD1C(MSENSOR_MWTS,1:4)= &
   & (/10.0_JPRB,0.44_JPRB,0.53_JPRB,0.56_JPRB           /)
  
  LVARQC_RAD1C(MSENSOR_MWHS)=.TRUE.
  RAQC_RAD1C(MSENSOR_MWHS,1:5)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)
  ROERR_RAD1C(MSENSOR_MWHS,1:5)= &
   & (/20.0_JPRB,20.0_JPRB,2.3_JPRB,2.5_JPRB,2.4_JPRB /)

  LVARQC_RAD1C(MSENSOR_AMSUA)=.TRUE.
  RAQC_RAD1C(MSENSOR_AMSUA,1:15)= &
   & (/0.50_JPRB,0.15_JPRB,0.15_JPRB,0.05_JPRB,0.37_JPRB &
   & ,0.20_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   & ,0.50_JPRB,0.15_JPRB,0.15_JPRB,0.05_JPRB,0.37_JPRB /)  

  IF(LECMWF) THEN
    ROERR_RAD1C(MSENSOR_AMSUA,1:15)= &
     & (/30.0_JPRB,30.0_JPRB,30.0_JPRB,30.0_JPRB,0.35_JPRB &
     & ,0.35_JPRB,0.35_JPRB,0.35_JPRB,0.35_JPRB,0.35_JPRB &
     & ,0.35_JPRB,0.50_JPRB,0.85_JPRB,1.40_JPRB,30.0_JPRB /)
  ELSE
    ROERR_RAD1C(MSENSOR_AMSUA,1:15)= &
     & (/30.0_JPRB,30.0_JPRB,30.0_JPRB,30.0_JPRB,0.45_JPRB &
     & ,0.35_JPRB,0.35_JPRB,0.35_JPRB,0.35_JPRB,0.35_JPRB &
     & ,0.50_JPRB,0.80_JPRB,1.20_JPRB,1.40_JPRB,30.0_JPRB /)  
  ENDIF

  LVARQC_RAD1C(MSENSOR_AMSUB)=.TRUE.
  RAQC_RAD1C(MSENSOR_AMSUB,1:5)= &
   & (/0.20_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)  
  IF(LECMWF) THEN
     ROERR_RAD1C(MSENSOR_AMSUB,1:5)= &
     & (/20.0_JPRB,20.0_JPRB,2.0_JPRB,2.0_JPRB,2.0_JPRB /)
  ELSE
     ROERR_RAD1C(MSENSOR_AMSUB,1:5)= &
     & (/20.0_JPRB,20.0_JPRB,3.0_JPRB,2.5_JPRB,2.0_JPRB /)
  ENDIF

  LVARQC_RAD1C(MSENSOR_MHS)=.TRUE.
  RAQC_RAD1C(MSENSOR_MHS,1:5)= &
   & (/0.20_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)
  IF(LECMWF) THEN
     ROERR_RAD1C(MSENSOR_MHS,1:5)= &
     & (/20.0_JPRB,20.0_JPRB,2.0_JPRB,2.0_JPRB,2.0_JPRB /)
  ELSE
     ROERR_RAD1C(MSENSOR_MHS,1:5)= &
     & (/20.0_JPRB,20.0_JPRB,3.0_JPRB,2.5_JPRB,2.0_JPRB /)
  ENDIF

  LVARQC_RAD1C(MSENSOR_SSMI)=.TRUE.
  RAQC_RAD1C(MSENSOR_SSMI,1:7)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   & ,0.50_JPRB,0.50_JPRB /)  
  ROERR_RAD1C(MSENSOR_SSMI,1:7)= &
   & (/3.0_JPRB,4.5_JPRB,4.0_JPRB,3.5_JPRB,4.0_JPRB &
   & ,4.0_JPRB,6.0_JPRB/)  

  LVARQC_RAD1C(MSENSOR_SSMIS)=.TRUE.
  RAQC_RAD1C(MSENSOR_SSMIS,1:24)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)
  ROERR_RAD1C(MSENSOR_SSMIS,1:24)= &
   & (/30.0_JPRB,30.0_JPRB,0.5_JPRB,0.7_JPRB,1.0_JPRB, &
   & 1.0_JPRB,1.0_JPRB,30.0_JPRB,2.5_JPRB,2.5_JPRB, &
   & 2.5_JPRB,4.5_JPRB,3.0_JPRB,3.5_JPRB,4.0_JPRB, &
   & 3.5_JPRB,4.0_JPRB,8.0_JPRB,30.0_JPRB,30.0_JPRB, &
   & 30.0_JPRB,2.0_JPRB,2.0_JPRB,2.0_JPRB/)

  LVARQC_RAD1C(MSENSOR_MWRI)=.TRUE.
  RAQC_RAD1C(MSENSOR_MWRI,1:10)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   &  ,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)
  ROERR_RAD1C(MSENSOR_MWRI,1:10)= &
   & (/3.0_JPRB,3.0_JPRB,3.0_JPRB,4.5_JPRB, &
   &   3.5_JPRB,4.5_JPRB,3.5_JPRB,4.0_JPRB,4.0_JPRB,6.0_JPRB/)

  LVARQC_RAD1C(MSENSOR_AMSRE)=.TRUE.
  RAQC_RAD1C(MSENSOR_AMSRE,1:12)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   &  ,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB /)  
  ROERR_RAD1C(MSENSOR_AMSRE,1:12)= &
   & (/3.0_JPRB,3.0_JPRB,3.0_JPRB,3.0_JPRB,3.0_JPRB,4.5_JPRB, &
   &   3.5_JPRB,4.5_JPRB,3.5_JPRB,4.0_JPRB,4.0_JPRB,6.0_JPRB/)  

  LVARQC_RAD1C(MSENSOR_TMI)=.TRUE.
  RAQC_RAD1C(MSENSOR_TMI,1:9)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   &  ,0.50_JPRB,0.50_JPRB,0.50_JPRB /)  
  ROERR_RAD1C(MSENSOR_TMI,1:9)= &
   & (/3.0_JPRB,3.0_JPRB,4.0_JPRB,4.5_JPRB, &
   &   4.5_JPRB,3.5_JPRB,4.0_JPRB,4.0_JPRB,6.0_JPRB/)  

  LVARQC_RAD1C(MSENSOR_WINDSAT)=.TRUE.
  RAQC_RAD1C(MSENSOR_WINDSAT,1:16)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   &  0.50_JPRB  /)
  ROERR_RAD1C(MSENSOR_WINDSAT,1:16)= &
   & (/5.0_JPRB,5.0_JPRB,5._JPRB,5.0_JPRB,5.0_JPRB, &
   & 5.0_JPRB,5.0_JPRB,5.0_JPRB,5.0_JPRB,5.0_JPRB, &
   & 5.0_JPRB,5.0_JPRB,5.0_JPRB,5.0_JPRB,5.0_JPRB, &
   & 5.0_JPRB /) 

  LVARQC_RAD1C(MSENSOR_VTPR1)=.TRUE.
  RAQC_RAD1C(MSENSOR_VTPR1,1:8)= &
   & (/0.50_JPRB,0.15_JPRB,0.15_JPRB,0.05_JPRB,0.37_JPRB &
   & ,0.20_JPRB,0.50_JPRB,0.50_JPRB                     /)  
  ROERR_RAD1C(MSENSOR_VTPR1,1:8)= &
   & (/2.00_JPRB,1.00_JPRB,0.80_JPRB,0.70_JPRB,0.60_JPRB &
   & ,0.60_JPRB,2.00_JPRB,1.00_JPRB                     /)  

  LVARQC_RAD1C(MSENSOR_VTPR2)=.TRUE.
  RAQC_RAD1C(MSENSOR_VTPR2,1:8)= &
   & (/0.50_JPRB,0.15_JPRB,0.15_JPRB,0.05_JPRB,0.37_JPRB &
   & ,0.20_JPRB,0.50_JPRB,0.50_JPRB                     /)  
  ROERR_RAD1C(MSENSOR_VTPR2,1:8)= &
   & (/2.00_JPRB,1.00_JPRB,0.80_JPRB,0.70_JPRB,0.60_JPRB &
   & ,0.60_JPRB,2.00_JPRB,1.00_JPRB                     /)  

  LVARQC_RAD1C(MSENSOR_METEOSAT)=.TRUE.
  RAQC_RAD1C(MSENSOR_METEOSAT,1:2)= &
   & (/0.50_JPRB,0.50_JPRB                               /)  
  ROERR_RAD1C(MSENSOR_METEOSAT,1:2)= &
   & (/2.00_JPRB,1.00_JPRB                               /)  

  LVARQC_RAD1C(MSENSOR_MSG_HR)=.TRUE.
  RAQC_RAD1C(MSENSOR_MSG_HR,1:8)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB &
   &  ,0.50_JPRB,0.50_JPRB,0.50_JPRB                     /)
  ROERR_RAD1C(MSENSOR_MSG_HR,1:8)= &    
   & (/1.05_JPRB,1.70_JPRB,1.70_JPRB,1.05_JPRB,1.05_JPRB &
   &  ,1.05_JPRB,1.05_JPRB,1.05_JPRB                     /)

  LVARQC_RAD1C(MSENSOR_MSG)=.TRUE.
  RAQC_RAD1C(MSENSOR_MSG,1:8)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB, &
   & 0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB           /)  
  ROERR_RAD1C(MSENSOR_MSG,1:8)= &
   & (/2.00_JPRB,2.00_JPRB,2.00_JPRB,2.00_JPRB, &
   & 2.00_JPRB,2.00_JPRB,2.00_JPRB,2.00_JPRB           /)  

  LVARQC_RAD1C(MSENSOR_MTSATIMG)=.TRUE.
  RAQC_RAD1C(MSENSOR_MTSATIMG,1:4)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB         /)
  ROERR_RAD1C(MSENSOR_MTSATIMG,1:4)= &
   & (/2.00_JPRB,2.00_JPRB,2.00_JPRB,2.00_JPRB         /)

  LVARQC_RAD1C(MSENSOR_VISSR)=.TRUE.
  RAQC_RAD1C(MSENSOR_VISSR,1:4)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB         /)
  ROERR_RAD1C(MSENSOR_VISSR,1:4)= &
   & (/2.00_JPRB,2.00_JPRB,2.00_JPRB,2.00_JPRB         /)

  LVARQC_RAD1C(MSENSOR_GOESIMG)=.TRUE.
  RAQC_RAD1C(MSENSOR_GOESIMG,1:4)= &
   & (/0.50_JPRB,0.50_JPRB,0.50_JPRB,0.50_JPRB           /)  
  ROERR_RAD1C(MSENSOR_GOESIMG,1:4)= &
   & (/2.00_JPRB,2.00_JPRB,1.00_JPRB,1.00_JPRB           /)  

    ROERR_RAD1C(MSENSOR_AIRS,:)=10.00_JPRB

!open and read file containing AIRS obs errors
IOMASTER=1
  IF(MYPROC == IOMASTER .OR. .NOT.LECMWF) THEN
      INIU1=NULUSR3
      WRITE(NULOUT,*)'READING AIRS TB ERROR (file text follows):'
      OPEN(INIU1,STATUS='OLD',FORM='FORMATTED',FILE='rmtberr_airs.dat')
      READ(INIU1,'(A120)')clrmtberr_text      
      WRITE(NULOUT,'(A)')clrmtberr_text                   
      INCHAN=0
      DO JCHAN=1,M__NumAIRSChans  
        READ(INIU1,*)IKCHAN,ZTBERROR
        INCHAN=INCHAN+1
        IF (ZTBERROR >= 1.E-3_JPRB .AND. ZTBERROR <= 1.E3_JPRB) &
         & ROERR_RAD1C(MSENSOR_AIRS,IKCHAN)=ZTBERROR
      ENDDO
      WRITE(NULOUT,*)'AIRS TB ERRORS READ OK:',INCHAN
      CLOSE(INIU1)
  ENDIF
  IF(NPROC > 1 .AND. LECMWF) THEN
    ITAG=5555
    CALL MPL_BROADCAST(ROERR_RAD1C(MSENSOR_AIRS,:),KROOT=IOMASTER,KTAG=ITAG,&
     & CDSTRING='DEFRUN:')
  ENDIF

! Now for IASI:

  ! First read in IASI channels in ODB (if not already set up in suvarbc)
  IF (.NOT.(ALLOCATED(IASICHAN))) THEN
     CALL READ_IASICHANS(IERR)
     IF (IERR == 1) CALL ABOR1('SUVARBC: Problem reading IASICHANS')
  ENDIF

  ROERR_RAD1C(MSENSOR_IASI,:)=2.00_JPRB
  ROERR_RAD1C(MSENSOR_IASI,193:426)=0.50_JPRB 
!open and read file containing IASI obs errors
  if (LECMWF) then
  IOMASTER=1
  IF(MYPROC == IOMASTER) THEN
    INIU1=NULUSR3
    WRITE(NULOUT,*)'READING IASI TB ERROR (file text follows):'
    OPEN(INIU1,STATUS='OLD',FORM='FORMATTED',FILE='rmtberr_iasi.dat')
    READ(INIU1,'(A120)')clrmtberr_text      
    WRITE(NULOUT,'(A)')clrmtberr_text                   
    INCHAN=0
    IOS=0
    READ(INIU1,*,IOSTAT=IOS)IKCHAN,ZTBERROR
    DO WHILE (IOS == 0)
      INCHAN=INCHAN+1
      ROERR_RAD1C(MSENSOR_IASI,IKCHAN)=ZTBERROR
      READ(INIU1,*,IOSTAT=IOS)IKCHAN,ZTBERROR
    ENDDO
    WRITE(NULOUT,*)'IASI TB ERRORS READ OK:',INCHAN
    CLOSE(INIU1)
  ENDIF
  IF(NPROC > 1) THEN
    ITAG=5555
    CALL MPL_BROADCAST(ROERR_RAD1C(MSENSOR_IASI,:),KROOT=IOMASTER,KTAG=ITAG,&
     & CDSTRING='DEFRUN:')
  ENDIF
  ENDIF

  RLQC_RAD1C(:,:)=5.0_JPRB

! BgQC, set all sensor to the same threshold, for the time being.
  RBGQC_RAD1C(:,:,1)=RBGQC (NVAR_RAD,NSATEM,1)
  RBGQC_RAD1C(:,:,2)=RBGQC (NVAR_RAD,NSATEM,2)
  RBGQC_RAD1C(:,:,3)=RBGQC (NVAR_RAD,NSATEM,3)
! MSG CSR
  IF(.NOT. LECMWF) THEN
    RBGQC_RAD1C(MSENSOR_MSG,:,3)=3.5_JPRB
  ENDIF
! Except SSMIS
  DO ICHAN=1,7
    RBGQC_RAD1C(MSENSOR_SSMIS,ICHAN,1:3) = (/9.00_JPRB,16.0_JPRB,6.25_JPRB/)*0.25_JPRB
  ENDDO
  DO ICHAN=22,24
    RBGQC_RAD1C(MSENSOR_SSMIS,ICHAN,1:3) = (/9.00_JPRB,16.0_JPRB,6.25_JPRB/)*0.25_JPRB
  ENDDO


!* Total SSMI PWC
  LVARQC(NVAR_PWC,NSATEM)=.TRUE.
  RAQC  (NVAR_PWC,NSATEM)=0.40_JPRB
  RLQC  (NVAR_PWC,NSATEM)=3.0_JPRB
  RBGQC (NVAR_PWC,NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!STD use varqc for o3
  LVARQC(NVAR_TO3,NSATEM)=.TRUE.
!  RAQC  (NVAR_TO3,NSATEM)=0.000044_JPRB    !5sigma
!  RAQC  (NVAR_TO3,NSATEM)=0.004_JPRB       !4sigma
!  RAQC  (NVAR_TO3,NSATEM)=0.0256_JPRB       !3.5 sigma
  RAQC  (NVAR_TO3,NSATEM)=0.116_JPRB       !3 sigma
  RLQC  (NVAR_TO3,NSATEM)=5.0_JPRB
!  RBGQC (NVAR_TO3,NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  RBGQC (NVAR_TO3,NSATEM,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)

!* AEROSOL OPTICAL DEPTH AT 0.55 microns
  LVARQC(NVAR_AOD,NSATEM)=.TRUE.
  RAQC  (NVAR_AOD,NSATEM)=0.0001_JPRB
  RLQC  (NVAR_AOD,NSATEM)=3.0_JPRB
  RBGQC (NVAR_AOD,NSATEM,1:3) = (/4.0_JPRB,9.0_JPRB,16.0_JPRB/)

!* CLOUD OPTICAL DEPTH 
  LVARQC(NVAR_COD,NSATEM)=.TRUE.
  RAQC  (NVAR_COD,NSATEM)=0.0001_JPRB
  RLQC  (NVAR_COD,NSATEM)=3.0_JPRB
  RBGQC (NVAR_COD,NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* RATIO OF FINE MODE AEROSOL TO TOTAL OPTICAL DEPTH AT 0.55 microns
  LVARQC(NVAR_RAO,NSATEM)=.TRUE.
  RAQC  (NVAR_RAO,NSATEM)=0.0001_JPRB
  RLQC  (NVAR_RAO,NSATEM)=3.0_JPRB
  RBGQC (NVAR_RAO,NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* AEROSOL REFLECTANCE 
  LVARQC(NVAR_RFA,NSATEM)=.TRUE.
  RAQC  (NVAR_RFA,NSATEM)=0.0001_JPRB
  RLQC  (NVAR_RFA,NSATEM)=3.0_JPRB
  RBGQC (NVAR_RFA,NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* AEROSOL OPTICAL DEPTH - multi-channel 
  LVARQC(NVAR_ODA,NSATEM)=.TRUE.
  RAQC  (NVAR_ODA,NSATEM)=0.0001_JPRB
  RLQC  (NVAR_ODA,NSATEM)=3.0_JPRB
  RBGQC (NVAR_ODA,NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!GRG variables
  DO JGRG=1,JPGRG
!    LVARQC(NVAR_GRG(JGRG),NSATEM)=.TRUE.
    IF (CVAR_GRG(JGRG)=='SO2') THEN
      LVARQC(NVAR_GRG(JGRG),NSATEM)=.FALSE.   ! switch off varqc
    ELSE
      LVARQC(NVAR_GRG(JGRG),NSATEM)=.TRUE.
    ENDIF
    RAQC  (NVAR_GRG(JGRG),NSATEM)=0.116_JPRB
    RLQC  (NVAR_GRG(JGRG),NSATEM)=5.0_JPRB
    RBGQC (NVAR_GRG(JGRG),NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
    IF (CVAR_GRG(JGRG)=='CO') THEN
      RBGQC (NVAR_GRG(JGRG),NSATEM,1:3) = (/2.25_JPRB,4.0_JPRB,9.0_JPRB/)
    ENDIF

  ENDDO

!GHG variables
  DO JGHG=1,JPGHG
!    LVARQC(NVAR_GHG(JGHG),NSATEM)=.TRUE.
    LVARQC(NVAR_GHG(JGHG),NSATEM)=.FALSE.   ! Switch off quality control
    RAQC  (NVAR_GHG(JGHG),NSATEM)=0.116_JPRB
    RLQC  (NVAR_GHG(JGHG),NSATEM)=5.0_JPRB
    RBGQC (NVAR_GHG(JGHG),NSATEM,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
  ENDDO

ENDIF

!*          1.8.8 PAOB

!* Height
LVARQC(NVAR_Z,NPAOB) = .TRUE.
RAQC  (NVAR_Z,NPAOB) = 0.1_JPRB
RLQC  (NVAR_Z,NPAOB) = 5.0_JPRB
RBGQC (NVAR_Z,NPAOB,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)*0.7_JPRB

!* Surface Pressure
LVARQC(NVAR_PS,NPAOB) = .TRUE.
RAQC  (NVAR_PS,NPAOB) = 0.1_JPRB
RLQC  (NVAR_PS,NPAOB) = 5.0_JPRB
RBGQC (NVAR_PS,NPAOB,1:3) = (/12.25_JPRB,25.0_JPRB,36.0_JPRB/)*0.7_JPRB

!* Wind upper-air
LVARQC(NVAR_U,NPAOB) = .TRUE.
RAQC  (NVAR_U,NPAOB) = 0.00006_JPRB
RLQC  (NVAR_U,NPAOB) = 5.0_JPRB
RBGQC (NVAR_U,NPAOB,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)

!* Wind surface
LVARQC(NVAR_U10,NPAOB) = .TRUE.
RAQC  (NVAR_U10,NPAOB) = 0.00001_JPRB
RLQC  (NVAR_U10,NPAOB) = 5.0_JPRB
RBGQC (NVAR_U10,NPAOB,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)


!*          1.8.9 SCAT

!* Ambiguous wind
LVARQC(NVAR_U10,NSCATT) = .TRUE.
RAQC  (NVAR_U10,NSCATT) = 0.008_JPRB
RLQC  (NVAR_U10,NSCATT) = 5.0_JPRB
RBGQC (NVAR_U10,NSCATT,1:3) = (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)*1000._JPRB

!*          1.8.10 Limb observations (alias raw radiances)

!* GPS values
LVARQC(NVAR_RO,NLIMB)=.TRUE.            
RAQC  (NVAR_RO,NLIMB)=0.001_JPRB         
RLQC  (NVAR_RO,NLIMB)=10.0_JPRB           
RBGQC (NVAR_RO,NLIMB,1:3) = (/9.00_JPRB,16.0_JPRB,25.0_JPRB/) 
IF (.NOT.LECMWF) RBGQC (NVAR_RO,NLIMB,1:3) = (/9.00_JPRB,4.0_JPRB,25.0_JPRB/)

!* Limb radiances
LVARQC(NVAR_LRA,NLIMB)=.TRUE.            
RAQC  (NVAR_LRA,NLIMB)=0.001_JPRB         
RLQC  (NVAR_LRA,NLIMB)=10.0_JPRB           
RBGQC (NVAR_LRA,NLIMB,1:3) = (/9.00_JPRB,16.0_JPRB,25.0_JPRB/) 

! Note: Observation error file for MIPAS is read in in rtl_setup 

!*         1.8.13 RADAR

!* reflectivity  bg check switch off
!RBGQC (NVAR_RFL,NRADAR,1:3)= (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)*1000._JPRB
RBGQC (NVAR_RFL,NRADAR,1:3)= (/9.0_JPRB,16.0_JPRB,25.0_JPRB/)
RAQC  (NVAR_RFL,NRADAR)=0.001_JPRB
RLQC (NVAR_RFL,NRADAR)=10.0_JPRB
!* Doppler wind
RBGQC (NVAR_DOW,NRADAR,1:3)= (/2.60_JPRB,2.60_JPRB,2.60_JPRB/)
RAQC  (NVAR_DOW,NRADAR)=0.001_JPRB
RLQC (NVAR_DOW,NRADAR)=10.0_JPRB

!*         1.9.0 OTHER VAR_QC PARAMETERS

IF(LQVARQC) THEN
  NITERQC = 0
ELSE
  NITERQC = 40
ENDIF

!*         1.10 CORRELATION OF OBSERVATION ERRORS
LOBSCOR=.FALSE.
LOBSCORDIAG=.FALSE.
LPRINT_OBSCOR_MATR=.FALSE.
LOBSCOR_SPLIT=.FALSE.
NBCORBLK=0
NOVERTRUN=1
EIGMIN=0.2_JPRB
LRANDOM_OBSCOR=.FALSE.
LOBSCOR_SATOB=.FALSE.
LOBSCOR_AMSUA=.FALSE.
OBSLATDIAG=0._JPRB
OBSLONDIAG=0._JPRB
OBSHSCALE=200000._JPRB
NSMAX_OBSCOR=159
!*          1.10.2 TIME CORRELATION

LTC=.NOT.LSCREEN        ! Always, except screening
RTCEFT=6._JPRB*60._JPRB*60._JPRB
RTCPART=0.3_JPRB
NTCOBS=0
NTCOBS_L=0
NTCLOC=0

!*         1.11 OBSERVATION SCREENING CONTROL PARAMETERS

LSCDPR = .FALSE.        ! SCREENING DIAGNOSTIC PRINTOUT
LSCRE4D = .TRUE.        ! SCREENING IN 4D-MODE
LTARGDROP = .FALSE.     ! RELAX FG-CHECK FOR TARGETED DROPSONDES
NICESEAMASK = 0         ! default value : no ice-sea mask used
NSCAWSOLMAX = 2         ! default value, from double-well cost function legacy
LQSCATAZI = .TRUE.      ! perform QC on azimuth diversity for QuikSCAT
LOSCATAZI = .TRUE.      ! perform QC on azimuth diversity for OCEANSAT-2
LPERTURB = .FALSE.      ! RANDOM PERTURBATION OF OBSERVATIONS
NAENSEMBLE = 0
NAEMEMBER = 0

NHLSFGOPT = 1           ! Option for HLOS FOE in FGCHK
ZHLSFGOPT = 4.0         ! Parameter for Option 2 for HLOS FOE in FGCHK, ie ZFOELIM in m/s

! 1.11.1   Parameters for advanced sounders' cloud detection:

CALL Cloud_Detect_SetUp

!*          1.11.5 Thinning of airep and satellite obs 
!                  Negative values switch thinning OFF.

NTHINSCA=4
RFIND_AIREP = 0.5625_JPRB*RA/RDEGREES
FL_MAXSPEED = 1200.0_JPRB
IF (LECMWF) THEN
  RAIREPTHIN=1500._JPRB
  RAIREPPCENTTHIN=0.05_JPRB
  RAIREPTOPPRES=10000.0_JPRB
ELSE
  RAIREPTHIN=0.0_JPRB
  RAIREPPCENTTHIN=0.0_JPRB
  RAIREPTOPPRES=0.0_JPRB
ENDIF

RMIND_TOV  = 0.6_JPRB*RA/RDEGREES
RFIND_TOV  = 2.5_JPRB*RA/RDEGREES
RMIND_SSMI = 0.6_JPRB*RA/RDEGREES
RFIND_SSMI_PWC = 1.25_JPRB*RA/RDEGREES
RFIND_SSMI_WSP = -1.0_JPRB
RMIND_SATOB = 0.6_JPRB*RA/RDEGREES
RFIND_SATOB = 1.25_JPRB*RA/RDEGREES
!RMIND_RADAR = 0.101_JPRB*RA/RDEGREES ! ALADIN
!RFIND_RADAR = 0.202_JPRB*RA/RDEGREES ! ALADIN
RMIND_RADAR = 0.075_JPRB*RA/RDEGREES ! AROME
RFIND_RADAR = 0.150_JPRB*RA/RDEGREES ! AROME

RMIND_RAD1C(:) = 0.6_JPRB*RA/RDEGREES
RFIND_RAD1C(:) = 1.25_JPRB*RA/RDEGREES
IF (LCO2) THEN
  RMIND_RAD1C(MSENSOR_AIRS) = -1.0_JPRB
  RFIND_RAD1C(MSENSOR_AIRS) = -1.0_JPRB
  RMIND_RAD1C(MSENSOR_IASI) = -1.0_JPRB
  RFIND_RAD1C(MSENSOR_IASI) = -1.0_JPRB
ENDIF

RMIND_SATAM  = 0.6_JPRB*RA/RDEGREES
RFIND_SATAM = 1.25_JPRB*RA/RDEGREES
RMIND_SCATT_ERS = 50000._JPRB*NTHINSCA/4._JPRB
RFIND_SCATT_ERS = 100000._JPRB*NTHINSCA/4._JPRB
IF ( .NOT.LECMWF ) THEN
  RFIND_AIREP = 1.7_JPRB*RA/RDEGREES
!* SATOB in SATOB format 
  RMIND_SATOB = 0.6_JPRB*RA/RDEGREES
  RFIND_SATOB = 2.5_JPRB*RA/RDEGREES
!*
  RMIND_RAD1C(:) = 0.8_JPRB*RA/RDEGREES
  RFIND_RAD1C(:) = 1.6_JPRB*RA/RDEGREES
!* SATOB in BUFR format (GEOWIND)
  RMIND_SATAM = 0.6_JPRB*RA/RDEGREES
  RFIND_SATAM = 2.5_JPRB*RA/RDEGREES
!* CSR MSG/meteosat-8 and 9
  RMIND_RAD1C(MSENSOR_MSG) = 1.25_JPRB*RA/RDEGREES
  RFIND_RAD1C(MSENSOR_MSG) = 2.50_JPRB*RA/RDEGREES
!* MSG/meteosat High Resolution
  RMIND_RAD1C(MSENSOR_MSG_HR) = 0.32_JPRB*RA/RDEGREES
  RFIND_RAD1C(MSENSOR_MSG_HR) = 0.65_JPRB*RA/RDEGREES
  RMIND_RAD1C(MSENSOR_METEOSAT) = 0.1_JPRB*RA/RDEGREES
  RFIND_RAD1C(MSENSOR_METEOSAT) = 0.25_JPRB*RA/RDEGREES
!* GPSRO
  RMIND_GPSRO = 0.6_JPRB*RA/RDEGREES
  RFIND_GPSRO = 1.25_JPRB*RA/RDEGREES
!*
ENDIF

!*          1.11.6 Preset QuikSCAT obs error, 
!                  Will be reset later to 2.0_JPRB in case LQSCATAZI=.T.

IF(JPQCELL /= 38 ) THEN
  WRITE(NULOUT,'(A,I10,A)') "DEFRUN ERROR: ",JPQCELL," JPQCELL SHOULD BE 38"
  CALL ABOR1('SUBROUTINE DEFRUN')
ENDIF

ROERR_QSCAT(1:38) = 1.5_JPRB*                             &
!*         1          2          3          4          5
&(/1.57_JPRB, 1.09_JPRB, 1.01_JPRB, 0.99_JPRB, 0.93_JPRB, &
&  0.92_JPRB, 0.91_JPRB, 0.92_JPRB, 0.92_JPRB, 0.93_JPRB, &
&  0.95_JPRB, 0.96_JPRB, 0.97_JPRB, 0.99_JPRB, 1.01_JPRB, &
&  1.06_JPRB, 1.11_JPRB, 1.17_JPRB, 1.21_JPRB, 1.21_JPRB, &
&  1.17_JPRB, 1.11_JPRB, 1.06_JPRB, 1.01_JPRB, 0.99_JPRB, &
&  0.97_JPRB, 0.96_JPRB, 0.95_JPRB, 0.93_JPRB, 0.92_JPRB, &
&  0.92_JPRB, 0.91_JPRB, 0.92_JPRB, 0.93_JPRB, 0.99_JPRB, &
&  1.01_JPRB, 1.09_JPRB, 1.57_JPRB                       /)

!*          1.11.7 Preset OCEANSAT-2 obs error,
!                  Will be reset later to 2.0_JPRB in case LOSCATAZI=.T.

IF(JPICELL /= 36 ) THEN
  WRITE(NULOUT,'(A,I10,A)') "DEFRUN ERROR: ",JPQCELL," JPQCELL SHOULD BE 36"
  CALL ABOR1('SUBROUTINE DEFRUN')
ENDIF

ROERR_OSCAT(1:36) = 1.5_JPRB*                             &
!*         1          2          3          4          5
&(/           1.09_JPRB, 1.01_JPRB, 0.99_JPRB, 0.93_JPRB, &
&  0.92_JPRB, 0.91_JPRB, 0.92_JPRB, 0.92_JPRB, 0.93_JPRB, &
&  0.95_JPRB, 0.96_JPRB, 0.97_JPRB, 0.99_JPRB, 1.01_JPRB, &
&  1.06_JPRB, 1.11_JPRB, 1.17_JPRB, 1.21_JPRB, 1.21_JPRB, &
&  1.17_JPRB, 1.11_JPRB, 1.06_JPRB, 1.01_JPRB, 0.99_JPRB, &
&  0.97_JPRB, 0.96_JPRB, 0.95_JPRB, 0.93_JPRB, 0.92_JPRB, &
&  0.92_JPRB, 0.91_JPRB, 0.92_JPRB, 0.93_JPRB, 0.99_JPRB, &
&  1.01_JPRB, 1.09_JPRB                                  /)


!*          1.11.6 METEO-FRANCE SCREENING ADITIONALS SWITCHES

LMFSCREEN = .FALSE.

NSCAT5_RQC=1          ! qscat rain-qc based on rain contamination
!NSCAT5_RQC=2          ! qscat rain-qc based on dist2cone (see scaqc routine)
IF ( LECMWF ) THEN
  LMFSCRE = .FALSE.
! NICESEAMASK = 3    ! sea-ice mask based on sea-ice fraction AND fg-sst ; used in cy32r2
  NICESEAMASK = 0    ! no check; to be handled by blacklist from cy32r3 onwards
! NSCAWSOLMAX = 4    ! should become default in cy33r+; for now specify in namelist
ELSE
  LMFSCRE = LSCREEN
  NICESEAMASK = 1    ! ice-sea mask based on fg-sst
ENDIF

!*          1.11.8 MAKECMA REPLACMENT

LMKCMARPL(:,:)   = LSCREEN !MKCMARPL part is under LSCREEN in suobs
IF (ANY(LMFSCRE)) THEN  ! MF screening
        LMKCMARPL(:,:)   = .FALSE.
        LMKCMARPL(:,NTEMPSQ) =.TRUE.
        LMKCMARPL(NSCAT2SQ,NSCATTSQ)=.TRUE.
ENDIF
LMKCMARPLO       = .FALSE.
LRPLSWAPOUT      = .FALSE.
LODBDDRMOD       = .FALSE.
LODBDDRMODF      = .FALSE.
LODBDDRMODS      = .FALSE.
LMKCMARPLRUN     = .FALSE.
LMKCMARPL_OPENMP = .TRUE.

LTHINNER_PRINT      = .FALSE.
L_F_SCR_WORK_TS     = .TRUE.

LSATOBTHIN_NO_SQ = .TRUE.
LSATAMTHIN_NO_SQ = .TRUE.
LTOVSTHIN_NO_SQ  = .TRUE.
LRAD1CTHIN_NO_SQ = .TRUE.
LSSMITHIN_NO_SQ  = .TRUE.
LSCATTTHIN_NO_SQ = .TRUE.
LSCATT_NEUTRAL   = .FALSE.
LSATEMTHIN_NO_SQ = .TRUE.
LREO3THIN_NO_SQ  = .TRUE.
LGPSROTHIN_NO_SQ = .TRUE.

LSYNOPPAOB_RED_NO_SQ   = .TRUE.
LSYNOPPAOB_REDRP_NO_SQ = .TRUE.
LSYNOPPAOB_REDRP1_NO_SQ= .TRUE.
LSHIP_NO_SQ            = .TRUE.
LAIREPS_NO_SQ          = .TRUE.
LAIREPS_DUP_NO_SQ      = .TRUE.
LDRIBUS_NO_SQ          = .TRUE.
LTEMPPILOT_NO_SQ       = .TRUE.
LTEMPSYNOP_NO_SQ       = .TRUE.

LVDFTRAJ=.FALSE.
LVDFMIN =.FALSE.
LZ0FC   =.FALSE.

L3DVAR      = .FALSE.
L3DFGAT     = .FALSE.
N4DMIN      = 360

!*          1.12   VARIABLE SELECTION

DO J1 = 1,JPMXOTP
  DO J2 = 1,JPMXOCT
    DO J3 = 1,JPMXVAR
      NMKCMVSE(J3,J2,J1) = 0
    ENDDO
  ENDDO
ENDDO

!*          1.12.1 SYNOP

IOBTYP = 1

DO JCT = 1 , JPMXOCT
  NMKCMVSE( 56,JCT,IOBTYP) = 1
  NMKCMVSE( 57,JCT,IOBTYP) = 1
  NMKCMVSE( 10,JCT,IOBTYP) = 1
  NMKCMVSE(  3,JCT,IOBTYP) = 1
  NMKCMVSE( 47,JCT,IOBTYP) = 1
  NMKCMVSE(  7,JCT,IOBTYP) = 1
  NMKCMVSE( 11,JCT,IOBTYP) = 1
  NMKCMVSE( 13,JCT,IOBTYP) = 1
  NMKCMVSE( 36,JCT,IOBTYP) = 1
  NMKCMVSE( 37,JCT,IOBTYP) = 1
  NMKCMVSE( 25,JCT,IOBTYP) = 1
  NMKCMVSE( 46,JCT,IOBTYP) = 1
  NMKCMVSE( 33,JCT,IOBTYP) = 1
  NMKCMVSE( 34,JCT,IOBTYP) = 1
  NMKCMVSE( 75,JCT,IOBTYP) = 1
ENDDO

!*          1.12.2 AIREP

IOBTYP = 2

DO JCT = 1 , JPMXOCT
  NMKCMVSE(  1,JCT,IOBTYP) = 1
  NMKCMVSE(  2,JCT,IOBTYP) = 1
  NMKCMVSE(  8,JCT,IOBTYP) = 1
ENDDO

!*          1.12.3 SATOB

IOBTYP = 3

DO JCT = 1 , JPMXOCT
  NMKCMVSE(  1,JCT,IOBTYP) = 1
  NMKCMVSE(  2,JCT,IOBTYP) = 1
  NMKCMVSE(  8,JCT,IOBTYP) = 0
ENDDO

!*          1.12.4 DRIBU

IOBTYP = 4

DO JCT = 1 , JPMXOCT
  NMKCMVSE( 56,JCT,IOBTYP) = 1
  NMKCMVSE( 57,JCT,IOBTYP) = 1
  NMKCMVSE( 10,JCT,IOBTYP) = 0
  NMKCMVSE(  3,JCT,IOBTYP) = 1
  NMKCMVSE( 47,JCT,IOBTYP) = 1
ENDDO

!*          1.12.5 TEMP

IOBTYP = 5

DO JCT = 1 , JPMXOCT
  NMKCMVSE(  1,JCT,IOBTYP) = 1
  NMKCMVSE( 56,JCT,IOBTYP) = 1
  NMKCMVSE(  2,JCT,IOBTYP) = 1
  NMKCMVSE( 57,JCT,IOBTYP) = 1
  NMKCMVSE(  3,JCT,IOBTYP) = 1
  NMKCMVSE(  8,JCT,IOBTYP) = 1
  NMKCMVSE( 10,JCT,IOBTYP) = 1
  NMKCMVSE(  9,JCT,IOBTYP) = 1
  NMKCMVSE( 11,JCT,IOBTYP) = 1
  NMKCMVSE(  5,JCT,IOBTYP) = 1
  NMKCMVSE(  7,JCT,IOBTYP) = 1
  NMKCMVSE( 63,JCT,IOBTYP) = 1
ENDDO
NMKCMVSE(  9,  4,IOBTYP) = 0
NMKCMVSE(  5,  4,IOBTYP) = 0
NMKCMVSE( 63,  4,IOBTYP) = 0

!*          1.12.6 PILOT

IOBTYP = 6

DO JCT = 1 , JPMXOCT
  NMKCMVSE(  1,JCT,IOBTYP) = 1
  NMKCMVSE( 56,JCT,IOBTYP) = 1
  NMKCMVSE(  2,JCT,IOBTYP) = 1
  NMKCMVSE( 57,JCT,IOBTYP) = 1
  NMKCMVSE(  3,JCT,IOBTYP) = 1
ENDDO

!*          1.12.6b DOPPLER WIND LIDAR (DWL) HLOS WIND COMPONENT
JCT = 6
  NMKCMVSE(  1,JCT,IOBTYP) = 0
  NMKCMVSE( 56,JCT,IOBTYP) = 0
  NMKCMVSE(  2,JCT,IOBTYP) = 0
  NMKCMVSE( 57,JCT,IOBTYP) = 0
  NMKCMVSE(  3,JCT,IOBTYP) = 0
  NMKCMVSE( 77,JCT,IOBTYP) = 1

!*          1.12.7 SATEM

IOBTYP = 7

NMKCMVSE(  8,  1,IOBTYP) = 1
NMKCMVSE(  8,  2,IOBTYP) = 1
NMKCMVSE(  8,  8,IOBTYP) = 1
NMKCMVSE(  8,  9,IOBTYP) = 1
NMKCMVSE(  8, 10,IOBTYP) = 1

NMKCMVSE(  4,  1,IOBTYP) = 1
NMKCMVSE(  4,  2,IOBTYP) = 1
NMKCMVSE(  4,  8,IOBTYP) = 1
NMKCMVSE(  4,  9,IOBTYP) = 1
NMKCMVSE(  4, 10,IOBTYP) = 1

NMKCMVSE(  6,  1,IOBTYP) = 1
NMKCMVSE(  6,  2,IOBTYP) = 1
NMKCMVSE(  6,  8,IOBTYP) = 1
NMKCMVSE(  6,  9,IOBTYP) = 1
NMKCMVSE(  6, 10,IOBTYP) = 1
NMKCMVSE(  6, 11,IOBTYP) = 1

NMKCMVSE( 50,  8,IOBTYP) = 1
NMKCMVSE( 50,  9,IOBTYP) = 1
NMKCMVSE( 50, 10,IOBTYP) = 1
NMKCMVSE( 50, 11,IOBTYP) = 1

NMKCMVSE( 49, 11,IOBTYP) = 1

NMKCMVSE( 60, 11,IOBTYP) = 1

NMKCMVSE( 47, 12,IOBTYP) = 1

NMKCMVSE(  8, 12,IOBTYP) = 1

NMKCMVSE(  6, 12,IOBTYP) = 1

NMKCMVSE( 68, 12,IOBTYP) = 1

NMKCMVSE( 69, 12,IOBTYP) = 1

NMKCMVSE( 78, 12,IOBTYP) = 1 ! Aerosol optical depth recognized under reo3

NMKCMVSE( 80, 12,IOBTYP) = 1     ! GRG1: NO2 recognized under reo3

NMKCMVSE( 81, 12,IOBTYP) = 1     ! GRG2: SO2 recognized under reo3

NMKCMVSE( 82, 12,IOBTYP) = 1     ! GRG3: CO recognized under reo3

NMKCMVSE( 83, 12,IOBTYP) = 1     ! GRG4: HCHO recognized under reo3

NMKCMVSE( 84, 12,IOBTYP) = 1     ! GRG5: GO3 recognized under reo3

NMKCMVSE( 85, 12,IOBTYP) = 1     ! Cloud optical depth recognized under reo3

NMKCMVSE( 86, 12,IOBTYP) = 1     ! RATIO OF FINE MODE AEROSOL TO TOTAL OPTICAL DEPTH under reo3

NMKCMVSE( 87, 12,IOBTYP) = 1     ! Aerosol reflectance recognized under reo3

NMKCMVSE( 88, 12,IOBTYP) = 1     ! Aerosol optical depth (multi-channel) recognized under reo3

NMKCMVSE( 94, 12,IOBTYP) = 1     ! GHG1: CO2 recognized under reo3

NMKCMVSE( 95, 12,IOBTYP) = 1     ! GHG2: CH4 recognized under reo3


!*          1.12.8 PAOB

IOBTYP = 8

DO JCT = 1 , JPMXOCT
  NMKCMVSE(  3,JCT,IOBTYP) = 1
  NMKCMVSE(47,JCT,IOBTYP) = 1
  NMKCMVSE(  1,JCT,IOBTYP) = 1
  NMKCMVSE( 56,JCT,IOBTYP) = 1
  NMKCMVSE(  2,JCT,IOBTYP) = 1
  NMKCMVSE( 57,JCT,IOBTYP) = 1
ENDDO

!*          1.12.9 SCATT.

IOBTYP = 9

DO JCT = 1 , JPMXOCT
  NMKCMVSE(61,JCT,IOBTYP) = 1
  NMKCMVSE(62,JCT,IOBTYP) = 1
  NMKCMVSE(53,JCT,IOBTYP) = 1
  NMKCMVSE(48,JCT,IOBTYP) = 1
  NMKCMVSE(49,JCT,IOBTYP) = 1
ENDDO

!*          1.12.10 LIMB OBSERVATIONS

IOBTYP =10

NMKCMVSE(76, 2, IOBTYP) = 1   
NMKCMVSE(77, 3, IOBTYP) = 1

!*            1.12.13 RADAR

IOBTYP=13

DO JCT = 1 , JPMXOCT
  NMKCMVSE(  74,JCT,IOBTYP) = 1
  NMKCMVSE(  89,JCT,IOBTYP) = 1
ENDDO

!*          1.13   SWITCHES

LTENDCOR = .FALSE.
LERRPERS = .FALSE.
LSPEHUM  = .TRUE.
LQERRFRH = .TRUE.
LQERRFT  = .FALSE. 
LQERRFP  = .FALSE.
LBIASCV  = .TRUE.
LTBIASBUFR = .FALSE.
LTBIASC  = .TRUE.
LHBIASC  = .FALSE.
LBIASCVO = .TRUE.
LSTOBIAS = .TRUE.

L_NEW_T_BIAS                      = .TRUE.
L_NEW_T_BIAS_SOLAR_vs_all_mean    = .FALSE.
L_NEW_T_BIAS_SOLAR_vs_day_mean    = .FALSE.
L_NEW_T_BIAS_SOLAR_vs_night_m  = .TRUE.
L_NEW_T_BIAS_ALL_MEAN             = .FALSE.
L_NEW_T_BIAS_DAY_MEAN             = .FALSE.
L_NEW_T_BIAS_NIGHT_MEAN           = .FALSE.

L_NEW_RH_BIAS                     = .TRUE.
L_NEW_RH_BIAS_SOLAR_vs_all_mean   = .FALSE.
L_NEW_RH_BIAS_SOLAR_vs_day_mean   = .FALSE.
L_NEW_RH_BIAS_SOLAR_vs_night_m = .TRUE.
L_NEW_RH_BIAS_ALL_MEAN            = .FALSE.
L_NEW_RH_BIAS_DAY_MEAN            = .FALSE.
L_NEW_RH_BIAS_NIGHT_MEAN          = .FALSE.

L_T_REF_SONDE_BIAS_ADJUST         = .TRUE.
C_T_REF_SONDE_NAME                = 'Vaisala_RS92_Autosonde'
N_T_REF_SONDE_CODE                = 81
L_RH_REF_SONDE_BIAS_ADJUST        = .TRUE.
C_RH_REF_SONDE_NAME               = 'Vaisala_RS92_Autosonde'
N_RH_REF_SONDE_CODE               = 81

LCHSHIP  = .FALSE.
LCHDRIBU = .FALSE.
LSHDRCHO = .FALSE.
LSHDRCHOC= .FALSE.
LSCATINT = .TRUE.
LSINOSOL = .FALSE.
LSCATTHI = .TRUE.
LTOTSCTH = .FALSE.
LTOTREM  = .FALSE.
LNOPROC  = .FALSE.
NTHINSCA = 4
NBIASCOR = 1
LAMRDBQC = .FALSE.
L_LAND_PS_BIAS  = .FALSE.
L_SHIP_PS_BIAS  = .FALSE.
L_METAR_PS_BIAS = .FALSE.
L_DRIBU_PS_BIAS = .FALSE.
L_SCAT_BIASSIG    = .TRUE.
L_OBS_ERR_INCREASE_Hretr = .FALSE.


!*          1.14   DATE AND TIME

!*          1.14.1 CENTURY DAY

IRET   = 0
NANCDY = IYMD2CD(NANDAT,IRET)
IF(IRET /= 0)     THEN
  WRITE(NULOUT,'(''0DEFRUN ERROR: '',I10,'' IN IYMD2CD'')') IRET
  CALL ABOR1('SUBROUTINE DEFRUN')
ENDIF

!*          1.14.2 ANALYSIS HOUR AND MINUTE

NANHOU = NANTIM / 10000
NANMIN = NANHOU * 60

!*          1.14.3 F/B TIME MARGIN

NTBMAR   =-180
NTFMAR   = 180

!*          1.15   OBS./CODE TYPES SWITCHES

LSYNOP  =.TRUE.
LCD011  =.TRUE.
LCD014  =.TRUE.
LCD021  =.TRUE.
LCD022  =.TRUE.
LCD023  =.TRUE.
LCD024  =.TRUE.

LAIREP  =.TRUE.
LCD041  =.TRUE.
LCD141  =.TRUE.
LCD142  =.TRUE.
LCD144  =.TRUE.
LCD145  =.TRUE.
LCD241  =.TRUE.

LSATOB  =.TRUE.
LCD088  =.TRUE.
LCD089  =.TRUE.
LCD090  =.TRUE.
LCD188  =.FALSE.

LODRIBU =.TRUE.
LCD063  =.TRUE.
LCD064  =.TRUE.
LCD165  =.TRUE.
LCD160  =.FALSE.

LTEMP   =.TRUE.
LCD035  =.TRUE.
LCD036  =.TRUE.
LCD037  =.TRUE.
LCD135  =.TRUE.
LCD039  =.TRUE.
LCD040  =.TRUE.
LCD137  =.FALSE.

LOPILOT =.TRUE.
LCD032  =.TRUE.
LCD033  =.TRUE.
LCD034  =.TRUE.
LCD131  =.TRUE.
LCD134  =.TRUE.

LSATEM  =.TRUE.
LCD086  =.TRUE.
LCD186  =.TRUE.
LCD185  =.FALSE.
LCD184  =.FALSE.
LCD206  =.TRUE.
LCD200  =.FALSE.
LCD201  =.FALSE.
LCD202  =.FALSE.
LCD210  =.TRUE.
LCD211  =.TRUE.
LCD212  =.TRUE.
LCD215  =.TRUE.

LOPAOB  =.TRUE.
LCD180  =.TRUE.

LSCATT  =.TRUE.
LCD008  =.TRUE.
LCD122  =.TRUE.
LCD139  =.TRUE.
LCD210SC=.TRUE.
LCD300  =.TRUE.
LCD301  =.TRUE.
LCD302  =.TRUE.

LALIMB  =.FALSE.
LCD192  =.TRUE.
LCD250  =.FALSE.
LCD251  =.FALSE.

LRADAR  =.TRUE.
!*          1.16   TIMESLOT VS TIMESTEP

NTSLVSTST(:) = -9999
IF (LCANARI) THEN
  NTSLOTNOS=1
  NTSLOTNOE=1
ELSEIF ( NSTOP == 0 ) THEN ! case 3dvar, no need to call tslvstst
  NTSLVSTST(1) = 0
ELSE    ! case 4dvar, call tslvstst to compute ntslvstst
  NTSLVSTST(:) = 0
  CALL TSLVSTST(NSTART,NSTOP,TSTEP,NACTIM,NTSLVSTST)
ENDIF

!*          1.17   RS T BIAS CORRECTION USING ODB

LRSTBIAS_ODB = .TRUE.




!     ------------------------------------------------------------------
!*       2.       OVERRIDE DEFAULT VALUES
!                 -----------------------

NGCVVAR (:,:) = 0
NOTVAR  (:,:) = 0

!*          2.1   READ NAMELIST NAMJO, NAMOBS, NAMSCC

WRITE(NULOUT,'('' READ NAMELISTs NAMJO, NAMOBS, NAMSCC AND NAMMKODB'')')
CALL FLUSH(NULOUT)
CALL POSNAM(NULNAM,'NAMJO')
READ(NULNAM,NAMJO )
CALL POSNAM(NULNAM,'NAMOBS')
READ(NULNAM,NAMOBS)
CALL POSNAM(NULNAM,'NAMSCC')
READ(NULNAM,NAMSCC)
CALL POSNAM(NULNAM,'NAMMKODB')
READ(NULNAM,NAMMKODB)
WRITE(NULOUT,'('' NAMELISTs NAMJO, NAMOBS, NAMSCC AND NAMMKODB READ'')')
CALL FLUSH(NULOUT)

!*          2.2   TRANSFORMATION OF THINNING PARAMETERS IN DEGREES

IF(RMIND_TOV > 0.0_JPRB) RMIND_TOV  = RMIND_TOV/RA*RDEGREES
IF(RFIND_TOV > 0.0_JPRB) RFIND_TOV  = RFIND_TOV/RA*RDEGREES

IF(RMIND_SSMI > 0.0_JPRB) RMIND_SSMI = RMIND_SSMI/RA*RDEGREES
IF(RFIND_SSMI_PWC > 0.0_JPRB) RFIND_SSMI_PWC = RFIND_SSMI_PWC/RA*RDEGREES
IF(RFIND_SSMI_WSP > 0.0_JPRB) RFIND_SSMI_WSP = RFIND_SSMI_WSP/RA*RDEGREES

IF(RMIND_SATOB > 0.0_JPRB) RMIND_SATOB = RMIND_SATOB/RA*RDEGREES
IF(RFIND_SATOB > 0.0_JPRB) RFIND_SATOB = RFIND_SATOB/RA*RDEGREES

IF(RFIND_AIREP > 0.0_JPRB) RFIND_AIREP = RFIND_AIREP/RA*RDEGREES

WHERE(RMIND_RAD1C(:) > 0.0_JPRB) RMIND_RAD1C(:) = RMIND_RAD1C(:)/RA*RDEGREES
WHERE(RFIND_RAD1C(:) > 0.0_JPRB) RFIND_RAD1C(:) = RFIND_RAD1C(:)/RA*RDEGREES
IF(RMIND_SATAM > 0.0_JPRB) RMIND_SATAM = RMIND_SATAM/RA*RDEGREES
IF(RFIND_SATAM > 0.0_JPRB) RFIND_SATAM = RFIND_SATAM/RA*RDEGREES
IF(RMIND_SCATT_ERS > 0.0_JPRB) RMIND_SCATT_ERS = RMIND_SCATT_ERS/RA*RDEGREES
IF(RFIND_SCATT_ERS > 0.0_JPRB) RFIND_SCATT_ERS = RFIND_SCATT_ERS/RA*RDEGREES
IF(RMIND_GPSRO > 0.0_JPRB) RMIND_GPSRO = RMIND_GPSRO/RA*RDEGREES
IF(RFIND_GPSRO > 0.0_JPRB) RFIND_GPSRO = RFIND_GPSRO/RA*RDEGREES
IF(RMIND_RADAR > 0.0_JPRB) RMIND_RADAR = RMIND_RADAR/RA*RDEGREES
IF(RFIND_RADAR > 0.0_JPRB) RFIND_RADAR = RFIND_RADAR/RA*RDEGREES

!*          2.3   TRANSFORMATION OF MAXIMUM FLIGHT SPEED TO REDUCE
!                 COST OF DISTANCE CALCULATION IN FLSPEEDBAD ROUTINE

FL_MAXSPEED=(2.*SIN(FL_MAXSPEED*1000./(2.0*RA))/60.)**2

IF (LSCREEN) THEN
  WRITE(NULOUT,'(A,F8.1,A,F5.2,A,F8.1)') ' RAIREPTHIN=',RAIREPTHIN,' RAIREPPCENTTHIN=',&
   & RAIREPPCENTTHIN,' RAIREPTOPPRES=',RAIREPTOPPRES

  ZAIREP(1)=0.
  
  IBOT=NFLEVG
  DO JJ=NFLEVG,1,-1
    IF (ABS(STPRE(JJ)-STPRE(NFLEVG)) < RAIREPTHIN ) THEN
      IBOT=JJ
    ENDIF
  ENDDO
  IAIREPLEV=1
  ZAIREP(IAIREPLEV)=STPRE(IBOT)
  
  DO JJ=IBOT-1,1,-1
    IF (STPRE(JJ) > RAIREPTOPPRES ) THEN
      IF (ABS(STPRE(JJ)-ZAIREP(IAIREPLEV)) > RAIREPTHIN .OR. &
       &  ABS(STPRE(JJ)-ZAIREP(IAIREPLEV))/(0.5*(STPRE(JJ)+ZAIREP(IAIREPLEV)))> RAIREPPCENTTHIN ) then
        IAIREPLEV=IAIREPLEV+1
        ZAIREP(IAIREPLEV)=STPRE(JJ)
      ENDIF
    ENDIF
  ENDDO
  
  IF (ALLOCATED(SELAIREPPRE)) DEALLOCATE(SELAIREPPRE)
  ALLOCATE (SELAIREPPRE(IAIREPLEV))
  DO JJ=1,IAIREPLEV
    SELAIREPPRE(JJ)=ZAIREP(IAIREPLEV-JJ+1)
    WRITE(NULOUT,'(A,I4,F10.1)') ' JLEV, SELAIREPPRE ',JJ,SELAIREPPRE(JJ)
  ENDDO

ENDIF


!*          2.4   Set obs errors for window channels (etc.) to something
!                 sensible if obs are to be perturbed.

IF (LPERTURB) THEN
  ROERR_RAD1C(MSENSOR_AMSUA,1:4) = 2.0_JPRB
  ROERR_RAD1C(MSENSOR_AMSUA,15)  = 2.0_JPRB
  ROERR_RAD1C(MSENSOR_AMSUB,1:5) = 2.0_JPRB
  ROERR_RAD1C(MSENSOR_MHS,1:5) = 2.0_JPRB
ENDIF

!*          2.5   Reset obs errors for QuikSCAT and OCEANSAT-2

IF (LQSCATAZI) ROERR_QSCAT(:)=2.0_JPRB
IF (LOSCATAZI) ROERR_OSCAT(:)=2.0_JPRB
IF (LSCREEN) THEN
    WRITE(NULOUT,'(''   LQSCATAZI= '',L8         )')LQSCATAZI
    WRITE(NULOUT,'('' ROERR_QSCAT='' ,38(1X,F8.3))')ROERR_QSCAT(1:38)
    WRITE(NULOUT,'(''   LOSCATAZI= '',L8         )')LOSCATAZI
    WRITE(NULOUT,'('' ROERR_OSCAT='' ,38(1X,F8.3))')ROERR_OSCAT(1:36)
ENDIF


!     ------------------------------------------------------------------
!*       3.       CHECK VALUES FOR CONSISTENCY
!                 ----------------------------

IF ( LMFSCRE(NSYNOP) .OR. LMFSCRE(NAIREP) .OR.&
 & LMFSCRE(NSATOB) .OR. LMFSCRE(NDRIBU) .OR.&
 & LMFSCRE(NTEMP ) .OR. LMFSCRE(NPILOT) .OR.&
 & LMFSCRE(NSATEM) .OR. LMFSCRE(NSCATT) .OR.&
 & LMFSCRE(NPAOB ) .OR. LMFSCRE(NLIMB)      )&
 & LMFSCREEN = .TRUE.  

IF ( LCANARI ) THEN

!*     ENSURE NO-USE OF UNDESIRABLE OBS

  NOTVAR(13,7) = -1
  NOTVAR(:,8)  = -1
  NOTVAR(:,9)  = -1
  NOTVAR(:,10) = -1

ENDIF

!*     ENSURE NO-USE NICESEAMASK=2/3 without GOM%ECCI
                                                                                
IF ((NICESEAMASK==2 .OR. NICESEAMASK==3) .AND. NUSE_ECCI/=1) &
 & CALL ABOR1('DEFRUN:NICESEAMASK=2/3 needs NUSE_ECCI=1')

!*        3.5 CHECK LQSCATT

IF (LQSCATT .AND. NCONF/100  /= 1) THEN
  WRITE(NULOUT,'(''0LQSCATT=.T. REQUIRES NCONF/100=1'')')
  CALL ABOR1('DEFRUN:LQSCATT=.T. REQUIRES NCONF/100=1')
ENDIF

!*        3.6 CHECK NSCAWSOLMAX

IF (NSCAWSOLMAX < 2) THEN
  WRITE(NULOUT,'(''0NSCAWSOLMAX SHOULD AT LEAST BE 2'')')
  CALL ABOR1('DEFRUN:NSCAWSOLMAX SHOULD AT LEAST BE 2')
ENDIF

!*        3.7 CHECK THE USAGE OF SURFACE QUANTITIES IN SURFACE OBSERVATION OPERATORS

IF(.NOT.LECMWF  ) LVDFTRAJ=.FALSE.
IF(     L3DFGAT ) LVDFTRAJ=.FALSE.
IF(.NOT.LVDFTRAJ) LVDFMIN =.FALSE.

!*        3.8 CHECK VAR-QC PARAMETERS
!             IF GLOBAL SWITCH (LVARQCG) IS OFF, SET ALL LVARQC FALSE


!*              LHUBERMINQC : HUBER-SWITCH, BY VARIABLE AND OBS. TYPES
LVARQC(NVAR_U,NSYNOP) = .NOT. LHUBERMINQCG 
LHUBERMINQC(NVAR_U,NSYNOP) = LHUBERMINQCG 
LHUBERBGQC(NVAR_U,NSYNOP) = LHUBERBGQCG 
LVARQC(NVAR_U10,NSYNOP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U10,NSYNOP) = LHUBERMINQCG
LHUBERBGQC(NVAR_U10,NSYNOP) = LHUBERBGQCG
LVARQC(NVAR_T,NSYNOP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_T,NSYNOP) = LHUBERMINQCG
LHUBERBGQC(NVAR_T,NSYNOP) = LHUBERBGQCG
LVARQC(NVAR_PS,NSYNOP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_PS,NSYNOP) = LHUBERMINQCG
LHUBERBGQC(NVAR_PS,NSYNOP) = LHUBERBGQCG
LVARQC(NVAR_U,NAIREP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U,NAIREP) = LHUBERMINQCG
LHUBERBGQC(NVAR_U,NAIREP) = LHUBERBGQCG
LVARQC(NVAR_T,NAIREP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_T,NAIREP) = LHUBERMINQCG
LHUBERBGQC(NVAR_T,NAIREP) = LHUBERBGQCG
LVARQC(NVAR_U,NDRIBU) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U,NDRIBU) = LHUBERMINQCG
LHUBERBGQC(NVAR_U,NDRIBU) = LHUBERBGQCG
LVARQC(NVAR_U10,NDRIBU) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U10,NDRIBU) = LHUBERMINQCG
LHUBERBGQC(NVAR_U10,NDRIBU) = LHUBERBGQCG
LVARQC(NVAR_PS,NDRIBU) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_PS,NDRIBU) = LHUBERMINQCG
LHUBERBGQC(NVAR_PS,NDRIBU) = LHUBERBGQCG
LVARQC(NVAR_U,NTEMP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U,NTEMP) = LHUBERMINQCG
LHUBERBGQC(NVAR_U,NTEMP) = LHUBERBGQCG
LVARQC(NVAR_U10,NTEMP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U10,NTEMP) = LHUBERMINQCG
LHUBERBGQC(NVAR_U10,NTEMP) = LHUBERBGQCG
LVARQC(NVAR_T,NTEMP) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_T,NTEMP) = LHUBERMINQCG
LHUBERBGQC(NVAR_T,NTEMP) = LHUBERBGQCG
LVARQC(NVAR_U,NPILOT) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U,NPILOT) = LHUBERMINQCG
LHUBERBGQC(NVAR_U,NPILOT) = LHUBERBGQCG
LVARQC(NVAR_U10,NPILOT) = .NOT. LHUBERMINQCG
LHUBERMINQC(NVAR_U10,NPILOT) = LHUBERMINQCG
LHUBERBGQC(NVAR_U10,NPILOT) = LHUBERBGQCG

! RHUBEROETUNING (Tuning for Observationerror) is defined for the
! standard pressure levels (JPMXESLV) specified in sulevlay.F90
! NBDLAYER and NTROPOP are variables to define the boundary layer top and the tropopause
! HUBERLEFT and HUBERRIGHT exist for 3 different layers:
! (1=stratosphere,2=troposphere,3=boundary layer)
! Observation errors only retuned if LHUBERBGQCG is true.

IF (LHUBERBGQCG) THEN
  DO JVAR=1,JPXVAR
    DO JCTP=1,JPMXOCT
      DO JOBT=1,JPNOTP
        DO JLEV=1,NBDLAYER
          RHUBEROETUNING(JLEV,JVAR,JCTP,JOBT)=ROE_HUBER(RHUBERLEFT(JVAR,JCTP,JOBT,3),RHUBERRIGHT(JVAR,JCTP,JOBT,3))
        ENDDO
        DO JLEV=NBDLAYER+1,NTROPOP
          RHUBEROETUNING(JLEV,JVAR,JCTP,JOBT)=ROE_HUBER(RHUBERLEFT(JVAR,JCTP,JOBT,2),RHUBERRIGHT(JVAR,JCTP,JOBT,2))
        ENDDO
        DO JLEV=NTROPOP+1,JPMXESLV
          RHUBEROETUNING(JLEV,JVAR,JCTP,JOBT)=ROE_HUBER(RHUBERLEFT(JVAR,JCTP,JOBT,1),RHUBERRIGHT(JVAR,JCTP,JOBT,1))
        ENDDO
      ENDDO
    ENDDO
  ENDDO
ELSE  
  RHUBEROETUNING(:,:,:,:)=1.0_JPRB
ENDIF

LVARQC(:,:) = LVARQC(:,:) .AND. LVARQCG
LVARQC_RAD1C(:) = LVARQC_RAD1C(:) .AND. LVARQCG

LHUBERMINQC(:,:) = LHUBERMINQC(:,:) .AND. LHUBERMINQCG
LHUBERBGQC(:,:) = LHUBERBGQC(:,:) .AND. LHUBERBGQCG

!             QUADRATIC VARQC HAS TO BE ACTIVATED FROM THE START OF THE
!             MINIMIZATION, I.E. FOR ALL ITERATIONS OF THE PRESENT INNER LOOP 

IF(.NOT.LVARQCG .AND. LQVARQC) THEN
  WRITE(NULOUT,'(''DEFRUN: WARNING! LQVARQC IS RESET TO .F.'', &
   & '' BECAUSE LVARQCG=.F.'')')  
  LQVARQC=.FALSE.
ENDIF

IF(LQVARQC) THEN
  IF(NITERQC /=0) THEN
    WRITE(NULOUT,'(''DEFRUN: WARNING! NITERQC IS RESET TO ZERO'', &
     & '' BECAUSE LQVARQC=.T.'')')  
  ENDIF
  NITERQC=0
ENDIF
IF(LVARQCG .AND. .NOT.LQVARQC .AND. NITERQC == 0) THEN
  WRITE(NULOUT,'(''DEFRUN: WARNING! NITERQC IS SET TO ZERO'', &
   & '' DESPITE LQVARQC=.F. - IS THIS REALLY WHAT YOU WANT?? '')')  
ENDIF

IF(.NOT.LVARQCG .AND. LHUBERMINQCG) THEN
  WRITE(NULOUT,'(''DEFRUN: ERROR! LHUBERMINQCG IS NOT ALLOWED WITHOUT LVARQCG!'')')  
  CALL ABOR1('DEFRUN:LVARQCG=.F. and LHUBERMINQCG=.T. not allowed')
ENDIF

IF(.NOT.LHUBERBGQCG .AND. LHUBERMINQCG) THEN
  WRITE(NULOUT,'(''DEFRUN: WARNING! IT IS BEST TO SET LHUBERBGQCG=.T. WHEN LHUBERMINQCG=.T.'')')  
ENDIF

!*        3.9 PRINT NAMELISTS

WRITE(NULOUT,'(1X,/,'' NAMELIST NAMJO '')')
IF(JPNOTP > 15) WRITE(NULOUT,&
 & '('' WARNING, ONLY FIRST 15 VARIABLES PRINTED '',&
 & '' JPNOTP='',I5)') JPNOTP  

IPRT=0
DO JVAR=1,JPXVAR
  IVAR=NVAR(JVAR)
  IPRT=IPRT+1
  IF(MOD(IPRT-1,5) == 0)&
   & WRITE(NULOUT,'(/,'' OBSERVATION TYPE:'',15(1X,I8)&
   & ,/,18X,15(1x,8(''-'')))') (JOTP,JOTP=1,MIN(JPNOTP,15))  
  WRITE(NULOUT,'('' VAR='',I3,''   NOTVAR ='',15(1X,I8))')&
   & JVAR,(NOTVAR(JVAR,JOTP),JOTP=1,MIN(JPNOTP,15))  
  IF (LAVCGL)&
   & WRITE(NULOUT,'('' VAR='',I3,''   NGCVVAR='',15(1X,I8))')&
   & JVAR,(NGCVVAR(JVAR,JOTP),JOTP=1,MIN(JPNOTP,15))
  IF (  IVAR==0 ) THEN
   CYCLE
  ENDIF
  IF(LSCREEN) THEN
    WRITE(NULOUT,'('' VAR='',I3,''     RAQC='',15(1X,F8.6))')&
     & IVAR,(RAQC(IVAR,JOTP),JOTP=1,MIN(JPNOTP,15))  
    WRITE(NULOUT,'('' VAR='',I3,''     RLQC='',15(1X,F8.1)/)')&
     & IVAR,(RLQC(IVAR,JOTP),JOTP=1,MIN(JPNOTP,15))  
    WRITE(NULOUT,'('' VAR='',I3,'' RBGQC(1)='',15(1X,F8.1)/)')&
     & IVAR,(RBGQC(IVAR,JOTP,1),JOTP=1,MIN(JPNOTP,15))  
    WRITE(NULOUT,'('' VAR='',I3,'' RBGQC(2)='',15(1X,F8.1)/)')&
     & IVAR,(RBGQC(IVAR,JOTP,2),JOTP=1,MIN(JPNOTP,15))  
    WRITE(NULOUT,'('' VAR='',I3,'' RBGQC(3)='',15(1X,F8.1)/)')&
     & IVAR,(RBGQC(IVAR,JOTP,3),JOTP=1,MIN(JPNOTP,15))  
  ELSE
    WRITE(NULOUT,'('' VAR='',I3,''   LVARQC='',15(1X,L8))')&
     & IVAR,(LVARQC(IVAR,JOTP),JOTP=1,MIN(JPNOTP,15))  
    WRITE(NULOUT,'('' VAR='',I3,''  LHUBERMINQC='',15(1X,L8))')&
     & IVAR,(LHUBERMINQC(IVAR,JOTP),JOTP=1,MIN(JPNOTP,15))  
    WRITE(NULOUT,'('' VAR='',I3,''LHUBERBGQC='',15(1X,L8))')&
     & IVAR,(LHUBERBGQC(IVAR,JOTP),JOTP=1,MIN(JPNOTP,15))  
  ENDIF
ENDDO

IF (LHUBERBGQCG) THEN
  IPRT=0
  DO JOBT=1,JPNOTP
    INOCTP=MNOCTP(JOBT)
    ICTP(:)=0
    IIOBT=JOBT
    DO JCTP=1,INOCTP
      IICTP=JCTP
      CALL CMOCTMAP('SQTOCODE',NULOUT,IOBSTYP,ICODETYP,IIOBT,IICTP)
      ICTP(JCTP)=ICODETYP
    ENDDO
    DO JVAR=1,JPXVAR
      IF (LHUBERBGQC(JVAR,JOBT)) THEN
        IPRT=IPRT+1
        IF(JVAR == 1) THEN
          WRITE(NULOUT,'(/,''   OBSERVATION TYPE:'',I3)') JOBT
          WRITE(NULOUT,'(/,''                              CODE TYPE:'',12(1X,I8)&
           & ,/,18X,12(1x,8(''-'')))') (ICTP(JCTP),JCTP=1,INOCTP)
        ENDIF  
        WRITE(NULOUT,'('' VAR='',I3,''                    LHUBERMINQC='',12(1X,L8))')&
         & JVAR,(LHUBERMINQC(JVAR,JOBT),JCTP=1,INOCTP)  
!        IF(LSCREEN) THEN
          DO JLEV=1,JPHUBLEV
            WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''              RHUBERLEFT='',12(1X,F8.2))')&
             & JVAR,JLEV,(RHUBERLEFT(JVAR,JCTP,JOBT,JLEV),JCTP=1,INOCTP)  
            WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''             RHUBERRIGHT='',12(1X,F8.2))')&
             & JVAR,JLEV,(RHUBERRIGHT(JVAR,JCTP,JOBT,JLEV),JCTP=1,INOCTP)  
            WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''          RHUBEROETUNING='',12(1X,F8.2))')&
             & JVAR,JLEV,(RHUBEROETUNING(1,JVAR,JCTP,JOBT),JCTP=1,INOCTP)  
            IF (JOBT == NTEMP .OR. JOBT == NPILOT) THEN
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,'' RHUBERBGQC_SONDEGOOD(1)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC_SONDEGOOD(JVAR,JOBT,JLEV,1),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,'' RHUBERBGQC_SONDEGOOD(2)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC_SONDEGOOD(JVAR,JOBT,JLEV,2),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,'' RHUBERBGQC_SONDEGOOD(3)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC_SONDEGOOD(JVAR,JOBT,JLEV,3),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''   RHUBERBGQC_SONDEOK(1)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC_SONDEOK(JVAR,JOBT,JLEV,1),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''  RHUBERBGQC_SONDE_OK(2)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC_SONDEOK(JVAR,JOBT,JLEV,2),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''   RHUBERBGQC_SONDEOK(3)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC_SONDEOK(JVAR,JOBT,JLEV,3),JCTP=1,INOCTP)  
            ELSE
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''           RHUBERBGQC(1)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC(JVAR,JCTP,JOBT,JLEV,1),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''           RHUBERBGQC(2)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC(JVAR,JCTP,JOBT,JLEV,2),JCTP=1,INOCTP)  
              WRITE(NULOUT,'('' VAR='',I3,'' LEV='',I2,''           RHUBERBGQC(3)='',12(1X,F8.1)/)')&
               & JVAR,JLEV,(RHUBERBGQC(JVAR,JCTP,JOBT,JLEV,3),JCTP=1,INOCTP)  
            ENDIF
          ENDDO  
!        ENDIF
      ENDIF
    ENDDO
  ENDDO
  DO IHUB=5,30,5
    ZHUB=REAL(IHUB,KIND=JPRB)*0.1_JPRB
    WRITE(NULOUT,'('' (HUBERLEFT+HUBERRIGHT)/2='',F8.2,'' RHUBEROETUNING='',F8.3)')&
     & ZHUB,ROE_HUBER(ZHUB,ZHUB)
  ENDDO
ENDIF


IF (LAVCGL) THEN
  IF (ANY(NOTVAR(:,:)==-1 .AND. NGCVVAR(:,:) == 0)) THEN
    IF (LECMWF) THEN
      WRITE(NULOUT,'('' ERROR -- NGCVVAR MUST BE -1 WHERE NOTVAR IS -1'')')
      CALL ABOR1 ('DEFRUN: CAN''T CROSS-VALIDATE AGAINST EXCLUDED OBS')
    ELSE
      NGCVVAR(:,:)=NOTVAR(:,:)
    ENDIF
  ENDIF
ENDIF

IF (LSCREEN) THEN
  WRITE(NULOUT,&
   & '('' SENSOR='',I3,'' RBGQC_RAD1C(3)='',2(1X,F8.1)/)')&
   & MSENSOR_METEOSAT,(RBGQC_RAD1C(MSENSOR_METEOSAT,ICHAN,3),ICHAN=1,2)  
  WRITE(NULOUT,&
   & '('' SENSOR='',I3,'' RBGQC_RAD1C(3)='',8(1X,F8.1)/)')&
   & MSENSOR_MSG,(RBGQC_RAD1C(MSENSOR_MSG,ICHAN,3),ICHAN=1,8)  
  WRITE(NULOUT,&
   & '('' SENSOR='',I3,'' RBGQC_RAD1C(3)='',4(1X,F8.1)/)')&
   & MSENSOR_MTSATIMG,(RBGQC_RAD1C(MSENSOR_MTSATIMG,ICHAN,3),ICHAN=1,4)  
  WRITE(NULOUT,&
   & '('' SENSOR='',I3,'' RBGQC_RAD1C(3)='',4(1X,F8.1)/)')&
   & MSENSOR_VISSR,(RBGQC_RAD1C(MSENSOR_VISSR,ICHAN,3),ICHAN=1,4)  
  WRITE(NULOUT,&
   & '('' SENSOR='',I3,'' RBGQC_RAD1C(3)='',4(1X,F8.1)/)')&
   & MSENSOR_GOESIMG,(RBGQC_RAD1C(MSENSOR_GOESIMG,ICHAN,3),ICHAN=1,4)  
  WRITE(NULOUT,&
   &'('' SENSOR='',I3,'' RBGQC_RAD1C(3)='',2(1X,F8.1)/)')&
   &MSENSOR_MSG_HR,(RBGQC_RAD1C(MSENSOR_MSG_HR,ICHAN,3),ICHAN=1,8)
ENDIF

IF ( LPERTURB .AND. ( ( NAENSEMBLE * NAEMEMBER ) < 1 ) ) &
   &CALL ABOR1 ('LPERTURB .AND. NAENSEMBLE*NAEMEMBER<1')

IF (LTSCV) THEN
 TSCVER=1._JPRB
 CALL POSNAM(NULNAM,'NAMTS')
 READ (NULNAM,NAMTS)
 WRITE(NULOUT,*) "TSCVER",TSCVER
ENDIF


WRITE(NULOUT,&
 & '('' LQSCATT ='',L2,'' WSCAT5_FAC ='',F5.2,'' WSCAT6_FAC ='',F5.2,'' LVARQCG ='',L2,'' LQVARQC ='',L2 &
 & ,'' NITERQC ='',I4,'' LHUBERMINQCG ='',L2,'' LHUBERBGQCG ='',L2)')&
 & LQSCATT,WSCAT5_FAC,WSCAT6_FAC,LVARQCG,LQVARQC,NITERQC,LHUBERMINQCG,LHUBERBGQCG  
WRITE(NULOUT,&
 & '('' OBSERVATION ERROR CORRELATION: LOBSCOR ='',L2 &
 & )') LOBSCOR
IF (LOBSCOR) WRITE(NULOUT,&
 & '('' OBSERVATION ERROR CORRELATION: NOVERTRUN ='',I2 &
 & )') NOVERTRUN
IF (LOBSCOR) WRITE(NULOUT,&
 & '('' OBSERVATION ERROR CORRELATION: NSMAX_OBSCOR ='',I2 &
 & )') NSMAX_OBSCOR 
IF (LOBSCOR) WRITE(NULOUT,&
 & '('' OBSERVATION ERROR CORRELATION: horizontal length scale ='',F8.0 &
 & )') OBSHSCALE 
IF (LOBSCOR) WRITE(NULOUT,&
 & '('' OBSERVATION ERROR CORRELATION: minimum eigenvalue ='',F8.2 &
 & )') EIGMIN
IF(NACTIM <= 1) LTC=.FALSE.
WRITE(NULOUT,&
 & '('' SYNOP/DRIBU TIME CORRELATION: LTC ='',L2 &
 & ,'' RTCEFT ='',F10.1,'' RTCPART ='',F8.3)')&
 & LTC,RTCEFT,RTCPART  

IF(NHLSFGOPT == 2) THEN
  WRITE(NULOUT,&
    &'('' HLOS OPTION FOR FGCHK ='',I2 &
     &,'' ZFOELIM (M/S) ='',F8.3)')&
         &NHLSFGOPT,ZHLSFGOPT
ELSEIF(NHLSFGOPT == 3) THEN
  WRITE(NULOUT,&
    &'('' HLOS OPTION FOR FGCHK ='',I2 &
     &,'' ZFOELIM/ZFGE ='',F8.3)')&
         &NHLSFGOPT,ZHLSFGOPT
ELSEIF(NHLSFGOPT /= 1) THEN
  WRITE(NULOUT,&
    &'('' WARNING: INVOKING DEFAULT HLOS OPTION FOR FGCHK, SPECIFIED ='')')&
         &NHLSFGOPT
  NHLSFGOPT = 1
ENDIF

WRITE(NULOUT,'(1X,/,'' NAMELIST NAMMKODB '')')
WRITE(NULOUT,'('' LBIASCV='',L1,'' LTBIASBUFR='',L1)') LBIASCV,LTBIASBUFR
WRITE(NULOUT,'('' LTBIASC='',L1,'' LHBIASC='',L1)') LTBIASC,LHBIASC
WRITE(NULOUT,'('' LBIASCVO='',L1,'' LSTOBIAS='',L1)') LBIASCVO,LSTOBIAS
WRITE(NULOUT,'('' L_NEW_T_BIAS='',L1)') L_NEW_T_BIAS
WRITE(NULOUT,'('' L_NEW_T_BIAS_SOLAR_vs_all_mean='',L1)') L_NEW_T_BIAS_SOLAR_vs_all_mean
WRITE(NULOUT,'('' L_NEW_T_BIAS_SOLAR_vs_day_mean='',L1)') L_NEW_T_BIAS_SOLAR_vs_day_mean
WRITE(NULOUT,'('' L_NEW_T_BIAS_SOLAR_vs_night_m='',L1)') L_NEW_T_BIAS_SOLAR_vs_night_m
WRITE(NULOUT,'('' L_NEW_T_BIAS_ALL_MEAN='',L1)') L_NEW_T_BIAS_ALL_MEAN
WRITE(NULOUT,'('' L_NEW_T_BIAS_DAY_MEAN='',L1)') L_NEW_T_BIAS_DAY_MEAN
WRITE(NULOUT,'('' L_NEW_T_BIAS_NIGHT_MEAN='',L1)') L_NEW_T_BIAS_NIGHT_MEAN
WRITE(NULOUT,'('' L_T_REF_SONDE_BIAS_ADJUST='',L1)') L_T_REF_SONDE_BIAS_ADJUST
WRITE(NULOUT,'('' C_T_REF_SONDE_NAME='',A)') trim(C_T_REF_SONDE_NAME)
WRITE(NULOUT,'('' N_T_REF_SONDE_CODE='',I5)') N_T_REF_SONDE_CODE
WRITE(NULOUT,'('' L_NEW_RH_BIAS='',L1)') L_NEW_RH_BIAS
WRITE(NULOUT,'('' L_NEW_RH_BIAS_SOLAR_vs_all_mean='',L1)') L_NEW_RH_BIAS_SOLAR_vs_all_mean
WRITE(NULOUT,'('' L_NEW_RH_BIAS_SOLAR_vs_day_mean='',L1)') L_NEW_RH_BIAS_SOLAR_vs_day_mean
WRITE(NULOUT,'('' L_NEW_RH_BIAS_SOLAR_vs_night_m='',L1)') L_NEW_RH_BIAS_SOLAR_vs_night_m
WRITE(NULOUT,'('' L_NEW_RH_BIAS_ALL_MEAN='',L1)') L_NEW_RH_BIAS_ALL_MEAN
WRITE(NULOUT,'('' L_NEW_RH_BIAS_DAY_MEAN='',L1)') L_NEW_RH_BIAS_DAY_MEAN
WRITE(NULOUT,'('' L_NEW_RH_BIAS_NIGHT_MEAN='',L1)') L_NEW_RH_BIAS_NIGHT_MEAN
WRITE(NULOUT,'('' L_RH_REF_SONDE_BIAS_ADJUST='',L1)') L_RH_REF_SONDE_BIAS_ADJUST
WRITE(NULOUT,'('' C_RH_REF_SONDE_NAME='',A)') trim(C_RH_REF_SONDE_NAME)
WRITE(NULOUT,'('' N_RH_REF_SONDE_CODE='',I5)') N_RH_REF_SONDE_CODE


WRITE(NULOUT,'(1X,/,'' NAMELIST NAMOBS '')')
WRITE(NULOUT,'('' LCAPACH='',L2)') LCAPACH
WRITE(NULOUT,'('' LCACHMT='',L2)') LCACHMT
WRITE(NULOUT,'('' NOBSHOR ='',I5)') NOBSHOR
WRITE(NULOUT,'('' LMFSCRE = '',10L2)') LMFSCRE
WRITE(NULOUT,'('' LMFSCREEN = '',L2)') LMFSCREEN
WRITE(NULOUT,'('' L_OBS_ERR_INCREASE_Hretr = '',L2)') L_OBS_ERR_INCREASE_Hretr
WRITE(NULOUT,'('' LRSTBIAS_ODB = '',L2)') LRSTBIAS_ODB
WRITE(NULOUT,&
 & '('' LHDREJ ='',L2,'' LHDRW10 ='',L2,'' LHDRT2 ='',L2 &
 & ,'' LHDRRH2 ='',L2,'' LSLREJ ='',L2 &
 & ,'' LSLRW10 ='',L2,'' LSLRT2 ='',L2,'' LSLRRH2 ='',L2 &
 & ,'' LSOE ='',L2)')&
 & LHDREJ,LHDRW10,LHDRT2,LHDRRH2,LSLREJ,LSLRW10,LSLRT2,LSLRRH2,LSOE
WRITE(NULOUT,'('' LAMSUB_FULL = '',L2)') LAMSUB_FULL

WRITE(CLFMT_LMKCMARPL,FMT="('( ''LMKCMARPL(1:',I2,','',I2,'') = '',',I2,'L2)')")JPMXOCT,JPMXOCT

DO JOTP=1,JPMXOTP
   WRITE(NULOUT,FMT=CLFMT_LMKCMARPL)JOTP,LMKCMARPL(:,JOTP)
ENDDO
WRITE(NULOUT,'('' LSCATT_NEUTRAL = '',L2,'' LZ0FC = '',L2)') LSCATT_NEUTRAL,LZ0FC
WRITE(NULOUT,'('' LVDFTRAJ = '',L2,'' LVDFMIN = '',L2)') LVDFTRAJ,LVDFMIN

WRITE(NULOUT,'('' NAMELIST NAMSCC '')')
WRITE(NULOUT,&
 & '('' LSCDPR ='',L2,'' LSCRE4D    ='',L2,&
 & '' LTARGDROP ='',L2)')&
 & LSCDPR,LSCRE4D,LTARGDROP  
WRITE(NULOUT,&
 & '('' NTHINSCA ='',I2,'' NICESEAMASK ='',I2,'' NSCAT5_RQC ='',I2, '' NSCAWSOLMAX ='',I2)')&
 & NTHINSCA,NICESEAMASK,NSCAT5_RQC,NSCAWSOLMAX
WRITE(NULOUT,&
 & '('' RMIND_TOV     ='',F10.3,'' RFIND_TOV     ='',F10.3,&
 & '' RMIND_SSMI    ='',F10.3,&
 & '' RFIND_SSMI_PWC='',F10.3,'' RFIND_SSMI_WSP='',F10.3,&
 & '' RMIND_SATOB   ='',F10.3,'' RFIND_SATOB   ='',F10.3,&
 & '' RMIND_SATAM   ='',F10.3,'' RFIND_SATAM   ='',F10.3,&
 & '' RMIND_GPSRO   ='',F10.3,'' RFIND_GPSRO   ='',F10.3,&
 & '' RMIND_RADAR   ='',F10.3,'' RFIND_RADAR   ='',F10.3)')&
 & RMIND_TOV,RFIND_TOV &
 & ,RMIND_SSMI,RFIND_SSMI_PWC,RFIND_SSMI_WSP &
 & ,RMIND_SATOB,RFIND_SATOB &
 & ,RMIND_SATAM,RFIND_SATAM &
 & ,RMIND_GPSRO,RFIND_GPSRO &
 & ,RMIND_RADAR,RFIND_RADAR
WRITE(NULOUT,&
 & '('' RMIND_RAD1C hirs  ='',F10.3,'' RFIND_RAD1C hirs  ='',F10.3/,&
 &   '' RMIND_RAD1C msu   ='',F10.3,'' RFIND_RAD1C msu   ='',F10.3/,&
 &   '' RMIND_RAD1C ssu   ='',F10.3,'' RFIND_RAD1C ssu   ='',F10.3/,&
 &   '' RMIND_RAD1C amsuA ='',F10.3,'' RFIND_RAD1C amsuA ='',F10.3/,&
 &   '' RMIND_RAD1C amsuB ='',F10.3,'' RFIND_RAD1C amsuB ='',F10.3/,&
 &   '' RMIND_RAD1C mhs   ='',F10.3,'' RFIND_RAD1C mhs   ='',F10.3/,&
 &   '' RMIND_RAD1C iras  ='',F10.3,'' RFIND_RAD1C iras  ='',F10.3/,&
 &   '' RMIND_RAD1C mwts  ='',F10.3,'' RFIND_RAD1C mwts  ='',F10.3/,&
 &   '' RMIND_RAD1C mwhs  ='',F10.3,'' RFIND_RAD1C mwhs  ='',F10.3/,&
 &   '' RMIND_RAD1C ssmi  ='',F10.3,'' RFIND_RAD1C ssmi  ='',F10.3/,&
 &   '' RMIND_RAD1C ssmis ='',F10.3,'' RFIND_RAD1C ssmis ='',F10.3/,&
 &   '' RMIND_RAD1C mwri  ='',F10.3,'' RFIND_RAD1C mwri  ='',F10.3/,&
 &   '' RMIND_RAD1C amsre ='',F10.3,'' RFIND_RAD1C amsre ='',F10.3/,&
 &   '' RMIND_RAD1C tmi   ='',F10.3,'' RFIND_RAD1C tmi   ='',F10.3/,&
 &   '' RMIND_RAD1C windsat ='',F10.3,'' RFIND_RAD1C windsat   ='',F10.3/,&
 &   '' RMIND_RAD1C vtpr1 ='',F10.3,'' RFIND_RAD1C vtpr1 ='',F10.3/,&
 &   '' RMIND_RAD1C vtpr2 ='',F10.3,'' RFIND_RAD1C vtpr2 ='',F10.3/,&
 &   '' RMIND_RAD1C meteos='',F10.3,'' RFIND_RAD1C meteos='',F10.3/,&
 &   '' RMIND_RAD1C msg   ='',F10.3,'' RFIND_RAD1C msg   ='',F10.3/,&
 &   '' RMIND_RAD1C msg hr='',F10.3,'' RFIND_RAD1C msg hr='',F10.3/,&
 &   '' RMIND_RAD1C mtsat ='',F10.3,'' RFIND_RAD1C mtsat ='',F10.3/,&
 &   '' RMIND_RAD1C fy-2  ='',F10.3,'' RFIND_RAD1C fy-2  ='',F10.3/,&
 &   '' RMIND_RAD1C goesim='',F10.3,'' RFIND_RAD1C goesim='',F10.3)')&
 &  RMIND_RAD1C(MSENSOR_HIRS)    ,RFIND_RAD1C(MSENSOR_HIRS) &
 & ,RMIND_RAD1C(MSENSOR_MSU)     ,RFIND_RAD1C(MSENSOR_MSU) &
 & ,RMIND_RAD1C(MSENSOR_SSU)     ,RFIND_RAD1C(MSENSOR_SSU) &
 & ,RMIND_RAD1C(MSENSOR_AMSUA)   ,RFIND_RAD1C(MSENSOR_AMSUA) &
 & ,RMIND_RAD1C(MSENSOR_AMSUB)   ,RFIND_RAD1C(MSENSOR_AMSUB) &
 & ,RMIND_RAD1C(MSENSOR_MHS)     ,RFIND_RAD1C(MSENSOR_MHS) &
 & ,RMIND_RAD1C(MSENSOR_IRAS)    ,RFIND_RAD1C(MSENSOR_IRAS) &
 & ,RMIND_RAD1C(MSENSOR_MWTS)    ,RFIND_RAD1C(MSENSOR_MWTS) &
 & ,RMIND_RAD1C(MSENSOR_MWHS)    ,RFIND_RAD1C(MSENSOR_MWHS) &
 & ,RMIND_RAD1C(MSENSOR_SSMI)    ,RFIND_RAD1C(MSENSOR_SSMI)  &
 & ,RMIND_RAD1C(MSENSOR_SSMIS)   ,RFIND_RAD1C(MSENSOR_SSMIS) &
 & ,RMIND_RAD1C(MSENSOR_MWRI)    ,RFIND_RAD1C(MSENSOR_MWRI) &
 & ,RMIND_RAD1C(MSENSOR_AMSRE)   ,RFIND_RAD1C(MSENSOR_AMSRE) &
 & ,RMIND_RAD1C(MSENSOR_TMI)     ,RFIND_RAD1C(MSENSOR_TMI)   &
 & ,RMIND_RAD1C(MSENSOR_WINDSAT) ,RFIND_RAD1C(MSENSOR_WINDSAT) &
 & ,RMIND_RAD1C(MSENSOR_VTPR1)   ,RFIND_RAD1C(MSENSOR_VTPR1) &
 & ,RMIND_RAD1C(MSENSOR_VTPR2)   ,RFIND_RAD1C(MSENSOR_VTPR2) &
 & ,RMIND_RAD1C(MSENSOR_METEOSAT),RFIND_RAD1C(MSENSOR_METEOSAT) &
 & ,RMIND_RAD1C(MSENSOR_MSG)     ,RFIND_RAD1C(MSENSOR_MSG)      &
 & ,RMIND_RAD1C(MSENSOR_MSG_HR)  ,RFIND_RAD1C(MSENSOR_MSG_HR) &
 & ,RMIND_RAD1C(MSENSOR_MTSATIMG),RFIND_RAD1C(MSENSOR_MTSATIMG) &
 & ,RMIND_RAD1C(MSENSOR_VISSR)   ,RFIND_RAD1C(MSENSOR_VISSR)    &
 & ,RMIND_RAD1C(MSENSOR_GOESIMG),RFIND_RAD1C(MSENSOR_GOESIMG)  

!     ------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('DEFRUN',1,ZHOOK_HANDLE)
END SUBROUTINE DEFRUN
