This file is indexed.

/usr/bin/mpiexec.lam is in lam-runtime 7.1.4-3.1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
#!/usr/bin/env perl

# Copyright (c) 2001-2004 The Trustees of Indiana University.  
#                         All rights reserved.
# Copyright (c) 1998-2001 University of Notre Dame. 
#                         All rights reserved.
# Copyright (c) 1994-1998 The Ohio State University.  
#                         All rights reserved.
# 
# This file is part of the LAM/MPI software package.  For license
# information, see the LICENSE file in the top level directory of the
# LAM/MPI source distribution.
# 
# $HEADER$
#
# Function:	- start an MPI application
#

use strict;
use warnings;
use File::Temp qw(tempfile tempdir);
use Data::Dumper;
use POSIX;

# Global variables

my $host_map;
my $as_fh;
my $as_fn = "";
my $host_arch_hash_created = 0;
my $mpirun_arg = "";
my %mpiexec_arg;
my $verbose_mode = "";
my $boot_flag = "-H";
my $debug_mode = "";
my $tv_mode = "";
my $ssi_args = "";
my $configfile = "";
my $lamboot_on = 0;
my $prefix_boot = 0;
my $prefix_path = "";
my $prefix_bin = "";
my $prefix_arg = "";
my $machinefile = "";
my $bootargs = "";
my $arg_index = 0;
my @local_args;
my $current_state = "";
my $booted_lam = 0;
my $pid;
my $child_waitpid_status;
my $lamhalt_timeout = 10;     # If lamhalt does not complete in 10 secs we 
                              # interrupt it and use lamwipe to lamhalt


# Specify signal handler for SIGINT, SIGTERM and SIGHUP

$SIG{INT} = \&sig_handler_INT;
$SIG{TERM} = \&sig_handler_TERM;
$SIG{HUP} = \&sig_handler_HUP;

# Parse global args

parse_global_args();
if ( $debug_mode ne "" )  {
    print "mpiexec: Global argument parsing done\n";
}


# lamboot if -machinefile or -boot specified 
# -machinefile specifies the host file to be passed to lamboot
# -boot indicates that we should lamboot however if -machinefile is
# not specified then no host file is passed to lamboot

if ( $lamboot_on == 1 ) {

# Cannot use system() as it does not propogate the signals to child
# process

# Cannot use backtics cause even though it propogates signal to child
# process we get runaway lamboot not sure why..

    if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
	print "mpiexec: Booting lam..\n";
    }
    $current_state = "lamboot";
    $booted_lam = 1;

    # Subroutine for fork-exec-waitpid (few) to fork-exec lamboot
    
    few();

    $current_state = "";
    undef ($pid);
    if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
	print "mpiexec: Lamboot Complete\n";
    }
} 

# Create hostname => node_no hash 
# This will print error and exit if "lamnodes"fail's 
# So when user had not lambooted before executing mpiexec and
# has not specified -machinefile then lamnodes will fail and we will
# print error and exit

create_host_node_hash();
if ( $debug_mode ne "" )  {
    print "mpiexec: Host-Node Number hash created\n";
}

# Create temp file for appschema (UNLINK makes sure file is deleted on exit
my $tmpdir;
if (exists($ENV{TMPDIR})) {
    $tmpdir = $ENV{TMPDIR};
} else {
    $tmpdir = "/tmp";
}
($as_fh, $as_fn) = tempfile($tmpdir . "/lam_appschema_XXXXXX");
if ( $debug_mode ne "" )  {
    print "mpiexec: Temporary file $as_fn created " . 
	   "(will be used as app schema file for mpirun)\n";
}

# Parse non global command line args

if ($configfile ne "") {
    if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
	print "mpiexec: Parsing config file $configfile \n";
    }
    parse_file($configfile);
} else { 
    @local_args = @ARGV[$arg_index .. $#ARGV];
    parse_arg(@local_args);
}

close($as_fh) || 
    mpiexec_die("Cannot close temp appshema file $as_fn!!!! $! \n");

# Execute mpirun

if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
    print "mpiexec: Launching MPI programs\n";
}
$current_state = "mpirun";

