Subversion Repositories lagranto.um

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
#!/bin/csh
2
 
15 michaesp 3
# Set Lagranto 
4
set LAGRANTO = ${LAGRANTOBASE}.${MODEL}/
5
 
3 michaesp 6
# -----------------------------------------------------------------------------
7
# Set some parameters
8
# -----------------------------------------------------------------------------
9
 
10
# Set input file
11
set inpfile=$1
12
if ( ${#argv} == 2 ) then
13
  set mode=$2
14
else
15
  set mode='all'
16
endif
17
 
18
# Write usage information
19
if ( ${#argv} == 0) then
20
  echo 
21
  echo "--------------------------------------------------------------"
22
  echo "Usage: trainfo.sh trafile mode        "
23
  echo 
24
  echo "         trafile           : Input trajectory file"
25
  echo
26
  echo "         mode = dim        : # trajectories #times #columns"
27
  echo "                ntra       : # trajectories"
28
  echo "                ntim       : # times "
29
  echo "                ncol       : # columns"
30
  echo "                vars       : List of variable names"
31
  echo "                refdate    : Reference date yyyymmdd_hhmm"
32
  echo "                times      : List of times"
33
  echo "                startdate  : start date yyyymmdd_hhmm"
34
  echo "                enddate    : start date yyyymmdd_hhmm"
35
  echo "                timerange  : time range (in min)"
36
  echo "                list       : complete listing of trajectories"
37
  echo
38
  echo "--------------------------------------------------------------"
39
  exit 0
40
endif
41
 
42
# Set Fortran program
43
set prog=${LAGRANTO}/goodies/trainfo
44
 
45
# -----------------------------------------------------------------------------
46
# Run program 
47
# -----------------------------------------------------------------------------
48
 
49
\rm -f trainfo.param
50
echo \"${inpfile}\" >! trainfo.param 
51
echo \"${mode}\"    >> trainfo.param
52
 
53
${prog}
54
 
55
\rm -f trainfo.param
56
 
57
exit 0
58
 
59
# -----------------------------------------------------------------------------
60
# Old code: shell script extraction of ntra,ntim,ncol
61
# -----------------------------------------------------------------------------
62
 
63
# Get line numbers of first trajectory block (separated by empty line) 
64
set first=4
65
loop1:
66
  @ first = ${first} + 1
67
  set line=`sed -ne "${first},${first}p" ${inpfile}` 
68
if ( "${line}" != "" ) goto loop1
69
@ final = ${first} + 1
70
loop2:
71
  @ final = ${final} + 1
72
  set line=`sed -ne "${final},${final}p" ${inpfile}`
73
if ( "${line}" != "" ) goto loop2
74
@ first = ${first} + 1
75
@ final = ${final} - 1
76
 
77
# Set the number of fields, of times and of trajectories
78
set ntime=`echo "1 + ${final} - ${first}" | bc`  
79
set line=`sed -ne "${first},${first}p" ${inpfile}`
80
set ncol=`echo ${line} | awk '{print NF}'` 
81
set nlines=`wc -l ${inpfile} | awk '{print $1}'`
82
set ntra=`echo "(${nlines}-4)/(${ntime}+1)" | bc`
83
 
84
# Write info
85
echo ${ntra} ${ntime} ${ncol}