SUBROUTINE SULUN(KULOUT)

!**** *SULUN * - Routine to initialize the common YOMLUN

!     Purpose.
!     --------
!           Initialize and print the common YOMLUN

!**   Interface.
!     ----------
!        *CALL* *SULUN

!        Explicit arguments : KULOUT - Unit used for diagnostic output (output)
!        --------------------

!        Implicit arguments :
!        --------------------
!        COMMON YOMLUN and QALOGO

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------

!     Reference.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     Author.
!     -------
!        Mats Hamrud and Philippe Courtier  *ECMWF*

!     Modifications.
!     --------------
!        Original : 87-10-15
!        MODIFIED : D. VASILJEVIC & B. HECKLEY UNIT NUMBERS FOR FORECAST
!                                              ERRORS AND OBS. (CMA)
!                                              ARRAYS
!                   PASCAL MARQUET : 90-11-15  UNIT NUMBERS "NPINMI" FOR
!                                              HELP ARRAYS OF IMPLICIT NMI
!                   PASCAL MARQUET : 90-04-01  UNIT NUMBERS NFREQ2 and NLTYPE
!        F.RABIER AND J.N THEPAUT  : 91-01-15  UNIT NUMBERS FOR 4-D DIAG.
!        modified by Michel Deque 91-02-28  Update of climatic fields
!                   P. GAUTHIER    : 91-04-22  UNIT NUMBERS NULUSR1,...,
!                                              NULUSR5, AVAILABLE FOR ANY
!                                              USER DEFINED TASK
!        D. VASILJEVIC 91-05-23: RESORT OF OBS. (CMA) UNIT NUMBERS
!                   Bill Heckley   : 91-06-26  UNIT NUMBER "NFCEVC" FOR
!                                              COMPRESSED ERROR CLIMATOLOGY
!        modified by Philippe Courtier 91-07-04 Legendre Polynomials
!                   Pascal Marquet : 91-10-15  UNIT NUMBER "NTIDE"
!                   C. Blondin & P. Caille     unit numbers for french OI
!                   31.05.91                   outputs and obs. files
!                   P. Benichou     : 91-10-01  unit numbers for french OI
!                   F. Taillefer    : 91-10-01  unit number for SST field
!                   C. Dreveton     : 92-05-25  unit number for coupled fields(5
!                   R. El Khatib    : 92-06-12  unit number for history witness
!                                               file
!                   V. Ducrocq      : 92-07-01  unit numbers for coupling
!                                     ALADIN files.
!                   D. Giard        : 93-08-2 4 unit number for bias (dig  filt)
!                   D. Dent         : 93-10-27 unit number for PP dirlist
!                                              and for display files
!                   R. El Khatib    : 94-02-15 reorder unit numbers
!                   R. El Khatib    : 94-03-02 Full-POS unit numbers
!                   F. Taillefer    : 95-08-18 unit numbers for CANARI stat.
!                                              + suppress SST file and qalogo
!                   M. Janiskova    : 96-11-13 unit number for transmiss.
!                                              coef. for simpl.rad.scheme
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!                   N. Bormann      : 04-12-23 Unit number for RTLIMB coeffs.
!                   V. Guidard    01-Apr-2004 unit number for Jk input
!                   K. Yessad     13-Sep-2005 add NULTRAJHR.
!                   K. Yessad     01-Mar-2006 add NULTRAJBG.
!                   C. Larsson    08-May-2006 Added unit for xmlstats
!                   M. Ko"hler    06-Jun-2006 Single Column Model option (LSCMEC) 
!     ------------------------------------------------------------------

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

USE YOMLUN   , ONLY : NULOUT   ,NULNAM   ,NCMAFL   ,NPOSSH   ,&
 & NTIDE    ,NTRJSH   ,NINMSH   ,&
 & NINISH   ,NINIGG   ,NFGISH   ,&
 & NPPPSH   ,NULTMP   ,NPODDH   ,&
 & NULCL1   ,NULCL2   ,&
 & NULASE   ,NULASS   ,NULDILA  ,NULCONT  ,&
 & NULROTC  ,NULRCF   ,NULHWF   ,NULUSR1  ,NULUSR2  ,&
 & NULUSR3  ,NULUSR4  ,NULUSR5  ,NULCO    ,NEFLS    ,&
 & NEFLSS   ,NBIAS    ,NPDIRL   ,NULSTAT  ,&
 & NULFP01  ,NULFP02  ,NULFP03  ,NULFP04  ,NULFP05  ,&
 & NULFP06  ,NULFP07  ,NULFP08  ,NULFP09  ,NULFP10  ,&
 & NULFP11  ,NULFP12  ,NULFP13  ,NULFP14  ,NULFP15  ,&
 & NULFPOS  ,NSCRTCH  ,NULERR   ,NULREF   ,&
 & NULRAD   ,NUO3CH1  ,NUO3CH2  ,NTCSR    ,NULRTL   ,&
 & NSCASPE  ,NSCASIG  ,NSCATAB  ,NEGASH   ,NULTRAJHR,NULTRAJBG

USE YOMCT0   , ONLY : LSCMEC

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(INOUT) :: KULOUT 

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

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "sumpout.intfb.h"

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

IF (LHOOK) CALL DR_HOOK('SULUN',0,ZHOOK_HANDLE)

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

!        1.    Initialize YOMLUN.
!              ------------------

NULERR     =  0
NULSTAT    =  1

!     If DM version diagnostic output optionally only on subset of PEs
!     NULNAM is set in sumpini.F to JPNULNAM defined in pardim.h  

KULOUT   =  20
! KULOUT.XML => LUN=40, OPENS IN GSTAT !

IF (.NOT. LSCMEC) THEN
  CALL SUMPOUT(KULOUT)
ENDIF

NSCRTCH    =  8
NULFP10    =  9
NULCL1     = 10
NULCL2     = 11
NULFP09    = 12
NULFP08    = 13
NULFP07    = 14
NULASE     = 16
NULASS     = 17
NULFP06    = 18
NULFP05    = 19
NULREF     = 23
NULRAD     = 25
NULRTL     = 26
NCMAFL( 1) = 20
NCMAFL( 2) = 21
NCMAFL( 3) = 22
NCMAFL( 4) = 23
NCMAFL( 5) = 24
NCMAFL( 6) = 25
NCMAFL( 7) = 26
NCMAFL( 8) = 27
NCMAFL( 9) = 28
NCMAFL(10) = 29
NULFP04    = 30
NULFP03    = 43
NULDILA    = 46
NULCONT    = 47
NULROTC    = 49
NULFP02    = 50
NPOSSH     = 51
NPODDH     = 53
NULFP01    = 54
NULCO      = 55
NTIDE      = 66
NTRJSH     = 71
NULTRAJHR  = 72
NEFLSS     = 73
NULFPOS    = 74
NULTMP     = 77
NEFLS      = 78
NINMSH     = 79
NINISH     = 81
NINIGG     = 82
NFGISH     = 83
NBIAS      = 90
NPPPSH     = 91
NPDIRL     = 92
NULHWF     = 93
NULRCF     = 94
NULUSR1    = 95
NULUSR2    = 96
NULUSR3    = 97
NULUSR4    = 98
NULUSR5    = 99
NULFP11    = 31
NULFP12    = 32
NULFP13    = 33
NULFP14    = 34
NULFP15    = 35

NSCATAB    = 36
NSCASIG    = 37
NSCASPE    = 38

NEGASH     = 39


NTCSR  = 15
NUO3CH1    = 16
NUO3CH2    = 17

NULTRAJBG  = NFGISH

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

!        2.    Print YOMLUN.
!              -------------

WRITE(UNIT=KULOUT,FMT='(&
 & '' NULOUT='',I3,'' NULNAM='',I3,/,&
 & '' NCMAFL='',10(I2,1X),/,&
 & '' NPOSSH='',I3,'' NPODDH='',I3,'' NULCO='',I3,&
 & '' NTIDE ='',I3  )')&
 & KULOUT,NULNAM,NCMAFL &
 & ,NPOSSH,NPODDH,NULCO &
 & ,NTIDE  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NULDILA='',I3,'' NULCONT='',I3,&
 & '' NULROTC='',I3,&
 & '' NINISH='',I3,'' NINIGG='',I3,&
 & '' NFGISH='',I3,/,&
 & '' NTRJSH='',I3,&
 & '' NPPPSH='',I3,&
 & '' NULCL1='',I3,'' NULCL2='',I3,/,&
 & '' NULASE='',I3,'' NULASS='',I3,&
 & '' NULRCF='',I3,'' NULHWF='',I3)')&
 & NULDILA,NULCONT,NULROTC &
 & ,NINISH,NINIGG,NFGISH &
 & ,NTRJSH,NPPPSH,NULCL1,NULCL2 &
 & ,NULASE,NULASS,NULRCF,NULHWF  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NULUSR1 = '',I3,'' NULUSR2 = '',I3,'' NULUSR3 = '',I3,&
 & '' NULUSR4 = '',I3,'' NULUSR5 = '',I3)')&
 & NULUSR1,NULUSR2,NULUSR3,NULUSR4,NULUSR5  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NEFLS = '',I3,'' NEFLSS = '',I3,'' NULTMP = '',I3)')&
 & NEFLS,NEFLSS,NULTMP  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NULFP01 = '',I3,'' NULFP02 = '',I3,'' NULFP03 = '',I3,&
 & '' NULFP04 = '',I3,'' NULFP05 = '',I3,'' NULFP06 = '',I3)')&
 & NULFP01, NULFP02, NULFP03, NULFP04, NULFP05, NULFP06  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NULFP07 = '',I3,'' NULFP08 = '',I3,'' NULFP09 = '',I3,&
 & '' NULFP10 = '',I3,'' NULFPOS = '',I3,'' NSCRTCH = '',I3)')&
 & NULFP07, NULFP08, NULFP09, NULFP10, NULFPOS, NSCRTCH  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NULERR = '',I3,'' NULREF = '',I3,&
 & '' NULRAD = '',I3,'' NULRTL = '',I3)')&
 & NULERR, NULREF, NULRAD, NULRTL  
WRITE(UNIT=KULOUT,FMT='(&
 & '' NULFP11 = '',I3,'' NULFP12 = '',I3,'' NULFP13 = '',I3,&
 & '' NULFP14 = '',I3,'' NULFP15 = '',I3)')&
 & NULFP11, NULFP12, NULFP13, NULFP14, NULFP15  
WRITE(UNIT=KULOUT,FMT='('' NTCSR = '',I3)') NTCSR
WRITE(UNIT=KULOUT,FMT='(&
 & '' NUO3CH1 = '',I3,'' NUO3CH2 = '',I3)')&
 & NUO3CH1,NUO3CH2  
WRITE(UNIT=KULOUT,FMT='('' NEGASH = '',I3)') NEGASH
WRITE(UNIT=KULOUT,FMT='('' NULTRAJHR = '',I3)') NULTRAJHR
WRITE(UNIT=KULOUT,FMT='('' NULTRAJBG = '',I3)') NULTRAJBG

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

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