ECC-13: Fortran interface and module

This commit is contained in:
Shahram Najm 2015-01-28 22:54:42 +00:00
parent 2a5717e1b1
commit da719dfd93
48 changed files with 690 additions and 216 deletions

View File

@ -14,7 +14,7 @@
!
!
program clone
use grib_api
use eccodes
implicit none
integer :: err,i,iret
integer :: nx, ny

View File

@ -13,7 +13,7 @@
!
!
program copy
use grib_api
use eccodes
implicit none
integer :: err, centre
integer(kind=kindOfSize) :: byte_size

View File

@ -12,7 +12,7 @@
!
!
program copy_namespace
use grib_api
use eccodes
implicit none
integer :: file1, file2, file3
integer :: igrib1,igrib2,igrib3

View File

@ -10,7 +10,7 @@
!
!
program get
use grib_api
use eccodes
implicit none
integer :: ifile

View File

@ -11,7 +11,7 @@
!
!
program get
use grib_api
use eccodes
implicit none
integer :: ifile

View File

@ -12,7 +12,7 @@
!
!
program get_data
use grib_api
use eccodes
implicit none
integer :: ifile
integer :: iret,i

View File

@ -6,7 +6,7 @@
!
!
program get
use grib_api
use eccodes
implicit none
integer :: ifile

View File

@ -12,7 +12,7 @@
!
!
program get_pl
use grib_api
use eccodes
implicit none
integer :: infile
integer :: igrib

View File

@ -13,7 +13,7 @@
!
!
program get_pv
use grib_api
use eccodes
implicit none
integer :: infile
integer :: igrib

View File

@ -12,7 +12,7 @@
! Original authors: Harald Anlauf, Doerte Liermann (DWD), Luis Kornblueh (MPIfM).
!
program get_set_uuid
use grib_api
use eccodes
implicit none
integer :: infile, outfile
integer :: igrib, ogrib

View File

@ -13,7 +13,7 @@
!
!
program index
use grib_api
use eccodes
implicit none
integer :: iret

View File

@ -8,7 +8,7 @@
!
!
program iterator
use grib_api
use eccodes
implicit none
integer :: ifile
integer :: iret,iter

View File

@ -14,7 +14,7 @@
!
!
program keys_iterator
use grib_api
use eccodes
implicit none
character(len=20) :: name_space
integer :: kiter,ifile,igrib,iret

View File

@ -14,7 +14,7 @@
!
!
program keys_iterator
use grib_api
use eccodes
implicit none
integer :: kiter,ifile,igrib,iret
character(len=256) :: key

View File

@ -16,7 +16,7 @@
!
!
program multi
use grib_api
use eccodes
implicit none
integer :: iret

View File

@ -14,7 +14,7 @@
!
!
program multi
use grib_api
use eccodes
implicit none
integer :: iret

View File

@ -15,7 +15,7 @@
!
!
program multi_write
use grib_api
use eccodes
implicit none
integer :: infile,outfile
integer :: in_gribid,iret

View File

@ -13,7 +13,7 @@
!
!
program find
use grib_api
use eccodes
implicit none
integer :: npoints
integer :: infile

View File

@ -11,7 +11,7 @@
!
!
program new_from_file
use grib_api
use eccodes
implicit none
integer :: ifile
integer :: iret

View File

@ -13,7 +13,7 @@
!
!
program precision
use grib_api
use eccodes
implicit none
integer(kind = 4) :: size1
integer :: infile,outfile

View File

@ -11,7 +11,7 @@
!
!
program precision
use grib_api
use eccodes
implicit none
integer(kind = 4) :: size
integer :: infile,outfile

View File

@ -12,7 +12,7 @@
!
!
program print_data
use grib_api
use eccodes
implicit none
integer :: ifile
integer :: iret

View File

@ -13,7 +13,7 @@
!
!
program print_data_fortran
use grib_api
use eccodes
implicit none
integer :: ifile
integer :: iret

View File

@ -10,7 +10,7 @@
! See GRIB-292
!
program read_from_file
use grib_api
use eccodes
implicit none
character(len=32) :: input_grib_file
integer,dimension(26) :: message_lengths ! expected message lengths

View File

@ -10,7 +10,7 @@
! Description: how to get values using keys.
!
program read_message
use grib_api
use eccodes
implicit none
integer :: ifile,ofile
integer :: iret,igrib

View File

