From c87a7496d6e164cf3c339241756571bb3435cfaa Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 25 Aug 2023 18:44:07 +0100 Subject: [PATCH] Examples: cleanup --- examples/F90/grib_multi.f90 | 12 +++++++----- examples/F90/grib_multi.sh | 8 +++++--- examples/F90/grib_precision.f90 | 2 +- examples/F90/grib_set_keys.f90 | 2 +- examples/F90/multi_fortran.f90 | 16 ++++++++++------ examples/F90/precision_fortran.f90 | 2 +- examples/F90/set_fortran.f90 | 2 +- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/examples/F90/grib_multi.f90 b/examples/F90/grib_multi.f90 index 96b168391..c18b005fe 100644 --- a/examples/F90/grib_multi.f90 +++ b/examples/F90/grib_multi.f90 @@ -16,27 +16,29 @@ program multi use eccodes implicit none - integer :: iret + integer :: iret, counter integer(kind=4) :: step integer :: ifile, igrib call codes_open_file(ifile, '../../data/multi_created.grib2', 'r') - ! turn on support for multi-field messages */ - call codes_grib_multi_support_on() + ! Turn off support for multi-field messages + call codes_grib_multi_support_off() - ! turn off support for multi-field messages */ - !call codes_grib_multi_support_off() + ! Turn on support for multi-field messages + call codes_grib_multi_support_on() ! Loop on all the messages in a file write (*, *) 'step' do while (.true.) call codes_grib_new_from_file(ifile, igrib, iret) if (iret == CODES_END_OF_FILE) exit + counter = counter + 1 call codes_get(igrib, 'step', step) write (*, '(i3)') step end do call codes_close_file(ifile) + !write(*,*) 'Message count =', counter end program multi diff --git a/examples/F90/grib_multi.sh b/examples/F90/grib_multi.sh index b90c94b5a..0ba6ed54b 100755 --- a/examples/F90/grib_multi.sh +++ b/examples/F90/grib_multi.sh @@ -9,6 +9,8 @@ . ./include.ctest.sh -${examples_dir}/eccodes_f_grib_multi > multi.out -diff multi.out ${data_dir}/multi.ok -rm -f multi.out +temp='temp.eccodes_f_grib_multi.txt' + +${examples_dir}/eccodes_f_grib_multi > $temp +diff $temp ${data_dir}/multi.ok +rm -f $temp diff --git a/examples/F90/grib_precision.f90 b/examples/F90/grib_precision.f90 index 93ee42519..165b805fd 100644 --- a/examples/F90/grib_precision.f90 +++ b/examples/F90/grib_precision.f90 @@ -41,7 +41,7 @@ program precision allocate (values1(size1), stat=iret) allocate (values2(size1), stat=iret) - ! get data values before changing the packing parameters*/ + ! get data values before changing the packing parameters call codes_get(igrib, "values", values1) ! setting decimal precision=2 means that 2 decimal digits diff --git a/examples/F90/grib_set_keys.f90 b/examples/F90/grib_set_keys.f90 index bbcd5eabe..dcc4aceee 100644 --- a/examples/F90/grib_set_keys.f90 +++ b/examples/F90/grib_set_keys.f90 @@ -30,7 +30,7 @@ program set call codes_set(igrib, 'dataDate', date1) call codes_set(igrib, 'type', marsType) - ! set centre as a integer */ + ! set centre as a integer call codes_set(igrib, 'centre', centre) ! check if it is correct in the actual GRIB message diff --git a/examples/F90/multi_fortran.f90 b/examples/F90/multi_fortran.f90 index 41515fec9..423fb1fb1 100644 --- a/examples/F90/multi_fortran.f90 +++ b/examples/F90/multi_fortran.f90 @@ -17,23 +17,25 @@ program multi use eccodes implicit none - integer :: iret + integer :: iret integer(kind=4) :: parameterCategory, parameterNumber, discipline - integer :: ifile, igrib + integer :: ifile, igrib, counter call codes_open_file(ifile, '../../data/multi.grib2', 'r') - ! Turn on support for multi-field messages */ - call codes_grib_multi_support_on() + ! Turn off support for multi-field messages + call codes_grib_multi_support_off() - ! Turn off support for multi-field messages */ - !call codes_grib_multi_support_off() + ! Turn on support for multi-field messages + call codes_grib_multi_support_on() call codes_grib_new_from_file(ifile, igrib) ! Loop on all the messages in a file. do while (igrib .ne. -1) + counter = counter + 1 + ! get as a integer*4 call codes_get(igrib, 'discipline', discipline) write (*, *) 'discipline=', discipline @@ -63,4 +65,6 @@ program multi end do call codes_close_file(ifile) + write(*,*) 'Message count =',counter + end program multi diff --git a/examples/F90/precision_fortran.f90 b/examples/F90/precision_fortran.f90 index 1a66f7cd8..33429c481 100644 --- a/examples/F90/precision_fortran.f90 +++ b/examples/F90/precision_fortran.f90 @@ -40,7 +40,7 @@ program precision allocate (values1(size), stat=iret) allocate (values2(size), stat=iret) - ! get data values before changing the packing parameters*/ + ! get data values before changing the packing parameters call codes_get(igrib, "values", values1) ! setting decimal precision=2 means that 2 decimal digits diff --git a/examples/F90/set_fortran.f90 b/examples/F90/set_fortran.f90 index 7e3f4ad2f..582677b5b 100644 --- a/examples/F90/set_fortran.f90 +++ b/examples/F90/set_fortran.f90 @@ -33,7 +33,7 @@ program set ! igrib is the grib id to be used in subsequent calls call codes_grib_new_from_file(infile, igrib) - ! set centre as a long */ + ! set centre as a long centre = 80 call codes_set(igrib, 'centre', centre)