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

Modifydiag_field_add_attribute to accept r4 and r8 #1625

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

uramirez8707
Copy link
Contributor

Description
Modifies diag_field_add_attribute to accept r4 and r8
Adds a test

Fixes #1621

How Has This Been Tested?
CI including new test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

Comment on lines 4568 to 4572
type is (real(kind=r4_kind))
call diag_field_add_attribute_scalar_r(diag_field_id, att_name, real(att_value))
type is (real(kind=r8_kind))
call diag_field_add_attribute_scalar_r(diag_field_id, att_name, real(att_value))
type is (integer(kind=i4_kind))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is enforcing the attribute value to be the same as the default precision specifiec at compile time, shouldn't it be the same as the incoming type-value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @bensonr is right here. If I build FMS as r4 then this:

    type is (real(kind=r8_kind))
      call diag_field_add_attribute_scalar_r(diag_field_id, att_name, real(att_value))

will cast the r8 real I pass down into an r4 (since that is what real means).

In my attempt at this, I essentially "doubled up" and made two diag_field_add_attribute_scalar_r4 and a diag_field_add_attribute_scalar_r8 (and similar for the r1d → r41d, r81d)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old diag manager, it ends up always writing the att_value as NF90_FLOAT.

CALL diag_field_attribute_init(diag_field_id, att_name, NF90_FLOAT, rval=att_value)

In 4829fe8, I made the changes so that the new diag manager uses the actual precision of att_value.

type is (real(kind=r4_kind))
CALL diag_field_attribute_init(diag_field_id, att_name, NF90_FLOAT, rval=real((/att_value/)))
type is (real(kind=r8_kind))
CALL diag_field_attribute_init(diag_field_id, att_name, NF90_FLOAT, rval=real((/att_value/)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a r8 value is coming in, shouldn't this be an NF90_DOUBLE in both?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both routines, not both lines, that is.

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.

Help with mixed-precision FMS (in GEOS)
3 participants