@ -11,7 +11,7 @@
!
!
program sample
use grib_api
use eccodes
implicit none
integer :: err
integer :: outfile, infile, datafile

View File

@ -13,7 +13,7 @@
!
!
program set
use grib_api
use eccodes
implicit none
integer(kind = 4) :: centre, date1
integer :: infile,outfile

View File

@ -13,7 +13,7 @@
!
!
program set_bitmap
use grib_api
use eccodes
implicit none
integer :: infile,outfile
integer :: igrib, iret

View File

@ -10,7 +10,7 @@
!
!
program set
use grib_api
use eccodes
implicit none
integer :: err
integer(kind = 4) :: centre

View File

@ -13,7 +13,7 @@
!
!
program set
use grib_api
use eccodes
implicit none
integer(kind = 4) :: NV
integer :: infile,outfile

View File

@ -13,7 +13,7 @@
!
!
program set
use grib_api
use eccodes
implicit none
integer :: infile,outfile
integer :: igrib, Ni, is_missing

View File

@ -10,7 +10,7 @@
!
!
program set
use grib_api
use eccodes
implicit none
integer :: err
integer :: len

View File

@ -13,7 +13,7 @@
!
!
program set_pv
use grib_api
use eccodes
implicit none
integer :: numberOfLevels
integer :: numberOfCoefficients

View File

@ -14,28 +14,35 @@ if( EC_HAVE_FORTRAN )
DEPENDS grib_types )
if( ${EC_SIZEOF_INT} EQUAL ${EC_SIZEOF_LONG} )
set( _long_int_interface grib_f90_int.f90 )
set( _long_int_interface grib_f90_int.f90 )
set( _long_int_interface_ec eccodes_f90_int.f90 )
else()
set( _long_int_interface grib_f90_long_int.f90 )
set( _long_int_interface grib_f90_long_int.f90 )
set( _long_int_interface_ec eccodes_f90_long_int.f90 )
endif()
if( ${EC_SIZEOF_INT} EQUAL ${EC_SIZEOF_SIZE_T} )
set( _sizet_int_interface grib_f90_int_size_t.f90 )
set( _sizet_int_interface grib_f90_int_size_t.f90 )
set( _sizet_int_interface_ec eccodes_f90_int_size_t.f90 )
else()
set( _sizet_int_interface grib_f90_long_size_t.f90 )
set( _sizet_int_interface grib_f90_long_size_t.f90 )
set( _sizet_int_interface_ec eccodes_f90_long_size_t.f90 )
endif()
add_custom_command( OUTPUT grib_f90.f90
COMMAND cat ${srcdir}/grib_f90_head.f90 ${srcdir}/${_long_int_interface} ${srcdir}/${_sizet_int_interface} ${srcdir}/grib_f90_tail.f90 > grib_f90.f90
DEPENDS grib_f90_head.f90 grib_f90_tail.f90 grib_kinds.h ${_long_int_interface} ${_sizet_int_interface} )
add_custom_command( OUTPUT eccodes_f90.f90
COMMAND cat ${srcdir}/eccodes_f90_head.f90 ${srcdir}/${_long_int_interface_ec} ${srcdir}/${_sizet_int_interface_ec} ${srcdir}/eccodes_f90_tail.f90 > eccodes_f90.f90
DEPENDS eccodes_f90_head.f90 eccodes_f90_tail.f90 grib_kinds.h ${_long_int_interface_ec} ${_sizet_int_interface_ec} )
ecbuild_add_library( TARGET grib_api_f77
SOURCES grib_fortran.c grib_f77.c
LIBS grib_api )
ecbuild_add_library( TARGET grib_api_f90
SOURCES grib_fortran.c grib_f90.f90 grib_kinds.h
GENERATED grib_f90.f90
SOURCES grib_fortran.c grib_f90.f90 eccodes_f90.f90 grib_kinds.h
GENERATED grib_f90.f90 eccodes_f90.f90
LIBS grib_api )
# Add the eccodes module file as well
@ -59,6 +66,11 @@ if( EC_HAVE_FORTRAN )
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
grib_f90_int_size_t.f90 grib_f90_long_size_t.f90
eccodes_visibility.h eccodes_constants.h
eccodes_f90.f90.head eccodes_f90.f90.tail eccodes_f90_int.f90 eccodes_f90_long_int.f90
eccodes_f90_int_size_t.f90 eccodes_f90_long_size_t.f90
same_int_long.f90 same_int_size_t.f90 grib_fortran_kinds.c )