# Subroutine for fork-exec-waitpid (few) to fork-exec mpirun

few();

$current_state = "";
undef ($pid);
if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
    print "mpiexec: MPI program execution over..\n";
}

# Delete temp app cshema file we had created

if ( $debug_mode ne "" )  {
    print "mpiexec: deleting temprory file $as_fn\n";
}
unlink($as_fn) || 
    mpiexec_die("Cannot delete temp appshema file $as_fn!!!! $! \n");
$as_fn = "";

# lamhalt if we lambooted from within mpiexec

if ( $booted_lam == 1 ) {
    if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
	print "mpiexec: Performing Lamhalt\n";
    }

# Our own function which takes care of Ignoring signals SIGINT,
# SIGTERM and SIGHUP during lamhalt. Also has a timeout mechanism
# where in if lamhalt does not complete within specified number of
# seconds it interrupts lamhalt and runs lamwipe to cleanup LAM RTE

    my_lamhalt();
}

exit(0);



######################################################################
## Subroutines from here down
######################################################################


# Our die function

sub mpiexec_die {
    if ( $debug_mode ne "" )  {
	print "mpiexec: mpiexec_die called\n";
    }

    # Delete temp app cshema file we had created
    
    if ( $as_fn ne "" ) {
	if ( $debug_mode ne "" )  {
	    print "mpiexec: deleting temprory file $as_fn\n";
	}
	unlink($as_fn);
	$as_fn = "";
    }

    # lamhalt if we lambooted from within mpiexec
    
    if ( $booted_lam == 1 ) {
        
# Our own function which takes care of Ignoring signals SIGINT,
# SIGTERM and SIGHUP during lamhalt. Also has a timeout mechanism
# where in if lamhalt does not complete within specified number of
# seconds it interrupts lamhalt and runs lamwipe to cleanup LAM RTE
	
	my_lamhalt();
    }
    
    die(@_);
}


# Signal Handlers

# SIGINT signal handler

sub sig_handler_INT {
    
    # Reinstall sighandler

    $SIG{INT} = \&sig_handler_INT;
    
    if ( $debug_mode ne "" )  {
	print "mpiexec: inside SIGINT handler\n";
    }

    # parent forwards the signal to fork-exec'ed lamboot process
    
    if ( ( $current_state ne "" ) && ( $pid ) ) {
	print "sending sig_INT to $current_state \n";
	kill INT => $pid;
	waitpid($pid, 0);
	
        # Handle waitpid status
	
	$child_waitpid_status = $?;
	handle_waitpid_status( $child_waitpid_status, $current_state );

    }
    
    # call generic signal handler

    sig_handler();

}


# SIGTERM signal handler

sub sig_handler_TERM {
    
    # Reinstall sighandler

    $SIG{TERM} = \&sig_handler_TERM;
    
    if ( $debug_mode ne "" )  {
	print "mpiexec: inside SIGTERM handler\n";
    }

    # parent forwards the signal to fork-exec'ed lamboot process
    
    if ( ( $current_state ne "" ) && ( $pid ) ) {
	kill TERM => $pid;
	waitpid($pid, 0);

        # Handle waitpid status
	
	$child_waitpid_status = $?;
	handle_waitpid_status( $child_waitpid_status, $current_state );

    }
    
    # call generic signal handler

    sig_handler();

}


# SIGHUP signal handler

sub sig_handler_HUP {
    
    # Reinstall sighandler

    $SIG{HUP} = \&sig_handler_HUP;

    if ( $debug_mode ne "" )  {
	print "mpiexec: inside SIGHUP handler\n";
    }
    
    # parent forwards the signal to fork-exec'ed lamboot process
    
    if ( ( $current_state ne "" ) && ( $pid ) ) {
	kill HUP => $pid;
	waitpid($pid, 0);

        # Handle waitpid status
	
	handle_waitpid_status( $?, $current_state );

    }
    
    # call generic signal handler

    sig_handler();

}


# SIGALRM signal handler

sub sig_handler_ALRM { 

    # Reinstall sighandler

    $SIG{ALRM} = \&sig_handler_ALRM;

    if ( $debug_mode ne "" )  {
	print "mpiexec: inside SIGALRM handler\n";
    }

    die "timeout\n";

}; 


# generic signal handler
 
sub sig_handler {
    
    # MRC: This stuff will change !!!!!! 
    # We might just get rid of sig_handler and have sig_handler_* 
    # just call mpiexec_die
    
    mpiexec_die("\n");

}


# Handle waitpid status

sub handle_waitpid_status {

    my $waitpid_status = $_[0];
    my $wait_func = $_[1];
    my $p_exit_status;
    
    if ( $debug_mode ne "" )  {
	print "mpiexec: Inside handle_waitpid_status " . 
	    "Function: $wait_func, Error Status: $waitpid_status\n";
    }

    if ( WIFEXITED($waitpid_status) ) {
	if ( ( $p_exit_status = WEXITSTATUS($waitpid_status) ) > 0 ) {
	    mpiexec_die "$wait_func failed with exit status $p_exit_status\n";
	}
    } 
    if ( WIFSIGNALED($waitpid_status) ) {
	mpiexec_die "$wait_func was killed by signal " . 
	    WTERMSIG($waitpid_status) . "\n";
    }
}


# Parse global args 

sub parse_global_args { 

    # Check for the bozo case of no command line arguments

    if ($#ARGV == -1) {
        show_help();
        exit(0);
    }

    # look for -test flag as first arg .. this is internal flag used by
    # lam configure script to find if appropriate version of Perl is
    # available

    if ($ARGV[0] eq "-test") {
	exit(0);
    }

    # look for global args -v, -d, -machinefile, -boot, -boot-args
    # and, -configfile
    
    while ( defined($ARGV[$arg_index]) ) {
	if ($ARGV[$arg_index] eq "-v") {
	    $verbose_mode = "-v";
            $boot_flag = "";
	} elsif ($ARGV[$arg_index] eq "-d") {
	    $debug_mode = "-d";
            $boot_flag = "";
	} elsif ($ARGV[$arg_index] eq "-configfile") {
	    $configfile = $ARGV[++$arg_index];
	} elsif ($ARGV[$arg_index] eq "-machinefile") {
	    $machinefile = $ARGV[++$arg_index];
	    $lamboot_on = 1;
	} elsif ($ARGV[$arg_index] eq "-boot") {
	    $lamboot_on = 1;
	} elsif ($ARGV[$arg_index] eq "-prefix") {
	    $prefix_boot = 1;
	    $prefix_path = $ARGV[++$arg_index];
	    $prefix_bin = "$prefix_path/bin/";
	} elsif ($ARGV[$arg_index] eq "-boot-args") {
	    $bootargs = $ARGV[++$arg_index];
	    $lamboot_on = 1;
	} elsif ($ARGV[$arg_index] eq "-tv") {
	    $tv_mode = "-tv";
	} elsif ($ARGV[$arg_index] eq "-ssi") {
            $ssi_args = "$ssi_args -ssi " . $ARGV[++$arg_index] . " " . 
                "\"" . $ARGV[++$arg_index] . "\"";
	} elsif ($ARGV[$arg_index] eq "-h") {
	    show_help();
	    exit(0);
	} else {
	    return;
	}
	$arg_index++;
    }

}


# Create hostname => node_no hash

sub create_host_node_hash {
    my $first = 1;
    my $line;
    my $node_number;
    my $hostname;

    open (NODELIST, $prefix_bin."lamnodes 2>&1 |") || 
	mpiexec_die("Cannot run Lamnodes! $!\n",
		    "Check if you had booted lam before calling mpiexec ",
		    "else pass -machinefile to mpiexec\n");
    while ($line = <NODELIST>) {
	chomp($line);
	if ( $first && ($line =~ /^-----------/) ) {
	    close(NODELIST);
	    mpiexec_die("Lamnodes Failed!\n",
			"Check if you had booted lam before calling mpiexec ",
			"else use -machinefile to pass host file to mpiexec",
			"\n");
	}
	$first = 0;
	($node_number, $hostname) = ($line =~ /^(.*?)\s+(.*?):/);
	$host_map->{$hostname}->{"lamnode"} = $node_number;
    }
    close(NODELIST);
}


