NOAA-EMC / NCEPLIBS-bufr

The NCEPLIBS-bufr library contains routines and utilites for working with the WMO BUFR format.
Other
44 stars 19 forks source link

subprogram WRDLEN() should be removed, and replace by an inc file filled in by CMake and configure time #382

Closed edwardhartnett closed 7 months ago

edwardhartnett commented 1 year ago

We have a subroutine WRDLEN(). From the documetation:

C> This subroutine figures out some important information about the
C> local machine on which the BUFRLIB software is being run, including
C> the native endianness, the number of bytes in an integer, and
C> whether the machine uses the ASCII or EBCDIC character set.

This is the kind of thing best done in CMake. CMake has all the tools to support this easily, and set up a .inc file that can be included by the Fortran code which will have all the answers.

The benefits are:

jbathegit commented 8 months ago

FWIW, we've already been using include(TestBigEndian) inside of CMake for quite some time to determine the endianness. Although I see now that that function is now apparently deprecated in favor of CMAKE_\<LANG>_BYTE_ORDER as of CMake v3.20, so it looks like we'll have to update that at some point.

We also no longer support EBCDIC as of #266, so that issue is now moot as well.

Furthermore, since we now only build the library with 4-byte integers as of v12.0.0, then I believe the still-existing wrdlen() logic to count the number of bytes in an integer can probably be retired as well.

Bottom line: we may well be able to fully remove wrdlen() sooner rather than later, but this still this may still need a bit of investigation to confirm whether everything it does can indeed be determined at compile time, and if so then the calls to it would also need to be removed from a number of other routines in the library.

edwardhartnett commented 8 months ago

I think that's great - remove what can be removed, and whatever is left we can try and figure out in CMake...