Class: NumRu::GPhys

Inherits:
Object
  • Object
show all
Defined in:
lib/gphys_gfdnavi.rb

Defined Under Namespace

Classes: Read_Size_Limit_1_Exceeded, Read_Size_Limit_2_Exceeded

Constant Summary collapse

@@read_size_limit_1 =

Parameters @@read_size_limit_1 and @@read_size_limit_2

By default, both are nil, so no restriction is made on the size of data to read in onto run-time memory. To limit it, set these parameters explicitly by calling the class methods read_size_limit_1= and/or read_size_limit_2=.

It’s up to the programmer how to use the two limits. It’s OK to use only one of them. If both are set, it is recommended to set as @@read_size_limit_2 > @@read_size_limit_1, because of the order of judgements (the former is evaluated first).

nil
@@read_size_limit_2 =

e.g., 2000000

nil

Class Method Summary collapse

Class Method Details

.__new__Object



34
# File 'lib/gphys_gfdnavi.rb', line 34

alias :__new__ :new

.new(*argv) ⇒ Object

Limit the size of data to read in with GPhys#val. This is implemented by defining singletone method for the VArray that represent the main data array. (Note that no restriction is made for coordinate varaibles, which is practically unnecessary.)



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gphys_gfdnavi.rb', line 41

def new(*argv)
	gp = __new__(*argv)
	data = gp.data
	def data.val
	  if @@read_size_limit_2 && length > @@read_size_limit_2
	    raise Read_Size_Limit_2_Exceeded, "Exceeded the maximum array size to read in (length=#{@@read_size_limit_2}). Reduce the size by using the 'axes' window, and try again. (Or perhaps you may get around the error by programming with GPhys::each_along_dims.)"
	  elsif @@read_size_limit_1 && length > @@read_size_limit_1
	    raise Read_Size_Limit_1_Exceeded, "Exceeded the maximum array size to read in (length=#{@@read_size_limit_1}). Reduce the size by using the 'axes' window, and try again. (Or perhaps you may get around the error by programming with GPhys::each_along_dims.)"
	  end
	  super
	end
	gp
end

.read_size_limit_1Object



69
70
71
# File 'lib/gphys_gfdnavi.rb', line 69

def read_size_limit_1
	@@read_size_limit_1
end

.read_size_limit_1=(limit) ⇒ Object

Set internal parameter @@read_size_limit_1

Raises:

  • (ArgumentError)


56
57
58
59
60
# File 'lib/gphys_gfdnavi.rb', line 56

def read_size_limit_1= (limit)
	return if limit.nil?
	raise(ArgumentError,"Expect an integer") if !limit.is_a?(Integer)
	@@read_size_limit_1 = limit
end

.read_size_limit_2Object



73
74
75
# File 'lib/gphys_gfdnavi.rb', line 73

def read_size_limit_2
	@@read_size_limit_1
end

.read_size_limit_2=(limit) ⇒ Object

Set internal parameter @@read_size_limit_2

Raises:

  • (ArgumentError)


63
64
65
66
67
# File 'lib/gphys_gfdnavi.rb', line 63

def read_size_limit_2= (limit)
	return if limit.nil?
	raise(ArgumentError,"Expect an integer") if !limit.is_a?(Integer)
	@@read_size_limit_2 = limit
end