From 77876d01e0e2c3eb5fe621eec914e6b0248f48db Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 17 Oct 2019 10:18:37 -0600 Subject: [PATCH 01/13] Change version to 2.0 After discussion with @mcflugen, I changed the version to 2.0 since the changes introduced to the BMI aren't backward-compatible. --- bmi.sidl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmi.sidl b/bmi.sidl index 2f19a88..f1d8738 100644 --- a/bmi.sidl +++ b/bmi.sidl @@ -1,4 +1,4 @@ -package csdms version 1.3b0 { +package csdms version 2.0b0 { interface bmi { int initialize(in string config_file); int update(); From 61d72ac4d273574807888652fa8e4cb74bc97426 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 17 Oct 2019 10:21:01 -0600 Subject: [PATCH 02/13] Use a better parameter name Using "then" is bad since it's a keyword or reserved word in many languages. --- bmi.sidl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmi.sidl b/bmi.sidl index f1d8738..570eaa5 100644 --- a/bmi.sidl +++ b/bmi.sidl @@ -2,7 +2,7 @@ package csdms version 2.0b0 { interface bmi { int initialize(in string config_file); int update(); - int update_until(in double then); + int update_until(in double time); int finalize(); int get_component_name(out string name); From d7fca4142b0b722f72cdf9ec6712056249b747cb Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 17 Oct 2019 10:26:35 -0600 Subject: [PATCH 03/13] Use better getter/setter parameter names This is the result of a discussion with @mcflugen. We want to convey meaning in the arguments for the getter and setter methods. Using "dest_ptr" helps clarify that a reference to a data array is being returned through this *get_value_ptr* parameter. The "src" parameter name in *set_value* is congruent with *set_value_at_indices* and incongruent with "dest" in *get_value*. --- bmi.sidl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bmi.sidl b/bmi.sidl index 570eaa5..cfe460d 100644 --- a/bmi.sidl +++ b/bmi.sidl @@ -25,11 +25,11 @@ package csdms version 2.0b0 { int get_time_step(out double time_step); int get_value(in string name, in array<> dest); - int get_value_ptr(in string name, out array<> values); + int get_value_ptr(in string name, out array<> dest_ptr); int get_value_at_indices(in string name, in array<> dest, in array inds); - int set_value(in string name, in array<> values); + int set_value(in string name, in array<> src); int set_value_at_indices(in string name, in array inds, in array<> src); From 7b6a58b5864c0c17f71ef518a32d582aa79915c4 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 17 Oct 2019 10:46:57 -0600 Subject: [PATCH 04/13] Add short file header and descriptions of functional groupings --- bmi.sidl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bmi.sidl b/bmi.sidl index cfe460d..86cf34c 100644 --- a/bmi.sidl +++ b/bmi.sidl @@ -1,16 +1,23 @@ +// +// The Basic Model Interface (BMI) +// package csdms version 2.0b0 { interface bmi { + + // Initialize, run, finalize (IRF) int initialize(in string config_file); int update(); int update_until(in double time); int finalize(); + // Exchange items int get_component_name(out string name); int get_input_item_count(out int count); int get_output_item_count(out int count); int get_input_var_names(out array names); int get_output_var_names(out array names); + // Variable information int get_var_grid(in string name, out int grid); int get_var_type(in string name, out string type); int get_var_units(in string name, out string units); @@ -18,17 +25,20 @@ package csdms version 2.0b0 { int get_var_nbytes(in string name, out int nbytes); int get_var_location(in string name, out string location); + // Time information int get_current_time(out double time); int get_start_time(out double time); int get_end_time(out double time); int get_time_units(out string units); int get_time_step(out double time_step); + // Getters int get_value(in string name, in array<> dest); int get_value_ptr(in string name, out array<> dest_ptr); int get_value_at_indices(in string name, in array<> dest, in array inds); + // Setters int set_value(in string name, in array<> src); int set_value_at_indices(in string name, in array inds, in array<> src); @@ -52,7 +62,6 @@ package csdms version 2.0b0 { int get_grid_node_count(in int grid, out int count); int get_grid_edge_count(in int grid, out int count); int get_grid_face_count(in int grid, out int count); - int get_grid_edge_nodes(in int grid, out array edge_nodes); int get_grid_face_edges(in int grid, out array face_edges); int get_grid_face_nodes(in int grid, out array face_nodes); From 537032cecd910fbb42dd9c30e9a2e479614dfb2e Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 14 Nov 2019 12:59:50 -0700 Subject: [PATCH 05/13] Remove Travis CI file We run Travis on the individual language bindings and examples. --- .travis.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dbe37a5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: c - -compiler: - - gcc - -install: - - cd bindings/c - - mkdir _build - - cd _build - - cmake ../ -DCMAKE_INSTALL_PREFIX=$(pwd)/../_inst - - make install - -script: - - ctest From 2d031c61cb806d600acf7d78d3d6b96f60609e6e Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 14 Nov 2019 13:02:07 -0700 Subject: [PATCH 06/13] Remove Fortran 90 language bindings While the Fortran 90 bindings are still valid, the bindings based on Fortran 2003 (which also support Fortran 77 and 90/95) are preferred. --- .gitmodules | 3 --- bindings/f90 | 1 - 2 files changed, 4 deletions(-) delete mode 160000 bindings/f90 diff --git a/.gitmodules b/.gitmodules index 7109fa5..13af079 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "bindings/c"] path = bindings/c url = https://github.com/csdms/bmi-c -[submodule "bindings/f90"] - path = bindings/f90 - url = https://github.com/csdms/bmi-f90 [submodule "bindings/cxx"] path = bindings/cxx url = https://github.com/csdms/bmi-cxx diff --git a/bindings/f90 b/bindings/f90 deleted file mode 160000 index c544622..0000000 --- a/bindings/f90 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c5446223bb04f954cdb637912168559a0cfc4ff5 From f54eb3278bc45336b9b27c404cbb4832ca8a7050 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Thu, 14 Nov 2019 13:11:38 -0700 Subject: [PATCH 07/13] Update C and Fortran language bindings to v2.0 --- bindings/c | 2 +- bindings/fortran | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/c b/bindings/c index 8892f9c..970010e 160000 --- a/bindings/c +++ b/bindings/c @@ -1 +1 @@ -Subproject commit 8892f9cd5c1da9f3bb571ea74d78466b8fba1a08 +Subproject commit 970010e3f4660d095d50d3dae755debbf7f4dabb diff --git a/bindings/fortran b/bindings/fortran index fa44470..02d98c9 160000 --- a/bindings/fortran +++ b/bindings/fortran @@ -1 +1 @@ -Subproject commit fa444703fc6b332f75ea2b555134a3af1d944804 +Subproject commit 02d98c9f769b5b7b86aaf707740b610b30e7165c From 4bb7cbcf2432a3ca1a742fe75992d28307f16534 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 6 Dec 2019 17:04:02 -0700 Subject: [PATCH 08/13] Update C++ and Python language bindings to v2.0 --- bindings/cxx | 2 +- bindings/python | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/cxx b/bindings/cxx index 4e475c5..912a381 160000 --- a/bindings/cxx +++ b/bindings/cxx @@ -1 +1 @@ -Subproject commit 4e475c595bb1ad6ada7b2a369101442938ca4efd +Subproject commit 912a3812a26e92a04962eb7d8cddec66b170f2cc diff --git a/bindings/python b/bindings/python index b8efaf0..7f534c0 160000 --- a/bindings/python +++ b/bindings/python @@ -1 +1 @@ -Subproject commit b8efaf008407e1f9cfa0b9dca1ccc541d7bfce9f +Subproject commit 7f534c0a039246dbac9083c1d7280334d4e3fd7d From 44aefde62a6551a52f596415aeb304022ebd8229 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 6 Dec 2019 17:06:00 -0700 Subject: [PATCH 09/13] Remove Java language bindings While only minimal effort would be required to update the Java language bindings to v2.0 (and complete an example), we don't currently support Java in pymt. Pushing to BMI v2.1. --- .gitmodules | 3 --- bindings/java | 1 - 2 files changed, 4 deletions(-) delete mode 160000 bindings/java diff --git a/.gitmodules b/.gitmodules index 13af079..36152b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "bindings/fortran"] path = bindings/fortran url = https://github.com/csdms/bmi-fortran -[submodule "bindings/java"] - path = bindings/java - url = https://github.com/csdms/bmi-java [submodule "bindings/python"] path = bindings/python url = https://github.com/csdms/bmi-python diff --git a/bindings/java b/bindings/java deleted file mode 160000 index 28358c9..0000000 --- a/bindings/java +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 28358c96cd7b45c6be7f838ac4f89f1352933de1 From 3598a3a5d7378a248b3feea482114658b1df672e Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 6 Dec 2019 17:14:31 -0700 Subject: [PATCH 10/13] Update Python and Fortran examples to use v2.0 bindings --- examples/fortran | 2 +- examples/python | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fortran b/examples/fortran index 958d64f..37bc500 160000 --- a/examples/fortran +++ b/examples/fortran @@ -1 +1 @@ -Subproject commit 958d64f57b27d3fe4a252af70fbec99f562af4a1 +Subproject commit 37bc5006144e7b00bae3375e055b3a1e89a75f71 diff --git a/examples/python b/examples/python index 19db2e7..2bcb965 160000 --- a/examples/python +++ b/examples/python @@ -1 +1 @@ -Subproject commit 19db2e78020d9266d44b1a9f3a61e8ef13acb453 +Subproject commit 2bcb9658d8b5e41df8f817d4a464f230348fa479 From 6db035619a992fffa1f8f5b9e40a8e87160a85b6 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 6 Dec 2019 17:27:01 -0700 Subject: [PATCH 11/13] Add C++ and C examples using BMI v2,0 --- .gitmodules | 6 ++++++ examples/c | 1 + examples/cxx | 1 + 3 files changed, 8 insertions(+) create mode 160000 examples/c create mode 160000 examples/cxx diff --git a/.gitmodules b/.gitmodules index 36152b6..d7a9733 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,9 @@ [submodule "examples/fortran"] path = examples/fortran url = https://github.com/csdms/bmi-example-fortran +[submodule "examples/c"] + path = examples/c + url = https://github.com/csdms/bmi-example-c +[submodule "examples/cxx"] + path = examples/cxx + url = https://github.com/csdms/bmi-example-cxx diff --git a/examples/c b/examples/c new file mode 160000 index 0000000..6946093 --- /dev/null +++ b/examples/c @@ -0,0 +1 @@ +Subproject commit 6946093838298782dda02ff9e06f78f33686e15c diff --git a/examples/cxx b/examples/cxx new file mode 160000 index 0000000..fa0d781 --- /dev/null +++ b/examples/cxx @@ -0,0 +1 @@ +Subproject commit fa0d781ccb23ec2122bce0d45270ee92bb3d5a3f From 8adfeb400366aaa5092bc01f8522747cd186cb38 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 6 Dec 2019 17:30:52 -0700 Subject: [PATCH 12/13] Create links in repo root to language bindings --- bmi.f90 | 409 +--------------------------------- bmi.h | 65 +----- bmi.hxx | 69 +----- bmi.py | 663 +------------------------------------------------------- 4 files changed, 4 insertions(+), 1202 deletions(-) mode change 100644 => 120000 bmi.f90 mode change 100644 => 120000 bmi.h mode change 100644 => 120000 bmi.hxx mode change 100644 => 120000 bmi.py diff --git a/bmi.f90 b/bmi.f90 deleted file mode 100644 index eb232d4..0000000 --- a/bmi.f90 +++ /dev/null @@ -1,408 +0,0 @@ -module bmif - - implicit none - - integer, parameter :: BMI_MAX_COMPONENT_NAME = 2048 - integer, parameter :: BMI_MAX_VAR_NAME = 2048 - integer, parameter :: BMI_MAX_TYPE_NAME = 2048 - integer, parameter :: BMI_MAX_UNITS_NAME = 2048 - - integer, parameter :: BMI_FAILURE = 1 - integer, parameter :: BMI_SUCCESS = 0 - - type, abstract :: bmi - contains - procedure (bmif_get_component_name), deferred :: get_component_name - procedure (bmif_get_input_var_names), deferred :: get_input_var_names - procedure (bmif_get_output_var_names), deferred :: get_output_var_names - procedure (bmif_initialize), deferred :: initialize - procedure (bmif_finalize), deferred :: finalize - procedure (bmif_get_start_time), deferred :: get_start_time - procedure (bmif_get_end_time), deferred :: get_end_time - procedure (bmif_get_current_time), deferred :: get_current_time - procedure (bmif_get_time_step), deferred :: get_time_step - procedure (bmif_get_time_units), deferred :: get_time_units - procedure (bmif_update), deferred :: update - procedure (bmif_update_frac), deferred :: update_frac - procedure (bmif_update_until), deferred :: update_until - procedure (bmif_get_var_grid), deferred :: get_var_grid - procedure (bmif_get_grid_type), deferred :: get_grid_type - procedure (bmif_get_grid_rank), deferred :: get_grid_rank - procedure (bmif_get_grid_shape), deferred :: get_grid_shape - procedure (bmif_get_grid_size), deferred :: get_grid_size - procedure (bmif_get_grid_spacing), deferred :: get_grid_spacing - procedure (bmif_get_grid_origin), deferred :: get_grid_origin - procedure (bmif_get_grid_x), deferred :: get_grid_x - procedure (bmif_get_grid_y), deferred :: get_grid_y - procedure (bmif_get_grid_z), deferred :: get_grid_z - procedure (bmif_get_grid_connectivity), deferred :: get_grid_connectivity - procedure (bmif_get_grid_offset), deferred :: get_grid_offset - procedure (bmif_get_var_type), deferred :: get_var_type - procedure (bmif_get_var_units), deferred :: get_var_units - procedure (bmif_get_var_itemsize), deferred :: get_var_itemsize - procedure (bmif_get_var_nbytes), deferred :: get_var_nbytes - procedure (bmif_get_value_int), deferred :: get_value_int - procedure (bmif_get_value_float), deferred :: get_value_float - procedure (bmif_get_value_double), deferred :: get_value_double - procedure (bmif_get_value_ptr_int), deferred :: get_value_ptr_int - procedure (bmif_get_value_ptr_float), deferred :: get_value_ptr_float - procedure (bmif_get_value_ptr_double), deferred :: get_value_ptr_double - procedure (bmif_get_value_at_indices_int), deferred :: get_value_at_indices_int - procedure (bmif_get_value_at_indices_float), deferred :: get_value_at_indices_float - procedure (bmif_get_value_at_indices_double), deferred :: get_value_at_indices_double - procedure (bmif_set_value_int), deferred :: set_value_int - procedure (bmif_set_value_float), deferred :: set_value_float - procedure (bmif_set_value_double), deferred :: set_value_double - procedure (bmif_set_value_at_indices_int), deferred :: set_value_at_indices_int - procedure (bmif_set_value_at_indices_float), deferred :: set_value_at_indices_float - procedure (bmif_set_value_at_indices_double), deferred :: set_value_at_indices_double - end type bmi - - abstract interface - - function bmif_get_component_name(this, name) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), pointer, intent(out) :: name - integer :: bmi_status - end function bmif_get_component_name - - function bmif_get_input_var_names(this, names) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), pointer, intent(out) :: names(:) - integer :: bmi_status - end function bmif_get_input_var_names - - function bmif_get_output_var_names(this, names) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), pointer, intent(out) :: names(:) - integer :: bmi_status - end function bmif_get_output_var_names - - function bmif_initialize(this, config_file) result(bmi_status) - import :: bmi - class (bmi), intent(out) :: this - character (len=*), intent(in) :: config_file - integer :: bmi_status - end function bmif_initialize - - function bmif_finalize(this) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - integer :: bmi_status - end function bmif_finalize - - function bmif_get_start_time(this, time) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - double precision, intent(out) :: time - integer :: bmi_status - end function bmif_get_start_time - - function bmif_get_end_time(this, time) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - double precision, intent(out) :: time - integer :: bmi_status - end function bmif_get_end_time - - function bmif_get_current_time(this, time) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - double precision, intent(out) :: time - integer :: bmi_status - end function bmif_get_current_time - - function bmif_get_time_step(this, time_step) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - double precision, intent(out) :: time_step - integer :: bmi_status - end function bmif_get_time_step - - function bmif_get_time_units(this, time_units) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(out) :: time_units - integer :: bmi_status - end function bmif_get_time_units - - function bmif_update(this) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - integer :: bmi_status - end function bmif_update - - function bmif_update_frac(this, time_frac) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - double precision, intent(in) :: time_frac - integer :: bmi_status - end function bmif_update_frac - - function bmif_update_until(this, time) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - double precision, intent(in) :: time - integer :: bmi_status - end function bmif_update_until - - function bmif_get_var_grid(this, var_name, grid_id) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - integer, intent(out) :: grid_id - integer :: bmi_status - end function bmif_get_var_grid - - function bmif_get_grid_type(this, grid_id, grid_type) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - character (len=*), intent(out) :: grid_type - integer :: bmi_status - end function bmif_get_grid_type - - function bmif_get_grid_rank(this, grid_id, grid_rank) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - integer, intent(out) :: grid_rank - integer :: bmi_status - end function bmif_get_grid_rank - - function bmif_get_grid_shape(this, grid_id, grid_shape) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - integer, dimension(:), intent(out) :: grid_shape - integer :: bmi_status - end function bmif_get_grid_shape - - function bmif_get_grid_size(this, grid_id, grid_size) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - integer, intent(out) :: grid_size - integer :: bmi_status - end function bmif_get_grid_size - - function bmif_get_grid_spacing(this, grid_id, grid_spacing) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - double precision, dimension(:), intent(out) :: grid_spacing - integer :: bmi_status - end function bmif_get_grid_spacing - - function bmif_get_grid_origin(this, grid_id, grid_origin) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - double precision, dimension(:), intent(out) :: grid_origin - integer :: bmi_status - end function bmif_get_grid_origin - - function bmif_get_grid_x(this, grid_id, grid_x) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - double precision, dimension(:), intent(out) :: grid_x - integer :: bmi_status - end function bmif_get_grid_x - - function bmif_get_grid_y(this, grid_id, grid_y) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - double precision, dimension(:), intent(out) :: grid_y - integer :: bmi_status - end function bmif_get_grid_y - - function bmif_get_grid_z(this, grid_id, grid_z) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - double precision, dimension(:), intent(out) :: grid_z - integer :: bmi_status - end function bmif_get_grid_z - - function bmif_get_grid_connectivity(this, grid_id, grid_conn) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - integer, dimension(:), intent(out) :: grid_conn - integer :: bmi_status - end function bmif_get_grid_connectivity - - function bmif_get_grid_offset(this, grid_id, grid_offset) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - integer, intent(in) :: grid_id - integer, dimension(:), intent(out) :: grid_offset - integer :: bmi_status - end function bmif_get_grid_offset - - function bmif_get_var_type(this, var_name, var_type) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - character (len=*), intent(out) :: var_type - integer :: bmi_status - end function bmif_get_var_type - - function bmif_get_var_units(this, var_name, var_units) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - character (len=*), intent(out) :: var_units - integer :: bmi_status - end function bmif_get_var_units - - function bmif_get_var_itemsize(this, var_name, var_size) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - integer, intent(out) :: var_size - integer :: bmi_status - end function bmif_get_var_itemsize - - function bmif_get_var_nbytes(this, var_name, var_nbytes) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - integer, intent(out) :: var_nbytes - integer :: bmi_status - end function bmif_get_var_nbytes - - function bmif_get_value_int(this, var_name, dest) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - integer, intent(inout) :: dest(:) - integer :: bmi_status - end function bmif_get_value_int - - function bmif_get_value_float(this, var_name, dest) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - real, intent(inout) :: dest(:) - integer :: bmi_status - end function bmif_get_value_float - - function bmif_get_value_double(this, var_name, dest) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - double precision, intent(inout) :: dest(:) - integer :: bmi_status - end function bmif_get_value_double - - function bmif_get_value_ptr_int(this, var_name, dest) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - integer, pointer, intent(inout) :: dest(:) - integer :: bmi_status - end function bmif_get_value_ptr_int - - function bmif_get_value_ptr_float(this, var_name, dest) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - real, pointer, intent(inout) :: dest(:) - integer :: bmi_status - end function bmif_get_value_ptr_float - - function bmif_get_value_ptr_double(this, var_name, dest) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - double precision, pointer, intent(inout) :: dest(:) - integer :: bmi_status - end function bmif_get_value_ptr_double - - function bmif_get_value_at_indices_int(this, var_name, dest, indices) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - integer, intent(inout) :: dest(:) - integer, intent(in) :: indices(:) - integer :: bmi_status - end function bmif_get_value_at_indices_int - - function bmif_get_value_at_indices_float(this, var_name, dest, indices) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - real, intent(inout) :: dest(:) - integer, intent(in) :: indices(:) - integer :: bmi_status - end function bmif_get_value_at_indices_float - - function bmif_get_value_at_indices_double(this, var_name, dest, indices) result(bmi_status) - import :: bmi - class (bmi), intent(in) :: this - character (len=*), intent(in) :: var_name - double precision, intent(inout) :: dest(:) - integer, intent(in) :: indices(:) - integer :: bmi_status - end function bmif_get_value_at_indices_double - - function bmif_set_value_int(this, var_name, src) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - character (len=*), intent(in) :: var_name - integer, intent(in) :: src(:) - integer :: bmi_status - end function bmif_set_value_int - - function bmif_set_value_float(this, var_name, src) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - character (len=*), intent(in) :: var_name - real, intent(in) :: src(:) - integer :: bmi_status - end function bmif_set_value_float - - function bmif_set_value_double(this, var_name, src) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - character (len=*), intent(in) :: var_name - double precision, intent(in) :: src(:) - integer :: bmi_status - end function bmif_set_value_double - - function bmif_set_value_at_indices_int(this, var_name, indices, src) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - character (len=*), intent(in) :: var_name - integer, intent(in) :: indices(:) - integer, intent(in) :: src(:) - integer :: bmi_status - end function bmif_set_value_at_indices_int - - function bmif_set_value_at_indices_float(this, var_name, indices, src) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - character (len=*), intent(in) :: var_name - integer, intent(in) :: indices(:) - real, intent(in) :: src(:) - integer :: bmi_status - end function bmif_set_value_at_indices_float - - function bmif_set_value_at_indices_double(this, var_name, indices, src) result(bmi_status) - import :: bmi - class (bmi), intent(inout) :: this - character (len=*), intent(in) :: var_name - integer, intent(in) :: indices(:) - double precision, intent(in) :: src(:) - integer :: bmi_status - end function bmif_set_value_at_indices_double - - end interface - -end module bmif diff --git a/bmi.f90 b/bmi.f90 new file mode 120000 index 0000000..71c27ae --- /dev/null +++ b/bmi.f90 @@ -0,0 +1 @@ +bindings/fortran/bmi.f90 \ No newline at end of file diff --git a/bmi.h b/bmi.h deleted file mode 100644 index 0dfdf45..0000000 --- a/bmi.h +++ /dev/null @@ -1,64 +0,0 @@ -#define BMI_SUCCESS (0) -#define BMI_FAILURE (1) - -#define BMI_MAX_UNITS_NAME (2048) -#define BMI_MAX_COMPONENT_NAME (2048) -#define BMI_MAX_VAR_NAME (2048) - -typedef struct { - void * self; - - int (*initialize)(void *self, char *config_file); - int (*update)(void *self, double time_interval); - int (*finalize)(void *self); - - int (*get_component_name)(void *self, char *name); - int (*get_input_item_count)(void *self, int *count); - int (*get_output_item_count)(void *self, int *count); - int (*get_input_var_names)(void *self, char **names); - int (*get_output_var_names)(void *self, char **names); - - int (*get_var_grid)(void *self, char *name, int *grid_id); - int (*get_var_type)(void *self, char *name, char *type); - int (*get_var_units)(void *self, char *name, char *units); - int (*get_var_itemsize)(void *self, char *name, int *size); - int (*get_var_nbytes)(void *self, char *name, int *nbytes); - int (*get_var_location)(void *self, char *name, char *location); - - int (*get_current_time)(void *self, double *time); - int (*get_start_time)(void *self, double *time); - int (*get_end_time)(void *self, double *time); - int (*get_time_units)(void *self, char *units); - int (*get_time_step)(void *self, double *time_step); - - int (*get_value)(void *self, char *name, void *dest); - int (*get_value_ptr)(void *self, char *name, void **values); - int (*get_value_at_indices)(void *self, char *name, void *dest, int *inds, int count); - - int (*set_value)(void *self, char *name, void *values); - int (*set_value_at_indices)(void *self, char *name, void *values, void *inds, int count); - - // Grid information - int (*get_grid_rank)(void *self, int grid, int *rank); - int (*get_grid_size)(void *self, int grid, int *size); - int (*get_grid_type)(void *self, int grid, char *type); - - // Uniform rectilinear - int (*get_grid_shape)(void *self, int grid, int *shape); - int (*get_grid_spacing)(void *self, int grid, double *spacing); - int (*get_grid_origin)(void *self, int grid, double *origin); - - // Non-uniform rectilinear, curvilinear - int (*get_grid_x)(void *self, int grid, double *x); - int (*get_grid_y)(void *self, int grid, double *y); - int (*get_grid_z)(void *self, int grid, double *z); - - int (*get_grid_node_count)(void *self, int grid, int *count); - int (*get_grid_edge_count)(void *self, int grid, int *count); - int (*get_grid_face_count)(void *self, int grid, int *count); - - int (*get_grid_edge_nodes)(void *self, int grid, int *edge_nodes); - int (*get_grid_face_edges)(void *self, int grid, int *face_edges); - int (*get_grid_face_nodes)(void *self, int grid, int *face_nodes); - int (*get_grid_nodes_per_face)(void *self, int grid, int *nodes_per_face); -} Bmi; diff --git a/bmi.h b/bmi.h new file mode 120000 index 0000000..b78dfb7 --- /dev/null +++ b/bmi.h @@ -0,0 +1 @@ +bindings/c/bmi.h \ No newline at end of file diff --git a/bmi.hxx b/bmi.hxx deleted file mode 100644 index dd62639..0000000 --- a/bmi.hxx +++ /dev/null @@ -1,68 +0,0 @@ -namespace bmi { - - const int MAX_COMPONENT_NAME = 2048; - const int MAX_VAR_NAME = 2048; - const int MAX_UNITS_NAME = 2048; - - class Bmi { - public: - // Model control functions. - virtual void Initialize(const char *config_file) = 0; - virtual void Update() = 0; - virtual void UpdateUntil(double time) = 0; - virtual void Finalize() = 0; - - // Model information functions. - virtual void GetComponentName(char * const name) = 0; - virtual int GetInputVarNameCount(void) = 0; - virtual int GetOutputVarNameCount(void) = 0; - virtual void GetInputVarNames(char **names) = 0; - virtual void GetOutputVarNames(char **names) = 0; - - // Variable information functions - virtual int GetVarGrid(const char *name) = 0; - virtual void GetVarType(const char *name, char *vtype) = 0; - virtual void GetVarUnits (const char *name, char *units) = 0; - virtual int GetVarItemsize(const char *name) = 0; - virtual int GetVarNbytes(const char *name) = 0; - virtual void GetVarLocation(const char *name, char *location) = 0; - - virtual double GetCurrentTime(void) = 0; - virtual double GetStartTime(void) = 0; - virtual double GetEndTime(void) = 0; - virtual void GetTimeUnits(char *units) = 0; - virtual double GetTimeStep(void) = 0; - - // Variable getters - virtual void GetValue(const char *name, void *dest) = 0; - virtual void *GetValuePtr(const char *name) = 0; - virtual void *GetValueAtIndices(const char *name, void *dest, int *inds, int count) = 0; - - // Variable setters - virtual void SetValue(const char *name, void *values) = 0; - virtual void SetValueAtIndices(const char *name, void *values, int *inds, int count) = 0; - - // Grid information functions - virtual int GetGridRank(const int grid) = 0; - virtual int GetGridSize(const int grid) = 0; - virtual void GetGridType(const int grid, char *gtype) = 0; - - virtual void GetGridShape(const int grid, int *shape) = 0; - virtual void GetGridSpacing(const int grid, double *spacing) = 0; - virtual void GetGridOrigin(const int grid, double *origin) = 0; - - virtual void GetGridX(const int grid, double *dest) = 0; - virtual void GetGridY(const int grid, double *dest) = 0; - virtual void GetGridZ(const int grid, double *dest) = 0; - - virtual int GetGridNodeCount(const int grid) = 0; - virtual int GetGridEdgeCount(const int grid) = 0; - virtual int GetGridFaceCount(const int grid) = 0; - - virtual void GetGridEdgeNodes(const int grid, int *edge_nodes) = 0; - virtual void GetGridFaceEdges(const int grid, int *face_edges) = 0; - virtual void GetGridFaceNodes(const int grid, int *face_nodes) = 0; - virtual void GetGridNodesPerFace(const int, int *nodes_per_face) = 0; - }; -} - diff --git a/bmi.hxx b/bmi.hxx new file mode 120000 index 0000000..ceaf89f --- /dev/null +++ b/bmi.hxx @@ -0,0 +1 @@ +bindings/cxx/bmi.hxx \ No newline at end of file diff --git a/bmi.py b/bmi.py deleted file mode 100644 index f115a0a..0000000 --- a/bmi.py +++ /dev/null @@ -1,662 +0,0 @@ -from abc import ABC, abstractmethod -from typing import Tuple - -import numpy as np - - -class Bmi(ABC): - @abstractmethod - def initialize(self, config_file: str) -> None: - """Perform startup tasks for the model. - - Perform all tasks that take place before entering the model's time - loop, including opening files and initializing the model state. Model - inputs are read from a text-based configuration file, specified by - `filename`. - - Parameters - ---------- - config_file : str, optional - The path to the model configuration file. - - Notes - ----- - Models should be refactored, if necessary, to use a - configuration file. CSDMS does not impose any constraint on - how configuration files are formatted, although YAML is - recommended. A template of a model's configuration file - with placeholder values is used by the BMI. - """ - ... - - @abstractmethod - def update(self) -> None: - """Advance model state by one time step. - - Perform all tasks that take place within one pass through the model's - time loop. This typically includes incrementing all of the model's - state variables. If the model's state variables don't change in time, - then they can be computed by the :func:`initialize` method and this - method can return with no action. - """ - ... - - @abstractmethod - def finalize(self) -> None: - """Perform tear-down tasks for the model. - - Perform all tasks that take place after exiting the model's time - loop. This typically includes deallocating memory, closing files and - printing reports. - """ - ... - - @abstractmethod - def get_component_name(self) -> str: - """Name of the component. - - Returns - ------- - str - The name of the component. - """ - ... - - @abstractmethod - def get_input_var_names(self) -> Tuple[str]: - """List of a model's input variables. - - Input variable names must be CSDMS Standard Names, also known - as *long variable names*. - - Returns - ------- - list of str - The input variables for the model. - - Notes - ----- - Standard Names enable the CSDMS framework to determine whether - an input variable in one model is equivalent to, or compatible - with, an output variable in another model. This allows the - framework to automatically connect components. - - Standard Names do not have to be used within the model. - """ - ... - - @abstractmethod - def get_output_var_names(self) -> Tuple[str]: - """List of a model's output variables. - - Output variable names must be CSDMS Standard Names, also known - as *long variable names*. - - Returns - ------- - list of str - The output variables for the model. - """ - ... - - @abstractmethod - def get_var_grid(self, name: str) -> int: - """Get grid identifier for the given variable. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - int - The grid identifier. - """ - ... - - @abstractmethod - def get_var_type(self, name: str) -> str: - """Get data type of the given variable. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - str - The Python variable type; e.g., ``str``, ``int``, ``float``. - """ - ... - - @abstractmethod - def get_var_units(self, name: str) -> str: - """Get units of the given variable. - - Standard unit names, in lower case, should be used, such as - ``meters`` or ``seconds``. Standard abbreviations, like ``m`` for - meters, are also supported. For variables with compound units, - each unit name is separated by a single space, with exponents - other than 1 placed immediately after the name, as in ``m s-1`` - for velocity, ``W m-2`` for an energy flux, or ``km2`` for an - area. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - str - The variable units. - - Notes - ----- - CSDMS uses the `UDUNITS`_ standard from Unidata. - - .. _UDUNITS: http://www.unidata.ucar.edu/software/udunits - """ - ... - - @abstractmethod - def get_var_itemsize(self, name: str) -> int: - """Get memory use for each array element in bytes. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - int - Item size in bytes. - """ - ... - - @abstractmethod - def get_var_nbytes(self, name: str) -> int: - """Get size, in bytes, of the given variable. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - int - The size of the variable, counted in bytes. - """ - ... - - @abstractmethod - def get_var_location(self, name: str) -> str: - """Get the grid element type that the a given variable is defined on. - - The grid topology can be composed of *nodes*, *edges*, and *faces*. - - *node* - A point that has a coordinate pair or triplet: the most - basic element of the topology. - - *edge* - A line or curve bounded by two *nodes*. - - *face* - A plane or surface enclosed by a set of edges. In a 2D - horizontal application one may consider the word “polygon”, - but in the hierarchy of elements the word “face” is most common. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - str - The grid location on which the variable is defined. Must be one of - `"node"`, `"edge"`, or `"face"`. - - Notes - ----- - CSDMS uses the `ugrid conventions`_ to define unstructured grids. - - .. _UGRID: http://ugrid-conventions.github.io/ugrid-conventions - """ - ... - - @abstractmethod - def get_current_time(self) -> float: - """Current time of the model. - - Returns - ------- - float - The current model time. - """ - ... - - @abstractmethod - def get_start_time(self) -> float: - """Start time of the model. - - Model times should be of type float. - - Returns - ------- - float - The model start time. - """ - ... - - @abstractmethod - def get_end_time(self) -> float: - """End time of the model. - - Returns - ------- - float - The maximum model time. - """ - ... - - @abstractmethod - def get_time_units(self) -> str: - """Time units of the model. - - Returns - ------- - float - The model time unit; e.g., `days` or `s`. - - Notes - ----- - CSDMS uses the UDUNITS standard from Unidata. - """ - ... - - @abstractmethod - def get_time_step(self) -> float: - """Current time step of the model. - - The model time step should be of type float. - - Returns - ------- - float - The time step used in model. - """ - ... - - @abstractmethod - def get_value(self, name: str, dest: np.ndarray) -> np.ndarray: - """Get a copy of values of the given variable. - - This is a getter for the model, used to access the model's - current state. It returns a *copy* of a model variable, with - the return type, size and rank dependent on the variable. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - dest : ndarray - A numpy array into which to place the values. - - Returns - ------- - ndarray - The same numpy array that was passed as an input buffer. - """ - ... - - @abstractmethod - def get_value_ptr(self, name: str) -> np.ndarray: - """Get a reference to values of the given variable. - - This is a getter for the model, used to access the model's - current state. It returns a reference to a model variable, - with the return type, size and rank dependent on the variable. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - - Returns - ------- - array_like - A reference to a model variable. - """ - ... - - @abstractmethod - def get_value_at_indices( - self, name: str, dest: np.ndarray, inds: np.ndarray - ) -> np.ndarray: - """Get values at particular indices. - - Parameters - ---------- - name : str - An input or output variable name, a CSDMS Standard Name. - dest : ndarray - A numpy array into which to place the values. - indices : array_like - The indices into the variable array. - - Returns - ------- - array_like - Value of the model variable at the given location. - """ - ... - - @abstractmethod - def set_value(self, name: str, values: np.ndarray) -> None: - """Specify a new value for a model variable. - - This is the setter for the model, used to change the model's - current state. It accepts, through *src*, a new value for a - model variable, with the type, size and rank of *src* - dependent on the variable. - - Parameters - ---------- - var_name : str - An input or output variable name, a CSDMS Standard Name. - src : array_like - The new value for the specified variable. - """ - ... - - @abstractmethod - def set_value_at_indices( - self, name: str, inds: np.ndarray, src: np.ndarray - ) -> None: - """Specify a new value for a model variable at particular indices. - - Parameters - ---------- - var_name : str - An input or output variable name, a CSDMS Standard Name. - indices : array_like - The indices into the variable array. - src : array_like - The new value for the specified variable. - """ - ... - - # Grid information - @abstractmethod - def get_grid_rank(self, grid: int) -> int: - """Get number of dimensions of the computational grid. - - Parameters - ---------- - grid : int - A grid identifier. - - Returns - ------- - int - Rank of the grid. - """ - ... - - @abstractmethod - def get_grid_size(self, grid: int) -> int: - """Get the total number of elements in the computational grid. - - Parameters - ---------- - grid : int - A grid identifier. - - Returns - ------- - int - Size of the grid. - """ - ... - - @abstractmethod - def get_grid_type(self, grid: int) -> str: - """Get the grid type as a string. - - Parameters - ---------- - grid : int - A grid identifier. - - Returns - ------- - str - Type of grid as a string. - """ - ... - - # Uniform rectilinear - @abstractmethod - def get_grid_shape(self, grid: int, shape: np.ndarray) -> np.ndarray: - """Get dimensions of the computational grid. - - Parameters - ---------- - grid : int - A grid identifier. - shape : ndarray of int, shape *(ndim,)* - A numpy array into which to place the shape of the grid. - - Returns - ------- - ndarray of int - The input numpy array that holds the grid's shape. - """ - ... - - @abstractmethod - def get_grid_spacing(self, grid: int, spacing: np.ndarray) -> np.ndarray: - """Get distance between nodes of the computational grid. - - Parameters - ---------- - grid : int - A grid identifier. - spacing : ndarray of float, shape *(ndim,)* - A numpy array to hold the spacing between grid rows and columns. - - Returns - ------- - ndarray of float - The input numpy array that holds the grid's spacing. - """ - ... - - @abstractmethod - def get_grid_origin(self, grid: int, origin: np.ndarray) -> np.ndarray: - """Get coordinates for the lower-left corner of the computational grid. - - Parameters - ---------- - grid : int - A grid identifier. - origin : ndarray of float, shape *(ndim,)* - A numpy array to hold the coordinates of the lower-left corner of - the grid. - - Returns - ------- - ndarray of float - The input numpy array that holds the coordinates of the grid's - lower-left corner. - """ - ... - - # Non-uniform rectilinear, curvilinear - @abstractmethod - def get_grid_x(self, grid: int, x: np.ndarray) -> np.ndarray: - """Get coordinates of grid nodes in the x direction. - - Parameters - ---------- - grid : int - A grid identifier. - x : ndarray of float, shape *(nrows,)* - A numpy array to hold the x-coordinates of the grid node columns. - - Returns - ------- - ndarray of float - The input numpy array that holds the grid's column x-coordinates. - """ - ... - - @abstractmethod - def get_grid_y(self, grid: int, y: np.ndarray) -> np.ndarray: - """Get coordinates of grid nodes in the y direction. - - Parameters - ---------- - grid : int - A grid identifier. - y : ndarray of float, shape *(ncols,)* - A numpy array to hold the y-coordinates of the grid node rows. - - Returns - ------- - ndarray of float - The input numpy array that holds the grid's row y-coordinates. - """ - ... - - @abstractmethod - def get_grid_z(self, grid: int, z: np.ndarray) -> np.ndarray: - """Get coordinates of grid nodes in the z direction. - - Parameters - ---------- - grid : int - A grid identifier. - z : ndarray of float, shape *(nlayers,)* - A numpy array to hold the z-coordinates of the grid nodes layers. - - Returns - ------- - ndarray of float - The input numpy array that holds the grid's layer z-coordinates. - """ - ... - - @abstractmethod - def get_grid_node_count(self, grid: int) -> int: - """Get the number of nodes in the grid. - - Parameters - ---------- - grid : int - A grid identifier. - - Returns - ------- - int - The total number of grid nodes. - """ - ... - - @abstractmethod - def get_grid_edge_count(self, grid: int) -> int: - """Get the number of edges in the grid. - - Parameters - ---------- - grid : int - A grid identifier. - - Returns - ------- - int - The total number of grid edges. - """ - ... - - @abstractmethod - def get_grid_face_count(self, grid: int) -> int: - """Get the number of faces in the grid. - - Parameters - ---------- - grid : int - A grid identifier. - - Returns - ------- - int - The total number of grid faces. - """ - ... - - @abstractmethod - def get_grid_edge_nodes(self, grid: int, edge_nodes: np.ndarray) -> np.ndarray: - """Get the edge-node connectivity. - - Parameters - ---------- - grid : int - A grid identifier. - edge_nodes : ndarray of int, shape *(2 x nnodes,)* - A numpy array to place the edge-node connectivity. For each edge, - connectivity is given as node at edge tail, followed by node at - edge head. - - Returns - ------- - ndarray of int - The input numpy array that holds the edge-node connectivity. - """ - ... - - @abstractmethod - def get_grid_face_nodes(self, grid: int, face_nodes: np.ndarray) -> np.ndarray: - """Get the face-node connectivity. - - Parameters - ---------- - grid : int - A grid identifier. - face_nodes : ndarray of int - A numpy array to place the face-node connectivity. For each face, - the nodes (listed in a counter-clockwise direction) that form the - boundary of the face. - - Returns - ------- - ndarray of int - The input numpy array that holds the face-node connectivity. - """ - ... - - @abstractmethod - def get_grid_nodes_per_face( - self, grid: int, nodes_per_face: np.ndarray - ) -> np.ndarray: - """Get the number of nodes for each face. - - Parameters - ---------- - grid : int - A grid identifier. - nodes_per_face : ndarray of int, shape *(nfaces,)* - A numpy array to place the number of edges per face. - - Returns - ------- - ndarray of int - The input numpy array that holds the number of nodes per edge. - """ - ... diff --git a/bmi.py b/bmi.py new file mode 120000 index 0000000..fdf6a78 --- /dev/null +++ b/bmi.py @@ -0,0 +1 @@ +bindings/python/bmipy/bmi.py \ No newline at end of file From dc5958872bce38832b7c29f2e5a50b3a4a805640 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 6 Dec 2019 20:33:52 -0700 Subject: [PATCH 13/13] Fix imports on Linux; update to v2.0 This is https://github.com/csdms/bmi-example-cxx/pull/6. --- examples/cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cxx b/examples/cxx index fa0d781..651e1e5 160000 --- a/examples/cxx +++ b/examples/cxx @@ -1 +1 @@ -Subproject commit fa0d781ccb23ec2122bce0d45270ee92bb3d5a3f +Subproject commit 651e1e5c6f0b297b999d751179dea481b060ed04