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

enhancement/bugfix: use NetCDF missing values instead of -9999 #570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

scrasmussen
Copy link
Member

DESCRIPTION OF CHANGES:

  • Using NetCDF variables for missing_values instead of -9999.0 and -9999
  • Fixing/adding generic interfaces for single and double precision. Because the generic interface allow a single subroutine name to be used to call using variables of single or double precision, missing_value_sp and missing_value_dp variables need to be used in the subroutine definitions.
  • Added generic interface definitions for NetCDF_read_att_dp, NetCDF_put_var_1d_sp, NetCDF_put_var_2d_sp, NetCDF_put_var_1d_dp, NetCDF_put_var_2d_dp, check_missing_real_sp_0d, check_missing_real_sp_1d, conditionally_set_real_sp_var_0d, conditionally_set_real_sp_var_1d

ISSUES: Related to issues brought up in Issue #519

TESTS: compiles both single and double precision build setup

@scrasmussen scrasmussen force-pushed the enhancement/netcdf_missing_value_precisions branch from 12363db to 63e7653 Compare March 20, 2025 22:15
Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

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

Looks good to me.
The precision police abide :)

@hertneky
Copy link
Collaborator

@scrasmussen @grantfirl I ran tests using some of Wayne's files. His files set a fill value that's quite large for the surface forcing variables e.g.:

        float hfss(time) ;
                hfss:_FillValue = 9.96921e+36f ;

With this PR, that of course causes the missing_value/missing_value_eps to be large and therefore causes this error to trigger, even when there are realistic flux values.

    if (maxval(input_force_sfc_sens_flx(:)) < missing_value_eps) then
      write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_sens_flx should be present, but it is missing. Stopping ...'
      error stop "The global attribute surfaceForcing in indicates that the variable sfc_sens_flx should be present, but it is missing."

This is just one example in the code of many where these types of checks are done. Is there another way to check if the value is missing. Is there issue with checking if var == missing_value, as I see in other places in the code? I understand that this method may not be reliable due to precision errors of floating point numbers, so probably not!

I will note that the noflux case did run through to completion and produced output, since it did not get caught up in any of these missing_value comparisons.

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.

3 participants