gphys 1.4.3.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. data/.ChangeLog.until201303 +2156 -0
  2. data/.gitignore +7 -1
  3. data/Rakefile +36 -1
  4. data/bin/gpview +75 -58
  5. data/{dim_op.c → ext/numru/gphys/dim_op.c} +4 -1
  6. data/{ext_coord.c → ext/numru/gphys/ext_coord.c} +35 -17
  7. data/{ext_init.c → ext/numru/gphys/ext_init.c} +0 -0
  8. data/ext/numru/gphys/extconf.rb +43 -0
  9. data/{interpo.c → ext/numru/gphys/interpo.c} +35 -30
  10. data/{multibitIO.c → ext/numru/gphys/multibitIO.c} +19 -15
  11. data/gphys-bigmem.gemspec +44 -0
  12. data/gphys.gemspec +4 -4
  13. data/lib/numru/dclext.rb +55 -0
  14. data/lib/numru/derivative.rb +6 -5
  15. data/lib/numru/ganalysis/met.rb +27 -10
  16. data/lib/numru/ganalysis/qg.rb +4 -3
  17. data/lib/numru/ganalysis/sph_harmonic_iso_g.rb +290 -0
  18. data/lib/numru/ggraph.rb +81 -2
  19. data/lib/numru/gphys/derivative.rb +3 -2
  20. data/lib/numru/gphys/gpcommon.rb +7 -1
  21. data/lib/numru/gphys/gphys_fft.rb +3 -3
  22. data/lib/numru/gphys/gphys_hdfeos5_io.rb +14 -13
  23. data/lib/numru/gphys/grib.rb +18 -7
  24. data/lib/numru/gphys/gtool3.rb +53 -52
  25. data/lib/numru/gphys/interpolate.rb +3 -2
  26. data/lib/numru/gphys/varraycomposite.rb +1 -1
  27. data/lib/numru/gphys/varraynetcdf.rb +38 -0
  28. data/lib/numru/gphys/version.rb +2 -1
  29. data/test/test_axis.rb +1 -5
  30. data/test/test_fitting.rb +0 -1
  31. data/test/test_gphys.rb +9 -5
  32. data/test/test_met_z.rb +1 -2
  33. data/test/test_sigma_coord.rb +0 -1
  34. metadata +36 -19
  35. checksums.yaml +0 -15
  36. data/.rspec +0 -2
  37. data/.travis.yml +0 -3
  38. data/ChangeLog +0 -7007
  39. data/extconf.rb +0 -51
  40. data/spec/gphys_spec.rb +0 -11
  41. data/spec/spec_helper.rb +0 -2
data/.gitignore CHANGED
@@ -1,3 +1,9 @@
1
+ *.[oa]
2
+ *~
3
+ *.so
4
+ *.log
5
+ Makefile
6
+ ChangeLog
1
7
  /.bundle/
2
8
  /.yardoc
3
9
  /Gemfile.lock
@@ -5,4 +11,4 @@
5
11
  /coverage/
6
12
  /pkg/
7
13
  /spec/reports/
8
- /tmp/
14
+ /tmp/
data/Rakefile CHANGED
@@ -1,2 +1,37 @@
1
- require "bundler/gem_tasks"
1
+ # -* coding: utf-8 -*-
2
+ require 'rake/testtask'
3
+ require 'rake/extensiontask'
4
+ require 'rake/packagetask'
5
+ begin
6
+ require 'bundler/gem_helper' # instead of 'bundler/gem_tasks' -> need manual
7
+ # calls of install_tasks (see below)
8
+ rescue LoadError
9
+ puts 'If you want to create gem, You must install Bundler'
10
+ end
2
11
 
12
+ # manual calls of install_tasks to support multiple gemspec files
13
+ Bundler::GemHelper.install_tasks(name: "gphys")
14
+ Bundler::GemHelper.install_tasks(name: "gphys-bigmem")
15
+
16
+ require './lib/numru/gphys/version.rb'
17
+ def version
18
+ NumRu::GPhys::VERSION
19
+ end
20
+
21
+ task :default => :test
22
+ task :test => :compile
23
+ Rake::TestTask.new do |t|
24
+ t.libs << 'lib' << 'test'
25
+ t.test_files = FileList['test/test_*.rb'].exclude('test/test_assoccoords.rb')
26
+ end
27
+
28
+ Rake::ExtensionTask.new do |ext|
29
+ ext.name = 'gphys_ext'
30
+ ext.ext_dir = 'ext/numru/gphys'
31
+ ext.lib_dir = 'lib/numru'
32
+ end
33
+
34
+ Rake::PackageTask.new('gphys', "#{version}") do |t|
35
+ t.need_tar_gz = true
36
+ t.package_files.include `git ls-files`.split("\n")
37
+ end
data/bin/gpview CHANGED
@@ -45,10 +45,14 @@ if you want to know more description, please read
45
45
 