# Create hostname => archtype hash

sub create_host_arch_hash {
    my $line;
    my $hostname;
    my $bogus;
    my $archtype;

    open (CMD, "lamexec N laminfo -arch -parsable -hostname |") ||
	mpiexec_die("Cannot run lamexec! \n");
    while ($line = <CMD>) {
	chomp($line);
	($hostname, $bogus, $archtype) = split(/:/, $line);
	$host_map->{$hostname}->{"arch"} = $archtype;
    }
    close(CMD);
    if ( $debug_mode ne "" )  {
	print "mpiexec: Here is hostname => (Node Number, Architecture) " .
	    "mapping\n";
	print Dumper($host_map);
    }
    $host_arch_hash_created = 1;
}


# Parse command line args

sub parse_arg {
    my (@my_ARGV) = @_; 
    my $i;
    my $arg;
    my $unrecognized_arg = 0;

    $i = 0;
    $arg = $my_ARGV[$i];

    while ($i <= $#my_ARGV) {
	if ( (! $unrecognized_arg ) && ($arg eq "-n") ) {
	    mpiexec_die("mpiexec arg -n cannot be used twice within same ",
			"context \n") 
		if ( defined($mpiexec_arg{"n"}) );
	    $mpiexec_arg{"n"} = $my_ARGV[++$i];
	} elsif ( (! $unrecognized_arg ) && ($arg eq "-host") ) {
	    mpiexec_die("mpiexec arg -host cannot be used twice within same ",
			"context \n") 
		if ( defined($mpiexec_arg{"host"}) );
	    $mpiexec_arg{"host"} = $my_ARGV[++$i];
	} elsif ( (! $unrecognized_arg ) && ($arg eq "-arch") ) {
	    mpiexec_die("mpiexec arg -arch cannot be used twice within same ",
			"context \n") 
		if ( defined($mpiexec_arg{"arch"}) );
	    $mpiexec_arg{"arch"} = $my_ARGV[++$i];
	} elsif ( (! $unrecognized_arg ) && ($arg eq "-wdir") ) {
	    mpiexec_die("mpiexec arg -wdir cannot be used twice within same ",
			"context \n") 
		if ( defined($mpiexec_arg{"wdir"}) );
	    $mpiexec_arg{"wdir"} = $my_ARGV[++$i];
	} elsif ( (! $unrecognized_arg ) && ($arg eq "-soft") ) {
	    $mpiexec_arg{"soft"} = $my_ARGV[++$i];
	} elsif ( (! $unrecognized_arg ) && ($arg eq "-path") ) {
	    $mpiexec_arg{"path"} = $my_ARGV[++$i];
	} elsif ( (! $unrecognized_arg ) && ($arg eq "-file") ) {
	    $mpiexec_arg{"file"} = $my_ARGV[++$i];
	} elsif ($arg eq ":") {
	    $arg = $my_ARGV[$i+1];
	    if (! defined($arg)) {
		mpiexec_die("Error in parsing line :\n",
			    join(" ", @my_ARGV), 
			    "\nYou cannot have : at end of line\n");
	    }

	    #write a line in appschema

	    app_schema_insert();

	    # Free up (empty) %mpiexec_arg and $mpirun_arg

	    undef %mpiexec_arg;
	    undef $mpirun_arg;
	    $mpirun_arg = "";
	    $unrecognized_arg = 0;
	} else {

	    # arg not recognized by mpiexec... so assume its mpirun arg

	    $unrecognized_arg = 1;
	    $mpirun_arg = $mpirun_arg . $arg . " ";
	}
	$arg = $my_ARGV[++$i];
    }
    
    # write a line in appschema

    app_schema_insert();

    # Free up (empty) %mpiexec_arg and $mpirun_arg

    undef %mpiexec_arg;
    undef $mpirun_arg;
    $mpirun_arg = "";
}


