#!/bin/bash
#

INIDIR=$WORK/reference_data_cclm/cclm_02800_CV_SOPI/int2lm_output
OUTPUT=$WORK/reference_data_cclm/cclm_02800_CV_SOPI/COSMO_output/CTRL_28_CV

export LIBDWD_BITMAP_TYPE=ASCII
export LIBDWD_FORCE_CONTROLWORDS=1


#### !!!! Adopt this directory !!!!
SPDIR=$HOME/cclm-sp_2.1

cd $PWD 


#################################################
# number of processors
#################################################

NPX=8
NPY=8
NPIO=0
NP1=`expr $NPX \* $NPY`
NP=`expr $NP1 + $NPIO`
N1=`expr $NP + 15`
NODES=`expr $N1 \/ 16`
#NN=`expr $NPY \/ $NNP`
anz_procs=$((${NPX}*${NPY}+${NPIO}))  # Anzahl Prozessoren

#################################################
# global settings
#################################################
#DATE=20121092000

class=d
wtime=60 #2880 # Zeit, wie lange Job rechnen darf

#################################################
# cleanup
#################################################
rm -f YU* OUTPUT
rm -f cclm_job
mv -f Job*.* ./Jobs/
rm -f $OUTPUT/l*

#################################################
# cat together the INPUT*-files
#################################################

cat > INPUT_ORG << end_input_org
 &LMGRID
  startlat_tot  = -8.75, startlon_tot  =-7.3,
  pollat = 40., pollon = -170.0, 
  dlon=0.025, dlat=0.025, 
  ie_tot=274, je_tot=262, ke_tot=50,
 /END
 &RUNCTL
  ydate_ini='2012090100', 
  ydate_end='2013040100',
           !ydate_bd='',                !if omitted equals ydate_ini, otherwise boundary files are
                                        !read from that date on
  itype_calendar=0,           		!0.gregorian. 1 a year has 360 days 2. a year has 365
  hstart = 1485.0,   hstop = 5064.0,  
           !nstop=0,
  dt=5.0, !in previous version it was 40   !time-step for the runge kutta or leap-frog integration models
  lphys=.TRUE.,                         !switch for PHYCTL physical parametrizations
  ldiagnos=.TRUE.,                      !switch for diagnostic calculations switches off /DIACTL/
           !ldfi=.FALSE.,               !s. using digital filtering scheme
  !luseobs=.TRUE.,            !s. for assimilation
           !leps=.FALSE.,               !. run in ensamble mode
           !lsspt=.FALSE.,              !s. for stocasthic perturbations activates /EPSCTL/
           !luse_rttov=.FALSE.,         ! compute satellite images
           !luse_radarfwo=.FALSE.,      !s. radar forward operator
           !lroutine=.FALSE.,           !s. to set if TRUE GRIB2 meta data
           !l_cosmo_art=.FALSE.,
           !l_pollen=.FALSE.,
           !llm=.FASLE.,                !running with zero vertical velocity for bound. cond.
  lartif_data=.FALSE.,        		!if TRUE model run with user defined initial and b. data created                                                  !in/ARTICCTL/
           !ltraj=.FALSE.               !for trajectories calculations
           !l2dim=.FASLE:,              !2-D model version. Needs je_tot=5
           !lperi_x=.FALSE.,            !use periodic lateral boundary cond.
           !lperi_y=.FALSE.,
  nprocx = $NPX,  nprocy = $NPY,   nprocio = $NPIO,
           !num_asynio_comm=2,		!To choose the number of asynchronous I/O communi-
					!cators for NetCDF. With several communicators it is
					!possible to parallelize the output over the files to be
					!written (the GRIBOUT namelists).Def: 0

           !num_iope_percomm=0,
  nboundlines= 3,                       !number of bound. lines at each side of the subdomain
  itype_timing=4,                       ! 1. hourly output timings per task
                                        !2.ouput timings per task
                                        !3output horly mean values for all tasks
                                        !4 output mean values for all tasks summed over all hours
            !lreproduce=.FALSE.,        !dealing with MPI
  lreorder   = .FALSE.,                 !  If .TRUE., the numbering of the MPI-processes can be
                                        ! reordered for the cartesian MPI-communicator.
  ldatatypes = .FALSE.,                 !choose an explicit buffering. Before: FALSE
  ltime_barrier = .FALSE.,              !use of barriers
  ncomm_type=3                         !choose a certain type of communication. 1. immediate send 
                                        !2. immediate receive blocking send and wait on the 
                                        !receiver side. 3. Using MPI SENDRECV
  hincmxt=24.0,               		!i.e. every hincmxt hours T_MIN_2M and T_MAX_2M 
                                        !arrays are reset to default values.
  hincmxu=1.0,                		!idem for VMAX_10M
  idbg_level=22,                        !selects the verbosity of the output model run. Before:2
  ldump_ascii=.FALSE.,          
           ! lprintdeb_all=.FALSE.,     ! To save the ASCII-Files written during the model run to disk
                                        ! in every time step
           !ldebug_dyn=.FALSE.,         ! To switch on/off the debug output for:dynamics, microphysics,
                                        ! radiation, turbulence, convection soil processes, input/output
                                        !asynchronous I/O, diagnostics, assimilation, latent heat nudging
                                        !ART module, local variables 
           !ldebug_gsp=.FALSE.,
           !ldebug_rad=.FALSE.,
           !ldebug_tur=.FALSE.,
           !ldebug_con=.FALSE.,
           !ldebug_soi=.FALSE.,
  ldebug_io=.FALSE.,
           !ldebug_mpe=.FALSE.,
           !ldebug_dia=.FALSE.,
           !ldebug_ass=.FALSE.,
           !ldebug_lhn=.FALSE.,
           !ldebug_art=.FALSE.,   
  linit_fields=.FALSE.,
 /END
 &TUNING