View File

@ -9,7 +9,7 @@ libgrib_api_f77_la_SOURCES= grib_fortran.c grib_f77.c
libgrib_api_f77_la_DEPENDENCIES = $(top_builddir)/src/libgrib_api.la
libgrib_api_f77_la_LDFLAGS = -version-info $(GRIB_ABI_CURRENT):$(GRIB_ABI_REVISION):$(GRIB_ABI_AGE)
libgrib_api_f90_la_SOURCES= grib_fortran.c grib_f90.f90
libgrib_api_f90_la_SOURCES= grib_fortran.c grib_f90.f90 eccodes_f90.f90
libgrib_api_f90_la_DEPENDENCIES = $(top_builddir)/src/libgrib_api.la grib_api_externals.h grib_api_visibility.h grib_api_constants.h grib_kinds.h
libgrib_api_f90_la_LDFLAGS = -version-info $(GRIB_ABI_CURRENT):$(GRIB_ABI_REVISION):$(GRIB_ABI_AGE)
@ -18,9 +18,11 @@ libgrib_api_fortran_prototypes= grib_fortran.c
if UPPER_CASE_MOD_FALSE
nodist_include_HEADERS = grib_api.mod
grib_api.mod: grib_f90.o
eccodes.mod: eccodes_f90.o
else
nodist_include_HEADERS = GRIB_API.mod
GRIB_API.mod: grib_f90.o
ECCODES.mod: eccodes_f90.o
endif
# set the include path
@ -28,7 +30,7 @@ INCLUDES= -I$(top_builddir)/src
## Make sure these will be cleaned even when they're not built by
## default.
CLEANFILES = libgrib_api_f77.la libgrib_api_f90.la grib_f90.f90 *.mod grib_types grib_kinds.h same_int_long same_int_size_t
CLEANFILES = libgrib_api_f77.la libgrib_api_f90.la grib_f90.f90 eccodes_f90.f90 *.mod grib_types grib_kinds.h same_int_long same_int_size_t
#noinst_HEADERS =
@ -36,14 +38,23 @@ 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_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 \
\
eccodes_f90_head.f90 eccodes_f90_tail.f90 eccodes_f90_int.f90 eccodes_f90_long_int.f90 \
eccodes_f90_int_size_t.f90 eccodes_f90_long_size_t.f90 \
same_int_long.f90 same_int_size_t.f90 grib_fortran_kinds.c \
CMakeLists.txt
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
./create_grib_f90.sh
eccodes_f90.f90: eccodes_f90_head.f90 eccodes_f90_tail.f90 eccodes_f90_int.f90 eccodes_f90_long_int.f90 eccodes_f90_int_size_t.f90 eccodes_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
eccodes_f90.o : grib_kinds.h
grib_kinds.h: grib_types
./grib_types > grib_kinds.h
@ -56,13 +67,9 @@ 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
# After the installation, create the eccodes module file as a symlink
# Note: hooks are always executed after the main rule's work is done
install-data-hook:
( cd $(DESTDIR)$(includedir) && ln -s $(nodist_include_HEADERS) eccodes.mod )
#install-data-hook:
# ( some commands in here .... )
include extrules.am
all-local:
rm -f eccodes.mod; ln -s $(nodist_include_HEADERS) eccodes.mod

View File

@ -12,8 +12,10 @@ same=`./same_int_long`
if [ $same -eq 1 ]
then
long=grib_f90_int.f90
ec_long=eccodes_f90_int.f90
else
long=grib_f90_long_int.f90
ec_long=eccodes_f90_long_int.f90
fi
same=`./same_int_size_t`
@ -21,9 +23,11 @@ same=`./same_int_size_t`
if [ $same -eq 1 ]
then
sizet=grib_f90_int_size_t.f90
ec_sizet=eccodes_f90_int_size_t.f90
else
sizet=grib_f90_long_size_t.f90
ec_sizet=eccodes_f90_long_size_t.f90
fi
cat grib_f90_head.f90 $long $sizet grib_f90_tail.f90 > grib_f90.f90
cat grib_f90_head.f90 $long $sizet grib_f90_tail.f90 > grib_f90.f90
cat eccodes_f90_head.f90 $ec_long $ec_sizet eccodes_f90_tail.f90 > eccodes_f90.f90

View File

