Minor fixes in Makefile and psn.conf
[PsN.git] / bin / execute
blob4a330d3dc2bfc7465ce73aa2203a9e2befe37bf9
1 #!/usr/local/bin/perl
3 # Only for Development
4 use FindBin qw($Bin);
5 use lib "$Bin/../lib";
7 # Don't edit the line below, it must look exactly like this.
8 # Everything above this line will be replaced #
10 # Perl includes #
11 use strict;
12 use Getopt::Long;
13 # External modules #
14 use Math::Random;
15 # PsN includes #
16 use PsN;
17 use tool::modelfit;
18 use model;
19 use debug;
20 use common_options;
21 use ui;
23 my $cmd_line = $0 . " " . join( " ", @ARGV );
25 my %options;
27 my $res = GetOptions( \%options,
28 @common_options::get_opt_strings );
30 exit unless $res;
32 common_options::set_globals( \%options );
34 common_options::online_help('execute', \%options, undef,{},{});
36 if ( scalar( @ARGV ) < 1 ){
37 print "At least one model file must be specified. Use 'execute -h' for help.\n";
38 exit;
41 ui -> category( 'modelfit' );
43 random_set_seed_from_phrase( $options{'seed'} ) if ( defined $options{'seed'} );
45 ui -> category( 'modelfit' );
47 debug -> level( $options{'debug'} );
48 debug -> package( $options{'debug_package'} );
49 debug -> subroutine( $options{'debug_subroutine'} );
50 debug -> warn_with_trace( $options{'warn_with_trace'} );
52 my $models_array;
54 my $eval_string = common_options::model_parameters(\%options);
56 my @outputfiles;
57 if( $options{'outputfile'} ){
58 @outputfiles = split( /,/, $options{'outputfile'} );
61 foreach my $model_name ( @ARGV ){
62 my $outputfile = shift @outputfiles;
63 my $model = model -> new ( eval( $eval_string ),
64 outputfile => $outputfile,
65 filename => $model_name,
66 ignore_missing_output_files => 1 );
68 push( @{$models_array}, $model );
71 my $modelfit = tool::modelfit ->
72 new ( eval( $common_options::parameters ),
73 models => $models_array );
75 open(CMD, ">", $modelfit -> directory . "/command.txt");
76 print CMD $cmd_line, "\n";
77 close(CMD);
79 $modelfit -> run;
80 #$modelfit -> print_results;
82 print "Done\n";