clc_diag  =   0.5,              ! Cloud cover at saturation in statictical cloud diagnostic                            
				!(default=0.5) 
  pat_len   = 500.0,              ! Length scale of sub-scale surface patterns over land                                 
					!(default=500)
  tur_len   = 150.0,              ! Maximal turbulent length scale (m)                                        
					!           (default=500)
  rlam_heat =   1,                ! Scaling factor for the thickness of the laminar boundary 
					!layer for heat formula      (default=1) 
  rlam_mom  =   0.0,              ! Scaling factor for the thickness of the laminar boundary 
					!layer for momentum formula  (default=0)
  rat_lam   =   1.0,              ! Ratio of laminar boundary layer thickness for water vapour 
					!and sensible heat         (default=1)
  rat_can   =   1.0,              ! Scaling factor for the calculation of the conopy height 
					!affecting the T2m            (default=1)
  rat_sea   =  20.0,              ! Scaling factor or rlam_heat over sea                                            
					!     (default=20)
  c_lnd     =   2.0,              ! Surface area index of gridpoints over land                                     
					!      (default=2)
  c_soil    =   1.0,              ! Surface area index of the evporating fraction of gridpoints 
					!over land                (default=1)
  c_sea     =   1.5,              ! Surface area index of gridpoints over sea  
					!       (default=1.5)
  z0m_dia   =   0.2,              ! Typical roughness length for a Synop station                
					!  (default=0.2)
  crsmin    = 150.0,              ! Minimum value of stomatal resistance                                           
					!      (default=150)
  qc0       =   0.0002,           ! Cloud water threshold for autoconverison                                    
					!         (default=0.0)
  qi0       =   0.0,              ! Coud ice threshold for autoconverison                                 
					!               (default=0.0)
  q_crit    =   1.6,              ! Critical value forn normaliued over-saturation                              
					!         (default=0.0)
  wichfakt  =   0.0,              ! Vertical smoothing factor for explicit vertical diffusion coefficient            
					!    (default=0.0)
  mu_rain   =   0.5,              ! Shape parameter of the rain drop size distribution                            
					!       (default=0.0)
  v0snow    =    20,              ! Factor in her terminal velocity for snow                                          
					!   (default=25)
  rain_n0_factor = 0.1,           ! To reduce the evaporation of rain drops                                         
					!     (default=1.0)
  tkhmin    =   0.4,              ! Minimal diffusion coefficients for heat active in stable BL conditions           
					!    (default=0.4)
  tkmmin    =   0.4,              ! Minimal diffusion coefficients for momentum active in stable BL conditions        
					!   (default=0.4)
 /END
end_input_org

cat > INPUT_IO  << end_input_io
 &IOCTL
  lasync_io=.FALSE., yform_read='ncdf',  
  lbdclim=.TRUE.,
  !nhour_restart=2,3,1,
  !nhour_restart=1485,5064,2,
  ydir_restart='${OUTPUT}/restarts/'
  ytunit_restart='d',
  ngribout=1,
  !yncglob_title="Europe 0.44 Starter Package",
  !yncglob_source = "${SPDIR}/src/cclm/cclm.exe}",
  !yncglob_project_id = "-",
  !yncglob_experiment_id ="spcclm",
  !ncglob_realization = 1,
  !yncglob_contact = "YourAddress",
  !yncglob_references = "http://www.clm-community.eu/",
 /END
 &DATABASE
 /END
 &GRIBIN
  lbdana = .FALSE.,
  lana_qi = .TRUE.,
  llb_qi = .TRUE.,
  lana_qr_qs = .FALSE.,
  llb_qr_qs = .FALSE.,
  lana_qg = .FALSE.,
  llb_qg = .FALSE.,
  lana_rho_snow  = .FALSE.,
  lan_t_s    = .FALSE.,
  lan_t_so0  = .TRUE.,
  lan_t_snow = .TRUE.,
  lan_t_cl   = .TRUE.,
  lan_w_snow = .TRUE.,
  lan_w_i    = .TRUE.,
  lan_w_cl   = .TRUE.,
  lan_vio3   = .TRUE.,
  lan_hmo3   = .TRUE.,
  lan_plcov  = .TRUE.,
  lan_lai    = .TRUE.,
  lan_rootdp = .TRUE.,
  lan_rho_snow= .FALSE.,
  ydirini='$INIDIR',
  lchkini=.TRUE.,
  hincbound=1,
  ydirbd='$INIDIR',
  lchkbd =.TRUE.,
  ytunitbd='d',
 /END
