SUBROUTINE SU_EVENTS(KOUT)

!**** SUBROUTINE SU_EVENTS - CMA REPORT AND DATA EVENTS

!        D. VASILJEVIC    ECMWF    17/10/1984

!**   PURPOSE
!     -------

!        DEFINE CMA REPORT AND DATA EVENTS

!**   INTERFACE
!     ---------

!        CALL SU_EVENTS(KOUT)
!     WHERE:
!            KOUT = OUTPUT UNIT

!        SU_EVENTS IS CALLED BY

!**   METHOD
!     ------

!        REPORT AND VARIABLE EVENTS ARE DEFINED.

!**   EXTERNALS
!     ---------

!       CMOCTMAP - MAP OBS. CODE TYPES
!     R. El Khatib: 31-Aug-2007 Initialise uninitialised variable

!-----------------------------------------------------------------------

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

USE YOMCMA   , ONLY : NMXOTP
USE YOMNMEV  , ONLY : NEVBITOC ,NEVUPLIM ,NEVLVLIM ,NMXREV1  ,&
 & NOREV1   ,NR1EVENT ,NMXREV2  ,NOREV2   ,NR2EVENT ,&
 & NMXDEV1  ,NODEV1   ,ND1EVENT ,NMXDEV2  ,NODEV2   ,&
 & ND2EVENT ,NMXRBLE  ,NORBLE   ,NRBLEVEN ,NMXDBLE  ,&
 & NODBLE   ,NDBLEVEN  
USE YOMCHEV  , ONLY : CR1EVENT ,CR2EVENT ,CRBLEVEN ,CH1EVENT ,&
 & CH2EVENT ,CHDBLEVE  
USE YOMCOCTP , ONLY : NSYNOP   ,NSRSCD   ,NAIREP   ,NAIRCD   ,&
 & NSATOB   ,NSTBCD   ,NDRIBU   ,NDRBCD   ,NTEMP    ,&
 & NLDTCD   ,NPILOT   ,NLDPCD   ,NSATEM   ,NSTMCD   ,&
 & NPAOB    ,NPABCD   ,NSCATT   ,NSCAT1   ,NLIMB    ,&
 & NGPSRO  

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KOUT 
INTEGER(KIND=JPIM) :: ICDSQN, ICDTYP, IOBTYP, IOTSQN, JDBLE, JDE1,&
 & JDE2, JER1, JER2, JRBLE, JSET, JTYP  ,ITYP, ITYPNEW
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "cmoctmap.intfb.h"

!*       0.         NO. OF BITS OCC. BY ANY EVENT AND LIMITS
!                   ----------------------------------------
!                   ON EVENT VALUES
!                   ---------------

IF (LHOOK) CALL DR_HOOK('SU_EVENTS',0,ZHOOK_HANDLE)
NEVBITOC = 1
NEVUPLIM = 1
NEVLVLIM = 0
!*
!-----------------------------------------------------------------------

!        1.         CMA REPORT EVENTS (PART 1)
!                   --------------------------

!*          1.0     PRESET

!*          1.0.1   MAX. NO. OF EVENTS IN PART 1

NMXREV1  = 30

!*          1.0.2   SET THEM TO MISSING OR EMPTY

DO JSET = 1 , NMXREV1
  NR1EVENT(JSET) = JSET
  CR1EVENT(JSET) = '  '
ENDDO

!*          1.0.3   NO. OF DEFINED EVENTS

NOREV1  = 16

!*          1.1     NO DATA IN THE REPORT (EVENT NO. 1)

NR1EVENT( 1) =   1
CR1EVENT( 1) = ' 1=NO DATA IN THE REPORT'

!*          1.2     ALL DATA REJECTED (EVENT NO. 2)

NR1EVENT( 2) =   2
CR1EVENT( 2) = ' 2=ALL DATA REJECTED'

!*          1.3     BAD REPORTING PRACTICE

NR1EVENT( 3) =   3
CR1EVENT( 3) = ' 3=BAD REPORTING PRACTICE'

!*          1.4     REJECTED DUE TO RDB FLAG

NR1EVENT( 4) =   4
CR1EVENT( 4) = ' 4=REJECTED DUE TO RDB FLAG'

!*          1.5      ACTIVATED DUE TO RDB FLAG