46
46
  :--wsn [1-4]:
47
47
  set work staion number. each number represent output device:
48
- 1 : X window.
49
- 2 : PS file. (named dcl.ps)
50
- 3 : Tcl/Tk file.
51
- 4 : GTK Windows (depend on dcl-5.3)
48
+ * for dcl-6,
49
+ 1 : X window
50
+ 2.: PDF file (named dcl.pdf).
51
+ * for dcl-5-?,
52
+ 1 : X window,
53
+ 2 : PS file. (named dcl.ps)
54
+ 3 : Tektronix terminal
55
+ 4 : GTK Windows
52
56
 
53
57
  :--clrmap [1-]:
54
58
  set colormap to draw tone/contour.
@@ -94,6 +98,9 @@ if you want to know more description, please read
94
98
  :--nowait, --Gw:
95
99
  not wait for any actions if animate
96
100
 
101
+ :--delay <number>:
102
+ wait <number> seconds for each new page drawing of animation
103
+
97
104
  :--reverse, --Gr:
98
105
  plot animation reversible if animate
99
106
 
@@ -225,7 +232,7 @@ if you want to know more description, please read
225
232
  :--udsfmt [strings]:
226
233
  change contour label format. see UDCNTR/DCL manual for the format.
227
234
 
228
- == EXAMPLES
235
+ = EXAMPLES
229
236
 
230
237
  For a single GPhys variable,
231
238
 
@@ -240,6 +247,7 @@ For a single GPhys variable,
240
247
  % gpview --smooth lon data.nc@temp,lon=130:150
241
248
  % gpview --levels 0,10,20,30 --pattern 30999,40999,50999,60999,70999 data.nc@temp
242
249
  % gpview --overplot=3 --anim t data.nc@temp,lon=0
250
+ % gpview --overplot=3 --Opc --anim t data.nc@temp,lon=0
243
251
  % gpview --mark data.nc@temp,lon=0,lat=0
244
252
  % gpview --operation log10 data.nc@temp,lon=0
245
253
  % gpview --time_ax false data.nc@temp,lon=0,lat=0
@@ -254,59 +262,62 @@ For multiple GPhys variables,
254
262
  % gpview --var temp,lon=130:150 data?.nc
255
263
  % gpview --anim t --var temp,lon=130:150 data*.nc
256
264
 
