NGen
Loading...
Searching...
No Matches
bmi.h
1// The Basic Model Interface (BMI) C specification.
2//
3// This language specification is derived from the Scientific
4// Interface Definition Language (SIDL) file bmi.sidl located at
5// https://github.com/csdms/bmi.
6//
7// bmi-c repo: https://github.com/csdms/bmi-c
8// Version 2.0, commit: e6f9f8a0ab326218831000b4a5571490ebc21ea2
9
10/*
11Usage granted under the following license:
12
13The MIT License (MIT)
14
15Copyright (c) 2014 Community Surface Dynamics Modeling System
16
17Permission is hereby granted, free of charge, to any person obtaining a copy
18of this software and associated documentation files (the "Software"), to deal
19in the Software without restriction, including without limitation the rights
20to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21copies of the Software, and to permit persons to whom the Software is
22furnished to do so, subject to the following conditions:
23
24The above copyright notice and this permission notice shall be included in all
25copies or substantial portions of the Software.
26
27THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33SOFTWARE.
34 */
35
36#ifndef BMI_H
37#define BMI_H
38
39#if defined(__cplusplus)
40extern "C" {
41#endif
42
43#define BMI_SUCCESS (0)
44#define BMI_FAILURE (1)
45
46#define BMI_MAX_UNITS_NAME (2048)
47#define BMI_MAX_TYPE_NAME (2048)
48#define BMI_MAX_COMPONENT_NAME (2048)
49#define BMI_MAX_VAR_NAME (2048)
50#define BMI_MAX_LOCATION_NAME (2048)
51
52
53typedef struct Bmi {
54 void *data;
55
56 /* Initialize, run, finalize (IRF) */
57 int (*initialize)(struct Bmi *self, const char *config_file);
58 int (*update)(struct Bmi *self);
59 int (*update_until)(struct Bmi *self, double then);
60 int (*finalize)(struct Bmi *self);
61
62 /* Exchange items */
63 int (*get_component_name)(struct Bmi *self, char *name);
64 int (*get_input_item_count)(struct Bmi *self, int *count);
65 int (*get_output_item_count)(struct Bmi *self, int *count);
66 int (*get_input_var_names)(struct Bmi *self, char **names);
67 int (*get_output_var_names)(struct Bmi *self, char **names);
68
69 /* Variable information */
70 int (*get_var_grid)(struct Bmi *self, const char *name, int *grid);
71 int (*get_var_type)(struct Bmi *self, const char *name, char *type);
72 int (*get_var_units)(struct Bmi *self, const char *name, char *units);
73 int (*get_var_itemsize)(struct Bmi *self, const char *name, int *size);
74 int (*get_var_nbytes)(struct Bmi *self, const char *name, int *nbytes);
75 int (*get_var_location)(struct Bmi *self, const char *name, char *location);
76
77 /* Time information */
78 int (*get_current_time)(struct Bmi *self, double *time);
79 int (*get_start_time)(struct Bmi *self, double *time);
80 int (*get_end_time)(struct Bmi *self, double *time);
81 int (*get_time_units)(struct Bmi *self, char *units);
82 int (*get_time_step)(struct Bmi *self, double *time_step);
83
84 /* Getters */
85 int (*get_value)(struct Bmi *self, const char *name, void *dest);
86 int (*get_value_ptr)(struct Bmi *self, const char *name, void **dest_ptr);
87 int (*get_value_at_indices)(struct Bmi *self, const char *name, void *dest, int *inds, int count);
88
89 /* Setters */
90 int (*set_value)(struct Bmi *self, const char *name, void *src);
91 int (*set_value_at_indices)(struct Bmi *self, const char *name, int *inds, int count, void *src);
92
93 /* Grid information */
94 int (*get_grid_rank)(struct Bmi *self, int grid, int *rank);
95 int (*get_grid_size)(struct Bmi *self, int grid, int *size);
96 int (*get_grid_type)(struct Bmi *self, int grid, char *type);
97
98 /* Uniform rectilinear */
99 int (*get_grid_shape)(struct Bmi *self, int grid, int *shape);
100 int (*get_grid_spacing)(struct Bmi *self, int grid, double *spacing);
101 int (*get_grid_origin)(struct Bmi *self, int grid, double *origin);
102
103 /* Non-uniform rectilinear, curvilinear */
104 int (*get_grid_x)(struct Bmi *self, int grid, double *x);
105 int (*get_grid_y)(struct Bmi *self, int grid, double *y);
106 int (*get_grid_z)(struct Bmi *self, int grid, double *z);
107
108 /* Unstructured */
109 int (*get_grid_node_count)(struct Bmi *self, int grid, int *count);
110 int (*get_grid_edge_count)(struct Bmi *self, int grid, int *count);
111 int (*get_grid_face_count)(struct Bmi *self, int grid, int *count);
112 int (*get_grid_edge_nodes)(struct Bmi *self, int grid, int *edge_nodes);
113 int (*get_grid_face_edges)(struct Bmi *self, int grid, int *face_edges);
114 int (*get_grid_face_nodes)(struct Bmi *self, int grid, int *face_nodes);
115 int (*get_grid_nodes_per_face)(struct Bmi *self, int grid, int *nodes_per_face);
116} Bmi;
117
118
119#if defined(__cplusplus)
120}
121#endif
122
123#endif
Definition bmi.h:53
int(* get_end_time)(struct Bmi *self, double *time)
Definition bmi.h:80
int(* finalize)(struct Bmi *self)
Definition bmi.h:60
int(* get_start_time)(struct Bmi *self, double *time)
Definition bmi.h:79
int(* get_grid_edge_count)(struct Bmi *self, int grid, int *count)
Definition bmi.h:110
int(* get_output_var_names)(struct Bmi *self, char **names)
Definition bmi.h:67
int(* update_until)(struct Bmi *self, double then)
Definition bmi.h:59
int(* get_grid_node_count)(struct Bmi *self, int grid, int *count)
Definition bmi.h:109
int(* get_var_type)(struct Bmi *self, const char *name, char *type)
Definition bmi.h:71
void * data
Definition bmi.h:54
int(* get_grid_x)(struct Bmi *self, int grid, double *x)
Definition bmi.h:104
int(* set_value_at_indices)(struct Bmi *self, const char *name, int *inds, int count, void *src)
Definition bmi.h:91
int(* get_grid_face_nodes)(struct Bmi *self, int grid, int *face_nodes)
Definition bmi.h:114
int(* get_grid_y)(struct Bmi *self, int grid, double *y)
Definition bmi.h:105
int(* get_value_at_indices)(struct Bmi *self, const char *name, void *dest, int *inds, int count)
Definition bmi.h:87
int(* get_input_var_names)(struct Bmi *self, char **names)
Definition bmi.h:66
int(* get_grid_edge_nodes)(struct Bmi *self, int grid, int *edge_nodes)
Definition bmi.h:112
int(* get_input_item_count)(struct Bmi *self, int *count)
Definition bmi.h:64
int(* get_var_nbytes)(struct Bmi *self, const char *name, int *nbytes)
Definition bmi.h:74
int(* get_current_time)(struct Bmi *self, double *time)
Definition bmi.h:78
int(* get_value)(struct Bmi *self, const char *name, void *dest)
Definition bmi.h:85
int(* set_value)(struct Bmi *self, const char *name, void *src)
Definition bmi.h:90
int(* get_grid_shape)(struct Bmi *self, int grid, int *shape)
Definition bmi.h:99
int(* get_grid_rank)(struct Bmi *self, int grid, int *rank)
Definition bmi.h:94
int(* get_value_ptr)(struct Bmi *self, const char *name, void **dest_ptr)
Definition bmi.h:86
int(* get_var_units)(struct Bmi *self, const char *name, char *units)
Definition bmi.h:72
int(* get_output_item_count)(struct Bmi *self, int *count)
Definition bmi.h:65
int(* get_var_location)(struct Bmi *self, const char *name, char *location)
Definition bmi.h:75
int(* get_var_grid)(struct Bmi *self, const char *name, int *grid)
Definition bmi.h:70
int(* update)(struct Bmi *self)
Definition bmi.h:58
int(* get_grid_nodes_per_face)(struct Bmi *self, int grid, int *nodes_per_face)
Definition bmi.h:115
int(* get_grid_spacing)(struct Bmi *self, int grid, double *spacing)
Definition bmi.h:100
int(* get_grid_size)(struct Bmi *self, int grid, int *size)
Definition bmi.h:95
int(* get_grid_face_count)(struct Bmi *self, int grid, int *count)
Definition bmi.h:111
int(* get_time_units)(struct Bmi *self, char *units)
Definition bmi.h:81
int(* get_time_step)(struct Bmi *self, double *time_step)
Definition bmi.h:82
int(* get_var_itemsize)(struct Bmi *self, const char *name, int *size)
Definition bmi.h:73
int(* get_component_name)(struct Bmi *self, char *name)
Definition bmi.h:63
int(* get_grid_face_edges)(struct Bmi *self, int grid, int *face_edges)
Definition bmi.h:113
int(* initialize)(struct Bmi *self, const char *config_file)
Definition bmi.h:57
int(* get_grid_origin)(struct Bmi *self, int grid, double *origin)
Definition bmi.h:101
int(* get_grid_z)(struct Bmi *self, int grid, double *z)
Definition bmi.h:106
int(* get_grid_type)(struct Bmi *self, int grid, char *type)
Definition bmi.h:96