1 |
+ |
! 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 |
+ |
!! it contains components that can be accessed using an integer index. However, |
7 |
+ |
!! the size of a Vector can grow as needed to accommodate |
8 |
+ |
!! adding and removing items after the Vector has been created. |
9 |
+ |
!! Each vector tries to optimize storage management by maintaining a capacity and a |
10 |
+ |
!! capacityIncrement. The capacity is always at least as large as the vector size; |
11 |
+ |
!! it is usually larger because as components are added to the vector, |
12 |
+ |
!! the vector's storage increases in chunks the size of capacityIncrement. |
13 |
+ |
!! An application can increase the capacity of a vector before inserting a large number |
14 |
+ |
!! of components; this reduces the amount of incremental reallocation. |
15 |
+ |
!! |
16 |
+ |
!! |
17 |
+ |
!! @author J. Daniel Gezelter |
18 |
+ |
!! @author Charles F. Vardeman II |
19 |
+ |
!! @author Matthew Meineke |
20 |
+ |
!! @version $Id: vector_class.F90,v 1.4 2003-03-11 20:15:18 chuckv Exp $, $Date: 2003-03-11 20:15:18 $, $Name: not supported by cvs2svn $, $Revision: 1.4 $ |
21 |
+ |
|
22 |
|
module Vector_class |
23 |
|
|
24 |
|
implicit NONE |
39 |
|
integer, parameter :: integer_data_type = 2 |
40 |
|
integer, parameter :: real_data_type = 3 |
41 |
|
|
42 |
+ |
integer :: dp = selected_real_kind(8) |
43 |
+ |
!! |
44 |
|
type, public :: Vector |
45 |
|
PRIVATE |
46 |
|
integer :: initialCapacity = 10 |
51 |
|
integer :: PropertyIncrement = 0 |
52 |
|
integer :: propertyCount = 0 |
53 |
|
|
54 |
< |
integer, pointer :: ElementData(:) |
55 |
< |
character(len=100), pointer :: PropertyDescriptions(:) |
56 |
< |
integer, pointer :: PropertyDataType(:) |
57 |
< |
real(kind = 8), pointer :: realElementProperties(:,:) |
58 |
< |
integer, pointer :: integerElementProperties(:,:) |
59 |
< |
logical, pointer :: logicalElementProperties(:,:) |
54 |
> |
integer, pointer :: ElementData(:) => null() |
55 |
> |
character(len=100), pointer :: PropertyDescriptions(:) => null() |
56 |
> |
integer, pointer :: PropertyDataType(:) => null() |
57 |
> |
real(kind = dp), pointer :: realElementProperties(:,:) => null() |
58 |
> |
integer, pointer :: integerElementProperties(:,:) => null() |
59 |
> |
logical, pointer :: logicalElementProperties(:,:) => null() |
60 |
|
end type Vector |
61 |
|
|
62 |
+ |
!! Initialize vector |
63 |
|
interface initialize |
64 |
|
module procedure initialize_0i |
65 |
|
module procedure initialize_1i |
280 |
|
type(Vector), pointer :: this |
281 |
|
integer :: id, whichprop |
282 |
|
character(len=*) :: PropName |
283 |
< |
real(kind=8) :: pv |
283 |
> |
real( kind = dp ) :: pv |
284 |
|
|
285 |
|
whichprop = getPropertyIndex(this, PropName) |
286 |
|
if (whichprop .eq. 0 ) then |
439 |
|
type(Vector), pointer :: this |
440 |
|
integer :: id, i |
441 |
|
character(len=*), intent(in) :: PropName |
442 |
< |
real( kind=8 ), intent(in) :: PropValue |
442 |
> |
real( kind = dp ), intent(in) :: PropValue |
443 |
|
logical :: foundit = .false. |
444 |
|
! first make sure that the PropName isn't in the list of known properties: |
445 |
|
do i = 1, this%propertyCount |
537 |
|
integer :: error |
538 |
|
type(Vector), pointer :: this |
539 |
|
nullify(this) |
540 |
< |
if (cap .lt. 0) then |
540 |
> |
if (cap < 0) then |
541 |
|
write(*,*) 'Bogus Capacity:', cap |
542 |
|
stop |
543 |
|
endif |
544 |
< |
if (nprop .lt. 0) then |
544 |
> |
if (nprop < 0) then |
545 |
|
write(*,*) 'Bogus Number of Properties:', nprop |
546 |
|
stop |
547 |
|
endif |
555 |
|
this%propertyIncrement = propinc |
556 |
|
|
557 |
|
allocate(this%elementData(this%initialCapacity), stat=error) |
558 |
< |
if(error .ne. 0) write(*,*) 'Could not allocate elementData!' |
558 |
> |
if(error /= 0) write(*,*) 'Could not allocate elementData!' |
559 |
|
|
560 |
|
allocate(this%PropertyDescriptions(this%initialProperties), & |
561 |
|
stat=error) |
562 |
< |
if(error .ne. 0) write(*,*) 'Could not allocate PropertyDescriptions!' |
562 |
> |
if(error /= 0) write(*,*) 'Could not allocate PropertyDescriptions!' |
563 |
|
|
564 |
|
allocate(this%integerElementProperties(this%initialCapacity, & |
565 |
|
this%initialProperties), stat=error) |
566 |
< |
if(error .ne. 0) write(*,*) 'Could not allocate integerElementProperties!' |
566 |
> |
if(error /= 0) write(*,*) 'Could not allocate integerElementProperties!' |
567 |
|
|
568 |
|
allocate(this%realElementProperties(this%initialCapacity, & |
569 |
|
this%initialProperties), stat=error) |
570 |
< |
if(error .ne. 0) write(*,*) 'Could not allocate realElementProperties!' |
570 |
> |
if(error /= 0) write(*,*) 'Could not allocate realElementProperties!' |
571 |
|
|
572 |
|
allocate(this%logicalElementProperties(this%initialCapacity, & |
573 |
|
this%initialProperties), stat=error) |