Subversion Repositories lagranto.um

Rev

Rev 3 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 15
1
#!/bin/csh
1
#!/bin/csh
2
 
2
 
-
 
3
# Set Lagranto 
-
 
4
set LAGRANTO = ${LAGRANTOBASE}.${MODEL}/
-
 
5
 
3
# -----------------------------------------------------------------------------
6
# -----------------------------------------------------------------------------
4
# Set some parameters
7
# Set some parameters
5
# -----------------------------------------------------------------------------
8
# -----------------------------------------------------------------------------
6
 
9
 
7
# Get arguments
10
# Get arguments
8
if ( ${#argv} == 0 ) then
11
if ( ${#argv} == 0 ) then
9
    set poleprint = 1
12
    set poleprint = 1
10
    set inpfile   = ""
13
    set inpfile   = ""
11
    set outfile   = ""
14
    set outfile   = ""
12
else
15
else
13
    set poleprint = 0
16
    set poleprint = 0
14
    set inpfile   = $1
17
    set inpfile   = $1
15
    set outfile   = $2
18
    set outfile   = $2
16
endif
19
endif
17
 
20
 
18
# Get the pole position
21
# Get the pole position
19
if ( -f geo2rot.pole ) then
22
if ( -f geo2rot.pole ) then
20
   set pole = `cat geo2rot.pole` 
23
   set pole = `cat geo2rot.pole` 
21
else if ( -f rot2geo.pole ) then 
24
else if ( -f rot2geo.pole ) then 
22
   set pole = `cat rot2geo.pole` 
25
   set pole = `cat rot2geo.pole` 
23
else
26
else
24
   set pole = "0. 90."
27
   set pole = "0. 90."
25
endif
28
endif
26
 
29
 
27
# Handle optional arguments
30
# Handle optional arguments
28
set polefile = 0
31
set polefile = 0
29
 
32
 
30
while ( $#argv > 0 )
33
while ( $#argv > 0 )
31
 
34
 
32
  switch ( $argv[1] )
35
  switch ( $argv[1] )
33
 
36
 
34
   case -lonlat
37
   case -lonlat
35
     set pole = "$argv[2] $argv[3]"
38
     set pole = "$argv[2] $argv[3]"
36
     shift; shift;
39
     shift; shift;
37
   breaksw
40
   breaksw
38
 
41
 
39
   case -file
42
   case -file
40
     set polefile = 1
43
     set polefile = 1
41
     set filename = $argv[2] 
44
     set filename = $argv[2] 
42
     shift;
45
     shift;
43
   breaksw
46
   breaksw
44
 
47
 
45
  endsw
48
  endsw
46
 
49
 
47
  shift;
50
  shift;
48
 
51
 
49
end
52
end
50
 
53
 
51
# Get the pole position from file  if requested
54
# Get the pole position from file  if requested
52
if ( "${polefile}" == "1" ) then
55
if ( "${polefile}" == "1" ) then
53
    
56
    
54
    # Check whether file is available
57
    # Check whether file is available
55
    if ( ! -f ${filename} ) then
58
    if ( ! -f ${filename} ) then
56
       echo "file ${filename} not found... stop"
59
       echo "file ${filename} not found... stop"
57
       exit 1
60
       exit 1
58
    endif
61
    endif
59
 
62
 
60
    # Get pole directly from cst or from P,S file
63
    # Get pole directly from cst or from P,S file
61
    set pollon = ""
64
    set pollon = ""
62
    set ok     = `ncdump -h ${filename} | grep pollon`
65
    set ok     = `ncdump -h ${filename} | grep pollon`
63
    if ( "${ok}" != "" ) then
66
    if ( "${ok}" != "" ) then
64
       set pollon = `ncdump ${filename} | grep 'pollon =' | awk '{print $3}'`
67
       set pollon = `ncdump ${filename} | grep 'pollon =' | awk '{print $3}'`
65
    else 
68
    else 
66
       set ok       = `ncdump -h ${filename} | grep constants_file_name`
69
       set ok       = `ncdump -h ${filename} | grep constants_file_name`
67
       set filename = `ncdump -h ${filename} | grep 'constants_file_name' | awk '{print $3}'`
70
       set filename = `ncdump -h ${filename} | grep 'constants_file_name' | awk '{print $3}'`
68
       set filename = `echo ${filename} | sed -e 's/\"//g'`
71
       set filename = `echo ${filename} | sed -e 's/\"//g'`
69
       set ok       = `ncdump -h ${filename} | grep pollon`
72
       set ok       = `ncdump -h ${filename} | grep pollon`
70
       set pollon   = `ncdump ${filename}    | grep 'pollon =' | awk '{print $3}'`
73
       set pollon   = `ncdump ${filename}    | grep 'pollon =' | awk '{print $3}'`
71
    endif
74
    endif
72
 
75
 
73
    set pollat = ""
76
    set pollat = ""
74
    set ok     = `ncdump -h ${filename} | grep pollat`
77
    set ok     = `ncdump -h ${filename} | grep pollat`
75
    if ( "${ok}" != "" ) then
78
    if ( "${ok}" != "" ) then
76
       set pollat = `ncdump ${filename} | grep 'pollat =' | awk '{print $3}'`
79
       set pollat = `ncdump ${filename} | grep 'pollat =' | awk '{print $3}'`
77
    else 
80
    else 
78
       set ok       = `ncdump -h ${filename} | grep constants_file_name`
81
       set ok       = `ncdump -h ${filename} | grep constants_file_name`
79
       set filename = `ncdump -h ${filename} | grep 'constants_file_name' | awk '{print $3}'`
82
       set filename = `ncdump -h ${filename} | grep 'constants_file_name' | awk '{print $3}'`
80
       set filename = `echo ${filename} | sed -e 's/\"//g'`
83
       set filename = `echo ${filename} | sed -e 's/\"//g'`
81
       set ok       = `ncdump -h ${filename} | grep pollat`
84
       set ok       = `ncdump -h ${filename} | grep pollat`
82
       set pollat   = `ncdump ${filename}    | grep 'pollat =' | awk '{print $3}'`
85
       set pollat   = `ncdump ${filename}    | grep 'pollat =' | awk '{print $3}'`
83
    endif
86
    endif
84
 
87
 
85
    if ( ( "${pollon}" == "" ) | ( "${pollat}" == "" ) ) then
88
    if ( ( "${pollon}" == "" ) | ( "${pollat}" == "" ) ) then
86
       echo "cannot find pollon/pollat on ${filename}... Stop"
89
       echo "cannot find pollon/pollat on ${filename}... Stop"
87
       exit 1
90
       exit 1
88
    endif
91
    endif
89
 
92
 
90
    set pole = "${pollon} ${pollat}"
93
    set pole = "${pollon} ${pollat}"
91
 
94
 
92
endif
95
endif
93
 
96
 
94
# Write the pole position to the pole file  
97
# Write the pole position to the pole file  
95
\rm -f geo2rot.pole
98
\rm -f geo2rot.pole
96
echo ${pole} > geo2rot.pole
99
echo ${pole} > geo2rot.pole
97
 
100
 
98
# Decide whether to exit from the script
101
# Decide whether to exit from the script
99
if ( "${inpfile}" == "-lonlat" ) set poleprint = 1
102
if ( "${inpfile}" == "-lonlat" ) set poleprint = 1
100
if ( "${inpfile}" == "-file"   ) set poleprint = 1
103
if ( "${inpfile}" == "-file"   ) set poleprint = 1
101
 
104
 
102
# On request, print the pole position and exit
105
# On request, print the pole position and exit
103
if ( ${poleprint} == 1 ) then
106
if ( ${poleprint} == 1 ) then
104
    cat geo2rot.pole
107
    cat geo2rot.pole
105
    exit 0
108
    exit 0
106
endif
109
endif
107
 
110
 
108
# Decide whether a position or a trajectory is to be rotated
111
# Decide whether a position or a trajectory is to be rotated
109
set ok1 = `echo ${inpfile} | sed -e 's/[0123456789.-]//g' | wc -w`
112
set ok1 = `echo ${inpfile} | sed -e 's/[0123456789.-]//g' | wc -w`
110
set ok2 = `echo ${outfile} | sed -e 's/[0123456789.-]//g' | wc -w`
113
set ok2 = `echo ${outfile} | sed -e 's/[0123456789.-]//g' | wc -w`
111
 
114
 
112
if ( ( ${ok1} == 0 ) && ( ${ok2} == 0 ) ) then
115
if ( ( ${ok1} == 0 ) && ( ${ok2} == 0 ) ) then
113
    set mode = 'position'
116
    set mode = 'position'
114
    set lon  = ${inpfile}
117
    set lon  = ${inpfile}
115
    set lat  = ${outfile}
118
    set lat  = ${outfile}
116
else if ( ( ${ok1} != 0 ) && ( ${ok2} != 0 ) ) then
119
else if ( ( ${ok1} != 0 ) && ( ${ok2} != 0 ) ) then
117
    set mode = 'trajectory'
120
    set mode = 'trajectory'
118
    if ( ! -f ${inpfile} ) then
121
    if ( ! -f ${inpfile} ) then
119
       echo "${inpfile} is missing... Stop"
122
       echo "${inpfile} is missing... Stop"
120
       exit 1
123
       exit 1
121
    endif
124
    endif
122
else
125
else
123
    set mode = 'nil'
126
    set mode = 'nil'
124
endif
127
endif
125
 
128
 
126
# Decide whether the Fortran programe needs to be launched
129
# Decide whether the Fortran programe needs to be launched
127
if ( "${mode}" == "nil" ) then
130
if ( "${mode}" == "nil" ) then
128
    exit 0
131
    exit 0
129
endif
132
endif
130
    
133
    
131
# Prepare the parameter file and run Fortran program
134
# Prepare the parameter file and run Fortran program
132
\rm -f geo2rot.param
135
\rm -f geo2rot.param
133
echo \"${mode}\"                             >! geo2rot.param
136
echo \"${mode}\"                             >! geo2rot.param
134
if ( "${mode}" == "position" ) then
137
if ( "${mode}" == "position" ) then
135
   echo ${lon}                               >> geo2rot.param
138
   echo ${lon}                               >> geo2rot.param
136
   echo ${lat}                               >> geo2rot.param
139
   echo ${lat}                               >> geo2rot.param
137
else if ( "${mode}" == "trajectory" ) then
140
else if ( "${mode}" == "trajectory" ) then
138
   echo \"${inpfile}\"                       >> geo2rot.param
141
   echo \"${inpfile}\"                       >> geo2rot.param
139
   echo \"${outfile}\"                       >> geo2rot.param
142
   echo \"${outfile}\"                       >> geo2rot.param
140
   ${LAGRANTO}/bin/trainfo.sh ${inpfile} dim >> geo2rot.param
143
   ${LAGRANTO}/bin/trainfo.sh ${inpfile} dim >> geo2rot.param
141
endif
144
endif
142
echo ${pole} >> geo2rot.param
145
echo ${pole} >> geo2rot.param
143
 
146
 
144
${LAGRANTO}/goodies/geo2rot
147
${LAGRANTO}/goodies/geo2rot
145
 
148
 
146
# Make clean
149
# Make clean
147
#\rm -f geo2rot.param
150
#\rm -f geo2rot.param
148
 
151
 
149
exit 0
152
exit 0
150
 
153