mirror of https://github.com/ecmwf/eccodes.git
GRIB-292: Changes from Tomas.Wilhelmsson@ecmwf.int
Accept both KindOfInt and KindOfSize_t for nbytes argument Introduce check for size_t type Move common code to grib_f90_head.f90 Renames to get proper .f90 suffix
This commit is contained in:
parent
53184931e5
commit
c8f159c461
|
@ -34,10 +34,11 @@ CLEANFILES = libgrib_api_f77.la libgrib_api_f90.la grib_f90.f90 *.mod grib_types
|
|||
|
||||
EXTRA_DIST= grib_fortran_prototypes.h grib_api_constants.h grib_api_externals.h \
|
||||
grib_api_visibility.h grib_types.f90 create_grib_f90.sh \
|
||||
grib_f90.f90.head grib_f90.f90.tail grib_f90_int.f90 grib_f90_long_int.f90 \
|
||||
same_int_long.f90 grib_fortran_kinds.c
|
||||
grib_f90_head.f90 grib_f90_tail.f90 grib_f90_int.f90 grib_f90_long_int.f90 \
|
||||
grib_f90_int_size_t.f90 grib_f90_long_size_t.f90 \
|
||||
same_int_long.f90 same_int_size_t.f90 grib_fortran_kinds.c
|
||||
|
||||
grib_f90.f90: grib_f90.f90.head grib_f90.f90.tail same_int_long grib_kinds.h
|
||||
grib_f90.f90: grib_f90_head.f90 grib_f90_tail.f90 grib_f90_int.f90 grib_f90_long_int.f90 grib_f90_int_size_t.f90 grib_f90_long_size_t.f90 same_int_long same_int_size_t grib_kinds.h
|
||||
./create_grib_f90.sh
|
||||
|
||||
grib_f90.o : grib_kinds.h
|
||||
|
@ -51,4 +52,7 @@ grib_types: grib_types.o grib_fortran_kinds.o
|
|||
same_int_long: same_int_long.o grib_fortran_kinds.o
|
||||
$(FC) $(FCFLAGS) -o same_int_long same_int_long.o grib_fortran_kinds.o
|
||||
|
||||
same_int_size_t: same_int_size_t.o grib_fortran_kinds.o
|
||||
$(FC) $(FCFLAGS) -o same_int_size_t same_int_size_t.o grib_fortran_kinds.o
|
||||
|
||||
include extrules.am
|
||||
|
|
|
@ -11,9 +11,19 @@ same=`./same_int_long`
|
|||
|
||||
if [ $same -eq 1 ]
|
||||
then
|
||||
interface=grib_f90_int.f90
|
||||
long=grib_f90_int.f90
|
||||
else
|
||||
interface=grib_f90_long_int.f90
|
||||
long=grib_f90_long_int.f90
|
||||
fi
|
||||
cat grib_f90.f90.head $interface grib_f90.f90.tail > grib_f90.f90
|
||||
|
||||
same=`./same_int_size_t`
|
||||
|
||||
if [ $same -eq 1 ]
|
||||
then
|
||||
sizet=grib_f90_int_size_t.f90
|
||||
else
|
||||
sizet=grib_f90_long_size_t.f90
|
||||
fi
|
||||
|
||||
cat grib_f90_head.f90 $long $sizet grib_f90_tail.f90 > grib_f90.f90
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
! Copyright 2005-2013 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.
|
||||
!
|
||||
!
|
||||
!> Module grib_api
|
||||
!>
|
||||
!> The grib_api module provides the Fortran 90 interface of the GRIB API.
|
||||
module grib_api
|
||||
|
||||
implicit none
|
||||
include "grib_kinds.h"
|
||||
include "grib_api_constants.h"
|
||||
include "grib_api_externals.h"
|
||||
include "grib_api_visibility.h"
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
! Copyright 2005-2013 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.
|
||||
!
|
||||
!
|
||||
!> Module grib_api
|
||||
!>
|
||||
!> The grib_api module provides the Fortran 90 interface of the GRIB API.
|
||||
module grib_api
|
||||
|
||||
implicit none
|
||||
include "grib_kinds.h"
|
||||
include "grib_api_constants.h"
|
||||
include "grib_api_externals.h"
|
||||
include "grib_api_visibility.h"
|
||||
|
||||
!> Create a new message in memory from an integer or character array containting the coded message.
|
||||
!>
|
||||
!> The message can be accessed through its gribid and it will be available\n
|
||||
!> until @ref grib_release is called. A reference to the original coded\n
|
||||
!> message is kept in the new message structure.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> \b Examples: \ref copy_message.f90 "copy_message.f90"
|
||||
!>
|
||||
!> @param gribid id of the grib loaded in memory
|
||||
!> @param message array containing the coded message
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_new_from_message
|
||||
module procedure grib_new_from_message_int4
|
||||
module procedure grib_new_from_message_char
|
||||
end interface grib_new_from_message
|
||||
|
||||
!> Get a value of specified index from an array key.
|
||||
!>
|
||||
!> Given a gribid and key name as input a value corresponding to the given index
|
||||
!> is returned. The index is zero based i.e. the first element has
|
||||
!> zero index, the second element index one and so on.
|
||||
!> If the parameter index is an array all the values correspondig to the indexes
|
||||
!> list is returned.
|
||||
!> The gribid references to a grib message loaded in memory.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref nearest.f90 "nearest.f90"
|
||||
!>
|
||||
!> @see grib_new_from_file, grib_release, grib_get
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[in] key key name
|
||||
!> @param[in] index index can be a scalar or array of integer(4)
|
||||
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8)
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_get_element
|
||||
module procedure grib_get_real4_element, &
|
||||
grib_get_real8_element, &
|
||||
grib_get_real4_elements, &
|
||||
grib_get_real8_elements
|
||||
end interface grib_get_element
|
||||
|
||||
!> Find the nearest point/points of a given latitude/longitude point.
|
||||
!>
|
||||
!> The value in the nearest point (or the four nearest points) is returned as well as the
|
||||
!> zero based index (which can be used in @ref grib_get_element)
|
||||
!> and its distance from the given point using the following
|
||||
!> formula (acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))).
|
||||
!>
|
||||
!> If the is_lsm flag is .true. the input field gribid is considered as
|
||||
!> a land sea mask and the nearest land point is returned.\n
|
||||
!> The nearest land point among the four neighbours is:
|
||||
!> - the nearest point with land sea mask value >= 0.5
|
||||
!> - the nearest without any other condition if all the four have land sea mask value <0.5.
|
||||
!>
|
||||
!> Arrays (real(8)) of latitude/longitude can be provided to find with one call
|
||||
!> the values,indexes and distances for all the lat/lon points listed in the arrays.
|
||||
!>
|
||||
!> If a single latitude/longitude point is provided and outlat,outlon,value,distance,index
|
||||
!> are defined as arrays with four elements the lat/lon coordinates and values, distances
|
||||
!> and indexes of the four nearest points are returned.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref nearest.f90 "nearest.f90"
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[in] is_lsm .true. if the nearest land point is required otherwise .false.
|
||||
!> @param[in] inlat latitude of the point in degrees
|
||||
!> @param[in] inlon longitudes of the point in degrees
|
||||
!> @param[out] outlat latitude of the nearest point in degrees
|
||||
!> @param[out] outlon longitude of the nearest point in degrees
|
||||
!> @param[out] distance distance between the given point and its nearest
|
||||
!> @param[out] index zero based index
|
||||
!> @param[out] value value of the field in the nearest point
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_find_nearest
|
||||
module procedure grib_find_nearest_single, &
|
||||
grib_find_nearest_four_single, &
|
||||
grib_find_nearest_multiple
|
||||
end interface grib_find_nearest
|
||||
|
||||
!> Get latitude/longitude and data values.
|
||||
!>
|
||||
!> Latitudes, longitudes, data values arrays are returned.
|
||||
!> They must be properly allocated by the caller and their required
|
||||
!> dimension can be obtained with \ref grib_get_size or by getting (with \ref grib_get)
|
||||
!> the value of the integer key "numberOfPoints".
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref get_data.f90 "get_data.f90"
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[out] lats latitudes array with dimension "size"
|
||||
!> @param[out] lons longitudes array with dimension "size"
|
||||
!> @param[out] values data values array with dimension "size"
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_get_data
|
||||
module procedure grib_get_data_real4, &
|
||||
grib_get_data_real8
|
||||
end interface grib_get_data
|
|
@ -118,79 +118,6 @@
|
|||
module procedure grib_get_size_int
|
||||
end interface grib_get_size
|
||||
|
||||
!> Create a new message in memory from an integer or character array containting the coded message.
|
||||
!>
|
||||
!> The message can be accessed through its gribid and it will be available\n
|
||||
!> until @ref grib_release is called. A reference to the original coded\n
|
||||
!> message is kept in the new message structure.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> \b Examples: \ref copy_message.f90 "copy_message.f90"
|
||||
!>
|
||||
!> @param gribid id of the grib loaded in memory
|
||||
!> @param message array containing the coded message
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_new_from_message
|
||||
module procedure grib_new_from_message_int4
|
||||
module procedure grib_new_from_message_char
|
||||
end interface grib_new_from_message
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_from_file
|
||||
module procedure grib_read_from_file_int4
|
||||
module procedure grib_read_from_file_char
|
||||
end interface grib_read_from_file
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_bytes
|
||||
module procedure grib_read_bytes_int4
|
||||
module procedure grib_read_bytes_char
|
||||
module procedure grib_read_bytes_real8
|
||||
module procedure grib_read_bytes_real4
|
||||
end interface grib_read_bytes
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_write_bytes
|
||||
module procedure grib_write_bytes_int4
|
||||
module procedure grib_write_bytes_char
|
||||
module procedure grib_write_bytes_real8
|
||||
module procedure grib_write_bytes_real4
|
||||
end interface grib_write_bytes
|
||||
|
||||
!> Set the value for a key in a grib message.
|
||||
!>
|
||||
!> The given \em value is set for the \em key in the \em gribid message.
|
||||
|
@ -229,98 +156,3 @@
|
|||
grib_set_force_real8_array
|
||||
end interface grib_set_force
|
||||
|
||||
!> Get a value of specified index from an array key.
|
||||
!>
|
||||
!> Given a gribid and key name as input a value corresponding to the given index
|
||||
!> is returned. The index is zero based i.e. the first element has
|
||||
!> zero index, the second element index one and so on.
|
||||
!> If the parameter index is an array all the values correspondig to the indexes
|
||||
!> list is returned.
|
||||
!> The gribid references to a grib message loaded in memory.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref nearest.f90 "nearest.f90"
|
||||
!>
|
||||
!> @see grib_new_from_file, grib_release, grib_get
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[in] key key name
|
||||
!> @param[in] index index can be a scalar or array of integer(4)
|
||||
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8)
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_get_element
|
||||
module procedure grib_get_real4_element, &
|
||||
grib_get_real8_element, &
|
||||
grib_get_real4_elements, &
|
||||
grib_get_real8_elements
|
||||
|
||||
end interface grib_get_element
|
||||
|
||||
!> Find the nearest point/points of a given latitude/longitude point.
|
||||
!>
|
||||
!> The value in the nearest point (or the four nearest points) is returned as well as the
|
||||
!> zero based index (which can be used in @ref grib_get_element)
|
||||
!> and its distance from the given point using the following
|
||||
!> formula (acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))).
|
||||
!>
|
||||
!> If the is_lsm flag is .true. the input field gribid is considered as
|
||||
!> a land sea mask and the nearest land point is returned.\n
|
||||
!> The nearest land point among the four neighbours is:
|
||||
!> - the nearest point with land sea mask value >= 0.5
|
||||
!> - the nearest without any other condition if all the four have land sea mask value <0.5.
|
||||
!>
|
||||
!> Arrays (real(8)) of latitude/longitude can be provided to find with one call
|
||||
!> the values,indexes and distances for all the lat/lon points listed in the arrays.
|
||||
!>
|
||||
!> If a single latitude/longitude point is provided and outlat,outlon,value,distance,index
|
||||
!> are defined as arrays with four elements the lat/lon coordinates and values, distances
|
||||
!> and indexes of the four nearest points are returned.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref nearest.f90 "nearest.f90"
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[in] is_lsm .true. if the nearest land point is required otherwise .false.
|
||||
!> @param[in] inlat latitude of the point in degrees
|
||||
!> @param[in] inlon longitudes of the point in degrees
|
||||
!> @param[out] outlat latitude of the nearest point in degrees
|
||||
!> @param[out] outlon longitude of the nearest point in degrees
|
||||
!> @param[out] distance distance between the given point and its nearest
|
||||
!> @param[out] index zero based index
|
||||
!> @param[out] value value of the field in the nearest point
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_find_nearest
|
||||
module procedure grib_find_nearest_single, &
|
||||
grib_find_nearest_four_single, &
|
||||
grib_find_nearest_multiple
|
||||
end interface grib_find_nearest
|
||||
|
||||
!> Get latitude/longitude and data values.
|
||||
!>
|
||||
!> Latitudes, longitudes, data values arrays are returned.
|
||||
!> They must be properly allocated by the caller and their required
|
||||
!> dimension can be obtained with \ref grib_get_size or by getting (with \ref grib_get)
|
||||
!> the value of the integer key "numberOfPoints".
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref get_data.f90 "get_data.f90"
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[out] lats latitudes array with dimension "size"
|
||||
!> @param[out] lons longitudes array with dimension "size"
|
||||
!> @param[out] values data values array with dimension "size"
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_get_data
|
||||
module procedure grib_get_data_real4, &
|
||||
grib_get_data_real8
|
||||
end interface grib_get_data
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
! Copyright 2005-2013 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.
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_from_file
|
||||
module procedure grib_read_from_file_int4
|
||||
module procedure grib_read_from_file_char
|
||||
end interface grib_read_from_file
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_bytes
|
||||
module procedure grib_read_bytes_int4
|
||||
module procedure grib_read_bytes_char
|
||||
module procedure grib_read_bytes_real8
|
||||
module procedure grib_read_bytes_real4
|
||||
end interface grib_read_bytes
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_write_bytes
|
||||
module procedure grib_write_bytes_int4
|
||||
module procedure grib_write_bytes_char
|
||||
module procedure grib_write_bytes_real8
|
||||
module procedure grib_write_bytes_real4
|
||||
end interface grib_write_bytes
|
||||
|
|
@ -65,80 +65,6 @@
|
|||
grib_index_select_real8
|
||||
end interface grib_index_select
|
||||
|
||||
!> Create a new message in memory from an integer or character array containting the coded message.
|
||||
!>
|
||||
!> The message can be accessed through its gribid and it will be available\n
|
||||
!> until @ref grib_release is called. A reference to the original coded\n
|
||||
!> message is kept in the new message structure.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> \b Examples: \ref copy_message.f90 "copy_message.f90"
|
||||
!>
|
||||
!> @param gribid id of the grib loaded in memory
|
||||
!> @param message array containing the coded message
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_new_from_message
|
||||
module procedure grib_new_from_message_int4
|
||||
module procedure grib_new_from_message_char
|
||||
end interface grib_new_from_message
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_from_file
|
||||
module procedure grib_read_from_file_int4
|
||||
module procedure grib_read_from_file_char
|
||||
end interface grib_read_from_file
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_bytes
|
||||
module procedure grib_read_bytes_int4
|
||||
module procedure grib_read_bytes_char
|
||||
module procedure grib_read_bytes_real8
|
||||
module procedure grib_read_bytes_real4
|
||||
end interface grib_read_bytes
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_write_bytes
|
||||
module procedure grib_write_bytes_int4
|
||||
module procedure grib_write_bytes_char
|
||||
module procedure grib_write_bytes_real8
|
||||
module procedure grib_write_bytes_real4
|
||||
end interface grib_write_bytes
|
||||
|
||||
|
||||
!> Get the value for a key from a grib message.
|
||||
!>
|
||||
!> Given a \em gribid and \em key as input a \em value for the \em key is returned.
|
||||
|
@ -231,103 +157,9 @@
|
|||
grib_set_real4_array, &
|
||||
grib_set_real8_array
|
||||
end interface grib_set
|
||||
|
||||
interface grib_set_force
|
||||
module procedure grib_set_force_real4_array, &
|
||||
grib_set_force_real8_array
|
||||
end interface grib_set_force
|
||||
|
||||
!> Get a value of specified index from an array key.
|
||||
!>
|
||||
!> Given a gribid and key name as input a value corresponding to the given index
|
||||
!> is returned. The index is zero based i.e. the first element has
|
||||
!> zero index, the second element index one and so on.
|
||||
!> If the parameter index is an array all the values correspondig to the indexes
|
||||
!> list is returned.
|
||||
!> The gribid references to a grib message loaded in memory.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref nearest.f90 "nearest.f90"
|
||||
!>
|
||||
!> @see grib_new_from_file, grib_release, grib_get
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[in] key key name
|
||||
!> @param[in] index index can be a scalar or array of integer(4)
|
||||
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8)
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_get_element
|
||||
module procedure grib_get_real4_element, &
|
||||
grib_get_real8_element, &
|
||||
grib_get_real4_elements, &
|
||||
grib_get_real8_elements
|
||||
|
||||
end interface grib_get_element
|
||||
|
||||
!> Find the nearest point/points of a given latitude/longitude point.
|
||||
!>
|
||||
!> The value in the nearest point (or the four nearest points) is returned as well as the
|
||||
!> zero based index (which can be used in @ref grib_get_element)
|
||||
!> and its distance from the given point using the following
|
||||
!> formula (acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))).
|
||||
!>
|
||||
!> If the is_lsm flag is .true. the input field gribid is considered as
|
||||
!> a land sea mask and the nearest land point is returned.\n
|
||||
!> The nearest land point among the four neighbours is:
|
||||
!> - the nearest point with land sea mask value >= 0.5
|
||||
!> - the nearest without any other condition if all the four have land sea mask value <0.5.
|
||||
!>
|
||||
!> Arrays (real(8)) of latitude/longitude can be provided to find with one call
|
||||
!> the values,indexes and distances for all the lat/lon points listed in the arrays.
|
||||
!>
|
||||
!> If a single latitude/longitude point is provided and outlat,outlon,value,distance,index
|
||||
!> are defined as arrays with four elements the lat/lon coordinates and values, distances
|
||||
!> and indexes of the four nearest points are returned.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref nearest.f90 "nearest.f90"
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[in] is_lsm .true. if the nearest land point is required otherwise .false.
|
||||
!> @param[in] inlat latitude of the point in degrees
|
||||
!> @param[in] inlon longitudes of the point in degrees
|
||||
!> @param[out] outlat latitude of the nearest point in degrees
|
||||
!> @param[out] outlon longitude of the nearest point in degrees
|
||||
!> @param[out] distance distance between the given point and its nearest
|
||||
!> @param[out] index zero based index
|
||||
!> @param[out] value value of the field in the nearest point
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_find_nearest
|
||||
module procedure grib_find_nearest_single, &
|
||||
grib_find_nearest_four_single, &
|
||||
grib_find_nearest_multiple
|
||||
end interface grib_find_nearest
|
||||
|
||||
!> Get latitude/longitude and data values.
|
||||
!>
|
||||
!> Latitudes, longitudes, data values arrays are returned.
|
||||
!> They must be properly allocated by the caller and their required
|
||||
!> dimension can be obtained with \ref grib_get_size or by getting (with \ref grib_get)
|
||||
!> the value of the integer key "numberOfPoints".
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!> \b Examples: \ref get_data.f90 "get_data.f90"
|
||||
!>
|
||||
!> @param[in] gribid id of the grib loaded in memory
|
||||
!> @param[out] lats latitudes array with dimension "size"
|
||||
!> @param[out] lons longitudes array with dimension "size"
|
||||
!> @param[out] values data values array with dimension "size"
|
||||
!> @param[out] status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_get_data
|
||||
module procedure grib_get_data_real4, &
|
||||
grib_get_data_real8
|
||||
end interface grib_get_data
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
! Copyright 2005-2013 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.
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_from_file
|
||||
module procedure grib_read_from_file_int4
|
||||
module procedure grib_read_from_file_int4_size_t
|
||||
module procedure grib_read_from_file_char
|
||||
module procedure grib_read_from_file_char_size_t
|
||||
end interface grib_read_from_file
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_read_bytes
|
||||
module procedure grib_read_bytes_int4
|
||||
module procedure grib_read_bytes_int4_size_t
|
||||
module procedure grib_read_bytes_char
|
||||
module procedure grib_read_bytes_char_size_t
|
||||
module procedure grib_read_bytes_real8
|
||||
module procedure grib_read_bytes_real8_size_t
|
||||
module procedure grib_read_bytes_real4
|
||||
module procedure grib_read_bytes_real4_size_t
|
||||
end interface grib_read_bytes
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
interface grib_write_bytes
|
||||
module procedure grib_write_bytes_int4
|
||||
module procedure grib_write_bytes_int4_size_t
|
||||
module procedure grib_write_bytes_char
|
||||
module procedure grib_write_bytes_char_size_t
|
||||
module procedure grib_write_bytes_real8
|
||||
module procedure grib_write_bytes_real8_size_t
|
||||
module procedure grib_write_bytes_real4
|
||||
module procedure grib_write_bytes_real4_size_t
|
||||
end interface grib_write_bytes
|
||||
|
|
@ -526,11 +526,13 @@
|
|||
subroutine grib_read_bytes_char ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
character(len=1),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_read_file(ifile,buffer,nbytes)
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
|
@ -538,6 +540,33 @@
|
|||
endif
|
||||
end subroutine grib_read_bytes_char
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer binary buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_bytes_char_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
character(len=1),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_read_file(ifile,buffer,nbytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_bytes','')
|
||||
endif
|
||||
end subroutine grib_read_bytes_char_size_t
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
|
@ -553,11 +582,13 @@
|
|||
subroutine grib_read_bytes_int4 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_read_file(ifile,buffer,nbytes)
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
|
@ -577,10 +608,10 @@
|
|||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_bytes_real4 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_read_bytes_int4_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
integer(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -590,6 +621,35 @@
|
|||
else
|
||||
call grib_check(iret,'grib_read_bytes','')
|
||||
endif
|
||||
end subroutine grib_read_bytes_int4_size_t
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_bytes_real4 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_bytes','')
|
||||
endif
|
||||
end subroutine grib_read_bytes_real4
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
|
@ -604,10 +664,10 @@
|
|||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_bytes_real8 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_read_bytes_real4_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
real(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -617,8 +677,64 @@
|
|||
else
|
||||
call grib_check(iret,'grib_read_bytes','')
|
||||
endif
|
||||
end subroutine grib_read_bytes_real4_size_t
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_bytes_real8 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_bytes','')
|
||||
endif
|
||||
end subroutine grib_read_bytes_real8
|
||||
|
||||
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_bytes_real8_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_read_file(ifile,buffer,nbytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_bytes','')
|
||||
endif
|
||||
end subroutine grib_read_bytes_real8_size_t
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
|
@ -634,11 +750,13 @@
|
|||
subroutine grib_read_from_file_int4 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_read_any_from_file(ifile,buffer,nbytes)
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
|
@ -658,10 +776,10 @@
|
|||
!> @param buffer binary buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_real4 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_read_from_file_int4_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
integer(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -671,6 +789,35 @@
|
|||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_int4_size_t
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer binary buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_real4 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_real4
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
|
@ -685,10 +832,10 @@
|
|||
!> @param buffer binary buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_real8 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_read_from_file_real4_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
real(kind=4),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -698,6 +845,35 @@
|
|||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_real4_size_t
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer binary buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_real8 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_real8
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
|
@ -709,13 +885,13 @@
|
|||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param buffer binary buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_char ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_read_from_file_real8_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
character(len=1),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
real(kind=8),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -725,10 +901,64 @@
|
|||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_real8_size_t
|
||||
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_char ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
character(len=1),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_char
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!> Reads a message in the buffer array from the file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be read
|
||||
!> @param nbytes number of bytes to be read
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_read_from_file_char_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
character(len=1),dimension(:), intent(out) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_read_any_from_file(ifile,buffer,nbytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_read_from_file','')
|
||||
endif
|
||||
end subroutine grib_read_from_file_char_size_t
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
|
@ -744,11 +974,13 @@
|
|||
subroutine grib_write_bytes_char ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
character(len=1), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_write_file(ifile,buffer,nbytes)
|
||||
ibytes=nbytes
|
||||
iret=grib_f_write_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
|
@ -768,10 +1000,10 @@
|
|||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_int4 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_write_bytes_char_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=4), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
character(len=1), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -781,6 +1013,35 @@
|
|||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_char_size_t
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_int4 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=4), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_write_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_int4
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
|
@ -795,10 +1056,10 @@
|
|||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_real4 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_write_bytes_int4_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=4), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
integer(kind=4), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -808,6 +1069,35 @@
|
|||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_int4_size_t
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_real4 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=4), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_write_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_real4
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
|
@ -822,10 +1112,10 @@
|
|||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_real8 ( ifile, buffer, nbytes, status )
|
||||
subroutine grib_write_bytes_real4_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(inout) :: nbytes
|
||||
real(kind=4), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
|
@ -835,8 +1125,64 @@
|
|||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_real4_size_t
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_real8 ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfInt), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfSize_t) :: ibytes
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
ibytes=nbytes
|
||||
iret=grib_f_write_file(ifile,buffer,ibytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_real8
|
||||
|
||||
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
|
||||
!>
|
||||
!>
|
||||
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||
!> exit with an error message.\n Otherwise the error message can be
|
||||
!> gathered with @ref grib_get_error_string.
|
||||
!>
|
||||
!>
|
||||
!> @param ifile id of the opened file to be used in all the file functions.
|
||||
!> @param buffer buffer to be written
|
||||
!> @param nbytes number of bytes to be written
|
||||
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||
subroutine grib_write_bytes_real8_size_t ( ifile, buffer, nbytes, status )
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
real(kind=8), dimension(:),intent(in) :: buffer
|
||||
integer(kind=kindOfSize_t), intent(in) :: nbytes
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
iret=grib_f_write_file(ifile,buffer,nbytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret,'grib_write_bytes','')
|
||||
endif
|
||||
end subroutine grib_write_bytes_real8_size_t
|
||||
|
||||
!> Close a file.
|
||||
!>
|
||||
!> If the \em fileid does not refer to an opened file an error code
|
|
@ -6,34 +6,6 @@
|
|||
! 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.
|
||||
|
||||
integer function kind_of_size_t()
|
||||
integer(2), dimension(2) :: x2 = (/1, 2/)
|
||||
integer(4), dimension(2) :: x4 = (/1, 2/)
|
||||
integer(8), dimension(2) :: x8 = (/1, 2/)
|
||||
character(len=1) :: ret
|
||||
|
||||
kind_of_size_t=-1
|
||||
|
||||
call check_size_t(x2(1),x2(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_size_t=2
|
||||
return
|
||||
endif
|
||||
|
||||
call check_size_t(x4(1),x4(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_size_t=4
|
||||
return
|
||||
endif
|
||||
|
||||
call check_size_t(x8(1),x8(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_size_t=8
|
||||
return
|
||||
endif
|
||||
|
||||
end function kind_of_size_t
|
||||
|
||||
integer function kind_of_long()
|
||||
integer(2), dimension(2) :: x2 = (/1, 2/)
|
||||
integer(4), dimension(2) :: x4 = (/1, 2/)
|
||||
|
@ -90,48 +62,6 @@ integer function kind_of_int()
|
|||
|
||||
end function kind_of_int
|
||||
|
||||
integer function kind_of_float()
|
||||
real(4), dimension(2) :: x4 = (/1., 2./)
|
||||
real(8), dimension(2) :: x8 = (/1., 2./)
|
||||
character(len=1) :: ret
|
||||
|
||||
kind_of_float=-1
|
||||
|
||||
call check_float(x4(1),x4(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_float=4
|
||||
return
|
||||
endif
|
||||
|
||||
call check_float(x8(1),x8(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_float=8
|
||||
return
|
||||
endif
|
||||
|
||||
end function kind_of_float
|
||||
|
||||
integer function kind_of_double()
|
||||
real(4), dimension(2) :: real4 = (/1., 2./)
|
||||
real(8), dimension(2) :: real8 = (/1., 2./)
|
||||
character(len=1) :: ret
|
||||
|
||||
kind_of_double=-1
|
||||
|
||||
call check_double(real4(1),real4(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_double=4
|
||||
return
|
||||
endif
|
||||
|
||||
call check_double(real8(1),real8(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_double=8
|
||||
return
|
||||
endif
|
||||
|
||||
end function kind_of_double
|
||||
|
||||
program same_int_long
|
||||
integer ki,kl
|
||||
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
! Copyright 2005-2013 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.
|
||||
|
||||
integer function kind_of_size_t()
|
||||
integer(2), dimension(2) :: x2 = (/1, 2/)
|
||||
integer(4), dimension(2) :: x4 = (/1, 2/)
|
||||
integer(8), dimension(2) :: x8 = (/1, 2/)
|
||||
character(len=1) :: ret
|
||||
|
||||
kind_of_size_t=-1
|
||||
|
||||
call check_size_t(x2(1),x2(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_size_t=2
|
||||
return
|
||||
endif
|
||||
|
||||
call check_size_t(x4(1),x4(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_size_t=4
|
||||
return
|
||||
endif
|
||||
|
||||
call check_size_t(x8(1),x8(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_size_t=8
|
||||
return
|
||||
endif
|
||||
|
||||
end function kind_of_size_t
|
||||
|
||||
integer function kind_of_int()
|
||||
integer(2), dimension(2) :: x2 = (/1, 2/)
|
||||
integer(4), dimension(2) :: x4 = (/1, 2/)
|
||||
integer(8), dimension(2) :: x8 = (/1, 2/)
|
||||
character(len=1) :: ret
|
||||
|
||||
kind_of_int=-1
|
||||
|
||||
call check_int(x2(1),x2(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_int=2
|
||||
return
|
||||
endif
|
||||
|
||||
call check_int(x4(1),x4(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_int=4
|
||||
return
|
||||
endif
|
||||
|
||||
call check_int(x8(1),x8(2),ret)
|
||||
if (ret == 't') then
|
||||
kind_of_int=8
|
||||
return
|
||||
endif
|
||||
|
||||
end function kind_of_int
|
||||
|
||||
program same_int_size_t
|
||||
integer ki,kl
|
||||
|
||||
ki=kind_of_int()
|
||||
kl=kind_of_size_t()
|
||||
if (ki /= kl) then
|
||||
write (*,'(i1)') 0
|
||||
else
|
||||
write (*,'(i1)') 1
|
||||
endif
|
||||
end program same_int_size_t
|
||||
|
Loading…
Reference in New Issue