Geant4 Cross Reference |
1 #!/usr/bin/perl 2 3 use Getopt::Std; 4 5 our $PreinitMacroDef = "preinit.mac"; 6 our $InitMacroDef = "init.mac"; 7 our $OverrideOpt = ""; 8 9 sub PrintUsage 10 { 11 print "Usage: [-p preinit_macro] [-m init_macro] [-r suffix] [-y] job_id\n"; 12 print "\tThis program will create a job script for starting a new "; 13 print "project\n\t\t<job_id>; the job script name will be prepended by "; 14 print "'cexmc_'\n\t\tand appended by '_<suffix>' if '-r' is specified\n"; 15 print "\tDefault preinit_macro is '$PreinitMacroDef', default init_macro "; 16 print "is '$InitMacroDef'\n"; 17 print "\tIf '-r' is specified then a project <job_id> will be read and a "; 18 print "new\n\t\tproject <job_id>_<suffix> will be started; preinit_macro\n"; 19 print "\t\tin this case will be ignored\n"; 20 print "\tUse '-y' to override existing project\n"; 21 } 22 23 sub VERSION_MESSAGE 24 { 25 PrintUsage; 26 exit 0; 27 } 28 29 getopts( "m:p:r:y" ); 30 31 unless ( $ARGV[ 0 ] ) 32 { 33 PrintUsage; 34 exit 1; 35 } 36 37 $opt_p ||= $PreinitMacroDef; 38 $opt_m ||= $InitMacroDef; 39 $opt_r &&= "_$opt_r"; 40 $OverrideOpt = "-y" if $opt_y; 41 42 open ( JOBFILE, "> cexmc_$ARGV[ 0 ]$opt_r.job" ) or die $!; 43 print JOBFILE "#!/bin/sh\n"; 44 print JOBFILE "CEXMC_PROJECTS_DIR=" . $ENV{ 'CEXMC_PROJECTS_DIR' } . "\n"; 45 print JOBFILE "PATH=" . $ENV{ 'PATH' } . "\n"; 46 print JOBFILE "LD_LIBRARY_PATH=" . $ENV{ 'LD_LIBRARY_PATH' } . "\n"; 47 if ( $opt_r ) 48 { 49 print JOBFILE "cexmc -m$opt_m $OverrideOpt -r$ARGV[ 0 ] "; 50 print JOBFILE "-w$ARGV[ 0 ]$opt_r\n"; 51 } 52 else 53 { 54 print JOBFILE "cexmc -p$opt_p -m$opt_m $OverrideOpt -w$ARGV[ 0 ]\n"; 55 } 56 57 close ( JOBFILE ) or die $!;