257
-
258
- == HISTORY
259
-
260
- 2004/12/14 D Tsukahara && T Horinouti(parse_gturl)
261
- 2005/01/08 D Tsukahara (add option --exch and able to invalid value)
262
- 2005/01/09 D Tsukahara (add option --animate, smooth, alternate, index )
263
- 2005/01/10 D Tsukahara (transpose axis with attr "positive:down" ,
264
- abailable loopsense_flag. )
265
- 2005/01/10 D Tsukahara (implement GGraph::color_bar, and margin_info,
266
- which file name, date, and toolname. )
267
- 2005/01/11 D Tsukahara ( 1. write document about OPTIONS.
268
- 2. add many options. more info please see document. )
269
- 2005/01/23 S Takehiro (add option --similar, map_axis)
270
- 2005/02/09 D Tsukahara && M Nakano (add option --reverse, --Gr, --map)
271
- 2005/02/10 D Tsukahara (change option parser (getopts => getoptlong))
272
- 2005/02/24 D Tsukahara (apply --range for line plot)
273
- 2005/06/15 S Takehiro (add option --levels, --clevels, --slevels, --patterns)
274
- 2005/06/17 S Takehiro (missing_value attribute setting removed)
275
- 2005/06/22 S Takehiro (debug, clipping control added to GGraph::annotate)
276
- 2005/06/23 S Takehiro (debug, option --title implemented)
277
- 2005/07/15 S Takehiro (option --noannotate implemented)
278
- 2005/08/07 S Takehiro (option --overplot implemented)
279
- 2005/08/09 S Takehiro && T Horinouchi (add option --help and help function.
280
- URL information corrected. )
281
- 2005/08/23 S Takehiro (multiple Gphys variables plotting
282
- and option --var implemented)
283
- 2005/08/23 S Takehiro (common methods to gp* command moved to gpcommon.rb)
284
- 2005/10/30 S Takehiro (option --animate recoverd)
285
- 2005/10/31 S Takehiro (option --smooth bug fixed)
286
- 2006/03/07 M Nakano (option --int bug fixed)
287
- 2007/10/03 S Takehiro (option --nocolorbar implemented)
288
- 2008/04/03 S Takehiro (option --nozero implemented)
289
- 2008/12/14 S Takehiro (option --mark implemented)
290
- 2010/03/10 Y SASAKI (change help block into RD format)
291
- 2011/01/14 T Tanigawa && S Takehiro (option --operation implemented)
292
- 2011/11/04 S Takehiro (option --time_ax implemented)
293
- 2011/11/20 S Takehiro (option --eddy implemented)
294
- 2012/02/19 S Takehiro (description for gturl format updated)
295
- 2013/01/29 T Tanigawa && S Takehiro (calculation of aspect ratio
296
- of viewport improved)
297
- 2013/01/29 S Nishizawa && S Takehiro (sequential operation implemented)
298
- 2014/02/21 Y Naito && S Takehiro (implement DCL internal variable setting,
299
- add option --udsfmt)
300
- 2014/02/21 S Noda && S Takehiro (add option --stddev)
301
- 2014/02/23 S Takehiro (option --tonf is changed to --tone)
302
- 2014/03/05 S Takehiro (add option --map_radius)
303
- 2014/03/10 Y Kawai && S Takehiro (setting labels for contours)
304
- 2014/04/06 S Takehiro (option --map_radius bug fix)
305
- 2014/06/27 S Nishizawa && S Takehiro (add options --xcoord, --ycoord)
306
- 2014/11/28 H Kashimura && S Takehiro (add option --diff, --tone bug fix)
307
- 2014/11/28 Y O Takahashi && S Takehiro (add option --overplot_color, --Opc)
308
-
309
265
  =end
266
+ #
267
+ # = HISTORY
268
+ #
269
+ # 2004/12/14 D Tsukahara && T Horinouti(parse_gturl)
270
+ # 2005/01/08 D Tsukahara (add option --exch and able to invalid value)
271
+ # 2005/01/09 D Tsukahara (add option --animate, smooth, alternate, index )
272
+ # 2005/01/10 D Tsukahara (transpose axis with attr "positive:down" ,
273
+ # abailable loopsense_flag. )
274
+ # 2005/01/10 D Tsukahara (implement GGraph::color_bar, and margin_info,
275
+ # which file name, date, and toolname. )
276
+ # 2005/01/11 D Tsukahara ( 1. write document about OPTIONS.
277
+ # 2. add many options. more info please see document. )
278
+ # 2005/01/23 S Takehiro (add option --similar, map_axis)
279
+ # 2005/02/09 D Tsukahara && M Nakano (add option --reverse, --Gr, --map)
280
+ # 2005/02/10 D Tsukahara (change option parser (getopts => getoptlong))
281
+ # 2005/02/24 D Tsukahara (apply --range for line plot)
282
+ # 2005/06/15 S Takehiro (add option --levels, --clevels, --slevels, --patterns)
283
+ # 2005/06/17 S Takehiro (missing_value attribute setting removed)
284
+ # 2005/06/22 S Takehiro (debug, clipping control added to GGraph::annotate)
285
+ # 2005/06/23 S Takehiro (debug, option --title implemented)
286
+ # 2005/07/15 S Takehiro (option --noannotate implemented)
287
+ # 2005/08/07 S Takehiro (option --overplot implemented)
288
+ # 2005/08/09 S Takehiro && T Horinouchi (add option --help and help function.
289
+ # URL information corrected. )
290
+ # 2005/08/23 S Takehiro (multiple Gphys variables plotting
291
+ # and option --var implemented)
292
+ # 2005/08/23 S Takehiro (common methods to gp* command moved to gpcommon.rb)
293
+ # 2005/10/30 S Takehiro (option --animate recoverd)
294
+ # 2005/10/31 S Takehiro (option --smooth bug fixed)
295
+ # 2006/03/07 M Nakano (option --int bug fixed)
296
+ # 2007/10/03 S Takehiro (option --nocolorbar implemented)
297
+ # 2008/04/03 S Takehiro (option --nozero implemented)
298
+ # 2008/12/14 S Takehiro (option --mark implemented)
299
+ # 2010/03/10 Y SASAKI (change help block into RD format)
300
+ # 2011/01/14 T Tanigawa && S Takehiro (option --operation implemented)
301
+ # 2011/11/04 S Takehiro (option --time_ax implemented)
302
+ # 2011/11/20 S Takehiro (option --eddy implemented)
303
+ # 2012/02/19 S Takehiro (description for gturl format updated)
304
+ # 2013/01/29 T Tanigawa && S Takehiro (calculation of aspect ratio
305
+ # of viewport improved)
306
+ # 2013/01/29 S Nishizawa && S Takehiro (sequential operation implemented)
307
+ # 2014/02/21 Y Naito && S Takehiro (implement DCL internal variable setting,
308
+ # add option --udsfmt)
309
+ # 2014/02/21 S Noda && S Takehiro (add option --stddev)
310
+ # 2014/02/23 S Takehiro (option --tonf is changed to --tone)
311
+ # 2014/03/05 S Takehiro (add option --map_radius)
312
+ # 2014/03/10 Y Kawai && S Takehiro (setting labels for contours)
313
+ # 2014/04/06 S Takehiro (option --map_radius bug fix)
314
+ # 2014/06/27 S Nishizawa && S Takehiro (add options --xcoord, --ycoord)
315
+ # 2014/11/28 H Kashimura && S Takehiro (add option --diff, --tone bug fix)
316
+ # 2014/11/28 Y O Takahashi && S Takehiro (add option --overplot_color, --Opc)
317
+ # 2015/03/10 S Takehiro (History removes from the output of --help option)
318
+ # 2015/09/05 Y O Takahashi && S Takehiro (add option --delay)
319
+ # 2015/09/06 Y O Takahashi && S Takehiro (defalt wsn number changed)
320
+ #
310
321
  #################################################
311
322
  require "getoptlong" # for option_parse
312
323
  require "numru/ggraph" # ggraph library
@@ -726,6 +737,7 @@ parser.set_options(
726
737
  ['--Gw', GetoptLong::NO_ARGUMENT],
727
738
  ['--smooth', GetoptLong::NO_ARGUMENT],
728
739
  ['--Gaw', GetoptLong::NO_ARGUMENT],
740
+ ['--delay', GetoptLong::REQUIRED_ARGUMENT],
729
741
  ['--exch', GetoptLong::NO_ARGUMENT],
730
742
  ['--reverse', GetoptLong::NO_ARGUMENT],
731
743
  ['--Gr', GetoptLong::NO_ARGUMENT],
@@ -838,7 +850,11 @@ loopdim = loopdim.to_i if loopdim.to_i.to_s == loopdim
838
850
  ### set colormap
839
851
  DCL.sgscmn($OPT_clrmap||1)
840
852
  ## open work station
841
- DCL.gropn($OPT_wsn||4)
853
+ if NumRu::DCL::DCLVERSION.to_f >= 6
854
+ DCL.gropn($OPT_wsn||1)
855
+ else
856
+ DCL.gropn($OPT_wsn||4)
857
+ end
842
858
 
843
859
  ## open netcdf variables
844
860
 
@@ -935,6 +951,7 @@ while ARGV[0] do
935
951
  if loopdim # animation
936
952
  each_along_dims(gp, loopdim){|gp_subset|
937
953
  proc.call(gp_subset)
954
+ sleep($OPT_delay.to_f) if ($OPT_delay && !DCL::swlget('lwait'))
938
955
  }
939
956
  else
940
957
  proc.call(gp)
@@ -14,7 +14,8 @@
14
14
  # define RARRAY_LEN(ary) (RARRAY(ary)->len)
15
15
  #endif
16
16
 
17
- #ifndef HAVE_NA_SHAPE_T
17
+ /* for compatibility for NArray and NArray with big memory patch */
18
+ #ifndef NARRAY_BIGMEM
18
19
  typedef int na_shape_t;
19
20
  #endif
20
21
 
@@ -904,7 +905,9 @@ cell_integ_irreg(obj, f, z, zdim, nzbound, ccell, w)
904
905
  }