&GRIBOUT
 yform_write='ncdf',
  hcomb=1485,5064,1,
  yvarml= 'U         ','V         ','W         ','T         ',        ! Wind and temperature
         'QV        ','QC        ','QI        ','QS        ',        ! Specific rain/snow content
         'QR        ','P         ','PP        ','QVSFLX    ',        ! PP=deviation from reference pressure
         'PS        ','QV_S      ','FI        ',			!Surface pressure,temperature,specific 
									!water content 
         'U_10M     ','V_10M     ','VMAX_10M  ',        		! Wind in 10m
         'T_2M      ','TD_2M     ','TD        ',
         'QV_2M     ','RELHUM_2M ','CLDEPTH   ','RELHUM    ',          ! Specific and relative humidity, 
									!normalized cloud depth
         'CLCT      ','CLCH      ','CLCM      ','CLCL      ',        ! Total cloud cover=CLCT,Cloud cover 
									! high/middle/low clouds
         'RAIN_GSP  ','SNOW_GSP  ','RAIN_CON  ','SNOW_CON  ',        ! Sum of rain/snow precipitation and 
									!rain/snow convective
        'TOT_PREC  ','TWATER    ','TQV       ','TOT_PR    ',        ! Total precipitation and total water 
									!content(TWATER) and precipitable water(TQV) 
         'ASHFL_S   ','ALHFL_S   ','SHFL_S    ','LHFL_S    ',        ! Average sensible and latent heat flux,
									!surface sensible and latent heat flux
         'CAPE_ML   ','CIN_ML    ','CAPE_MU   ','CIN_MU    ',        ! CAPE/CIN of mean surface layer (ML) and 
									!for most unstable parcel (MU)
         'CAPE_CON  ','QCVG_CON  ','TKE       ',        		! CAPE specific(CON),moisture convergence in 
									!the air for kuo type closure(QCVG_CON)
         'SLI       ','SI        ','AEVAP_S   ',!'EVATRA_SUM',        ! Showalter index (SI)and surface lifted index
									! (SLI) and Evaporation products        
         'BAS_CON   ','TOP_CON   ','HPBL      ',                     ! Index convective cloud base (BAS), cloud 
									!top(TOP),Height of boundary layer(HPBL) 
         'HTOP_DC   ','HTOP_CON  ','HBAS_CON  ',                     ! Height of dry convective top (HTOP_DC)and 
									!cloud top (HTOP_CON),cloud base(HBAS),  
         'PMSL      ','LCL_ML    ','LFC_ML    ',                     ! Mean sea level presure(PMSL),Lifting 
	 'VORTIC_U  ','VORTIC_V  ','VORTIC_W  ',
         'ZHD       ','ZTD       ','ZWD       ',

         'HSURF     ','FIS       ','FR_LAND   ','SOILTYP   ',
         'PLCOV     ','ROOTDP    ','Z0        ',  !Constant External parameters for the surface
         'SS0_STDH  ','SS0_GAMMA ','SS0_THETA ','SS0_SIGMA ',        !Constant Ext. param. For the sso scheme
        
	 'SKYVIEW   ','SLO_ASP   ','SLO_ANG   ','HORIZON   ', !Topograph. correc. in the Radiation sch.
        


 		!'FR_LAKE   ','DEPTH_LK  ', !External parameters for lakes
         
	 'PRS_MIN   ','EMIS_RAD  ','FOR_E     ','FOR_D     ',

	!'PLCOV_MX  ','PLCOV_MN  ',       						!Plants variables:
         'PLCOV12   ','NDVI_MRAT ',!'LAI_MX    ',
         'LAI_MIN   ',
         'LAI12     ','DBZ       ','LAI       ',
         'ALB_DRY   ','ALB_SAT   ','RSMIN     ',        !Thermal radiative surface emissivity
       

	 'VIO3      ','HMO3      ','AER_SO4   ',AER_DUST   ',
         'AER_ORG   ',AER_BC     ','AER_SS    ',   

	 'T_SNOW    ','W_SNOW    ','W_I       ',
         'T_S       ',                                       		!Soil and surface variables
         'T_SO      ','W_SO_ICE  ','W_SO      ','FRESHSNW   ',
         'RHO_SNOW  ',



         'T_M       ','T_CL      ','WG_1      ','WG_2      ',        !For the two-or three layer soil model 
         'WG_3      ','W_CL      ',
									!condensation level(LCL_ML),

 !        'QV        ','QC        ','QI        ','QS        ',        ! Specific rain/snow content
  !       'QR        ','P         ','PP        ',                     ! PP=deviation from reference pressure
 yvarzl= 'T         ','RELHUM    ','U         ','V         ',
         'P         ','OMEGA     ','QC        ','QI        ',
         'QR        ','QS        ','QV        ','W         ',
         'DBZ       ',    
 yvarpl= 'T         ','RELHUM    ','U         ','V         ',
         'FI        ','OMEGA     ','QC        ','QI        ',
         'QR        ','QS        ','QV        ','W         ', 
         'DBZ       ','HHL       ',

  zlev=250.0,500.0,750.0,1000.0,1500.0,2000.0,3000.0,5000.0,
 ! plev=300,400,500,600,700,850,900,925,950,975,1000,1050,
  plev=100,150,200,250,300,400,500,600,700,850,900,925,950,975,1000,1050,
  l_p_filter=.TRUE.,
  		!luvmasspoint=.FALSE.,
  lcheck = .TRUE.,
  lwrite_const=.TRUE.,
  ydir='$OUTPUT',
  ytunit='d',
 /END
