csdms / bmi-fortran

Basic Model Interface for Fortran

Home Page:https://bmi.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is the correct intent used in BMI functions?

mdpiper opened this issue · comments

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).