Subversion Repositories lagranto.um

Rev

Go to most recent revision | 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
  echo "--------------------------------------------------------------"
19
  echo "Usage: trainfo.sh trafile mode        "
20
  echo 
21
  echo "         trafile           : Input trajectory file"
22
  echo
23
  echo "         mode = dim        : # trajectories #times #columns"
24
  echo "                ntra       : # trajectories"
25
  echo "                ntim       : # times "
26
  echo "                ncol       : # columns"
27
  echo "                vars       : List of variable names"
28
  echo "                refdate    : Reference date yyyymmdd_hhmm"
29
  echo "                times      : List of times"
30
  echo "                startdate  : start date yyyymmdd_hhmm"
31
  echo "                enddate    : start date yyyymmdd_hhmm"
32
  echo "                timerange  : time range (in min)"
33
  echo "                list       : complete listing of trajectories"
34
  echo
35
  echo "--------------------------------------------------------------"
36
  exit 0
37
endif
38
 
39
# Set Fortran program
40
set prog=${LAGRANTO}/goodies/trainfo
41
 
42
# -----------------------------------------------------------------------------
43
# Run program 
44
# -----------------------------------------------------------------------------
45
 
46
\rm -f trainfo.param
47
echo \"${inpfile}\" >! trainfo.param 
48
echo \"${mode}\"    >> trainfo.param
49
 
50
${prog}
51
 
52
\rm -f trainfo.param
53
 
54
exit 0
55
 
56
# -----------------------------------------------------------------------------
57
# Old code: shell script extraction of ntra,ntim,ncol
58
# -----------------------------------------------------------------------------
59
 
60
# Get line numbers of first trajectory block (separated by empty line) 
61
set first=4
62
loop1:
63
  @ first = ${first} + 1
64
  set line=`sed -ne "${first},${first}p" ${inpfile}` 
65
if ( "${line}" != "" ) goto loop1
66
@ final = ${first} + 1
67
loop2:
68
  @ final = ${final} + 1
69
  set line=`sed -ne "${final},${final}p" ${inpfile}`
70
if ( "${line}" != "" ) goto loop2
71
@ first = ${first} + 1
72
@ final = ${final} - 1
73
 
74
# Set the number of fields, of times and of trajectories
75
set ntime=`echo "1 + ${final} - ${first}" | bc`  
76
set line=`sed -ne "${first},${first}p" ${inpfile}`
77
set ncol=`echo ${line} | awk '{print NF}'` 
78
set nlines=`wc -l ${inpfile} | awk '{print $1}'`
79
set ntra=`echo "(${nlines}-4)/(${ntime}+1)" | bc`
80
 
81
# Write info
82
echo ${ntra} ${ntime} ${ncol}