end_input_io

cat > INPUT_DYN << end_input_dyn
 &DYNCTL
epsass=0.15, betasw=0.4,               ! Numerical filters
 lspubc=.TRUE.,                         ! sponge layer with damping
 hd_corr_trcr_in=0.0,                   ! difussion factor (interior domain) for tracers
 hd_corr_t_bd=0.75,                     ! difussion factor (boundary zone)   for temperature
 hd_corr_u_bd=0.75,                     ! difussion factor (boundary zone)   for wind
 hd_corr_p_bd=0.75,                     ! difussion factor (boundary zone)   for pressure
 hd_corr_trcr_bd=0.0,                   ! difussion factor (boundary zone)   for tracers
 hd_corr_u_in=0.1,                      ! difussion factor (interior domain) for wind
 hd_corr_t_in=0.0,                      ! difussion factor (interior domain) for temperature
 hd_corr_p_in=0.0,                      ! difussion factor (interior domain) for pressure
 l_diff_smag=.TRUE.,                    ! swith on/off the Smagorinskty diffusion  (default=T)
 itype_hdiff=2,                         ! type of horizontal diffusion
 hd_dhmax=250,                          ! Threshold value for the maximum height difference between
					! adjecent girdpoint int hte orographic flux limiter (default=250)
 ikrylow_si=20,                         ! Demension of Kyrlow space for ellipitc solver (default=20)
 lsemi_imp=.FALSE.,                     ! True. instead of the standard Leagfrog time-split scheme, a
					! Leagfrog with semi.implicit treatment
 l2tls=.TRUE.,                          ! The default time-integration scheme is a 2 time-level Runge-Kutta 
					!scheme with time-split treatment of acoustic and 
 lcond=.TRUE.,                          ! To include (.TRUE.) or exclude (.FALSE.) cloud water 
					!condensation and evaporation during the forecast.
 itype_outflow_qrsg=2,                  ! Choose the typw of lateral bounddary treatment for qr,qs,qg ; 
					!=2 gqr,qs,,qg to 0.0 at boundary zone          (default=1)
 lexpl_lbc=.TRUE.,                      ! Choose an explicit formulation of the lateral boundary relaxation. (default=T)
 itype_lbc_qrsg=1,                      ! Choose the type of lateral boundary treatment for qr,qs
 itype_fast_waves=2,                    ! type of fast waves solver 
 itype_bbc_w=114,                       ! Option for choosing bottom boundary condition for vertical wind (default=114) 
 y_scalar_advect='BOTT2_STRANG',        ! ’Bott2’ Bott 2nd order finite-volumescheme (lsl_adv_qx=.FALSE., 
					!yef_adv_qx=’Bott x’) (default='BOTT2_STRANG')
 ldiabf_lh=.TRUE.,                      ! Include diabatic forcing due to latent heat in the Runge-Kutta scheme.  
					! (default=T)
 ldyn_bbc=.FALSE.,                      ! dynamical bottom layer
 nrdtau=5,                              ! damping at model top
 rlwidth=23000.,                        ! Width of relaxion layer
 irunge_kutta=1,                        ! to selcet Runge-Kutta scheme
 iadv_order=5,                          ! order of advection scheme 
 itheta_adv=0,                          ! Option using potential temperature as advected variable in the Runge-Kutto-Scheme (default 0: Use perturbaion T for advection)
 /END
end_input_dyn

