Subversion Repositories lagranto.wrf

Rev

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

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