@ -0,0 +1,132 @@
! Copyright 2005-2015 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 eccodes
!>
!> The eccodes module provides the Fortran 90 interface.
module eccodes
use grib_api
implicit none
include "eccodes_constants.h"
include "eccodes_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 codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_new_from_message
module procedure codes_new_from_message_int4
module procedure codes_new_from_message_char
end interface codes_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 codes_get_error_string.
!>
!> \b Examples: \ref nearest.f90 "nearest.f90"
!>
!> @see codes_new_from_file, codes_release, codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_get_element
module procedure codes_get_real4_element, &
codes_get_real8_element, &
codes_get_real4_elements, &
codes_get_real8_elements
end interface codes_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 codes_get_element)
!> and its distance from the given point using the following
!> formula radius * 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 codes_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 (in km)
!> @param[out] index zero based index
!> @param[out] value value of the field in the nearest point
!> @param[out] status CODES_SUCCESS if OK, integer value on error
interface codes_find_nearest
module procedure codes_find_nearest_single, &
codes_find_nearest_four_single, &
codes_find_nearest_multiple
end interface codes_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 codes_get_size or by getting (with \ref codes_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 codes_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"
interface codes_get_data
module procedure codes_get_data_real4, &
codes_get_data_real8
end interface codes_get_data

159
fortran/eccodes_f90_int.f90 Normal file
View File

@ -0,0 +1,159 @@
! Copyright 2005-2015 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.
!> Get the distinct values of the key in argument contained in the index. The key must belong to the index.
!>
!>
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref index.f90 "index.f90"
!>
!> @param indexid id of an index created from a file. The index must have been created with the key in argument.
!> @param key key for wich the values are returned
!> @param values array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_index_get
module procedure codes_index_get_int, &
codes_index_get_string, &
codes_index_get_real8
end interface codes_index_get
!> Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.
!>
!>
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref index.f90 "index.f90"
!>
!> @param indexid id of an index created from a file. The index must have been created with the key in argument.
!> @param key key for which the number of values is computed
!> @param size number of distinct values of the key in the index
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_index_get_size
module procedure codes_index_get_size_int
end interface codes_index_get_size
!> Select the message subset with key==value.
!>
!>
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref index.f90 "index.f90"
!>
!> @param indexid id of an index created from a file. The index must have been created with the key in argument.
!> @param key key to be selected
!> @param value value of the key to select
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_index_select
module procedure codes_index_select_int, &
codes_index_select_string, &
codes_index_select_real8
end interface codes_index_select
!> 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.
!> In some cases the \em value can be an array rather than a scalar.
!> As examples of array keys we have "values","pl", "pv" respectively the data values,
!> the list of number of points for each latitude in a reduced grid and the list of
!> vertical levels. In these cases the \em value array must be allocated by the caller
!> and their required dimension can be obtained with \ref codes_get_size. \n
!> The \em value can be integer(4), real(4), real(8), character.
!> Although each key has its own native type, a key of type integer
!> can be retrieved (with \ref codes_get) as real(4), real(8) or character.
!> Analogous conversions are always provided when possible.
!> Illegal conversions are real to integer and character to any other type.
!>
!> The \em 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 codes_get_error_string.
!>
!> \b Examples: \ref get.f90 "get.f90", \ref print_data.f90 "print_data.f90"
!>
!> @see codes_new_from_file, codes_release, codes_set
!>
!>
!> @param[in] gribid id of the grib loaded in memory
!> @param[in] key key name
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8),character
!> @param[out] status CODES_SUCCESS if OK, integer value on error
interface codes_get
module procedure codes_get_int, &
codes_get_real4, &
codes_get_real8, &
codes_get_string, &
codes_get_int_array, &
codes_get_byte_array, &
codes_get_real4_array, &
codes_get_real8_array
end interface codes_get
!> Get the size of an array key.
!>
!> To get the size of a key representing an array.
!>
!> 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 codes_get_error_string.
!>
!> @param gribid id of the grib loaded in memory
!> @param key name of the key
!> @param size size of the array key
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_get_size
module procedure codes_get_size_int
end interface codes_get_size
!> 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.
!> In some cases the \em value can be an array rather than a scalar.
!> As examples of array keys we have "values","pl", "pv" respectively the data values,
!> the list of number of points for each latitude in a reduced grid and the list of
!> vertical levels. In these cases the \em value array must be allocated by the caller
!> and their required dimension can be obtained with \ref codes_get_size. \n
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref set.f90 "set.f90"
!>
!> @see codes_new_from_file, codes_release, codes_get
!>
!> @param[in] gribid id of the grib loaded in memory
!> @param[in] key key name
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8)
!> @param[out] status CODES_SUCCESS if OK, integer value on error
interface codes_set
module procedure codes_set_int, &
codes_set_real4, &
codes_set_real8, &
codes_set_string, &
codes_set_int_array, &
codes_set_byte_array, &
codes_set_real4_array, &
codes_set_real8_array
end interface codes_set
interface codes_set_force
module procedure codes_set_force_real4_array, &
codes_set_force_real8_array
end interface codes_set_force