cat > INPUT_PHY << end_input_phy
&PHYCTL
    lgsp=.TRUE.,                         !Main switch for including grid scale precipitation.                 (default=T)               
     ldiniprec=.FALSE.,                   ! with on ta diagnostic initialization of rain and show             (default=F)
     itype_gscp=4,                        ! select special scheme                                             (default=3)
    lrad=.TRUE.,                         !Main switch for including radiation.                                                 (default=T)
      nradcoarse=2,                       ! If nradcoarse > 1, the radiation is computedn on a coarser grid to save computation time. (default=1)
      lradf_avg=.TRUE.,                   ! To average the radiative forcings when running on a coarser grid (nradcoarse > 1). ???
      hincrad=0.25,                       ! Interval between two calls of the radiation scheme (in hours)
      lforest=.TRUE.,                     ! External parameter fields modifying the scnw albedo of evergereen and deciduous foresest (default=F)
      ico2_rad=10,                        ! choose special CO2 concentration  (default=0)
      icldm_rad=4,                        ! Parameter to select the mode of cloud representation  as input to the radiation parameterization.
    ltur=.TRUE.,                         !Main switch for including turbulent diffusion.
      limpltkediff=.TRUE.,                ! inculded horizontal turbuelent difffusion 
      ninctura=1,                         ! Increment in time steps for recalculating the transport coefficientcients Km and Kh for vertical
      ltkesso=.TRUE.,                     ! Switch, to calculate SSO-wake turbulence production for TKE. (default=F)
      lexpcor=.FALSE.,                    ! Explicit corrections of the implicitly calculated turbulent heat and moisture uxes due to effects from subgrid-scale condensation
      ltmpcor=.FALSE.,                    ! Consideration of thermal TKE-source in enthalpy budget (only if itype turb=3)
      lnonloc=.FALSE.,                    ! Nonlocal calculation of vertical gradients used for turbulent diffusion (only if itype turb=3).
      lcpfluc=.FALSE.,                    ! Consideration of uctuations of the heat capacity of air (only if itype turb=3).
      itype_turb=3,                       ! Parameter to select the vertical turbulent diffusion parameterization.
      imode_turb=1,                       ! Mode of turbulent vertical diffusion parametrization in case of itype turb = 3. (default=0)
      icldm_turb=2,                       ! Mode of cloud representation to take into account subgrid-scale condensation within the turbulence parameterization in case of itype turb
    itype_tran=2,                       !Main prameter to select a specific surface-layer parameterization. 2: TKE-based scheme inculding a laminar sub-layer (default=2)
      imode_tran=1,                       ! Type of surface-atmosphere transfer. 1: Based on diagnostic TKE in the surface layer. (default=1)
      itype_wcld=2,                       ! Type of cloud water diagnosis.       2: Diagnosis based on a statistical scheme.
      icldm_tran=0,                       ! Mode of cloud representation to take into account subgridscale condensation 0: No clouds are considered
      itype_synd=2,                       ! Type of diagnosis of synoptic station values.  2: Interpolation of screen-level (2-m, 10-m) values based on profile relations used in the new surface-layer scheme.
      lprfcor=.FALSE.,                    ! Using the profile values of the lowest main level instead of the mean value of the lowest layer for surface ux calculations.
   lsoil=.TRUE.,                        !Main switch to include soil processes by running a soil model.
      itype_evsl=2,                       ! Parameter to select the type of parameterization for evaporation of bare soil. 2: BATS version.
      itype_trvg=2,                       ! Parameter to select the type of parameterization for transpiration by vegetation. 2: BATS version.
      lmulti_layer=.TRUE.,                ! Switch to run the multi-layer (TRUE)
      lmelt=.TRUE.,                       ! Switch to include melting processes within the soil when running the multi-layer soil modelTERRA ML (default=F)
      lmelt_var=.TRUE.,                   ! Sub-option for the lmelt parameter. IF lmelt var = .TRUE, the soil freezing temperature is treated to be dependent on the water content (default=F)
      czbot_w_so=4.0,                     ! Depth of the bottom of last hydrological atice soil layer (default=2.5)
      !ke_soil = 9,
      !czml_soil = 0.005, 0.025, 0.07, 0.16, 0.34, 0.7, 1.42, 2.86, 5.74, 11.5,
    lconv=.TRUE.,                       !Main switch for including subgrid-scale convection
      nincconv=10,                        ! Intervall between two calls of the convection scheme    (default=4)
      itype_conv=3,                       ! To specify the type of convection parameterization  0: Tiedtke scheme(COSMO-EU)  3: Shallow convection based on Tiedtke scheme (COSMO-DE)
      lconv_inst=.TRUE.,                  ! Switch to write instantaneous (.TRUE.) or aggregate (.FALSE.) values of top con and bas con to model output.
      lcape=.FALSE.,                      ! Enables a CAPE-type closure within the Tiedtke convection scheme (not fully tested yet).
    lsso=.FALSE.,                       !Main switch to include subgrid scale orography processes     (default=T) 
    lseaice=.FALSE.,                    !Main switch to ativate the sea ice scheme                    (default=T)
   itype_albedo=2,                     !Switch to choose the type of solar surface albedo.
/END
end_input_phy

cat > INPUT_DIA << end_input_dia
 &DIACTL
  n0meanval=0, nincmeanval=24,
  lgplong=.FALSE., lgpshort=.TRUE., lgpspec=.FALSE.,
  n0gp=0,      hincgp=6.0,
  stationlist_tot= 0, 0, 52.220, 14.135, 'Lindenberg_Obs',
                   0, 0, 53.633,  9.983, 'Hamburg',
 /END
end_input_dia

cat > INPUT_INI << end_input_ini
 &INICTL
  ndfi=2,
  tspan=  600.0, taus=  600.0,
  dtbak=15.0, dtfwd=15.0,
 /END
end_input_ini