# Parse configfile

sub parse_file {
    my $temp_line;
    my @temp_argv;
    my $line_continued = 0;
    my $prev_line = "";

    # Open config file for reading

    open (CONF_FILE, "$_[0]") || 
	mpiexec_die("Cannot open config file $_[0] : $!\n");
    
    while ($temp_line = <CONF_FILE>) {

	# ignore commented lines in configfile

	if ($temp_line =~ /^\s*#/) {
	    next; 
	}

	# If previous line is being continued..

	if ($line_continued) {
	    $temp_line = $prev_line . $temp_line;
	    $prev_line = "";
	    $line_continued = 0;
	}

	# check if this line will be continued..

	if ($temp_line =~ /\\$/) {
	    $temp_line =~ s/\\$//;
	    $prev_line = $temp_line;
	    chomp($prev_line);
	    $line_continued = 1;
	    next;
	}
	chomp($temp_line);
	@temp_argv = split(/\s+/, $temp_line);
	parse_arg(@temp_argv);
    }
    
    close (CONF_FILE) || 
	mpiexec_die("Cannot close config file $_[0] : $!\n");

}


# Write a line in appschema file

sub app_schema_insert {
    my $found = 0;
    my $host;

    # if -host was specified we need to convert it to <where> option
    # for appschema

    if ($mpiexec_arg{"host"}) {

	if ($host_map->{$mpiexec_arg{"host"}}) {
	    print $as_fh $host_map->{$mpiexec_arg{"host"}}->{"lamnode"}
	    , " ";
	} else {
	    mpiexec_die "Invalid hostname " . $mpiexec_arg{"host"} .
		" specified\n";
	}
    }

    # if -arch was specified we need to convert it to <where> option
    # for appschema

    if ($mpiexec_arg{"arch"}) {
	if (! $host_arch_hash_created) {
	    create_host_arch_hash();
	}

	foreach $host ( keys( %{$host_map} ) ) {
	    if ($host_map->{$host}->{"arch"} =~ /$mpiexec_arg{"arch"}/) { 
		print $as_fh $host_map->{$host}->{"lamnode"} . " "; 
		$found = 1; 
	    } 
	} 
	
	if (! $found) { 
	    mpiexec_die("mpiexec didnt find any node with -arch = ",
			$mpiexec_arg{"arch"}, " \n");
	} 
    }

    # if -n was specified we need to convert it to -np option for appschema

    if ($mpiexec_arg{"n"}) {
	print $as_fh "-np " . $mpiexec_arg{"n"} . " ";
    }

    # if -wdir was specified we need to convert it to -wd option for
    # appschema

    if ($mpiexec_arg{"wdir"}) {
	print $as_fh "-wd " . $mpiexec_arg{"wdir"} . " ";
    }

    # if -file was specified we need to print warning that it was
    # ignored

    if ($mpiexec_arg{"file"}) {
	print "Warning!!! \"-file " . $mpiexec_arg{"file"} . 
	    "\" was ignored by mpiexec\n";
    }
    
    # stuff we don't handle yet
    
    if ( $mpiexec_arg{"soft"} || $mpiexec_arg{"path"} ) {
	mpiexec_die "mpiexec's -soft and -path arguments are not ",
	"currently supported \n";
    }
    
    # Finish the line

    print $as_fh $mpirun_arg . "\n";
    
}


# Our own function which takes care of Ignoring signals SIGINT,
# SIGTERM and SIGHUP during lamhalt. Also has a timeout mechanism
# where in if lamhalt does not complete within specified number of
# seconds it interrupts lamhalt and runs lamwipe to cleanup LAM RTE

