root/branches/newmole/scripts/dayslow_master.pl

Revision 687, 8.9 kB (checked in by peter, 2 years ago)

Merge changes from mainline upto r685.

This branch is now fully merged. Any remaining problems in doxygen, scripts
and tsuite should now be resolved.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!perl -w
2# this script runs part of the slow test suite
3# if should be called with an argument that gives the run number
4# this runs the models in the following load-leveled list of sims
5# 0 will do from the 0th to 1st in the list
6# if no number is given then 0th run is done
7
8# this vector gives the load-leveled list of model numbers
9# zero runs first, then < second
10@runs=(0,5,11,1000);
11
12# this is the number of different runs that are possible with the above array
13# due to counting from zero, we are called with argv of 0, 1, and 2 for now
14# so two is the limit
15# this gets the size of the array at subtracts two
16$LAST = @runs - 2;
17
18if(!$ARGV[0])
19{
20   $ARGV[0] = 0;;
21}
22# this gives which one of the set this is
23$nrun = $ARGV[0];
24
25# these are the runs we shall do
26#$runs[0]=0;
27#$runs[1]=4;
28#$runs[2]=9;
29#$runs[3]=1000;
30
31# the disk drive
32$c = "M";
33
34# try using net use net use u: \\server-name\share-name\
35system( "net use $c: \\\\cumulus\\cumulus_c\$ /persistent:no" );
36
37$in_dir = "$c:/projects/cloudy/trunk/tsuite/slow/";
38$out_dir = "$c:/projects/cloudy/trunk/tsuite/slow/";
39
40# move to the output directory
41chdir( $out_dir or die "could not move to test suite directory\n");
42
43$log_file = "dayslow"."$nrun".".log";
44open( ioLOG , ">$log_file" );
45printf( ioLOG "have moved to output dir and opened log files\n");
46printf( ioLOG "input dir is $in_dir, out is $out_dir\n");
47
48if( $nrun == 0 || $nrun == 1 || $nrun == 2 )
49{
50   printf( ioLOG " start run number $nrun for test suite\n");
51}
52else
53{
54   printf( ioLOG " invalid run number $nrun for test suite\n");
55   exit(1);
56}
57
58# next two give first and last sim to compute in the range that are present
59# if( $nModTotal >= $nSkip && $nModTotal < $nmod_calc )
60# first sim to actually compute
61$nSkip = $runs[$nrun];
62# this is the upper bound
63$nmod_calc = $runs[$nrun+1];
64
65#$exe = "$c:/projects/Cloudy/current_net/Debug/current_net.exe";
66#$exe = "$c:\\projects\\Cloudy\\trunk\\current_net\\Debug\\current_net.exe";
67#$exe_org = "$c:/projects/cloudy/trunk/release/trunk.exe";
68# use fast gcc exe
69$exe_gcc = "$c:/projects/cloudy/trunk/gcc/release/cloudy_gcc.exe";
70$exe_icl = "$c:/projects/cloudy/trunk/icl/release/cloudy_icl.exe";
71$exe_org = $exe_icl;
72system("cp $exe_org $out_dir ");
73#$exe = "c:/projects/Cloudy/trunk/release/trunk.exe";
74#$exe = "$out_dir"."trunk.exe";
75$exe_gcc = "$out_dir"."cloudy_gcc.exe";
76$exe_icl = "$out_dir"."cloudy_icl.exe";
77$exe = $exe_icl;
78printf(ioLOG "exe is $exe\n");
79
80$TRUE = 1;
81$FALSE = 0;
82
83# if true then always recompute even when exe is older than results
84$lgForceCompute = $TRUE;
85# if false then only recompute when newer exe than results
86$lgForceCompute = $FALSE;
87
88# file containing any errors, also used for timestamp
89$errors = "$out_dir"."errors"."$nrun".".txt";
90# this file exists while long checking runs with purify are in pregress
91$blockrun = "blockfile.txt";
92# file with list of PROBLEM and DEBUG strings
93$problem_file = "$out_dir"."problems"."$nrun".".txt";
94
95# does $exe exist?
96if( !open(EXEFILE, "$exe_org") )
97{
98        printf( ioLOG "executable did not exist so exiting without running.\n" );
99        printf( STDERR "executable did not exist so exiting without running.\n" );
100        exit(1);
101}
102
103# see if errors.txt exists, if it does, and younger than exe file, just quit
104# $lgForceCompute set above, option to force recomputing model
105if( !$lgForceCompute  )
106{
107        if( -e $errors )
108        {
109                # is age of errors file smaler than exe file?
110                if( (-M $errors) < (-M EXEFILE ) )
111                {
112                        printf( ioLOG "executable older than errors.txt so exit.\n" );
113                        # no need to run tests, just quit
114                        exit(2);
115                }
116                # this file created when purify test is running
117                if( -e $blockrun )
118                {
119                        printf( ioLOG "blockrun file exists so exit.\n" );
120                        # no need to run tests, just quit
121                        exit(3);
122                }
123        }
124}
125
126
127printf( ioLOG "entering loop, exe is $exe \n" );
128
129# counter for total number of sims in directory
130$nModTotal = 0;
131# counter for number we actually computed
132$nComputed = 0;
133
134while( defined( $input = glob("$in_dir*.in") ) )
135{
136        if( $nModTotal >= $nSkip && $nModTotal < $nmod_calc )
137        {
138                # copy input file to fileout to exit it
139                $output = $input;
140                $output =~ s/$in_dir/$out_dir/gi;
141                # change .in to .out
142                $output =~ s/\.in/.out/gi;
143                # create backup file if output exists already
144                if( -e $output )
145                {
146                   $backup = $output;
147                   $backup =~ s/\.out/\.bak/gi;
148                   system( "cp $output $backup " );
149                }
150                # $output = "$out_dir"."$output";
151                system "nice -n 5 $exe < $input  > $output ";
152                printf( ioLOG "$input going to $output \n" );
153                ++$nComputed;
154        }
155        ++$nModTotal;
156}
157
158printf( ioLOG "$nComputed sims were run\n");
159# look for errors
160check_output();
161
162# send mail announcing results,
163# if no problem occur then also execute last_good.pl, copying files to last_good directory
164send_mail();
165
166#if this is the last run of the group, check for errors
167if( $nrun == $LAST )
168{
169   # look for errors
170   system( "perl checkall.pl" );
171   # does errors exist and have non-zero size?
172   if( -s "serious.txt" )
173   {
174      # this branck - problems
175      system("c:\\u\\blat\\blat.exe serious.txt -t gary\@pa.uky.edu -s \"last Cloudy slow run completed and errors existed\" " );
176   }
177   else
178   {
179      $script_dir = "$c:/projects/cloudy/trunk/scripts/";
180      system( "perl \"$script_dir\"promote_last_good_slow.pl" );
181
182      open( ioEMAIL , ">message.txt" );
183      printf( ioEMAIL " Last Cloudy slow run completed and no errors found\n"); 
184      close( ioEMAIL );
185      system("c:\\u\\blat\\blat.exe message.txt -t gary\@pa.uky.edu -s \"last Cloudy slow run finished and all are successfull\" " );
186   }
187}
188
189exit(0);
190
191
192#=============================================================
193#             send_mail(),
194#=============================================================
195
196sub send_mail
197{
198
199
200        # does errors exist and have non-zero size?
201        if( -s "$errors" )
202        {
203                system("c:\\u\\blat\\blat.exe $errors -t gary\@pa.uky.edu -s \"Cloudy slow run dayslow$nrun had errors\" " );
204        }
205        else
206        {
207                 open( ioEMAIL , ">message.txt" );
208     
209                 printf( ioEMAIL " Cloudy slow run dayslow$nrun ran OK on PC\n"); 
210                 printf( ioEMAIL " no crashes or asserts\r\n" ) ;
211                 close( ioEMAIL );
212                system("c:\\u\\blat\\blat.exe message.txt -t gary\@pa.uky.edu -s \"Cloudy slow run dayslow$nrun successfull\" " );
213
214        }
215
216        # now check for problems that occurred
217        if( -s "$problem_file" )
218        {
219                system("c:\\u\\blat\\blat.exe problems.txt -t gary\@pa.uky.edu -s \"Cloudy slow run dayslow$nrun PROBLEM or DEBUG string\" " );
220        }
221 }
222
223
224#===========================================================
225#          check_output()
226#===========================================================
227sub check_output
228{
229
230        #find "BOTCH " and "W-" string in all the output file and write
231        #corresponding line into messages file.
232        if( $lgLOGGING )
233        {
234                printf( ioLOG "check_output entered\n");
235        }
236
237        # check  output file to see whether they contain "Cloudy ends:"
238        # string and write corresponding line into checkend.txt file.
239        # if size of file $out_dir/checkend.txt is zero, then program crashed. 
240
241        $checkend = "$out_dir"."checkend.txt";
242        # search for PROBLEM in any file
243        if( -e $problem_file )
244        {
245           unlink( $problem_file );
246        }
247        if( -e $errors )
248        {
249           unlink( $errors );
250        }
251
252        # counter for total number of sims in directory
253        $nModTotal = 0;
254        while( defined( $input = glob("$in_dir*.in") ) )
255        {
256           if( $nModTotal >= $nSkip && $nModTotal < $nmod_calc )
257           {
258              # form name of output file
259              # change input dir name to output
260              $output = $input;
261              $output =~ s/$in_dir/$out_dir/gi;
262              # change .in to .out
263              $output =~ s/\.in/.out/gi;
264
265              system "grep -H Botch  $output >>$errors";
266              system "grep -H \"W-\"  $output >> $errors";
267              # check whether it crashed
268              system "grep -H \"ChkAssert\"  $output > $checkend ";
269              # check whether output file exists and has zero size (string did not occur)
270              if(-z "$checkend")
271              {
272                 system( "echo \"$output did not end or had no asserts\" >> $errors " );     
273              }
274              # find all PROBLEMs
275              system( "grep -H \"PROBLEM\"  $output > $problem_file" );
276              # now look for debug print strings and cat to end
277              system( "grep -H \"DEBUG\"  $output >> $problem_file" );
278           }
279           ++$nModTotal;
280        }
281
282         # check whether any models were skipped because they were renamed *.skip
283         system "ls \"$out_dir*.skip\" > skip.txt" ;
284         # skipfile will have non-zero length if *.skip returned any names
285         if( -s "skip.txt" )
286         {
287            print STDERR "\n\n some files were skipped by renmaing to .skip - list is in skip.txt\n" ;
288            system "echo some files were skipped by renmaing to .skip - list is in skip.txt >> checkall.txt ";
289         }
290
291        if( $lgLOGGING )
292        {
293                printf( ioLOG "check_output exits\n");
294        }
295
296}
Note: See TracBrowser for help on using the browser.