cat > INPUT_ASS << end_input_ass
 &NUDGING
  !lnudge  =.TRUE.           !On−off switch for nudging
  !lverif  =.TRUE.           !On−off switch for verification
  llhn    =.FALSE.          !On−off switch for latent heat nudging
  lsurfa  =.FALSE.          !On−off switch for deriving 2D analyses from observations
  !General variables controlling the nudging
  hnudgsta=48.0,                         !start of nudging period in [hours]. Def: 0
  hnudgend=72.0,                        !end of nudging period in [hours]. Def: 0
  tconbox=3600,                 !time box in [s] for which analysis increments are computed
                                        !once and then held constant. Def: 3*dt
  nwtyp=2,                              !if > 1 then compute net weighted observation increments
                                        ! preliminary analysis increments ∆ψ in Section 3.2 of Part III)
                                        !for ’nwtyp’ different ’sets of observing systems’ separately.
                                        ! Def: 1
  niwtyp=1,5,                   !for each of the ’nwtyp’ ’sets of observing systems’:
                                        !number of observation and/or code types which belong to and
                                        !define that set of observing systems (for obs./code types, see
                                        !below: ’use of observation and code types’)
                                        !(nwtyp = number of non-zero elements in ’niwtyp’). Def: 1,0,0
  iwtyp=12,-830,-930,-899,-829,-929     !for each of the ’nwtyp’ ’sets of observing systems’:
                                        !observation types (as positive values) and/or code types (as
                                        !negative values by setting: ’minus code type’) which define suc-
                                        !cessively one set after the other. Def: 0,0,0
  kwtyp=2,                              !mode of weighting W for multiple observations k , specified for
                                        !each ’set of obseration systems’ m=1 implies cw=0, m=2, cw=1

  !General variables controlling the verification without influence on the nudging 
   hversta=0.0,
   hverend=72.0,
   mveripr=2,
        !mruntyp
   lverpas=.TRUE.,                      !on−off switch for writing also passive reports to the verification
                                        !file(s). Defauklt:.TRUE.
  !Corrections to balance the analysis increments
 	!ntpscor			!switch for hydrostatic temperature correction
					!(to balance the “surface” pressure analysis increments
					!such that the implied upper-level pressure increments 
					!decrease with increasing height according to the functions
					!given below and become zero for p < ptop ). 0 implies
					! no hydrostatic temperature correction. 1 and 2 are 
					! different correction formulas. Def: 1
	!ptpstop			!upper boundary ptop of temperature correction in [hPa]. Def=400
	!luvgcor			!on−off switch for geostrophic wind correction. Def: TRUE
	!qgeo				!fraction of the full geostrophic wind increments that is added
					!to the model wind fields at 1000 hPa. Def 0.3
	!qgeotop			!fraction of the full geostrophic wind increments that is added
					!to the model wind fields at level ’ptpstop’ (in between, this
					!fraction is linearly interpolated). Def: 0.5
	!mpsgcor			!switch for geostrophic pressure correction. 0 implies no pressure 
					! corection 1 implies correction balancing wind increments from
					! scaterometer. 2 imples:  corr. balacing scatterometer + in-situ 10					          !-m wind increm. Def: 1
	!qgeops				!fraction of the full geostrophic pressure increments that is
					!added to the pressure field at the lowest model level. dEF: 0.9
	!khumbal			!radius (in [number of mesh widths]) of the area around a con-
					!vectively precipitating grid point, in which specific humidity
					!instead of relative humidity is preserved when temperature is
					!nudged. Special cases: - 1 : relative humidity preserved everywhere
					!>= 99 : specific humidity preserved everywhere
					!>= 100 : specific humidity preserved additionally for incre-
					!ments from hydrostatic temperature correction. Def=100
  !Nudging coefficients
        !gnudg=0.0006,0.0012,0.0006,0.0006,			!
	!gnudgar=0.0060.0000,0.0006,0.0000,
	!gnudgsu=0.0006,0.0012,0.0000,0.0006
					!nudging coefficients in [1/s] for surface-level data. Def: 
					!6exp10 -4 1.2 exp 10 -r 0, 6 exp 10 -4
   gnudggp=0.0003,			! nudging coefficient in [1/s] for GPS-derived IWV. Def:0

  !Temporal Weights
   ltipol=.TRUE.,			!linear interpolation in time between pairs of collocated
					!upper-air reports (one report in the past and one in the
					!future) from the same station which are less than
					!tipolmx hours apart from each other
					!==> at most 2 reports per station used at each timestep. Def=TRUE

   ltipsu=.TRUE.,			!linear interpolation in time of pairs of surface-level reports
					!less than tipmxsu hours apart from each other. Def=TRUE

   tipolmx=1.0,				!max. time span (in [hours]) between 2 upper-air reports to
					!allow for temporal linear interpolation. Def=1.0

   tipmxsu=1.0,				!max. time span (in [hours]) between 2 surface-level reports
					!to allow for temporal linear interpolation. Def: 1.0,

	!wtukrsa			!radius towards the past for radiosonde data. Def= 3.0
	!wtukrse			!radius towards the future for radiosonde data. Def=1.0
	!wtukara 			!radius towards the past for aircraft data. Def=1.5
	!wtukare 			!radius towards the past for surface-level data. Def=0.5
	!wtuksua			!radius towards the past for surface-level data. Def=1.5
	!wtuksue			!radius towards the future for surface-level data. Def=0.5
  !Spatial Weights, basic mode of spreading
	!msprpar			!switch specifying the surfaces along which upper-air
					!observation increments are (primarily) spread
					!= 0: spreading along model levels
					!= 1: spreading along horizontal surfaces
					!= 2: spreading along isentropic surfaces. Def= 1
	!msprpsu			!switch specifying the surface along which surface-level
					!observation increments are (primarily) spread
					!= 0: spreading along model levels
					!= 1: spreading along horizontal surfaces
					!= 2: spreading along isentropic surfaces
					!(for msprpsu , point POI is always a grid point
					!at the lowest full model level). Def=0
  !Vertical weights for upper-level observations
	!vcorls
	!vcutof
	!lsvcorl
  !Vertical weights for surface-level observations
   vcorlsu=0.13,0.013,0.002,0.00001,	!square of the vertical correlation scale
					!i.e. square of Gaussian vertical “radius” of influence
					!- in log-pressure differences , if (msprpar ≤ 1)
					!(i.e. default e-folding decay height for T, f ≈ 300 m)
					!- in potential temperature Θ diff. , if (msprpar = 2)
					!(reasonable values: 11.1, 11.1, 1.33, 1.33)
					!Def: 0.013, 0.013, 0.002, 0.002
   vcutosu=0.75,0.75,4.0,0.001	!cut-off for Gaussian vertical correlation function.
					!Def: 0.75, 0.75, 4.0, 4.0
	!vpblsu			!Gaussian vertical “radius” of influence in potential
					!temperature differences between the observation
					!increment point POI and the target model level
					!at the horizontal observation location
					!(—> this defines an additional Gaussian weight
					!that makes the total vertical weight depend on the
					!near-surface stability even if (msprpar = 1))
					!Def: 0.99, 0.99, 0.99, 0.99
  !Horizontal weights for upper-air observations
	!rhinfl
	!rhvfac
	!rhtfac
   rhfgps=0.45
	!cutofr
	!vcsni
  !Horizontal weights for surface-level observations
	!rhinflsu			!constant part sc of the correlation scale s (in [km])
					! Def= 70, 70, 100, 70
	!rhtfsu				!temporal factor ft scaling the correlation scale s
					!at the beginning and the end of the nudging period
					!for an individual observation relative to s valid at the
					!observation time (see figure for rhtfac above)
					!DEf: 1, 1.43, 1.0, 1.0
	!cutofsu			!cut-off (in [multiples of correlation scales s ])
					!of the horizontal correlation function 
					!Def: 2.0, 3.5, 2.0, 2.0
  	!vcsnisu			!square of Gaussian ’radius’ of influence
	!rhfpsdd			!for scaling horizontal correlation scale for surface pressure data

  !Geometry for lateral spreading of horizontal wind
	!cnondiv			!constant part γc of the non-divergence correction factor γn
					!Def=0.1
	!fnondiv			!multiplication factor fv to the vertically varying part γv
					!of the non-divergence correction factor 
					!deF: 0.8
	!tnondiv			!temporal factor ft scaling the correction factor γn
					!at the beginning and the end of the nudging period
					!for an individual observation relative to γn valid at
					!the observation time (analogous to rhtfac above).Def=1.1
  !Observation increments from multi-level reports
	!lscadj
	!topobs
	!botmod
  !Observation increments from surface-level reports
	!loiqv2m			! TRUE: 2-m humidity observation increments as differences
					!of specific humidity instead of relative humidity
					!Def: FALSE.
	!lqfqv2m			! TRUE: quality weight factor for 2-m humidity observations
					!dependent on 2-m temperature observation increments
					!Def: FALSE
  !Threshold quality control:
	!dtqc				!timestep (in [s]) for the threshold quality control (QC)
					!(in addition, QC is applied to an observation when
					!it is used for the first time). Def=720.0
  !QC thresholds ψthr for upper-air data
        !qcc=0.0,500.0,0.0,0.0,
        !qcvf=5.0,1.0,10.0,1.0,
  !QC thresholds ψthr at observation time for surface-level data (units for as for qcc )
	!qccsu				!Def: 12, 500, 12, 0.7,
  !QC thresholds ψthr for GPS IWV data
	!qcciq				!constant part of the thresholds at observation time (in [mm]). Def:1.0
	!qcsiq				!fraction of the IWV of the saturated model temperature profile,
					!which is added to the QC threshold. Def=0.15
  !Quality weights for observations
   	doromx=200,200,200,200,		!cut-off and Gaussian “radius” in [m] for reduction factor z
					!which is part of quality weight for surface-level
					!observations. Def: 100, 150, 150, 150,
	!qcfpst				!maximum enhancement factor of the (quality) weight for
					!surface pressure observations due to observed 3-hourly
					!surface pressure tendency ∂t ps. Def: 1.5
  !Use of observations and reports
	!altopsu			!surface-level observations above height altopsu (in [m])
					!are neglected;
					!if altopsu = 0. , all surface-level observations
					!assigned to land grid points are neglected. Def: 100, 5000, 5000,5000
	!thairh				!for contructing multi-level reports (’piecewise profiles’)
					!from single-level aircraft reports :
					!maximum horizontal distance in [km] between the resulting
					!multi-level report and the original location of any single-level
					!report included in this multi-level report. Def=20.
	!lgpsbias			!seasonal daytime-dependent bias correction applied to GPS-
					!derived IWV (integrated water vapour) data. Def=.FALSE.
        !mqcorr92=2,			!switch for bias correction for Vaisala RS92 radiosonde humidity
					!= 0 : no correction for humidity
					!= 1 : correction of solar radiation bias only
					!= 2 : correction of total bias (incl. nighttime bias). Def=0,
	!nolbc				!number of grid rows at the lateral boundaries of the COSMO-
					!Model domain where all reports are neglected. Def=5
	!obnlat				!observation area : all reports outside of it are neglected
	!obslat				! latitude of northern boundary of observation area ([deg.])
					! latitude of southern boundary of observation area ([deg.])
 	!obwlon				!longitude of western boundary of observation area ([deg.])
	!obelon				! longitude of eastern boundary of observation area ([deg.])
  !Use of observation types and code types
					!exclusion area : reports inside of it are neglected if their
					!observation or code type is set to .FALSE.
					!latitude of northern boundary of exclusion area ([deg.])
					!latitude of southern boundary of exclusion area ([deg.])
					!longitude of western boundary of exclusion area ([deg.])
					!longitude of eastern boundary of exclusion area ([deg.])
	!exnlat				!Def=90
	!exslat				!Def=-90
	!exwlon    			!Def=-180
	!exelon				!Def=180
  !Observation type 			!observation type : reports inside the exclusion area are
					!set passive if their type is set to .FALSE.
   lsynop = .FALSE.,			!observation type SYNOP. Def: TRUE
   laircf = .FALSE.,			!observation type AIREP (aircraft).Default:.TRUE.
	!lsatob				!observation type SATOB.Default:..FALSE.
   ldribu = .FALSE., 			!observation type DRIBU (drifting buoy).Default:.TRUE.
   ltemp  = .FALSE.,			!observation type TEMP.Default:..TRUE.
   lpilot = .FALSE.,			!observation type PILOT.Default:..TRUE.
	!lsatem				!observation type SATEM.Default:..FALSE.
   lgps   = .TRUE.,				!observation type GPS. Default:FALSE
   lscatt = .FALSE.,			!observation type SCATT (scatterometer).Default:..TRUE.
   !Code Types:  reports inside the exclusion area are set passive if their code type is set to .FALSE.
	!lcd011 			!SYNOP  code 11 (manual land). Def=.TRUE.
	!lcd014				!SYNOP  code 14 (manual land). Def=.TRUE.
	!lcd021				!SYNOP  code 21 (manual land). Def=.TRUE.
	!lcd022				!SYNOP  code 22 (manual land). Def=.TRUE.
	!lcd023				! etc...
	!lcd024
	!lcd140
	!lcd041				!AIREP  code 41 (manual land). Def=.TRUE.
	!lcd141				! etc..
	!lcd241
	!lcd144
	!lcd146
	!lcd244
	!lcd088				!SATOB  code 88 (manual land). Def=.TRUE.
	!lcd188
	!lcd063				!DRIBU  code 63 (manual land). Def=.TRUE.
	!lcd064				!etc...
	!lcd165
	!lcd035				!TEMP  code 35 (manual land). Def=.TRUE.
	!lcd036				!etc...
	!lcd037
	!lcd135
	!lcd039
	!lcd040
	!lcd032				!PILOT  code 32 (manual land). Def=.TRUE.
	!lcd033				!etc...
	!lcd038
	!lcd132
	!lcd133
	!lcd136
	!lcd137
	!lcd122				!SCATT  code 11 (manual land). Def=.TRUE.
	!lcd123
        !lcd096=.TRUE.,			!GPS code 96
					! (ground-based GPS) ; this code type is used
					!only for GPS data read from a special
					!ASCII file in COST-716 format
   igpscen = 30,99,29,74,22,21,23,24,25,33,34,35,37,26,32
					!array of pirocessing centres of GPS reports used actively:
					!− the order of centres determines the preference in the
					!redundancy check; ’-1’ means no active centre
					!− the numbers Np indicating the processing centres are given
					!in the WMO Common Code Table C-12 for BUFR/CREX
					!data (WMO descriptor ’0 01 034’)
					!− the code types for GPS data (if read from NetCDF files)
					!are set to ’X + Np ’ where X=800 or X=900 ;
					!these code type have to be used e.g. for setting ’iwtyp’. Def:
					!-1, -1, -1,...
  !Observation dependent array sizes
   maxmlo=1,
   maxsgo=1,				!maximum number of surface-level reports. Def: 3000
   maxuso=1,
   maxgpo=5000,
