IODA Bundle
legacy_test_fortran_api_open_non_existing_file.f90
Go to the documentation of this file.
1 ! (C) Copyright 1996-2012 ECMWF.
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 ! In applying this licence, ECMWF does not waive the privileges and immunities
6 ! granted to it by virtue of its status as an intergovernmental organisation nor
7 ! does it submit to any jurisdiction.
8 !
9 
11  use, intrinsic :: iso_c_binding
12  use odc_c_binding
13  implicit none
14 
15  integer, parameter :: max_varlen = 128
16  integer(kind=4) :: ncolumns = 4
17 
18  write(0,*) "Calling odb_start..."
19 
20  call odb_start()
21 
23 
24 contains
25 
27  implicit none
28  type(c_ptr) :: odb_handle, odb_it, odb_select_handle, odb_select_it
29  integer(kind=C_INT) :: cerr
30  character(kind=C_CHAR, len=64) :: config = c_null_char
31  character(kind=C_CHAR, len=max_varlen) :: inputfile = "test_fortran_api_non_existing_file.odb"//achar(0)
32  character(kind=C_CHAR, len=128) :: sql='select * from "test_fortran_api_non_existing_file.odb";'//achar(0)
33 
34  write(0,*) 'test_fortran_api_non_existing_file'
35  odb_handle = odb_read_new(config, cerr)
36  odb_it = odb_read_iterator_new(odb_handle, inputfile, cerr);
37  ! This should fail
38  write(0,*) 'test_fortran_api_non_existing_file: odb_read_iterator_new => ', cerr
39  if (cerr == 0) stop 1
40 
41  odb_handle = odb_select_new(config, cerr)
42  odb_it = odb_select_iterator_new(odb_handle, sql, cerr);
43  if (cerr == 0) stop 1
45 
46 end program test_fortran_api
Initialize ODB API. This function must be called before any other function from the ODB API.
Provides Fortran bindings for ODB API.