Subversion Repositories pvinversion.ecmwf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
#!/usr/bin/perl
2
 
3
# Get input arguments
4
$paramfile=$ARGV[0];
5
$parammode=$ARGV[1];
6
 
7
# Define the extraction tables for the inversion programmes
8
if ( "$parammode" eq "p2z" )
9
   { @list = ('GRID.GEO_ZMIN',
10
              'GRID.GEO_NZ',
11
              'GRID.GEO_DZ'); }
12
 
13
if ( "$parammode" eq "ref" )
14
   { @list = ('GRID.REF_R'); }
15
 
16
if ( "$parammode" eq "def_anomaly" )
17
   { @list = ('ANOMALY.BOX_XMIN',
18
              'ANOMALY.BOX_XMAX',
19
              'ANOMALY.BOX_YMIN',
20
              'ANOMALY.BOX_YMAX',
21
              'ANOMALY.BOX_ZMIN',
22
              'ANOMALY.BOX_ZMAX',
23
              'ANOMALY.NFILTER',
24
              'ANOMALY.BOUND_XY',
25
              'ANOMALY.BOUND_Z'); }
26
 
27
if ( "$parammode" eq "rotate_grid" )
28
   { @list = ('GRID.ROT_NX',
29
              'GRID.ROT_NY',
30
              'GRID.ROT_DX',
31
              'GRID.ROT_DY',
32
              'GRID.CLON',
33
              'GRID.CLAT',
34
              'GRID.CROT'); }
35
 
36
if ( "$parammode" eq "rotate_lalo" )
37
   { @list = ('GRID.GEO_NX',
38
              'GRID.GEO_NY',
39
              'GRID.GEO_DX',
40
              'GRID.GEO_DY',
41
              'GRID.GEO_XMIN',
42
              'GRID.GEO_YMIN',
43
              'GRID.CLON',
44
              'GRID.CLAT',
45
              'GRID.CROT'); }
46
 
47
if ( "$parammode" eq "add2p" )
48
   { @list = ('NUMERICS.TRANS_XY',
49
              'NUMERICS.PS_CHANGE' ); }
50
 
51
if ( "$parammode" eq "coastline" )
52
   { @list = ('GRID.CLON',
53
              'GRID.CLAT',
54
              'GRID.CROT'); }
55
 
56
if ( "$parammode" eq "prep_iteration" )
57
   { @list = ('NUMERICS.ALPHA'); }
58
 
59
if ( "$parammode" eq "inp_dir" )
60
   { @list = ('DATA.INP_DIR'); };
61
 
62
if ( "$parammode" eq "run_dir" )
63
   { @list = ('DATA.RUN_DIR'); };
64
 
65
if ( "$parammode" eq "out_dir" )
66
   { @list = ('DATA.OUT_DIR'); };
67
 
68
if ( "$parammode" eq "n_of_iteration" )
69
   { @list = ('NUMERICS.NOFITER'); };
70
 
71
if ( "$parammode" eq "save_iteration" )
72
   { @list = ('NUMERICS.SAVEITER'); };
73
 
74
if ( "$parammode" eq "date" )
75
   { @list = ('DATA.DATE'); };
76
 
77
# Read the parameter file
78
@zeilen = `more $paramfile`;
79
 
80
# Set the first parameter which should be retrieved
81
foreach $listentry (@list)
82
{
83
  # Get section and name of the parameter
84
  @param = split /\./, "$listentry";
85
  $found=0;
86
 
87
  # Loop over all variables 
88
  foreach $zeile ( @zeilen )
89
  { 
90
 
91
    # -------------- BEGIN ------------------------------------
92
    if ( $zeile =~ 'BEGIN' )
93
    {
94
      @field = split / /, "$zeile";
95
      $_=$field[1];s/\s+//g;$bmode=$_;
96
    }
97
 
98
    # -------------- ASSIGNMENT -------------------------------
99
    if ( ($zeile =~ '=') && ($zeile =~ ';') )
100
    { 
101
      @field1 = split /=/, "$zeile";
102
      @field2 = split /;/, "$field1[1]";
103
      $_=$field1[0];s/\s+//g;$field1[0]=$_;
104
      $_=$field2[0];s/\s+//g;$field2[0]=$_;
105
      @field  = ( $field1[0], $field2[0] );
106
 
107
      if ( ("$bmode" eq "$param[0]") && ("$field[0]" eq "$param[1]" ) )
108
      {
109
         $found=1;
110
         print "$field[0] $field[1] \n";
111
      }
112
    }
113
 
114
    # -------------- END --------------------------------------
115
    if ( $zeile =~ 'END' )
116
    {
117
      @field = split / /, "$zeile";
118
      $_=$field[1];s/\s+//g;$emode=$_;
119
      if ( "$bmode" ne "$emode" )
120
      {
121
         die "Invalid structure of parameter file... $bmode\n";
122
      }
123
    }
124
  }
125
 if ( $found == 0 )
126
 {
127
   die("Parameter $listentry not found... Stop");
128
 }
129
}