! 	maxgpo=20600260,			!maximum number of ground-based GPS reports
					!Note: - maxmlo + maxsgo = maximum number of
					!surface pressure reports
					!- maxmlo, maxsgo, and maxgpo also scale the
					!size of the arrays which contain all the multi-level,
					!single-level (upper-air and surface level) resp. GPS
					!reports on the local sub-domain (on distributed-
					!memory computers) which have to be stored at a
					!certain timestep to be used then or later on
	!maxmlv
	!mxfrep
	!mxfobs
  !Directory and file names related to nudging
  itype_obfile=2,			!Type of observation input file. 1 means AOF 2 means NetCDF. Def: 1
  	!yaofpath='/home/kit/imk-tro/ys7516/GPS-IWV_assimilation/assim_gps_COST_20120910/cost_s_u_201209100000_201209102355_mult_mult.dat',
					!path (directory (unless working directory) and filename) of
					!the input observation file ’AOF’. Def 'aof'
   ycdfdir='/home/kit/imk-tro/ys7516/GPS-IWV_assimilation/assim_gps_cclm',
					!directory, where NetCDF observation input files and the
					!blacklist file reside './'
  !Diagnostic output
   lprodr=.TRUE.,
   ionl=2.0,
   jonl=36.0,
   ionl2=2.1,
   jonl2=36.1,
	!lpraof
	!dinlat
	!dislat
	!diwlon
	!dielon
	!noctrq
!2-dimensional analyses derived from observations. lsurfa=.TRUE.
! Some basic variables on the LHN and its diagnosis
!Variables controlling the LHN algorithm itself:
 /END
end_input_ass

#echo starte Job...s


#################################################
# run the program
#################################################

cat > cclm_job << ****
job_submit -p${anz_procs} -c $class -t $wtime -m 4000 mpirun ${SPDIR}/src/cclm/bin/cclm.exe

****
chmod u+x cclm_job
./cclm_job
job_queue
