Subversion Repositories lagranto.ecmwf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
#!/bin/csh
2
 
3
# -----------------------------------------------------------------------------
4
# Set some parameters
5
# -----------------------------------------------------------------------------
6
 
7
# Set input file
8
set inpfile=$1
9
if ( ${#argv} == 2 ) then
10
  set mode=$2
11
else
12
  set mode='all'
13
endif
14
 
15
# Write usage information
16
if ( ${#argv} == 0) then
17
  echo 
18
  ${LAGRANTO}/bin/lagrantohelp trainfo short
19
  echo  
20
  exit 0
21
endif
22
 
23
# Set Fortran program
24
set prog=${LAGRANTO}/goodies/trainfo
25
 
26
# -----------------------------------------------------------------------------
27
# Run program 
28
# -----------------------------------------------------------------------------
29
 
30
\rm -f trainfo.param
31
echo \"${inpfile}\" >! trainfo.param 
32
echo \"${mode}\"    >> trainfo.param
33
 
34
${prog}
35
 
36
\rm -f trainfo.param
37
 
38
exit 0
39
 
40
# -----------------------------------------------------------------------------
41
# Old code: shell script extraction of ntra,ntim,ncol
42
# -----------------------------------------------------------------------------
43
 
44
# Get line numbers of first trajectory block (separated by empty line) 
45
set first=4
46
loop1:
47
  @ first = ${first} + 1
48
  set line=`sed -ne "${first},${first}p" ${inpfile}` 
49
if ( "${line}" != "" ) goto loop1
50
@ final = ${first} + 1
51
loop2:
52
  @ final = ${final} + 1
53
  set line=`sed -ne "${final},${final}p" ${inpfile}`
54
if ( "${line}" != "" ) goto loop2
55
@ first = ${first} + 1
56
@ final = ${final} - 1
57
 
58
# Set the number of fields, of times and of trajectories
59
set ntime=`echo "1 + ${final} - ${first}" | bc`  
60
set line=`sed -ne "${first},${first}p" ${inpfile}`
61
set ncol=`echo ${line} | awk '{print NF}'` 
62
set nlines=`wc -l ${inpfile} | awk '{print $1}'`
63
set ntra=`echo "(${nlines}-4)/(${ntime}+1)" | bc`
64
 
65
# Write info
66
echo ${ntra} ${ntime} ${ncol}