carray 1.3.5 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSES +22 -0
- data/README.md +18 -21
- data/Rakefile +31 -0
- data/carray.gemspec +13 -26
- data/{ca_iter_block.c → ext/ca_iter_block.c} +13 -13
- data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +16 -16
- data/{ca_iter_window.c → ext/ca_iter_window.c} +10 -10
- data/{ca_obj_array.c → ext/ca_obj_array.c} +60 -55
- data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +12 -12
- data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +7 -7
- data/{ca_obj_block.c → ext/ca_obj_block.c} +42 -42
- data/{ca_obj_fake.c → ext/ca_obj_fake.c} +7 -7
- data/{ca_obj_farray.c → ext/ca_obj_farray.c} +18 -18
- data/{ca_obj_field.c → ext/ca_obj_field.c} +15 -15
- data/{ca_obj_grid.c → ext/ca_obj_grid.c} +27 -27
- data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +9 -9
- data/{ca_obj_object.c → ext/ca_obj_object.c} +37 -37
- data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +1 -1
- data/{ca_obj_refer.c → ext/ca_obj_refer.c} +33 -33
- data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +43 -43
- data/{ca_obj_select.c → ext/ca_obj_select.c} +2 -2
- data/{ca_obj_shift.c → ext/ca_obj_shift.c} +23 -23
- data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +23 -23
- data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +55 -55
- data/{ca_obj_window.c → ext/ca_obj_window.c} +26 -26
- data/{carray.h → ext/carray.h} +77 -51
- data/{carray_access.c → ext/carray_access.c} +133 -91
- data/{carray_attribute.c → ext/carray_attribute.c} +12 -12
- data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +0 -0
- data/{carray_cast.c → ext/carray_cast.c} +6 -6
- data/{carray_cast_func.rb → ext/carray_cast_func.rb} +0 -0
- data/{carray_class.c → ext/carray_class.c} +0 -0
- data/{carray_conversion.c → ext/carray_conversion.c} +11 -13
- data/{carray_copy.c → ext/carray_copy.c} +19 -19
- data/{carray_core.c → ext/carray_core.c} +2 -2
- data/ext/carray_data_type.c +66 -0
- data/{carray_element.c → ext/carray_element.c} +9 -9
- data/{carray_generate.c → ext/carray_generate.c} +67 -1
- data/{carray_iterator.c → ext/carray_iterator.c} +40 -38
- data/{carray_loop.c → ext/carray_loop.c} +24 -24
- data/{carray_mask.c → ext/carray_mask.c} +17 -6
- data/{carray_math.rb → ext/carray_math.rb} +25 -25
- data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +0 -0
- data/{carray_numeric.c → ext/carray_numeric.c} +1 -1
- data/{carray_operator.c → ext/carray_operator.c} +32 -9
- data/{carray_order.c → ext/carray_order.c} +2 -153
- data/{carray_sort_addr.c → ext/carray_sort_addr.c} +0 -0
- data/{carray_stat.c → ext/carray_stat.c} +5 -5
- data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +23 -23
- data/{carray_test.c → ext/carray_test.c} +22 -21
- data/{carray_undef.c → ext/carray_undef.c} +0 -0
- data/{carray_utils.c → ext/carray_utils.c} +0 -0
- data/{extconf.rb → ext/extconf.rb} +0 -5
- data/{mkmath.rb → ext/mkmath.rb} +12 -2
- data/{ruby_carray.c → ext/ruby_carray.c} +9 -2
- data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +0 -0
- data/{ruby_float_func.c → ext/ruby_float_func.c} +0 -0
- data/{version.h → ext/version.h} +5 -5
- data/{version.rb → ext/version.rb} +0 -0
- data/lib/carray.rb +49 -7
- data/lib/carray/{base/autoload.rb → autoload.rb} +48 -6
- data/lib/carray/autoload/autoload_base.rb +1 -5
- data/lib/carray/autoload/autoload_gem_cairo.rb +9 -0
- data/lib/carray/autoload/autoload_gem_ffi.rb +9 -0
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +2 -0
- data/lib/carray/autoload/autoload_gem_io_csv.rb +14 -0
- data/lib/carray/autoload/autoload_gem_io_pg.rb +6 -0
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +12 -0
- data/lib/carray/autoload/autoload_gem_narray.rb +10 -0
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +15 -0
- data/lib/carray/autoload/autoload_gem_opencv.rb +16 -0
- data/lib/carray/autoload/autoload_gem_random.rb +8 -0
- data/lib/carray/autoload/autoload_gem_rmagick.rb +23 -0
- data/lib/carray/autoload/{autoload_graphics_zimg.rb → autoload_gem_zimg.rb} +0 -0
- data/lib/carray/basic.rb +193 -0
- data/lib/carray/compose.rb +291 -0
- data/lib/carray/construct.rb +445 -0
- data/lib/carray/convert.rb +115 -0
- data/lib/carray/{base/inspect.rb → inspect.rb} +6 -6
- data/lib/carray/io/imagemagick.rb +1 -1
- data/lib/carray/{base/iterator.rb → iterator.rb} +3 -3
- data/lib/carray/mask.rb +91 -0
- data/lib/carray/{base/math.rb → math.rb} +17 -47
- data/lib/carray/math/histogram.rb +7 -7
- data/lib/carray/mkmf.rb +8 -0
- data/lib/carray/object/ca_obj_pack.rb +8 -8
- data/lib/carray/obsolete.rb +272 -0
- data/lib/carray/ordering.rb +157 -0
- data/lib/carray/{base/serialize.rb → serialize.rb} +28 -53
- data/lib/carray/string.rb +190 -0
- data/lib/carray/{base/struct.rb → struct.rb} +20 -20
- data/lib/carray/{io/table.rb → table.rb} +1 -9
- data/lib/carray/testing.rb +56 -0
- data/lib/carray/time.rb +78 -0
- data/lib/carray/transform.rb +100 -0
- data/misc/Methods.ja.md +182 -0
- data/{NOTE → misc/NOTE} +0 -0
- data/test/test_ALL.rb +0 -2
- data/test/test_order.rb +7 -7
- data/test/test_ref_store.rb +13 -13
- data/test/test_stat.rb +7 -15
- data/{devel → utils}/guess_shape.rb +0 -0
- data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
- metadata +100 -254
- data/COPYING +0 -56
- data/GPL +0 -340
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -33
- data/LEGAL +0 -50
- data/TODO +0 -5
- data/carray_random.c +0 -531
- data/ext/calculus/carray_calculus.c +0 -931
- data/ext/calculus/carray_interp.c +0 -358
- data/ext/calculus/extconf.rb +0 -12
- data/ext/calculus/lib/autoload/autoload_math_calculus.rb +0 -2
- data/ext/calculus/lib/math/calculus.rb +0 -119
- data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
- data/ext/fortio/extconf.rb +0 -3
- data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +0 -5
- data/ext/fortio/lib/carray/io/fortran_format.rb +0 -43
- data/ext/fortio/lib/fortio.rb +0 -3
- data/ext/fortio/lib/fortio/fortran_format.rb +0 -605
- data/ext/fortio/lib/fortio/fortran_format.tab.rb +0 -536
- data/ext/fortio/lib/fortio/fortran_format.y +0 -215
- data/ext/fortio/lib/fortio/fortran_namelist.rb +0 -151
- data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +0 -470
- data/ext/fortio/lib/fortio/fortran_namelist.y +0 -213
- data/ext/fortio/lib/fortio/fortran_sequential.rb +0 -345
- data/ext/fortio/ruby_fortio.c +0 -182
- data/ext/fortio/test/test_H.rb +0 -5
- data/ext/fortio/test/test_T.rb +0 -7
- data/ext/fortio/test/test_fortran_format.rb +0 -86
- data/ext/fortio/test/test_namelist.rb +0 -25
- data/ext/fortio/test/test_namelist_write.rb +0 -10
- data/ext/fortio/test/test_sequential.rb +0 -13
- data/ext/fortio/test/test_sequential2.rb +0 -13
- data/ext/fortio/work/test.rb +0 -10
- data/ext/fortio/work/test_e.rb +0 -19
- data/ext/fortio/work/test_ep.rb +0 -10
- data/ext/fortio/work/test_parse.rb +0 -12
- data/ext/imagemap/carray_imagemap.c +0 -495
- data/ext/imagemap/doc/call_graph.dot +0 -28
- data/ext/imagemap/draw.c +0 -567
- data/ext/imagemap/extconf.rb +0 -13
- data/ext/imagemap/lib/autoload/autoload_graphics_imagemap.rb +0 -1
- data/ext/imagemap/lib/graphics/imagemap.rb +0 -273
- data/ext/imagemap/lib/image_map.rb +0 -4
- data/ext/imagemap/test/swath_index.rb +0 -83
- data/ext/imagemap/test/swath_warp.rb +0 -99
- data/ext/imagemap/test/test.rb +0 -23
- data/ext/imagemap/test/test_image.rb +0 -42
- data/ext/imagemap/test/test_line.rb +0 -14
- data/ext/imagemap/test/test_rotate.rb +0 -17
- data/ext/imagemap/test/test_triangle.rb +0 -20
- data/ext/imagemap/test/test_warp.rb +0 -26
- data/ext/mathfunc/extconf.rb +0 -18
- data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +0 -1
- data/ext/mathfunc/lib/math/mathfunc.rb +0 -15
- data/ext/mathfunc/test/test_hypot.rb +0 -5
- data/ext/mathfunc/test/test_j0.rb +0 -22
- data/ext/mathfunc/test/test_jn.rb +0 -8
- data/ext/mathfunc/test/test_sph.rb +0 -9
- data/ext/narray/README +0 -22
- data/ext/narray/ca_wrap_narray.c +0 -500
- data/ext/narray/carray_narray.c +0 -21
- data/ext/narray/extconf.rb +0 -57
- data/ext/narray/lib/autoload/autoload_math_narray.rb +0 -1
- data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +0 -11
- data/ext/narray/lib/math/narray.rb +0 -17
- data/ext/narray/lib/math/narray_miss.rb +0 -45
- data/lib/carray/autoload/autoload_graphics_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_io_sqlite3.rb +0 -12
- data/lib/carray/autoload/autoload_io_table.rb +0 -1
- data/lib/carray/autoload/autoload_math_interp.rb +0 -4
- data/lib/carray/base/basic.rb +0 -1090
- data/lib/carray/base/obsolete.rb +0 -131
- data/lib/carray/graphics/gnuplot.rb +0 -2131
- data/lib/carray/graphics/zimg.rb +0 -296
- data/lib/carray/io/csv.rb +0 -572
- data/lib/carray/io/pg.rb +0 -101
- data/lib/carray/io/sqlite3.rb +0 -215
- data/lib/carray/math/interp.rb +0 -57
- data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
- data/mt19937ar.c +0 -182
- data/mt19937ar.h +0 -86
- data/rdoc_main.rb +0 -27
- data/rdoc_math.rb +0 -5
- data/rdoc_stat.rb +0 -31
- data/test/test_narray.rb +0 -64
- data/test/test_random.rb +0 -15
- data/utils/create_rdoc.sh +0 -9
- data/utils/make_tgz.sh +0 -3
@@ -1,215 +0,0 @@
|
|
1
|
-
# ----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# carray/io/fortran_format.y
|
4
|
-
#
|
5
|
-
# This file is part of Ruby/CArray extension library.
|
6
|
-
# You can redistribute it and/or modify it under the terms of
|
7
|
-
# the Ruby Licence.
|
8
|
-
#
|
9
|
-
# Copyright (C) 2005 Hiroki Motoyoshi
|
10
|
-
#
|
11
|
-
# ----------------------------------------------------------------------------
|
12
|
-
|
13
|
-
#
|
14
|
-
# racc fortran_format.y -> fortan_format.tab.rb
|
15
|
-
#
|
16
|
-
|
17
|
-
class FortranFormatParser
|
18
|
-
|
19
|
-
rule
|
20
|
-
|
21
|
-
format :
|
22
|
-
format_string {
|
23
|
-
if val[0].size == 1 and val[0].first.is_a?(Group)
|
24
|
-
result = val[0].first
|
25
|
-
else
|
26
|
-
result = Group.new(1,val[0])
|
27
|
-
end
|
28
|
-
}
|
29
|
-
|
30
|
-
format_string :
|
31
|
-
format_spec { result = [val[0]] }
|
32
|
-
| format_string format_spec
|
33
|
-
{ result = val[0] + [val[1]] }
|
34
|
-
|
35
|
-
format_spec :
|
36
|
-
hollerith { result = val[0] }
|
37
|
-
| unrepeatable { result = val[0] }
|
38
|
-
| repeatable { result = val[0] }
|
39
|
-
| DIGITS repeatable
|
40
|
-
{ val[1].count = val[0]; result = val[1] }
|
41
|
-
|
42
|
-
hollerith : H { result = NodeH.new(*val[0]) }
|
43
|
-
|
44
|
-
unrepeatable :
|
45
|
-
STRING { result = NodeS.new(val[0]) }
|
46
|
-
| P { result = NodeP.new(val[0]) }
|
47
|
-
| Sp { result = NodeSp.new(val[0]) }
|
48
|
-
| B { result = NodeB.new(val[0]) }
|
49
|
-
| T { result = NodeT.new(val[0]) }
|
50
|
-
| TR { result = NodeTR.new(val[0]) }
|
51
|
-
| TL { result = NodeTL.new(val[0]) }
|
52
|
-
| '$' { result = Continue.new }
|
53
|
-
|
54
|
-
repeatable :
|
55
|
-
'(' format_string ')'
|
56
|
-
{ result = Group.new(1,val[1]) }
|
57
|
-
| fixed_point
|
58
|
-
| floating_point
|
59
|
-
| '/' { result = Flush.new(1) }
|
60
|
-
|
61
|
-
fixed_point :
|
62
|
-
X { result = NodeX.new(1) }
|
63
|
-
| A { result = NodeA.new(1, val[0]) }
|
64
|
-
| I { result = NodeI.new(1, *val[0]) }
|
65
|
-
| L { result = NodeL.new(1, *val[0]) }
|
66
|
-
| F { result = NodeF.new(1, *val[0]) }
|
67
|
-
|
68
|
-
floating_point :
|
69
|
-
E { result = NodeE.new(1, *val[0]) }
|
70
|
-
| ES { result = NodeES.new(1, *val[0]) }
|
71
|
-
| D { result = NodeE.new(1, *val[0]) }
|
72
|
-
| G { result = NodeG.new(1, *val[0]) }
|
73
|
-
| floating_point EXP
|
74
|
-
{ result = val[0]; result.exp = val[1] }
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
---- inner
|
79
|
-
|
80
|
-
def parse (str)
|
81
|
-
@scan = FortranFormatScanner.new(str)
|
82
|
-
@scale = 0
|
83
|
-
@continue = false
|
84
|
-
do_parse
|
85
|
-
end
|
86
|
-
|
87
|
-
def next_token
|
88
|
-
return @scan.yylex
|
89
|
-
end
|
90
|
-
|
91
|
-
---- header
|
92
|
-
|
93
|
-
require "strscan"
|
94
|
-
|
95
|
-
class FortranFormatScanner
|
96
|
-
|
97
|
-
def initialize (text)
|
98
|
-
@s = StringScanner.new(text)
|
99
|
-
end
|
100
|
-
|
101
|
-
def yylex
|
102
|
-
while @s.rest?
|
103
|
-
case
|
104
|
-
when @s.scan(/\A(ES|[FEDG])(\d+)\.(\d+)/i) ### {F|E|D|G|ES}w.d
|
105
|
-
return [
|
106
|
-
@s[1].upcase.to_sym,
|
107
|
-
[
|
108
|
-
@s[2].to_i,
|
109
|
-
@s[3].to_i
|
110
|
-
]
|
111
|
-
]
|
112
|
-
when @s.scan(/\AE(\d+)/i) ### Ed (for exponential)
|
113
|
-
return [
|
114
|
-
:EXP,
|
115
|
-
@s[1].to_i
|
116
|
-
]
|
117
|
-
when @s.scan(/\AI(\d+)(\.(\d+))?/i) ### Iw(.d)
|
118
|
-
return [
|
119
|
-
:I,
|
120
|
-
[
|
121
|
-
@s[1].to_i,
|
122
|
-
@s[3] ? @s[3].to_i : nil
|
123
|
-
]
|
124
|
-
]
|
125
|
-
when @s.scan(/\AL(\d+)?/i) ### L(w)
|
126
|
-
return [
|
127
|
-
:L,
|
128
|
-
@s[1] ? @s[1].to_i : nil
|
129
|
-
]
|
130
|
-
when @s.scan(/\AA(\d+)?/i) ### A(w)
|
131
|
-
return [
|
132
|
-
:A,
|
133
|
-
@s[1] ? @s[1].to_i : nil
|
134
|
-
]
|
135
|
-
when @s.scan(/\AX/i) ### X
|
136
|
-
return [
|
137
|
-
:X,
|
138
|
-
nil
|
139
|
-
]
|
140
|
-
when @s.scan(/\ATL(\d+)?/i) ### TLw
|
141
|
-
return [
|
142
|
-
:TL,
|
143
|
-
@s[1] ? @s[1].to_i : 1
|
144
|
-
]
|
145
|
-
when @s.scan(/\ATR(\d+)?/i) ### TRw
|
146
|
-
return [
|
147
|
-
:TR,
|
148
|
-
@s[1] ? @s[1].to_i : 1
|
149
|
-
]
|
150
|
-
when @s.scan(/\AT(\d+)?/i) ### Tw
|
151
|
-
return [
|
152
|
-
:T,
|
153
|
-
@s[1] ? @s[1].to_i : 1
|
154
|
-
]
|
155
|
-
when @s.scan(/\A([+-]?\d+)P/i) ### {+|-|}P
|
156
|
-
return [
|
157
|
-
:P,
|
158
|
-
@s[1].to_i
|
159
|
-
]
|
160
|
-
when @s.scan(/\AS[PS]?/i) ### S,SP,SS
|
161
|
-
return [
|
162
|
-
:Sp,
|
163
|
-
@s[0] =~ /SP/i ? true : false
|
164
|
-
]
|
165
|
-
when @s.scan(/\AB[NZ]/i) ### BN,BZ
|
166
|
-
return [
|
167
|
-
:B,
|
168
|
-
@s[0] =~ /BZ/i ? true : false
|
169
|
-
]
|
170
|
-
when @s.match?(/\A(\d+)?H/i) ### Hollerith
|
171
|
-
count = @s[1] ? @s[1].to_i : 1
|
172
|
-
if @s.scan(/\A(\d+)?H(.{#{count}})/)
|
173
|
-
return [
|
174
|
-
:H,
|
175
|
-
[count, @s[2]]
|
176
|
-
]
|
177
|
-
else
|
178
|
-
raise "invalid horeris descriptor"
|
179
|
-
end
|
180
|
-
when @s.scan(/\A'((?:''|[^'])*)'/) ### 'quoted string'
|
181
|
-
return [
|
182
|
-
:STRING,
|
183
|
-
@s[1].gsub(/''/, "'")
|
184
|
-
]
|
185
|
-
when @s.scan(/\A"((?:""|[^"])*)"/) ### 'double-quoted string'
|
186
|
-
return [
|
187
|
-
:STRING,
|
188
|
-
@s[1].gsub(/""/, '"')
|
189
|
-
]
|
190
|
-
when @s.scan(/\A(\d+)/) ### digits
|
191
|
-
return [
|
192
|
-
:DIGITS,
|
193
|
-
@s[1].to_i
|
194
|
-
]
|
195
|
-
when @s.scan(/\A([\(\)\/\$\:])/) ### {(|)|/|$}
|
196
|
-
return [
|
197
|
-
@s[1],
|
198
|
-
nil
|
199
|
-
]
|
200
|
-
when @s.scan(/:/)
|
201
|
-
raise("format descriptor ':' is not supported.")
|
202
|
-
when @s.scan(/\A,/) ### blank
|
203
|
-
next
|
204
|
-
when @s.scan(/\A\s+/) ### blank
|
205
|
-
next
|
206
|
-
else
|
207
|
-
raise "FortranFormat parse error\n\t#{@s.string}\n\t#{' '*@s.pos}^"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
end
|
213
|
-
|
214
|
-
---- footer
|
215
|
-
|
@@ -1,151 +0,0 @@
|
|
1
|
-
# ----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# carray/io/fortran_namelist.rb
|
4
|
-
#
|
5
|
-
# This file is part of Ruby/CArray extension library.
|
6
|
-
# You can redistribute it and/or modify it under the terms of
|
7
|
-
# the Ruby Licence.
|
8
|
-
#
|
9
|
-
# Copyright (C) 2005 Hiroki Motoyoshi
|
10
|
-
#
|
11
|
-
# ----------------------------------------------------------------------------
|
12
|
-
|
13
|
-
require "carray"
|
14
|
-
require "fortio/fortran_namelist.tab"
|
15
|
-
|
16
|
-
class FortranNamelistReader
|
17
|
-
|
18
|
-
def initialize (text)
|
19
|
-
@namelist = FortranNamelistParser.new.parse(text)
|
20
|
-
end
|
21
|
-
|
22
|
-
def read (name, out={})
|
23
|
-
name = name.downcase
|
24
|
-
unless nml = @namelist[name]
|
25
|
-
raise "no definition of namelist '#{name}'"
|
26
|
-
end
|
27
|
-
nml.each do |paramdef|
|
28
|
-
paramdef.set(out)
|
29
|
-
end
|
30
|
-
return out
|
31
|
-
end
|
32
|
-
|
33
|
-
def read_all
|
34
|
-
all = {}
|
35
|
-
@namelist.each do |name, nml|
|
36
|
-
all[name] = {}
|
37
|
-
read(name, all[name])
|
38
|
-
end
|
39
|
-
return all
|
40
|
-
end
|
41
|
-
|
42
|
-
attr_reader :namelist
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def fortran_namelist (name, out)
|
47
|
-
list = out.map{ |ident, value|
|
48
|
-
case value
|
49
|
-
when CArray
|
50
|
-
ident = "#{ident}(" + value.dim.map{|d| "1:#{d}" }.join(",") + ")"
|
51
|
-
value = value.flatten.to_a.join(",")
|
52
|
-
when Array
|
53
|
-
value = value.flatten.join(",")
|
54
|
-
when String
|
55
|
-
if value !~ /'/
|
56
|
-
value = "'" + value + "'"
|
57
|
-
else
|
58
|
-
value = '"' + value.gsub(/"/, '""') + '"'
|
59
|
-
end
|
60
|
-
when Float
|
61
|
-
value = value.to_s.sub(/e/, "d")
|
62
|
-
end
|
63
|
-
" #{ident} = #{value}"
|
64
|
-
}
|
65
|
-
return ["&#{name}", list.join(",\n") + " /", ""].join("\n")
|
66
|
-
end
|
67
|
-
|
68
|
-
def fortran_namelist_read (io, name=nil, out={})
|
69
|
-
case io
|
70
|
-
when String
|
71
|
-
text = io
|
72
|
-
else
|
73
|
-
text = io.read
|
74
|
-
end
|
75
|
-
if name
|
76
|
-
return FortranNamelistReader.new(text).read(name, out)
|
77
|
-
else
|
78
|
-
return FortranNamelistReader.new(text).read_all()
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def fortran_namelist_write (io, name, out)
|
83
|
-
io << fortran_namelist(name, out)
|
84
|
-
return io
|
85
|
-
end
|
86
|
-
|
87
|
-
class FortranNamelistParser
|
88
|
-
|
89
|
-
ParamDef = Struct.new(:ident, :array_spec, :rval)
|
90
|
-
class ParamDef
|
91
|
-
def set (hash)
|
92
|
-
case hash[ident]
|
93
|
-
when CArray
|
94
|
-
hash[ident].attach { |ca|
|
95
|
-
if array_spec
|
96
|
-
crv = rval.to_ca
|
97
|
-
if crv.search(nil)
|
98
|
-
mask = crv.ne(nil)
|
99
|
-
ca[*array_spec][0...crv.size][mask] = crv[mask]
|
100
|
-
elsif ca[*array_spec].is_a?(CArray)
|
101
|
-
ca[*array_spec][0...crv.size] = crv
|
102
|
-
else
|
103
|
-
ca[*array_spec] = rval.first
|
104
|
-
end
|
105
|
-
else
|
106
|
-
if rval.is_a?(Array) and rval.size == 1
|
107
|
-
ca[0] = rval.first
|
108
|
-
else
|
109
|
-
ca[0...rval.size] = rval
|
110
|
-
end
|
111
|
-
end
|
112
|
-
}
|
113
|
-
when Array
|
114
|
-
if array_spec
|
115
|
-
if array_spec.first.is_a?(Integer) and rval.size == 1
|
116
|
-
hash[ident][*array_spec] = rval.first
|
117
|
-
else
|
118
|
-
hash[ident][*array_spec] = rval.first
|
119
|
-
end
|
120
|
-
else
|
121
|
-
if rval.is_a?(Array) and rval.size == 1
|
122
|
-
hash[ident][0] = rval.first
|
123
|
-
else
|
124
|
-
hash[ident].clear
|
125
|
-
hash[ident].push(*rval)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
else
|
129
|
-
if array_spec
|
130
|
-
hash[ident] = []
|
131
|
-
set(hash)
|
132
|
-
else
|
133
|
-
if rval.is_a?(Array) and rval.size == 1
|
134
|
-
hash[ident] = rval.first
|
135
|
-
else
|
136
|
-
hash[ident] = rval
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
def inspect
|
142
|
-
if array_spec
|
143
|
-
return "#{ident}(#{array_spec.inspect}) = #{rval.inspect}"
|
144
|
-
else
|
145
|
-
return "#{ident} = #{rval}"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
@@ -1,470 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.6
|
4
|
-
# from Racc grammer file "".
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'racc/parser.rb'
|
8
|
-
|
9
|
-
|
10
|
-
require "strscan"
|
11
|
-
require "stringio"
|
12
|
-
|
13
|
-
class FortranNamelistScanner
|
14
|
-
|
15
|
-
def initialize (text)
|
16
|
-
@s = StringScanner.new(text)
|
17
|
-
@in_namelist = false
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_accessor :in_namelist
|
21
|
-
|
22
|
-
def yylex
|
23
|
-
while @s.rest?
|
24
|
-
unless @in_namelist
|
25
|
-
case
|
26
|
-
when @s.scan(/\A([\$&])/) ### {$|&}
|
27
|
-
@in_namelist = true
|
28
|
-
return [
|
29
|
-
@s[0],
|
30
|
-
nil
|
31
|
-
]
|
32
|
-
when @s.scan(/\A[^\$&]/)
|
33
|
-
next
|
34
|
-
end
|
35
|
-
else
|
36
|
-
case
|
37
|
-
when @s.scan(/\A[+-]?(\d+)\.(\d+)?([ED][+-]?(\d+))?/i) ### float
|
38
|
-
return [ ### 1.2E+3, 1.E+3, 1.2E3
|
39
|
-
:FLOAT, ### 1.2, 1.
|
40
|
-
@s[0].sub(/D/i,'e').sub(/\.e/,".0e").to_f
|
41
|
-
]
|
42
|
-
when @s.scan(/\A[+-]?\.(\d+)([ED][+-]?(\d+))?/i) ### float
|
43
|
-
return [ ### .2E+3, -.2E+3, .2E3
|
44
|
-
:FLOAT, ### .2, -.2
|
45
|
-
@s[0].sub(/D/i,'e').sub(/\./, '0.').to_f
|
46
|
-
]
|
47
|
-
when @s.scan(/\A[+-]?(\d+)[ED][+-]?(\d+)/i) ### float
|
48
|
-
return [ ### 12E+3, 12E3, 0E0
|
49
|
-
:FLOAT,
|
50
|
-
@s[0].sub(/D/i,'e').to_f
|
51
|
-
]
|
52
|
-
when @s.scan(/\A[\-\+]?\d+/) ### digits
|
53
|
-
return [
|
54
|
-
:DIGITS,
|
55
|
-
Integer(@s[0])
|
56
|
-
]
|
57
|
-
when @s.scan(/\A'((?:''|[^'])*)'/) ### 'quoted string'
|
58
|
-
return [
|
59
|
-
:STRING,
|
60
|
-
@s[1].gsub(/''/, "'")
|
61
|
-
]
|
62
|
-
when @s.scan(/\A"((?:""|[^"])*)"/) ### 'double-quoted string'
|
63
|
-
return [
|
64
|
-
:STRING,
|
65
|
-
@s[1].gsub(/""/, '"')
|
66
|
-
]
|
67
|
-
when @s.scan(/\A,/) ### ,
|
68
|
-
@s.scan(/\A\s+/)
|
69
|
-
while @s.scan(/\A\n\s*/) or @s.scan(/\A\![^\n]*/)
|
70
|
-
### skip comment
|
71
|
-
end
|
72
|
-
if @s.match?(/\A[a-z]\w*/i) or @s.match?(/\A[\&\$\/\!]/)
|
73
|
-
return [
|
74
|
-
:COMMA,
|
75
|
-
nil
|
76
|
-
]
|
77
|
-
elsif @s.match?(/\A,/)
|
78
|
-
return [
|
79
|
-
:NIL,
|
80
|
-
nil
|
81
|
-
]
|
82
|
-
else
|
83
|
-
return [
|
84
|
-
',',
|
85
|
-
nil
|
86
|
-
]
|
87
|
-
end
|
88
|
-
when @s.scan(/\A[\$&\/=\(\):*]/) ### {$|&|/|,|=|(|)|:|*}
|
89
|
-
return [
|
90
|
-
@s[0],
|
91
|
-
nil
|
92
|
-
]
|
93
|
-
when @s.scan(/\A[a-z]\w*/i) ### IDENT
|
94
|
-
return [
|
95
|
-
:IDENT,
|
96
|
-
@s[0]
|
97
|
-
]
|
98
|
-
when @s.scan(/\A\s+/) ### blank
|
99
|
-
next
|
100
|
-
when @s.scan(/\A![^\n]*?\n/) ### comment
|
101
|
-
next
|
102
|
-
when @s.scan(/\A\n/) ### newline
|
103
|
-
next
|
104
|
-
else
|
105
|
-
@s.rest =~ /\A(.*)$/
|
106
|
-
raise "FortranFormat parse error\n\t#{$1}\n\t^"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
class FortranNamelistParser < Racc::Parser
|
115
|
-
|
116
|
-
module_eval(<<'...end fortran_namelist.y/module_eval...', 'fortran_namelist.y', 94)
|
117
|
-
|
118
|
-
def parse (str)
|
119
|
-
@scan = FortranNamelistScanner.new(str)
|
120
|
-
@root = {}
|
121
|
-
do_parse
|
122
|
-
return @root
|
123
|
-
end
|
124
|
-
|
125
|
-
def next_token
|
126
|
-
return @scan.yylex
|
127
|
-
end
|
128
|
-
|
129
|
-
...end fortran_namelist.y/module_eval...
|
130
|
-
##### State transition tables begin ###
|
131
|
-
|
132
|
-
racc_action_table = [
|
133
|
-
38, 28, 41, 36, 24, 25, 11, 22, 36, 24,
|
134
|
-
25, 35, 22, 39, 24, 25, 35, 22, 28, 24,
|
135
|
-
25, 1, 32, 2, 22, 18, 24, 25, 19, 11,
|
136
|
-
20, 21, 14, 22, 29, 24, 25, 15, 1, 34,
|
137
|
-
2, 13, 11, 40, 8, 7, 29, 45, 46, 47,
|
138
|
-
6, 29, 33 ]
|
139
|
-
|
140
|
-
racc_action_check = [
|
141
|
-
29, 46, 34, 48, 34, 34, 18, 46, 23, 46,
|
142
|
-
46, 48, 48, 29, 48, 48, 23, 23, 14, 23,
|
143
|
-
23, 4, 19, 4, 14, 12, 14, 14, 12, 12,
|
144
|
-
12, 12, 11, 36, 15, 36, 36, 11, 0, 22,
|
145
|
-
0, 8, 5, 30, 3, 2, 38, 39, 40, 45,
|
146
|
-
1, 47, 20 ]
|
147
|
-
|
148
|
-
racc_action_pointer = [
|
149
|
-
33, 44, 39, 44, 16, 36, nil, nil, 41, nil,
|
150
|
-
nil, 28, 23, nil, 12, 22, nil, nil, 0, 16,
|
151
|
-
46, nil, 26, 5, nil, nil, nil, nil, nil, -3,
|
152
|
-
33, nil, nil, nil, -10, nil, 21, nil, 34, 35,
|
153
|
-
44, nil, nil, nil, nil, 46, -5, 39, 0, nil ]
|
154
|
-
|
155
|
-
racc_action_default = [
|
156
|
-
-31, -31, -31, -31, -1, -31, -4, -5, -31, -2,
|
157
|
-
-11, -31, -31, 50, -31, -31, -3, -12, -14, -7,
|
158
|
-
-6, -8, -25, -15, -24, -26, -17, -22, -21, -27,
|
159
|
-
-31, -13, -9, -10, -31, -19, -31, -18, -31, -31,
|
160
|
-
-31, -25, -23, -20, -29, -28, -31, -31, -16, -30 ]
|
161
|
-
|
162
|
-
racc_goto_table = [
|
163
|
-
23, 30, 37, 10, 3, 16, 12, 42, 9, nil,
|
164
|
-
17, nil, nil, nil, nil, 43, 31, nil, nil, nil,
|
165
|
-
nil, nil, nil, nil, 44, nil, nil, 37, nil, nil,
|
166
|
-
nil, nil, 48, 49 ]
|
167
|
-
|
168
|
-
racc_goto_check = [
|
169
|
-
7, 8, 9, 6, 1, 5, 4, 10, 1, nil,
|
170
|
-
6, nil, nil, nil, nil, 9, 6, nil, nil, nil,
|
171
|
-
nil, nil, nil, nil, 8, nil, nil, 9, nil, nil,
|
172
|
-
nil, nil, 7, 8 ]
|
173
|
-
|
174
|
-
racc_goto_pointer = [
|
175
|
-
nil, 4, nil, nil, 1, -7, -2, -14, -14, -21,
|
176
|
-
-27 ]
|
177
|
-
|
178
|
-
racc_goto_default = [
|
179
|
-
nil, nil, 4, 5, nil, nil, nil, nil, nil, 26,
|
180
|
-
27 ]
|
181
|
-
|
182
|
-
racc_reduce_table = [
|
183
|
-
0, 0, :racc_error,
|
184
|
-
1, 18, :_reduce_none,
|
185
|
-
2, 18, :_reduce_none,
|
186
|
-
3, 19, :_reduce_3,
|
187
|
-
2, 20, :_reduce_4,
|
188
|
-
2, 20, :_reduce_5,
|
189
|
-
1, 22, :_reduce_none,
|
190
|
-
1, 22, :_reduce_none,
|
191
|
-
1, 22, :_reduce_none,
|
192
|
-
2, 22, :_reduce_9,
|
193
|
-
2, 22, :_reduce_10,
|
194
|
-
1, 21, :_reduce_11,
|
195
|
-
2, 21, :_reduce_12,
|
196
|
-
3, 21, :_reduce_13,
|
197
|
-
2, 21, :_reduce_14,
|
198
|
-
3, 23, :_reduce_15,
|
199
|
-
6, 23, :_reduce_16,
|
200
|
-
1, 24, :_reduce_17,
|
201
|
-
2, 24, :_reduce_18,
|
202
|
-
2, 24, :_reduce_19,
|
203
|
-
3, 24, :_reduce_20,
|
204
|
-
1, 24, :_reduce_21,
|
205
|
-
1, 26, :_reduce_22,
|
206
|
-
3, 26, :_reduce_23,
|
207
|
-
1, 27, :_reduce_none,
|
208
|
-
1, 27, :_reduce_none,
|
209
|
-
1, 27, :_reduce_none,
|
210
|
-
1, 25, :_reduce_27,
|
211
|
-
3, 25, :_reduce_28,
|
212
|
-
3, 25, :_reduce_29,
|
213
|
-
5, 25, :_reduce_30 ]
|
214
|
-
|
215
|
-
racc_reduce_n = 31
|
216
|
-
|
217
|
-
racc_shift_n = 50
|
218
|
-
|
219
|
-
racc_token_table = {
|
220
|
-
false => 0,
|
221
|
-
:error => 1,
|
222
|
-
:COMMA => 2,
|
223
|
-
"," => 3,
|
224
|
-
"=" => 4,
|
225
|
-
"&" => 5,
|
226
|
-
:IDENT => 6,
|
227
|
-
"$" => 7,
|
228
|
-
"/" => 8,
|
229
|
-
"(" => 9,
|
230
|
-
")" => 10,
|
231
|
-
:NIL => 11,
|
232
|
-
:DIGITS => 12,
|
233
|
-
"*" => 13,
|
234
|
-
:STRING => 14,
|
235
|
-
:FLOAT => 15,
|
236
|
-
":" => 16 }
|
237
|
-
|
238
|
-
racc_nt_base = 17
|
239
|
-
|
240
|
-
racc_use_result_var = true
|
241
|
-
|
242
|
-
Racc_arg = [
|
243
|
-
racc_action_table,
|
244
|
-
racc_action_check,
|
245
|
-
racc_action_default,
|
246
|
-
racc_action_pointer,
|
247
|
-
racc_goto_table,
|
248
|
-
racc_goto_check,
|
249
|
-
racc_goto_default,
|
250
|
-
racc_goto_pointer,
|
251
|
-
racc_nt_base,
|
252
|
-
racc_reduce_table,
|
253
|
-
racc_token_table,
|
254
|
-
racc_shift_n,
|
255
|
-
racc_reduce_n,
|
256
|
-
racc_use_result_var ]
|
257
|
-
|
258
|
-
Racc_token_to_s_table = [
|
259
|
-
"$end",
|
260
|
-
"error",
|
261
|
-
"COMMA",
|
262
|
-
"\",\"",
|
263
|
-
"\"=\"",
|
264
|
-
"\"&\"",
|
265
|
-
"IDENT",
|
266
|
-
"\"$\"",
|
267
|
-
"\"/\"",
|
268
|
-
"\"(\"",
|
269
|
-
"\")\"",
|
270
|
-
"NIL",
|
271
|
-
"DIGITS",
|
272
|
-
"\"*\"",
|
273
|
-
"STRING",
|
274
|
-
"FLOAT",
|
275
|
-
"\":\"",
|
276
|
-
"$start",
|
277
|
-
"namelist_all",
|
278
|
-
"namelist",
|
279
|
-
"header",
|
280
|
-
"paramlist",
|
281
|
-
"tailer",
|
282
|
-
"paramdef",
|
283
|
-
"rvalues",
|
284
|
-
"array_spec",
|
285
|
-
"abbreb",
|
286
|
-
"constant" ]
|
287
|
-
|
288
|
-
Racc_debug_parser = false
|
289
|
-
|
290
|
-
##### State transition tables end #####
|
291
|
-
|
292
|
-
# reduce 0 omitted
|
293
|
-
|
294
|
-
# reduce 1 omitted
|
295
|
-
|
296
|
-
# reduce 2 omitted
|
297
|
-
|
298
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 32)
|
299
|
-
def _reduce_3(val, _values, result)
|
300
|
-
@root[val[0]] = val[1]; @scan.in_namelist = false
|
301
|
-
result
|
302
|
-
end
|
303
|
-
.,.,
|
304
|
-
|
305
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 35)
|
306
|
-
def _reduce_4(val, _values, result)
|
307
|
-
result = val[1].downcase
|
308
|
-
result
|
309
|
-
end
|
310
|
-
.,.,
|
311
|
-
|
312
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 36)
|
313
|
-
def _reduce_5(val, _values, result)
|
314
|
-
result = val[1].downcase
|
315
|
-
result
|
316
|
-
end
|
317
|
-
.,.,
|
318
|
-
|
319
|
-
# reduce 6 omitted
|
320
|
-
|
321
|
-
# reduce 7 omitted
|
322
|
-
|
323
|
-
# reduce 8 omitted
|
324
|
-
|
325
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 42)
|
326
|
-
def _reduce_9(val, _values, result)
|
327
|
-
on_error unless val[1] =~ /\Aend\Z/i
|
328
|
-
result
|
329
|
-
end
|
330
|
-
.,.,
|
331
|
-
|
332
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 43)
|
333
|
-
def _reduce_10(val, _values, result)
|
334
|
-
on_error unless val[1] =~ /\Aend\Z/i
|
335
|
-
result
|
336
|
-
end
|
337
|
-
.,.,
|
338
|
-
|
339
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 46)
|
340
|
-
def _reduce_11(val, _values, result)
|
341
|
-
result = [val[0]]
|
342
|
-
result
|
343
|
-
end
|
344
|
-
.,.,
|
345
|
-
|
346
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 48)
|
347
|
-
def _reduce_12(val, _values, result)
|
348
|
-
result = val[0] + [val[1]]
|
349
|
-
result
|
350
|
-
end
|
351
|
-
.,.,
|
352
|
-
|
353
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 50)
|
354
|
-
def _reduce_13(val, _values, result)
|
355
|
-
result = val[0] + [val[2]]
|
356
|
-
result
|
357
|
-
end
|
358
|
-
.,.,
|
359
|
-
|
360
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 52)
|
361
|
-
def _reduce_14(val, _values, result)
|
362
|
-
result = val[0]
|
363
|
-
result
|
364
|
-
end
|
365
|
-
.,.,
|
366
|
-
|
367
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 56)
|
368
|
-
def _reduce_15(val, _values, result)
|
369
|
-
result = ParamDef.new(val[0].downcase.intern, nil, val[2])
|
370
|
-
result
|
371
|
-
end
|
372
|
-
.,.,
|
373
|
-
|
374
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 58)
|
375
|
-
def _reduce_16(val, _values, result)
|
376
|
-
result = ParamDef.new(val[0].downcase.intern, val[2], val[5])
|
377
|
-
result
|
378
|
-
end
|
379
|
-
.,.,
|
380
|
-
|
381
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 61)
|
382
|
-
def _reduce_17(val, _values, result)
|
383
|
-
result = val[0]
|
384
|
-
result
|
385
|
-
end
|
386
|
-
.,.,
|
387
|
-
|
388
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 63)
|
389
|
-
def _reduce_18(val, _values, result)
|
390
|
-
result = val[0] + val[1]
|
391
|
-
result
|
392
|
-
end
|
393
|
-
.,.,
|
394
|
-
|
395
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 65)
|
396
|
-
def _reduce_19(val, _values, result)
|
397
|
-
result = val[0] + [nil]
|
398
|
-
result
|
399
|
-
end
|
400
|
-
.,.,
|
401
|
-
|
402
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 67)
|
403
|
-
def _reduce_20(val, _values, result)
|
404
|
-
result = val[0] + val[2]
|
405
|
-
result
|
406
|
-
end
|
407
|
-
.,.,
|
408
|
-
|
409
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 69)
|
410
|
-
def _reduce_21(val, _values, result)
|
411
|
-
result = val[0]
|
412
|
-
result
|
413
|
-
end
|
414
|
-
.,.,
|
415
|
-
|
416
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 72)
|
417
|
-
def _reduce_22(val, _values, result)
|
418
|
-
result = [val[0]]
|
419
|
-
result
|
420
|
-
end
|
421
|
-
.,.,
|
422
|
-
|
423
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 74)
|
424
|
-
def _reduce_23(val, _values, result)
|
425
|
-
result = [val[2]] * val[0]
|
426
|
-
result
|
427
|
-
end
|
428
|
-
.,.,
|
429
|
-
|
430
|
-
# reduce 24 omitted
|
431
|
-
|
432
|
-
# reduce 25 omitted
|
433
|
-
|
434
|
-
# reduce 26 omitted
|
435
|
-
|
436
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 82)
|
437
|
-
def _reduce_27(val, _values, result)
|
438
|
-
result = [val[0]-1]
|
439
|
-
result
|
440
|
-
end
|
441
|
-
.,.,
|
442
|
-
|
443
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 84)
|
444
|
-
def _reduce_28(val, _values, result)
|
445
|
-
result = [(val[0]-1)..(val[2]-1)]
|
446
|
-
result
|
447
|
-
end
|
448
|
-
.,.,
|
449
|
-
|
450
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 86)
|
451
|
-
def _reduce_29(val, _values, result)
|
452
|
-
result = [val[0]-1] + val[2]
|
453
|
-
result
|
454
|
-
end
|
455
|
-
.,.,
|
456
|
-
|
457
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 88)
|
458
|
-
def _reduce_30(val, _values, result)
|
459
|
-
result = [(val[0]-1)..(val[2]-1)] + val[4]
|
460
|
-
result
|
461
|
-
end
|
462
|
-
.,.,
|
463
|
-
|
464
|
-
def _reduce_none(val, _values, result)
|
465
|
-
val[0]
|
466
|
-
end
|
467
|
-
|
468
|
-
end # class FortranNamelistParser
|
469
|
-
|
470
|
-
|