libsim Versione 7.1.11

◆ vol7d_var_features_delete()

subroutine vol7d_var_features_delete

Deallocate the global table of variable features.

This subroutine deallocates the table of variable features allocated in the vol7d_var_features_init subroutine.

Definizione alla linea 538 del file vol7d_var_class.F90.

539! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
540! authors:
541! Davide Cesari <dcesari@arpa.emr.it>
542! Paolo Patruno <ppatruno@arpa.emr.it>
543
544! This program is free software; you can redistribute it and/or
545! modify it under the terms of the GNU General Public License as
546! published by the Free Software Foundation; either version 2 of
547! the License, or (at your option) any later version.
548
549! This program is distributed in the hope that it will be useful,
550! but WITHOUT ANY WARRANTY; without even the implied warranty of
551! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
552! GNU General Public License for more details.
553
554! You should have received a copy of the GNU General Public License
555! along with this program. If not, see <http://www.gnu.org/licenses/>.
556#include "config.h"
557
562MODULE vol7d_var_class
563USE kinds
566IMPLICIT NONE
567
576TYPE vol7d_var
577 CHARACTER(len=10) :: btable=cmiss
578 CHARACTER(len=65) :: description=cmiss
579 CHARACTER(len=24) :: unit=cmiss
580 INTEGER :: scalefactor=imiss
581
582 INTEGER :: r=imiss
583 INTEGER :: d=imiss
584 INTEGER :: i=imiss
585 INTEGER :: b=imiss
586 INTEGER :: c=imiss
587 INTEGER :: gribhint(4)=imiss
588END TYPE vol7d_var
589
591TYPE(vol7d_var),PARAMETER :: vol7d_var_miss= &
592 vol7d_var(cmiss,cmiss,cmiss,imiss,imiss,imiss,imiss,imiss,imiss, &
593 (/imiss,imiss,imiss,imiss/))
594
598INTERFACE init
599 MODULE PROCEDURE vol7d_var_init
600END INTERFACE
601
604INTERFACE delete
605 MODULE PROCEDURE vol7d_var_delete
606END INTERFACE
607
613INTERFACE OPERATOR (==)
614 MODULE PROCEDURE vol7d_var_eq
615END INTERFACE
616
622INTERFACE OPERATOR (/=)
623 MODULE PROCEDURE vol7d_var_ne, vol7d_var_nesv
624END INTERFACE
625
627INTERFACE c_e
628 MODULE PROCEDURE vol7d_var_c_e
629END INTERFACE
630
631#define VOL7D_POLY_TYPE TYPE(vol7d_var)
632#define VOL7D_POLY_TYPES _var
633#include "array_utilities_pre.F90"
634
636INTERFACE display
637 MODULE PROCEDURE display_var, display_var_vect
638END INTERFACE
639
640
641TYPE vol7d_var_features
642 TYPE(vol7d_var) :: var
643 REAL :: posdef
644 INTEGER :: vartype
645END TYPE vol7d_var_features
646
647TYPE(vol7d_var_features),ALLOCATABLE :: var_features(:)
648
649! constants for vol7d_vartype
650INTEGER,PARAMETER :: var_ord=0
651INTEGER,PARAMETER :: var_dir360=1
652INTEGER,PARAMETER :: var_press=2
653INTEGER,PARAMETER :: var_ucomp=3
654INTEGER,PARAMETER :: var_vcomp=4
655INTEGER,PARAMETER :: var_wcomp=5
656
657
658CONTAINS
659
665elemental SUBROUTINE vol7d_var_init(this, btable, description, unit, scalefactor)
666TYPE(vol7d_var),INTENT(INOUT) :: this
667CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
668CHARACTER(len=*),INTENT(in),OPTIONAL :: description
669CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
670INTEGER,INTENT(in),OPTIONAL :: scalefactor
671
672IF (PRESENT(btable)) THEN
673 this%btable = btable
674ELSE
675 this%btable = cmiss
676 this%description = cmiss
677 this%unit = cmiss
678 this%scalefactor = imiss
679 RETURN
680ENDIF
681IF (PRESENT(description)) THEN
682 this%description = description
683ELSE
684 this%description = cmiss
685ENDIF
686IF (PRESENT(unit)) THEN
687 this%unit = unit
688ELSE
689 this%unit = cmiss
690ENDIF
691if (present(scalefactor)) then
692 this%scalefactor = scalefactor
693else
694 this%scalefactor = imiss
695endif
696
697this%r = -1
698this%d = -1
699this%i = -1
700this%b = -1
701this%c = -1
702
703END SUBROUTINE vol7d_var_init
704
705
706ELEMENTAL FUNCTION vol7d_var_new(btable, description, unit, scalefactor) RESULT(this)
707CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
708CHARACTER(len=*),INTENT(in),OPTIONAL :: description
709CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
710INTEGER,INTENT(in),OPTIONAL :: scalefactor
711
712TYPE(vol7d_var) :: this
713
714CALL init(this, btable, description, unit, scalefactor)
715
716END FUNCTION vol7d_var_new
717
718
720elemental SUBROUTINE vol7d_var_delete(this)
721TYPE(vol7d_var),INTENT(INOUT) :: this
722
723this%btable = cmiss
724this%description = cmiss
725this%unit = cmiss
726this%scalefactor = imiss
727
728END SUBROUTINE vol7d_var_delete
729
730
731ELEMENTAL FUNCTION vol7d_var_eq(this, that) RESULT(res)
732TYPE(vol7d_var),INTENT(IN) :: this, that
733LOGICAL :: res
734
735res = this%btable == that%btable
736
737END FUNCTION vol7d_var_eq
738
739
740ELEMENTAL FUNCTION vol7d_var_ne(this, that) RESULT(res)
741TYPE(vol7d_var),INTENT(IN) :: this, that
742LOGICAL :: res
743
744res = .NOT.(this == that)
745
746END FUNCTION vol7d_var_ne
747
748
749FUNCTION vol7d_var_nesv(this, that) RESULT(res)
750TYPE(vol7d_var),INTENT(IN) :: this, that(:)
751LOGICAL :: res(SIZE(that))
752
753INTEGER :: i
754
755DO i = 1, SIZE(that)
756 res(i) = .NOT.(this == that(i))
757ENDDO
758
759END FUNCTION vol7d_var_nesv
760
761
762
764subroutine display_var(this)
765
766TYPE(vol7d_var),INTENT(in) :: this
767
768print*,"VOL7DVAR: ",this%btable,trim(this%description)," : ",this%unit,&
769 " scale factor",this%scalefactor
770
771end subroutine display_var
772
773
775subroutine display_var_vect(this)
776
777TYPE(vol7d_var),INTENT(in) :: this(:)
778integer :: i
779
780do i=1,size(this)
781 call display_var(this(i))
782end do
783
784end subroutine display_var_vect
785
786FUNCTION vol7d_var_c_e(this) RESULT(c_e)
787TYPE(vol7d_var),INTENT(IN) :: this
788LOGICAL :: c_e
789c_e = this /= vol7d_var_miss
790END FUNCTION vol7d_var_c_e
791
792
801SUBROUTINE vol7d_var_features_init()
802INTEGER :: un, i, n
803TYPE(csv_record) :: csv
804CHARACTER(len=1024) :: line
805
806IF (ALLOCATED(var_features)) RETURN
807
808un = open_package_file('varbufr.csv', filetype_data)
809n=0
810DO WHILE(.true.)
811 READ(un,*,END=100)
812 n = n + 1
813ENDDO
814
815100 CONTINUE
816
817rewind(un)
818ALLOCATE(var_features(n))
819
820DO i = 1, n
821 READ(un,'(A)',END=200)line
822 CALL init(csv, line)
823 CALL csv_record_getfield(csv, var_features(i)%var%btable)
824 CALL csv_record_getfield(csv)
825 CALL csv_record_getfield(csv)
826 CALL csv_record_getfield(csv, var_features(i)%posdef)
827 CALL csv_record_getfield(csv, var_features(i)%vartype)
828 CALL delete(csv)
829ENDDO
830
831200 CONTINUE
832CLOSE(un)
833
834END SUBROUTINE vol7d_var_features_init
835
836
840SUBROUTINE vol7d_var_features_delete()
841IF (ALLOCATED(var_features)) DEALLOCATE(var_features)
842END SUBROUTINE vol7d_var_features_delete
843
844
851ELEMENTAL FUNCTION vol7d_var_features_vartype(this) RESULT(vartype)
852TYPE(vol7d_var),INTENT(in) :: this
853INTEGER :: vartype
854
855INTEGER :: i
856
857vartype = imiss
858
859IF (ALLOCATED(var_features)) THEN
860 DO i = 1, SIZE(var_features)
861 IF (this == var_features(i)%var) THEN
862 vartype = var_features(i)%vartype
863 RETURN
864 ENDIF
865 ENDDO
866ENDIF
867
868END FUNCTION vol7d_var_features_vartype
869
870
881ELEMENTAL SUBROUTINE vol7d_var_features_posdef_apply(this, val)
882TYPE(vol7d_var),INTENT(in) :: this
883REAL,INTENT(inout) :: val
884
885INTEGER :: i
886
887IF (ALLOCATED(var_features)) THEN
888 DO i = 1, SIZE(var_features)
889 IF (this == var_features(i)%var) THEN
890 IF (c_e(var_features(i)%posdef)) val = max(var_features(i)%posdef, val)
891 RETURN
892 ENDIF
893 ENDDO
894ENDIF
895
896END SUBROUTINE vol7d_var_features_posdef_apply
897
898
903ELEMENTAL FUNCTION vol7d_vartype(this) RESULT(vartype)
904TYPE(vol7d_var),INTENT(in) :: this
905
906INTEGER :: vartype
907
908vartype = var_ord
909SELECT CASE(this%btable)
910CASE('B01012', 'B11001', 'B11043', 'B22001') ! direction, degree true
911 vartype = var_dir360
912CASE('B07004', 'B10004', 'B10051', 'B10060') ! pressure, Pa
913 vartype = var_press
914CASE('B11003', 'B11200') ! u-component
915 vartype = var_ucomp
916CASE('B11004', 'B11201') ! v-component
917 vartype = var_vcomp
918CASE('B11005', 'B11006') ! w-component
919 vartype = var_wcomp
920END SELECT
921
922END FUNCTION vol7d_vartype
923
924
925#include "array_utilities_inc.F90"
926
927
928END MODULE vol7d_var_class
Distruttore per la classe vol7d_var.
display on the screen a brief content of object
Costruttore per la classe vol7d_var.
Utilities for managing files.
Definition of constants to be used for declaring variables of a desired type.
Definition: kinds.F90:251
Definitions of constants and functions for working with missing values.
Classe per la gestione delle variabili osservate da stazioni meteo e affini.
Definisce una variabile meteorologica osservata o un suo attributo.

Generated with Doxygen.