libsim Versione 7.2.1

◆ arrayof_doubleprecision_append()

integer function, private arrayof_doubleprecision_append ( type(arrayof_doubleprecision) this,
doubleprecision, intent(in) content )
private

Quick method to append an element to the array.

The return value is the position at which the element has been appended.

Parametri
thisarray object to extend
[in]contentobject of TYPE DOUBLEPRECISION to append

Definizione alla linea 6135 del file array_utilities.F90.

6136! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
6137! authors:
6138! Davide Cesari <dcesari@arpa.emr.it>
6139! Paolo Patruno <ppatruno@arpa.emr.it>
6140
6141! This program is free software; you can redistribute it and/or
6142! modify it under the terms of the GNU General Public License as
6143! published by the Free Software Foundation; either version 2 of
6144! the License, or (at your option) any later version.
6145
6146! This program is distributed in the hope that it will be useful,
6147! but WITHOUT ANY WARRANTY; without even the implied warranty of
6148! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6149! GNU General Public License for more details.
6150
6151! You should have received a copy of the GNU General Public License
6152! along with this program. If not, see <http://www.gnu.org/licenses/>.
6153
6154
6155
6158#include "config.h"
6159MODULE array_utilities
6160
6161IMPLICIT NONE
6162
6163! la routine per i char non puo' essere sviluppata in macro perche` si deve scrivere diversa
6164!cosi' esiste la function count_distinctc (senza _ ) e la subroutine pack_distinctc qui ivi scritte
6165
6166#undef VOL7D_POLY_TYPE_AUTO
6167
6168#undef VOL7D_POLY_TYPE
6169#undef VOL7D_POLY_TYPES
6170#define VOL7D_POLY_TYPE INTEGER
6171#define VOL7D_POLY_TYPES _i
6172#define ENABLE_SORT
6173#include "array_utilities_pre.F90"
6174#undef ENABLE_SORT
6175
6176#undef VOL7D_POLY_TYPE
6177#undef VOL7D_POLY_TYPES
6178#define VOL7D_POLY_TYPE REAL
6179#define VOL7D_POLY_TYPES _r
6180#define ENABLE_SORT
6181#include "array_utilities_pre.F90"
6182#undef ENABLE_SORT
6183
6184#undef VOL7D_POLY_TYPE
6185#undef VOL7D_POLY_TYPES
6186#define VOL7D_POLY_TYPE DOUBLEPRECISION
6187#define VOL7D_POLY_TYPES _d
6188#define ENABLE_SORT
6189#include "array_utilities_pre.F90"
6190#undef ENABLE_SORT
6191
6192#define VOL7D_NO_PACK
6193#undef VOL7D_POLY_TYPE
6194#undef VOL7D_POLY_TYPES
6195#define VOL7D_POLY_TYPE CHARACTER(len=*)
6196#define VOL7D_POLY_TYPE_AUTO(var) CHARACTER(len=LEN(var))
6197#define VOL7D_POLY_TYPES _c
6198#define ENABLE_SORT
6199#include "array_utilities_pre.F90"
6200#undef VOL7D_POLY_TYPE_AUTO
6201#undef ENABLE_SORT
6202
6203
6204#define ARRAYOF_ORIGEQ 1
6205
6206#define ARRAYOF_ORIGTYPE INTEGER
6207#define ARRAYOF_TYPE arrayof_integer
6208#include "arrayof_pre.F90"
6209
6210#undef ARRAYOF_ORIGTYPE
6211#undef ARRAYOF_TYPE
6212#define ARRAYOF_ORIGTYPE REAL
6213#define ARRAYOF_TYPE arrayof_real
6214#include "arrayof_pre.F90"
6215
6216#undef ARRAYOF_ORIGTYPE
6217#undef ARRAYOF_TYPE
6218#define ARRAYOF_ORIGTYPE DOUBLEPRECISION
6219#define ARRAYOF_TYPE arrayof_doubleprecision
6220#include "arrayof_pre.F90"
6221
6222#undef ARRAYOF_ORIGEQ
6223
6224#undef ARRAYOF_ORIGTYPE
6225#undef ARRAYOF_TYPE
6226#define ARRAYOF_ORIGTYPE LOGICAL
6227#define ARRAYOF_TYPE arrayof_logical
6228#include "arrayof_pre.F90"
6229
6230PRIVATE
6231! from arrayof
6233PUBLIC insert_unique, append_unique
6234
6235PUBLIC sort, index, index_c, &
6236 count_distinct_sorted, pack_distinct_sorted, &
6237 count_distinct, pack_distinct, count_and_pack_distinct, &
6238 map_distinct, map_inv_distinct, &
6239 firsttrue, lasttrue, pack_distinct_c, map
6240
6241CONTAINS
6242
6243
6246FUNCTION firsttrue(v) RESULT(i)
6247LOGICAL,INTENT(in) :: v(:)
6248INTEGER :: i
6249
6250DO i = 1, SIZE(v)
6251 IF (v(i)) RETURN
6252ENDDO
6253i = 0
6254
6255END FUNCTION firsttrue
6256
6257
6260FUNCTION lasttrue(v) RESULT(i)
6261LOGICAL,INTENT(in) :: v(:)
6262INTEGER :: i
6263
6264DO i = SIZE(v), 1, -1
6265 IF (v(i)) RETURN
6266ENDDO
6267
6268END FUNCTION lasttrue
6269
6270
6271! Definisce le funzioni count_distinct(_sorted) e pack_distinct(_sorted)
6272#undef VOL7D_POLY_TYPE_AUTO
6273#undef VOL7D_NO_PACK
6274
6275#undef VOL7D_POLY_TYPE
6276#undef VOL7D_POLY_TYPES
6277#define VOL7D_POLY_TYPE INTEGER
6278#define VOL7D_POLY_TYPES _i
6279#define ENABLE_SORT
6280#include "array_utilities_inc.F90"
6281#undef ENABLE_SORT
6282
6283#undef VOL7D_POLY_TYPE
6284#undef VOL7D_POLY_TYPES
6285#define VOL7D_POLY_TYPE REAL
6286#define VOL7D_POLY_TYPES _r
6287#define ENABLE_SORT
6288#include "array_utilities_inc.F90"
6289#undef ENABLE_SORT
6290
6291#undef VOL7D_POLY_TYPE
6292#undef VOL7D_POLY_TYPES
6293#define VOL7D_POLY_TYPE DOUBLEPRECISION
6294#define VOL7D_POLY_TYPES _d
6295#define ENABLE_SORT
6296#include "array_utilities_inc.F90"
6297#undef ENABLE_SORT
6298
6299#define VOL7D_NO_PACK
6300#undef VOL7D_POLY_TYPE
6301#undef VOL7D_POLY_TYPES
6302#define VOL7D_POLY_TYPE CHARACTER(len=*)
6303#define VOL7D_POLY_TYPE_AUTO(var) CHARACTER(len=LEN(var))
6304#define VOL7D_POLY_TYPES _c
6305#define ENABLE_SORT
6306#include "array_utilities_inc.F90"
6307#undef VOL7D_POLY_TYPE_AUTO
6308#undef ENABLE_SORT
6309
6310SUBROUTINE pack_distinct_c(vect, pack_distinct, mask, back) !RESULT(pack_distinct)
6311CHARACTER(len=*),INTENT(in) :: vect(:)
6312LOGICAL,INTENT(in),OPTIONAL :: mask(:), back
6313CHARACTER(len=LEN(vect)) :: pack_distinct(:)
6314
6315INTEGER :: count_distinct
6316INTEGER :: i, j, dim
6317LOGICAL :: lback
6318
6319dim = SIZE(pack_distinct)
6320IF (PRESENT(back)) THEN
6321 lback = back
6322ELSE
6323 lback = .false.
6324ENDIF
6325count_distinct = 0
6326
6327IF (PRESENT (mask)) THEN
6328 IF (lback) THEN
6329 vectm1: DO i = 1, SIZE(vect)
6330 IF (.NOT.mask(i)) cycle vectm1
6331! DO j = i-1, 1, -1
6332! IF (vect(j) == vect(i)) CYCLE vectm1
6333 DO j = count_distinct, 1, -1
6334 IF (pack_distinct(j) == vect(i)) cycle vectm1
6335 ENDDO
6336 count_distinct = count_distinct + 1
6337 IF (count_distinct > dim) EXIT
6338 pack_distinct(count_distinct) = vect(i)
6339 ENDDO vectm1
6340 ELSE
6341 vectm2: DO i = 1, SIZE(vect)
6342 IF (.NOT.mask(i)) cycle vectm2
6343! DO j = 1, i-1
6344! IF (vect(j) == vect(i)) CYCLE vectm2
6345 DO j = 1, count_distinct
6346 IF (pack_distinct(j) == vect(i)) cycle vectm2
6347 ENDDO
6348 count_distinct = count_distinct + 1
6349 IF (count_distinct > dim) EXIT
6350 pack_distinct(count_distinct) = vect(i)
6351 ENDDO vectm2
6352 ENDIF
6353ELSE
6354 IF (lback) THEN
6355 vect1: DO i = 1, SIZE(vect)
6356! DO j = i-1, 1, -1
6357! IF (vect(j) == vect(i)) CYCLE vect1
6358 DO j = count_distinct, 1, -1
6359 IF (pack_distinct(j) == vect(i)) cycle vect1
6360 ENDDO
6361 count_distinct = count_distinct + 1
6362 IF (count_distinct > dim) EXIT
6363 pack_distinct(count_distinct) = vect(i)
6364 ENDDO vect1
6365 ELSE
6366 vect2: DO i = 1, SIZE(vect)
6367! DO j = 1, i-1
6368! IF (vect(j) == vect(i)) CYCLE vect2
6369 DO j = 1, count_distinct
6370 IF (pack_distinct(j) == vect(i)) cycle vect2
6371 ENDDO
6372 count_distinct = count_distinct + 1
6373 IF (count_distinct > dim) EXIT
6374 pack_distinct(count_distinct) = vect(i)
6375 ENDDO vect2
6376 ENDIF
6377ENDIF
6378
6379END SUBROUTINE pack_distinct_c
6380
6382FUNCTION map(mask) RESULT(mapidx)
6383LOGICAL,INTENT(in) :: mask(:)
6384INTEGER :: mapidx(count(mask))
6385
6386INTEGER :: i,j
6387
6388j = 0
6389DO i=1, SIZE(mask)
6390 j = j + 1
6391 IF (mask(i)) mapidx(j)=i
6392ENDDO
6393
6394END FUNCTION map
6395
6396#define ARRAYOF_ORIGEQ 1
6397
6398#undef ARRAYOF_ORIGTYPE
6399#undef ARRAYOF_TYPE
6400#define ARRAYOF_ORIGTYPE INTEGER
6401#define ARRAYOF_TYPE arrayof_integer
6402#include "arrayof_post.F90"
6403
6404#undef ARRAYOF_ORIGTYPE
6405#undef ARRAYOF_TYPE
6406#define ARRAYOF_ORIGTYPE REAL
6407#define ARRAYOF_TYPE arrayof_real
6408#include "arrayof_post.F90"
6409
6410#undef ARRAYOF_ORIGTYPE
6411#undef ARRAYOF_TYPE
6412#define ARRAYOF_ORIGTYPE DOUBLEPRECISION
6413#define ARRAYOF_TYPE arrayof_doubleprecision
6414#include "arrayof_post.F90"
6415
6416#undef ARRAYOF_ORIGEQ
6417
6418#undef ARRAYOF_ORIGTYPE
6419#undef ARRAYOF_TYPE
6420#define ARRAYOF_ORIGTYPE LOGICAL
6421#define ARRAYOF_TYPE arrayof_logical
6422#include "arrayof_post.F90"
6423
6424END MODULE array_utilities
Quick method to append an element to the array.
Destructor for finalizing an array object.
Method for inserting elements of the array at a desired position.
Method for packing the array object reducing at a minimum the memory occupation, without destroying i...
Method for removing elements of the array at a desired position.
Index method.
This module defines usefull general purpose function and subroutine.

Generated with Doxygen.