libsim  Versione6.3.0
arrayof_pre.F90
1 ! This universal template can be used to wrap any derived type into a
2 ! derived type defining a 1-dimensional array of the original type;
3 ! this array can be dynamically extended or shortened by adding or
4 ! removing elements at an arbitrary position through the ::insert and
5 ! ::remove methods. All the allocations, deallocations, copy
6 ! operations are taken care of in the present module; the user can
7 ! also call the ::packarray method in order to reduce the memory
8 ! occupation of the object or the ::delete method in order to delete
9 ! all the data and release all the memory. Before use, any object of
10 ! the array type should be initialised through the constructor
11 ! ARRAYOF_TYPE_new:: .
12 !
13 ! The template requires the definition of the following preprocessor macros
14 ! before being included:
15 ! - \c ARRAYOF_ORIGTYPE the type to be wrapped
16 ! - \c ARRAYOF_TYPE the name of the "arrayed" derived type, containing a 1-d array of ARRAYOF_ORIGTYPE, if undefined it will be \a arrayof_ARRAYOF_ORIGTYPE
17 ! - \c ARRAYOF_ORIGDESTRUCTOR(x) the instruction required in order to "destroy" an object of \c ARRAYOF_ORIGTYPE when the ::remove method is called, optional, if undefined no destructor is called
18 ! - \c ARRAYOF_ORIGEQ to be defined if ARRAYOF_ORIGTYPE supports the == operator, in that case the *_unique method are defined for the array
19 ! - \c ARRAYOF_PRIVATE to be defined if the array type is not going to be PUBLIC
20 !
21 ! The template comes in 2 parts, one to be included in the
22 ! declaration part of the module (before \c CONTAINS) and the second
23 ! in the execution part of it (after \c CONTAINS).
24 #ifndef ARRAYOF_TYPE
25 #define ARRAYOF_TYPE arrayof_/**/ARRAYOF_ORIGTYPE
26 #endif
27 
29 TYPE arrayof_type
30  arrayof_origtype, POINTER :: array(:)=>null()
31  INTEGER :: arraysize=0
34  DOUBLE PRECISION :: overalloc=2.0d0
35 END TYPE arrayof_type
36 
39 INTERFACE insert
40  MODULE PROCEDURE arrayof_type/**/_insert, arrayof_type/**/_insert_array
41 END INTERFACE
42 
48 INTERFACE append
49  MODULE PROCEDURE arrayof_type/**/_append
50 END INTERFACE
51 
54 INTERFACE remove
55  MODULE PROCEDURE arrayof_type/**/_remove
56 END INTERFACE
57 
61 INTERFACE delete
62  MODULE PROCEDURE arrayof_type/**/_delete
63 END INTERFACE
64 
71 INTERFACE packarray
72  MODULE PROCEDURE arrayof_type/**/_packarray
73 END INTERFACE
74 
75 #ifndef ARRAYOF_PRIVATE
76 PUBLIC arrayof_type
77 #endif
78 
79 PRIVATE arrayof_type/**/_alloc, &
80  arrayof_type/**/_insert, arrayof_type/**/_insert_array, &
81  arrayof_type/**/_append, arrayof_type/**/_remove, &
82  arrayof_type/**/_delete, &
83  arrayof_type/**/_packarray
84 
85 !PUBLIC insert, append, remove, delete, packarray
86 
87 #ifdef ARRAYOF_ORIGEQ
88 INTERFACE insert_unique
89  MODULE PROCEDURE arrayof_type/**/_insert_unique
90 END INTERFACE
91 
92 INTERFACE append_unique
93  MODULE PROCEDURE arrayof_type/**/_append_unique
94 END INTERFACE
95 
96 #ifdef ARRAYOF_ORIGGT
97 INTERFACE insert_sorted
98  MODULE PROCEDURE arrayof_type/**/_insert_sorted
99 END INTERFACE insert_sorted
100 
101 PRIVATE arrayof_type/**/_insert_sorted
102 #endif
103 
104 PRIVATE arrayof_type/**/_insert_unique, arrayof_type/**/_append_unique
105 
106 !PUBLIC insert_unique, append_unique
107 #endif
108 

Generated with Doxygen.