libsim Versione 7.2.0

◆ overalloc

double precision overalloc =2.0D0

overallocation factor, values close to 1 determine more calls to the system alloc function (decreased performances) at the advantage of less memory consumption, the default is 2; the results are not affected by the value of this member

Definizione alla linea 844 del file array_utilities.F90.

844! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
845! authors:
846! Davide Cesari <dcesari@arpa.emr.it>
847! Paolo Patruno <ppatruno@arpa.emr.it>
848
849! This program is free software; you can redistribute it and/or
850! modify it under the terms of the GNU General Public License as
851! published by the Free Software Foundation; either version 2 of
852! the License, or (at your option) any later version.
853
854! This program is distributed in the hope that it will be useful,
855! but WITHOUT ANY WARRANTY; without even the implied warranty of
856! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
857! GNU General Public License for more details.
858
859! You should have received a copy of the GNU General Public License
860! along with this program. If not, see <http://www.gnu.org/licenses/>.
861
862
863
866#include "config.h"
867MODULE array_utilities
868
869IMPLICIT NONE
870
871! la routine per i char non puo' essere sviluppata in macro perche` si deve scrivere diversa
872!cosi' esiste la function count_distinctc (senza _ ) e la subroutine pack_distinctc qui ivi scritte
873
874#undef VOL7D_POLY_TYPE_AUTO
875
876#undef VOL7D_POLY_TYPE
877#undef VOL7D_POLY_TYPES
878#define VOL7D_POLY_TYPE INTEGER
879#define VOL7D_POLY_TYPES _i
880#define ENABLE_SORT
881#include "array_utilities_pre.F90"
882#undef ENABLE_SORT
883
884#undef VOL7D_POLY_TYPE
885#undef VOL7D_POLY_TYPES
886#define VOL7D_POLY_TYPE REAL
887#define VOL7D_POLY_TYPES _r
888#define ENABLE_SORT
889#include "array_utilities_pre.F90"
890#undef ENABLE_SORT
891
892#undef VOL7D_POLY_TYPE
893#undef VOL7D_POLY_TYPES
894#define VOL7D_POLY_TYPE DOUBLEPRECISION
895#define VOL7D_POLY_TYPES _d
896#define ENABLE_SORT
897#include "array_utilities_pre.F90"
898#undef ENABLE_SORT
899
900#define VOL7D_NO_PACK
901#undef VOL7D_POLY_TYPE
902#undef VOL7D_POLY_TYPES
903#define VOL7D_POLY_TYPE CHARACTER(len=*)
904#define VOL7D_POLY_TYPE_AUTO(var) CHARACTER(len=LEN(var))
905#define VOL7D_POLY_TYPES _c
906#define ENABLE_SORT
907#include "array_utilities_pre.F90"
908#undef VOL7D_POLY_TYPE_AUTO
909#undef ENABLE_SORT
910
911
912#define ARRAYOF_ORIGEQ 1
913
914#define ARRAYOF_ORIGTYPE INTEGER
915#define ARRAYOF_TYPE arrayof_integer
916#include "arrayof_pre.F90"
917
918#undef ARRAYOF_ORIGTYPE
919#undef ARRAYOF_TYPE
920#define ARRAYOF_ORIGTYPE REAL
921#define ARRAYOF_TYPE arrayof_real
922#include "arrayof_pre.F90"
923
924#undef ARRAYOF_ORIGTYPE
925#undef ARRAYOF_TYPE
926#define ARRAYOF_ORIGTYPE DOUBLEPRECISION
927#define ARRAYOF_TYPE arrayof_doubleprecision
928#include "arrayof_pre.F90"
929
930#undef ARRAYOF_ORIGEQ
931
932#undef ARRAYOF_ORIGTYPE
933#undef ARRAYOF_TYPE
934#define ARRAYOF_ORIGTYPE LOGICAL
935#define ARRAYOF_TYPE arrayof_logical
936#include "arrayof_pre.F90"
937
938PRIVATE
939! from arrayof
941PUBLIC insert_unique, append_unique
942
943PUBLIC sort, index, index_c, &
944 count_distinct_sorted, pack_distinct_sorted, &
945 count_distinct, pack_distinct, count_and_pack_distinct, &
946 map_distinct, map_inv_distinct, &
947 firsttrue, lasttrue, pack_distinct_c, map
948
949CONTAINS
950
951
954FUNCTION firsttrue(v) RESULT(i)
955LOGICAL,INTENT(in) :: v(:)
956INTEGER :: i
957
958DO i = 1, SIZE(v)
959 IF (v(i)) RETURN
960ENDDO
961i = 0
962
963END FUNCTION firsttrue
964
965
968FUNCTION lasttrue(v) RESULT(i)
969LOGICAL,INTENT(in) :: v(:)
970INTEGER :: i
971
972DO i = SIZE(v), 1, -1
973 IF (v(i)) RETURN
974ENDDO
975
976END FUNCTION lasttrue
977
978
979! Definisce le funzioni count_distinct(_sorted) e pack_distinct(_sorted)
980#undef VOL7D_POLY_TYPE_AUTO
981#undef VOL7D_NO_PACK
982
983#undef VOL7D_POLY_TYPE
984#undef VOL7D_POLY_TYPES
985#define VOL7D_POLY_TYPE INTEGER
986#define VOL7D_POLY_TYPES _i
987#define ENABLE_SORT
988#include "array_utilities_inc.F90"
989#undef ENABLE_SORT
990
991#undef VOL7D_POLY_TYPE
992#undef VOL7D_POLY_TYPES
993#define VOL7D_POLY_TYPE REAL
994#define VOL7D_POLY_TYPES _r
995#define ENABLE_SORT
996#include "array_utilities_inc.F90"
997#undef ENABLE_SORT
998
999#undef VOL7D_POLY_TYPE
1000#undef VOL7D_POLY_TYPES
1001#define VOL7D_POLY_TYPE DOUBLEPRECISION
1002#define VOL7D_POLY_TYPES _d
1003#define ENABLE_SORT
1004#include "array_utilities_inc.F90"
1005#undef ENABLE_SORT
1006
1007#define VOL7D_NO_PACK
1008#undef VOL7D_POLY_TYPE
1009#undef VOL7D_POLY_TYPES
1010#define VOL7D_POLY_TYPE CHARACTER(len=*)
1011#define VOL7D_POLY_TYPE_AUTO(var) CHARACTER(len=LEN(var))
1012#define VOL7D_POLY_TYPES _c
1013#define ENABLE_SORT
1014#include "array_utilities_inc.F90"
1015#undef VOL7D_POLY_TYPE_AUTO
1016#undef ENABLE_SORT
1017
1018SUBROUTINE pack_distinct_c(vect, pack_distinct, mask, back) !RESULT(pack_distinct)
1019CHARACTER(len=*),INTENT(in) :: vect(:)
1020LOGICAL,INTENT(in),OPTIONAL :: mask(:), back
1021CHARACTER(len=LEN(vect)) :: pack_distinct(:)
1022
1023INTEGER :: count_distinct
1024INTEGER :: i, j, dim
1025LOGICAL :: lback
1026
1027dim = SIZE(pack_distinct)
1028IF (PRESENT(back)) THEN
1029 lback = back
1030ELSE
1031 lback = .false.
1032ENDIF
1033count_distinct = 0
1034
1035IF (PRESENT (mask)) THEN
1036 IF (lback) THEN
1037 vectm1: DO i = 1, SIZE(vect)
1038 IF (.NOT.mask(i)) cycle vectm1
1039! DO j = i-1, 1, -1
1040! IF (vect(j) == vect(i)) CYCLE vectm1
1041 DO j = count_distinct, 1, -1
1042 IF (pack_distinct(j) == vect(i)) cycle vectm1
1043 ENDDO
1044 count_distinct = count_distinct + 1
1045 IF (count_distinct > dim) EXIT
1046 pack_distinct(count_distinct) = vect(i)
1047 ENDDO vectm1
1048 ELSE
1049 vectm2: DO i = 1, SIZE(vect)
1050 IF (.NOT.mask(i)) cycle vectm2
1051! DO j = 1, i-1
1052! IF (vect(j) == vect(i)) CYCLE vectm2
1053 DO j = 1, count_distinct
1054 IF (pack_distinct(j) == vect(i)) cycle vectm2
1055 ENDDO
1056 count_distinct = count_distinct + 1
1057 IF (count_distinct > dim) EXIT
1058 pack_distinct(count_distinct) = vect(i)
1059 ENDDO vectm2
1060 ENDIF
1061ELSE
1062 IF (lback) THEN
1063 vect1: DO i = 1, SIZE(vect)
1064! DO j = i-1, 1, -1
1065! IF (vect(j) == vect(i)) CYCLE vect1
1066 DO j = count_distinct, 1, -1
1067 IF (pack_distinct(j) == vect(i)) cycle vect1
1068 ENDDO
1069 count_distinct = count_distinct + 1
1070 IF (count_distinct > dim) EXIT
1071 pack_distinct(count_distinct) = vect(i)
1072 ENDDO vect1
1073 ELSE
1074 vect2: DO i = 1, SIZE(vect)
1075! DO j = 1, i-1
1076! IF (vect(j) == vect(i)) CYCLE vect2
1077 DO j = 1, count_distinct
1078 IF (pack_distinct(j) == vect(i)) cycle vect2
1079 ENDDO
1080 count_distinct = count_distinct + 1
1081 IF (count_distinct > dim) EXIT
1082 pack_distinct(count_distinct) = vect(i)
1083 ENDDO vect2
1084 ENDIF
1085ENDIF
1086
1087END SUBROUTINE pack_distinct_c
1088
1090FUNCTION map(mask) RESULT(mapidx)
1091LOGICAL,INTENT(in) :: mask(:)
1092INTEGER :: mapidx(count(mask))
1093
1094INTEGER :: i,j
1095
1096j = 0
1097DO i=1, SIZE(mask)
1098 j = j + 1
1099 IF (mask(i)) mapidx(j)=i
1100ENDDO
1101
1102END FUNCTION map
1103
1104#define ARRAYOF_ORIGEQ 1
1105
1106#undef ARRAYOF_ORIGTYPE
1107#undef ARRAYOF_TYPE
1108#define ARRAYOF_ORIGTYPE INTEGER
1109#define ARRAYOF_TYPE arrayof_integer
1110#include "arrayof_post.F90"
1111
1112#undef ARRAYOF_ORIGTYPE
1113#undef ARRAYOF_TYPE
1114#define ARRAYOF_ORIGTYPE REAL
1115#define ARRAYOF_TYPE arrayof_real
1116#include "arrayof_post.F90"
1117
1118#undef ARRAYOF_ORIGTYPE
1119#undef ARRAYOF_TYPE
1120#define ARRAYOF_ORIGTYPE DOUBLEPRECISION
1121#define ARRAYOF_TYPE arrayof_doubleprecision
1122#include "arrayof_post.F90"
1123
1124#undef ARRAYOF_ORIGEQ
1125
1126#undef ARRAYOF_ORIGTYPE
1127#undef ARRAYOF_TYPE
1128#define ARRAYOF_ORIGTYPE LOGICAL
1129#define ARRAYOF_TYPE arrayof_logical
1130#include "arrayof_post.F90"
1131
1132END 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.