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

Generated with Doxygen.