summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Eff_F03.f90
blob: bf4797fc99689563c9266923473eebc9e2d7a31d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
!****h* ROBODoc/H5E (F03)
!
! NAME
!  H5L_PROVISIONAL
!
! FILE
!  src/fortran/src/H5Eff_F03.f90 
!
! PURPOSE
!
!  This file contains Fortran 90 and Fortran 2003 interfaces for H5E functions.
!  It contains the same functions as H5Eff_DEPRECIATE.f90 but includes the
!  Fortran 2003 functions and the interface listings. This file will be compiled
!  instead of H5Eff_DEPRECIATE.f90 if Fortran 2003 functions are enabled.
!
!
! COPYRIGHT
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!   Copyright by The HDF Group.                                               *
!   Copyright by the Board of Trustees of the University of Illinois.         *
!   All rights reserved.                                                      *
!                                                                             *
!   This file is part of HDF5.  The full HDF5 copyright notice, including     *
!   terms governing use, modification, and redistribution, is contained in    *
!   the files COPYING and Copyright.html.  COPYING can be found at the root   *
!   of the source code distribution tree; Copyright.html can be found at the  *
!   root level of an installed copy of the electronic HDF5 document set and   *
!   is linked from the top-level documents page.  It can also be found at     *
!   http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
!   access to either file, you may request a copy from help@hdfgroup.org.     *
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!
! NOTES
!                         *** IMPORTANT ***
!  If you add a new H5E function to the module you must add the function name
!  to the Windows dll file 'hdf5_fortrandll.def' in the fortran/src directory.
!  This is needed for Windows based operating systems.
!
!*****

MODULE H5E_PROVISIONAL

  USE H5GLOBAL

CONTAINS

  INTEGER FUNCTION h5eprint_def() bind(C)

    USE ISO_C_BINDING
    IMPLICIT NONE
    INTEGER :: hdferr
    
    PRINT*,'Inside h5eprint_def'
!    STOP

!!$    CALL h5eprint_f(hdferr)
!!$    h5eprint_def = hdferr
    
  END FUNCTION h5eprint_def

!****s* H5E/h5eset_auto2_f
!
! NAME
!  h5eset_auto2_f
!
! PURPOSE
!  Returns settings for automatic error stack traversal function and its data.
!
! Inputs:
!  printflag   - Flag to turn automatic error printing on or off;
!                possible values are:
!                  printon (1)
!                  printoff(0)
!  estack_id   - Error stack identifier.
!  func        - Function to be called upon an error condition.
!  client_data - Data passed to the error function
!  
! Outputs:
!  hdferr      - Returns 0 if successful and -1 if fails
!
! AUTHOR
!  M. Scot Breitenfeld
!  July 10, 2009
!
! Signature:
  SUBROUTINE h5eset_auto_f(printflag, hdferr, estack_id, func, client_data)
    USE ISO_C_BINDING
    INTEGER       , INTENT(IN)            :: printflag
    INTEGER       , INTENT(OUT)           :: hdferr
    INTEGER(HID_T), INTENT(IN) , OPTIONAL :: estack_id
    TYPE(C_FUNPTR), INTENT(IN) , OPTIONAL :: func
    TYPE(C_PTR)   , INTENT(IN) , OPTIONAL :: client_data
!*****
    INTEGER(HID_T) :: estack_id_default
    TYPE(C_FUNPTR) :: func_default
    TYPE(C_PTR)    :: client_data_default
    INTERFACE
       INTEGER FUNCTION h5eset_auto2_c(printflag, estack_id, func, client_data)
         USE ISO_C_BINDING
         USE H5GLOBAL
         !DEC$IF DEFINED(HDF5F90_WINDOWS)
         !DEC$ATTRIBUTES C,reference,decorate,alias:'H5ESET_AUTO2_C'::h5eset_auto2_c
         !DEC$ENDIF
         INTEGER :: printflag
         INTEGER(HID_T) :: estack_id
!!$         TYPE(C_FUNPTR) :: func
!!$         TYPE(C_PTR), VALUE :: client_data
         TYPE(C_FUNPTR), VALUE :: func
         TYPE(C_PTR), VALUE :: client_data
       END FUNCTION h5eset_auto2_c
    END INTERFACE

    estack_id_default = -1
    func_default = C_NULL_FUNPTR
    client_data_default = C_NULL_PTR

    IF(PRESENT(estack_id)) estack_id_default = estack_id
    IF(PRESENT(func)) func_default = func
    IF(PRESENT(client_data)) client_data_default = client_data

    hdferr = h5eset_auto2_c(printflag, estack_id_default, func_default, client_data_default)
  END SUBROUTINE h5eset_auto_f

