summaryrefslogtreecommitdiff
path: root/Ganlib/src/KDIOP.f90
blob: 0af8d6a6083302a0aa72956d164372229f70e196 (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
!
!-----------------------------------------------------------------------
!
!Purpose:
! Fortran-2003 bindings for kdi.
!
!Copyright:
! Copyright (C) 2009 Ecole Polytechnique de Montreal
! This library is free software; you can redistribute it and/or
! modify it under the terms of the GNU Lesser General Public
! License as published by the Free Software Foundation; either
! version 2.1 of the License, or (at your option) any later version.
!
!Author(s): A. Hebert
!
!-----------------------------------------------------------------------
!
function KDIOP(name, iactio)
   ! open a KDI file
   use, intrinsic :: iso_c_binding
   use LCMAUX
   type(c_ptr) KDIOP
   character(len=*) :: name
   integer :: iactio
   character(kind=c_char), dimension(13) :: name13
   interface
      function kdiop_c (name_c, iactio) bind(c)
         use, intrinsic :: iso_c_binding
         type(c_ptr) kdiop_c
         character(kind=c_char), dimension(*) :: name_c
         integer(c_int), value :: iactio
      end function kdiop_c
   end interface
   call STRCUT(name13, name)
   KDIOP=kdiop_c(name13, iactio)
end function KDIOP
!
subroutine KDIPUT(my_file, idata, iofset, length)
   ! store a data array in a KDI file at offset iofset
   use, intrinsic :: iso_c_binding
   type(c_ptr) :: my_file, pt_data
   integer, target, dimension(*) :: idata
   integer :: iofset, length
   interface
      subroutine kdiput_c (my_file, idata, iofset, length) bind(c)
         use, intrinsic :: iso_c_binding
         type(c_ptr), value :: my_file, idata
         integer(c_int), value :: iofset, length
      end subroutine kdiput_c
   end interface
   pt_data=c_loc(idata)
   call kdiput_c(my_file, pt_data, iofset, length)
end subroutine KDIPUT
!
subroutine KDIGET(my_file, idata, iofset, length)
   ! read a data array from a KDI file at offset iofset
   use, intrinsic :: iso_c_binding
   type(c_ptr) :: my_file, pt_data
   integer, target, dimension(*) :: idata
   integer :: iofset, length
   interface
      subroutine kdiget_c (my_file, idata, iofset, length) bind(c)
         use, intrinsic :: iso_c_binding
         type(c_ptr), value :: my_file, idata
         integer(c_int), value :: iofset, length
      end subroutine kdiget_c
   end interface
   pt_data=c_loc(idata)
   call kdiget_c(my_file, pt_data, iofset, length)
end subroutine KDIGET
!
function KDICL(my_file, istatu)
   ! close a KDI file
   use, intrinsic :: iso_c_binding
   integer(c_int) KDICL
   type(c_ptr) :: my_file
   integer :: istatu
   interface
      function kdicl_c (my_file, istatu) bind(c)
         use, intrinsic :: iso_c_binding
         integer(c_int) kdicl_c
         type(c_ptr), value :: my_file
         integer(c_int), value :: istatu
      end function kdicl_c
   end interface
   KDICL=kdicl_c(my_file, istatu)
end function KDICL