ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/vector_class.F90
(Generate patch)

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/vector_class.F90 (file contents):
Revision 317 by gezelter, Tue Mar 11 23:13:06 2003 UTC vs.
Revision 344 by chuckv, Fri Mar 14 18:34:39 2003 UTC

# Line 19 | Line 19
19   !! @author J. Daniel Gezelter
20   !! @author Charles F. Vardeman II
21   !! @author Matthew Meineke
22 < !! @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 $
22 > !! @version $Id: vector_class.F90,v 1.7 2003-03-14 18:34:39 chuckv Exp $, $Date: 2003-03-14 18:34:39 $, $Name: not supported by cvs2svn $, $Revision: 1.7 $
23  
24   module Vector_class
25    
# Line 445 | Line 445 | contains
445      
446      whichprop = getPropertyIndex(this, PropName)
447      if (whichprop .eq. 0 ) then
448 <       write(*,*) 'unknown property!'
448 >       write(*,*) 'unknown property! ', PropName
449         pv = 0.0
450      else
451         if (this%PropertyDataType(whichprop) .ne. real_data_type) then
452 <          write(*,*) 'wrong data type for this property!'
452 >          write(*,*) 'Property! ', PropName, " is not real data type."
453            pv = 0.0
454         else
455            pv = this%realElementProperties(id, whichprop)
# Line 465 | Line 465 | contains
465      
466      whichprop = getPropertyIndex(this, PropName)
467      if (whichprop .eq. 0 ) then
468 <       write(*,*) 'unknown property!'
468 >       write(*,*) 'unknown property! ', PropName
469         pv = 0
470      else
471         if (this%PropertyDataType(whichprop) .ne. integer_data_type) then
472 <          write(*,*) 'wrong data type for this property!'
472 >          write(*,*) 'Property! ', PropName, " is not integer data type."
473            pv = 0
474         else
475            pv = this%integerElementProperties(id, whichprop)
# Line 485 | Line 485 | contains
485      
486      whichprop = getPropertyIndex(this, PropName)
487      if (whichprop .eq. 0 ) then
488 <       write(*,*) 'unknown property!'
488 >       write(*,*) 'unknown property! ', PropName
489         pv = .false.
490      else
491         if (this%PropertyDataType(whichprop) .ne. logical_data_type) then
492 <          write(*,*) 'wrong data type for this property!'
492 >          write(*,*) 'Property! ', PropName, " is not logical data type."
493            pv = .false.
494         else
495            pv = this%logicalElementProperties(id, whichprop)
# Line 501 | Line 501 | contains
501      type(Vector), pointer :: this
502      integer :: id, i
503      character(len=*) :: PropName
504 <    
504 >
505      do i = 1, this%propertyCount
506         if (this%PropertyDescriptions(i) == PropName) then
507            id = i
# Line 518 | Line 518 | contains
518      integer :: newCapacity, newPropCap
519      logical :: resizeFlag = .false.
520  
521    oldCapacity = size(this%ElementData)
522    oldPropCap = size(this%PropertyDescriptions)
521  
522 + !  first time: allocate a new vector with default size
523 +    if (.not. associated(this)) then
524 +       this => initialize()
525 +    endif
526 +
527 +    oldCapacity = size(this%ElementData)
528 +    oldPropCap  = size(this%PropertyDescriptions)
529 +
530 +    
531      if (minCapacity > oldCapacity) then
532         if (this%capacityIncrement .gt. 0) then
533            newCapacity = oldCapacity + this%capacityIncrement
# Line 532 | Line 539 | contains
539         endif
540         resizeFlag = .true.
541      endif
542 <
542 >    
543 > !!! newCapacity is not set.....
544      if (minPropCap > oldPropCap) then
545         if (this%PropertyIncrement .gt. 0) then
546            newPropCap = oldPropCap + this%PropertyIncrement
# Line 544 | Line 552 | contains
552         endif
553         resizeFlag = .true.
554      endif
555 <      
555 >    
556      if (resizeFlag) then
557 <       that = initialize(newCapacity, newPropCap, &
557 >       write(*,*) "Resizing to new capacity: ",newCapacity
558 >       that => initialize(newCapacity, newPropCap, &
559              this%capacityIncrement, this%PropertyIncrement)      
560         call copyAllData(this, that)
561         deallocate(this)
# Line 590 | Line 599 | contains
599    function addElement(this) result (id)
600      type(Vector), pointer :: this
601      integer :: id
602 <    call ensureCapacityHelper(this, this%elementCount + 1, this%PropertyCount)
603 <    this%elementCount = this%elementCount + 1
604 <    this%elementData = this%elementCount
605 <    id = this%elementCount
602 >    integer :: error
603 >
604 >    if (.not. associated(this)) then
605 >       call ensureCapacityHelper(this,1,0)
606 >    else
607 >       call ensureCapacityHelper(this, this%elementCount + 1, this%PropertyCount)
608 >    end if
609 >
610 >       this%elementCount = this%elementCount + 1
611 >       this%elementData = this%elementCount
612 >       id = this%elementCount
613 >
614 >
615    end function addElement
616  
617    recursive subroutine setElementPropertyReal(this, id, PropName, PropValue)
# Line 601 | Line 619 | contains
619      integer :: id, i
620      character(len=*), intent(in) :: PropName
621      real( kind = 8 ), intent(in) :: PropValue
622 <    logical :: foundit = .false.
622 >    logical :: foundit
623 >    
624 >    foundit = .false.
625 >
626      ! first make sure that the PropName isn't in the list of known properties:
627 +
628      do i = 1, this%propertyCount
629         if (PropName == this%PropertyDescriptions(i)) then
630            foundit = .true.
631            this%realElementProperties(id,i) = PropValue
632         endif
633      enddo
634 <    
634 >
635      if (.not.foundit) then
636 <       call addPropertyToVector(this, PropName, real_data_type)
637 <       call setElementPropertyReal(this, id, PropName, PropValue)
636 >         call addPropertyToVector(this, PropName, real_data_type)
637 >         call setElementPropertyReal(this, id, PropName, PropValue)
638      endif
639    end subroutine setElementPropertyReal
640  
# Line 621 | Line 643 | contains
643      integer :: id, i
644      character(len=*), intent(in) :: PropName
645      integer, intent(in) :: PropValue
646 <    logical :: foundit = .false.
646 >    logical :: foundit
647 >
648 >    foundit = .false.
649      ! first make sure that the PropName isn't in the list of known properties:
650      do i = 1, this%propertyCount
651         if (PropName == this%PropertyDescriptions(i)) then
# Line 641 | Line 665 | contains
665      integer :: id, i
666      character(len=*), intent(in) :: PropName
667      logical, intent(in) :: PropValue
668 <    logical :: foundit = .false.
668 >    logical :: foundit
669 >
670 >    foundit = .false.
671      ! first make sure that the PropName isn't in the list of known properties:
672      do i = 1, this%propertyCount
673         if (PropName == this%PropertyDescriptions(i)) then
# Line 660 | Line 686 | contains
686      type(Vector), pointer :: this
687      character(len=*), intent(in) :: PropName
688      integer data_type
689 <    call ensureCapacityHelper(this, this%elementCount, this%propertyCount + 1)
690 <    this%propertyCount = this%propertyCount + 1
691 <    this%PropertyDescriptions(this%propertyCount) = PropName
692 <    this%PropertyDataType(this%propertyCount) = data_type
693 <  end subroutine addPropertyToVector
689 >    
690 >     call ensureCapacityHelper(this, this%elementCount, this%propertyCount + 1)
691 >     this%propertyCount = this%propertyCount + 1
692 >     this%PropertyDescriptions(this%propertyCount) = PropName
693 >     this%PropertyDataType(this%propertyCount) = data_type
694 >   end subroutine addPropertyToVector
695    
696    function initialize_0i() result(this)
697      type(Vector), pointer :: this
698 <    nullify(this)
672 <    this = initialize_2i(10, 5)
698 >    this => initialize_2i(10, 5)
699    end function initialize_0i
700  
701    function initialize_1i(nprop) result(this)
702      integer, intent(in) :: nprop
703      type(Vector), pointer :: this
704 <    nullify(this)
679 <    this = initialize_2i(10, nprop)
704 >    this => initialize_2i(10, nprop)
705    end function initialize_1i
706  
707    function initialize_2i(cap, nprop) result(this)
708      integer, intent(in) :: cap, nprop
709      type(Vector), pointer :: this
710 <    nullify(this)
686 <    this = initialize_4i(cap, nprop, 0, 0)
710 >    this => initialize_4i(cap, nprop, 0, 0)
711    end function initialize_2i
712  
713    function initialize_3i(cap, nprop, capinc) result(this)
714      integer, intent(in) :: cap, nprop, capinc
715      type(Vector), pointer :: this
716 <    nullify(this)
693 <    this = initialize_4i(cap, nprop, capinc, 0)
716 >    this => initialize_4i(cap, nprop, capinc, 0)
717    end function initialize_3i
718  
719    function initialize_4i(cap, nprop, capinc, propinc) result(this)
720      integer, intent(in) :: cap, nprop, capinc, propinc
721      integer :: error
722      type(Vector), pointer :: this
723 +
724      nullify(this)
725 <    if (cap < 0) then
725 >
726 >     if (cap < 0) then
727         write(*,*) 'Bogus Capacity:', cap
728         return
729      endif
# Line 706 | Line 731 | contains
731         write(*,*) 'Bogus Number of Properties:', nprop
732         return
733      endif
734 <
735 <    allocate(this, stat=error)
736 <    if(error .ne. 0) write(*,*) 'Could not allocate Vector!'
737 <
738 <    this%initialCapacity = cap
739 <    this%initialProperties = nprop
740 <    this%capacityIncrement = capinc
716 <    this%propertyIncrement = propinc
717 <
734 >    
735 >    allocate(this,stat=error)
736 >    if ( error /= 0 ) then
737 >       write(*,*) 'Could not allocate Vector!'
738 >       return
739 >    end if
740 >
741      allocate(this%elementData(this%initialCapacity), stat=error)
742      if(error /= 0) write(*,*) 'Could not allocate elementData!'
743 <    
743 >
744 >
745      allocate(this%PropertyDescriptions(this%initialProperties), &
746           stat=error)
747      if(error /=  0) write(*,*) 'Could not allocate PropertyDescriptions!'
748  
749 +    allocate(this%PropertyDataType(this%initialProperties), &
750 +         stat=error)
751 +    if(error /=  0) write(*,*) 'Could not allocate PropertyDataType!'
752 +    
753      allocate(this%integerElementProperties(this%initialCapacity, &
754           this%initialProperties), stat=error)
755      if(error /= 0) write(*,*) 'Could not allocate integerElementProperties!'
# Line 733 | Line 761 | contains
761      allocate(this%logicalElementProperties(this%initialCapacity, &
762           this%initialProperties), stat=error)
763      if(error .ne. 0) write(*,*) 'Could not allocate logicalElementProperties!'
736  end function initialize_4i
737    
764  
739    
765  
766  
767 +
768 +    this%initialCapacity = cap
769 +    this%initialProperties = nprop
770 +    this%capacityIncrement = capinc
771 +    this%propertyIncrement = propinc
772  
773 +
774 +  end function initialize_4i
775 +    
776 +  
777 +  
778   end module Vector_class

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines