TABLE OF CONTENTS
- ABINIT/m_Vector
- ABINIT/m_Vector/Vector_clear
- ABINIT/m_Vector/Vector_destroy
- ABINIT/m_Vector/Vector_enlarge
- ABINIT/m_Vector/Vector_init
- ABINIT/m_Vector/Vector_print
- ABINIT/m_Vector/Vector_pushBack
- ABINIT/m_Vector/Vector_setSize
- m_Vector/Vector
ABINIT/m_Vector [ Modules ]
NAME
m_Vector
FUNCTION
Manage a double precision vector
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
NOTES
SOURCE
22 #include "defs.h" 23 MODULE m_Vector 24 USE m_Global 25 IMPLICIT NONE
ABINIT/m_Vector/Vector_clear [ Functions ]
NAME
Vector_clear
FUNCTION
Clear vector
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
276 SUBROUTINE Vector_clear(this) 277 278 !Arguments ------------------------------------ 279 TYPE(Vector), INTENT(INOUT) :: this 280 this%tail = 0 281 END SUBROUTINE Vector_clear
ABINIT/m_Vector/Vector_destroy [ Functions ]
NAME
Vector_destroy
FUNCTION
Destroy vector
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
356 SUBROUTINE Vector_destroy(this) 357 358 !Arguments ------------------------------------ 359 TYPE(Vector), INTENT(INOUT) :: this 360 361 FREEIF(this%vec) 362 363 this%tail = 0 364 this%size = 0 365 END SUBROUTINE Vector_destroy
ABINIT/m_Vector/Vector_enlarge [ Functions ]
NAME
Vector_enlarge
FUNCTION
enlarge memory size
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector size=memory size to add
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
177 SUBROUTINE Vector_enlarge(this, size) 178 179 !Arguments ------------------------------------ 180 TYPE(Vector) , INTENT(INOUT) :: this 181 INTEGER , INTENT(IN ) :: size 182 !Local variables ------------------------------ 183 INTEGER :: width 184 INTEGER :: tail 185 DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:) :: thistemp 186 INTEGER :: size_val 187 188 IF ( ALLOCATED(this%vec) ) THEN 189 FREEIF(thistemp) 190 width = this%size 191 tail = this%tail 192 size_val = size 193 MALLOC(thistemp,(1:tail)) 194 thistemp(1:tail) = this%vec(1:tail) 195 FREE(this%vec) 196 this%size = width + size_val 197 MALLOC(this%vec,(1:this%size)) 198 this%vec(1:tail) = thistemp(1:tail) 199 FREE(thistemp) 200 ELSE 201 CALL Vector_init(this, Global_SIZE) 202 END IF 203 END SUBROUTINE Vector_enlarge
ABINIT/m_Vector/Vector_init [ Functions ]
NAME
Vector_init
FUNCTION
initialize
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector size=size of initialization
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
89 SUBROUTINE Vector_init(this, size) 90 91 !Arguments ------------------------------------ 92 TYPE(Vector) , INTENT(INOUT) :: this 93 INTEGER, OPTIONAL, INTENT(IN ) :: size 94 !Local variables ------------------------------ 95 INTEGER :: size_val 96 97 size_val = Global_SIZE 98 IF ( PRESENT(size) ) size_val = size 99 this%size = size_val 100 FREEIF(this%vec) 101 MALLOC(this%vec,(1:size_val)) 102 this%tail = 0 103 this%vec = 0.d0 104 END SUBROUTINE Vector_init
ABINIT/m_Vector/Vector_print [ Functions ]
NAME
Vector_print
FUNCTION
print vector
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector ostream=file stream
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
309 SUBROUTINE Vector_print(this,ostream) 310 311 !Arguments ------------------------------------ 312 TYPE(Vector), INTENT(IN) :: this 313 INTEGER, OPTIONAL, INTENT(IN) :: ostream 314 !Local variables ------------------------------ 315 INTEGER :: ostream_val 316 INTEGER :: it1 317 CHARACTER(LEN=4 ) :: size 318 CHARACTER(LEN=15) :: string 319 320 ostream_val = 6 321 IF ( PRESENT(ostream) ) ostream_val = ostream 322 WRITE(size,'(I4)') this%tail 323 WRITE(ostream_val,'(A)') "(" 324 string ='(1x,1ES10.2)' 325 DO it1 = 1, this%tail 326 WRITE(ostream_val,string) this%vec(it1) 327 END DO 328 WRITE(ostream_val,'(A)') ")" 329 END SUBROUTINE Vector_print
ABINIT/m_Vector/Vector_pushBack [ Functions ]
NAME
Vector_pushBack
FUNCTION
push an element at the end
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector value=value to add
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
231 SUBROUTINE Vector_pushBack(this, value) 232 233 !Arguments ------------------------------------ 234 TYPE(Vector) , INTENT(INOUT) :: this 235 DOUBLE PRECISION, INTENT(IN ) :: value 236 !Local variables ------------------------------ 237 INTEGER :: tail 238 239 IF ( this%size .EQ. 0 ) THEN 240 CALL Vector_init(this, Global_SIZE) 241 END IF 242 tail = this%tail 243 tail = tail + 1 244 IF ( tail .GT. this%size ) THEN 245 CALL Vector_enlarge(this,Global_SIZE) 246 END IF 247 this%vec(tail) = value 248 this%tail = tail 249 END SUBROUTINE Vector_pushBack
ABINIT/m_Vector/Vector_setSize [ Functions ]
NAME
Vector_setSize
FUNCTION
impose size
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
INPUTS
this=vector new_tail=new_size
OUTPUT
SIDE EFFECTS
NOTES
SOURCE
132 SUBROUTINE Vector_setSize(this,new_tail) 133 134 !Arguments ------------------------------------ 135 TYPE(Vector), INTENT(INOUT) :: this 136 INTEGER , INTENT(IN ) :: new_tail 137 !Local variables ------------------------------ 138 INTEGER :: size 139 140 IF ( .NOT. ALLOCATED(this%vec) ) THEN 141 CALL Vector_init(this,new_tail) 142 ELSE 143 size = this%size 144 IF( new_tail .GT. size ) THEN 145 CALL Vector_enlarge(this,MAX(Global_SIZE,new_tail-size)) 146 END IF 147 END IF 148 this%tail = new_tail 149 END SUBROUTINE Vector_setSize
m_Vector/Vector [ Types ]
[ Top ] [ m_Vector ] [ Types ]
NAME
Vector
FUNCTION
This structured datatype contains the necessary data
COPYRIGHT
Copyright (C) 2013-2024 ABINIT group (J. Bieder) This file is distributed under the terms of the GNU General Public License, see ~abinit/COPYING or http://www.gnu.org/copyleft/gpl.txt .
SOURCE
46 TYPE, PUBLIC :: Vector 47 INTEGER :: size 48 INTEGER :: tail 49 DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:) :: vec 50 END TYPE Vector