libsim Versione 7.1.11

◆ vol7d_vartype()

elemental integer function vol7d_vartype ( type(vol7d_var), intent(in)  this)

Return the physical type of the variable.

Returns a rough classification of the variable depending on the physical parameter it represents. The result is one of the constants vartype_* defined in the module. To be extended.

Parametri
[in]thisvol7d_var object to be tested

Definizione alla linea 601 del file vol7d_var_class.F90.

602! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
603! authors:
604! Davide Cesari <dcesari@arpa.emr.it>
605! Paolo Patruno <ppatruno@arpa.emr.it>
606
607! This program is free software; you can redistribute it and/or
608! modify it under the terms of the GNU General Public License as
609! published by the Free Software Foundation; either version 2 of
610! the License, or (at your option) any later version.
611
612! This program is distributed in the hope that it will be useful,
613! but WITHOUT ANY WARRANTY; without even the implied warranty of
614! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
615! GNU General Public License for more details.
616
617! You should have received a copy of the GNU General Public License
618! along with this program. If not, see <http://www.gnu.org/licenses/>.
619#include "config.h"
620
625MODULE vol7d_var_class
626USE kinds
629IMPLICIT NONE
630
639TYPE vol7d_var
640 CHARACTER(len=10) :: btable=cmiss
641 CHARACTER(len=65) :: description=cmiss
642 CHARACTER(len=24) :: unit=cmiss
643 INTEGER :: scalefactor=imiss
644
645 INTEGER :: r=imiss
646 INTEGER :: d=imiss
647 INTEGER :: i=imiss
648 INTEGER :: b=imiss
649 INTEGER :: c=imiss
650 INTEGER :: gribhint(4)=imiss
651END TYPE vol7d_var
652
654TYPE(vol7d_var),PARAMETER :: vol7d_var_miss= &
655 vol7d_var(cmiss,cmiss,cmiss,imiss,imiss,imiss,imiss,imiss,imiss, &
656 (/imiss,imiss,imiss,imiss/))
657
661INTERFACE init
662 MODULE PROCEDURE vol7d_var_init
663END INTERFACE
664
667INTERFACE delete
668 MODULE PROCEDURE vol7d_var_delete
669END INTERFACE
670
676INTERFACE OPERATOR (==)
677 MODULE PROCEDURE vol7d_var_eq
678END INTERFACE
679
685INTERFACE OPERATOR (/=)
686 MODULE PROCEDURE vol7d_var_ne, vol7d_var_nesv
687END INTERFACE
688
690INTERFACE c_e
691 MODULE PROCEDURE vol7d_var_c_e
692END INTERFACE
693
694#define VOL7D_POLY_TYPE TYPE(vol7d_var)
695#define VOL7D_POLY_TYPES _var
696#include "array_utilities_pre.F90"
697
699INTERFACE display
700 MODULE PROCEDURE display_var, display_var_vect
701END INTERFACE
702
703
704TYPE vol7d_var_features
705 TYPE(vol7d_var) :: var
706 REAL :: posdef
707 INTEGER :: vartype
708END TYPE vol7d_var_features
709
710TYPE(vol7d_var_features),ALLOCATABLE :: var_features(:)
711
712! constants for vol7d_vartype
713INTEGER,PARAMETER :: var_ord=0
714INTEGER,PARAMETER :: var_dir360=1
715INTEGER,PARAMETER :: var_press=2
716INTEGER,PARAMETER :: var_ucomp=3
717INTEGER,PARAMETER :: var_vcomp=4
718INTEGER,PARAMETER :: var_wcomp=5
719
720
721CONTAINS
722
728elemental SUBROUTINE vol7d_var_init(this, btable, description, unit, scalefactor)
729TYPE(vol7d_var),INTENT(INOUT) :: this
730CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
731CHARACTER(len=*),INTENT(in),OPTIONAL :: description
732CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
733INTEGER,INTENT(in),OPTIONAL :: scalefactor
734
735IF (PRESENT(btable)) THEN
736 this%btable = btable
737ELSE
738 this%btable = cmiss
739 this%description = cmiss
740 this%unit = cmiss
741 this%scalefactor = imiss
742 RETURN
743ENDIF
744IF (PRESENT(description)) THEN
745 this%description = description
746ELSE
747 this%description = cmiss
748ENDIF
749IF (PRESENT(unit)) THEN
750 this%unit = unit
751ELSE
752 this%unit = cmiss
753ENDIF
754if (present(scalefactor)) then
755 this%scalefactor = scalefactor
756else
757 this%scalefactor = imiss
758endif
759
760this%r = -1
761this%d = -1
762this%i = -1
763this%b = -1
764this%c = -1
765
766END SUBROUTINE vol7d_var_init
767
768
769ELEMENTAL FUNCTION vol7d_var_new(btable, description, unit, scalefactor) RESULT(this)
770CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
771CHARACTER(len=*),INTENT(in),OPTIONAL :: description
772CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
773INTEGER,INTENT(in),OPTIONAL :: scalefactor
774
775TYPE(vol7d_var) :: this
776
777CALL init(this, btable, description, unit, scalefactor)
778
779END FUNCTION vol7d_var_new
780
781
783elemental SUBROUTINE vol7d_var_delete(this)
784TYPE(vol7d_var),INTENT(INOUT) :: this
785
786this%btable = cmiss
787this%description = cmiss
788this%unit = cmiss
789this%scalefactor = imiss
790
791END SUBROUTINE vol7d_var_delete
792
793
794ELEMENTAL FUNCTION vol7d_var_eq(this, that) RESULT(res)
795TYPE(vol7d_var),INTENT(IN) :: this, that
796LOGICAL :: res
797
798res = this%btable == that%btable
799
800END FUNCTION vol7d_var_eq
801
802
803ELEMENTAL FUNCTION vol7d_var_ne(this, that) RESULT(res)
804TYPE(vol7d_var),INTENT(IN) :: this, that
805LOGICAL :: res
806
807res = .NOT.(this == that)
808
809END FUNCTION vol7d_var_ne
810
811
812FUNCTION vol7d_var_nesv(this, that) RESULT(res)
813TYPE(vol7d_var),INTENT(IN) :: this, that(:)
814LOGICAL :: res(SIZE(that))
815
816INTEGER :: i
817
818DO i = 1, SIZE(that)
819 res(i) = .NOT.(this == that(i))
820ENDDO
821
822END FUNCTION vol7d_var_nesv
823
824
825
827subroutine display_var(this)
828
829TYPE(vol7d_var),INTENT(in) :: this
830
831print*,"VOL7DVAR: ",this%btable,trim(this%description)," : ",this%unit,&
832 " scale factor",this%scalefactor
833
834end subroutine display_var
835
836
838subroutine display_var_vect(this)
839
840TYPE(vol7d_var),INTENT(in) :: this(:)
841integer :: i
842
843do i=1,size(this)
844 call display_var(this(i))
845end do
846
847end subroutine display_var_vect
848
849FUNCTION vol7d_var_c_e(this) RESULT(c_e)
850TYPE(vol7d_var),INTENT(IN) :: this
851LOGICAL :: c_e
852c_e = this /= vol7d_var_miss
853END FUNCTION vol7d_var_c_e
854
855
864SUBROUTINE vol7d_var_features_init()
865INTEGER :: un, i, n
866TYPE(csv_record) :: csv
867CHARACTER(len=1024) :: line
868
869IF (ALLOCATED(var_features)) RETURN
870
871un = open_package_file('varbufr.csv', filetype_data)
872n=0
873DO WHILE(.true.)
874 READ(un,*,END=100)
875 n = n + 1
876ENDDO
877
878100 CONTINUE
879
880rewind(un)
881ALLOCATE(var_features(n))
882
883DO i = 1, n
884 READ(un,'(A)',END=200)line
885 CALL init(csv, line)
886 CALL csv_record_getfield(csv, var_features(i)%var%btable)
887 CALL csv_record_getfield(csv)
888 CALL csv_record_getfield(csv)
889 CALL csv_record_getfield(csv, var_features(i)%posdef)
890 CALL csv_record_getfield(csv, var_features(i)%vartype)
891 CALL delete(csv)
892ENDDO
893
894200 CONTINUE
895CLOSE(un)
896
897END SUBROUTINE vol7d_var_features_init
898
899
903SUBROUTINE vol7d_var_features_delete()
904IF (ALLOCATED(var_features)) DEALLOCATE(var_features)
905END SUBROUTINE vol7d_var_features_delete
906
907
914ELEMENTAL FUNCTION vol7d_var_features_vartype(this) RESULT(vartype)
915TYPE(vol7d_var),INTENT(in) :: this
916INTEGER :: vartype
917
918INTEGER :: i
919
920vartype = imiss
921
922IF (ALLOCATED(var_features)) THEN
923 DO i = 1, SIZE(var_features)
924 IF (this == var_features(i)%var) THEN
925 vartype = var_features(i)%vartype
926 RETURN
927 ENDIF
928 ENDDO
929ENDIF
930
931END FUNCTION vol7d_var_features_vartype
932
933
944ELEMENTAL SUBROUTINE vol7d_var_features_posdef_apply(this, val)
945TYPE(vol7d_var),INTENT(in) :: this
946REAL,INTENT(inout) :: val
947
948INTEGER :: i
949
950IF (ALLOCATED(var_features)) THEN
951 DO i = 1, SIZE(var_features)
952 IF (this == var_features(i)%var) THEN
953 IF (c_e(var_features(i)%posdef)) val = max(var_features(i)%posdef, val)
954 RETURN
955 ENDIF
956 ENDDO
957ENDIF
958
959END SUBROUTINE vol7d_var_features_posdef_apply
960
961
966ELEMENTAL FUNCTION vol7d_vartype(this) RESULT(vartype)
967TYPE(vol7d_var),INTENT(in) :: this
968
969INTEGER :: vartype
970
971vartype = var_ord
972SELECT CASE(this%btable)
973CASE('B01012', 'B11001', 'B11043', 'B22001') ! direction, degree true
974 vartype = var_dir360
975CASE('B07004', 'B10004', 'B10051', 'B10060') ! pressure, Pa
976 vartype = var_press
977CASE('B11003', 'B11200') ! u-component
978 vartype = var_ucomp
979CASE('B11004', 'B11201') ! v-component
980 vartype = var_vcomp
981CASE('B11005', 'B11006') ! w-component
982 vartype = var_wcomp
983END SELECT
984
985END FUNCTION vol7d_vartype
986
987
988#include "array_utilities_inc.F90"
989
990
991END 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.