View File

@ -0,0 +1,72 @@
! Copyright 2005-2015 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 codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_read_from_file
module procedure codes_read_from_file_int4
module procedure codes_read_from_file_char
end interface codes_read_from_file
!> Reads nbytes bytes into the buffer from a file opened with codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_read_bytes
module procedure codes_read_bytes_int4
module procedure codes_read_bytes_char
module procedure codes_read_bytes_real8
module procedure codes_read_bytes_real4
end interface codes_read_bytes
!> Write nbytes bytes from the buffer in a file opened with codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_write_bytes
module procedure codes_write_bytes_int4
module procedure codes_write_bytes_char
module procedure codes_write_bytes_real8
module procedure codes_write_bytes_real4
end interface codes_write_bytes
!> Get the size of a coded message.
!>
!> 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 codes_get_error_string.
!>
!> @param gribid id of the grib loaded in memory
!> @param nbytes size in bytes of the message
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_get_message_size
module procedure codes_get_message_size_int
end interface codes_get_message_size

View File

@ -0,0 +1,165 @@
! Copyright 2005-2015 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.
!> Get the distinct values of the key in argument contained in the index. The key must belong to the index.
!>
!>
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref index.f90 "index.f90"
!>
!> @param indexid id of an index created from a file. The index must have been created with the key in argument.
!> @param key key for wich the values are returned
!> @param values array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_index_get
module procedure codes_index_get_int, &
codes_index_get_long, &
codes_index_get_string, &
codes_index_get_real8
end interface codes_index_get
!> Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.
!>
!>
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref index.f90 "index.f90"
!>
!> @param indexid id of an index created from a file. The index must have been created with the key in argument.
!> @param key key for which the number of values is computed
!> @param size number of distinct values of the key in the index
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_index_get_size
module procedure codes_index_get_size_int, &
codes_index_get_size_long
end interface codes_index_get_size
!> Select the message subset with key==value.
!>
!>
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref index.f90 "index.f90"
!>
!> @param indexid id of an index created from a file. The index must have been created with the key in argument.
!> @param key key to be selected
!> @param value value of the key to select
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_index_select
module procedure codes_index_select_int, &
codes_index_select_long, &
codes_index_select_string, &
codes_index_select_real8
end interface codes_index_select
!> 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.
!> In some cases the \em value can be an array rather than a scalar.
!> As examples of array keys we have "values","pl", "pv" respectively the data values,
!> the list of number of points for each latitude in a reduced grid and the list of
!> vertical levels. In these cases the \em value array must be allocated by the caller
!> and their required dimension can be obtained with \ref codes_get_size. \n
!> The \em value can be integer(4), real(4), real(8), character.
!> Although each key has its own native type, a key of type integer
!> can be retrieved (with \ref codes_get) as real(4), real(8) or character.
!> Analogous conversions are always provided when possible.
!> Illegal conversions are real to integer and character to any other type.
!>
!> The \em 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 codes_get_error_string.
!>
!> \b Examples: \ref get.f90 "get.f90", \ref print_data.f90 "print_data.f90"
!>
!> @see codes_new_from_file, codes_release, codes_set
!>
!>
!> @param[in] gribid id of the grib loaded in memory
!> @param[in] key key name
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8),character
!> @param[out] status CODES_SUCCESS if OK, integer value on error
interface codes_get
module procedure codes_get_int, &
codes_get_long, &
codes_get_real4, &
codes_get_real8, &
codes_get_string, &
codes_get_int_array, &
codes_get_byte_array, &
codes_get_real4_array, &
codes_get_real8_array
end interface codes_get
!> Get the size of an array key.
!>
!> To get the size of a key representing an array.
!>
!> 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 codes_get_error_string.
!>
!> @param gribid id of the grib loaded in memory
!> @param key name of the key
!> @param size size of the array key
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_get_size
module procedure codes_get_size_int, &
codes_get_size_long
end interface codes_get_size
!> 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.
!> In some cases the \em value can be an array rather than a scalar.
!> As examples of array keys we have "values","pl", "pv" respectively the data values,
!> the list of number of points for each latitude in a reduced grid and the list of
!> vertical levels. In these cases the \em value array must be allocated by the caller
!> and their required dimension can be obtained with \ref codes_get_size. \n
!> 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 codes_get_error_string.
!>
!> \b Examples: \ref set.f90 "set.f90"
!>
!> @see codes_new_from_file, codes_release, codes_get
!>
!> @param[in] gribid id of the grib loaded in memory
!> @param[in] key key name
!> @param[out] value value can be a scalar or array of integer(4),real(4),real(8)
!> @param[out] status CODES_SUCCESS if OK, integer value on error
interface codes_set
module procedure codes_set_int, &
codes_set_long, &
codes_set_real4, &
codes_set_real8, &
codes_set_string, &
codes_set_int_array, &
codes_set_long_array, &
codes_set_byte_array, &
codes_set_real4_array, &
codes_set_real8_array
end interface codes_set
interface codes_set_force
module procedure codes_set_force_real4_array, &
codes_set_force_real8_array
end interface codes_set_force