NR1EVENT( 5) =   5
CR1EVENT( 5) = ' 5=ACTIVATED DUE TO RDB FLAG'

!*          1.6     ACTIVATED BY WHITELIST

NR1EVENT( 6) =   6
CR1EVENT( 6) = ' 6=ACTIVATED BY WHITELIST'

!*          1.7     HORIZONTAL POSITION OUT OF RANGE

NR1EVENT( 7) =   7
CR1EVENT( 7) = ' 7=HORIZONTAL POSITION OUT OF RANGE'

!*          1.8     VERTICAL POSITION OUT OF RANGE

NR1EVENT( 8) =   8
CR1EVENT( 8) = ' 8=VERTICAL POSITION OUT OF RANGE'

!*          1.9     TIME OUT OF RANGE

NR1EVENT( 9) =   9
CR1EVENT( 9) = ' 9=TIME OUT OF RANGE'

!*          1.10    REDUNDANT REPORT

NR1EVENT(10) =  10
CR1EVENT(10) = '10=REDUNDANT REPORT'

!*          1.11    REPORT OVER LAND

NR1EVENT(11) =  11
CR1EVENT(11) = '11=REPORT OVER LAND'

!*          1.12    REPORT OVER SEA

NR1EVENT(12) =  12
CR1EVENT(12) = '12=REPORT OVER SEA'

!*          1.13    MISSING STATION ALTITUDE

NR1EVENT(13) =  13
CR1EVENT(13) = '13=MISSING STATION ALTITUDE'

!*          1.14    MODEL SUR. TOO FAR FROM STAT. ALT.

NR1EVENT(14) =  14
CR1EVENT(14) = '14=MODEL SUR. TOO FAR FROM STAT. ALT.'

!*          1.15    REPORT REJECTED THROUGH THE NAMELIST

NR1EVENT(15) =  15
CR1EVENT(15) = '15=REPORT REJECTED THROUGH THE NAMELIST'

!*          1.16    FAILED QUALITY CONTROL

NR1EVENT(16) =  16
CR1EVENT(16) = '16=FAILED QUALITY CONTROL'
!*
!-----------------------------------------------------------------------

!        2.         CMA REPORT EVENTS (PART 2)
!                   --------------------------

!*          2.0     PRESET

!*          2.0.1   MAX. NO. OF EVENTS IN PART 2

NMXREV2  = 30

!*          2.0.2   SET ALL OF THEM TO MISSING OR EMPTY

DO JTYP = 1 , NMXOTP
  DO JSET = 1 , NMXREV2
    NR2EVENT(JSET,JTYP) = JSET
    CR2EVENT(JSET,JTYP) = '  '
  ENDDO
ENDDO
NOREV2(:)=0

!*          2.1     SYNOP EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NSYNOP,NSRSCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  0

!*          2.1.1   NO DEFINED EVENTS

!*          2.2     AIREP EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NAIREP,NAIRCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  0

!*          2.2.1   NO DEFINED EVENTS

!*          2.3     SATOB EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NSATOB,NSTBCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  0

!*          2.3.1   NO DEFINED EVENTS

!*          2.4     DRIBU EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NDRIBU,NDRBCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  0

!*          2.4.1   NO DEFINED EVENTS

!*          2.5     TEMP EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NTEMP ,NLDTCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  3

!*          2.5.1   OLD STYLE Z BIAS CORRECTION

NR2EVENT( 1,IOTSQN) =   1
CR2EVENT( 1,IOTSQN) = ' 1=OLD STYLE Z BIAS CORRECTION APPLIED'

!*          2.5.2   T BIAS CORRECTION

NR2EVENT( 2,IOTSQN) =   2
CR2EVENT( 2,IOTSQN) = ' 2=NEW STYLE T BIAS CORRECTION APPLIED'

!*          2.5.3   H BIAS CORRECTION

NR2EVENT( 3,IOTSQN) =   3
CR2EVENT( 3,IOTSQN) = ' 3=H BIAS CORRECTION APPLIED'

!*          2.6     PILOT EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NPILOT,NLDPCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  2

!*          2.6.1   AMERICAN WIND PROFILER

NR2EVENT( 1,IOTSQN) =   1
CR2EVENT( 1,IOTSQN) = ' 1=AMERICAN WIND PROFILER'

