From 5d58da9af0bae69d66183cc48388279016e4d77e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 10 Nov 2015 11:21:44 +0000 Subject: [PATCH] F90 codes_dump for GRIB and BUFR (debugging aid) --- examples/F90/bufr_get_keys.f90 | 4 +++- examples/F90/grib_get_keys.f90 | 4 +++- fortran/grib_fortran.c | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/examples/F90/bufr_get_keys.f90 b/examples/F90/bufr_get_keys.f90 index 9d6f410b0..293c752d3 100644 --- a/examples/F90/bufr_get_keys.f90 +++ b/examples/F90/bufr_get_keys.f90 @@ -34,9 +34,11 @@ character(len=9) :: typicalDate do while (iret/=CODES_END_OF_FILE) + ! For debugging + call codes_dump(ibufr) + ! get and print some keys form the BUFR header write(*,*) 'message: ',count - call codes_dump(ibufr) ! we need to instruct ecCodes to expand all the descriptors ! i.e. unpack the data values diff --git a/examples/F90/grib_get_keys.f90 b/examples/F90/grib_get_keys.f90 index 023221b3b..e2e1b8fd0 100644 --- a/examples/F90/grib_get_keys.f90 +++ b/examples/F90/grib_get_keys.f90 @@ -39,7 +39,9 @@ program grib_get_keys LOOP: DO WHILE (iret /= CODES_END_OF_FILE) - call grib_dump(igrib) + ! For debugging + call grib_dump(igrib) + !check if the value of the key is MISSING is_missing=0; call codes_is_missing(igrib,'Ni',is_missing); diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index bee4b21f0..e21080184 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -1590,13 +1590,28 @@ int grib_f_release(int* hid){ } /*****************************************************************************/ +static void do_the_dump(grib_handle* h) +{ + if (h->product_kind == PRODUCT_GRIB) + { + const int dump_flags = GRIB_DUMP_FLAG_VALUES + | GRIB_DUMP_FLAG_READ_ONLY + | GRIB_DUMP_FLAG_ALIASES + | GRIB_DUMP_FLAG_TYPE; + grib_dump_content(h,stdout,"debug", dump_flags, NULL); + } + else + { + grib_dump_content(h,stdout,"wmo",0,NULL); + } +} int grib_f_dump_(int* gid){ grib_handle *h = get_handle(*gid); if(!h) return GRIB_INVALID_GRIB; else - grib_dump_content(h,stdout,"wmo",0,NULL); + do_the_dump(h); return GRIB_SUCCESS; }