libsim Versione 7.1.11

◆ vol7d_var_features_vartype()

elemental integer function vol7d_var_features_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. In order for this to work, the subroutine vol7d_var_features_init has to be preliminary called.

Parametri
[in]thisvol7d_var object to be tested

Definizione alla linea 549 del file vol7d_var_class.F90.

550! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
551! authors:
552! Davide Cesari <dcesari@arpa.emr.it>
553! Paolo Patruno <ppatruno@arpa.emr.it>
554
555! This program is free software; you can redistribute it and/or
556! modify it under the terms of the GNU General Public License as
557! published by the Free Software Foundation; either version 2 of
558! the License, or (at your option) any later version.
559
560! This program is distributed in the hope that it will be useful,
561! but WITHOUT ANY WARRANTY; without even the implied warranty of
562! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
563! GNU General Public License for more details.
564
565! You should have received a copy of the GNU General Public License
566! along with this program. If not, see <http://www.gnu.org/licenses/>.
567#include "config.h"
568
573MODULE vol7d_var_class
574USE kinds
577IMPLICIT NONE
578
587TYPE vol7d_var
588 CHARACTER(len=10) :: btable=cmiss
589 CHARACTER(len=65) :: description=cmiss
590 CHARACTER(len=24) :: unit=cmiss
591 INTEGER :: scalefactor=imiss
592
593 INTEGER :: r=imiss
594 INTEGER :: d=imiss
595 INTEGER :: i=imiss
596 INTEGER :: b=imiss
597 INTEGER :: c=imiss
598 INTEGER :: gribhint(4)=imiss
599END TYPE vol7d_var
600
602TYPE(vol7d_var),PARAMETER :: vol7d_var_miss= &
603 vol7d_var(cmiss,cmiss,cmiss,imiss,imiss,imiss,imiss,imiss,imiss, &
604 (/imiss,imiss,imiss,imiss/))
605
609INTERFACE init
610 MODULE PROCEDURE vol7d_var_init
611END INTERFACE
612
615INTERFACE delete
616 MODULE PROCEDURE vol7d_var_delete
617END INTERFACE
618
624INTERFACE OPERATOR (==)
625 MODULE PROCEDURE vol7d_var_eq
626END INTERFACE
627
633INTERFACE OPERATOR (/=)
634 MODULE PROCEDURE vol7d_var_ne, vol7d_var_nesv
635END INTERFACE
636
638INTERFACE c_e
639 MODULE PROCEDURE vol7d_var_c_e
640END INTERFACE
641
642#define VOL7D_POLY_TYPE TYPE(vol7d_var)
643#define VOL7D_POLY_TYPES _var
644#include "array_utilities_pre.F90"
645
647INTERFACE display
648 MODULE PROCEDURE display_var, display_var_vect
649END INTERFACE
650
651
652TYPE vol7d_var_features
653 TYPE(vol7d_var) :: var
654 REAL :: posdef
655 INTEGER :: vartype
656END TYPE vol7d_var_features
657
658TYPE(vol7d_var_features),ALLOCATABLE :: var_features(:)
659
660! constants for vol7d_vartype
661INTEGER,PARAMETER :: var_ord=0
662INTEGER,PARAMETER :: var_dir360=1
663INTEGER,PARAMETER :: var_press=2
664INTEGER,PARAMETER :: var_ucomp=3
665INTEGER,PARAMETER :: var_vcomp=4
666INTEGER,PARAMETER :: var_wcomp=5
667
668
669CONTAINS
670
676elemental SUBROUTINE vol7d_var_init(this, btable, description, unit, scalefactor)
677TYPE(vol7d_var),INTENT(INOUT) :: this
678CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
679CHARACTER(len=*),INTENT(in),OPTIONAL :: description
680CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
681INTEGER,INTENT(in),OPTIONAL :: scalefactor
682
683IF (PRESENT(btable)) THEN
684 this%btable = btable
685ELSE
686 this%btable = cmiss
687 this%description = cmiss
688 this%unit = cmiss
689 this%scalefactor = imiss
690 RETURN
691ENDIF
692IF (PRESENT(description)) THEN
693 this%description = description
694ELSE
695 this%description = cmiss
696ENDIF
697IF (PRESENT(unit)) THEN
698 this%unit = unit
699ELSE
700 this%unit = cmiss
701ENDIF
702if (present(scalefactor)) then
703 this%scalefactor = scalefactor
704else
705 this%scalefactor = imiss
706endif
707
708this%r = -1
709this%d = -1
710this%i = -1
711this%b = -1
712this%c = -1
713
714END SUBROUTINE vol7d_var_init
715
716
717ELEMENTAL FUNCTION vol7d_var_new(btable, description, unit, scalefactor) RESULT(this)
718CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
719CHARACTER(len=*),INTENT(in),OPTIONAL :: description
720CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
721INTEGER,INTENT(in),OPTIONAL :: scalefactor
722
723TYPE(vol7d_var) :: this
724
725CALL init(this, btable, description, unit, scalefactor)
726
727END FUNCTION vol7d_var_new
728
729
731elemental SUBROUTINE vol7d_var_delete(this)
732TYPE(vol7d_var),INTENT(INOUT) :: this
733
734this%btable = cmiss
735this%description = cmiss
736this%unit = cmiss
737this%scalefactor = imiss
738
739END SUBROUTINE vol7d_var_delete
740
741
742ELEMENTAL FUNCTION vol7d_var_eq(this, that) RESULT(res)
743TYPE(vol7d_var),INTENT(IN) :: this, that
744LOGICAL :: res
745
746res = this%btable == that%btable
747
748END FUNCTION vol7d_var_eq
749
750
751ELEMENTAL FUNCTION vol7d_var_ne(this, that) RESULT(res)
752TYPE(vol7d_var),INTENT(IN) :: this, that
753LOGICAL :: res
754
755res = .NOT.(this == that)
756
757END FUNCTION vol7d_var_ne
758
759
760FUNCTION vol7d_var_nesv(this, that) RESULT(res)
761TYPE(vol7d_var),INTENT(IN) :: this, that(:)
762LOGICAL :: res(SIZE(that))
763
764INTEGER :: i
765
766DO i = 1, SIZE(that)
767 res(i) = .NOT.(this == that(i))
768ENDDO
769
770END FUNCTION vol7d_var_nesv
771
772
773
775subroutine display_var(this)
776
777TYPE(vol7d_var),INTENT(in) :: this
778
779print*,"VOL7DVAR: ",this%btable,trim(this%description)," : ",this%unit,&
780 " scale factor",this%scalefactor
781
782end subroutine display_var
783
784
786subroutine display_var_vect(this)
787
788TYPE(vol7d_var),INTENT(in) :: this(:)
789integer :: i
790
791do i=1,size(this)
792 call display_var(this(i))
793end do
794
795end subroutine display_var_vect
796
797FUNCTION vol7d_var_c_e(this) RESULT(c_e)
798TYPE(vol7d_var),INTENT(IN) :: this
799LOGICAL :: c_e
800c_e = this /= vol7d_var_miss
801END FUNCTION vol7d_var_c_e
802
803
812SUBROUTINE vol7d_var_features_init()
813INTEGER :: un, i, n
814TYPE(csv_record) :: csv
815CHARACTER(len=1024) :: line
816
817IF (ALLOCATED(var_features)) RETURN
818
819un = open_package_file('varbufr.csv', filetype_data)
820n=0
821DO WHILE(.true.)
822 READ(un,*,END=100)
823 n = n + 1
824ENDDO
825
826100 CONTINUE
827
828rewind(un)
829ALLOCATE(var_features(n))
830
831DO i = 1, n
832 READ(un,'(A)',END=200)line
833 CALL init(csv, line)
834 CALL csv_record_getfield(csv, var_features(i)%var%btable)
835 CALL csv_record_getfield(csv)
836 CALL csv_record_getfield(csv)
837 CALL csv_record_getfield(csv, var_features(i)%posdef)
838 CALL csv_record_getfield(csv, var_features(i)%vartype)
839 CALL delete(csv)
840ENDDO
841
842200 CONTINUE
843CLOSE(un)
844
845END SUBROUTINE vol7d_var_features_init
846
847
851SUBROUTINE vol7d_var_features_delete()
852IF (ALLOCATED(var_features)) DEALLOCATE(var_features)
853END SUBROUTINE vol7d_var_features_delete
854
855
862ELEMENTAL FUNCTION vol7d_var_features_vartype(this) RESULT(vartype)
863TYPE(vol7d_var),INTENT(in) :: this
864INTEGER :: vartype
865
866INTEGER :: i
867
868vartype = imiss
869
870IF (ALLOCATED(var_features)) THEN
871 DO i = 1, SIZE(var_features)
872 IF (this == var_features(i)%var) THEN
873 vartype = var_features(i)%vartype
874 RETURN
875 ENDIF
876 ENDDO
877ENDIF
878
879END FUNCTION vol7d_var_features_vartype
880
881
892ELEMENTAL SUBROUTINE vol7d_var_features_posdef_apply(this, val)
893TYPE(vol7d_var),INTENT(in) :: this
894REAL,INTENT(inout) :: val
895
896INTEGER :: i
897
898IF (ALLOCATED(var_features)) THEN
899 DO i = 1, SIZE(var_features)
900 IF (this == var_features(i)%var) THEN
901 IF (c_e(var_features(i)%posdef)) val = max(var_features(i)%posdef, val)
902 RETURN
903 ENDIF
904 ENDDO
905ENDIF
906
907END SUBROUTINE vol7d_var_features_posdef_apply
908
909
914ELEMENTAL FUNCTION vol7d_vartype(this) RESULT(vartype)
915TYPE(vol7d_var),INTENT(in) :: this
916
917INTEGER :: vartype
918
919vartype = var_ord
920SELECT CASE(this%btable)
921CASE('B01012', 'B11001', 'B11043', 'B22001') ! direction, degree true
922 vartype = var_dir360
923CASE('B07004', 'B10004', 'B10051', 'B10060') ! pressure, Pa
924 vartype = var_press
925CASE('B11003', 'B11200') ! u-component
926 vartype = var_ucomp
927CASE('B11004', 'B11201') ! v-component
928 vartype = var_vcomp
929CASE('B11005', 'B11006') ! w-component
930 vartype = var_wcomp
931END SELECT
932
933END FUNCTION vol7d_vartype
934
935
936#include "array_utilities_inc.F90"
937
938
939END 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.