libsim Versione 7.2.6

◆ vol7d_timerange_new()

type(vol7d_timerange) function vol7d_timerange_new ( integer, intent(in), optional timerange,
integer, intent(in), optional p1,
integer, intent(in), optional p2 )

Inizializza un oggetto vol7d_timerange con i parametri opzionali forniti.

Questa è la versione FUNCTION, in stile F2003, del costruttore, da preferire rispetto alla versione SUBROUTINE init. Se non viene passato nessun parametro opzionale l'oggetto è inizializzato a valore mancante.

Parametri
[in]timerangetipo di intervallo temporale
[in]p1valore per il primo istante temporale
[in]p2valore per il secondo istante temporale
Restituisce
oggetto da inizializzare

Definizione alla linea 507 del file vol7d_timerange_class.F90.

508! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
509! authors:
510! Davide Cesari <dcesari@arpa.emr.it>
511! Paolo Patruno <ppatruno@arpa.emr.it>
512
513! This program is free software; you can redistribute it and/or
514! modify it under the terms of the GNU General Public License as
515! published by the Free Software Foundation; either version 2 of
516! the License, or (at your option) any later version.
517
518! This program is distributed in the hope that it will be useful,
519! but WITHOUT ANY WARRANTY; without even the implied warranty of
520! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
521! GNU General Public License for more details.
522
523! You should have received a copy of the GNU General Public License
524! along with this program. If not, see <http://www.gnu.org/licenses/>.
525#include "config.h"
526
527!> Classe per la gestione degli intervalli temporali di osservazioni
528!! meteo e affini.
529!! Questo modulo definisce una classe in grado di rappresentare
530!! l'intervallo di tempo a cui si riferisce un'osservazione meteo,
531!! ad es. valore istantaneo, cumulato, medio, ecc., prendendo in prestito
532!! concetti dal formato grib.
533!! \ingroup vol7d
535USE kinds
538IMPLICIT NONE
539
540!> Definisce l'intervallo temporale di un'osservazione meteo.
541!! I membri di \a vol7d_timerange sono pubblici e quindi liberamente
542!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
543!! il costruttore ::init.
545 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
546 INTEGER :: p1 !< termine del periodo di validità del dato, in secondi, a partire dall'istante di riferimento (0 per dati osservati o analizzati)
547 INTEGER :: p2 !< durata del periodo di validità del dato, in secondi (0 per dati istantanei)
548END TYPE vol7d_timerange
549
550!> Valore mancante per vol7d_timerange.
551TYPE(vol7d_timerange),PARAMETER :: vol7d_timerange_miss= &
552 vol7d_timerange(imiss,imiss,imiss)
553
554!> Costruttore per la classe vol7d_timerange.
555!! Deve essere richiamato
556!! per tutti gli oggetti di questo tipo definiti in un programma.
557INTERFACE init
558 MODULE PROCEDURE vol7d_timerange_init
559END INTERFACE
560
561!> Distruttore per la classe vol7d_timerange.
562!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
563INTERFACE delete
564 MODULE PROCEDURE vol7d_timerange_delete
565END INTERFACE
566
567!> Logical equality operator for objects of \a vol7d_timerange class.
568!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
569!! of any shape.
570INTERFACE OPERATOR (==)
571 MODULE PROCEDURE vol7d_timerange_eq
572END INTERFACE
573
574!> Logical inequality operator for objects of \a vol7d_timerange class.
575!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
576!! of any shape.
577INTERFACE OPERATOR (/=)
578 MODULE PROCEDURE vol7d_timerange_ne
579END INTERFACE
580
581!> Logical greater-than operator for objects of \a vol7d_timerange class.
582!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
583!! of any shape.
584INTERFACE OPERATOR (>)
585 MODULE PROCEDURE vol7d_timerange_gt
586END INTERFACE
587
588!> Logical less-than operator for objects of \a vol7d_timerange class.
589!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
590!! of any shape.
591INTERFACE OPERATOR (<)
592 MODULE PROCEDURE vol7d_timerange_lt
593END INTERFACE
594
595!> Logical greater-equal operator for objects of \a vol7d_timerange class.
596!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
597!! of any shape.
598INTERFACE OPERATOR (>=)
599 MODULE PROCEDURE vol7d_timerange_ge
600END INTERFACE
601
602!> Logical less-equal operator for objects of \a vol7d_timerange class.
603!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
604!! of any shape.
605INTERFACE OPERATOR (<=)
606 MODULE PROCEDURE vol7d_timerange_le
607END INTERFACE
608
609!> Logical almost equality operator for objects of \a vol7d_timerange class.
610!! If one component is missing it is not used in comparison.
611INTERFACE OPERATOR (.almosteq.)
612 MODULE PROCEDURE vol7d_timerange_almost_eq
613END INTERFACE
614
615
616! da documentare in inglese assieme al resto
617!> to be documented
618INTERFACE c_e
619 MODULE PROCEDURE vol7d_timerange_c_e
620END INTERFACE
621
622#define VOL7D_POLY_TYPE TYPE(vol7d_timerange)
623#define VOL7D_POLY_TYPES _timerange
624#define ENABLE_SORT
625#include "array_utilities_pre.F90"
626
627!>Print object
628INTERFACE display
629 MODULE PROCEDURE display_timerange
630END INTERFACE
631
632!>Represent timerange object in a pretty string
633INTERFACE to_char
634 MODULE PROCEDURE to_char_timerange
635END INTERFACE
636
637#define ARRAYOF_ORIGTYPE TYPE(vol7d_timerange)
638#define ARRAYOF_TYPE arrayof_vol7d_timerange
639#define ARRAYOF_ORIGEQ 1
640#include "arrayof_pre.F90"
641
642
643type(vol7d_timerange) :: almost_equal_timeranges(2)=(/&
644 vol7d_timerange(254,0,imiss),&
645 vol7d_timerange(3,0,3600)/)
646
647
648! from arrayof
650PUBLIC insert_unique, append_unique
651PUBLIC almost_equal_timeranges
652
653CONTAINS
654
655
656!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
657!! Questa è la versione \c FUNCTION, in stile F2003, del costruttore, da preferire
658!! rispetto alla versione \c SUBROUTINE \c init.
659!! Se non viene passato nessun parametro opzionale l'oggetto è
660!! inizializzato a valore mancante.
661FUNCTION vol7d_timerange_new(timerange, p1, p2) RESULT(this)
662INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
663INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
664INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
665
666TYPE(vol7d_timerange) :: this !< oggetto da inizializzare
667
668CALL init(this, timerange, p1, p2)
669
670END FUNCTION vol7d_timerange_new
671
672
673!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
674!! Se non viene passato nessun parametro opzionale l'oggetto è
675!! inizializzato a valore mancante.
676SUBROUTINE vol7d_timerange_init(this, timerange, p1, p2)
677TYPE(vol7d_timerange),INTENT(INOUT) :: this !< oggetto da inizializzare
678INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
679INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
680INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
681
682IF (PRESENT(timerange)) THEN
683 this%timerange = timerange
684ELSE
685 this%timerange = imiss
686 this%p1 = imiss
687 this%p2 = imiss
688 RETURN
689ENDIF
690!!$IF (timerange == 1) THEN ! p1 sempre 0
691!!$ this%p1 = 0
692!!$ this%p2 = imiss
693!!$ELSE IF (timerange == 0 .OR. timerange == 10) THEN ! solo p1
694!!$ IF (PRESENT(p1)) THEN
695!!$ this%p1 = p1
696!!$ ELSE
697!!$ this%p1 = 0
698!!$ ENDIF
699!!$ this%p2 = imiss
700!!$ELSE ! tutti gli altri
701 IF (PRESENT(p1)) THEN
702 this%p1 = p1
703 ELSE
704 this%p1 = imiss
705 ENDIF
706 IF (PRESENT(p2)) THEN
707 this%p2 = p2
708 ELSE
709 this%p2 = imiss
710 ENDIF
711!!$END IF
712
713END SUBROUTINE vol7d_timerange_init
714
715
716!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
717SUBROUTINE vol7d_timerange_delete(this)
718TYPE(vol7d_timerange),INTENT(INOUT) :: this
719
720this%timerange = imiss
721this%p1 = imiss
722this%p2 = imiss
723
724END SUBROUTINE vol7d_timerange_delete
725
726
727SUBROUTINE display_timerange(this)
728TYPE(vol7d_timerange),INTENT(in) :: this
729
730print*,to_char_timerange(this)
731
732END SUBROUTINE display_timerange
733
734
735FUNCTION to_char_timerange(this)
736#ifdef HAVE_DBALLE
737USE dballef
738#endif
739TYPE(vol7d_timerange),INTENT(in) :: this
740CHARACTER(len=80) :: to_char_timerange
741
742#ifdef HAVE_DBALLE
743INTEGER :: handle, ier
744
745handle = 0
746ier = idba_messaggi(handle,"/dev/null", "w", "BUFR")
747ier = idba_spiegat(handle,this%timerange,this%p1,this%p2,to_char_timerange)
748ier = idba_fatto(handle)
749
750to_char_timerange="Timerange: "//to_char_timerange
751
752#else
753
754to_char_timerange="Timerange: "//trim(to_char(this%timerange))//" P1: "//&
755 trim(to_char(this%p1))//" P2: "//trim(to_char(this%p2))
756
757#endif
758
759END FUNCTION to_char_timerange
760
761
762ELEMENTAL FUNCTION vol7d_timerange_eq(this, that) RESULT(res)
763TYPE(vol7d_timerange),INTENT(IN) :: this, that
764LOGICAL :: res
765
766
767res = &
768 this%timerange == that%timerange .AND. &
769 this%p1 == that%p1 .AND. (this%p2 == that%p2 .OR. &
770 this%timerange == 254)
771
772END FUNCTION vol7d_timerange_eq
773
774
775ELEMENTAL FUNCTION vol7d_timerange_almost_eq(this, that) RESULT(res)
776TYPE(vol7d_timerange),INTENT(IN) :: this, that
777LOGICAL :: res
778
779IF (.not. c_e(this%timerange) .or. .not. c_e(that%timerange) .or. this%timerange == that%timerange .AND. &
780 this%p1 == that%p1 .AND. &
781 this%p2 == that%p2) THEN
782 res = .true.
783ELSE
784 res = .false.
785ENDIF
786
787END FUNCTION vol7d_timerange_almost_eq
788
789
790ELEMENTAL FUNCTION vol7d_timerange_ne(this, that) RESULT(res)
791TYPE(vol7d_timerange),INTENT(IN) :: this, that
792LOGICAL :: res
793
794res = .NOT.(this == that)
795
796END FUNCTION vol7d_timerange_ne
797
798
799ELEMENTAL FUNCTION vol7d_timerange_gt(this, that) RESULT(res)
800TYPE(vol7d_timerange),INTENT(IN) :: this, that
801LOGICAL :: res
802
803IF (this%timerange > that%timerange .OR. &
804 (this%timerange == that%timerange .AND. this%p1 > that%p1) .OR. &
805 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
806 this%p2 > that%p2)) THEN
807 res = .true.
808ELSE
809 res = .false.
810ENDIF
811
812END FUNCTION vol7d_timerange_gt
813
814
815ELEMENTAL FUNCTION vol7d_timerange_lt(this, that) RESULT(res)
816TYPE(vol7d_timerange),INTENT(IN) :: this, that
817LOGICAL :: res
818
819IF (this%timerange < that%timerange .OR. &
820 (this%timerange == that%timerange .AND. this%p1 < that%p1) .OR. &
821 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
822 this%p2 < that%p2)) THEN
823 res = .true.
824ELSE
825 res = .false.
826ENDIF
827
828END FUNCTION vol7d_timerange_lt
829
830
831ELEMENTAL FUNCTION vol7d_timerange_ge(this, that) RESULT(res)
832TYPE(vol7d_timerange),INTENT(IN) :: this, that
833LOGICAL :: res
834
835IF (this == that) THEN
836 res = .true.
837ELSE IF (this > that) THEN
838 res = .true.
839ELSE
840 res = .false.
841ENDIF
842
843END FUNCTION vol7d_timerange_ge
844
845
846ELEMENTAL FUNCTION vol7d_timerange_le(this, that) RESULT(res)
847TYPE(vol7d_timerange),INTENT(IN) :: this, that
848LOGICAL :: res
849
850IF (this == that) THEN
851 res = .true.
852ELSE IF (this < that) THEN
853 res = .true.
854ELSE
855 res = .false.
856ENDIF
857
858END FUNCTION vol7d_timerange_le
859
860
861ELEMENTAL FUNCTION vol7d_timerange_c_e(this) RESULT(c_e)
862TYPE(vol7d_timerange),INTENT(IN) :: this
863LOGICAL :: c_e
864c_e = this /= vol7d_timerange_miss
865END FUNCTION vol7d_timerange_c_e
866
867
868#include "array_utilities_inc.F90"
869
870#include "arrayof_post.F90"
871
872
873END MODULE vol7d_timerange_class
Quick method to append an element to the array.
Distruttore per la classe vol7d_timerange.
Costruttore per la classe vol7d_timerange.
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.
Represent timerange object in a pretty string.
Utilities for CHARACTER variables.
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.
Classe per la gestione degli intervalli temporali di osservazioni meteo e affini.
Definisce l'intervallo temporale di un'osservazione meteo.

Generated with Doxygen.