ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/vector_class.F90
Revision: 317
Committed: Tue Mar 11 23:13:06 2003 UTC (21 years, 5 months ago) by gezelter
File size: 23977 byte(s)
Log Message:
Bug fixes

File Contents

# User Rev Content
1 chuckv 315 ! vector_class.F90
2     !! Module Vector_class
3     !! Fortran 95 Vector class module. Similar to java.util vector class.
4     !!
5     !! The Vector class implements a growable array of objects. Like an array,
6 gezelter 316 !! it contains components that can be accessed using an integer index.
7     !! However, the size of a Vector can grow as needed to accommodate
8 chuckv 315 !! adding and removing items after the Vector has been created.
9 gezelter 316 !! Each vector tries to optimize storage management by maintaining a
10     !! capacity and a capacityIncrement. The capacity is always at least as
11     !! large as the vector size;
12 chuckv 315 !! it is usually larger because as components are added to the vector,
13     !! the vector's storage increases in chunks the size of capacityIncrement.
14 gezelter 316 !! An application can increase the capacity of a vector before inserting a
15     !! large number of components; this reduces the amount of incremental
16     !! reallocation.
17 chuckv 315 !!
18     !!
19     !! @author J. Daniel Gezelter
20     !! @author Charles F. Vardeman II
21     !! @author Matthew Meineke
22 gezelter 317 !! @version $Id: vector_class.F90,v 1.6 2003-03-11 23:13:06 gezelter Exp $, $Date: 2003-03-11 23:13:06 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $
23 chuckv 315
24 gezelter 312 module Vector_class
25    
26     implicit NONE
27     PRIVATE
28    
29     public :: initialize
30     public :: getSize
31     public :: getElementAt
32     public :: getPropertyListSize
33     public :: getPropertyNameAt
34     public :: addElement
35     public :: setElementProperty
36     public :: getElementProperty
37 gezelter 313 public :: getMatchingElementList
38     public :: getFirstMatchingElement
39 gezelter 312
40     integer, parameter :: logical_data_type = 1
41     integer, parameter :: integer_data_type = 2
42     integer, parameter :: real_data_type = 3
43    
44 chuckv 315 !!
45 gezelter 312 type, public :: Vector
46     PRIVATE
47     integer :: initialCapacity = 10
48     integer :: capacityIncrement = 0
49     integer :: elementCount = 0
50    
51     integer :: initialProperties = 5
52     integer :: PropertyIncrement = 0
53     integer :: propertyCount = 0
54    
55 chuckv 315 integer, pointer :: ElementData(:) => null()
56     character(len=100), pointer :: PropertyDescriptions(:) => null()
57     integer, pointer :: PropertyDataType(:) => null()
58 gezelter 316 real(kind = 8), pointer :: realElementProperties(:,:) => null()
59 chuckv 315 integer, pointer :: integerElementProperties(:,:) => null()
60     logical, pointer :: logicalElementProperties(:,:) => null()
61 gezelter 312 end type Vector
62    
63 chuckv 315 !! Initialize vector
64 gezelter 312 interface initialize
65     module procedure initialize_0i
66     module procedure initialize_1i
67     module procedure initialize_2i
68     module procedure initialize_3i
69     module procedure initialize_4i
70     end interface
71    
72     interface setElementProperty
73     module procedure setElementPropertyReal
74     module procedure setElementPropertyInt
75     module procedure setElementPropertyLogical
76     end interface
77    
78     interface getElementProperty
79     module procedure getElementPropertyReal
80     module procedure getElementPropertyInt
81     module procedure getElementPropertyLogical
82     end interface
83 gezelter 313
84     interface getMatchingElementList
85     module procedure getMatchingElementList1i
86     module procedure getMatchingElementList2i
87 gezelter 316 module procedure getMatchingElementList1l
88     module procedure getMatchingElementList2l
89 gezelter 313 end interface
90    
91     interface getFirstMatchingElement
92     module procedure getFirstMatchingElement1i
93     module procedure getFirstMatchingElement2i
94 gezelter 316 module procedure getFirstMatchingElement1l
95     module procedure getFirstMatchingElement2l
96 gezelter 313 end interface
97 gezelter 312 contains
98    
99     function getSize(this) result (ne)
100     type(Vector), pointer :: this
101     integer :: ne
102     ne = this%elementCount
103     end function getSize
104    
105     function getElementAt(this, loc) result (id)
106     type(Vector), pointer :: this
107     integer, intent(in) :: loc
108     integer :: id
109     id = this%ElementData(loc)
110     end function getElementAt
111    
112     function getPropertyListSize(this) result (np)
113     type(Vector), pointer :: this
114     integer :: np
115     np = this%propertyCount
116     end function getPropertyListSize
117    
118     function getPropertyNameAt(this, loc) result (pn)
119     type(Vector), pointer :: this
120     integer, intent(in) :: loc
121     character(len=len(this%PropertyDescriptions)) :: pn
122     pn = this%PropertyDescriptions(loc)
123     end function getPropertyNameAt
124    
125 gezelter 313 function getFirstMatchingElement1i(this, MatchName, MatchValue) result (id)
126     type(Vector), pointer :: this
127     character(len=*), intent(in) :: MatchName
128     integer, intent(in) :: MatchValue
129     integer :: id
130     integer :: i, j
131    
132     id = 0
133    
134     do i = 1, this%propertyCount
135     if (this%PropertyDescriptions(i) == MatchName) then
136     do j = 1, this%elementCount
137     if (this%integerElementProperties(j, i) == MatchValue) then
138     id = j
139     return
140     endif
141     enddo
142     endif
143     enddo
144     return
145     end function getFirstMatchingElement1i
146    
147     function getFirstMatchingElement2i(this, MatchName1, MatchValue1, &
148     MatchName2, MatchValue2) result (id)
149     type(Vector), pointer :: this
150     character(len=*), intent(in) :: MatchName1, MatchName2
151     integer, intent(in) :: MatchValue1, MatchValue2
152     integer :: id
153     integer :: i, j, MatchID1, MatchID2
154     logical :: found1 = .false.
155     logical :: found2 = .false.
156    
157     id = 0
158     ! first figure out which properties we are using to do the match:
159    
160     do i = 1, this%propertyCount
161     if (this%PropertyDescriptions(i) == MatchName1) then
162     MatchID1 = i
163     found1 = .true.
164     endif
165     if (this%PropertyDescriptions(i) == MatchName2) then
166     MatchID2 = i
167     found2 = .true.
168     endif
169    
170     if (found1.and.found2) then
171     do j = 1, this%elementCount
172     if ((this%integerElementProperties(j, MatchID1) == MatchValue1) &
173     .and. &
174     (this%integerElementProperties(j, MatchID2) ==MatchValue2)) &
175     then
176     id = j
177     return
178     endif
179     enddo
180     endif
181     end do
182    
183     return
184     end function getFirstMatchingElement2i
185    
186 gezelter 316 function getFirstMatchingElement1l(this, MatchName, MatchValue) result (id)
187     type(Vector), pointer :: this
188     character(len=*), intent(in) :: MatchName
189     logical, intent(in) :: MatchValue
190     integer :: id
191     integer :: i, j
192    
193     id = 0
194 gezelter 313
195 gezelter 316 do i = 1, this%propertyCount
196     if (this%PropertyDescriptions(i) == MatchName) then
197     do j = 1, this%elementCount
198     if (this%logicalElementProperties(j, i) .eqv. MatchValue) then
199     id = j
200     return
201     endif
202     enddo
203     endif
204     enddo
205     return
206     end function getFirstMatchingElement1l
207    
208     function getFirstMatchingElement2l(this, MatchName1, MatchValue1, &
209     MatchName2, MatchValue2) result (id)
210     type(Vector), pointer :: this
211     character(len=*), intent(in) :: MatchName1, MatchName2
212     logical, intent(in) :: MatchValue1, MatchValue2
213     integer :: id
214     integer :: i, j, MatchID1, MatchID2
215     logical :: found1 = .false.
216     logical :: found2 = .false.
217    
218     id = 0
219     ! first figure out which properties we are using to do the match:
220    
221     do i = 1, this%propertyCount
222     if (this%PropertyDescriptions(i) == MatchName1) then
223     MatchID1 = i
224     found1 = .true.
225     endif
226     if (this%PropertyDescriptions(i) == MatchName2) then
227     MatchID2 = i
228     found2 = .true.
229     endif
230    
231     if (found1.and.found2) then
232     do j = 1, this%elementCount
233     if ((this%logicalElementProperties(j, MatchID1).eqv.MatchValue1) &
234     .and. &
235     (this%logicalElementProperties(j, MatchID2).eqv.MatchValue2)) &
236     then
237     id = j
238     return
239     endif
240     enddo
241     endif
242     end do
243    
244     return
245     end function getFirstMatchingElement2l
246    
247 gezelter 313 subroutine getMatchingElementList1i(this, MatchName, MatchValue, &
248     nMatches, MatchList)
249     type(Vector), pointer :: this
250     character(len=*), intent(in) :: MatchName
251     integer, intent(in) :: MatchValue
252     integer, intent(out) :: nMatches
253 gezelter 316 integer, pointer :: MatchList(:)
254 gezelter 313 integer :: i
255    
256     ! first figure out which property we are using to do the match:
257    
258     do i = 1, this%propertyCount
259     if (this%PropertyDescriptions(i) == MatchName) then
260 gezelter 316 call getAllMatches1i(this, i, MatchValue, nMatches, MatchList)
261 gezelter 313 return
262     endif
263     enddo
264     return
265     end subroutine getMatchingElementList1i
266    
267     subroutine getMatchingElementList2i(this, MatchName1, MatchValue1, &
268     MatchName2, MatchValue2, nMatches, MatchList)
269     type(Vector), pointer :: this
270     character(len=*), intent(in) :: MatchName1, MatchName2
271 gezelter 314 integer, intent(in) :: MatchValue1, MatchValue2
272     integer, intent(out) :: nMatches
273     integer, pointer :: MatchList(:)
274 gezelter 313 integer :: i, MatchID1, MatchID2
275     logical :: found1 = .false.
276     logical :: found2 = .false.
277    
278     ! first figure out which properties we are using to do the match:
279    
280     do i = 1, this%propertyCount
281     if (this%PropertyDescriptions(i) == MatchName1) then
282     MatchID1 = i
283     found1 = .true.
284     endif
285     if (this%PropertyDescriptions(i) == MatchName2) then
286     MatchID2 = i
287     found2 = .true.
288     endif
289    
290     if (found1.and.found2) then
291     call getAllMatches2i(this, MatchID1, MatchValue1, &
292     MatchID2, MatchValue2, nMatches, MatchList)
293     return
294     endif
295     enddo
296     return
297     end subroutine getMatchingElementList2i
298 gezelter 316
299     subroutine getMatchingElementList1l(this, MatchName, MatchValue, &
300     nMatches, MatchList)
301     type(Vector), pointer :: this
302     character(len=*), intent(in) :: MatchName
303     logical, intent(in) :: MatchValue
304     integer, intent(out) :: nMatches
305     integer, pointer :: MatchList(:)
306     integer :: i
307    
308     ! first figure out which property we are using to do the match:
309    
310     do i = 1, this%propertyCount
311     if (this%PropertyDescriptions(i) == MatchName) then
312     call getAllMatches1l(this, i, MatchValue, nMatches, MatchList)
313     return
314     endif
315     enddo
316     return
317     end subroutine getMatchingElementList1l
318    
319     subroutine getMatchingElementList2l(this, MatchName1, MatchValue1, &
320     MatchName2, MatchValue2, nMatches, MatchList)
321     type(Vector), pointer :: this
322     character(len=*), intent(in) :: MatchName1, MatchName2
323     logical, intent(in) :: MatchValue1, MatchValue2
324     integer, intent(out) :: nMatches
325     integer, pointer :: MatchList(:)
326     integer :: i, MatchID1, MatchID2
327     logical :: found1 = .false.
328     logical :: found2 = .false.
329 gezelter 313
330 gezelter 316 ! first figure out which properties we are using to do the match:
331    
332     do i = 1, this%propertyCount
333     if (this%PropertyDescriptions(i) == MatchName1) then
334     MatchID1 = i
335     found1 = .true.
336     endif
337     if (this%PropertyDescriptions(i) == MatchName2) then
338     MatchID2 = i
339     found2 = .true.
340     endif
341    
342     if (found1.and.found2) then
343     call getAllMatches2l(this, MatchID1, MatchValue1, &
344     MatchID2, MatchValue2, nMatches, MatchList)
345     return
346     endif
347     enddo
348     return
349     end subroutine getMatchingElementList2l
350    
351 gezelter 313 subroutine getAllMatches1i(this, MatchID, MatchValue, nMatches, MatchList)
352     type(Vector), pointer :: this
353     integer, intent(in) :: MatchID
354     integer, intent(in) :: MatchValue
355     integer, pointer :: MatchList(:)
356     integer, intent(out) :: nMatches
357     integer :: error, i
358    
359     allocate(MatchList(this%elementCount), stat=error)
360     if(error .ne. 0) write(*,*) 'Could not allocate MatchList!'
361    
362     nMatches = 0
363    
364     do i = 1, this%elementCount
365     if (this%integerElementProperties(i, MatchID) == MatchValue) then
366     nMatches = nMatches + 1
367     MatchList(nMatches) = i
368     endif
369     enddo
370     end subroutine getAllMatches1i
371    
372     subroutine getAllMatches2i(this, MatchID1, MatchValue1, &
373     MatchID2, MatchValue2, nMatches, MatchList)
374     type(Vector), pointer :: this
375     integer, intent(in) :: MatchID1, MatchID2
376     integer, intent(in) :: MatchValue1, MatchValue2
377     integer, pointer :: MatchList(:)
378     integer, intent(out) :: nMatches
379     integer :: error, i
380    
381     allocate(MatchList(this%elementCount), stat=error)
382     if(error .ne. 0) write(*,*) 'Could not allocate MatchList!'
383    
384     nMatches = 0
385    
386     do i = 1, this%elementCount
387     if ((this%integerElementProperties(i, MatchID1) == MatchValue1) .and. &
388     (this%integerElementProperties(i, MatchID2) == MatchValue2)) then
389     nMatches = nMatches + 1
390     MatchList(nMatches) = i
391     endif
392     enddo
393     end subroutine getAllMatches2i
394 gezelter 316
395     subroutine getAllMatches1l(this, MatchID, MatchValue, nMatches, MatchList)
396     type(Vector), pointer :: this
397     integer, intent(in) :: MatchID
398     logical, intent(in) :: MatchValue
399     integer, pointer :: MatchList(:)
400     integer, intent(out) :: nMatches
401     integer :: error, i
402 gezelter 313
403 gezelter 316 allocate(MatchList(this%elementCount), stat=error)
404     if(error .ne. 0) write(*,*) 'Could not allocate MatchList!'
405    
406     nMatches = 0
407    
408     do i = 1, this%elementCount
409     if (this%logicalElementProperties(i, MatchID).eqv.MatchValue) then
410     nMatches = nMatches + 1
411     MatchList(nMatches) = i
412     endif
413     enddo
414     end subroutine getAllMatches1l
415    
416     subroutine getAllMatches2l(this, MatchID1, MatchValue1, &
417     MatchID2, MatchValue2, nMatches, MatchList)
418     type(Vector), pointer :: this
419     integer, intent(in) :: MatchID1, MatchID2
420     logical, intent(in) :: MatchValue1, MatchValue2
421     integer, pointer :: MatchList(:)
422     integer, intent(out) :: nMatches
423     integer :: error, i
424    
425     allocate(MatchList(this%elementCount), stat=error)
426     if(error .ne. 0) write(*,*) 'Could not allocate MatchList!'
427    
428     nMatches = 0
429    
430     do i = 1, this%elementCount
431     if ((this%logicalElementProperties(i, MatchID1).eqv.MatchValue1) .and. &
432     (this%logicalElementProperties(i, MatchID2).eqv.MatchValue2)) then
433     nMatches = nMatches + 1
434     MatchList(nMatches) = i
435     endif
436     enddo
437     end subroutine getAllMatches2l
438    
439 gezelter 313
440 gezelter 312 subroutine getElementPropertyReal(this, id, PropName, pv)
441     type(Vector), pointer :: this
442     integer :: id, whichprop
443     character(len=*) :: PropName
444 gezelter 316 real( kind = 8 ) :: pv
445 gezelter 312
446     whichprop = getPropertyIndex(this, PropName)
447     if (whichprop .eq. 0 ) then
448     write(*,*) 'unknown property!'
449     pv = 0.0
450     else
451     if (this%PropertyDataType(whichprop) .ne. real_data_type) then
452     write(*,*) 'wrong data type for this property!'
453     pv = 0.0
454     else
455     pv = this%realElementProperties(id, whichprop)
456     endif
457     endif
458     end subroutine getElementPropertyReal
459    
460     subroutine getElementPropertyInt(this, id, PropName, pv)
461     type(Vector), pointer :: this
462     integer :: id, whichprop
463     character(len=*) :: PropName
464     integer :: pv
465    
466     whichprop = getPropertyIndex(this, PropName)
467     if (whichprop .eq. 0 ) then
468     write(*,*) 'unknown property!'
469     pv = 0
470     else
471     if (this%PropertyDataType(whichprop) .ne. integer_data_type) then
472     write(*,*) 'wrong data type for this property!'
473     pv = 0
474     else
475     pv = this%integerElementProperties(id, whichprop)
476     endif
477     endif
478     end subroutine getElementPropertyInt
479    
480     subroutine getElementPropertyLogical(this, id, PropName, pv)
481     type(Vector), pointer :: this
482     integer :: id, whichprop
483     character(len=*) :: PropName
484     logical :: pv
485    
486     whichprop = getPropertyIndex(this, PropName)
487     if (whichprop .eq. 0 ) then
488     write(*,*) 'unknown property!'
489     pv = .false.
490     else
491     if (this%PropertyDataType(whichprop) .ne. logical_data_type) then
492     write(*,*) 'wrong data type for this property!'
493     pv = .false.
494     else
495     pv = this%logicalElementProperties(id, whichprop)
496     endif
497     endif
498     end subroutine getElementPropertyLogical
499    
500     function getPropertyIndex(this, PropName) result (id)
501     type(Vector), pointer :: this
502     integer :: id, i
503     character(len=*) :: PropName
504    
505     do i = 1, this%propertyCount
506     if (this%PropertyDescriptions(i) == PropName) then
507     id = i
508     return
509     endif
510     enddo
511     id = 0
512     end function getPropertyIndex
513    
514     subroutine ensureCapacityHelper(this, minCapacity, minPropCap)
515     type(Vector), pointer :: this, that
516     integer, intent(in) :: minCapacity, minPropCap
517     integer :: oldCapacity, oldPropCap
518     integer :: newCapacity, newPropCap
519     logical :: resizeFlag = .false.
520    
521     oldCapacity = size(this%ElementData)
522     oldPropCap = size(this%PropertyDescriptions)
523    
524     if (minCapacity > oldCapacity) then
525     if (this%capacityIncrement .gt. 0) then
526     newCapacity = oldCapacity + this%capacityIncrement
527     else
528     newCapacity = oldCapacity * 2
529     endif
530     if (newCapacity .lt. minCapacity) then
531     newCapacity = minCapacity
532     endif
533     resizeFlag = .true.
534     endif
535    
536     if (minPropCap > oldPropCap) then
537     if (this%PropertyIncrement .gt. 0) then
538     newPropCap = oldPropCap + this%PropertyIncrement
539     else
540     newPropCap = oldPropCap * 2
541     endif
542     if (newPropCap .lt. minPropCap) then
543     newPropCap = minPropCap
544     endif
545     resizeFlag = .true.
546     endif
547    
548     if (resizeFlag) then
549     that = initialize(newCapacity, newPropCap, &
550     this%capacityIncrement, this%PropertyIncrement)
551     call copyAllData(this, that)
552     deallocate(this)
553     this => that
554     endif
555     end subroutine ensureCapacityHelper
556    
557     subroutine copyAllData(v1, v2)
558     type(Vector), pointer :: v1
559     type(Vector), pointer :: v2
560     integer :: i, j
561    
562     do i = 1, v1%elementCount
563     v2%elementData(i) = v1%elementData(i)
564     do j = 1, v1%propertyCount
565    
566     if (v1%PropertyDataType(j) .eq. integer_data_type) &
567     v2%integerElementProperties(i,j) = &
568     v1%integerElementProperties(i,j)
569    
570     if (v1%PropertyDataType(j) .eq. real_data_type) &
571     v2%realElementProperties(i,j) = v1%realElementProperties(i,j)
572    
573     if (v1%PropertyDataType(j) .eq. logical_data_type) &
574     v2%logicalElementProperties(i,j) = &
575     v1%logicalElementProperties(i,j)
576     enddo
577     enddo
578    
579     do j = 1, v1%propertyCount
580     v2%PropertyDescriptions(j) = v1%PropertyDescriptions(j)
581     v2%PropertyDataType(j) = v1%PropertyDataType(j)
582     enddo
583    
584     v2%elementCount = v1%elementCount
585     v2%propertyCount = v1%propertyCount
586    
587     return
588     end subroutine copyAllData
589    
590     function addElement(this) result (id)
591     type(Vector), pointer :: this
592     integer :: id
593     call ensureCapacityHelper(this, this%elementCount + 1, this%PropertyCount)
594     this%elementCount = this%elementCount + 1
595     this%elementData = this%elementCount
596     id = this%elementCount
597     end function addElement
598    
599     recursive subroutine setElementPropertyReal(this, id, PropName, PropValue)
600     type(Vector), pointer :: this
601     integer :: id, i
602     character(len=*), intent(in) :: PropName
603 gezelter 316 real( kind = 8 ), intent(in) :: PropValue
604 gezelter 312 logical :: foundit = .false.
605     ! first make sure that the PropName isn't in the list of known properties:
606     do i = 1, this%propertyCount
607     if (PropName == this%PropertyDescriptions(i)) then
608     foundit = .true.
609     this%realElementProperties(id,i) = PropValue
610     endif
611     enddo
612    
613     if (.not.foundit) then
614     call addPropertyToVector(this, PropName, real_data_type)
615     call setElementPropertyReal(this, id, PropName, PropValue)
616     endif
617     end subroutine setElementPropertyReal
618    
619     recursive subroutine setElementPropertyInt(this, id, PropName, PropValue)
620     type(Vector), pointer :: this
621     integer :: id, i
622     character(len=*), intent(in) :: PropName
623     integer, intent(in) :: PropValue
624     logical :: foundit = .false.
625     ! first make sure that the PropName isn't in the list of known properties:
626     do i = 1, this%propertyCount
627     if (PropName == this%PropertyDescriptions(i)) then
628     foundit = .true.
629     this%integerElementProperties(id,i) = PropValue
630     endif
631     enddo
632    
633     if (.not.foundit) then
634     call addPropertyToVector(this, PropName, integer_data_type)
635     call setElementPropertyInt(this, id, PropName, PropValue)
636     endif
637     end subroutine setElementPropertyInt
638    
639     recursive subroutine setElementPropertyLogical(this, id, PropName, PropValue)
640     type(Vector), pointer :: this
641     integer :: id, i
642     character(len=*), intent(in) :: PropName
643     logical, intent(in) :: PropValue
644     logical :: foundit = .false.
645     ! first make sure that the PropName isn't in the list of known properties:
646     do i = 1, this%propertyCount
647     if (PropName == this%PropertyDescriptions(i)) then
648     foundit = .true.
649     this%logicalElementProperties(id,i) = PropValue
650     endif
651     enddo
652    
653     if (.not.foundit) then
654     call addPropertyToVector(this, PropName, logical_data_type)
655     call setElementPropertyLogical(this, id, PropName, PropValue)
656     endif
657     end subroutine setElementPropertyLogical
658    
659     subroutine addPropertyToVector(this, PropName, data_type)
660     type(Vector), pointer :: this
661     character(len=*), intent(in) :: PropName
662     integer data_type
663     call ensureCapacityHelper(this, this%elementCount, this%propertyCount + 1)
664     this%propertyCount = this%propertyCount + 1
665     this%PropertyDescriptions(this%propertyCount) = PropName
666     this%PropertyDataType(this%propertyCount) = data_type
667     end subroutine addPropertyToVector
668    
669     function initialize_0i() result(this)
670     type(Vector), pointer :: this
671     nullify(this)
672     this = initialize_2i(10, 5)
673     end function initialize_0i
674    
675     function initialize_1i(nprop) result(this)
676     integer, intent(in) :: nprop
677     type(Vector), pointer :: this
678     nullify(this)
679     this = initialize_2i(10, nprop)
680     end function initialize_1i
681    
682     function initialize_2i(cap, nprop) result(this)
683     integer, intent(in) :: cap, nprop
684     type(Vector), pointer :: this
685     nullify(this)
686     this = initialize_4i(cap, nprop, 0, 0)
687     end function initialize_2i
688    
689     function initialize_3i(cap, nprop, capinc) result(this)
690     integer, intent(in) :: cap, nprop, capinc
691     type(Vector), pointer :: this
692     nullify(this)
693     this = initialize_4i(cap, nprop, capinc, 0)
694     end function initialize_3i
695    
696     function initialize_4i(cap, nprop, capinc, propinc) result(this)
697     integer, intent(in) :: cap, nprop, capinc, propinc
698     integer :: error
699     type(Vector), pointer :: this
700     nullify(this)
701 chuckv 315 if (cap < 0) then
702 gezelter 312 write(*,*) 'Bogus Capacity:', cap
703 gezelter 317 return
704 gezelter 312 endif
705 chuckv 315 if (nprop < 0) then
706 gezelter 312 write(*,*) 'Bogus Number of Properties:', nprop
707 gezelter 317 return
708 gezelter 312 endif
709    
710     allocate(this, stat=error)
711     if(error .ne. 0) write(*,*) 'Could not allocate Vector!'
712    
713     this%initialCapacity = cap
714     this%initialProperties = nprop
715     this%capacityIncrement = capinc
716     this%propertyIncrement = propinc
717    
718     allocate(this%elementData(this%initialCapacity), stat=error)
719 chuckv 315 if(error /= 0) write(*,*) 'Could not allocate elementData!'
720 gezelter 312
721     allocate(this%PropertyDescriptions(this%initialProperties), &
722     stat=error)
723 chuckv 315 if(error /= 0) write(*,*) 'Could not allocate PropertyDescriptions!'
724 gezelter 312
725     allocate(this%integerElementProperties(this%initialCapacity, &
726     this%initialProperties), stat=error)
727 chuckv 315 if(error /= 0) write(*,*) 'Could not allocate integerElementProperties!'
728 gezelter 312
729     allocate(this%realElementProperties(this%initialCapacity, &
730     this%initialProperties), stat=error)
731 chuckv 315 if(error /= 0) write(*,*) 'Could not allocate realElementProperties!'
732 gezelter 312
733     allocate(this%logicalElementProperties(this%initialCapacity, &
734     this%initialProperties), stat=error)
735     if(error .ne. 0) write(*,*) 'Could not allocate logicalElementProperties!'
736     end function initialize_4i
737    
738    
739    
740    
741    
742    
743     end module Vector_class