View File

@ -0,0 +1,83 @@
! Copyright 2005-2015 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 codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_read_from_file
module procedure codes_read_from_file_int4
module procedure codes_read_from_file_int4_size_t
module procedure codes_read_from_file_char
module procedure codes_read_from_file_char_size_t
end interface codes_read_from_file
!> Reads nbytes bytes into the buffer from a file opened with codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_read_bytes
module procedure codes_read_bytes_int4
module procedure codes_read_bytes_int4_size_t
module procedure codes_read_bytes_char
module procedure codes_read_bytes_char_size_t
module procedure codes_read_bytes_real8
module procedure codes_read_bytes_real8_size_t
module procedure codes_read_bytes_real4
module procedure codes_read_bytes_real4_size_t
end interface codes_read_bytes
!> Write nbytes bytes from the buffer in a file opened with codes_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 codes_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 CODES_SUCCESS if OK, integer value on error
interface codes_write_bytes
module procedure codes_write_bytes_int4
module procedure codes_write_bytes_int4_size_t
module procedure codes_write_bytes_char
module procedure codes_write_bytes_char_size_t
module procedure codes_write_bytes_real8
module procedure codes_write_bytes_real8_size_t
module procedure codes_write_bytes_real4
module procedure codes_write_bytes_real4_size_t
end interface codes_write_bytes
!> Get the size of a coded message.
!>
!> 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 codes_get_error_string.
!>
!> @param gribid id of the grib loaded in memory
!> @param nbytes size in bytes of the message
!> @param status CODES_SUCCESS if OK, integer value on error
interface codes_get_message_size
module procedure codes_get_message_size_int
module procedure codes_get_message_size_size_t
end interface codes_get_message_size

View File

@ -1,3 +1,6 @@
contains
!>
!> Wrapper for eccodes
!>
@ -1245,3 +1248,5 @@ subroutine codes_skip_read_only ( iterid, status )
call grib_skip_read_only ( iterid, status )
end subroutine codes_skip_read_only
end module eccodes

View File

@ -15,10 +15,8 @@ module grib_api
implicit none
include "grib_kinds.h"
include "grib_api_constants.h"
include "eccodes_constants.h"
include "grib_api_externals.h"
include "grib_api_visibility.h"
include "eccodes_visibility.h"
!> Create a new message in memory from an integer or character array containting the coded message.
!>
@ -40,10 +38,6 @@ module grib_api
module procedure grib_new_from_message_int4
module procedure grib_new_from_message_char
end interface grib_new_from_message
interface codes_new_from_message
module procedure codes_new_from_message_int4
module procedure codes_new_from_message_char
end interface codes_new_from_message
!> Get a value of specified index from an array key.
!>
@ -73,12 +67,6 @@ module grib_api
grib_get_real4_elements, &
grib_get_real8_elements
end interface grib_get_element
interface codes_get_element
module procedure codes_get_real4_element, &
codes_get_real8_element, &
codes_get_real4_elements, &
codes_get_real8_elements
end interface codes_get_element
!> Find the nearest point/points of a given latitude/longitude point.
!>
@ -122,12 +110,6 @@ module grib_api
grib_find_nearest_multiple
end interface grib_find_nearest
interface codes_find_nearest
module procedure codes_find_nearest_single, &
codes_find_nearest_four_single, &
codes_find_nearest_multiple
end interface codes_find_nearest
!> Get latitude/longitude and data values.
!>
!> Latitudes, longitudes, data values arrays are returned.
@ -151,7 +133,3 @@ module grib_api
grib_get_data_real8
end interface grib_get_data
interface codes_get_data
module procedure codes_get_data_real4, &
codes_get_data_real8
end interface codes_get_data

