This file is indexed.

/usr/share/metview/etc/MarsRules is in metview-data 5.0.0~beta.1-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
!
! This is the mars check file
!
! Each request is checked again each rule
! The rules have the following syntax:
!
!   RULE   ---> if TEST then ACTION 
!
!
!   TEST   ---> PARAMETER  =  VALUE
!          ---> PARAMETER  >  VALUE
!          ---> PARAMETER  <  VALUE
!          ---> PARAMETER  >= VALUE
!          ---> PARAMETER  <= VALUE
!          ---> PARAMETER  <> VALUE
!          ---> PARAMETER  in LIST_OF_VALUES
!          ---> not TEST
!          ---> TEST and TEST
!          ---> TEST or TEST
!          ---> ( TEST )
!
!
!   ACTION ---> error    MESSAGE
!          ---> warning	 MESSAGE
!          ---> info	 MESSAGE
!          ---> mail	 MESSAGE
!          ---> set      PARAMETER = VALUE
!          ---> unset    PARAMETER 
!
!
!
! B.Raoult
! Wed Feb 13 15:07:49 GMT 1991
!

# Remove access to marsodb
%if (_VERB = ARCHIVE %or 
	 _VERB = STAGE %or 
	 _VERB = FLUSH %or 
	 _VERB = REMOVE)
	%and DATABASE=marsodb %then
	%unset DATABASE

%include "oldrd.chk"


%if CLASS = OD %and (TYPE = CM %or TYPE = CS %or TYPE = CR) %and DOMAIN = G %then 
	%warning "Domain forced to E"
	%set DOMAIN = E

%if (TYPE = IM %or TYPE = SIM %or TYPE = OLDIM) %and STREAM <> SSMI %then
	%set REPRES = SV
	%unset PARAM
	%unset LEVTYPE
	%unset LEVELIST
	%unset RESOL
	%unset DUPLICATES 
	%unset GRID 
	%unset ROTATION 

# Simulated radiances
%if (TYPE = SSD) %then
	%unset LEVTYPE
	%unset LEVELIST

%if (TYPE = GSD) %then
	%unset LEVTYPE
	%unset LEVELIST
	%unset STEP


%if (TYPE = IM  %or TYPE = OLDIM) %and STREAM <> SSMI %then
	%unset STEP


%if TYPE = OB %or TYPE = FB  %or STREAM = SSMI %or TYPE = AI %or TYPE = AF %or TYPE = AB %or TYPE = OFB %or TYPE = MFB %or TYPE = OAI %then 
	%set REPRES = BU
	%unset PARAM  
	%unset STEP  
	%unset LEVTYPE  
	%unset LEVELIST  
	%unset GRID 
	%unset ROTATION 

%if TYPE = TF %then
	%set REPRES = BU
	%unset PARAM
	%unset LEVTYPE
	%unset LEVELIST
	%unset GRID 
	%unset ROTATION

%if TYPE = AB %then
	%unset TIME

%if TYPE = OB %or TYPE = FB %then
	%unset ORDER

%if TYPE = CL %then
	%unset STEP

%if LEVTYPE = SFC %or LEVTYPE = WAVE %then 
	%unset LEVELIST

%if LEVTYPE = SFC %and CLASS = OD %and STREAM = OPER %then
	%set REPRES = GG

%if LEVTYPE = SFC %and CLASS = ER %and STREAM = OPER %and (TYPE = AN %or TYPE = FC) %and (%not REPRES) %then
	%set REPRES = GG

%if LEVTYPE = SFC %and CLASS = OD %and STREAM = OPER %and (TYPE = IA %or TYPE = AN) %and DATE < 19830420 %then
	%set REPRES = LL

%if (_VERB = RETRIEVE %and TYPE = TU) %then
	%set REPRES = LL

%if _VERB = LIST %and (%not OBSGROUP) %and (TYPE = OB %or TYPE = FB %or TYPE = AI %or TYPE = AF %or TYPE = AB %or TYPE = TF %or TYPE = OFB %or TYPE = MFB %or TYPE=OAI) %then
	%set OBSGROUP = ALL

%if %not ( TYPE = OLDIM %or TYPE = OB %or TYPE = FB %or TYPE = AI %or TYPE = AF %or TYPE = AB %or TYPE = TF %or TYPE = OFB %or TYPE = MFB %or TYPE = OAI) %then 
	%unset OBSTYPE 
	%unset OBSGROUP 
	%unset DUPLICATES 

