Skip to content

Commit

Permalink
Corrected most data types and var namings
Browse files Browse the repository at this point in the history
Refs #19 and #20
  • Loading branch information
sverhoeven committed Nov 13, 2019
1 parent 9f3ec70 commit 819bdf7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 44 deletions.
24 changes: 12 additions & 12 deletions BMI/lib/marrmotBMI_oct.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,22 +281,22 @@ function set_value_at_indices(obj,long_var_name, inds, src)

% Grid rank
function output = get_grid_rank(~)
output = 2; % Fixed for all MARRMoT models
output = int32(2); % Fixed for all MARRMoT models
end

% Grid size
function output = get_grid_size(~)
output = 1; % Fixed for all MARRMoT models
output = int32(1); % Fixed for all MARRMoT models
end

% Grid shape
function output = get_grid_shape(~)
output = [1,1]; % Fixed for all MARRMoT models
output = [int32(1), int32(1)]; % Fixed for all MARRMoT models
end

% Grid origin
function output = get_grid_origin(obj)
output = [obj.lat,obj.lon];
output = [obj.lon,obj.lat];
end

% Grid spacing
Expand All @@ -305,18 +305,18 @@ function set_value_at_indices(obj,long_var_name, inds, src)
end

% Grid X
function output = get_grid_x(~)
output = 1; % Fixed for all MARRMoT models
function output = get_grid_x(obj)
output = [obj.lon];
end

% Grid Y
function output = get_grid_y(~)
output = 1; % Fixed for all MARRMoT models
function output = get_grid_y(obj)
output = [obj.lat];
end

% Grid Z
function output = get_grid_z(~)
output = 1; % Fixed for all MARRMoT models
output = []; % Fixed for all MARRMoT models
end


Expand Down Expand Up @@ -379,7 +379,7 @@ function set_value_at_indices(obj,long_var_name, inds, src)
tmp = obj.solver.resnorm_tolerance;
tmp = whos('tmp');
output = tmp.class;
case 'resnorm_maxiter'
case 'sol_resnorm_maxiter'
tmp = obj.solver.resnorm_maxiter;
tmp = whos('tmp');
output = tmp.class;
Expand All @@ -392,7 +392,7 @@ function set_value_at_indices(obj,long_var_name, inds, src)
tmp = whos('tmp');
output = tmp.class;
case 'flux_in_tmp'
tmp = obj.output_internalFluxes;
tmp = obj.output_internalFluxes.tmp;
tmp = whos('tmp');
output = tmp.class;
case 'wb'
Expand Down Expand Up @@ -510,7 +510,7 @@ function set_value_at_indices(obj,long_var_name, inds, src)

% Grid
function output = get_var_grid(obj,long_var_name)
output = 1; % Grid size is 1 for all models, so arbitrary values
output = int32(1); % Grid size is 1 for all models, so arbitrary values
end

% Location
Expand Down
70 changes: 38 additions & 32 deletions BMI/python/MARRMoTPythonBMI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import numpy as np




class MARRMoTPythonBMI(BMI):
def __init__(self,MARRMoTLoc=None):
self._name = "MARRMoTPythonBMI"
Expand All @@ -34,8 +32,8 @@ def get_input_var_names(self):
def get_output_var_names(self):
return octave.eval('model.get_output_var_names()').tolist()[0]

def get_var_grid(self, gridType):
commandString = 'model.get_var_grid("' + gridType + '")'
def get_var_grid(self, varName):
commandString = 'model.get_var_grid("' + varName + '")'
return octave.eval(commandString)

def get_var_type(self, varName):
Expand All @@ -48,11 +46,11 @@ def get_var_units(self, varName):

def get_var_itemsize(self, itemName):
commandString = 'model.get_var_itemsize("' + itemName + '")'
return octave.eval(commandString)
return int(octave.eval(commandString))

def get_var_nbytes(self, varName):
commandString = 'model.get_var_nbytes("' + varName + '")'
return octave.eval(commandString)
return int(octave.eval(commandString))

def get_var_location(self, varName):
commandString = 'model.get_var_location("' + varName + '")'
Expand Down Expand Up @@ -101,53 +99,61 @@ def set_value_at_indices(self, varName, indices, src):
return octave.eval(commandString)

# Grid information
def get_grid_rank(self):
return octave.eval('model.get_grid_rank()')
def get_grid_rank(self, grid_id):
return octave.eval('model.get_grid_rank(' + str(grid_id) + ')')


def get_grid_size(self):
return octave.eval('model.get_grid_size()')
def get_grid_size(self, grid_id):
return octave.eval('model.get_grid_size(' + str(grid_id) + ')')


def get_grid_type(self):
return octave.eval('model.get_grid_type()')
def get_grid_type(self, grid_id):
return octave.eval('model.get_grid_type(' + str(grid_id) + ')')

# Uniform rectilinear
def get_grid_shape(self):
return octave.eval('model.get_grid_shape()')
def get_grid_shape(self, grid_id):
return octave.eval('model.get_grid_shape(' + str(grid_id) + ')').flatten()

def get_grid_spacing(self):
return octave.eval('model.get_grid_spacing()')
def get_grid_spacing(self, grid_id):
return octave.eval('model.get_grid_spacing(' + str(grid_id) + ')').flatten()

def get_grid_origin(self):
return octave.eval('model.get_grid_origin()')
def get_grid_origin(self, grid_id):
return octave.eval('model.get_grid_origin(' + str(grid_id) + ')').flatten()

# Non-uniform rectilinear, curvilinear
def get_grid_x(self):
return octave.eval('model.get_grid_x()')

def get_grid_y(self):
return octave.eval('model.get_grid_y()')

def get_grid_z(self):
return octave.eval('model.get_grid_z()')
def get_grid_x(self, grid_id):
value = octave.eval('model.get_grid_x(' + str(grid_id) + ')')
# oct2py converts single value vectors to scalars, while bmi expects list
if type(value) is float:
return [value]
return value

def get_grid_y(self, grid_id):
value = octave.eval('model.get_grid_y(' + str(grid_id) + ')')
# oct2py converts single value vectors to scalars, while bmi expects list
if type(value) is float:
return [value]
return value

def get_grid_z(self, grid_id):
return octave.eval('model.get_grid_z(' + str(grid_id) + ')')

#not implemented in MARRMoT (all MARRMoT models have no grid)

def get_grid_node_count(self):
def get_grid_node_count(self, grid_id):
return "grids not implemented yet"

def get_grid_edge_count(self):
def get_grid_edge_count(self, grid_id):
return "grids not implemented yet"

def get_grid_face_count(self):
def get_grid_face_count(self, grid_id):
return "grids not implemented yet"

def get_grid_edge_nodes(self):
def get_grid_edge_nodes(self, grid_id):
return "grids not implemented yet"

def get_grid_face_nodes(self):
def get_grid_face_nodes(self, grid_id):
return "grids not implemented yet"

def get_grid_nodes_per_face(self):
def get_grid_nodes_per_face(self, grid_id):
return "grids not implemented yet"

0 comments on commit 819bdf7

Please sign in to comment.