libsim Versione 7.2.4

◆ vol7d_var_features_init()

subroutine vol7d_var_features_init

Initialise the global table of variable features.

This subroutine reads the table of variable features from an external file and stores it in a global array. It has to be called once at the beginning of the program. At the moment it gives access to the information about type of variable and positive definitness. The table is based on the unique bufr-like variable table. The table is contained in the csv file vargrib.csv. It is not harmful to call this subroutine multiple times.

Definizione alla linea 493 del file vol7d_var_class.F90.

494! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
495! authors:
496! Davide Cesari <dcesari@arpa.emr.it>
497! Paolo Patruno <ppatruno@arpa.emr.it>
498
499! This program is free software; you can redistribute it and/or
500! modify it under the terms of the GNU General Public License as
501! published by the Free Software Foundation; either version 2 of
502! the License, or (at your option) any later version.
503
504! This program is distributed in the hope that it will be useful,
505! but WITHOUT ANY WARRANTY; without even the implied warranty of
506! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
507! GNU General Public License for more details.
508
509! You should have received a copy of the GNU General Public License
510! along with this program. If not, see <http://www.gnu.org/licenses/>.
511#include "config.h"
512
517MODULE vol7d_var_class
518USE kinds
521IMPLICIT NONE
522
531TYPE vol7d_var
532 CHARACTER(len=10) :: btable=cmiss
533 CHARACTER(len=65) :: description=cmiss
534 CHARACTER(len=24) :: unit=cmiss
535 INTEGER :: scalefactor=imiss
536
537 INTEGER :: r=imiss
538 INTEGER :: d=imiss
539 INTEGER :: i=imiss
540 INTEGER :: b=imiss
541 INTEGER :: c=imiss
542 INTEGER :: gribhint(4)=imiss
543END TYPE vol7d_var
544
546TYPE(vol7d_var),PARAMETER :: vol7d_var_miss= &
547 vol7d_var(cmiss,cmiss,cmiss,imiss,imiss,imiss,imiss,imiss,imiss, &
548 (/imiss,imiss,imiss,imiss/))
549
553INTERFACE init
554 MODULE PROCEDURE vol7d_var_init
555END INTERFACE
556
559INTERFACE delete
560 MODULE PROCEDURE vol7d_var_delete
561END INTERFACE
562
568INTERFACE OPERATOR (==)
569 MODULE PROCEDURE vol7d_var_eq
570END INTERFACE
571
577INTERFACE OPERATOR (/=)
578 MODULE PROCEDURE vol7d_var_ne, vol7d_var_nesv
579END INTERFACE
580
582INTERFACE c_e
583 MODULE PROCEDURE vol7d_var_c_e
584END INTERFACE
585
586#define VOL7D_POLY_TYPE TYPE(vol7d_var)
587#define VOL7D_POLY_TYPES _var
588#include "array_utilities_pre.F90"
589
591INTERFACE display
592 MODULE PROCEDURE display_var, display_var_vect
593END INTERFACE
594
595
596TYPE vol7d_var_features
597 TYPE(vol7d_var) :: var
598 REAL :: posdef
599 INTEGER :: vartype
600END TYPE vol7d_var_features
601
602TYPE(vol7d_var_features),ALLOCATABLE :: var_features(:)
603
604! constants for vol7d_vartype
605INTEGER,PARAMETER :: var_ord=0
606INTEGER,PARAMETER :: var_dir360=1
607INTEGER,PARAMETER :: var_press=2
608INTEGER,PARAMETER :: var_ucomp=3
609INTEGER,PARAMETER :: var_vcomp=4
610INTEGER,PARAMETER :: var_wcomp=5
611
612
613CONTAINS
614
620elemental SUBROUTINE vol7d_var_init(this, btable, description, unit, scalefactor)
621TYPE(vol7d_var),INTENT(INOUT) :: this
622CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
623CHARACTER(len=*),INTENT(in),OPTIONAL :: description
624CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
625INTEGER,INTENT(in),OPTIONAL :: scalefactor
626
627IF (PRESENT(btable)) THEN
628 this%btable = btable
629ELSE
630 this%btable = cmiss
631 this%description = cmiss
632 this%unit = cmiss
633 this%scalefactor = imiss
634 RETURN
635ENDIF
636IF (PRESENT(description)) THEN
637 this%description = description
638ELSE
639 this%description = cmiss
640ENDIF
641IF (PRESENT(unit)) THEN
642 this%unit = unit
643ELSE
644 this%unit = cmiss
645ENDIF
646if (present(scalefactor)) then
647 this%scalefactor = scalefactor
648else
649 this%scalefactor = imiss
650endif
651
652this%r = -1
653this%d = -1
654this%i = -1
655this%b = -1
656this%c = -1
657
658END SUBROUTINE vol7d_var_init
659
660
661ELEMENTAL FUNCTION vol7d_var_new(btable, description, unit, scalefactor) RESULT(this)
662CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
663CHARACTER(len=*),INTENT(in),OPTIONAL :: description
664CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
665INTEGER,INTENT(in),OPTIONAL :: scalefactor
666
667TYPE(vol7d_var) :: this
668
669CALL init(this, btable, description, unit, scalefactor)
670
671END FUNCTION vol7d_var_new
672
673
675elemental SUBROUTINE vol7d_var_delete(this)
676TYPE(vol7d_var),INTENT(INOUT) :: this
677
678this%btable = cmiss
679this%description = cmiss
680this%unit = cmiss
681this%scalefactor = imiss
682
683END SUBROUTINE vol7d_var_delete
684
685
686ELEMENTAL FUNCTION vol7d_var_eq(this, that) RESULT(res)
687TYPE(vol7d_var),INTENT(IN) :: this, that
688LOGICAL :: res
689
690res = this%btable == that%btable
691
692END FUNCTION vol7d_var_eq
693
694
695ELEMENTAL FUNCTION vol7d_var_ne(this, that) RESULT(res)
696TYPE(vol7d_var),INTENT(IN) :: this, that
697LOGICAL :: res
698
699res = .NOT.(this == that)
700
701END FUNCTION vol7d_var_ne
702
703
704FUNCTION vol7d_var_nesv(this, that) RESULT(res)
705TYPE(vol7d_var),INTENT(IN) :: this, that(:)
706LOGICAL :: res(SIZE(that))
707
708INTEGER :: i
709
710DO i = 1, SIZE(that)
711 res(i) = .NOT.(this == that(i))
712ENDDO
713
714END FUNCTION vol7d_var_nesv
715
716
717
719subroutine display_var(this)
720
721TYPE(vol7d_var),INTENT(in) :: this
722
723print*,"VOL7DVAR: ",this%btable,trim(this%description)," : ",this%unit,&
724 " scale factor",this%scalefactor
725
726end subroutine display_var
727
728
730subroutine display_var_vect(this)
731
732TYPE(vol7d_var),INTENT(in) :: this(:)
733integer :: i
734
735do i=1,size(this)
736 call display_var(this(i))
737end do
738
739end subroutine display_var_vect
740
741FUNCTION vol7d_var_c_e(this) RESULT(c_e)
742TYPE(vol7d_var),INTENT(IN) :: this
743LOGICAL :: c_e
744c_e = this /= vol7d_var_miss
745END FUNCTION vol7d_var_c_e
746
747
756SUBROUTINE vol7d_var_features_init()
757INTEGER :: un, i, n
758TYPE(csv_record) :: csv
759CHARACTER(len=1024) :: line
760
761IF (ALLOCATED(var_features)) RETURN
762
763un = open_package_file('varbufr.csv', filetype_data)
764n=0
765DO WHILE(.true.)
766 READ(un,*,END=100)
767 n = n + 1
768ENDDO
769
770100 CONTINUE
771
772rewind(un)
773ALLOCATE(var_features(n))
774
775DO i = 1, n
776 READ(un,'(A)',END=200)line
777 CALL init(csv, line)
778 CALL csv_record_getfield(csv, var_features(i)%var%btable)
779 CALL csv_record_getfield(csv)
780 CALL csv_record_getfield(csv)
781 CALL csv_record_getfield(csv, var_features(i)%posdef)
782 CALL csv_record_getfield(csv, var_features(i)%vartype)
783 CALL delete(csv)
784ENDDO
785
786200 CONTINUE
787CLOSE(un)
788
789END SUBROUTINE vol7d_var_features_init
790
791
795SUBROUTINE vol7d_var_features_delete()
796IF (ALLOCATED(var_features)) DEALLOCATE(var_features)
797END SUBROUTINE vol7d_var_features_delete
798
799
806ELEMENTAL FUNCTION vol7d_var_features_vartype(this) RESULT(vartype)
807TYPE(vol7d_var),INTENT(in) :: this
808INTEGER :: vartype
809
810INTEGER :: i
811
812vartype = imiss
813
814IF (ALLOCATED(var_features)) THEN
815 DO i = 1, SIZE(var_features)
816 IF (this == var_features(i)%var) THEN
817 vartype = var_features(i)%vartype
818 RETURN
819 ENDIF
820 ENDDO
821ENDIF
822
823END FUNCTION vol7d_var_features_vartype
824
825
836ELEMENTAL SUBROUTINE vol7d_var_features_posdef_apply(this, val)
837TYPE(vol7d_var),INTENT(in) :: this
838REAL,INTENT(inout) :: val
839
840INTEGER :: i
841
842IF (ALLOCATED(var_features)) THEN
843 DO i = 1, SIZE(var_features)
844 IF (this == var_features(i)%var) THEN
845 IF (c_e(var_features(i)%posdef)) val = max(var_features(i)%posdef, val)
846 RETURN
847 ENDIF
848 ENDDO
849ENDIF
850
851END SUBROUTINE vol7d_var_features_posdef_apply
852
853
858ELEMENTAL FUNCTION vol7d_vartype(this) RESULT(vartype)
859TYPE(vol7d_var),INTENT(in) :: this
860
861INTEGER :: vartype
862
863vartype = var_ord
864SELECT CASE(this%btable)
865CASE('B01012', 'B11001', 'B11043', 'B22001') ! direction, degree true
866 vartype = var_dir360
867CASE('B07004', 'B10004', 'B10051', 'B10060') ! pressure, Pa
868 vartype = var_press
869CASE('B11003', 'B11200') ! u-component
870 vartype = var_ucomp
871CASE('B11004', 'B11201') ! v-component
872 vartype = var_vcomp
873CASE('B11005', 'B11006') ! w-component
874 vartype = var_wcomp
875END SELECT
876
877END FUNCTION vol7d_vartype
878
879
880#include "array_utilities_inc.F90"
881
882
883END 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:245
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.