forked from ImperialCollegeLondon/WInc3D
-
Notifications
You must be signed in to change notification settings - Fork 4
/
FreeIPC_free.f90
82 lines (70 loc) · 2.53 KB
/
FreeIPC_free.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
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
! FreeIPC - A library to allow Fortran programs that use MPI
! to easily access shared memory within multicore nodes
! Date - 23rd Oct Version 0.0
! Copyright(C) 2009 Ian Bush
!
! 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 3.0 of the License, or (at your option) any later version.
!
! This library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public
! License along with this library; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
!
!
! This library is released under LGPL. The full text of LGPL may be found
! at http://www.gnu.org/licenses/lgpl-3.0.txt
!
! In particular, the terms of the GNU LGPL imply that you CAN use this library with
! proprietary code with some restrictions (you can link, but not use the code directly).
! Please consult the above URL for exact details.
Type( FIPC_ctxt ) :: ctxt
Type( segment_list_type ), Pointer :: p
! Check things are initialized
If( .Not. Associated( FIPC_ctxt_world%initialized ) ) Then
error = FIPC_not_initialized
Return
End If
If( .Not. Associated( a ) ) Then
error = FIPC_free_null_pointer
Return
End If
! First find the segment
! Be careful to only look at segments that could possible be associated
! with this pointer
p => seg_list
Do While( Associated( p ) )
If( p%data%type == type ) Then
If( Size( p%data%sizes ) == Size( Shape( a ) ) ) Then
If( All( p%data%sizes == Shape( a ) ) ) Then
Call c_f_pointer( p%data%shmaddr, fp, p%data%sizes )
If( Associated( a, fp ) ) Then
Exit
End If
End If
End If
End If
p => p%next
End Do
If( .Not. Associated( p ) ) Then
error = FIPC_seg_not_found
Return
End If
If( debug ) Then
ctxt = p%data%ctxt
End If
Call segment_free( p%data%shmid, error )
If( error /= FIPC_success ) Then
Return
End If
a => Null()
If( debug ) Then
Call print_seg_list( ctxt )
End If
error = FIPC_success