!*          2.6.2   EUROPEAN WIND PROFILER

NR2EVENT( 2,IOTSQN) =   2
CR2EVENT( 2,IOTSQN) = ' 2=EUROPEAN WIND PROFILER'

!*          2.7     SATEM EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NSATEM,NSTMCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  1

!*          2.7.1   THINNED SSMI REPORT

NR2EVENT( 1,IOTSQN) =   1
CR2EVENT( 1,IOTSQN) = ' 1=THINNED REPORT'

!*          2.8     PAOB EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NPAOB ,NPABCD,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  0

!*          2.9     SCAT. EVENTS

CALL CMOCTMAP('CODETOSQ',KOUT,NSCATT,NSCAT1,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  4

!*          2.9.1   THINNED REPORT

NR2EVENT( 1,IOTSQN) =   1
CR2EVENT( 1,IOTSQN) = ' 1=THINNED REPORT'

!*          2.9.2   REPORTED WIND DIRECTIONS ARE TOO CLOSE TOGETHER

NR2EVENT( 2,IOTSQN) =   2
CR2EVENT( 2,IOTSQN) = ' 2=REPORTED WIND DIRECTIONS ARE TOO CLOSE TOGETHER'

!*          2.9.3   REPORT NOT IN QuikSCAT/OCEANSAT2 SWEET SPOTS

NR2EVENT( 3,IOTSQN) =   3
CR2EVENT( 3,IOTSQN) = ' 3=REPORT NOT IN QuikSCAT/OCEANSAT-2 SWEET SPOTS'

!*          2.9.4   REPORT CONTAMINATED BY RAIN

NR2EVENT( 4,IOTSQN) =   4
CR2EVENT( 4,IOTSQN) = ' 4=REPORT CONTAMINATED BY RAIN'

!*          2.10    LIMB OBSERVATIONS EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NLIMB,NGPSRO,IOTSQN,ICDSQN)
NOREV2(IOTSQN)  =  0

!*          2.10.1  NO DEFINED EVENTS

!*
!-----------------------------------------------------------------------

!        3.         CMA DATA EVENTS (PART 1)
!                   ------------------------

!*          3.0     PRESET

!*          3.0.1   MAX. NO. OF EVENTS IN PART 1

NMXDEV1  = 30

!*          3.0.2   SET ALL OF THEM TO MISSING OR EMPTY

DO JSET = 1 , NMXDEV1
  ND1EVENT(JSET) = JSET
  CH1EVENT(JSET) = '  '
ENDDO

!*          3.0.3   NO. OF DEFINED EVENTS

NODEV1  = 28

!*          3.1     MISSING VERTICAL COORDINATE

ND1EVENT( 1) =   1
CH1EVENT( 1) = ' 1=MISSING VERTICAL COORDINATE'

!*          3.2     MISSING OBSERVED VALUE

ND1EVENT( 2) =   2
CH1EVENT( 2) = ' 2=MISSING OBSERVED VALUE'

!*          3.3     MISSING FIRST GUESS VALUE

ND1EVENT( 3) =   3
CH1EVENT( 3) = ' 3=MISSING FIRST GUESS VALUE'

!*          3.4     REJECTED DUE TO RDB FLAG

ND1EVENT( 4) =   4
CH1EVENT( 4) = ' 4=REJECTED DUE TO RDB FLAG'

!*          3.5     ACTIVATED DUE TO RDB FLAG

ND1EVENT( 5) =   5
CH1EVENT( 5) = ' 5=ACTIVATED DUE TO RDB FLAG'

!*          3.6     ACTIVATED BY WHITELIST

ND1EVENT( 6) =   6
CH1EVENT( 6) = ' 6=ACTIVATED BY WHITELIST'

!*          3.7     BAD REPORTING PRACTICE

ND1EVENT( 7) =   7
CH1EVENT( 7) = ' 7=BAD REPORTING PRACTICE'

!*          3.8     VERTICAL POSITION OUT OF RANGE

ND1EVENT( 8) =   8
CH1EVENT( 8) = ' 8=VERTICAL POSITION OUT OF RANGE'

!*          3.9     REFERENCE LEVEL POSITION OUT OF RANGE

