libsim Versione 7.2.0

◆ display_var()

subroutine display_var ( type(vol7d_var), intent(in)  this)

display on the screen a brief content of vol7d_var object

Parametri
[in]thisvol7d_var object to display

Definizione alla linea 456 del file vol7d_var_class.F90.

457! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
458! authors:
459! Davide Cesari <dcesari@arpa.emr.it>
460! Paolo Patruno <ppatruno@arpa.emr.it>
461
462! This program is free software; you can redistribute it and/or
463! modify it under the terms of the GNU General Public License as
464! published by the Free Software Foundation; either version 2 of
465! the License, or (at your option) any later version.
466
467! This program is distributed in the hope that it will be useful,
468! but WITHOUT ANY WARRANTY; without even the implied warranty of
469! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
470! GNU General Public License for more details.
471
472! You should have received a copy of the GNU General Public License
473! along with this program. If not, see <http://www.gnu.org/licenses/>.
474#include "config.h"
475
480MODULE vol7d_var_class
481USE kinds
484IMPLICIT NONE
485
494TYPE vol7d_var
495 CHARACTER(len=10) :: btable=cmiss
496 CHARACTER(len=65) :: description=cmiss
497 CHARACTER(len=24) :: unit=cmiss
498 INTEGER :: scalefactor=imiss
499
500 INTEGER :: r=imiss
501 INTEGER :: d=imiss
502 INTEGER :: i=imiss
503 INTEGER :: b=imiss
504 INTEGER :: c=imiss
505 INTEGER :: gribhint(4)=imiss
506END TYPE vol7d_var
507
509TYPE(vol7d_var),PARAMETER :: vol7d_var_miss= &
510 vol7d_var(cmiss,cmiss,cmiss,imiss,imiss,imiss,imiss,imiss,imiss, &
511 (/imiss,imiss,imiss,imiss/))
512
516INTERFACE init
517 MODULE PROCEDURE vol7d_var_init
518END INTERFACE
519
522INTERFACE delete
523 MODULE PROCEDURE vol7d_var_delete
524END INTERFACE
525
531INTERFACE OPERATOR (==)
532 MODULE PROCEDURE vol7d_var_eq
533END INTERFACE
534
540INTERFACE OPERATOR (/=)
541 MODULE PROCEDURE vol7d_var_ne, vol7d_var_nesv
542END INTERFACE
543
545INTERFACE c_e
546 MODULE PROCEDURE vol7d_var_c_e
547END INTERFACE
548
549#define VOL7D_POLY_TYPE TYPE(vol7d_var)
550#define VOL7D_POLY_TYPES _var
551#include "array_utilities_pre.F90"
552
554INTERFACE display
555 MODULE PROCEDURE display_var, display_var_vect
556END INTERFACE
557
558
559TYPE vol7d_var_features
560 TYPE(vol7d_var) :: var
561 REAL :: posdef
562 INTEGER :: vartype
563END TYPE vol7d_var_features
564
565TYPE(vol7d_var_features),ALLOCATABLE :: var_features(:)
566
567! constants for vol7d_vartype
568INTEGER,PARAMETER :: var_ord=0
569INTEGER,PARAMETER :: var_dir360=1
570INTEGER,PARAMETER :: var_press=2
571INTEGER,PARAMETER :: var_ucomp=3
572INTEGER,PARAMETER :: var_vcomp=4
573INTEGER,PARAMETER :: var_wcomp=5
574
575
576CONTAINS
577
583elemental SUBROUTINE vol7d_var_init(this, btable, description, unit, scalefactor)
584TYPE(vol7d_var),INTENT(INOUT) :: this
585CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
586CHARACTER(len=*),INTENT(in),OPTIONAL :: description
587CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
588INTEGER,INTENT(in),OPTIONAL :: scalefactor
589
590IF (PRESENT(btable)) THEN
591 this%btable = btable
592ELSE
593 this%btable = cmiss
594 this%description = cmiss
595 this%unit = cmiss
596 this%scalefactor = imiss
597 RETURN
598ENDIF
599IF (PRESENT(description)) THEN
600 this%description = description
601ELSE
602 this%description = cmiss
603ENDIF
604IF (PRESENT(unit)) THEN
605 this%unit = unit
606ELSE
607 this%unit = cmiss
608ENDIF
609if (present(scalefactor)) then
610 this%scalefactor = scalefactor
611else
612 this%scalefactor = imiss
613endif
614
615this%r = -1
616this%d = -1
617this%i = -1
618this%b = -1
619this%c = -1
620
621END SUBROUTINE vol7d_var_init
622
623
624ELEMENTAL FUNCTION vol7d_var_new(btable, description, unit, scalefactor) RESULT(this)
625CHARACTER(len=*),INTENT(in),OPTIONAL :: btable
626CHARACTER(len=*),INTENT(in),OPTIONAL :: description
627CHARACTER(len=*),INTENT(in),OPTIONAL :: unit
628INTEGER,INTENT(in),OPTIONAL :: scalefactor
629
630TYPE(vol7d_var) :: this
631
632CALL init(this, btable, description, unit, scalefactor)
633
634END FUNCTION vol7d_var_new
635
636
638elemental SUBROUTINE vol7d_var_delete(this)
639TYPE(vol7d_var),INTENT(INOUT) :: this
640
641this%btable = cmiss
642this%description = cmiss
643this%unit = cmiss
644this%scalefactor = imiss
645
646END SUBROUTINE vol7d_var_delete
647
648
649ELEMENTAL FUNCTION vol7d_var_eq(this, that) RESULT(res)
650TYPE(vol7d_var),INTENT(IN) :: this, that
651LOGICAL :: res
652
653res = this%btable == that%btable
654
655END FUNCTION vol7d_var_eq
656
657
658ELEMENTAL FUNCTION vol7d_var_ne(this, that) RESULT(res)
659TYPE(vol7d_var),INTENT(IN) :: this, that
660LOGICAL :: res
661
662res = .NOT.(this == that)
663
664END FUNCTION vol7d_var_ne
665
666
667FUNCTION vol7d_var_nesv(this, that) RESULT(res)
668TYPE(vol7d_var),INTENT(IN) :: this, that(:)
669LOGICAL :: res(SIZE(that))
670
671INTEGER :: i
672
673DO i = 1, SIZE(that)
674 res(i) = .NOT.(this == that(i))
675ENDDO
676
677END FUNCTION vol7d_var_nesv
678
679
680
682subroutine display_var(this)
683
684TYPE(vol7d_var),INTENT(in) :: this
685
686print*,"VOL7DVAR: ",this%btable,trim(this%description)," : ",this%unit,&
687 " scale factor",this%scalefactor
688
689end subroutine display_var
690
691
693subroutine display_var_vect(this)
694
695TYPE(vol7d_var),INTENT(in) :: this(:)
696integer :: i
697
698do i=1,size(this)
699 call display_var(this(i))
700end do
701
702end subroutine display_var_vect
703
704FUNCTION vol7d_var_c_e(this) RESULT(c_e)
705TYPE(vol7d_var),INTENT(IN) :: this
706LOGICAL :: c_e
707c_e = this /= vol7d_var_miss
708END FUNCTION vol7d_var_c_e
709
710
719SUBROUTINE vol7d_var_features_init()
720INTEGER :: un, i, n
721TYPE(csv_record) :: csv
722CHARACTER(len=1024) :: line
723
724IF (ALLOCATED(var_features)) RETURN
725
726un = open_package_file('varbufr.csv', filetype_data)
727n=0
728DO WHILE(.true.)
729 READ(un,*,END=100)
730 n = n + 1
731ENDDO
732
733100 CONTINUE
734
735rewind(un)
736ALLOCATE(var_features(n))
737
738DO i = 1, n
739 READ(un,'(A)',END=200)line
740 CALL init(csv, line)
741 CALL csv_record_getfield(csv, var_features(i)%var%btable)
742 CALL csv_record_getfield(csv)
743 CALL csv_record_getfield(csv)
744 CALL csv_record_getfield(csv, var_features(i)%posdef)
745 CALL csv_record_getfield(csv, var_features(i)%vartype)
746 CALL delete(csv)
747ENDDO
748
749200 CONTINUE
750CLOSE(un)
751
752END SUBROUTINE vol7d_var_features_init
753
754
758SUBROUTINE vol7d_var_features_delete()
759IF (ALLOCATED(var_features)) DEALLOCATE(var_features)
760END SUBROUTINE vol7d_var_features_delete
761
762
769ELEMENTAL FUNCTION vol7d_var_features_vartype(this) RESULT(vartype)
770TYPE(vol7d_var),INTENT(in) :: this
771INTEGER :: vartype
772
773INTEGER :: i
774
775vartype = imiss
776
777IF (ALLOCATED(var_features)) THEN
778 DO i = 1, SIZE(var_features)
779 IF (this == var_features(i)%var) THEN
780 vartype = var_features(i)%vartype
781 RETURN
782 ENDIF
783 ENDDO
784ENDIF
785
786END FUNCTION vol7d_var_features_vartype
787
788
799ELEMENTAL SUBROUTINE vol7d_var_features_posdef_apply(this, val)
800TYPE(vol7d_var),INTENT(in) :: this
801REAL,INTENT(inout) :: val
802
803INTEGER :: i
804
805IF (ALLOCATED(var_features)) THEN
806 DO i = 1, SIZE(var_features)
807 IF (this == var_features(i)%var) THEN
808 IF (c_e(var_features(i)%posdef)) val = max(var_features(i)%posdef, val)
809 RETURN
810 ENDIF
811 ENDDO
812ENDIF
813
814END SUBROUTINE vol7d_var_features_posdef_apply
815
816
821ELEMENTAL FUNCTION vol7d_vartype(this) RESULT(vartype)
822TYPE(vol7d_var),INTENT(in) :: this
823
824INTEGER :: vartype
825
826vartype = var_ord
827SELECT CASE(this%btable)
828CASE('B01012', 'B11001', 'B11043', 'B22001') ! direction, degree true
829 vartype = var_dir360
830CASE('B07004', 'B10004', 'B10051', 'B10060') ! pressure, Pa
831 vartype = var_press
832CASE('B11003', 'B11200') ! u-component
833 vartype = var_ucomp
834CASE('B11004', 'B11201') ! v-component
835 vartype = var_vcomp
836CASE('B11005', 'B11006') ! w-component
837 vartype = var_wcomp
838END SELECT
839
840END FUNCTION vol7d_vartype
841
842
843#include "array_utilities_inc.F90"
844
845
846END 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.