coderunner 0.17.11 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +18 -0
- data/README.md +34 -5
- data/VERSION +1 -1
- data/coderunner.gemspec +11 -8
- data/dependencies/Makefile +101 -0
- data/dependencies/README.md +34 -0
- data/dependencies/download_dependencies.sh +20 -0
- data/lib/coderunner.rb +284 -321
- data/lib/coderunner/class_methods.rb +3 -13
- data/lib/coderunner/config.rb +87 -0
- data/lib/coderunner/fortran_namelist.rb +6 -6
- data/lib/coderunner/interactive_config.rb +57 -0
- data/lib/coderunner/interactive_methods.rb +333 -687
- data/lib/coderunner/repository.rb +1 -1
- data/lib/coderunner/run.rb +4 -0
- metadata +8 -5
- data/README.rdoc +0 -19
- data/test/test_coderunnerrepo.rb +0 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43d5315b9baf7aa8ce1151c670f76f9b1e600dc
|
4
|
+
data.tar.gz: 8cb20e034938fe3c2d871ac1c4393ff2fdfe75ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb742efc08e538dcbe3edc91796d39034ed53ae749ef079c241d876cf2de19ea06b3c3759cc28f2cb5c20ab54697227b592ab261eb416dafdf6d0cfae1fe540
|
7
|
+
data.tar.gz: 13efb514d160fa482fbae40a92a83be17ea65dcc9afb651c4fd0b7ed6f8990d0aeb597f9d102fe9f49f4e55ac512408c632e7e9714c2ead0f2246037599761e9
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Contributing to coderunner
|
2
|
+
=========================
|
3
|
+
|
4
|
+
* Check out the latest master to make sure the feature hasn't been implemented
|
5
|
+
or the bug hasn't been fixed yet.
|
6
|
+
* Check out the issue tracker to make sure someone already hasn't requested it
|
7
|
+
and/or contributed it. If not open a new issue.
|
8
|
+
* Fork the project referencing the issue number.
|
9
|
+
* Write feature/bugfix and tests. Please adhere to the coding style guide in
|
10
|
+
the README.
|
11
|
+
* Open a Pull Request. This will trigger an automated Travis CI build to run
|
12
|
+
the tests.
|
13
|
+
* Once PR passes all tests and reviews it will be merged into master.
|
14
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to
|
15
|
+
have your own version, or is otherwise necessary, that is fine, but please
|
16
|
+
isolate to its own commit so I can cherry-pick around it.
|
17
|
+
|
18
|
+
|
data/README.md
CHANGED
@@ -1,7 +1,29 @@
|
|
1
|
-
|
1
|
+
CodeRunner
|
2
2
|
==========
|
3
3
|
|
4
|
-
CodeRunner is a framework for the automated running and analysis of
|
4
|
+
CodeRunner is a framework for the automated running and analysis of
|
5
|
+
simulations. It automatically generates any necessary input files, organises
|
6
|
+
the output data and analyses it. Because it is a modular system, it can easily
|
7
|
+
be customised to work with any system and any simulation code.
|
8
|
+
|
9
|
+
Installation
|
10
|
+
============
|
11
|
+
|
12
|
+
CodeRunner requires several system dependencies which are explained in the
|
13
|
+
`dependencies/README.md` file.
|
14
|
+
|
15
|
+
From RubyGems:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ gem install coderunner
|
19
|
+
```
|
20
|
+
|
21
|
+
From source:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ rake build
|
25
|
+
$ gem install -l pkg/coderunner-x.x.x.gem
|
26
|
+
```
|
5
27
|
|
6
28
|
Coding Style Guide
|
7
29
|
==================
|
@@ -9,8 +31,15 @@ Coding Style Guide
|
|
9
31
|
These bullet points are taken from here: https://github.com/bbatsov/ruby-style-guide
|
10
32
|
|
11
33
|
* Indentation is strictly two spaces, i.e. not tabs.
|
12
|
-
* Where possible do not exceed 80 columns. This makes the code much more
|
13
|
-
|
14
|
-
* Avoid unnecessary comments or inline comments, try to write code which is
|
34
|
+
* Where possible do not exceed 80 columns. This makes the code much more
|
35
|
+
readable.
|
36
|
+
* Avoid unnecessary comments or inline comments, try to write code which is
|
37
|
+
self documenting or have a short comment preceding your code.
|
15
38
|
* Do not use the ';' character to write several statements on one line.
|
16
39
|
* If in doubt refer to the style guide.
|
40
|
+
|
41
|
+
Copyright
|
42
|
+
=========
|
43
|
+
|
44
|
+
Copyright (c) 2016 Edmund Highcock. See LICENSE.txt for further details.
|
45
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.18.0
|
data/coderunner.gemspec
CHANGED
@@ -2,37 +2,39 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: coderunner 0.
|
5
|
+
# stub: coderunner 0.18.0 ruby lib
|
6
6
|
# stub: ext/extconf.rb
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "coderunner"
|
10
|
-
s.version = "0.
|
10
|
+
s.version = "0.18.0"
|
11
11
|
|
12
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.authors = ["Edmund Highcock"]
|
15
|
-
s.date = "2016-04-
|
15
|
+
s.date = "2016-04-02"
|
16
16
|
s.description = "CodeRunner is a framework for the automated running and analysis of simulations. It automatically generates any necessary input files, organises the output data and analyses it. Because it is a modular system, it can easily be customised to work with any system and any simulation code. One of its greatest strengths is that it is independent of any one simulation code; thus it can easily plot and compare the data from different codes."
|
17
17
|
s.email = "edmundhighcock@sourceforge.net"
|
18
18
|
s.executables = ["coderunner", "coderunnerrepo"]
|
19
19
|
s.extensions = ["ext/extconf.rb"]
|
20
20
|
s.extra_rdoc_files = [
|
21
21
|
"LICENSE.txt",
|
22
|
-
"README.md"
|
23
|
-
"README.rdoc"
|
22
|
+
"README.md"
|
24
23
|
]
|
25
24
|
s.files = [
|
26
25
|
".document",
|
26
|
+
"CONTRIBUTING.md",
|
27
27
|
"Gemfile",
|
28
28
|
"LICENSE.txt",
|
29
29
|
"README.md",
|
30
|
-
"README.rdoc",
|
31
30
|
"Rakefile",
|
32
31
|
"VERSION",
|
33
32
|
"bin/coderunner",
|
34
33
|
"bin/coderunnerrepo",
|
35
34
|
"coderunner.gemspec",
|
35
|
+
"dependencies/Makefile",
|
36
|
+
"dependencies/README.md",
|
37
|
+
"dependencies/download_dependencies.sh",
|
36
38
|
"ext/code_runner_ext.c",
|
37
39
|
"ext/extconf.rb",
|
38
40
|
"ext/graph_kit.c",
|
@@ -41,12 +43,14 @@ Gem::Specification.new do |s|
|
|
41
43
|
"lib/code_runner_extension.rb",
|
42
44
|
"lib/coderunner.rb",
|
43
45
|
"lib/coderunner/class_methods.rb",
|
46
|
+
"lib/coderunner/config.rb",
|
44
47
|
"lib/coderunner/feedback.rb",
|
45
48
|
"lib/coderunner/fortran_namelist.rb",
|
46
49
|
"lib/coderunner/fortran_namelist_c.rb",
|
47
50
|
"lib/coderunner/graphs_and_films.rb",
|
48
51
|
"lib/coderunner/heuristic_run_methods.rb",
|
49
52
|
"lib/coderunner/instance_methods.rb",
|
53
|
+
"lib/coderunner/interactive_config.rb",
|
50
54
|
"lib/coderunner/interactive_methods.rb",
|
51
55
|
"lib/coderunner/long_regexen.rb",
|
52
56
|
"lib/coderunner/merged_code_runner.rb",
|
@@ -93,8 +97,7 @@ Gem::Specification.new do |s|
|
|
93
97
|
"test/fortran_namelist.in",
|
94
98
|
"test/helper.rb",
|
95
99
|
"test/old_test.rb",
|
96
|
-
"test/test_coderunner.rb"
|
97
|
-
"test/test_coderunnerrepo.rb"
|
100
|
+
"test/test_coderunner.rb"
|
98
101
|
]
|
99
102
|
s.homepage = "http://coderunner.sourceforge.net"
|
100
103
|
s.licenses = ["GPLv3"]
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# Makefile for installing CodeRunner dependencies
|
2
|
+
# Written by Edmund Highcock Oct 2012
|
3
|
+
# edmundhighcock@sourceforge.net
|
4
|
+
#
|
5
|
+
|
6
|
+
MY_MAKEFLAGS?=
|
7
|
+
MY_CONFFLAGS=LDFLAGS=-L${PREFIX}/lib CFLAGS=-I${PREFIX}/include
|
8
|
+
|
9
|
+
# Packages
|
10
|
+
NETCDF="netcdf-4.2.1.1"
|
11
|
+
GSL="gsl-1.16"
|
12
|
+
HDF5="hdf5-1.8.9"
|
13
|
+
YAML="yaml-0.1.4"
|
14
|
+
READLINE="readline-6.2"
|
15
|
+
NCURSES="ncurses-5.9"
|
16
|
+
RUBY="ruby-2.1-stable"
|
17
|
+
|
18
|
+
help:
|
19
|
+
@echo
|
20
|
+
@echo
|
21
|
+
@echo "----------------------------------------------------------------"
|
22
|
+
@echo "A Makefile for installing the dependencies of CodeRunner."
|
23
|
+
@echo "If you are not sure which are already on your system then"
|
24
|
+
@echo "type:"
|
25
|
+
@echo " make hd all rb PREFIX=<yourprefix>"
|
26
|
+
@echo "where your prefix is the folder where you want to install it."
|
27
|
+
@echo
|
28
|
+
@echo "If you want to install only certain ones then choose from "
|
29
|
+
@echo "-> gsl(gl), hdf5(hd), netcdf(nc), yaml(ym), readline(rl), ncurses(nu)"
|
30
|
+
@echo "-> ruby(rb) [mandatory, must be done after ym and rl]"
|
31
|
+
@echo
|
32
|
+
@echo "e.g."
|
33
|
+
@echo " make gl nc ym PREFIX=<yourprefix>"
|
34
|
+
@echo " make rb PREFIX=<yourprefix>"
|
35
|
+
@echo
|
36
|
+
@echo "Notes:"
|
37
|
+
@echo "1. If you take the second option and use system libraries"
|
38
|
+
@echo " you may run into a whole host of compatibility issues."
|
39
|
+
@echo " If you are not confident with what you are doing we "
|
40
|
+
@echo " recommend that you install everything again from here."
|
41
|
+
@echo "2. Why doesn't the makefile resolve the depencies of ruby"
|
42
|
+
@echo " i.e. readline, ncurses and yaml? Because we don't want to have to"
|
43
|
+
@echo " start with readline and yaml every time the ruby installation"
|
44
|
+
@echo " is unexpectedly interrupted."
|
45
|
+
@echo "----------------------------------------------------------------"
|
46
|
+
|
47
|
+
.default_goal: help
|
48
|
+
|
49
|
+
all: netcdf gsl readline yaml ncurses
|
50
|
+
|
51
|
+
gl: gsl
|
52
|
+
|
53
|
+
gsl:
|
54
|
+
tar -xzf ${GSL}.tar.gz
|
55
|
+
cd ${GSL}; ./configure --prefix=${PREFIX} && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
56
|
+
|
57
|
+
hd: hdf5
|
58
|
+
|
59
|
+
hdf5:
|
60
|
+
tar -xzf ${HDF5}.tar.gz
|
61
|
+
cd ${HDF5}; ./configure --prefix=${PREFIX} && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
62
|
+
|
63
|
+
nc: netcdf
|
64
|
+
|
65
|
+
netcdf:
|
66
|
+
tar -xzf ${NETCDF}.tar.gz
|
67
|
+
cd ${NETCDF}; ./configure ${MY_CONFFLAGS} --prefix=${PREFIX} --enable-shared --enable-netcdf4 && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
68
|
+
|
69
|
+
ym: yaml
|
70
|
+
|
71
|
+
yaml:
|
72
|
+
tar -xzf ${YAML}.tar.gz
|
73
|
+
cd ${YAML}; ./configure --prefix=${PREFIX} && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
74
|
+
|
75
|
+
rl: readline
|
76
|
+
|
77
|
+
readline:
|
78
|
+
tar -xzf ${READLINE}.tar.gz
|
79
|
+
cd ${READLINE}; ./configure --prefix=${PREFIX} && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
80
|
+
|
81
|
+
nu: ncurses
|
82
|
+
|
83
|
+
ncurses:
|
84
|
+
tar -xzf ${NCURSES}.tar.gz
|
85
|
+
cd ${NCURSES}; ./configure --prefix=${PREFIX} --with-shared && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
86
|
+
|
87
|
+
rb: ruby
|
88
|
+
|
89
|
+
ruby:
|
90
|
+
tar -xzf ${RUBY}.tar.gz
|
91
|
+
cd ${RUBY}; ./configure --prefix=${PREFIX} ${MY_CONFFLAGS} && make ${MY_MAKEFLAGS} && make install ${MY_MAKEFLAGS}
|
92
|
+
cd ${RUBY}/ext/readline; ruby extconf.rb ; make && make install
|
93
|
+
cd ${RUBY}/ext/psych/; ruby extconf.rb ; make && make install
|
94
|
+
|
95
|
+
ruby_ext:
|
96
|
+
cd ${RUBY}/ext/readline; ruby extconf.rb ; make && make install
|
97
|
+
cd ${RUBY}/ext/psych/; ruby extconf.rb ; make && make install
|
98
|
+
|
99
|
+
clean:
|
100
|
+
rm -rf ${RUBY} ${RUBY} ${NETCDF} ${YAML} ${READLINE} ${GSL}
|
101
|
+
rm -rf ${NCURSES} ${HDF5}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
System dependencies
|
2
|
+
===================
|
3
|
+
|
4
|
+
CodeRunner requires the following system-level dependencies:
|
5
|
+
|
6
|
+
1. GSL
|
7
|
+
2. HDF5
|
8
|
+
3. ncurses
|
9
|
+
4. NetCDF
|
10
|
+
5. readline
|
11
|
+
6. Ruby
|
12
|
+
7. yaml
|
13
|
+
|
14
|
+
To install these, there are two option:
|
15
|
+
|
16
|
+
1. Install through a package manager (recommended).
|
17
|
+
2. Install using the from source.
|
18
|
+
|
19
|
+
In some cases, packages downloaded through the system package manager are too
|
20
|
+
old for some RubyGems. In that case follow the manual installation below.
|
21
|
+
|
22
|
+
Manual Installation
|
23
|
+
=================
|
24
|
+
|
25
|
+
1. Run `./download_dependencies.sh -P /path/to/download/dir`. Default
|
26
|
+
location is in the dependencies directory.
|
27
|
+
2. To compile all the packages, run `make hd all rb PREFIX=/path/to/install/dir`.
|
28
|
+
3. If you only want to build one package see the makefile for the short name
|
29
|
+
of the package. If you find any of these out of date, please open an
|
30
|
+
issue of GitHub.
|
31
|
+
4. Finally, export these to the system PATH by adding the following to your
|
32
|
+
`.bashrc`:
|
33
|
+
|
34
|
+
`export PATH=/path/to/install/dir:$PATH`
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
DIR="$PWD"
|
4
|
+
|
5
|
+
while [ $# -gt 0 ]
|
6
|
+
do
|
7
|
+
case "$1" in
|
8
|
+
-P) DIR="$2"; shift
|
9
|
+
esac
|
10
|
+
shift
|
11
|
+
done
|
12
|
+
|
13
|
+
wget -nc ftp://ftp.gnu.org/gnu/gsl/gsl-1.16.tar.gz -P $DIR
|
14
|
+
wget -nc https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.9/src/hdf5-1.8.9.tar.gz -P $DIR
|
15
|
+
wget -nc ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz -P $DIR
|
16
|
+
wget -nc ftp://ftp.unidata.ucar.edu/pub/netcdf/old/netcdf-4.2.1.1.tar.gz -P $DIR
|
17
|
+
wget -nc ftp://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz -P $DIR
|
18
|
+
wget -nc http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz -P $DIR
|
19
|
+
wget -nc https://cache.ruby-lang.org/pub/ruby/ruby-2.1-stable.tar.gz -P $DIR
|
20
|
+
|
data/lib/coderunner.rb
CHANGED
@@ -2,52 +2,16 @@
|
|
2
2
|
$stderr.puts "CodeRunner (c) 2009-2016. Written by Edmund Highcock & Ferdinand van Wyk. Loading..." unless $has_put_startup_message_for_code_runner
|
3
3
|
|
4
4
|
if RUBY_VERSION.to_f < 1.9
|
5
|
-
|
5
|
+
raise "Ruby version 1.9 or greater required (current version is #{RUBY_VERSION})"
|
6
6
|
end
|
7
7
|
|
8
|
-
# Basic class setup
|
9
8
|
|
10
9
|
require 'rubygems'
|
11
10
|
require "rubyhacks"
|
12
11
|
|
12
|
+
# Basic class setup
|
13
|
+
require 'coderunner/config'
|
13
14
|
|
14
|
-
#Create the coderunner config directory if it doesn't exist
|
15
|
-
FileUtils.makedirs(ENV['HOME'] + "/.coderunner")
|
16
|
-
|
17
|
-
class CodeRunner
|
18
|
-
|
19
|
-
COMMAND_FOLDER = Dir.pwd
|
20
|
-
SCRIPT_FOLDER = File.dirname(File.expand_path(__FILE__)) + '/coderunner' #i.e. where this script is
|
21
|
-
|
22
|
-
if ENV['CODE_RUNNER_OPTIONS']
|
23
|
-
GLOBAL_OPTIONS = eval(ENV['CODE_RUNNER_OPTIONS']) # global options are set by the environment but some can be changed.
|
24
|
-
else
|
25
|
-
GLOBAL_OPTIONS = {}
|
26
|
-
end
|
27
|
-
SYS = (GLOBAL_OPTIONS[:system] or ENV['CODE_RUNNER_SYSTEM'] or ENV['SYSTEM'] or "generic_linux")
|
28
|
-
require SCRIPT_FOLDER + "/system_modules/#{SYS}.rb"
|
29
|
-
SYSTEM_MODULE = const_get(SYS.variable_to_class_name)
|
30
|
-
include SYSTEM_MODULE
|
31
|
-
class << self
|
32
|
-
include SYSTEM_MODULE
|
33
|
-
end
|
34
|
-
# begin
|
35
|
-
# SYSTEM_MODULE.configure_environment
|
36
|
-
# rescue NoMethodError
|
37
|
-
# end
|
38
|
-
@@sys = SYS
|
39
|
-
def gets #No reading from the command line thank you very much!
|
40
|
-
$stdin.gets
|
41
|
-
end
|
42
|
-
def self.gets
|
43
|
-
$stdin.gets
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# CodeRunner::SCRIPT_FOLDER = File.dirname(File.expand_path(__FILE__)) #i.e. where this script is
|
51
15
|
|
52
16
|
$JCODE = 'U'
|
53
17
|
|
@@ -74,19 +38,19 @@ require "drb"
|
|
74
38
|
require 'parallelpipes'
|
75
39
|
require 'find'
|
76
40
|
|
77
|
-
begin
|
78
|
-
|
41
|
+
begin
|
42
|
+
require 'hostmanager'
|
79
43
|
rescue LoadError
|
80
|
-
|
44
|
+
eprint 'no hostmanager.'
|
81
45
|
end
|
82
46
|
|
83
47
|
begin
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
48
|
+
require "rubygems"
|
49
|
+
require "rbgsl"
|
50
|
+
require "gsl_extras"
|
51
|
+
#require CodeRunner::SCRIPT_FOLDER + "/gsl_tools.rb"
|
88
52
|
rescue LoadError
|
89
|
-
|
53
|
+
$stderr.puts "Warning: could not load rbgsl; limited functionality"
|
90
54
|
end
|
91
55
|
|
92
56
|
#require CodeRunner::SCRIPT_FOLDER + "/gnuplot.rb"
|
@@ -115,7 +79,6 @@ eprint '.' unless $has_put_startup_message_for_code_runner
|
|
115
79
|
load CodeRunner::SCRIPT_FOLDER + "/repository.rb"
|
116
80
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
117
81
|
|
118
|
-
CodeRunner::CODE_RUNNER_VERSION = Version.new(Gem.loaded_specs['coderunner'].version.to_s) rescue "test"
|
119
82
|
|
120
83
|
CodeRunner::GLOBAL_BINDING = binding
|
121
84
|
|
@@ -126,69 +89,69 @@ Log.log_file = nil
|
|
126
89
|
|
127
90
|
|
128
91
|
class CodeRunner
|
129
|
-
|
130
|
-
####################################
|
131
|
-
# Commmand line processing #
|
132
|
-
####################################
|
133
|
-
|
134
|
-
|
135
|
-
# Here are all the methods that map the command line invocation into the correct class method call
|
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
|
-
rihelp = <<EOF
|
191
|
-
Documents classes, methods, constants and modules in the usual Ruby form: e.g.
|
92
|
+
|
93
|
+
####################################
|
94
|
+
# Commmand line processing #
|
95
|
+
####################################
|
96
|
+
|
97
|
+
|
98
|
+
# Here are all the methods that map the command line invocation into the correct class method call
|
99
|
+
COMMAND_LINE_FLAGS_WITH_HELP = [
|
100
|
+
["--recalc-all", "-A", GetoptLong::NO_ARGUMENT, %[Causes each directory to be reprocessed, rather than reading the cache of data. Its exact effect depends on the code module being used. By convention it implies that ALL data analysis will be redone.]],
|
101
|
+
["--reprocess-all", "-a", GetoptLong::NO_ARGUMENT, %[Causes each directory to be reprocessed, rather than reading the cache of data. Its exact effect depends on the code module being used. By convention it implies that VERY LITTLE data analysis will be redone.]],
|
102
|
+
["--code", "-C", GetoptLong::REQUIRED_ARGUMENT, %[The code that is being used for simulations in this folder. This string must correspond to a code module supplied to CodeRunner. It usually only needs to be specified once as it will be stored as a default in the folder.]],
|
103
|
+
["--comment", "-c", GetoptLong::REQUIRED_ARGUMENT, %[A comment about the submitted run.]],
|
104
|
+
["--debug", "-d", GetoptLong::NO_ARGUMENT, %[Submit the simulation to the debug queue. This usually only has meaning on HPC systems. It does not mean debug CodeRunner!]],
|
105
|
+
["--defaults-file", "-D", GetoptLong::REQUIRED_ARGUMENT, %[Specify a defaults file to be used when submitting runs. The name should correspond to file named something like '<name>_defaults.rb' in the correct folders within the code module. Every time a different defaults file is specified, a local copy of that defaults file is stored in the root folder. This local copy can be edited and all runs will use the local copy to get defaults. CodeRunner will never overwrite the local copy.]],
|
106
|
+
["--film-options", "-F", GetoptLong::OPTIONAL_ARGUMENT, %[Specify a hash of options when making films. The most important one is fa (frame array). For example -F '{fa: [0, 200]}'. For all possible options see the CodeRunner method make_film_from_lists.]],
|
107
|
+
["--conditions", "-f", GetoptLong::REQUIRED_ARGUMENT, %[A string specifying conditions used to filter runs. This filter is used in a variety of circumstances, for example when printing out the status, plotting graphs etc. Example: '@height == 10 and @width = 2.2 and @status==:Complete'.]],
|
108
|
+
["--run-graph", "-g", GetoptLong::REQUIRED_ARGUMENT, %[Specify a run_graphkit to plot. A run_graphkit is one that is plotted for an individual run. The run graphkits available depend on the code module. The syntax is graphkit shorthand:\n -g '<graph_name>[ ; <graph_options> [ ; <conditions> [ ; <sort> ] ] ]'\n where conditions (i.e. filter) and sort will override the -f and -O flags respectively. The -g flag can be specified multiple times, which will plot multiple graphs on the same page.]],
|
109
|
+
["--graph", "-G", GetoptLong::REQUIRED_ARGUMENT, %[Specify a graphkit to plot. A graphkit combines data for every filtered run. The syntax is graphkit shorthand:\n -G '<axis1>[ : <axis2> [ : <axis3 [ : <axis4> ] ] ] [ ; <graph_options> [ ; <conditions> [ ; <sort> ] ] ]'\n where conditions (i.e. filter) and sort will override the -f and -O flags respectively. <axis1> etc are strings which can be evaluated by the runs. The -G flag can be specified multiple times, which will plot multiple graphs on the same page. For example\n -G 'width : 2*height ; {} ; depth == 2 ; width'\n will plot twice the height against the width for every run where the depth is equal to 2, and will order the data points by width.]],
|
110
|
+
["--heuristic-analysis", "-H", GetoptLong::NO_ARGUMENT, %[Should be specified whenever CodeRunner is being used to analyse simulations which did not originally submit (and which will therefore not have the usual CodeRunner meta data stored with them).] ],
|
111
|
+
["--use-component", "-h", GetoptLong::OPTIONAL_ARGUMENT, %[Specify whether to use real or component runs]],
|
112
|
+
["--just", "-j", GetoptLong::REQUIRED_ARGUMENT, %[Specify individual run ids. For example -j 45,63,128 is shorthand for -f 'id==45 or id==63 or id==128']],
|
113
|
+
["--job_chain", "-J", GetoptLong::NO_ARGUMENT, %[Chain multiple simulations into one batch/submission job. Most useful for HPC systems.]],
|
114
|
+
["--skip-similar-jobs-off", "-k", GetoptLong::NO_ARGUMENT, %[Normally CodeRunner will not submit a run whose input parameters identical to a previous run (to avoid wasting computer time). Specifying the flag will override that behaviour and force submission of an identical run.]],
|
115
|
+
["--loop", "-l", GetoptLong::NO_ARGUMENT, %[Used with the status command. Keep continually printing out live status information.]],
|
116
|
+
["--multiple-processes", "-M", GetoptLong::REQUIRED_ARGUMENT],
|
117
|
+
["--modlet", "-m", GetoptLong::REQUIRED_ARGUMENT, %[Specify the modlet to be used in the current folder. Only needs to be specified once as it will be stored as a default.]],
|
118
|
+
["--no-run", "-N", GetoptLong::NO_ARGUMENT, %[On some machines getting a list of currently running jobs takes a long time. Specifying this flag tells CodeRunner that you definitely know that no runs in the folder are still queueing or running. Do not specify it if there are still running jobs as it will cause their statuses to be updated incorrectly.]],
|
119
|
+
["--nprocs", "-n", GetoptLong::REQUIRED_ARGUMENT, %[A string specifying the processor layout for the simulation. For example -n 46x4 means use 46 nodes with four processors per node. In the case of a personal computer something like -n 2 is more likely. The default is 1]],
|
120
|
+
["--sort", "-O", GetoptLong::REQUIRED_ARGUMENT, %[Specify the sort order for the runs. Used for a variety of commands, for example status. It is a string of semicolon separated sort keys: for example -O height;width will sort the runs by height and then width.]],
|
121
|
+
["--project", "-P", GetoptLong::REQUIRED_ARGUMENT, %[Specify the project to be used for billing purposes. Only necessary on some systems.]],
|
122
|
+
["--parameters", "-p", GetoptLong::REQUIRED_ARGUMENT, %[A hash of parameters for the simulation. For example -p '{height: 20, width: 2.3}'. These parameters will override the defaults in the local defaults file.]],
|
123
|
+
["--queue", "-Q", GetoptLong::REQUIRED_ARGUMENT, %[The name of the queue to submit to on HPC systems. Not yet implemented for all systems. Please submit a feature request if it is not working on your system.]],
|
124
|
+
["--no-auto-create-runner", "-q", GetoptLong::NO_ARGUMENT, %[Used for interactive mode when you don't want CodeRunner to analyse the current directory.]],
|
125
|
+
["--terminal-size", "-t", GetoptLong::REQUIRED_ARGUMENT, %[Specify the terminal size for situations where CodeRunner cannot work it out: -t '[rows, cols]' (square brackets are part of the syntax)]],
|
126
|
+
["--test-submission", "-T", GetoptLong::NO_ARGUMENT, %[Don't actually submit the run, but exit after printing out the run parameters and generating any input files necessary.]],
|
127
|
+
["--use-large-cache-but-recheck-incomplete", "-u", GetoptLong::NO_ARGUMENT, %[Use the large cache for speed, but check any runs whose status is not :Complete or :Failed.]],
|
128
|
+
["--use-large-cache", "-U", GetoptLong::NO_ARGUMENT, %[Use the large cache for speed. No run data will be updated.]],
|
129
|
+
["--version", "-v", GetoptLong::REQUIRED_ARGUMENT, %[Specify the version of the simulation code being used. Only has an effect for certain code modules.]],
|
130
|
+
["--wall-mins", "-W", GetoptLong::REQUIRED_ARGUMENT, %[Specify the wall clock limit in minutes.]],
|
131
|
+
["--write-options", "-w", GetoptLong::REQUIRED_ARGUMENT, %[Use when plotting graphs. A hash of custom options which are applied to the graphkit just before plotting it; for example: -w '{xlabel: 'X Axis Quantity, log_axis: 'y'}']],
|
132
|
+
["--executable", "-X", GetoptLong::REQUIRED_ARGUMENT, %[Specify the location of the executable of the simulation code. It only needs to be specified once in any folder, unless it needs to be changed.]],
|
133
|
+
["--other-folder", "-Y", GetoptLong::REQUIRED_ARGUMENT, %[Run CodeRunner in a different folder. On a local machine 'coderunner st -Y some/other/folder' is identical to 'cd some/other/folder; coderunner st -Y'. However, this flag can also be used for remote folders using RemoteCodeRunner (as long as CodeRunner is installed on the remote machine). e.g. -Y username@machine.location:path/to/folder. If this option is specified multiple times, a merged runner will be created from the set of specified folders.]],
|
134
|
+
["--supplementary-options", "-y", GetoptLong::REQUIRED_ARGUMENT],
|
135
|
+
["--server", "-Z", GetoptLong::REQUIRED_ARGUMENT, %[Technical use only]],
|
136
|
+
["--log", "-z", GetoptLong::NO_ARGUMENT, %[Switch logging on (currently not working very well (05/2010)).]] # :nodoc:
|
137
|
+
]
|
138
|
+
|
139
|
+
CLF = COMMAND_LINE_FLAGS = COMMAND_LINE_FLAGS_WITH_HELP.map{|arr| arr.slice(0..2)}
|
140
|
+
|
141
|
+
CODE_COMMAND_OPTIONS = [] # NEEDS FIXING!!!!
|
142
|
+
#(Dir.entries(SCRIPT_FOLDER + "/code_modules/") - [".", "..", ".svn"]).map do |d|
|
143
|
+
#["--#{d}-options", "", GetoptLong::REQUIRED_ARGUMENT, %[A hash of options for the #{d} code module]]
|
144
|
+
#end
|
145
|
+
|
146
|
+
LONG_COMMAND_LINE_OPTIONS = [
|
147
|
+
["--replace-existing", "", GetoptLong::NO_ARGUMENT, %[Use with resubmit: causes each resubmitted run to replace the run being resubmitted.]],
|
148
|
+
["--smart-resubmit-name", "", GetoptLong::NO_ARGUMENT, %[Use with resubmit: causes each resubmitted run to only contain its original id and changed parameters in its run name.]],
|
149
|
+
["--submit-runner-index", "", GetoptLong::NO_ARGUMENT, %[Use with submit or resubmit when specifying multiple root folders... selects which runner will be used for submitting (i.e. which root folder the runs will be submitted in.]],
|
150
|
+
] + CODE_COMMAND_OPTIONS
|
151
|
+
LONG_COMMAND_LINE_FLAGS = LONG_COMMAND_LINE_OPTIONS.map{|arr| [arr[0], arr[2]]}
|
152
|
+
|
153
|
+
rihelp = <<EOF
|
154
|
+
Documents classes, methods, constants and modules in the usual Ruby form: e.g.
|
192
155
|
|
193
156
|
* CodeRunner -- a class
|
194
157
|
* CodeRunner.status -- a class method
|
@@ -196,98 +159,98 @@ Documents classes, methods, constants and modules in the usual Ruby form: e.g.
|
|
196
159
|
* CodeRunner::Run -- a sub class
|
197
160
|
* CodeRunner::CODE_RUNNER_VERSION --a constant
|
198
161
|
EOF
|
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
|
-
|
162
|
+
|
163
|
+
|
164
|
+
COMMANDS_WITH_HELP = [
|
165
|
+
["available_modlets", "av", 0, 'List the available modlets for the code module.', [], [:C]],
|
166
|
+
["available_defaults_files", "avd", 0, 'List the defaults files for the code module.', [], [:C]],
|
167
|
+
["cancel", "can", 0, 'Cancel the specified job.', [], [:j, :f, :U, :N]],
|
168
|
+
["change_run_id", "cri", 1, 'Changes the id of a given set of runs to a new set of ids', ['new_ids'], [:j, :f, :U, :N]],
|
169
|
+
["code_command", "cc", 1, 'Call a class method of the run class. Effectively this will call run_class.class_eval(command). See documentation for whichever code module is in use.', ['command'], []],
|
170
|
+
["concat", "concat", 1, 'Concatenates NetCDF output files together. File is output in the CR root directory.', ['output file'], [:j, :f, :U, :N]],
|
171
|
+
["continue_in_new_folder", "cnf", 1, 'Make a new folder in the parent directory and copy all coderunner configuration files to that folder. If options j or f are specified, copy all matching runs to that new folder.', ['folder'], [:j, :f, :U, :N]],
|
172
|
+
["code_runner_execute", "crex", 1, 'Run (within the CodeRunner class) the fragment of Ruby code given.', ['Ruby fragment'], []],
|
173
|
+
["delete", "del", 0, 'Permanently erase all filtered runs.', [], [:j, :F, :U, :N]],
|
174
|
+
["differences_between", "diff", 0, 'Print a table of all the differences between the input parameters of the filtered ids.', [], [:j, :f, :U, :N]],
|
175
|
+
["directory", "dir", 1, 'Print out the directory for the given run.', ['id'], []],
|
176
|
+
['dumb_film', "dfm", 0, 'Create a film of the specified graphkits using gnuplot "dumb" ASCII terminal.', [], [:F, :G, :g, :U, :N, :j, :f]],
|
177
|
+
["execute", "ex", 1, 'Run (at the top level) the fragment of Ruby code given.', ['Ruby fragment'], []],
|
178
|
+
['film', "fm", 0, 'Create a film of the specified graphkits.', [], [:F, :G, :g, :U, :N, :j, :f]],
|
179
|
+
["generate_modlet_from_input_file", "gm", 1, 'Deprecated', [], []],
|
180
|
+
["generate_cubecalc", "gencc", 0, 'Generate the file cubecalc.cc, the source code for the coderunner test program.', [], []],
|
181
|
+
["generate_documentation", "rdoc", 1, 'Create automatic documentation using the rdoc tool (deprecated, use the command line tool ri for getting help, or see rubygems.org/gems/coderunner).', [], []],
|
182
|
+
["interactive_mode", "im", 0, 'Launch an interactive terminal. Any command line flags specified set the defaults for the session.', [], [:U, :N, :j, :q]],
|
183
|
+
["load_file", "ld", 1, 'Load a Ruby script file using the CodeRunner framework.', ['script file'], []],
|
184
|
+
['manual', 'man', 0, 'Print out command line manual', [], []],
|
185
|
+
['netcdf_plot', 'ncplot', 3, 'Plot a comma separated list of variables, at a comma separated list of indices (nil for all) from the specified netcdf file against each other using gnuplot.', ['netcdf_file', 'vars', 'indices'], [:w]],
|
186
|
+
["plot_graph", "plot", 0, 'Plot the specified graphkits using Gnuplot', [], [:G, :g, :w, :O, :U, :N, :j, :f]],
|
187
|
+
["parameter_scan", "ps", 1, 'Read a parameter scan from file. For full details of how to write a parameter scan, see online documentation (coderunner.sourceforge.net).', ['scan file'], [:n, :W, :k, :v, :p, :T, :d]],
|
188
|
+
['print_queue_status', 'qstat', 0, 'Show the current status of the queue', [], [:U, :u]],
|
189
|
+
["readout", "ro", 0, 'Print a simple text readout of all data from the runs.', [], []],
|
190
|
+
["reference", "ri", 1, "Print out documentation for the given class or method. #{rihelp}", ['ruby_class_or_method'], []],
|
191
|
+
["resubmit", "resub", 0, 'Resubmit the filtered runs to be simulated. All parameters will be the same bar those altered by the p option.', [], [:p, :n, :W, :k, :v, :T, :d, :J, :f, :j]],
|
192
|
+
["run_command", "rc", 1, 'Cause all filtered runs to evaluate the given string.', ['command string'], [:U, :f, :j, :N]],
|
193
|
+
["runner_eval", "ev", 1, 'Cause the runner (the CodeRunner instance) to evaluate the given string.', ['command string'], [:U, :N, :j, :f]],
|
194
|
+
["scan", "scan", 1, 'Submit a simple scan. For full details of how to write a simple scan, see online documentation (coderunner.sourceforge.net).', ['scan string'], [:p, :n, :W, :k, :v, :T, :d]],
|
195
|
+
["show_values_of", "shvl", 1, 'Evaluate the expression for each run and print a unique sorted list of them.', ['expression'], [:U, :N, :j, :f]],
|
196
|
+
['start_launcher', 'launch', 2, 'Start a simple job launcher for non batch systems.', ['refresh_interval', 'max_queue_size'], []],
|
197
|
+
["status", "st", 0, 'Print out a summary of the status of the filtered runs.', [], [:U, :N, :j, :f, :O]],
|
198
|
+
["status_with_comments", "sc", 0, 'Print a list of ids with their status and any comments.', [], [:U, :N, :j, :f, :O]],
|
199
|
+
["status_loop", "sl", 0, 'Loop, updating the filtered runs, then printing out a summary of the status of the filtered runs. ', [], [:U, :N, :j, :f, :O]],
|
200
|
+
["status_loop_running", "slr", 0, 'Loop, updating and then printing out a summary of runs which are currently running.', [], [:U, :N, :O]],
|
201
|
+
["submit", "sub", 0, 'Submit a run to be simulated.', [], [:p, :n, :W, :k, :v, :T, :d, :J]],
|
202
|
+
["submit_command", "subcom", 2, 'Submit an arbitrary shell command to the batch queue.', ['job name', 'command'], [:n, :W, :v, :T, :d]],
|
203
|
+
["write_graph", "wg", 1, 'Write a graph to disk.', ['filename'], [:G, :g, :w, :O, :U, :N, :j, :f]],
|
204
|
+
["write_report", "wr", 0, 'Writes out a summary of a given run in a LaTeX document.', [], [:j, :f, :U, :N]],
|
205
|
+
]
|
206
|
+
|
207
|
+
# This lists all the commands available on the command line. The first two items in each array indicate the long and short form of the command, and the third indicates the number of arguments the command takes. They are all implemented as Code Runner class methods (the method is named after the long form). The short form of the command is available as a global method in Code Runner interactive mode.
|
208
|
+
|
209
|
+
COMMANDS = COMMANDS_WITH_HELP.map{|arr| arr.slice(0..2)}
|
210
|
+
|
211
|
+
# A lookup hash which gives the appropriate short command option (copt) key for a given long command flag
|
212
|
+
|
213
|
+
CLF_TO_SHORT_COPTS = COMMAND_LINE_FLAGS.inject({}){ |hash, (long, short, _req)|
|
214
|
+
letter = short[1,1]
|
215
|
+
hash[long] = letter.to_sym
|
216
|
+
hash
|
217
|
+
}
|
218
|
+
|
219
|
+
# specifying flag sets a bool to be true
|
220
|
+
|
221
|
+
CLF_BOOLS = [:H, :U, :u, :A, :a, :T, :N, :q, :z, :d, :J, :replace_existing]
|
222
|
+
# CLF_BOOLS = [:s, :r, :D, :H, :U, :u, :L, :l, :A, :a, :T, :N,:V, :q, :z, :d] #
|
223
|
+
|
224
|
+
CLF_INVERSE_BOOLS = [:k] # specifying flag sets a bool to be false
|
225
|
+
|
226
|
+
# a look up hash that converts the long form of the command options to the short form (NB command options e.g. use_large_cache have a different form from command line flags e.g. --use-large-cache)
|
227
|
+
|
228
|
+
LONG_TO_SHORT = COMMAND_LINE_FLAGS.inject({}){ |hash, (long, short, _req)|
|
229
|
+
letter = short[1,1]
|
230
|
+
hash[long[2, long.size].gsub(/\-/, '_').to_sym] = letter.to_sym
|
231
|
+
hash
|
232
|
+
}
|
270
233
|
|
271
234
|
# A look up table that converts long only command line options (in LONG_COMMAND_LINE_OPTIONS) to the equivalent CodeRunner command option
|
272
235
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
236
|
+
CLF_TO_LONG = LONG_COMMAND_LINE_OPTIONS.inject({}) do |hash, (long, _short, _req, _help)|
|
237
|
+
option = long[2, long.size].gsub(/\-/, '_').to_sym
|
238
|
+
hash[long] = option
|
239
|
+
hash
|
240
|
+
end
|
241
|
+
|
242
|
+
#Converts a command line flag opt with value arg to a command option which is stored in copts
|
243
|
+
|
244
|
+
def self.process_command_line_option(opt, arg, copts)
|
245
|
+
case opt
|
246
|
+
when "--change-directory"
|
247
|
+
copts[:c] = arg.to_i
|
248
|
+
when "--delete"
|
249
|
+
copts[:x] = arg.to_i
|
250
|
+
when "--graph"
|
251
|
+
copts[:G].push arg
|
252
|
+
when "--run-graph"
|
253
|
+
copts[:g].push arg
|
291
254
|
when "--other-folder"
|
292
255
|
if copts[:Y]
|
293
256
|
if copts[:Y].kind_of? String
|
@@ -298,103 +261,103 @@ EOF
|
|
298
261
|
else
|
299
262
|
copts[:Y] = arg
|
300
263
|
end
|
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
|
-
|
264
|
+
# when "--cancel"
|
265
|
+
# copts[:K] = arg.to_i
|
266
|
+
when "--multiple-processes"
|
267
|
+
copts[:M] = arg.to_i
|
268
|
+
when "--film"
|
269
|
+
copts[:F] = (arg or true)
|
270
|
+
when "--recheck"
|
271
|
+
copts[:R] = arg.to_i
|
272
|
+
when "--use-large-cache-but-recheck-incomplete"
|
273
|
+
copts[:U] = true
|
274
|
+
copts[:u]=true
|
275
|
+
when "--wall-mins"
|
276
|
+
copts[:W] = arg.to_i
|
277
|
+
when "--use-component"
|
278
|
+
copts[:h] = (arg and arg =~ /\S/) ? arg.to_sym : :component
|
279
|
+
when "--terminal-size"
|
280
|
+
array = eval arg
|
281
|
+
ENV['ROWS'], ENV['COLS'] = array[0].to_s, array[1].to_s
|
282
|
+
when "--interactive-mode"
|
283
|
+
@@interactive_mode = true
|
284
|
+
when "--parameters"
|
285
|
+
copts[:p].push arg
|
286
|
+
else
|
287
|
+
if CLF_BOOLS.include? CLF_TO_SHORT_COPTS[opt]
|
288
|
+
copts[CLF_TO_SHORT_COPTS[opt]] = true
|
289
|
+
elsif CLF_INVERSE_BOOLS.include? CLF_TO_SHORT_COPTS[opt]
|
290
|
+
copts[CLF_TO_SHORT_COPTS[opt]] = false
|
291
|
+
elsif CLF_TO_SHORT_COPTS[opt] # Applies to most options
|
292
|
+
copts[CLF_TO_SHORT_COPTS[opt]] = arg
|
293
|
+
elsif CLF_BOOLS.include? CLF_TO_LONG[opt]
|
294
|
+
copts[CLF_TO_LONG[opt]] = true
|
295
|
+
elsif CLF_INVERSE_BOOLS.include? CLF_TO_LONG[opt]
|
296
|
+
copts[CLF_TO_LONG[opt]] = false
|
297
|
+
elsif CODE_COMMAND_OPTIONS.map{|o| o[0]}.include? opt
|
298
|
+
begin
|
299
|
+
#copts[:code_copts] ||= {}
|
300
|
+
copts[
|
301
|
+
#CLF_TO_LONG[opt].to_s.sub('_options','').to_sym
|
302
|
+
CLF_TO_LONG[opt]
|
303
|
+
] = eval(arg)
|
304
|
+
rescue SyntaxError => err
|
305
|
+
eputs "\nOption #{opt} must be a hash\n\n"
|
306
|
+
raise err
|
307
|
+
end
|
308
|
+
|
309
|
+
elsif CLF_TO_LONG[opt]
|
310
|
+
copts[CLF_TO_LONG[opt]] = arg
|
311
|
+
else
|
312
|
+
raise "Unknown command line argument: #{opt}"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
copts
|
316
|
+
end
|
317
|
+
|
318
|
+
# Default command options; they are usually determined by the command line flags, but can be set independently
|
319
|
+
|
320
|
+
DEFAULT_COMMAND_OPTIONS = {}
|
321
|
+
|
322
|
+
def self.set_default_command_options_from_command_line
|
323
|
+
|
324
|
+
#some defaults
|
325
|
+
# DEFAULT_COMMAND_OPTIONS[:p] ||= {}
|
326
|
+
DEFAULT_COMMAND_OPTIONS[:v] ||= ""
|
327
|
+
#DEFAULT_COMMAND_OPTIONS[:n] ||= "1"
|
328
|
+
DEFAULT_COMMAND_OPTIONS[:G] = []
|
329
|
+
DEFAULT_COMMAND_OPTIONS[:g] = []
|
330
|
+
DEFAULT_COMMAND_OPTIONS[:k] = true
|
331
|
+
DEFAULT_COMMAND_OPTIONS[:h] ||= :real
|
332
|
+
DEFAULT_COMMAND_OPTIONS[:p] = []
|
333
|
+
|
334
|
+
# ep COMMAND_LINE_FLAGS
|
335
|
+
opts = GetoptLong.new(*(COMMAND_LINE_FLAGS + LONG_COMMAND_LINE_FLAGS))
|
336
|
+
opts.each do |opt, arg|
|
337
|
+
process_command_line_option(opt, arg, DEFAULT_COMMAND_OPTIONS)
|
338
|
+
end
|
339
|
+
#raise "\n\nCannot use large cache ('-U' or '-u' ) if submitting runs" if DEFAULT_COMMAND_OPTIONS[:U] and (DEFAULT_COMMAND_OPTIONS[:s] or DEFAULT_COMMAND_OPTIONS[:P])
|
340
|
+
|
341
|
+
|
342
|
+
if DEFAULT_COMMAND_OPTIONS[:z]
|
343
|
+
Log.log_file = Dir.pwd + '/.cr_logfile.txt'
|
344
|
+
Log.clean_up
|
345
|
+
else
|
346
|
+
Log.log_file = nil
|
347
|
+
# puts Log.log_file
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def self.run_script
|
352
|
+
set_default_command_options_from_command_line
|
353
|
+
if DEFAULT_COMMAND_OPTIONS[:Z]
|
354
|
+
DEFAULT_COMMAND_OPTIONS.absorb(eval(DEFAULT_COMMAND_OPTIONS[:Z]))
|
355
|
+
puts "Begin Output"
|
356
|
+
end
|
357
|
+
command = COMMANDS.find{|com| com.slice(0..1).include? ARGV[0]}
|
358
|
+
raise "\n-------------------\nCommand #{ARGV[0].inspect} not found: try 'coderunner man' for help\n-------------------\n" unless command
|
359
|
+
send(command[0].to_sym, *ARGV.values_at(*(1...(1+command[2])).to_a))
|
360
|
+
end
|
398
361
|
|
399
362
|
|
400
363
|
end
|
@@ -415,34 +378,34 @@ do_profile = (ENV['CODE_RUNNER_PROFILE'] and ENV['CODE_RUNNER_PROFILE'].size > 0
|
|
415
378
|
|
416
379
|
|
417
380
|
if do_profile
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
381
|
+
begin
|
382
|
+
require 'ruby-prof'
|
383
|
+
rescue LoadError
|
384
|
+
eputs "Please install ruby-prof using ' $ gem install ruby-prof'"
|
385
|
+
exit
|
386
|
+
end
|
387
|
+
|
388
|
+
# Profile the code
|
389
|
+
RubyProf.start
|
427
390
|
end
|
428
391
|
####################
|
429
392
|
CodeRunner.run_script if $0 == __FILE__
|
430
393
|
###################
|
431
394
|
|
432
395
|
if do_profile
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
396
|
+
result = RubyProf.stop
|
397
|
+
|
398
|
+
# Print a flat profile to text
|
399
|
+
case ENV['CODE_RUNNER_PROFILE']
|
400
|
+
when /html/i
|
401
|
+
printer = RubyProf::GraphHtmlPrinter.new(result)
|
402
|
+
when /graph/i
|
403
|
+
printer = RubyProf::GraphPrinter.new(result)
|
404
|
+
when /txt/i
|
405
|
+
printer = RubyProf::FlatPrinter.new(result)
|
406
|
+
else
|
407
|
+
raise "CODE_RUNNER_PROFILE should be 'html', 'graph' or 'txt'"
|
408
|
+
end
|
409
|
+
|
410
|
+
printer.print($stdout, {})
|
448
411
|
end
|