ND1EVENT( 9) =   9
CH1EVENT( 9) = ' 9=REFERENCE LEVEL POSITION OUT OF RANGE'

!*          3.10    TOO BIG FIRST GUESS DEPARTURE

ND1EVENT(10) =  10
CH1EVENT(10) = '10=TOO BIG FIRST GUESS DEPARTURE'

!*          3.11    TOO BIG DEPARTURE IN ASSIMILATION

ND1EVENT(11) =  11
CH1EVENT(11) = '11=TOO BIG DEPARTURE IN ASSIMILATION'

!*          3.12    TOO BIG OBSERVATION ERROR

ND1EVENT(12) =  12
CH1EVENT(12) = '12=TOO BIG OBSERVATION ERROR'

!*          3.13    REDUNDANT DATUM

ND1EVENT(13) =  13
CH1EVENT(13) = '13=REDUNDANT DATUM'

!*          3.14    REDUNDANT LEVEL

ND1EVENT(14) =  14
CH1EVENT(14) = '14=REDUNDANT LEVEL'

!*          3.15    REPORT OVER LAND

ND1EVENT(15) =  15
CH1EVENT(15) = '15=REPORT OVER LAND'

!*          3.16    REPORT OVER SEA

ND1EVENT(16) =  16
CH1EVENT(16) = '16=REPORT OVER SEA'

!*          3.17    NOT AN ANALYSIS VARIABLE

ND1EVENT(17) =  17
CH1EVENT(17) = '17=NOT AN ANALYSIS VARIABLE'

!*          3.18    DUPLICATED DATUM/LEVEL

ND1EVENT(18) =  18
CH1EVENT(18) = '18=DUPLICATED DATUM/LEVEL'

!*          3.19    TOO MANY SURFACE DATA/LEVELS

ND1EVENT(19) =  19
CH1EVENT(19) = '19=TOO MANY SURFACE DATA/LEVELS'

!*          3.20    MULTI LEVEL CHECK

ND1EVENT(20) =  20
CH1EVENT(20) = '20=MULTI LEVEL CHECK'

!*          3.21    LEVEL SELECTION

ND1EVENT(21) =  21
CH1EVENT(21) = '21=LEVEL SELECTION'

!*          3.22    VERTICAL CONSISTENCY CHECK

ND1EVENT(22) =  22
CH1EVENT(22) = '22=VERTICAL CONSISTENCY CHECK'

!*          3.23    VERTICAL COORDINATE CHANGED FROM Z TO P

ND1EVENT(23) =  23
CH1EVENT(23) = '23=VERTICAL COORDINATE CHANGED FROM Z TO P'

!*          3.24    DATUM REJECTED THROUGH THE NAMELIST

ND1EVENT(24) =  24
CH1EVENT(24) = '24=DATUM REJECTED THROUGH THE NAMELIST'

!*          3.25    COMBINED FLAGGING

ND1EVENT(25) =  25
CH1EVENT(25) = '25=COMBINED FLAGGING'

!*          3.26    DATUM REJECTED DUE TO REJECTED REPORT

ND1EVENT(26) =  26
CH1EVENT(26) = '26=DATUM REJECTED DUE TO REJECTED REPORT'

!*          3.27    VARIATIONAL QC PERFORMED

ND1EVENT(27) =  27
CH1EVENT(27) = '27=VARIATIONAL QC PERFORMED'

!*          3.28    OBS ERROR INCREASED

ND1EVENT(28) =  28
CH1EVENT(28) = '28=OBS ERR INCREASED'

!*
!-----------------------------------------------------------------------

!        4.         CMA DATA EVENTS (PART 2)
!                   ------------------------

!*          4.0     PRESET

!*          4.0.1   MAX. NO. OF EVENTS IN PART 2

NMXDEV2  = 30

!*          4.0.2   SET ALL OF THEM TO MISSING OR EMPTY

DO JTYP = 1 , NMXOTP
  DO JSET = 1 , NMXDEV2
    ND2EVENT(JSET,JTYP) = JSET
    CH2EVENT(JSET,JTYP) = '  '
  ENDDO
ENDDO
NODEV2(:)=0

!*          4.1     SYNOP EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NSYNOP,NSRSCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  1

!*          4.1.1   BIAS CORRECTED VALUE