View File

@ -25,11 +25,6 @@
grib_index_get_string, &
grib_index_get_real8
end interface grib_index_get
interface codes_index_get
module procedure codes_index_get_int, &
codes_index_get_string, &
codes_index_get_real8
end interface codes_index_get
!> Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.
!>
@ -47,9 +42,6 @@
interface grib_index_get_size
module procedure grib_index_get_size_int
end interface grib_index_get_size
interface codes_index_get_size
module procedure codes_index_get_size_int
end interface codes_index_get_size
!> Select the message subset with key==value.
!>
@ -69,11 +61,6 @@
grib_index_select_string, &
grib_index_select_real8
end interface grib_index_select
interface codes_index_select
module procedure codes_index_select_int, &
codes_index_select_string, &
codes_index_select_real8
end interface codes_index_select
!> Get the value for a key from a grib message.
!>
@ -114,17 +101,7 @@
grib_get_real4_array, &
grib_get_real8_array
end interface grib_get
interface codes_get
module procedure codes_get_int, &
codes_get_real4, &
codes_get_real8, &
codes_get_string, &
codes_get_int_array, &
codes_get_byte_array, &
codes_get_real4_array, &
codes_get_real8_array
end interface codes_get
!> Get the size of an array key.
!>
@ -141,9 +118,6 @@
interface grib_get_size
module procedure grib_get_size_int
end interface grib_get_size
interface codes_get_size
module procedure codes_get_size_int
end interface codes_get_size
!> Set the value for a key in a grib message.
!>
@ -177,23 +151,8 @@
grib_set_real4_array, &
grib_set_real8_array
end interface grib_set
interface codes_set
module procedure codes_set_int, &
codes_set_real4, &
codes_set_real8, &
codes_set_string, &
codes_set_int_array, &
codes_set_byte_array, &
codes_set_real4_array, &
codes_set_real8_array
end interface codes_set
interface grib_set_force
module procedure grib_set_force_real4_array, &
grib_set_force_real8_array
end interface grib_set_force
interface codes_set_force
module procedure codes_set_force_real4_array, &
codes_set_force_real8_array
end interface codes_set_force

View File

@ -21,10 +21,6 @@
module procedure grib_read_from_file_int4
module procedure grib_read_from_file_char
end interface grib_read_from_file
interface codes_read_from_file
module procedure codes_read_from_file_int4
module procedure codes_read_from_file_char
end interface codes_read_from_file
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
!>
@ -43,12 +39,6 @@
module procedure grib_read_bytes_real8
module procedure grib_read_bytes_real4
end interface grib_read_bytes
interface codes_read_bytes
module procedure codes_read_bytes_int4
module procedure codes_read_bytes_char
module procedure codes_read_bytes_real8
module procedure codes_read_bytes_real4
end interface codes_read_bytes
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
!>
@ -67,12 +57,6 @@
module procedure grib_write_bytes_real8
module procedure grib_write_bytes_real4
end interface grib_write_bytes
interface codes_write_bytes
module procedure codes_write_bytes_int4
module procedure codes_write_bytes_char
module procedure codes_write_bytes_real8
module procedure codes_write_bytes_real4
end interface codes_write_bytes
!> Get the size of a coded message.
!>
@ -86,6 +70,3 @@
interface grib_get_message_size
module procedure grib_get_message_size_int
end interface grib_get_message_size
interface codes_get_message_size
module procedure codes_get_message_size_int
end interface codes_get_message_size

View File

