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

adding test for 4.9 #125

Merged
merged 4 commits into from
Apr 17, 2024
Merged

adding test for 4.9 #125

merged 4 commits into from
Apr 17, 2024

Conversation

edwardhartnett
Copy link
Contributor

Part of #113

lvl_type1 = 'xxx'
scale_fac1 = 0
scaled_val1 = 0
lvl_type2 = 'xxx'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EricJames-NOAA as with 4.46, this is letting me use 'xxx' as a lvl_type. Is that expected?

Copy link
Contributor

Choose a reason for hiding this comment

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

@edwardhartnett lvl_type is a character type variable...that should be fine for a test. In real application, it will be text indicating one of these options:

https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The table you indicate has integer codes. Why are these types char array?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the subroutine call get_g2_fixedsurfacetypes matches the text string with the integer value using the table4_5. You can see the lvl_type is type char array for other templates too (for example g2sec4_temp0).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, here's the code:

!> This subroutine returns the corresponding GRIB2 - Fixed Surface Types and Units
 !>   value for a given short key name based on Table 4.5 of Section 4, Octets 23 and 29
 !>
 !> @param[in] key - GRIB2 character short key for fixed surface types from Table 4.5
 !> @param[out] value - corresponding GRIB2 value from Table 4.5
 !> @param[out] ierr - 0 for success, 9 if key not found
 !>
 !> @author V. Krishna Kumar         ORG: W/NP12    @date 2009-12-10
 subroutine get_g2_fixedsurfacetypes(key, value, ierr)
   character(len=*) :: key
   integer :: value, n, ierr
   !
   ierr = 0
   do n=1, MAXFIXEDSURFACETYPES
      if (trim(table4_5(n)%fixedsurfacetypeskey).eq.trim(key)) then
         value=table4_5(n)%fixedsurfacetypesval
         return
      endif
   enddo

   value=table4_5(66)%fixedsurfacetypesval
   !           print *, 'get_g2_fixedsurfacetypes key: ', trim(key), value,  &
   !                   ' not found in table 4.5'
   ierr=9
   return
 end subroutine get_g2_fixedsurfacetypes

Note that the print statement is commented out. Is that intentional? All the other lookup functions print an error message when a text string is not found.

Also, when this code is called, the return code is never checked:

    call get_g2_fixedsurfacetypes(lvl_type1, value, ierr)
    ipdstmpl0(10) = value
    ipdstmpl0(11) = scale_fac1
    ipdstmpl0(12) = scaled_val1
    !
    call get_g2_fixedsurfacetypes(lvl_type2, value, ierr)
    ipdstmpl0(13) = value
    !
    ipdstmpl0(14) = scale_fac2
    ipdstmpl0(15) = scaled_val2
    !

So what's happening is that 'xxx' is used, it is not found in the table, but no error message is printed. It returns an error code, but that code is never checked.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why that print statement is commented out. I did not modify this section of code. I'm fine with uncommenting that print statement.

@Hang-Lei-NOAA Hang-Lei-NOAA merged commit 5e69c26 into develop Apr 17, 2024
8 checks passed
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