ND2EVENT( 1,IOTSQN) =   1
CH2EVENT( 1,IOTSQN) = ' 1=BIAS CORRECTED Ps'

!*          4.1.1   NO DEFINED EVENTS

!*          4.2     AIREP EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NAIREP,NAIRCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  0

!*          4.2.1   NO DEFINED EVENTS

!*          4.3     SATOB EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NSATOB,NSTBCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  0

!*          4.3.1   NO DEFINED EVENTS

!*          4.4     DRIBU EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NDRIBU,NDRBCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  1

!*          4.4.1   BIAS CORRECTED VALUE

ND2EVENT( 1,IOTSQN) =   1
CH2EVENT( 1,IOTSQN) = ' 1=BIAS CORRECTED Ps'

!*          4.4.1   NO DEFINED EVENTS

!*          4.5     TEMP EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NTEMP ,NLDTCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  1

!*          4.5.1   BIAS CORRECTED VALUE USED

ND2EVENT( 1,IOTSQN) =   1
CH2EVENT( 1,IOTSQN) = ' 1=BIAS CORRECTED VALUE USED'

!*          4.6     PILOT EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NPILOT,NLDPCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  0

!*          4.6.1   NO DEFINED EVENTS

!*          4.7     SATEM EVENTS

CALL CMOCTMAP('CODETOSQ',KOUT,NSATEM,NSTMCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  5

!*          4.7.1   NOT PREDEFINED LAYER

ND2EVENT( 1,IOTSQN) =   1
CH2EVENT( 1,IOTSQN) = ' 1=NOT PREDEFINED LAYER'

!*          4.7.2   LAYER FORMED BY THINNING UP

ND2EVENT( 2,IOTSQN) =   2
CH2EVENT( 2,IOTSQN) = ' 2=LAYER FORMED BY THINNING UP'

!*          4.7.3   LAYER FORMED BY SUMMING UP

ND2EVENT( 3,IOTSQN) =   3
CH2EVENT( 3,IOTSQN) = ' 3=LAYER FORMED BY SUMMING UP'

!*          4.7.4   LAYER FORMED BY SUMMING UP

ND2EVENT( 4,IOTSQN) =   4
CH2EVENT( 4,IOTSQN) = ' 4=CHANNEL NOT USED IN ANALYSIS'

!*          4.7.5   LAYER FORMED BY SUMMING UP

ND2EVENT( 5,IOTSQN) =   5
CH2EVENT( 5,IOTSQN) = ' 5=OVERWRITTEN BY ADVAR'

!*          4.8     PAOB EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NPAOB ,NPABCD,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  0

!*          4.8.1   NO DEFINED EVENTS

!*          4.9     SCAT. EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NSCATT,NSCAT1,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  0

!*          4.9.1   NO DEFINED EVENTS

!*          4.10    LIMB OBSERVATIONS EVENTS (NO. OF DEFINED EVENTS)

CALL CMOCTMAP('CODETOSQ',KOUT,NLIMB,NGPSRO,IOTSQN,ICDSQN)
NODEV2(IOTSQN)  =  0

!*          4.10.1  NO DEFINED EVENTS

!*
!-----------------------------------------------------------------------

!        5.         CMA REPORT BLACKLIST EVENTS
!                   ---------------------------

!*          5.0     PRESET

!*          5.0.1   MAX. NO. OF REPORT BLACKLIST EVENTS

NMXRBLE  = 31

!*          5.0.2   SET THEM TO MISSING OR EMPTY

DO JSET = 1 , NMXRBLE
  NRBLEVEN(JSET) = JSET
  CRBLEVEN(JSET) = '  '
ENDDO

!*          5.0.3   NO. OF DEFINED EVENTS

NORBLE  = 17

!*          5.1     MONTHLY MONITORING

NRBLEVEN( 1) =   1
CRBLEVEN( 1) = ' 1=MONTHLY MONITORING'

!*          5.2     CONSTANT BLACKLISTING

NRBLEVEN( 2) =   2
CRBLEVEN( 2) = ' 2=CONSTANT BLACKLISTING'

!*          5.3     EXPERIMENTAL BLACKLISTING

NRBLEVEN( 3) =   3
CRBLEVEN( 3) = ' 3=EXPERIMENTAL BLACKLISTING'

!*          5.4     WHITELISTING

NRBLEVEN( 4) =   4
CRBLEVEN( 4) = ' 4=WHITELISTING'

!*          5.5     EXPERIMENTAL WHITELISTING

NRBLEVEN( 5) =   5
CRBLEVEN( 5) = ' 5=EXPERIMENTAL WHITELISTING'

!*          5.6      OBSERVATION TYPE BLACKLISTED

NRBLEVEN( 6) =   6
CRBLEVEN( 6) = ' 6=OBSERVATION TYPE BLACKLISTED'

!*          5.7     STATION ID BLACKLISTED

NRBLEVEN( 7) =   7
CRBLEVEN( 7) = ' 7=STATION ID BLACKLISTED'

!*          5.8     CODE TYPE BLACKLISTED

NRBLEVEN( 8) =   8
CRBLEVEN( 8) = ' 8=CODE TYPE BLACKLISTED'

!*          5.9     INSTRUMENT TYPE BLACKLISTED

NRBLEVEN( 9) =   9
CRBLEVEN( 9) = ' 9=INSTRUMENT TYPE BLACKLISTED'

!*          5.10    DATE BLACKLISTED

NRBLEVEN(10) =  10
CRBLEVEN(10) = '10=DATE BLACKLISTED'

!*          5.11    TIME BLACKLISTED

NRBLEVEN(11) =  11
CRBLEVEN(11) = '11=TIME BLACKLISTED'

!*          5.12    LATITUDE BLACKLISTED

NRBLEVEN(12) =  12
CRBLEVEN(12) = '12=LATITUDE BLACKLISTED'

!*          5.13    LONGITUDE BLACKLISTED

NRBLEVEN(13) =  13
CRBLEVEN(13) = '13=LONGITUDE BLACKLISTED'

!*          5.14    STATION ALTITUDE BLACKLISTED

NRBLEVEN(14) =  14
CRBLEVEN(14) = '14=STATION ALTITUDE BLACKLISTED'

!*          5.15    BLACKLISTED DUE TO LAND/SEA MASK

NRBLEVEN(15) =  15
CRBLEVEN(15) = '15=BLACKLISTED DUE TO LAND/SEA MASK'

!*          5.16    BLACKLISTED DUE TO MODEL OROGRAPHY

NRBLEVEN(16) =  16
CRBLEVEN(16) = '16=BLACKLISTED DUE TO MODEL OROGRAPHY'

!*          5.17    BLACKLISTED DUE TO DISTANCE FROM REF. POINT

NRBLEVEN(17) =  17
CRBLEVEN(17) = '17=BLACKLISTED DUE TO DISTANCE FROM REF. POINT'
!*
!-----------------------------------------------------------------------

!        6.         CMA DATA BLACKLIST EVENTS
!                   -------------------------

!*          6.0     PRESET

!*          6.0.1   MAX. NO. OF DATA BLACKLIST EVENTS

NMXDBLE  = 30

!*          6.0.2   SET ALL OF THEM TO MISSING OR EMPTY

DO JSET = 1 , NMXDBLE
  NDBLEVEN(JSET) = JSET
  CHDBLEVE(JSET) = '  '
ENDDO

!*          6.0.3   NO. OF DEFINED EVENTS

NODBLE  = 6

!*          6.1     PRESSURE BLACKLISTED

NDBLEVEN( 1) =   1
CHDBLEVE( 1) = ' 1=PRESSURE BLACKLISTED'

!*          6.2     VARIABLE NAME BLACKLISTED

NRBLEVEN( 2) =   2
CRBLEVEN( 2) = ' 2=VARIABLE NAME BLACKLISTED'

!*          6.3     BLACKLISTED DUE TO PRESSURE CODE

NRBLEVEN( 3) =   3
CRBLEVEN( 3) = ' 3=BLACKLISTED DUE TO PRESSURE CODE'

!*          6.4     BLACKLISTED DUE TO DISTANCE FROM REF. POINT

NRBLEVEN( 4) =   4
CRBLEVEN( 4) = ' 4=BLACKLISTED DUE TO TYPE OF VERTICAL COORDINATE'

!*          6.5     BLACKLISTED DUE TO OBSERVED VALUE

NRBLEVEN( 5) =   5
CRBLEVEN( 5) = ' 5=BLACKLISTED DUE TO OBSERVED VALUE'

!*          6.6     BLACKLISTED DUE TO FIRST GUESS DEPARTURE

NRBLEVEN( 6) =   6
CRBLEVEN( 6) = ' 6=BLACKLISTED DUE TO FIRST GUESS DEPARTURE'
!*
!-----------------------------------------------------------------------

!        7.         SETUP
!                   -----

WRITE(KOUT,'(''0EVENTS SETUP'')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'(''   CMA REPORT EVENTS (PART 1) STRUCTURE:'')')
WRITE(KOUT,'(''   -------------------------------------'')')
WRITE(KOUT,'('' '')')
DO JER1 = 1 , NOREV1
  WRITE(KOUT,'(''   '',A)') CR1EVENT(JER1)
ENDDO

WRITE(KOUT,'('' '')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'(''   CMA REPORT EVENTS (PART 2) STRUCTURE:'')')
WRITE(KOUT,'(''   -------------------------------------'')')
ITYP=1
DO WHILE(ITYP<=NMXOTP)
  ICDSQN=1
  ITYPNEW=ITYP
  CALL CMOCTMAP('SQTOCODE',KOUT,IOBTYP,ICDTYP,ITYPNEW,ICDSQN)
  WRITE(KOUT,'('' '')')
  WRITE(KOUT,'(''   OBSERVATION TYPE: '',I5)') IOBTYP
  WRITE(KOUT,'('' '')')
  DO JER2 = 1 , NOREV2(ITYPNEW)
    WRITE(KOUT,'(''   '',A)') CR2EVENT(JER2,ITYPNEW)
  ENDDO
  IF(ITYPNEW==ITYP)THEN
    ITYP=ITYP+1
  ELSE
    ITYP=ITYPNEW+1
  ENDIF
ENDDO

WRITE(KOUT,'('' '')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'(''   CMA DATUM EVENTS (PART 1) STRUCTURE:'')')
WRITE(KOUT,'(''   ------------------------------------'')')
WRITE(KOUT,'('' '')')
DO JDE1 = 1 , NODEV1
  WRITE(KOUT,'(''   '',A)') CH1EVENT(JDE1)
ENDDO

WRITE(KOUT,'('' '')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'(''   CMA DATUM EVENTS (PART 2) STRUCTURE:'')')
WRITE(KOUT,'(''   -------------------------------------'')')
ITYP=1
DO WHILE(ITYP<=NMXOTP)
  ICDSQN=1
  ITYPNEW=ITYP
  CALL CMOCTMAP('SQTOCODE',KOUT,IOBTYP,ICDTYP,ITYPNEW,ICDSQN)
  WRITE(KOUT,'('' '')')
  WRITE(KOUT,'(''   OBSERVATION TYPE: '',I5)') IOBTYP
  WRITE(KOUT,'('' '')')
  DO JDE2 = 1 , NODEV2(ITYPNEW)
    WRITE(KOUT,'(''   '',A)') CH2EVENT(JDE2,ITYPNEW)
  ENDDO
  IF(ITYPNEW==ITYP)THEN
    ITYP=ITYP+1
  ELSE
    ITYP=ITYPNEW+1
  ENDIF
ENDDO

WRITE(KOUT,'('' '')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'(''   CMA REPORT BLACKLIST EVENTS STRUCTURE:'')')
WRITE(KOUT,'(''   --------------------------------------'')')
WRITE(KOUT,'('' '')')
DO JRBLE = 1 , NORBLE
  WRITE(KOUT,'(''   '',A)') CRBLEVEN(JRBLE)
ENDDO

WRITE(KOUT,'('' '')')
WRITE(KOUT,'('' '')')
WRITE(KOUT,'(''   CMA DATUM BLACKLIST EVENTS STRUCTURE:'')')
WRITE(KOUT,'(''   -------------------------------------'')')
WRITE(KOUT,'('' '')')
DO JDBLE = 1 , NODBLE
  WRITE(KOUT,'(''   '',A)') CHDBLEVE(JDBLE)
ENDDO
!*
!-----------------------------------------------------------------------

!        8.         RETURN
!                   ------

IF (LHOOK) CALL DR_HOOK('SU_EVENTS',1,ZHOOK_HANDLE)
END SUBROUTINE SU_EVENTS
