libsim  Versione 7.1.7
arrayof_pre_nodoc.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 
28 TYPE arrayof_type
29  arrayof_origtype, POINTER :: array(:)=>null()
30  INTEGER :: arraysize=0
31  DOUBLE PRECISION :: overalloc=2.0d0
32 END TYPE arrayof_type
33 
34 INTERFACE insert
35  MODULE PROCEDURE arrayof_type/**/_insert, arrayof_type/**/_insert_array
36 END INTERFACE
37 
38 INTERFACE append
39  MODULE PROCEDURE arrayof_type/**/_append
40 END INTERFACE
41 
42 INTERFACE remove
43  MODULE PROCEDURE arrayof_type/**/_remove
44 END INTERFACE
45 
46 INTERFACE delete
47  MODULE PROCEDURE arrayof_type/**/_delete
48 END INTERFACE
49 
50 INTERFACE packarray
51  MODULE PROCEDURE arrayof_type/**/_packarray
52 END INTERFACE
53 
54 #ifndef ARRAYOF_PRIVATE
55 PUBLIC arrayof_type
56 #endif
57 
58 PRIVATE arrayof_type/**/_alloc, &
59  arrayof_type/**/_insert, arrayof_type/**/_insert_array, &
60  arrayof_type/**/_append, arrayof_type/**/_remove, &
61  arrayof_type/**/_delete, &
62  arrayof_type/**/_packarray
63 
64 !PUBLIC insert, append, remove, delete, packarray
65 
66 #ifdef ARRAYOF_ORIGEQ
67 INTERFACE insert_unique
68  MODULE PROCEDURE arrayof_type/**/_insert_unique
69 END INTERFACE
70 
71 INTERFACE append_unique
72  MODULE PROCEDURE arrayof_type/**/_append_unique
73 END INTERFACE
74 
75 #ifdef ARRAYOF_ORIGGT
76 INTERFACE insert_sorted
77  MODULE PROCEDURE arrayof_type/**/_insert_sorted
78 END INTERFACE insert_sorted
79 
80 PRIVATE arrayof_type/**/_insert_sorted
81 #endif
82 
83 PRIVATE arrayof_type/**/_insert_unique, arrayof_type/**/_append_unique
84 
85 !PUBLIC insert_unique, append_unique
86 #endif
87 

Generated with Doxygen.