905
906
 
906
907
  // main loop
908
+ #pragma omp parallel for private(nzw,m,k,wa,wb,fa,fb,dz,wac,wbc,a,b,fi)
907
909
  for (l=0; l<n2; l++){
910
+ #pragma omp parallel for private(nzw,m,k,wa,wb,fa,fb,dz,wac,wbc,a,b,fi)
908
911
  for (j=0; j<n0; j++){
909
912
  if (nzbound == Qnil) {
910
913
  nzw = nz;
@@ -13,6 +13,16 @@
13
13
  # define RARRAY_LEN(ary) (RARRAY(ary)->len)
14
14
  #endif
15
15
 
16
+ /* for compatibility for NArray and NArray with big memory patch */
17
+ #ifndef NARRAY_BIGMEM
18
+ typedef int na_shape_t;
19
+ typedef int32_t na_shape_na_t; /* Usually same as na_shape_t,
20
+ but to ensure the use of NA_LINT */
21
+ #define NA_SIZE NA_LINT
22
+ #else
23
+ typedef na_shape_t na_shape_na_t;
24
+ #endif
25
+
16
26
  /* cut_range : a private method for AssocCoord (used in AssocCoord#cut)
17
27
  */
18
28
  static VALUE
@@ -21,13 +31,16 @@ assoc_coord_cut_range(self, vmins, vmaxs, crds, masks, crdaxexist, orgaxlens)
21
31
  // All input variables are supposed to be Arrays
22
32
  {
23
33
  VALUE wheres, whna; // return value (Array)
24
- int nc, ic, na, ia, jlen, j, klen, k, ndimk, dimk;
25
- int *lens, lentot, lenmax, *mod, *sub, **mlt, *jmlt, *dimk2a;
26
- int last_non0, l, cidx, *natype, *nomask, included, whcount;
27
- int32_t **axexist, *whptr, *whbuf;
34
+ int nc, ic;
35
+ na_shape_t na, ia, jlen, j, klen, k, ndimk, dimk;
36
+ na_shape_t *lens, lentot, lenmax, *mod, *sub, **mlt, *jmlt, *dimk2a;
37
+ na_shape_t last_non0, l, cidx, included, whcount;
38
+ int *natype, *nomask;
39
+ int32_t **axexist;
40
+ na_shape_na_t *whptr, *whbuf;
28
41
  double *vmax, *vmin, val, **dval;
29
42
  float **fval;
30
- int8_t **mask;
43
+ u_int8_t **mask;
31
44
 
32
45
  nc = RARRAY_LEN(crds); // lengths of vmins,vmaxs,crds,masks,crdaxexist
33
46
  na = RARRAY_LEN(orgaxlens);
@@ -47,23 +60,28 @@ assoc_coord_cut_range(self, vmins, vmaxs, crds, masks, crdaxexist, orgaxlens)
47
60
 
48
61
  lentot = 1;
49
62
  lenmax = -1;
50
- lens = ALLOCA_N(int,na);
63
+ lens = ALLOCA_N(na_shape_t,na);
51
64
  for(ia=0; ia<na; ia++){
52
65
  lens[ia] = NUM2INT( RARRAY_PTR(orgaxlens)[ia] );
53
66
  lentot *= lens[ia];
54
67
  if (lens[ia] > lenmax) { lenmax = lens[ia]; }
55
68
  }
56
69
  ndimk = ( (na==1) ? 1 : (na-1) ) ;
57
- mod = ALLOCA_N(int,ndimk);
58
- sub = ALLOCA_N(int,ndimk);
59
- mlt = ALLOCA_N(int*,nc);
70
+ mod = ALLOCA_N(na_shape_t,ndimk);
71
+ sub = ALLOCA_N(na_shape_t,ndimk);
72
+ mlt = ALLOCA_N(na_shape_t*,nc);
60
73
  axexist = ALLOCA_N(int32_t*,nc);
61
74
  for(ic=0; ic<nc; ic++){
62
- mlt[ic] = ALLOCA_N(int,ndimk);
63
- axexist[ic] = NA_PTR_TYPE( RARRAY_PTR(crdaxexist)[ic], int32_t* );
75
+ mlt[ic] = ALLOCA_N(na_shape_t,ndimk);
76
+ if ( NA_TYPE( RARRAY_PTR(crdaxexist)[ic] ) == NA_LINT ) {
77
+ axexist[ic] = NA_PTR_TYPE( RARRAY_PTR(crdaxexist)[ic], int32_t* );
78
+ } else {
79
+ rb_raise(rb_eArgError,"crdaxexist[%d] is not NArray::LINT [%s:%d]",
80
+ ic,__FILE__,__LINE__);
81
+ }
64
82
  }
65
- jmlt = ALLOCA_N(int,nc);
66
- dimk2a = ALLOCA_N(int,ndimk);
83
+ jmlt = ALLOCA_N(na_shape_t,nc);
84
+ dimk2a = ALLOCA_N(na_shape_t,ndimk);
67
85
 
68
86
  /* ruby objs to C for coordinates and cut params */
69
87
 
@@ -71,7 +89,7 @@ assoc_coord_cut_range(self, vmins, vmaxs, crds, masks, crdaxexist, orgaxlens)
71
89
  vmax = ALLOCA_N(double,nc);
72
90
  dval = ALLOCA_N(double*,nc);
73
91
  fval = ALLOCA_N(float*,nc);
74
- mask = ALLOCA_N(int8_t*,nc);
92
+ mask = ALLOCA_N(u_int8_t*,nc);
75
93
  nomask = ALLOCA_N(int,nc);
76
94
  natype = ALLOCA_N(int,nc);
77
95
  for(ic=0; ic<nc; ic++){
@@ -95,7 +113,7 @@ assoc_coord_cut_range(self, vmins, vmaxs, crds, masks, crdaxexist, orgaxlens)
95
113
  }
96
114
 
97
115
  /* prepare output objs */
98
- whbuf = ALLOCA_N(int32_t,lenmax);
116
+ whbuf = ALLOCA_N(na_shape_na_t,lenmax);
99
117
 
100
118
  /* main loop */
101
119
  for(ia=0; ia<na; ia++){
@@ -185,9 +203,9 @@ assoc_coord_cut_range(self, vmins, vmaxs, crds, masks, crdaxexist, orgaxlens)
185
203
  }
186
204
  }
187
205
  }
188
- whna = na_make_object(NA_LINT, 1, &whcount, cNArray);
206
+ whna = na_make_object(NA_SIZE, 1, &whcount, cNArray);
189
207
  rb_ary_push( wheres, whna );
190
- whptr = NA_PTR_TYPE( whna, int32_t* );
208
+ whptr = NA_PTR_TYPE( whna, na_shape_na_t* );
191
209
  for(j=0; j<whcount; j++){
192
210
  whptr[j] = whbuf[j];
193
211
  }
File without changes
@@ -0,0 +1,43 @@
1
+ require 'mkmf'
2
+ gem_path = nil
3
+
4
+ if Gem.respond_to?(:find_files) and Gem.find_files("narray.h").length > 0
5
+ require "rbconfig"
6
+ so = RbConfig::CONFIG["DLEXT"]
7
+ narray_include = File.expand_path(File.dirname(Gem.find_files("narray.h")[0]))
8
+ narray_lib = File.expand_path(File.dirname(Gem.find_files("narray." + so)[0]))
9
+ else
10
+ gem_home=(`gem environment GEM_HOME`).chomp
11
+ narray_dir = Dir.glob("#{gem_home}/gems/narray-*/ext/narray").sort[-1]
12
+ if narray_dir
13
+ narray_include = narray_lib = narray_dir
14
+ else
15
+ narray_include = narray_lib = [ $sitearchdir, $vendorarchdir]
16
+ end
17
+ end
18
+ dir_config('narray', narray_include, narray_lib)
19
+
20
+ require "narray"
21
+ if NArray.const_defined?(:SUPPORT_BIGMEM) && NArray::SUPPORT_BIGMEM
22
+
23
+ case RbConfig::CONFIG["CC"]
24
+ when "gcc"
25
+ omp_opt = "-fopenmp"
26
+ else
27
+ omp_opt = nil
28
+ end
29
+ omp_opt = arg_config("--openmp", omp_opt)
30
+
31
+ omp_opt = nil if omp_opt.to_s.empty?
32
+
33
+ if omp_opt
34
+ $CFLAGS << " " << omp_opt
35
+ $DLDFLAGS << " " << omp_opt
36
+ warn "OpenMP support: ON"
37
+ else
38
+ warn "OpenMP support: OFF"
39
+ warn "if you want to enable openmp, set --openmp=compile_option"
40
+ end
41
+ end
42
+
43
+ create_makefile('numru/gphys_ext')
@@ -13,6 +13,11 @@
13
13
  # define RARRAY_LEN(ary) (RARRAY(ary)->len)
14
14
  #endif
15
15
 
16
+ /* for compatibility for NArray and NArray with big memory patch */
17
+ #ifndef NARRAY_BIGMEM
18
+ typedef int na_shape_t;
19
+ #endif
20
+
16
21
  static VALUE
17
22
  interpo_do(obj, shape_to, idxmap, val_from, missval, extrapo)
18
23
  VALUE obj;
@@ -27,17 +32,17 @@ interpo_do(obj, shape_to, idxmap, val_from, missval, extrapo)
27
32
  struct NARRAY *naf;
28
33
  VALUE vm;
29
34
  int natype;
30
- int *sht; // shape to (could be size_t if NArray is changed)
31
- int *shf; // shape from (could be size_t if NArray is changed)
32
- size_t cshf;
33
- size_t rankf, rankt, lent;
35
+ na_shape_t *sht; // shape to
36
+ na_shape_t *shf; // shape from
37
+ na_shape_t cshf;
38
+ na_shape_t rankf, rankt, lent;
34
39
  double *pt, *pf;
35
40
  int nomiss;
36
41
  double vmiss;
37
42
  int extr;
38
- size_t i, it, kf, j, k, l;
43
+ na_shape_t i, it, kf, j, k, l;
39
44
  int *mtyp;
40
- size_t *dm, *dm2, *dm2f, *dm3, *dm3f, *dm4, *dm4f;
45
+ na_shape_t *dm, *dm2, *dm2f, *dm3, *dm3f, *dm4, *dm4f;
41
46
  int **di, nid, nic;
42
47
  double **df, *f, a;
43
48
  int *idf, idfc, *idt;
@@ -59,7 +64,7 @@ interpo_do(obj, shape_to, idxmap, val_from, missval, extrapo)
59
64
  // read argument (shape_to)
60
65
 
61
66
  rankt = RARRAY_LEN(shape_to);
62
- sht = ALLOCA_N(int, rankt);
67
+ sht = ALLOCA_N(na_shape_t, rankt);
63
68
  for(i=0; i<rankt; i++){
64
69
  sht[i] = NUM2INT( RARRAY_PTR(shape_to)[i] );
65
70
  }
@@ -90,13 +95,13 @@ interpo_do(obj, shape_to, idxmap, val_from, missval, extrapo)
90
95
  }
91
96
 
92
97
  mtyp = ALLOCA_N(int, rankf);
93
- dm = ALLOCA_N(size_t, rankf);
94
- dm2 = ALLOCA_N(size_t, rankf);
95
- dm2f = ALLOCA_N(size_t, rankf);
96
- dm3 = ALLOCA_N(size_t, rankf);
97
- dm3f = ALLOCA_N(size_t, rankf);
98
- dm4 = ALLOCA_N(size_t, rankf);
99
- dm4f = ALLOCA_N(size_t, rankf);
98
+ dm = ALLOCA_N(na_shape_t, rankf);
99
+ dm2 = ALLOCA_N(na_shape_t, rankf);
100
+ dm2f = ALLOCA_N(na_shape_t, rankf);
101
+ dm3 = ALLOCA_N(na_shape_t, rankf);
102
+ dm3f = ALLOCA_N(na_shape_t, rankf);
103
+ dm4 = ALLOCA_N(na_shape_t, rankf);
104
+ dm4f = ALLOCA_N(na_shape_t, rankf);
100
105
  di = ALLOCA_N(int *, rankf);
101
106
  df = ALLOCA_N(double *, rankf);
102
107
  nid = 0;
@@ -231,13 +236,13 @@ interpo_do(obj, shape_to, idxmap, val_from, missval, extrapo)
231
236
  static void
232
237
  __interpo_find_loc_1D(N, P, n, p, vmiss, extr, ids, f)
233
238
  double *P, *p; // INPUT
234
- size_t N, n; // INPUT
239
+ na_shape_t N, n; // INPUT
235
240
  double vmiss; // INPUT
236
241
  int extr; // INPUT
237
242
  int *ids; // OUTPUT
238
243
  double *f; // OUTPUT
239
244
  {
240
- size_t j;
245
+ na_shape_t j;
241
246
  int i, il, ir;
242
247
  int down;
243
248
 
@@ -313,13 +318,13 @@ interpo_find_loc_1D(obj, X, x, missval, extrapo)
313
318
  {
314
319
  VALUE na_ids, na_f;
315
320
  VALUE chk;
316
- size_t N, n;
321
+ na_shape_t N, n;
317
322
  struct NARRAY *na;
318
323
  double *P, *p, vmiss;
319
324
  int extr;
320
325
  int *ids;
321
326
  double *f;
322
- int shape[1]; // could be size_t if NArray is changed
327
+ na_shape_t shape[1];
323
328
 
324
329
  // check and unwrap the input arguments
325
330
 
@@ -375,20 +380,20 @@ interpo_find_loc_1D_MD(obj, X, x, dimc, missval, extrapo)
375
380
  {
376
381
  VALUE na_ids, na_f;
377
382
  VALUE chk;
378
- size_t N, n1;
383
+ na_shape_t N, n1;
379
384
  struct NARRAY *na;
380
385
  double *P, *p, *p1, vmiss;
381
386
  int extr;
382
387
  int *ids, *ids1;
383
388
  double *f, *f1;
384
- int *shr; // shape of the result (could be size_t if NArray is changed)
385
- int *shl; // shape of multi-D loop (could be size_t if NArray is changed)
386
- int *shx; // shape of x (could be size_t if NArray is changed)
389
+ na_shape_t *shr; // shape of the result
390
+ na_shape_t *shl; // shape of multi-D loop
391
+ na_shape_t *shx; // shape of x
387
392
  int dmc; // dimc
388
393
  int rank, dl, dc;
389
- size_t *cshxl, *cshrl, *cshl; // cumulative shapes for looping
390
- size_t fxl; // same but only for the dimension treated here
391
- size_t il, i, j, ix, ir, totl;
394
+ na_shape_t *cshxl, *cshrl, *cshl; // cumulative shapes for looping
395
+ na_shape_t fxl; // same but only for the dimension treated here
396
+ na_shape_t il, i, j, ix, ir, totl;
392
397
 
393
398
  // check and unwrap the input arguments
394
399
 
@@ -423,8 +428,8 @@ interpo_find_loc_1D_MD(obj, X, x, dimc, missval, extrapo)
423
428
 
424
429
  // prepare output NArrays
425
430
 
426
- shl = ALLOCA_N(int, rank-1);
427
- shr = ALLOCA_N(int, rank);
431
+ shl = ALLOCA_N(na_shape_t, rank-1);
432
+ shr = ALLOCA_N(na_shape_t, rank);
428
433
  shr[0] = N;
429
434
  totl = 1;
430
435
  for(dl=0,dc=0; dl<rank-1; dl++,dc++){
@@ -433,13 +438,13 @@ interpo_find_loc_1D_MD(obj, X, x, dimc, missval, extrapo)
433
438
  totl *= shl[dl];
434
439
  }
435
440
 
436
- cshl = ALLOCA_N(size_t, rank-1);
441
+ cshl = ALLOCA_N(na_shape_t, rank-1);
437
442
  cshl[0] = 1;
438
443
  for(dl=1; dl<rank-1; dl++){
439
444
  cshl[dl] = cshl[dl-1]*shl[dl-1];
440
445
  }
441
446
 
442
- cshxl = ALLOCA_N(size_t, rank-1);
447
+ cshxl = ALLOCA_N(na_shape_t, rank-1);
443
448
  if(dmc==0) {
444
449
  fxl = 1;
445
450
  cshxl[0] = shx[0];
@@ -461,7 +466,7 @@ interpo_find_loc_1D_MD(obj, X, x, dimc, missval, extrapo)
461
466
  fxl = cshxl[rank-2]*shx[rank-2];
462
467
  }
463
468
 
464
- cshrl = ALLOCA_N(size_t, rank-1);
469
+ cshrl = ALLOCA_N(na_shape_t, rank-1);
465
470
  cshrl[0] = shr[0];
466
471
  for(dl=1; dl<rank-1; dl++){
467
472
  cshrl[dl] = cshrl[dl-1]*shr[dl];