!****s* H5E/h5eget_auto_f
!
! NAME
!  h5eget_auto_f
!
! PURPOSE
!  Returns the settings for the automatic error stack traversal function and its data.
!
! Inputs:
!  estack_id    - Error stack identifier. H5E_DEFAULT_F indicates the current stack.
! Outputs:
!  func         - The function currently set to be called upon an error condition.
!  client_data  - Data currently set to be passed to the error function.
!  hdferr       - Returns 0 if successful and -1 if fails.
!
! AUTHOR
!  M. Scot Breitenfeld
!  July 10, 2009
!
! Signature:
  SUBROUTINE h5eget_auto_f(estack_id, op, client_data, hdferr)
    USE ISO_C_BINDING
    IMPLICIT NONE
    INTEGER(HID_T), INTENT(IN) :: estack_id
!!$    TYPE(C_FUNPTR) :: op_f
!!$    TYPE(C_PTR) :: client_data_f
    TYPE(C_FUNPTR) :: op
    TYPE(C_PTR), VALUE :: client_data
    INTEGER, INTENT(OUT) :: hdferr
!*****
    INTEGER :: ret_func2
    !INTEGER(C_INT), DIMENSION(:), POINTER :: ptr_data
    INTEGER, DIMENSION(1:1) :: array_shape
    TYPE(C_PTR), TARGET :: f_ptr1
    INTEGER(C_INT) :: ptr_data
    INTEGER(C_INT) :: i
    TYPE(C_PTR) :: test
    INTEGER, POINTER :: a

    INTEGER, TARGET :: j
    TYPE(C_PTR) :: f_ptr2

    INTERFACE
       INTEGER FUNCTION h5eget_auto_c(estack_id, op, client_data, ret_func2)
         USE ISO_C_BINDING
         USE H5GLOBAL
         IMPLICIT NONE
         !DEC$IF DEFINED(HDF5F90_WINDOWS)
         !DEC$ATTRIBUTES C,reference,decorate,alias:'H5EGET_AUTO_C'::h5eget_auto_c
         !DEC$ENDIF
         INTEGER(HID_T) :: estack_id
         TYPE(C_FUNPTR) :: op
         TYPE(C_PTR) :: client_data
         INTEGER :: ret_func2
       END FUNCTION h5eget_auto_c

!!$       TYPE(C_PTR) FUNCTION h5eget_auto_c2(estack_id, op, ret_func2)
!!$         USE ISO_C_BINDING
!!$         USE H5GLOBAL
!!$         IMPLICIT NONE
!!$         !DEC$IF DEFINED(HDF5F90_WINDOWS)
!!$         !DEC$ATTRIBUTES C,reference,decorate,alias:'H5EGET_AUTO_C'::h5eget_auto_c
!!$         !DEC$ENDIF
!!$         INTEGER(HID_T) :: estack_id
!!$         TYPE(C_FUNPTR) :: op
!!$         INTEGER :: ret_func2
!!$       END FUNCTION h5eget_auto_c2

!!$    SUBROUTINE process_buffer(estack_id, buffer)
!!$       USE, INTRINSIC :: ISO_C_BINDING
!!$      USE H5GLOBAL
!!$       INTEGER(HID_T) :: estack_id
!!$       TYPE(C_PTR) :: buffer
!!$     END SUBROUTINE process_buffer

    END INTERFACE

!   j = -9999


    f_ptr2 = c_loc(j)
!    CALL process_buffer(estack_id,f_ptr2)

    hdferr = h5eget_auto_c(estack_id, op, f_ptr2, ret_func2)

!!!!!    PRINT*,c_associated(f_ptr2)
!!$    hdferr = h5eget_auto_c(estack_id, op, client_data, ret_func2)
    
    PRINT*,'fortran',j
    stop

!    client_data = h5eget_auto_c2(estack_id, op, ret_func2)

!    PRINT*,'Is client_data associated',C_associated(client_data)
!    PRINT*,'Is op_data associated',C_associated(op)

!    ALLOCATE(i(1:1))
!    CALL c_f_pointer(f_ptr2,a,[1])
!    CALL c_f_pointer(f_ptr2,i)
!    PRINT*,i
!    PRINT*,"Buffer in (F) = ", a(1)

!    stop

!    ALLOCATE(ptr_data(1:2))
!    ptr_data = 0
!    array_shape(1) = 1
!    CALL C_F_POINTER(client_data, ptr_data, array_shape)
!    CALL C_F_POINTER(f_ptr2, i,(/ 1 /))

!    ptr_data => f_ptr1(1)

!    PRINT*,'value in fortran',i
    

! Check to see if the user created their own function,
! otherwise we have to create a fortran version of the default

!!$    IF(ret_func2.EQ.0)THEN
!!$       op = c_funloc(h5eprint_def)
!!$    END IF

  END SUBROUTINE h5eget_auto_f

END MODULE H5E_PROVISIONAL