%if %not ( TYPE = IM %or TYPE = OLDIM %or TYPE = SIM %or TYPE = OB %or TYPE = FB %or TYPE = AI %or TYPE = AF %or TYPE = AB %or TYPE = TF %or TYPE = OFB %or TYPE = MFB %or TYPE = SSD %or TYPE=OAI %or TYPE = GSD) %then 
	%unset IDENT 

%if GRID=O  %and (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %then %unset GRID
%if GRID=AV  %and (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %then %unset GRID

# READ can have RESOL=AUTO and GRID=ANY 
%if (RESOL=AUTO %or RESOL=AV) %and ((%not GRID) %or (GRID = ANY)) %then %unset RESOL

%if (STYLE = DISSEMINATION) %and (RESOL=AUTO %or (%not RESOL)) %then 
	%warning "Force RESOL=AV when STYLE=DISSEMINATION"
	%set RESOL=AV

%if AREA = E %then
	%set AREA = 73.5/-27/33/45

%if (AREA = G %or AREA = GLOBE) %and (_APPL = diss) %then
	%warning "Expand global AREA for dissemination to AREA = 90/0/-90/359.99"
	%set AREA = 90/0/-90/359.99

%if AREA = G %then
	%set _AREA_N = 0
	%set _AREA_W = 0
	%set _AREA_S = 0
	%set _AREA_E = 0

%if AREA = G %and (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %then %unset AREA
%if AREA = GLOBE %and (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %then %unset AREA

%if FORMAT = P %or FORMAT = PACKED  %then %unset FORMAT

# %if FORMAT %then %warning "Format is not yet implemented" %unset FORMAT


%if USE = NORMAL     %then %unset USE
%if USE = STAGE     %then %set TARGET="/dev/null" %unset FIELDSET %set EXPECT=0
%if COSTONLY = N %then %unset COSTONLY

%if (CLASS = EI) %and (GRID = 128 %or GRID=0.75) %then 
    %warning "For full resolution grid, it is recommended to use RESOL=AV to prevent any truncation before transformation"


!
!
!
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and CLASS=ANY     %then %unset CLASS
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and STREAM=ANY    %then %unset STREAM
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and MODEL=ANY     %then %unset MODEL
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and LEVTYPE=ANY   %then %unset LEVTYPE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and LEVELIST=ANY  %then %unset LEVELIST
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and TYPE=ANY      %then %unset TYPE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and PARAM=ANY     %then %unset PARAM
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and DATE=ANY      %then %unset DATE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and TIME=ANY      %then %unset TIME
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and STEP=ANY      %then %unset STEP
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and ANOFFSET=ANY %then %unset ANOFFSET
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and AREA=ANY      %then %unset AREA
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and GRID=ANY      %then %unset GRID
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and ROTATION=ANY  %then %unset ROTATION
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and STYLE=ANY     %then %unset STYLE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and RESOL=ANY     %then %unset RESOL
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and ORDER=0       %then %unset ORDER
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and EXPVER=ANY    %then %unset EXPVER
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and REFERENCE=ANY %then %unset REFERENCE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and DOMAIN=ANY    %then %unset DOMAIN
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and ORIGIN=ANY    %then %unset ORIGIN
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and CHANNEL=ANY   %then %unset CHANNEL
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and RANGE=ANY     %then %unset RANGE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and LEADTIME=ANY  %then %unset LEADTIME
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and OPTTIME=ANY   %then %unset OPTTIME

%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and PADDING=ANY     %then %unset PADDING
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and SYSTEM=ANY     %then %unset SYSTEM
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and METHOD=ANY     %then %unset METHOD
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and PRODUCT=ANY     %then %unset PRODUCT
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and SECTION=ANY     %then %unset SECTION
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and LATITUDE=ANY     %then %unset LATITUDE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and LONGITUDE=ANY     %then %unset LONGITUDE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and NUMBER=ANY     %then %unset NUMBER
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and QUANTILE=ANY     %then %unset QUANTILE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and ITERATION=ANY     %then %unset ITERATION
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and DIAGNOSTIC=ANY     %then %unset DIAGNOSTIC
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and INSTRUMENT=ANY     %then %unset INSTRUMENT
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and FILTER=ANY     %then %unset FILTER
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and INTERPOLATION=ANY     %then %unset INTERPOLATION
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and REFDATE=ANY     %then %unset REFDATE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and HDATE=ANY     %then %unset HDATE
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and FREQUENCY=ANY     %then %unset FREQUENCY
%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and DIRECTION=ANY     %then %unset DIRECTION




%if TYPE <> CF %and TYPE <> PF %and TYPE <> CV %then %unset ENSEMBLE
%if TYPE <> CM %and TYPE <> CS  %then %unset CLUSTER
%if TYPE <> FP %then %unset PROBABILITY


#%if TYPE <> CF %and 
%if TYPE <> PF %and 
	TYPE <> CM %and 
	TYPE <> CS %and 
	TYPE <> CR %and 
	TYPE <> CV %and 
	TYPE <> SV %and 
	TYPE <> AS %and 
	TYPE <> FP %and 
	TYPE <> ED %and 
	TYPE <> TU %and 
	TYPE <> CI %and
	TYPE <> ME %and 
	TYPE <> FF %and           # Ocean
	TYPE <> ICP %and 
	TYPE <> SOT %and 
	TYPE <> FCMEAN %and
	TYPE <> FCMAX %and
	TYPE <> FCMIN %and
	TYPE <> FCSTDEV %and
	TYPE <> SVAR %and
	CLASS <> TI %and
	CLASS <> S2 %and
	STREAM <> MOFC %and 
	STREAM <> WAMF %and 
	STREAM <> MOFM %and 
	STREAM <> WMFM %and 
	STREAM <> SEAS %and 
	STREAM <> WASF %and
	STREAM <> WAMF %and
	STREAM <> SFMM %and
	STREAM <> SMMA %and
	STREAM <> SEAP %and 
	STREAM <> SWMM %and
	STREAM <> OCEA %and
# New Monthly Forecast
	STREAM <> MNFC %and
    STREAM <> MNFH %and
    STREAM <> MNFA %and
    STREAM <> MNFW %and
    STREAM <> MFHW %and
    STREAM <> MFAW %and
    STREAM <> MNFM %and
    STREAM <> MFHM %and
    STREAM <> MFAM %and
    STREAM <> MFWM %and
    STREAM <> MHWM %and
    STREAM <> MAWM %and
# New Multi-model
	STREAM <> MMSF %and 
	STREAM <> MSMM %and 
	STREAM <> WAMS %and 
	STREAM <> MSWM %and 
	STREAM <> MMSA %and 
# Ensemble Data Assimilation
	STREAM <> ENDA %and 
	STREAM <> EWDA %and 
	STREAM <> EDMM %and 
	STREAM <> EDMO %and 
	STREAM <> EWMM %and 
	STREAM <> EWMO %and 
	STREAM <> ELDA %and 
	STREAM <> EWLA %and 
# Ensemble Supplementary data
	STREAM <> ESPD %and 
# Multi-model Multi-annual
	STREAM <> MMAF %and 
	STREAM <> MMAM %and 
	STREAM <> MMAW %and 
	STREAM <> MMWM %and 
	STREAM <> SEAS %then
	%unset NUMBER

%if STREAM <> ENFH %and 
	STREAM <> ENWH %and
	STREAM <> EFHO %and
	STREAM <> EHMM %and
	STREAM <> EWHO %then
	%unset HDATE

%if (TYPE <> PD %and 
    TYPE <> CD %and
    TYPE <> PB) %then
	%unset QUANTILE

%if ( STREAM = MNFM %or
	STREAM = MFHM %or
    STREAM = MFAM %or
    STREAM = MFWM %or
    STREAM = MHWM %or
    STREAM = ESMM %or
    STREAM = EHMM %or
    STREAM = MAWM )
	%then
	%unset STEP

%if ( STREAM = MFHM %and
	( TYPE = EM %or TYPE = ES %or TYPE = SES) )
	%then 
	%unset DATE

%if ( STREAM = MNFH %and
	( TYPE = EM %or TYPE = ES %or TYPE = SES %or TYPE = ED ) )
	%then
	%unset DATE

%if (_VERB = RETRIEVE %or _VERB = ARCHIVE) %and 
	(STREAM <> MOFC %and STREAM <> WAMF %and STREAM <> MOFM %and STREAM <> WMFM) %and 
	(TYPE = CF %or TYPE = EM %or TYPE = ES %or TYPE = SES %or TYPE = TAEM %or TYPE = TAES) %then 
	%unset ENSEMBLE %unset NUMBER

! For read
%if _VERB = READ %and CLASS  <> ANY %then %warning "CLASS  ignored in READ"
%if _VERB = READ %and REPRES <> ANY %then %warning "REPRES ignored in READ"

%if _VERB = READ %then 
	%unset CLASS 
	%unset REPRES

%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %and TYPE = FG %and STEP = 0 %and STREAM = OPER  
	%then 
		%warning "First Guess step 0 removed"
		%error   "Please, use STEP=06 instead"


! =========================================
! For wave, there is no step for FG
%if (STREAM = WAVE %or STREAM = SCWV %or STREAM = DCWV) %and TYPE = FG %and STEP <> 0 %then 
	%warning "For wave first-guess, step is ignored and set to zero"
	%set     STEP = 0

! =========================================
! There are no waves in altitude
%if STREAM = WAVE %or 
	STREAM = WAEF %or 
	STREAM = WEHS %or 
	STREAM = WEOV %or 
	STREAM = WAMO %or 
	STREAM = SCWV %or 
	STREAM = DCWV %or 
	STREAM = WVHC %or
	STREAM = EWHC %or
	STREAM = MAWV %or
	STREAM = WASF %or 
	STREAM = WAMF %or
	STREAM = WMFM %or
	STREAM = SWMM %or
	STREAM = MNFW %or
	STREAM = MFHW %or
	STREAM = MFAW %or
	STREAM = MFWM %or
	STREAM = MHWM %or
	STREAM = MAWM %or
	STREAM = WAMS %or
	STREAM = DACW %or
	STREAM = EWDA %or
	STREAM = LWWV %or
	STREAM = EWLA %or
	STREAM = EWMM %or
	STREAM = EWMO %or
	STREAM = WAMD %or
	STREAM = MSWM %then

	%warning "For wave data, LEVTYPE forced to Surface"
	%set     LEVTYPE = SFC
	%unset   LEVELIST

!===========================================================

!
! Avoid use of ENSEMBLE, CLUSTER and PROBABILITY in new MARS retrieval editors

%if TYPE = PF %and ENSEMBLE = OFF %then %unset ENSEMBLE
%if (TYPE = CM %or TYPE = CS %or TYPE = CR) %and CLUSTER = OFF %then %unset CLUSTER
%if (TYPE = FP) %and PROBABILITY = OFF %then %unset PROBABILITY

%if STREAM <> WAVE %and 
	STREAM <> SCWV %and 
	STREAM <> DCWV %and 
	STREAM <> MAWV %and 
	STREAM <> WASF %and 

	STREAM <> WAEF %and 
	STREAM <> EWDA %and 

	STREAM <> MNFW %and 
	STREAM <> MFHW %and 
	STREAM <> MFAW %and 

	STREAM <> WVHC %and
	STREAM <> EWHC %and

	STREAM <> ENWH %and
	STREAM <> EWHO %and

	STREAM <> LWWV %and
	STREAM <> EWLA %and

	STREAM <> WAMD %and

	STREAM <> WAMF %then 
	%unset FREQUENCY %unset DIRECTION

! Avoid visiting all mars tree on the server
%if (_VERB = LIST %and OUTPUT <> BROWSER %and (%not CLASS))   %then 
	%warning "Missing CLASS. Force to Operations"
	%set CLASS= OD

%if (_VERB = LIST %and OUTPUT <> BROWSER %and CLASS <> RD  %and (%not DATE) %and (%not PSEUDODATE) ) %then 
	%warning "Missing DATE. Force to yesterday"
	%set DATE = -1

%if (_VERB = LIST %and OUTPUT <> BROWSER %and CLASS <> RD  %and (%not STREAM) ) %then 
	%warning "Missing STREAM. Force to Daily archive"
	%set STREAM = OPER

%if (_VERB = LIST %and OUTPUT <> BROWSER %and CLASS <> RD  %and (%not EXPVER) ) %then 
	%warning "Missing EXPVER. Force to 1"
	%set EXPVER = 1

%if (_VERB = LIST %and OUTPUT <> BROWSER %and CLASS <> RD  %and (%not TYPE) ) %then 
	%warning "Missing TYPE. Force to Analysis"
	%set TYPE = AN

%if (_VERB = LIST %and OUTPUT <> BROWSER %and CLASS = RD  %and (%not EXPVER) ) %then 
	%error "Missing EXPVER. Please, specify one"

%if (_VERB = LIST %and OUTPUT = TREE %and (%not HIDE)) %then 
	%set HIDE=FILE/LENGTH/MISSING/OFFSET/ID/COST/MONTH/YEAR


! Observation retrieval from new MARS
%if (_VERB = RETRIEVE %and (STREAM = SSBT %or STREAM = E1)) %then
	%warning "Changed STREAM to OPER"
	%set STREAM = OPER

%if (_VERB = RETRIEVE %and STREAM = SSMI) %then
	%warning "Changed STREAM=OPER, TYPE=OB"
	%set STREAM = OPER
	%set TYPE = OB

%if (ACCURACY = N) %and (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %then
	%unset ACCURACY

%if (ACCURACY = R %or ACCURACY = L) %then
	%warning "ACCURACY Low or Reduced force to 8 bits"
	%set ACCURACY = 8

%if (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) 
	%and _VERB = RETRIEVE 
	%and SOURCE 
	%and (%not DATABASE) %then
	%set DATABASE = file


%if (_VERB = ARCHIVE %or 
	 _VERB = FLUSH %or 
	 _VERB = STAGE %or 
	 _VERB = LIST %or 
	 _VERB = REMOVE)
	%and (CLASS=E4 %or 
	      CLASS=EI %or
		  CLASS=ER %or 
		  CLASS=PV %or 
		  CLASS=DM %or 
		  CLASS=CS %or 
		  CLASS=TO %or 
		  CLASS=DT %or 
		  CLASS=EL %or 
		  CLASS=YT %or 
		  CLASS=MC %or 
		  CLASS=EM %or 
		  CLASS=E2 %or 
		  CLASS=EA %or 
		  CLASS=ET %or 
		  CLASS=NR %or 
		  CLASS=EP %or 
		  CLASS=RM %or 
		  CLASS=C3 %or 
		  CLASS=UR %or 
		  CLASS=YP %or 
		  CLASS=ME %or 
		  CLASS=EN) 
	%and (%not DATABASE) %then
	%set DATABASE = marser

%if (_VERB = ARCHIVE %or 
	 _VERB = FLUSH %or 
	 _VERB = STAGE %or 
	 _VERB = LIST %or 
	 _VERB = REMOVE)
	%and (CLASS=TI %or
	      CLASS=S2)
	%and (%not DATABASE) %then
	%set DATABASE = marsth

%if (_VERB = ARCHIVE %or 
	 _VERB = STAGE %or 
	 _VERB = FLUSH %or 
	 _VERB = LIST %or 
	 _VERB = REMOVE)
	%and CLASS=OD 
	%and EXPVER < 10
	%and (%not DATABASE) %then
	%set DATABASE = marsod

%if (_VERB = ARCHIVE %or 
	 _VERB = STAGE %or 
	 _VERB = FLUSH %or 
	 _VERB = LIST %or 
	 _VERB = REMOVE)
	%and CLASS=OD 
	%and EXPVER > 9
	%and (%not DATABASE) %then
	%set DATABASE = marsode

%if (_VERB = ARCHIVE %or 
	 _VERB = STAGE %or 
	 _VERB = FLUSH %or 
	 _VERB = LIST %or 
	 _VERB = REMOVE)
	%and (CLASS=CO %or CLASS=SR %or CLASS=LA %or CLASS=MS)
	%and (%not DATABASE) %then
	%set DATABASE = marsms

%if (_VERB = ARCHIVE %or 
	 _VERB = FLUSH %or 
	 _VERB = STAGE %or 
	 _VERB = REMOVE %or 
	 _VERB = LIST)
	%and (CLASS<>E4 %and 
	      CLASS<>EI %and
	      CLASS<>TI %and
	      CLASS<>S2 %and
		  CLASS<>ER %and 
		  CLASS<>PV %and 
		  CLASS<>DM %and 
		  CLASS<>OD %and 
		  CLASS<>TO %and
		  CLASS<>DT %and
		  CLASS<>EN %and
		  CLASS<>CO %and
		  CLASS<>RM %and
		  CLASS<>SR %and
		  CLASS<>LA %and
		  CLASS<>EL %and
		  CLASS<>MS %and
		  CLASS<>ME %and
		  CLASS<>EM %and
		  CLASS<>E2 %and
		  CLASS<>EA %and
		  CLASS<>ET %and
		  CLASS<>C3 %and
		  CLASS<>UR %and
		  CLASS<>YP %and
		  CLASS<>MC %and
		  CLASS<>NR %and
		  CLASS<>EP %and
		  CLASS<>CS)
	%and (%not DATABASE) %then
	%set DATABASE = marsrd

# ocean
%if LEVTYPE = DP
	%and (SECTION = M %or SECTION = Z) 
	%and (PRODUCT = INST %or PRODUCT = TACC %or PRODUCT = TAVG)
	%then
	%unset LEVELIST

# Special case for TIMS, V
%if LEVTYPE = DP
	%and SECTION = V
	%and PRODUCT = TIMS 
	%then
	%unset LEVELIST

%if LEVTYPE = DP
	%and TYPE = OR
	%and (%not PRODUCT)
	%then
		%warning "Default PRODUCT for Ocean ReAnalysis set to Instantaneous"
		%set PRODUCT = INST


# Year & month
%if _VERB = RETRIEVE %and (YEAR %or MONTH) %then
	%unset DATE

# Boundary Conditions (BC)
%if _VERB = RETRIEVE %and CLASS = OD %and TIME = 00 %and STREAM = OPER %and DATE >= 20000906 %and EXPVER = 02
%then 
	%warning "From 20000906 onwards, please use EXPVER=1"
	%warning "STREAM=SCDA for Boundary Conditions Project data"

%if _VERB = RETRIEVE %and CLASS = OD %and TIME = 00 %and STREAM = WAVE %and DATE >= 20000906 %and EXPVER = 02
%then 
	%warning "From 20000906 onwards, please use EXPVER=1"
	%warning "STREAM=SCWV for Boundary Conditions wave data"

%if (_VERB = ARCHIVE %and (STREAM = SFMM %or STREAM = SWMM %or STREAM = SMMA) %and VERIFY) %then
	%error "Please, use FCMONTH instead of VERIFY for archiving"
	%error "Exiting..."

%if ((CLASS <> OD %and CLASS <> EN %and CLASS <> ME %and CLASS <> C3) %and SYSTEM ) %then
	%unset SYSTEM

# A bit of paranoia...

%if _VERB = REMOVE %and CLASS = OD %and %not DATABASE %then
	%set DATABASE = dhstest
	
# That should be disabled in mars.def anyway

%if _VERB = REMOVE %and (
	CLASS = ER %or
	CLASS = E4 %or 
	CLASS = EI %or 
	CLASS = EM %or 
	CLASS = E2 %or 
	CLASS = CS %or 
	CLASS = PV %or 
	CLASS = TO %or 
	CLASS = DT %or 
	CLASS = PE %or 
	CLASS = MC %or 
	CLASS = ME %or 
	CLASS = DM
	) %then
	%error "Cannot remove this data..."


%if (CLASS = IT %and MODEL = HRM) %or (CLASS = CO) %then
	%warning "Post-processing directives are ignored"
	%set _POSTPROCESSING = 0

%if (STREAM = MODA %or STREAM = MSDA %or STREAM = EDMO %or STREAM = EWMO %or STREAM = WAMD) %and (CLASS <> ER) %then
	%unset TIME
	%unset STEP

%if (STREAM = MDFA) %then
	%unset TIME

%if (CLASS <> TO %and CLASS <> DT) %or STREAM <> SEAP %then
	%unset LEADTIME
	%unset OPTTIME

%if (CLASS=DT) %then
	%unset METHOD

#########################################
# Migration from old images to new images
#########################################

# Meteosat
%if (TYPE=IM %and OBSTYPE=0 %and (IDENT=52 %or IDENT=53 %or IDENT=54))  %then 
	%warning "Replacing OBSTYPE=0 by CHANNEL=2, INSTRUMENT=205"
	%unset OBSTYPE 
	%set CHANNEL    = 2 
	%set INSTRUMENT = 205

%if (TYPE=IM %and OBSTYPE=10 %and (IDENT=52 %or IDENT=53 %or IDENT=54))  %then 
	%warning "Replacing OBSTYPE=10 by CHANNEL=3, INSTRUMENT=205"
	%unset OBSTYPE 
	%set CHANNEL    = 3 
	%set INSTRUMENT = 205

%if (TYPE=IM %and OBSTYPE=20 %and (IDENT=52 %or IDENT=53 %or IDENT=54))  %then 
	%warning "Replacing OBSTYPE=10 by CHANNEL=1, INSTRUMENT=205"
	%unset OBSTYPE 
	%set CHANNEL    = 1 
	%set INSTRUMENT = 205

# GOES
%if (TYPE=IM %and OBSTYPE=0 %and (IDENT=252 %or IDENT=253 %or IDENT=254 %or IDENT=255 %or IDENT=256)) %then 
	%warning "Replacing OBSTYPE=0 by CHANNEL=4, INSTRUMENT=615"
	%unset OBSTYPE 
	%set CHANNEL    = 4 
	%set INSTRUMENT = 615

%if (TYPE=IM %and OBSTYPE=10 %and (IDENT=252 %or IDENT=253 %or IDENT=254 %or IDENT=255 %or IDENT=256)) %then 
	%warning "Replacing OBSTYPE=10 by CHANNEL=1, INSTRUMENT=615"
	%unset OBSTYPE 
	%set CHANNEL    = 1 
	%set INSTRUMENT = 615

%if (TYPE=IM %and OBSTYPE=20 %and (IDENT=252 %or IDENT=253 %or IDENT=254 %or IDENT=255 %or IDENT=256)) %then 
	%warning "Replacing OBSTYPE=20 by CHANNEL=3, INSTRUMENT=615"
	%unset OBSTYPE 
	%set CHANNEL    = 3 
	%set INSTRUMENT = 615

################################################
# end of Migration from old images to new images
################################################

%if (FCMONTH %or FCPERIOD)  %and (_APPL = mars %or _APPL = marsG2 %or _APPL = msserver %or _APPL = uniserver) %then 
	%unset STEP

# %if (STREAM = SFMM %or STREAM = SWMM %or STREAM = SMMA %or STREAM = MMSA) %then
# 	%unset STEP
# 

%if (CLASS = TI %or CLASS = S2 %or CLASS = UR ) %then                %unset DOMAIN
%if (CLASS = TI %or CLASS = S2) %and TYPE = CF %then %set NUMBER=0
%if CLASS = TI %and TYPE = FC %then %set STREAM=OPER
%if (CLASS = TI %or CLASS = S2 %or CLASS = UR ) %and (%not EXPVER) %then %set EXPVER=PROD

%if (CLASS = UR) %then %unset MODEL

%if CLASS = DM %and TYPE = FC %then %set TIME=0

# ANOFFSET not valid unless Long window 4dvar 
%if STREAM <> LWDA %and 
	STREAM <> LWWV %and
	STREAM <> ELDA %and 
	STREAM <> EWLA %then
	%unset ANOFFSET


# ERA Interim Data Server at full resolution
%if ((DATASET = interim_full_daily)  %and
    ((TYPE <> AN %and TYPE <> FC) %or
	 (TYPE = FC %and (STEP > 12 %or LEVTYPE <> SFC)))) %then
	 %error "Dataset ERA-Interim full resolution available only for Analysis and Forecast surface fluxes at time-step <= 12"
	 %fail

%if ((CLASS = EM) %and EXPVER=1605 %and STREAM=EDMO) %then
	%error "Access to dataset ERA-20CMv0 daily monthly means has been disabled"
	%error "For more information, see http://www.ecmwf.int/en/forecasts/datasets/era-20cm-model-integrations"
	%fail

# Double-archiving marsrd/marsrd-cluster
#%if ((_VERB = ARCHIVE %or 
#	 _VERB = FLUSH %or 
#	 _VERB = REMOVE) %and 
#    (DATABASE = marsrd)) %then %set DATABASE = marsrd/marsrd-cluster


#%if ((_VERB = ARCHIVE %or 
#	 _VERB = FLUSH %or 
#	 _VERB = REMOVE) %and 
#     (DATABASE = marstest)) %then %set DATABASE = marstest/marsdev-core

%if (GRID = N1280 %or (GRID=1280 %and GAUSSIAN=REDUCED)) %then 
	%error "Classic reduced gaussian 1280 not supported"
	%fail 

%include "rt_by_obsgroup.chk"