Fixed $PRIOR support and bugfix in shrinkage results handling
[PsN.git] / bin / pind
blob63e26357283ea8d64e47cfc24f6fb56c6284578e
1 #!/usr/bin/perl
3 use FindBin qw($Bin);
4 use lib "$Bin/../lib";
6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
9 use PsN;
10 use model;
11 use tool::pind;
12 use strict;
13 use debug;
14 use Getopt::Long;
15 use common_options;
17 my $cmd_line = $0 . " " . join( " ", @ARGV );
19 ## Configure the command line parsing
20 Getopt::Long::config("auto_abbrev");
22 my %options;
23 ## Declare the options
25 my %required_options;
27 my %optional_options = ("lst:s"=>'',
28 "ind_param:s"=>''
31 my $res = GetOptions( \%options,
32 @common_options::get_opt_strings,
33 keys(%required_options),
34 keys(%optional_options) );
35 exit unless $res;
37 common_options::set_globals( \%options, 'pind' );
38 common_options::get_defaults( \%options, 'pind' );
39 common_options::sanity_checks( \%options, 'pind' );
41 my %help_text;
43 $help_text{Pre_help_message} = <<'EOF';
44 pind
46 Perl script for individual probabilities.
48 Usage:
49 EOF
51 $help_text{Options} = <<'EOF';
52 Options:
54 The options are given here in their long form. Any option may be
55 abbreviated to any nonconflicting prefix. The -threads option
56 may be abbreviated to -t(or even -thr) but -debug may not be
57 abbreviated to -d because it conflicts with -debug_packages and
58 -debug_subroutines.
60 The following options are valid:
61 EOF
63 $help_text{-h} = <<'EOF';
64 -h | -?
66 With -h or -? pind will print a list of options and exit.
67 EOF
69 $help_text{-help} = <<'EOF';
70 -help
72 With -help pind will print this, longer, help message.
73 EOF
75 $help_text{-lst_file} = <<'EOF';
76 -lst_file=<filename>
78 Optional, the lst-file from where to read initial parameter estimates.
79 Default is the same name as the model file but with .mod replaced with .lst.
80 EOF
82 $help_text{-ind_param} = <<'EOF';
83 -ind_param=eta|theta
85 Optional, default eta. The parameter to set in individual ofv model files.
86 Possibilities are eta or theta.
87 EOF
90 $help_text{Post_help_message} = <<'EOF';
91 Also see 'execute -help' for a description of common options.
92 EOF
94 common_options::online_help( 'pind', \%options, \%help_text, \%required_options, \%optional_options);
96 ## Check that we do have a model file
97 if ( scalar(@ARGV) < 1 ) {
98 print "A simulation model file must be specified. Use 'pind -h' for help.\n";
99 exit;
102 if( scalar(@ARGV) > 1 ){
103 print "PIND can only handle one modelfile, you listed: ",join(',',@ARGV),". Use 'pind -h' for help.\n";
104 exit;
107 my $lst_file;
108 if (defined $options{'lst_file'}){
109 $lst_file=$options{'lst_file'};
110 } else {
111 #assume modelfile ends with .mod
112 $lst_file = (substr ($ARGV[0],0,-3)).'lst'; #keep from beginning, skip last four characters
113 unless ( -e $lst_file ){
114 print "When option -lst_file is omitted, the name of the lst-file is assumed to be the same\n".
115 "as the modelfile except that the last three letters are lst. Cannot find file $lst_file.\n";
116 exit;
120 unless ( defined $options{'clean'} ){
121 # Clean may be changed by default
122 $options{'clean'} = 1;
125 my $eval_string = common_options::model_parameters(\%options);
127 my $model = model -> new ( eval( $eval_string ),
128 extra_output => ['fort.80'],
129 filename => $ARGV[0],
130 ignore_missing_output_files => 1 );
132 my $pind = tool::pind ->
133 new ( eval( $common_options::parameters ),
134 models => [$model],
135 lst_file => $lst_file,
136 ind_param => $options{'ind_param'}
140 open(CMD, ">", $pind -> directory . "/command.txt");
141 print CMD $cmd_line, "\n";
142 close(CMD);
144 $pind -> run;
146 open( TMP, ">", 'ofv.done' );
147 print TMP "1";
148 close( TMP );
151 #$pind -> prepare_results;
152 #$pind -> print_results;