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