mirror of https://github.com/ecmwf/eccodes.git
Fix spelling errors in example code
This commit is contained in:
parent
ffaf91cd19
commit
c9004a56b6
|
@ -88,7 +88,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* relase the clone's handle */
|
||||
/* release the clone's handle */
|
||||
codes_handle_delete(clone_handle);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/*
|
||||
* C Implementation: bufr_expanded
|
||||
*
|
||||
* Description: how to read all the exapanded data values from BUFR messages.
|
||||
* Description: how to read all the expanded data values from BUFR messages.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -62,7 +62,7 @@ int main(int argc,char* argv[])
|
|||
/* allocate array for data values */
|
||||
values = (double*)malloc(values_len*sizeof(double));
|
||||
|
||||
/* get the exapanded data values*/
|
||||
/* get the expanded data values*/
|
||||
CODES_CHECK(codes_get_double_array(h, "numericValues", values, &values_len),0);
|
||||
|
||||
for(i = 0; i < values_len; i++)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_attributes
|
||||
! FORTRAN 90 Implementation: bufr_attributes
|
||||
!
|
||||
! Description: how to read attributes of keys in BUFR messages.
|
||||
!
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
!
|
||||
! FORTRAN 90 Implementation: bufr_expanded
|
||||
!
|
||||
! Description: how to read all the exapanded data values from BUFR messages.
|
||||
! Description: how to read all the expanded data values from BUFR messages.
|
||||
!
|
||||
!
|
||||
program bufr_expanded
|
||||
|
@ -31,19 +31,19 @@ real(kind=8), dimension(:), allocatable :: values
|
|||
call codes_bufr_new_from_file(ifile,ibufr,iret)
|
||||
|
||||
do while (iret/=CODES_END_OF_FILE)
|
||||
|
||||
|
||||
! get and print some keys form the BUFR header
|
||||
write(*,*) 'message: ',count
|
||||
|
||||
! we need to instruct ecCodes to expand all the descriptors
|
||||
! i.e. unpack the data values
|
||||
call codes_set(ibufr,"unpack",1);
|
||||
|
||||
! get the exapanded data values
|
||||
|
||||
! get the expanded data values
|
||||
call codes_get(ibufr,'numericValues',values)
|
||||
|
||||
numberOfValues=size(values)
|
||||
|
||||
|
||||
do i=1,numberOfValues
|
||||
write(*,*) ' ',i,values(i)
|
||||
enddo
|
||||
|
@ -53,16 +53,16 @@ real(kind=8), dimension(:), allocatable :: values
|
|||
|
||||
! load the next bufr message
|
||||
call codes_bufr_new_from_file(ifile,ibufr,iret)
|
||||
|
||||
! free array
|
||||
deallocate(values)
|
||||
|
||||
count=count+1
|
||||
|
||||
end do
|
||||
|
||||
! close file
|
||||
! free array
|
||||
deallocate(values)
|
||||
|
||||
count=count+1
|
||||
|
||||
end do
|
||||
|
||||
! close file
|
||||
call codes_close_file(ifile)
|
||||
|
||||
|
||||
|
||||
end program bufr_expanded
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_get_keys
|
||||
! FORTRAN 90 Implementation: bufr_get_keys
|
||||
!
|
||||
! Description: how to read values of different type of keys from BUFR messages.
|
||||
!
|
||||
|
@ -33,7 +33,7 @@ character(len=9) :: typicalDate
|
|||
call codes_bufr_new_from_file(ifile,ibufr,iret)
|
||||
|
||||
do while (iret/=CODES_END_OF_FILE)
|
||||
|
||||
|
||||
! For debugging
|
||||
call codes_dump(ibufr)
|
||||
|
||||
|
@ -43,46 +43,46 @@ character(len=9) :: typicalDate
|
|||
! we need to instruct ecCodes to expand all the descriptors
|
||||
! i.e. unpack the data values
|
||||
call codes_set(ibufr,"unpack",1);
|
||||
|
||||
|
||||
! get as character
|
||||
call codes_get(ibufr,'typicalDate',typicalDate)
|
||||
write(*,*) ' typicalDate:',typicalDate
|
||||
|
||||
|
||||
! get as integer
|
||||
call codes_get(ibufr,'blockNumber',blockNumber);
|
||||
write(*,*) ' blockNumber:',blockNumber
|
||||
|
||||
|
||||
! get as integer
|
||||
call codes_get(ibufr,'stationNumber',stationNumber);
|
||||
write(*,*) ' stationNumber:',stationNumber
|
||||
|
||||
|
||||
! get as real
|
||||
call codes_get(ibufr,'airTemperatureAt2M',t2m);
|
||||
write(*,*) ' airTemperatureAt2M:',t2m
|
||||
|
||||
|
||||
! ---- array of integer ----------------
|
||||
|
||||
! get the exapanded descriptors
|
||||
|
||||
! get the expanded descriptors
|
||||
call codes_get(ibufr,'bufrdcExpandedDescriptors',descriptors)
|
||||
|
||||
|
||||
do i=1,size(descriptors)
|
||||
write(*,*) ' ',i,descriptors(i)
|
||||
enddo
|
||||
|
||||
enddo
|
||||
|
||||
! ---- array of real ----------------
|
||||
|
||||
! get the exapanded data values
|
||||
|
||||
! get the expanded data values
|
||||
call codes_get(ibufr,'numericValues',values)
|
||||
|
||||
|
||||
do i=1,size(values)
|
||||
write(*,*) ' ',i,values(i)
|
||||
enddo
|
||||
|
||||
|
||||
! get as character
|
||||
call codes_get(ibufr,'typicalDate',typicalDate)
|
||||
write(*,*) ' typicalDate:',typicalDate
|
||||
|
||||
! free arrays
|
||||
|
||||
! free arrays
|
||||
deallocate(values)
|
||||
deallocate(descriptors)
|
||||
|
||||
|
@ -91,13 +91,13 @@ character(len=9) :: typicalDate
|
|||
|
||||
! load the next bufr message
|
||||
call codes_bufr_new_from_file(ifile,ibufr,iret)
|
||||
|
||||
count=count+1
|
||||
|
||||
end do
|
||||
|
||||
! close file
|
||||
count=count+1
|
||||
|
||||
end do
|
||||
|
||||
! close file
|
||||
call codes_close_file(ifile)
|
||||
|
||||
|
||||
|
||||
end program bufr_get_keys
|
||||
|
|
|
@ -8,29 +8,28 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_get_string_array
|
||||
! FORTRAN 90 Implementation: bufr_get_string_array
|
||||
!
|
||||
! Description: how to get an array of strings from a BUFR message.
|
||||
|
||||
program bufr_get_string_array
|
||||
use eccodes
|
||||
implicit none
|
||||
integer :: ifile
|
||||
integer :: iret,i,n
|
||||
integer :: ibufr
|
||||
integer :: strsize
|
||||
integer, parameter :: max_strsize = 20
|
||||
character(len=max_strsize) , dimension(:),allocatable :: stationOrSiteName
|
||||
use eccodes
|
||||
implicit none
|
||||
integer :: ifile
|
||||
integer :: iret,i,n
|
||||
integer :: ibufr
|
||||
integer :: strsize
|
||||
integer, parameter :: max_strsize = 20
|
||||
character(len=max_strsize) , dimension(:),allocatable :: stationOrSiteName
|
||||
|
||||
call codes_open_file(ifile,'../../data/bufr/pgps_110.bufr','r')
|
||||
|
||||
call codes_bufr_new_from_file(ifile,ibufr,iret)
|
||||
|
||||
|
||||
! unpack the data values
|
||||
call codes_set(ibufr,'unpack',1)
|
||||
|
||||
! get the width of the strings which is te same for all of them
|
||||
! get the width of the strings which is the same for all of them
|
||||
call codes_get(ibufr,'stationOrSiteName->width',strsize)
|
||||
|
||||
! the width is given in bits
|
||||
|
@ -42,7 +41,7 @@ character(len=max_strsize) , dimension(:),allocatable :: stationOrSiteName
|
|||
print *,'stationOrSiteName array dimension is ',max_strsize,' and should be ',strsize
|
||||
call exit(1)
|
||||
end if
|
||||
|
||||
|
||||
! allocating the array of strings to be passed to codes_get_string_array is mandatory
|
||||
call codes_get_size(ibufr,'stationOrSiteName',n)
|
||||
allocate(stationOrSiteName(n))
|
||||
|
@ -55,14 +54,12 @@ character(len=max_strsize) , dimension(:),allocatable :: stationOrSiteName
|
|||
|
||||
!remember to deallocate
|
||||
deallocate(stationOrSiteName)
|
||||
|
||||
|
||||
! release memory associated with bufr handle
|
||||
! ibufr won't be accessible any more from codes_release on
|
||||
! ibufr won't be accessible after this
|
||||
call codes_release(ibufr)
|
||||
|
||||
! close file
|
||||
call codes_close_file(ifile)
|
||||
|
||||
|
||||
end program bufr_get_string_array
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_read_scatterometer
|
||||
! FORTRAN 90 Implementation: bufr_read_scatterometer
|
||||
!
|
||||
! Description: how to read data for a given beam from scatterometer BUFR messages.
|
||||
!
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_read_synop
|
||||
! FORTRAN 90 Implementation: bufr_read_synop
|
||||
!
|
||||
! Description: how to read SYNOP BUFR messages.
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_read_tropical_cyclone
|
||||
! FORTRAN 90 Implementation: bufr_read_tropical_cyclone
|
||||
!
|
||||
! Description: how to read data for a tropical cyclone BUFR message.
|
||||
!
|
||||
|
|
|
@ -19,13 +19,13 @@ program bufr_set_keys
|
|||
integer :: ibufr
|
||||
integer :: count=0
|
||||
integer(kind=4) :: centre, centreNew
|
||||
|
||||
! open input file
|
||||
|
||||
! open input file
|
||||
call codes_open_file(infile,'../../data/bufr/syno_multi.bufr','r')
|
||||
|
||||
|
||||
! open output file
|
||||
call codes_open_file(outfile,'bufr_set_keys_test_f.tmp.bufr','w')
|
||||
|
||||
|
||||
! the first bufr message is loaded from file
|
||||
! ibufr is the bufr id to be used in subsequent calls
|
||||
call codes_bufr_new_from_file(infile,ibufr,iret)
|
||||
|
@ -33,33 +33,33 @@ program bufr_set_keys
|
|||
do while (iret/=CODES_END_OF_FILE)
|
||||
|
||||
write(*,*) 'message: ',count
|
||||
|
||||
|
||||
! This is the place where you may wish to modify the message
|
||||
! E.g. we change the centre
|
||||
|
||||
|
||||
! set centre
|
||||
centre=222
|
||||
call codes_set(ibufr,'bufrHeaderCentre',222)
|
||||
write(*,*) ' set bufrHeaderCentre to:',centre
|
||||
|
||||
|
||||
! check centre's new value
|
||||
centreNew=0
|
||||
call codes_get(ibufr,'bufrHeaderCentre',centreNew)
|
||||
write(*,*) ' bufrHeaderCentre''s new value:',centreNew
|
||||
|
||||
|
||||
! write modified message to a file
|
||||
call codes_write(ibufr,outfile)
|
||||
|
||||
! relase the handle
|
||||
|
||||
! release the handle
|
||||
call codes_release(ibufr)
|
||||
|
||||
|
||||
! next message from source
|
||||
call codes_bufr_new_from_file(infile,ibufr,iret)
|
||||
|
||||
|
||||
count=count+1
|
||||
|
||||
|
||||
end do
|
||||
|
||||
|
||||
call codes_close_file(infile)
|
||||
call codes_close_file(outfile)
|
||||
|
||||
|
|
|
@ -8,22 +8,23 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: get_product_kind
|
||||
! FORTRAN 90 Implementation: get_product_kind
|
||||
!
|
||||
! Description: how to process a file containing a mix of messages
|
||||
! and print the kind of product (e.g. GRIB, BUFR etc)
|
||||
!
|
||||
program get_product_kind
|
||||
use eccodes
|
||||
implicit none
|
||||
integer :: ifile
|
||||
integer :: iret
|
||||
integer :: ihandle
|
||||
integer :: count=0
|
||||
character(len=32) :: product_kind
|
||||
character(len=120) :: infile_name
|
||||
use eccodes
|
||||
implicit none
|
||||
integer :: ifile
|
||||
integer :: iret
|
||||
integer :: ihandle
|
||||
integer :: count=0
|
||||
character(len=32) :: product_kind
|
||||
character(len=120) :: infile_name
|
||||
|
||||
call getarg(1, infile_name)
|
||||
write(*,*) 'infile_name|',infile_name,'|'
|
||||
call codes_open_file(ifile,infile_name,'r')
|
||||
|
||||
! the first message is loaded from file
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: grib_clone
|
||||
! FORTRAN 90 Implementation: grib_clone
|
||||
!
|
||||
! Description: how to create a new GRIB message by cloning
|
||||
! an existing message.
|
||||
|
|
|
@ -51,7 +51,7 @@ def example():
|
|||
# write the cloned message to a file
|
||||
codes_write(clone_id, fout)
|
||||
|
||||
# relase the clone's handle
|
||||
# release the clone's handle
|
||||
codes_release(clone_id)
|
||||
|
||||
# release the source's handle
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2016 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
. ./include.sh
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="bufr_dump_decode_fortran_test"
|
||||
|
||||
#Create log file
|
||||
fLog=${label}".log"
|
||||
rm -f $fLog
|
||||
|
||||
tempBufr=outfile.bufr
|
||||
tempDir=${label}.dir
|
||||
mkdir -p $tempDir
|
||||
|
||||
bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
||||
|
||||
# If FORTRAN is enabled, then the pkgconfig should be one level above the test dir
|
||||
PKGCONFIG_FILE=../eccodes_f90.pc
|
||||
CACHE_FILE=../CMakeCache.txt
|
||||
|
||||
COMPILE_AND_RUN=0
|
||||
|
||||
if command -v pkg-config >/dev/null 2>&1; then
|
||||
if [ -f "$PKGCONFIG_FILE" ]; then
|
||||
# Work out the Fortran compiler and flags from pkgconfig
|
||||
COMPILER=`pkg-config --variable=FC $PKGCONFIG_FILE`
|
||||
FLAGS_COMPILER=`pkg-config --cflags $PKGCONFIG_FILE`
|
||||
FLAGS_LINKER=`pkg-config --libs $PKGCONFIG_FILE`
|
||||
|
||||
# The pkgconfig variables refer to the install directory. Change to build dir
|
||||
BUILD_DIR=`grep -w eccodes_BINARY_DIR $CACHE_FILE | cut -d'=' -f2`
|
||||
INSTALL_DIR=`grep -w CMAKE_INSTALL_PREFIX $CACHE_FILE | cut -d'=' -f2`
|
||||
FLAGS_LINKER=`echo $FLAGS_LINKER | sed -e "s:$INSTALL_DIR:$BUILD_DIR:g"`
|
||||
FLAGS_COMPILER=`echo $FLAGS_COMPILER | sed -e "s:$INSTALL_DIR:$BUILD_DIR:g"`
|
||||
|
||||
# TODO: For now only support when shared libs enabled
|
||||
SHARED_LIBS=`grep -w BUILD_SHARED_LIBS $CACHE_FILE | cut -d'=' -f2`
|
||||
if [ "$SHARED_LIBS" = "ON" ]; then
|
||||
COMPILE_AND_RUN=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $tempDir
|
||||
|
||||
for file in ${bufr_files}
|
||||
do
|
||||
tempSrc=$label.$file.f90
|
||||
tempExe=$label.$file.exe
|
||||
filePath=${data_dir}/bufr/$file
|
||||
|
||||
# Generate F90 code from BUFR file
|
||||
${tools_dir}bufr_dump -Dfortran ${filePath} > $tempSrc
|
||||
|
||||
# Compile
|
||||
if [ $COMPILE_AND_RUN -eq 1 ]; then
|
||||
$COMPILER -ffree-line-length-0 -g -o $tempExe $tempSrc $FLAGS_COMPILER $FLAGS_LINKER
|
||||
# valgrind --error-exitcode=1 ./$tempExe
|
||||
./$tempExe $filePath
|
||||
fi
|
||||
|
||||
rm -f $tempExe $tempSrc
|
||||
done
|
Loading…
Reference in New Issue