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

IO: get_field_nc values to intent(inout) #9

Conversation

marshallward
Copy link

This patch changes the intent of values in get_field_nc from intent(out) to intent(inout).

Because only the compute domain of values is filled by get_field_nc, it may contain residual values in its halos. Previous use of intent(out) would not necessarily preserve these values. This change explicitly directs the compiler to preserve them.

This patch addresses some of the proposed changes to `get_field_nc`.

* `WARNING` is removed from `use MOM_error_handler` since it is unused.

* Zero initialization of `values` has been removed

  I find no evidence that `MOM_read_data` or its principal function
  call, `mpp_read`, apply any initialization to the halo data.  Also,
  there is no reason why the user should expect a `read()`-like function
  to populate these fields, so this has been removed.

  If a field needs these initialized, then it should be done outside of
  the `read()` call.

* Zero initialization of `values_c` by `source=` has been removed.

  This initialization serves no purpose, since every value will be
  filled by the netCDF read statement.

* `values_c` indexing is now 1-based

  `values` has ambiguous shape, so it can follow no natural indexing.
  Although `values_c` always resides on the compute domain, the transfer
  to `values` may feel unintuitive.  Allocating from the 1 index
  identifies this as an explicit transfer of 1-based indices.

* Computation of the data domain indices were moved to the actual
  transfer of `values_c` to `values`.

* A comment was added to explain the initial "magic value" of
  `unlim_index`.

Stylistic changes consistent with the existing file have also been
imposed:

* `values_nc` renamed to `values_c`

  Previous suffix indicated some special netCDF property of this field,
  when it's just the compute subdomain of the field's values.

* Comments have been truncated for readability

* Column width is restricted to 80

* Composite statements (semicolons) have been removed
@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2023

Codecov Report

❗ No coverage uploaded for pull request base (get_field_nc_indexing_bugfix@7f9b66e). Click here to learn what that means.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@                       Coverage Diff                       @@
##             get_field_nc_indexing_bugfix       #9   +/-   ##
===============================================================
  Coverage                                ?   37.15%           
===============================================================
  Files                                   ?      265           
  Lines                                   ?    74516           
  Branches                                ?    13839           
===============================================================
  Hits                                    ?    27690           
  Misses                                  ?    41731           
  Partials                                ?     5095           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

This patch changes the intent of `values` from `intent(out)` to
`intent(inout)` in `get_field_nc` and `netCDF_read_data_2d`.
`read_netcdf_field` is left as `intent(out)`.

This is due to the ambiguous shape of `values` in these two functions,
which may represent either the compute or data domain.

Because only the compute domain of `values` is filled by `get_field_nc`,
it may contain residual values in its halos.  Previous use of
`intent(out)` would not necessarily preserve these values.  This change
explicitly directs the compiler to preserve them.
@marshallward marshallward deleted the get_field_nc_indexing_bugfix branch May 11, 2023 15:08
Hallberg-NOAA pushed a commit that referenced this pull request Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants