Added initial SGE support
[PsN.git] / lib / common_options.pm
blobea7e927b387e3786879301acc21d5cb0da86e041
1 package common_options;
3 use FindBin qw($Bin);
4 use lib "$Bin/../lib";
5 use Getopt::Long;
6 use Text::Wrap;
8 ## Configure the command line parsing
9 Getopt::Long::config("auto_abbrev");
11 my @tool_options = ( "abort_on_fail",
12 "adaptive!",
13 "clean:i",
14 "compress",
15 "condition_number_limit:f",
16 "correlation_limit:f",
17 # "cpu_time:i",
18 "directory:s",
19 "drop_dropped",
20 "expected_run_time",
21 # "eigen_values",
22 # "grid_batch_size:i",
23 # "grid_poll_interval:i",
24 "handle_maxevals",
25 "large_theta_cv_limit:f",
26 "large_omega_cv_limit:f",
27 "large_sigma_cv_limit:f",
28 "lsf_job_name:s",
29 "lsf_options:s",
30 "lsf_project_name:s",
31 "lsf_queue:s",
32 "lsf_resources:s",
33 "lsf_ttl:s",
34 "min_retries:i",
35 "missing_data_token:s",
36 "near_bound_sign_digits:i",
37 "near_zero_boundary_limit:f",
38 "nice:i",
39 "nm_version:s",
40 "nm_directory:s",
41 "no_remote_compile",
42 "no_remote_execution",
43 "nonparametric_etas",
44 "nonparametric_marginals",
45 "picky",
46 "quick_summarize|quick_summary",
47 # "remove_temp_files",
48 "rerun:i",
49 # "results_file:s",
50 "retries:i",
51 # "run_on_nordugrid",
52 "run_on_lsf",
53 "run_on_ud",
54 "run_on_umbrella",
55 "run_on_sge",
56 "seed:s",
57 "shrinkage",
58 "significant_digits_rerun:f",
59 "sign_digits_off_diagonals:i",
60 "summarize|summary",
61 "threads:i",
62 "tweak_inits:i",
63 "umbrella_timeout",
64 "ud_native_retrieve",
65 "ud_sleep:i",
66 "verbose!",
67 "wrap_data",
68 "near_bound_sign_digits:i",
69 "near_zero_boundary_limit:f",
70 "sign_digits_off_diagonals:i",
71 "large_theta_cv_limit:f",
72 "large_omega_cv_limit:f",
73 "large_sigma_cv_limit:f",
74 "confidence_level:f",
75 "precision:i",
79 my @model_options = ("extra_data_files:s@",
80 "extra_files:s",
81 "extra_output:s",
82 "sde",
83 "compute_cwres",
84 "outputfile:s",
85 "nm_version:s",
88 my @script_options = ( "debug:i",
89 "debug_package:s",
90 "debug_subroutine:s",
91 "h|?",
92 "help",
93 "html_help",
94 "project:s",
95 "silent",
96 # "submit_self",
97 "user:s",
98 "warn_with_trace:i"
101 @get_opt_strings = (sort(@tool_options), sort(@model_options), sort(@script_options));
103 sub options_to_parameters {
104 my $opts = shift;
105 my @options = @{$opts};
107 my $parameter_string = '( ';
109 foreach my $opt ( @options ){
110 $opt =~ s/[!:|].*//g;
111 $parameter_string .= "$opt => \$options{'$opt'},\n";
113 $parameter_string .= ' )';
114 return $parameter_string;
117 $parameters = options_to_parameters([@tool_options,'top_tool']);
120 @extra_files;
121 @extra_output;
123 sub set_globals {
124 my $opts = shift;
125 my %options = %{$opts};
126 if ( $PsN::config -> {'_'} -> {'use_database'} ) {
128 $PsN::config -> {'_'} -> {'project'} =
129 defined $options{'project'} ? $options{'project'} :
130 $PsN::config -> {'_'} -> {'default_project'};
131 $PsN::config -> {'_'} -> {'user'} =
132 defined $options{'user'} ? $options{'user'} :
133 $PsN::config -> {'_'} -> {'default_user'};
134 print "Using database ".$PsN::config -> {'_'} -> {'project'}."\n";
135 if ( defined $options{'password'} ) {
136 $PsN::config -> {'_'} -> {'password'} = $options{'password'};
137 } elsif( defined $PsN::config -> {'_'} -> {'default_password'} ) {
138 $PsN::config -> {'_'} -> {'password'} =
139 $PsN::config -> {'_'} -> {'default_password'};
140 } else {
141 system( "stty -echo" );
142 print "Database password for ".$PsN::config -> {'_'} -> {'user'}.": ";
143 my $word;
144 chomp($word = <STDIN>);
145 print "\n";
146 system( "stty echo" );
147 $PsN::config -> {'_'} -> {'password'} = $word;
152 sub get_defaults {
153 my $options = shift;
154 my $tool = shift;
155 foreach my $default_option ( keys %{$PsN::config -> {'default_'.$tool.'_options'}} ){
156 unless( exists $options -> {$default_option} ){
157 $options -> {$default_option} = $PsN::config -> {'default_'.$tool.'_options'} -> {$default_option};
163 foreach my $default_option ( keys %{$PsN::config -> {'default_options'}} ){
164 unless( exists $options -> {$default_option} ){
165 $options -> {$default_option} = $PsN::config -> {'default_options'} -> {$default_option};
169 $options -> {'top_tool'} = 1;
172 sub print_help {
173 my( $command, $required, $optional ) = @_;
174 my %is_required;
175 my %all_options = (%{$required},%{$optional});
177 foreach my $req( keys %{$required} ){
178 $is_required{$req} = 1;
181 my $option_help;
183 $option_help .= "[ -h | -? ] [ --help ]\n\t" . ' ' x (1+length($command));
185 my @loop_array;
186 if( $command eq 'execute' ){
187 @loop_array = sort(@get_opt_strings);
188 } else {
189 @loop_array = (sort(keys %{$required}), sort(keys %{$optional}));
192 foreach my $help( @loop_array ) {
193 next if( $help eq 'help' or $help eq 'h|?' );
194 unless( $is_required{$help} ){
195 $option_help .= "[ ";
196 } else {
197 $option_help .= " ";
199 if( $all_options{$help} ne '' ){
200 $help =~ /^([^:]+)/;
201 $option_help .= "--$1=\'" . $all_options{$help} . "\'";
202 } elsif( $help =~ /(.+):s/ ){
203 $option_help .= "--$1=\'string\'";
204 } elsif( $help =~ /(.+):i/ ){
205 $option_help .= "--$1=\'integer\'";
206 } elsif( $help =~ /(.+):f/ ){
207 $option_help .= "--$1=\'number\'";
208 } elsif( $help =~ /(.+):(\d)/ ){
209 $option_help .= "--$1=$2";
210 } elsif( $help =~ /(.+)[^:]$/ ){
211 $option_help .= "--$help";
213 unless( $is_required{$help} ){
214 $option_help .= " ]";
216 $option_help .= "\n\t".' ' x (1+length($command));
219 return $option_help;
222 sub model_parameters {
223 my $options = shift;
224 #my %options = %{$opt};
226 if( defined $options -> {'extra_data_files'} ){
227 for( my $i=0; $i < scalar(@{$options -> {'extra_data_files'}}) ; $i++ ){
228 my @arr = split( /,/ , @{$options -> {'extra_data_files'}}[$i] );
229 if( @arr < 2 ){
230 die "extra_data_file must be of form: \"filename, head1, head2\"\n" ;
233 @{$options -> {'extra_data_files'}}[$i] = $arr[0];
234 my @subarray = @arr[1..$#arr];
235 push( @{$options -> {'extra_data_headers'}}, \@subarray )
239 push(@model_options, 'extra_data_headers');
241 if( defined $options -> {'extra_files'} ){
242 my @array = split( /,/ , $options -> {'extra_files'} );
243 $options -> {'extra_files'} = \@array;
246 if( defined $options -> {'extra_output'} ){
247 my @array = split( /,/ , $options -> {'extra_output'} );
248 $options -> {'extra_output'} = \@array;
251 return options_to_parameters(\@model_options);
256 sub online_help {
258 my $command = shift;
259 my $opts = shift;
260 my $help_text = shift;
261 my $required_options = shift;
262 my $optional_options = shift;
263 my %options = %{$opts};
265 my %help_hash;
267 $help_hash{Pre_help_message} = << 'EOF';
268 <h3 class="heading1">execute</h3>
270 Perl script running one or more modelfiles using PsN.
272 <h3 class="heading1">Usage:</h3>
275 $help_hash{Description} = <<'EOF';
276 <h3 class="heading1">Description:</h3>
278 The execute utility is a Perl script that allows you to run multiple
279 modelfiles either sequentially or in parallel. It is more or less an
280 nmfe replacement.
281 <br><br>
282 The execute utility creates subdirectories where it puts NONMEMs
283 input and output files, to make sure that parallel NONMEM runs do not
284 interfere with each other. The top directory is by default named
285 'modelfit_dirX' where 'X' is a number that starts at 0 and is
286 increased by one each time you run the execute utility.
287 <br><br>
288 When the NONMEM runs are finished, the output and table files will be
289 copied to the directory where execute started in which means that you
290 can normaly ignore the 'modelfit_dirX' directory. If you need to
291 access any special files you can find them inside the
292 'modelfit_dirX'. Inside the 'modelfit_dirX' you find a few
293 subdirectories named 'NM_runY'. For each model file you
294 specified on the command line there will be one 'NM_runY' directory in
295 which the actual NONMEM execution takes place. The order of the
296 'NM_runY' directories corresponds to the order of the modelfiles given
297 on the command line. The first run will take place inside 'NM_run1',
298 the second in 'NM_run2' and so on.
301 $help_hash{Examples} = <<'EOF';
302 <h3 class="heading1">Example:</h3>
304 <p align="justify" class="style2">$ execute pheno.mod </p>
306 <p align="justify">Runs one model file and accepts all default values.</p>
308 <p align="justify" class="style2">$ execute -threads=2 -retries=5 phenobarbital.mod pheno_alternate.mod</p>
310 <p align="justify">Runs two model files in parallel using 5 possible retries.</>p
313 $help_hash{Options} = <<'EOF';
314 <h3 class="heading1">Options:</h3>
316 The options are given here in their long form. Any option may be
317 abbreviated to any nonconflicting prefix. The <span class="style2">-threads</span> option may
318 be abbreviated to <span class="style2">-t</span> (or even <span class="style2">-thr</span>) but <span class="style2">-debug</span> may not be
319 abbreviated to <span class="style2">-d</span> because it conflicts with <span class="style2">-debug_packages</span> and
320 <span class="style2">-debug_subroutines</span>.
321 <br><br>
322 The following options are valid:
325 $help_hash{'-?'} = <<'EOF';
326 <p class="style2">-h | -?</p>
328 With <span class="style2">-h</span> or <span class="style2">-?</span> execute.pl prints the list of available options
329 and exit.
332 $help_hash{-help} = <<'EOF';
333 <p class="style2">-help</p>
335 With <span class="style2">-help</span> execute will print a longer help message.
338 $help_hash{-nm_version} = <<'EOF';
339 <p class="style2">-nm_version='integer'</p>
341 If you have more than one installation of NONMEM you can choose
342 between them using the <span class="style2">-nm_version</span> option. The installations must be
343 specified in the psn.conf file. The default value is 5.
346 $help_hash{-threads} = <<'EOF';
347 <p class="style2">-threads='integer'</p>
349 Use the threads option to enable parallel execution of multiple
350 NONMEM runs. On a desktop computer it is recommended to set
351 <span class="style2">-threads</span> to the number of CPUs in the system plus one. You can
352 specify more threads, but it will probably not increase the
353 performance. If you are running on a computer cluster, you should
354 consult your systems administrator to find out how many threads
355 you can specify. The <span class="style2">-threads</span> option will be ignored if you run on
356 a grid system, since gridshave ther own scheduling algoritms. The
357 default value for the <span class="style2">-threads</span> option is 1.
360 $help_hash{-nice} = <<'EOF';
361 <p class="style2">-nice='integer'</p>
363 This option only has effect on unix like operating systems. It
364 sets the priority (or nice value) on a process. You can give any
365 value that is legal for the "nice" command, likely it is between 0
366 and 19, where 0 is the highest priority. Check "man nice" for
367 details.
370 $help_hash{-directory} = <<'EOF';
371 <p class="style2">-directory='string'</p>
373 The directory option sets the directory in which execute will run
374 NONMEM. The default directory name is 'modelfit_dirX' where X will
375 be increased by one each time you run the execute utility. You do
376 not have to create the directory, it will be done for you.
378 If you abort execute or if your system crashes you can use the
379 '<span class="style2">-directory</span>' option set to the directory of the execute run that
380 crashed. Execute will then not run the modelfiles that had
381 finished before the crash, thereby saving some time. Notice that
382 is important that you give exactly the same options that you gave
383 the first time.
386 $help_hash{-drop_dropped} = <<'EOF';
387 <p class="style2">-drop_dropped</p>
389 If there are drop columns in your control file and <span class="style2">-drop_dropped</span>
390 is used, PsN will remove those columns from the data set used
391 internally. It saves both diskspace and conserves memory
392 usage. Note that PsN does NOT alter your original data set, only
393 those used internally in PsN.
396 $help_hash{-extra_data_files} = <<'EOF';
397 <p class="style2">-extra_data_files='extra_data1.dta, COLUMN1, COLUMN2'</p>
399 NONMEM only allows 20 column datasets, but PsN can add code to
400 control files that reads extra data columns from a separate
401 file. To use this feature you must create a new data file which
402 has the same ID row as the main data file. Then you specify a
403 comma separated list with <span class="style2">-extra_data_files</span>. The first element
404 in the list is the filename and the rest of the list is the header
405 of the extra data file. You can have multiple extra files if neccesary.
408 $help_hash{-extra_files} = <<'EOF';
409 <p class="style2">-extra_files='extra_file1.dta, extra_file2.dta'</p>
411 If you need extra files in the directory where NONMEM is run you
412 specify them in list to the <span class="style2">-extra_files</span> list. It could for
413 example be fortran subroutines you need compiled with NONMEM.
416 $help_hash{-handle_maxevals} = <<'EOF';
417 <p class="style2">-handle_maxevals='number'</p>
419 NONMEM only allows 9999 function evaluations. PsN can expand this
420 limit by adding an MSFO option to $ESTIMATION, later when NONMEM
421 hits the max number of function evaluations(9999) PsN will remove
422 intial estimates from the modelfile and add $MSFI and restart
423 NONMEM. PsN will do this until the number of evaluations specified
424 with <span class="style2">-handle_maxevals</span> is reached.
427 $help_hash{-seed} = <<'EOF';
428 <p class="style2">-seed='string'</p>
430 If you use the <span class="style2">-retries='integer'</span> option, execute will use a
431 random number to create new intial estimates for the model
432 parameters. To make sure that the same result is produced if you
433 redo the same run, you can set your own random seed with the <span class="style2">-seed</span>
434 option.
438 $help_hash{'-summarize|summary'} = <<'EOF';
439 <p><span class="style2">-summarize</span> or <span class="style2">-summary</span></p>
441 <span class="style2">summarize</span> or <span class="style2">-summary</span> will do a set of diagnostics test
442 and print minimization message for each model run.
445 $help_hash{-verbose} = <<'EOF';
446 <p class="style2">-verbose</p>
448 With <span class="style2">verbose</span> set to 1, PsN will print
449 more details about NONMEM runs. More precisely PsN will print the
450 minimization message for each successfull run and a R:X for each
451 retry PsN makes of a failed run, where X is the run number.
454 $help_hash{-wrap_data} = <<'EOF';
455 <p class="style2">-wrap_data</p>
457 NONMEM only allows 20 column datasets, but it is possible to wrap
458 observation lines into multiple rows by adding a CONT column. With
459 <span class="style2">wrap_data</span> PsN does it automatically.
462 $help_hash{-lsf_job_name} = <<'EOF';
463 <p class="style2">-lsf_job_name='string'</p>
465 <span class="style2">lsf_job_name</span> sets the name of the LSF job name of every NONMEM run,
466 they all get the same name.
469 $help_hash{-lsf_options} = <<'EOF';
470 <p class="style2">-lsf_options='string'</p>
472 LSF jobs are submitted using bsub and all LSF related options are
473 translated to corresponding bsub options. For maximum flexibility
474 we allow any string to be passed as options to bsub, so if a specific
475 bsub feature not available through any ot the other -lsf_ options
476 is needed, use <span class="style2">lsf_options</span> to pass any option to bsub.
479 $help_hash{-lsf_project_name} = <<'EOF';
480 <p class="style2">-lsf_project_name='string'</p>
482 Use <span class="style2">lsf_project_name</span> to assign a
483 project name to your LSF runs.
486 $help_hash{-lsf_resources} = <<'EOF';
487 <p class="style2">-lsf_resources='string'</p>
489 <span class="style2">lsf_resources</span> specifies which LSF resources is required when submiting
490 NONMEM runs.
493 $help_hash{-lsf_ttl} = <<'EOF';
494 <p class="style2">-lsf_ttl='string'</p>
496 <span class="style2">lsf_ttl</span> sets the maximum time a NONMEM run should be allowed to run on
497 the LSF grid.
500 $help_hash{-lsf_queue} = <<'EOF';
501 <p class="style2">-lsf_queue='string'</p>
503 <span class="style2">lsf_queue</span> specifies which LSF queue PsN should submit NONMEM runs
504 to and is used in conjuction with <span class="style2">-run_on_lsf</span>
507 $help_hash{-min_retries} = <<'EOF';
508 <p class="style2">-min_retries='string'</p>
510 <span class="style2">min_retries</span> forces the PsN to try
511 several initial values for each estimate and selecting the best
512 one. The best model is chosen in the following maner: if <span class="style2">-picky</span>
513 is used the model must pass the picky test. Then the one with
514 highest number of significant digits and an ofv value no more than
515 five units above than the lowest ofv value among all models.
518 $help_hash{-remove_temp_files} = <<'EOF';
519 <p class="style2">-remove_temp_files</p>
521 If the <span class="style2">-remove_temp_files</span> option is set to 1, execute will remove
522 the 'FCON', 'FDATA', 'FREPORT', 'FSUBS', 'FSUBS.f', 'LINK.LNK',
523 'FSTREAM', 'PRDERR' and 'nonmem' files from the 'NM_runX'
524 directory. The default value is 0.
527 $help_hash{-clean} = <<'EOF';
528 <p class="style2">-clean</p>
530 If the <span class="style2">-clean</span>
531 option is set to 1, execute will remove the entire 'NM_runX'
532 directory after the NONMEM run is finished. The default value of
533 <span class="style2">-clean </span>is 0.
536 $help_hash{-missing_data_token} = <<'EOF';
537 <p class="style2">-missing_data_token='string'</p>
539 <span class="style2">missing_data_token</span> sets the string
540 that PsN accepts as missing data, default is -99.
543 $help_hash{-nm_directory} = <<'EOF';
544 <p class="style2">-nm_directory='string'</p>
546 The argument of <span class="style2">nm_directory</span> is
547 directory where NONMEM is installed. Normally its easiest to setup
548 a version in psn.conf and use <span class="style2">-nm_version</span> to access it.
551 $help_hash{-no_remote_compile} = <<'EOF';
552 <p class="style2">-no_remote_compile</p>
554 When running on LSF it is no guaranteed that NONMEM is available
555 on the computing node, then <span class="style2">-no_remote_compile</span> allows you to compile
556 NONMEM localy and only submit the NONMEM executable to the grid.
559 $help_hash{-no_remote_execution} = <<'EOF';
560 <p class="style2">-no_remote_execution</p>
562 <span class="style2">no_remote_execution</span> prohibits execution on the LSF grid. Used together
563 with <span class="style2">-no_remote_compile</span> it cancels out <span class="style2">-run_on_lsf</span>
566 $help_hash{-compress} = <<'EOF';
567 <p class="style2">-compress</p>
569 The execute utility will compress the contents of 'NM_runX' to the
570 file 'nonmem_files.tgz' if the <span class="style2">-compress</span> option is used and if you
571 have the archive and compress programs <strong>tar</strong> and <strong>gzip</strong> installed. If
572 you use the <span class="style2">-clean</span> options, run files will be
573 removed before the compression. The <span class="style2">-compress</span> option obviously has
574 no effect if you also use the <span class="style2">-clean</span> option.
577 $help_hash{-tweak_inits} = <<'EOF';
578 <p class="style2">-tweak_inits</p>
580 <!--/>If NONMEM terminates nonsuccessfully, PsN can perturb the initial
581 estimates and run NONMEM again. The generation of new initial
582 estimates init_i for the i:th retry are performed according to
584 init_i = init_0 + rand_uniform(+-0.1*i*init_0)
586 where init_0 are the initial estimates of the original run. The
587 updating procedure makes sure that boundary conditions on the
588 parameters are still valid. For this option to have effect, the
589 -retries option must be set to number larger than zero. The
590 default setting uses tweak_inits.<-->
591 <?php print '<p> If NONMEM terminates nonsuccessfully, PsN can perturb the initial estimates and run NONMEM again. The generation of new initial estimates <img src="images/init1.gif"> for the <em>i</em>:th retry are performed according to</p><p align="center"><img src="images/perturb1.gif" width="236" height="32"></p> <p>where <img src="images/init_orig1.gif" width="29" height="28"> are the initial estimates of the original run. The updating procedure makes sure that boundary conditions on the parameters are still valid. For this option to be valid, the <span class="style2">-retries</span> option must be set to a number larger than zero. The default setting uses tweak_inits. </p>'; ?>
594 $help_hash{-outputfile} = <<'EOF';
595 <p class="style2">-outputfile</p>
597 The <span class="style2">-outputfile</span> option specifies the output file name for the
598 NONMEM run. Currently This option is only valid when a single
599 model is supplied to the execute utility.
602 $help_hash{-picky} = <<'EOF';
603 <p class="style2">-picky</p>
605 The <span class="style2">-picky</span> option is only valid together with <span class="style2">-tweak_inits</span>.
606 Normally PsN only tries new initial estimates if
607 '<span class="style2">MINIMZATION SUCCESSFUL</span>' is not found in the NONMEM output
608 file. With the <span class="style2">-picky</span> option, PsN will regard any of the
609 following messages as a signal for rerunning:
610 <p class="style2">
611 0ESTIMATE OF THETA IS NEAR THE BOUNDARY<br>
612 0PARAMETER ESTIMATE IS NEAR ITS BOUNDARY<br>
613 0R MATRIX ALGORITHMICALLY SINGULAR<br>
614 0S MATRIX ALGORITHMICALLY SINGULAR</p>
617 $help_hash{'-quick_summarize|quick_summary'} = <<'EOF';
618 <p><span class="style2">-quick_summarize</span> or <span class="style2">-quick_summary</span></p>
620 If either of <span class="style2">quick_summarize</span> and <span class="style2">quick_summary</span> is used, PsN will print
621 the ofv value and minimization message for each NONMEM run.
624 $help_hash{-rerun} = <<'EOF';
625 <p class="style2">-rerun</p>
627 PsN can redo or resume a run using information in PsN run
628 directory(see documentation for <span class="style2">-directory</span>). It is called
629 a rerun. During a rerun PsN will consider to redo parts of
630 the run. With the <span class="style2">-rerun</span> option you can control which parts
631 will be redone. The default value of <span class="style2">-rerun</span> is 1.
632 With rerun set to 1 PsN will rerun any model with a missing
633 list file. Notice that every "retry" (see the documentation
634 for <span class="style2">-retries</span> and <span class="style2">-min_retries</span>) will be considered for a rerun.
635 This means you can change the value of the <span class="style2">-retries</span> and
636 <span class="style2">-min_retries</span> options if you like more or less retries.
637 Setting <span class="style2">-rerun</span> to 0 means that PsN will not check for
638 missing or incomplete "retry" list files. This is usefull
639 if you have one or more run modelfiles and you wish to have
640 a PsN raw_results file or a PsN summary, you do a "execute"
641 run with them as arguments and specify <span class="style2">-rerun=0</span>, PsN will not
642 do any NONMEM run, but produce usefull output summary.
643 You can also set <span class="style2">-rerun</span> to 2, and PsN will ignore any existing
644 list files and rerun everything, creating raw_results and
645 summaries from the new listfiles.
648 $help_hash{-run_on_lsf} = <<'EOF';
649 <p class="style2">-run_on_lsf</p>
651 PsN connects with Platform Load Sharing Facility (LsF). With
652 <span class="style2">-run_on_lsf</span>. PsN will submit to the queue defined in "psn.conf"
653 unless specified with <span class="style2">-lsf_queue</span>.
656 $help_hash{-run_on_ud} = <<'EOF';
657 <p class="style2">-run_on_ud</p>
659 PsN connects with United Devices Grid MP. With <span class="style2">-run_on_ud</span> PsN will submit to the UD grid
660 with parameters defined in the "uduserconf" file.
662 $help_hash{-retries} = <<'EOF';
663 <p class="style2">-retries='integer'</p>
665 The <span class="style2">-retries</span> option tells the execute utility how many times it
666 shall try to rerun a NONMEM job if it fails according to given criterias.. In
667 the current version of PsN (2.2), the <span class="style2">-retries</span> option is only
668 valid together with <span class="style2">-tweak_inits</span>. The default value of the
669 <span class="style2">-retries</span> option is 6.
672 $help_hash{-significant_digits_rerun} = <<'EOF';
673 <p class="style2">-significant_digits_rerun='number'</p>
675 The <span class="style2">-picky</span> option is only valid together with <span class="style2">-tweak_inits</span>.
676 Normally PsN only tries new initial estimates if
677 '<span class="style2">MINIMZATION SUCCESSFUL</span>' is not found in the NONMEM output
678 file. With the <span class="style2">-significant_digits_rerun</span>, PsN will rerun if
679 the resulting significant digits is lower than the value
680 specified with this option.
683 $help_hash{-abort_on_fail} = <<'EOF';
684 <p class="style2">-abort_on_fail</p>
686 If the <span class="style2">-abort_on_fail</span> option is set and one of the NONMEM runs
687 fails, execute will stop scheduling more runs and try to stop
688 those that are currently running. A run is considered failed if it
689 fails to produce a list file which PsN can read. This can occure
690 if a nonmem run crashes or gets killed.
693 $help_hash{-adaptive} = <<'EOF';
694 <p class="style2">-adaptive</p>
696 <span class="style2">-adaptive</span> enables a highly experimental feature to dynamically
697 assign the number of threads depending on the number of running
698 nonmem processes on the computer. It requires a server program
699 which is not distributed with PsN. If you are interrested in this
700 feature, contact the PsN developers.
703 $help_hash{-run_on_nordugrid} = <<'EOF';
704 <p class="style2">-run_on_nordugrid</p>
706 !! Currently only valid for Linux system !!
707 execute will run on nordugrid clusters listed in ~/.ng_cluster .
708 If you do not know about Nordugrid, you can safely ignore this option.
709 Read more on http://www.nordugrid.org
712 $help_hash{-cpu_time} = <<'EOF';
713 <p class="style2">-cpu_time='integer'</p>
715 !! Currently only valid for Linux system !!
716 This option specifies the number of minutes allocated for a
717 gridjob. The default value is 120 minutes. This option is only
718 valid together with the <span class="style2">-run_on_nordugrid</span> option.
721 $help_hash{-grid_batch_size} = <<'EOF';
722 <p class="style2">-grid_batch_size='integer'</p>
724 This option specifies the number of nonmem runs that will be
725 grouped together into one grid job. The default number is 5. This
726 option is only valid together with the '<span class="style2">-run_on_nordugrid'</span> option.
729 $help_hash{-silent} = <<'EOF';
730 <p class="style2">-silent</p>
732 The silent option turns off all output from PsN. Results and log
733 files are still written to disk, but nothing is printed to the
734 screen.
737 $help_hash{-debug} = <<'EOF';
738 <p class="style2">-debug='integer'</p>
740 The <span class="style2">-debug</span> option is mainly intended for developers who whish to
741 debug PsN. By default <span class="style2">-debug</span> is set to zero but you can try
742 setting it to '1' to enable warning messages. If you run in to
743 problems that require support, you may have to increase this
744 number to 2 or 3 and send the output to us.
747 $help_hash{-debug_package} = <<'EOF';
748 <p class="style2">-debug_package='string'</p>
750 When used together with <span class="style2">-debug</span>, the <span class="style2">-debug_package</span> option makes is
751 possible to choose which part of PsN you want to see debug
752 messages for. Again, this option is mostly for developers.
755 $help_hash{-debug_subroutine} = <<'EOF';
756 <p class="style2">-debug_subroutine='string'</p>
758 Default value is: empty string
760 With this option it is possible to specify, with even finer
761 granularity, which part of PsN you want to see debug messages
762 from. This is definitly only for developers.
765 $help_hash{-warn_with_trace} = <<'EOF';
766 <p class="style2">-warn_with_trace</p>
768 If the <span class="style2">-debug</span> level is bigger than zero PsN will print warning
769 messages. If <span class="style2">-warn_with_trace</span> is set, PsN will print a stack
770 trace from the point where the warning message was printed.
771 This is definitly only for developers.
775 $help_hash{-sde} = <<'EOF';
776 <p class="style2">-sde</p>
778 If you are running SDE models, you must use this option, otherwise
779 PsN will destroy the formatting of the models, and the NONMEM runs
780 will fail.
783 $help_hash{'-h'} = $help_hash{'-?'};
786 if( defined $help_text ){
787 %help_hash = %{$help_text};
790 my $help;
792 if($options{'h'} or $options{'?'} or $options{'help'} ) {
794 if( $options{'html_help'} ){
796 open(EXAMPLES, '>', 'html/' . $command . '_examples.php' );
797 print EXAMPLES $help_hash{Examples};
798 close( EXAMPLES );
800 open(SYNOPSIS, '>', 'html/' . $command . '_synopsis.php' );
801 print SYNOPSIS $help_hash{Pre_help_message} . "<pre>\t$command " . common_options::print_help($command,$required_options, $optional_options)."</pre>" ;
802 close( SYNOPSIS );
804 open(OPTIONS, '>', 'html/' . $command . '_options.php' );
805 my $opt_help;
807 if( $command eq 'execute' ){
808 @loop_array = @get_opt_strings;
809 } else {
810 @loop_array = (sort(keys %{$required_options}), sort(keys %{$optional_options}));
813 foreach my $option( @loop_array ){
814 #foreach my $option(keys %help_hash){
815 $option =~ s/[^\w]*$|:.*//;
816 if( exists $help_hash{'-'.$option}){
817 $opt_help .= $help_hash{'-'.$option}."\n\n";
818 } else {
819 $opt_help .= " <p class=\"style2\">-$option</p> <p>No help available for '$option'</p>";
822 print OPTIONS $help_hash{Options} . $opt_help;
823 close( OPTIONS );
825 open(DESC, '>', 'html/' . $command . '_description.php' );
826 print DESC $help_hash{Description};
827 close( DESC );
829 exit;
830 } else {
832 if( scalar( @ARGV ) > 0 ){
833 foreach my $option ( @ARGV ){
835 if( exists $help_hash{'-'.$option} ){
836 $help .= "\n".$help_hash{'-'.$option}. "\n";
837 } else {
838 $help .= "\nNo help available for '$option'\n\n";
842 $help =~ s/<\?.*\?>//g;
843 $help =~ s/<[^>]*>//g;
844 print $help;
845 exit;
848 $help .= "\n" . $help_hash{Pre_help_message} . "\n";
849 $help .= "\t$command ";
850 $help .= common_options::print_help($command,$required_options, $optional_options);
853 if( $options{'help'} ){
855 $help .= "\n\n".$help_hash{Description}."\n\n";
856 $help .= $help_hash{Examples}."\n\n";
857 $help .= $help_hash{Options}."\n\n";
859 my @loop_array;
861 if( $command eq 'execute' ){
862 @loop_array = @get_opt_strings;
863 } else {
864 @loop_array = (sort(keys %{$required_options}), sort(keys %{$optional_options}));
867 foreach my $option( @loop_array ){
868 #print "special case: $option\n" if ( $option =~ /\W+$|:.*/ );
869 $option =~ s/[^\w]*$|:.*//;
870 #$option = '-'.$option unless( $option =~ /^-/ );
871 if( exists $help_hash{'-'.$option}){
872 $help .= $help_hash{'-'.$option}."\n\n";
873 } else {
874 $help .= " -$option\n\n No help available for '$option'\n\n\n";
878 $help .= $help_hash{Post_help_message} . "\n";
880 } else {
881 $help .= "\n Use '$command -help' for a longer desctription.\n\n";
884 $help =~ s/<\?.*\?>//g;
885 $help =~ s/<[^>]*>//g;
886 print $help;
888 exit;