Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the correct intent used in BMI functions? #41

Open
mdpiper opened this issue Jan 31, 2020 · 0 comments
Open

Is the correct intent used in BMI functions? #41

mdpiper opened this issue Jan 31, 2020 · 0 comments
Labels

Comments

@mdpiper
Copy link
Member

mdpiper commented Jan 31, 2020

The BMI functions

  • get_grid_shape
  • get_grid_spacing
  • get_grid_origin
  • get_grid_x
  • get_grid_y
  • get_grid_z
  • get_grid_edge_nodes
  • get_grid_face_edges
  • get_grid_face_nodes
  • get_grid_nodes_per_face

are declared with a 1d array parameter of intent in in the SIDL file. This is done so that in a language like C, a pointer can be passed that will hold the shape, spacing, etc. output.

In Fortran, intent in is interpreted differently, in that declaring intent(in) on a parameter means the values of the parameter can't be changed in the subprogram. Setting intent(in) in the Fortran BMI wouldn't work. I've set the array parameter for these functions as intent(out), which means that they can only output information; information can't be communicated into the subprogram. For example, I can't change anything about the grid, I can only get back information (shape, spacing, etc.) about the grid from these functions.

I think this is the correct interpretation of the BMI, although I could also make a case for intent(inout).

mdpiper added a commit to csdms/bmi-example-fortran that referenced this issue Feb 5, 2020
Use array subscripts on output variables so that it's obvious that
an existing array is being used, not a new array. E.g.,

    shape(:) = [this%model%n_y, this%model%n_x]

instead of

    shape = [this%model%n_y, this%model%n_x]

This is related to csdms/bmi-fortran#41.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant