root/tags/mcxtrace_beta/compiletest.sh

Revision 2239, 3.4 KB (checked in by farhi, 4 years ago)

MAJOR commit to McStas 2.x
uniformized parameter naming in components
uniformized SITE for instruments
all compile OK

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3#    This file is part of the McStas neutron ray-trace simulation package
4#    Copyright (C) 1997-2004, All rights reserved
5#    Risoe National Laborartory, Roskilde, Denmark
6#    Institut Laue Langevin, Grenoble, France
7#
8#    This program is free software; you can redistribute it and/or modify
9#    it under the terms of the GNU General Public License as published by
10#    the Free Software Foundation; version 2 of the License.
11#
12#    This program is distributed in the hope that it will be useful,
13#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#    GNU General Public License for more details.
16#
17#    You should have received a copy of the GNU General Public License
18#    along with this program; if not, write to the Free Software
19#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20#
21#    compiletest.sh - Developer tool / simple shell script for compilation
22#    check of all example instruments. To be used/checked before release of
23#    new 'stable' releases of McStas
24#   
25
26
27if [ $MCSTAS ]
28then
29  echo "McStas environment var set"
30else
31  MCSTAS="/usr/local/lib/mcstas"
32fi
33
34EXAMPLES="$MCSTAS/examples"
35export EXAMPLES
36EXECDIR=`mktemp -d -t McRun_XXXX`
37export EXECDIR
38MCSTAS_CFLAGS=
39export MCSTAS_CFLAGS
40
41echo "Example folder used is $EXAMPLES - compiling in $EXECDIR"
42
43for file in `find $MCSTAS -name \*.comp | grep -v obsolete | grep -v Adapt | grep -v Res_mon | grep -v PreMonitor_nD | grep -v Monitor_Optimizer | grep -v Pol `;
44do
45    comp=`basename $file .comp`
46    instr=`echo $EXECDIR/cTest_$comp.instr`
47    export comp
48    export instr
49    echo Creating $instr
50    # Extract parameter names and set to 0...
51    # DEFINITION PARMS:
52    echo "DEFINE INSTRUMENT Test_$comp()" > $instr
53    echo "TRACE" >> $instr
54    echo "COMPONENT Test = $comp(" >> $instr
55    first=1
56    export first
57    for parm in `grep SETTING -A 100 $file | grep -B 100 OUTPUT | sed -e 's/\"/\\\\"/g' | xargs echo | cut -f1 -d \) | cut -f2 -d \( | sed -e 's/int //g' | sed -e 's/double //g' | sed -e 's/string //g' | sed -e 's/char //g' | sed -e 's/\*//g' | sed -e 's/ =/=/g' | sed -e 's/= /=/g' | sed -e 's/ //g' | sed -e 's/,/ /g'`;
58    do
59        if [ "$first" != "1"  ]; then
60            echo ", " >> $instr
61        else
62          first=0
63          export first
64        fi
65        eq=`echo $parm | grep -c \=`
66        if [ "$eq" == "0"  ]; then
67          echo `echo $parm` = 1 >> $instr
68        else
69          echo `echo $parm` >> $instr 
70        fi   
71    done
72    for parm in `grep DEFINITION -A 100 $file | grep -B 100 SETTING | sed -e 's/\"/\\\\"/g' | xargs echo | cut -f1 -d \) | cut -f2 -d \( | sed -e 's/int //g' | sed -e 's/double //g' | sed -e 's/string //g' | sed -e 's/char //g' | sed -e 's/\*//g' | sed -e 's/ =/=/g' | sed -e 's/= /=/g' | sed -e 's/ //g' | sed -e 's/,/ /g'`;
73    do
74        if [ "$first" != "1"  ]; then
75            echo ", " >> $instr
76        else
77          first=0
78          export first
79        fi
80        eq=`echo $parm | grep -c \=`
81        if [ "$eq" == "0"  ]; then
82          echo `echo $parm ` = 1 >> $instr
83        else
84          echo `echo $parm` >> $instr 
85        fi   
86    done
87    echo ") AT (0,0,0) ABSOLUTE" >> $instr
88    echo END >> $instr
89done   
90
91if [ -e $EXAMPLES ]
92then
93  echo "Copying example instruments to $EXECDIR"
94  cp $EXAMPLES/*.instr $EXECDIR
95  cd $EXECDIR
96  NUMINSTR=`ls *.instr | wc -l`
97  echo Test-compiling $NUMINSTR instrument files...
98  for instr in `ls *.instr`
99  do
100    mcrun -n0 $instr > /dev/null
101    echo $instr done
102  done
103else
104  echo "Sorry, $EXAMPLES did not exist"
105  return 1
106fi
Note: See TracBrowser for help on using the browser.