-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvarlist_item_mod.f90
45 lines (37 loc) · 1.32 KB
/
varlist_item_mod.f90
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
module libvarlistitem
use, intrinsic :: iso_c_binding
use libvarlistitem_c
private
public :: varlist_item
type varlist_item
type(varlist_item_c) :: item
contains
procedure :: getName => varlist_item_getName
procedure :: getValuePtr => varlist_item_getValuePtr
end type varlist_item
interface varlist_item
procedure varlist_item_create
end interface varlist_item
contains
function varlist_item_create(name, value_ptr)
implicit none
type(varlist_item) :: varlist_item_create
integer, intent(in) :: name
type(c_ptr), intent(in) :: value_ptr
varlist_item_create%item%name = name
varlist_item_create%item%value_ptr = value_ptr
end function varlist_item_create
function varlist_item_getName(this) result(name)
use, intrinsic :: iso_c_binding
implicit none
integer(c_int) :: name
class(varlist_item), intent(in) :: this
name = this%item%name
end function varlist_item_getName
function varlist_item_getValuePtr(this) result(value_ptr)
implicit none
real*8, pointer :: value_ptr
class(varlist_item), intent(in) :: this
call c_f_pointer(this%item%value_ptr, value_ptr)
end function varlist_item_getValuePtr
end module libvarlistitem