@ -26,12 +26,6 @@
grib_index_get_string, &
grib_index_get_real8
end interface grib_index_get
interface codes_index_get
module procedure codes_index_get_int, &
codes_index_get_long, &
codes_index_get_string, &
codes_index_get_real8
end interface codes_index_get
!> Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.
!>
@ -50,10 +44,6 @@
module procedure grib_index_get_size_int, &
grib_index_get_size_long
end interface grib_index_get_size
interface codes_index_get_size
module procedure codes_index_get_size_int, &
codes_index_get_size_long
end interface codes_index_get_size
!> Select the message subset with key==value.
!>
@ -74,12 +64,6 @@
grib_index_select_string, &
grib_index_select_real8
end interface grib_index_select
interface codes_index_select
module procedure codes_index_select_int, &
codes_index_select_long, &
codes_index_select_string, &
codes_index_select_real8
end interface codes_index_select
!> Get the value for a key from a grib message.
!>
@ -121,17 +105,6 @@
grib_get_real4_array, &
grib_get_real8_array
end interface grib_get
interface codes_get
module procedure codes_get_int, &
codes_get_long, &
codes_get_real4, &
codes_get_real8, &
codes_get_string, &
codes_get_int_array, &
codes_get_byte_array, &
codes_get_real4_array, &
codes_get_real8_array
end interface codes_get
!> Get the size of an array key.
!>
@ -149,10 +122,6 @@
module procedure grib_get_size_int, &
grib_get_size_long
end interface grib_get_size
interface codes_get_size
module procedure codes_get_size_int, &
codes_get_size_long
end interface codes_get_size
!> Set the value for a key in a grib message.
!>
@ -188,25 +157,8 @@
grib_set_real4_array, &
grib_set_real8_array
end interface grib_set
interface codes_set
module procedure codes_set_int, &
codes_set_long, &
codes_set_real4, &
codes_set_real8, &
codes_set_string, &
codes_set_int_array, &
codes_set_long_array, &
codes_set_byte_array, &
codes_set_real4_array, &
codes_set_real8_array
end interface codes_set
interface grib_set_force
module procedure grib_set_force_real4_array, &
grib_set_force_real8_array
end interface grib_set_force
interface codes_set_force
module procedure codes_set_force_real4_array, &
codes_set_force_real8_array
end interface codes_set_force

View File

@ -23,12 +23,6 @@
module procedure grib_read_from_file_char
module procedure grib_read_from_file_char_size_t
end interface grib_read_from_file
interface codes_read_from_file
module procedure codes_read_from_file_int4
module procedure codes_read_from_file_int4_size_t
module procedure codes_read_from_file_char
module procedure codes_read_from_file_char_size_t
end interface codes_read_from_file
!> Reads nbytes bytes into the buffer from a file opened with grib_open_file.
!>
@ -51,16 +45,6 @@
module procedure grib_read_bytes_real4
module procedure grib_read_bytes_real4_size_t
end interface grib_read_bytes
interface codes_read_bytes
module procedure codes_read_bytes_int4
module procedure codes_read_bytes_int4_size_t
module procedure codes_read_bytes_char
module procedure codes_read_bytes_char_size_t
module procedure codes_read_bytes_real8
module procedure codes_read_bytes_real8_size_t
module procedure codes_read_bytes_real4
module procedure codes_read_bytes_real4_size_t
end interface codes_read_bytes
!> Write nbytes bytes from the buffer in a file opened with grib_open_file.
!>
@ -83,16 +67,6 @@
module procedure grib_write_bytes_real4
module procedure grib_write_bytes_real4_size_t
end interface grib_write_bytes
interface codes_write_bytes
module procedure codes_write_bytes_int4
module procedure codes_write_bytes_int4_size_t
module procedure codes_write_bytes_char
module procedure codes_write_bytes_char_size_t
module procedure codes_write_bytes_real8
module procedure codes_write_bytes_real8_size_t
module procedure codes_write_bytes_real4
module procedure codes_write_bytes_real4_size_t
end interface codes_write_bytes
!> Get the size of a coded message.
!>
@ -107,7 +81,3 @@
module procedure grib_get_message_size_int
module procedure grib_get_message_size_size_t
end interface grib_get_message_size
interface codes_get_message_size
module procedure codes_get_message_size_int
module procedure codes_get_message_size_size_t
end interface codes_get_message_size

View File

@ -3132,10 +3132,5 @@
endif
end subroutine grib_skip_read_only
!>
!> eccodes wrapper functions
!>
include "eccodes_f90_tail.f90"
end module grib_api