sub my_lamhalt {

    # ignore signals INT, TERM and HUP during lamhalt
	
    $SIG{INT} = 'IGNORE';
    $SIG{TERM} = 'IGNORE';
    $SIG{HUP} = 'IGNORE';
    
    $SIG{ALRM} = \&sig_handler_ALRM;

    # We have to use eval here because on timeout sig_handler_ALRM
    # gets invoked and calls die. eval forces output of die to go into
    # $@ instead of exiting the program with that error message.. kind
    # of try catch

    eval {
  	alarm ($lamhalt_timeout);
	system($prefix_bin."lamhalt $boot_flag $verbose_mode $debug_mode") &&
	    die("Cannot lamhalt !!!! $! \n");
	alarm (0); # clear the still pending alarm
    };
    
    if ($@) {
	
	if ($@ =~ /timeout/) {
	    
	    # lamboot timed out.. so use lamwipe 
	    
	    if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
		print "mpiexec: Lamhalt operation timedout .. trying lamwipe\n";
	    }
	    system("lamwipe $verbose_mode $debug_mode $machinefile") &&
		die("Cannot lamwipe !!!! $! \n");
	    if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
		print "mpiexec: lamwipe completed\n";
	    }
	} 
	else {

	    # something else caused alarm
	    # propagate unexpected errors

	    alarm(0); # clear the still pending alarm
	    die "\n";

	}
    }	
    else { 

        # lamboot didn't time out
 	
	if ( ( $verbose_mode ne "" ) || ( $debug_mode ne "" ) ) {
	    print "mpiexec: Lamhalt complete\n";
	}
    }
    $booted_lam = 0;
    
    # reinstall signal handlers for signals INT, TERM and HUP
    
    $SIG{INT} = \&sig_handler_INT;
    $SIG{TERM} = \&sig_handler_TERM;
    $SIG{HUP} = \&sig_handler_HUP;

}


# Subroutine for fork-exec-waitpid (few)

sub few {

    if ($pid = fork) {
	waitpid($pid, 0);
	
	# check exit status of child process
	
	$child_waitpid_status = $?;
	handle_waitpid_status( $child_waitpid_status, $current_state );
	
    } else {
	die "Cannot fork: $!\n" 
	    unless defined $pid;
	
	# exec lamboot

	if ( $current_state eq "lamboot" ) {
	    if ( $prefix_boot == 1) {
		$prefix_arg = "-prefix $prefix_path";
	    } 
            if ( $verbose_mode ne "" ) {
                print "Running: " . "lamboot $boot_flag $verbose_mode $debug_mode $bootargs $ssi_args $prefix_arg $machinefile";
            }
	    exec("lamboot $boot_flag $verbose_mode $debug_mode $bootargs $prefix_arg $machinefile") 
		|| die "mpiexec cannot exec lamboot $machinefile: $!\n"; 
	}

	# exec mpirun

	if ( $current_state eq "mpirun" ) {
            if ( $verbose_mode ne "" ) {
                print "Running: " . $prefix_bin."mpirun $ssi_args $verbose_mode $tv_mode $as_fn";
            }
	    exec($prefix_bin."mpirun $ssi_args $verbose_mode $tv_mode $as_fn") ||
		mpiexec_die("mpiexec cannot exec mpirun: $!\n"); 
	}
    }
}


# Help message

sub show_help {
    print "-----------------------------------------------------------------------------
Synopsis:       mpiexec [global_args] local_args1 [: local_args2 [...]]
                mpiexec [global_args] -configfile <filename>

Description:    Run MPI programs on LAM nodes.

Global arguments:
   -h                  This message
   -boot               Boot the LAM universe before running
   -boot-args <args>   Pass <args> to the booting agent
   -d                  Lots of debugging output
   -machinefile <file> Use boot schema <filename> to boot the LAM universe
   -prefix <lam/install/path>
                       Use the LAM installation specified in </lam/install/path/>
   -ssi <key> <value>  Set SSI parameter <key> to value <value>
   -tv                 Launch MPI process under the TotalView debugger
   -v                  Be verbose

Local arguments:
   -n <numprocs>       Specify how many processes to start
   -host <hostname>    Launch on a specific hostname
   -arch <arch>        Launch on a specific architecture type
   -wdir <dir>         Set working directory
   <other_arguments>   Passed back to the MPI executable
-----------------------------------------------------------------------------\n";
}