libsim Versione 7.2.6
|
◆ pack_distinct_sorted_timerange()
compatta gli elementi distinti di vect in un sorted array Definizione alla linea 850 del file vol7d_timerange_class.F90. 852! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
853! authors:
854! Davide Cesari <dcesari@arpa.emr.it>
855! Paolo Patruno <ppatruno@arpa.emr.it>
856
857! This program is free software; you can redistribute it and/or
858! modify it under the terms of the GNU General Public License as
859! published by the Free Software Foundation; either version 2 of
860! the License, or (at your option) any later version.
861
862! This program is distributed in the hope that it will be useful,
863! but WITHOUT ANY WARRANTY; without even the implied warranty of
864! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
865! GNU General Public License for more details.
866
867! You should have received a copy of the GNU General Public License
868! along with this program. If not, see <http://www.gnu.org/licenses/>.
869#include "config.h"
870
871!> Classe per la gestione degli intervalli temporali di osservazioni
872!! meteo e affini.
873!! Questo modulo definisce una classe in grado di rappresentare
874!! l'intervallo di tempo a cui si riferisce un'osservazione meteo,
875!! ad es. valore istantaneo, cumulato, medio, ecc., prendendo in prestito
876!! concetti dal formato grib.
877!! \ingroup vol7d
882IMPLICIT NONE
883
884!> Definisce l'intervallo temporale di un'osservazione meteo.
885!! I membri di \a vol7d_timerange sono pubblici e quindi liberamente
886!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
887!! il costruttore ::init.
889 INTEGER :: timerange !< proprietà statistiche del dato (es. 0=media, 1=cumulazione, 2=massimo, 3=minimo, 4=differenza... 254=dato istantaneo) tratte dalla code table 4.10 del formato WMO grib edizione 2, vedi http://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI2/LatestVERSION/WMO306_vI2_GRIB2_CodeFlag_en.pdf
890 INTEGER :: p1 !< termine del periodo di validità del dato, in secondi, a partire dall'istante di riferimento (0 per dati osservati o analizzati)
891 INTEGER :: p2 !< durata del periodo di validità del dato, in secondi (0 per dati istantanei)
893
894!> Valore mancante per vol7d_timerange.
895TYPE(vol7d_timerange),PARAMETER :: vol7d_timerange_miss= &
896 vol7d_timerange(imiss,imiss,imiss)
897
898!> Costruttore per la classe vol7d_timerange.
899!! Deve essere richiamato
900!! per tutti gli oggetti di questo tipo definiti in un programma.
902 MODULE PROCEDURE vol7d_timerange_init
903END INTERFACE
904
905!> Distruttore per la classe vol7d_timerange.
906!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
908 MODULE PROCEDURE vol7d_timerange_delete
909END INTERFACE
910
911!> Logical equality operator for objects of \a vol7d_timerange class.
912!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
913!! of any shape.
914INTERFACE OPERATOR (==)
915 MODULE PROCEDURE vol7d_timerange_eq
916END INTERFACE
917
918!> Logical inequality operator for objects of \a vol7d_timerange class.
919!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
920!! of any shape.
921INTERFACE OPERATOR (/=)
922 MODULE PROCEDURE vol7d_timerange_ne
923END INTERFACE
924
925!> Logical greater-than operator for objects of \a vol7d_timerange class.
926!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
927!! of any shape.
928INTERFACE OPERATOR (>)
929 MODULE PROCEDURE vol7d_timerange_gt
930END INTERFACE
931
932!> Logical less-than operator for objects of \a vol7d_timerange class.
933!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
934!! of any shape.
935INTERFACE OPERATOR (<)
936 MODULE PROCEDURE vol7d_timerange_lt
937END INTERFACE
938
939!> Logical greater-equal operator for objects of \a vol7d_timerange class.
940!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
941!! of any shape.
942INTERFACE OPERATOR (>=)
943 MODULE PROCEDURE vol7d_timerange_ge
944END INTERFACE
945
946!> Logical less-equal operator for objects of \a vol7d_timerange class.
947!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
948!! of any shape.
949INTERFACE OPERATOR (<=)
950 MODULE PROCEDURE vol7d_timerange_le
951END INTERFACE
952
953!> Logical almost equality operator for objects of \a vol7d_timerange class.
954!! If one component is missing it is not used in comparison.
955INTERFACE OPERATOR (.almosteq.)
956 MODULE PROCEDURE vol7d_timerange_almost_eq
957END INTERFACE
958
959
960! da documentare in inglese assieme al resto
961!> to be documented
963 MODULE PROCEDURE vol7d_timerange_c_e
964END INTERFACE
965
966#define VOL7D_POLY_TYPE TYPE(vol7d_timerange)
967#define VOL7D_POLY_TYPES _timerange
968#define ENABLE_SORT
969#include "array_utilities_pre.F90"
970
971!>Print object
973 MODULE PROCEDURE display_timerange
974END INTERFACE
975
976!>Represent timerange object in a pretty string
978 MODULE PROCEDURE to_char_timerange
979END INTERFACE
980
981#define ARRAYOF_ORIGTYPE TYPE(vol7d_timerange)
982#define ARRAYOF_TYPE arrayof_vol7d_timerange
983#define ARRAYOF_ORIGEQ 1
984#include "arrayof_pre.F90"
985
986
987type(vol7d_timerange) :: almost_equal_timeranges(2)=(/&
988 vol7d_timerange(254,0,imiss),&
989 vol7d_timerange(3,0,3600)/)
990
991
992! from arrayof
994PUBLIC insert_unique, append_unique
995PUBLIC almost_equal_timeranges
996
997CONTAINS
998
999
1000!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
1001!! Questa è la versione \c FUNCTION, in stile F2003, del costruttore, da preferire
1002!! rispetto alla versione \c SUBROUTINE \c init.
1003!! Se non viene passato nessun parametro opzionale l'oggetto è
1004!! inizializzato a valore mancante.
1005FUNCTION vol7d_timerange_new(timerange, p1, p2) RESULT(this)
1006INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
1007INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
1008INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
1009
1010TYPE(vol7d_timerange) :: this !< oggetto da inizializzare
1011
1013
1014END FUNCTION vol7d_timerange_new
1015
1016
1017!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
1018!! Se non viene passato nessun parametro opzionale l'oggetto è
1019!! inizializzato a valore mancante.
1020SUBROUTINE vol7d_timerange_init(this, timerange, p1, p2)
1021TYPE(vol7d_timerange),INTENT(INOUT) :: this !< oggetto da inizializzare
1022INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
1023INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
1024INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
1025
1026IF (PRESENT(timerange)) THEN
1027 this%timerange = timerange
1028ELSE
1029 this%timerange = imiss
1030 this%p1 = imiss
1031 this%p2 = imiss
1032 RETURN
1033ENDIF
1034!!$IF (timerange == 1) THEN ! p1 sempre 0
1035!!$ this%p1 = 0
1036!!$ this%p2 = imiss
1037!!$ELSE IF (timerange == 0 .OR. timerange == 10) THEN ! solo p1
1038!!$ IF (PRESENT(p1)) THEN
1039!!$ this%p1 = p1
1040!!$ ELSE
1041!!$ this%p1 = 0
1042!!$ ENDIF
1043!!$ this%p2 = imiss
1044!!$ELSE ! tutti gli altri
1045 IF (PRESENT(p1)) THEN
1046 this%p1 = p1
1047 ELSE
1048 this%p1 = imiss
1049 ENDIF
1050 IF (PRESENT(p2)) THEN
1051 this%p2 = p2
1052 ELSE
1053 this%p2 = imiss
1054 ENDIF
1055!!$END IF
1056
1057END SUBROUTINE vol7d_timerange_init
1058
1059
1060!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1061SUBROUTINE vol7d_timerange_delete(this)
1062TYPE(vol7d_timerange),INTENT(INOUT) :: this
1063
1064this%timerange = imiss
1065this%p1 = imiss
1066this%p2 = imiss
1067
1068END SUBROUTINE vol7d_timerange_delete
1069
1070
1071SUBROUTINE display_timerange(this)
1072TYPE(vol7d_timerange),INTENT(in) :: this
1073
1074print*,to_char_timerange(this)
1075
1076END SUBROUTINE display_timerange
1077
1078
1079FUNCTION to_char_timerange(this)
1080#ifdef HAVE_DBALLE
1081USE dballef
1082#endif
1083TYPE(vol7d_timerange),INTENT(in) :: this
1084CHARACTER(len=80) :: to_char_timerange
1085
1086#ifdef HAVE_DBALLE
1087INTEGER :: handle, ier
1088
1089handle = 0
1090ier = idba_messaggi(handle,"/dev/null", "w", "BUFR")
1091ier = idba_spiegat(handle,this%timerange,this%p1,this%p2,to_char_timerange)
1092ier = idba_fatto(handle)
1093
1094to_char_timerange="Timerange: "//to_char_timerange
1095
1096#else
1097
1100
1101#endif
1102
1103END FUNCTION to_char_timerange
1104
1105
1106ELEMENTAL FUNCTION vol7d_timerange_eq(this, that) RESULT(res)
1107TYPE(vol7d_timerange),INTENT(IN) :: this, that
1108LOGICAL :: res
1109
1110
1111res = &
1112 this%timerange == that%timerange .AND. &
1113 this%p1 == that%p1 .AND. (this%p2 == that%p2 .OR. &
1114 this%timerange == 254)
1115
1116END FUNCTION vol7d_timerange_eq
1117
1118
1119ELEMENTAL FUNCTION vol7d_timerange_almost_eq(this, that) RESULT(res)
1120TYPE(vol7d_timerange),INTENT(IN) :: this, that
1121LOGICAL :: res
1122
1123IF (.not. c_e(this%timerange) .or. .not. c_e(that%timerange) .or. this%timerange == that%timerange .AND. &
1124 this%p1 == that%p1 .AND. &
1125 this%p2 == that%p2) THEN
1126 res = .true.
1127ELSE
1128 res = .false.
1129ENDIF
1130
1131END FUNCTION vol7d_timerange_almost_eq
1132
1133
1134ELEMENTAL FUNCTION vol7d_timerange_ne(this, that) RESULT(res)
1135TYPE(vol7d_timerange),INTENT(IN) :: this, that
1136LOGICAL :: res
1137
1138res = .NOT.(this == that)
1139
1140END FUNCTION vol7d_timerange_ne
1141
1142
1143ELEMENTAL FUNCTION vol7d_timerange_gt(this, that) RESULT(res)
1144TYPE(vol7d_timerange),INTENT(IN) :: this, that
1145LOGICAL :: res
1146
1147IF (this%timerange > that%timerange .OR. &
1148 (this%timerange == that%timerange .AND. this%p1 > that%p1) .OR. &
1149 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
1150 this%p2 > that%p2)) THEN
1151 res = .true.
1152ELSE
1153 res = .false.
1154ENDIF
1155
1156END FUNCTION vol7d_timerange_gt
1157
1158
1159ELEMENTAL FUNCTION vol7d_timerange_lt(this, that) RESULT(res)
1160TYPE(vol7d_timerange),INTENT(IN) :: this, that
1161LOGICAL :: res
1162
1163IF (this%timerange < that%timerange .OR. &
1164 (this%timerange == that%timerange .AND. this%p1 < that%p1) .OR. &
1165 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
1166 this%p2 < that%p2)) THEN
1167 res = .true.
1168ELSE
1169 res = .false.
1170ENDIF
1171
1172END FUNCTION vol7d_timerange_lt
1173
1174
1175ELEMENTAL FUNCTION vol7d_timerange_ge(this, that) RESULT(res)
1176TYPE(vol7d_timerange),INTENT(IN) :: this, that
1177LOGICAL :: res
1178
1179IF (this == that) THEN
1180 res = .true.
1181ELSE IF (this > that) THEN
1182 res = .true.
1183ELSE
1184 res = .false.
1185ENDIF
1186
1187END FUNCTION vol7d_timerange_ge
1188
1189
1190ELEMENTAL FUNCTION vol7d_timerange_le(this, that) RESULT(res)
1191TYPE(vol7d_timerange),INTENT(IN) :: this, that
1192LOGICAL :: res
1193
1194IF (this == that) THEN
1195 res = .true.
1196ELSE IF (this < that) THEN
1197 res = .true.
1198ELSE
1199 res = .false.
1200ENDIF
1201
1202END FUNCTION vol7d_timerange_le
1203
1204
1205ELEMENTAL FUNCTION vol7d_timerange_c_e(this) RESULT(c_e)
1206TYPE(vol7d_timerange),INTENT(IN) :: this
1207LOGICAL :: c_e
1208c_e = this /= vol7d_timerange_miss
1209END FUNCTION vol7d_timerange_c_e
1210
1211
1212#include "array_utilities_inc.F90"
1213
1214#include "arrayof_post.F90"
1215
1216
Quick method to append an element to the array. Definition vol7d_timerange_class.F90:425 Distruttore per la classe vol7d_timerange. Definition vol7d_timerange_class.F90:244 Costruttore per la classe vol7d_timerange. Definition vol7d_timerange_class.F90:238 Method for inserting elements of the array at a desired position. Definition vol7d_timerange_class.F90:416 Method for packing the array object reducing at a minimum the memory occupation, without destroying i... Definition vol7d_timerange_class.F90:448 Method for removing elements of the array at a desired position. Definition vol7d_timerange_class.F90:431 Represent timerange object in a pretty string. Definition vol7d_timerange_class.F90:369 Definition of constants to be used for declaring variables of a desired type. Definition kinds.F90:245 Definitions of constants and functions for working with missing values. Definition missing_values.f90:50 Classe per la gestione degli intervalli temporali di osservazioni meteo e affini. Definition vol7d_timerange_class.F90:215 Definisce l'intervallo temporale di un'osservazione meteo. Definition vol7d_timerange_class.F90:225 |