libsim Versione 7.2.6

◆ vol7d_dballe_set_var_du()

subroutine, public vol7d_dballe_set_var_du ( type(vol7d) this)

Integra il vettore delle variabili in vol7d con le descrizioni e le unità di misura eventualmente mancanti.

Parametri
thisoggetto vol7d con le variabili da completare

Definizione alla linea 1725 del file vol7d_dballe_class.F03.

1726FUNCTION open_dballe_file(filename, filetype) RESULT(unit)
1727CHARACTER(len=*), INTENT(in) :: filename
1728INTEGER, INTENT(in) :: filetype
1729INTEGER :: unit,i
1730
1731CHARACTER(len=512) :: path
1732
1733unit = -1
1734path=get_dballe_filepath(filename, filetype)
1735IF (path == '') RETURN
1736
1737unit = getunit()
1738IF (unit == -1) RETURN
1739
1740OPEN(unit, file=path, status='old', iostat = i)
1741IF (i == 0) THEN
1742 CALL l4f_log(l4f_info, 'dballe file '//trim(path)//' opened')
1743 RETURN
1744ENDIF
1745
1746CALL l4f_log(l4f_error, 'dballe file '//trim(filename)//' not found')
1747CALL raise_error()
1748unit = -1
1749
1750END FUNCTION open_dballe_file
1751
1752
1753!> \brief Exporta un volume dati a un DSN DB-all.e
1754!!
1755!! Riscrive i dati nel DSN di DB-All.e con la possibilità di attivare
1756!! una serie di filtri.
1757
1758
1759!!! TODO manage attr_only
1760!!! attention template migrated in init
1761!SUBROUTINE vol7d_dballe_export(this, network, coordmin, coordmax,&
1762! timei, timef,level,timerange,var,attr,anavar,anaattr,attr_only,ana,dataonly)
1763
1764SUBROUTINE vol7d_dballe_export_old(this, network, coordmin, coordmax,&
1765 timei, timef,level,timerange,var,attr,anavar,anaattr,ana,dataonly,anaonly,template,attr_only)
1766
1767TYPE(vol7d_dballe),INTENT(inout) :: this !< oggetto contenente il volume e altre info per l'accesso al DSN
1768character(len=network_name_len),INTENT(in),optional :: network !< network da exportare
1769!> coordinate minime e massime che definiscono il
1770!! rettangolo di estrazione per l'esportazione
1771TYPE(geo_coord),INTENT(in),optional :: coordmin,coordmax
1772!>estremi temporali dei dati da esportare
1773TYPE(datetime),INTENT(in),optional :: timei, timef
1774TYPE(vol7d_level),INTENT(in),optional :: level !< livello selezionato per l'esportazione
1775TYPE(vol7d_timerange),INTENT(in),optional :: timerange !< timerange selezionato per l'esportazione
1776!> variabili da exportare secondo la tabella B locale o alias relative a dati, attributi,
1777!! anagrafica e attributi dell'anagrafica
1778CHARACTER(len=*),INTENT(in),OPTIONAL :: var(:),attr(:),anavar(:),anaattr(:)
1779!!$!> permette di riscrivere su un DSN letto precedentemente, modificando solo gli attributi ai dati,
1780!!$!! ottimizzando enormente le prestazioni: gli attributi riscritti saranno quelli con this%data_id definito
1781!!$!! (solitamente ricopiato dall'oggetto letto)
1782!!$logical,intent(in),optional :: attr_only
1783TYPE(vol7d_ana),INTENT(inout),optional :: ana !< identificativo della stazione da exportare
1784logical, intent(in),optional :: dataonly !< set to .true. to export data only
1785logical, intent(in),optional :: anaonly !< set to .true. to export ana only
1786!> specificando category.subcategory.localcategory oppure un alias ("synop", "metar","temp","generic") forza l'exportazione ad uno specifico template BUFR/CREX"
1787!! the special value "generic-frag is used to generate bufr on file where ana data is reported only once at beginning and data in other bufr after
1788character(len=*),intent(in),optional :: template
1789logical, intent(in),optional :: attr_only !< set to .true. to export attr only (no data)
1790
1791
1792type(dbadcv) :: vars,starvars,anavars,anastarvars
1793type(dbafilter) :: filter
1794type(dbacoord) :: mydbacoordmin, mydbacoordmax
1795type(dbaana) :: mydbaana
1796type(dbadatetime) :: mydatetimemin, mydatetimemax
1797type(dbatimerange) :: mydbatimerange
1798type(dbalevel) :: mydbalevel
1799type(dbanetwork) :: mydbanetwork
1800
1801integer :: i
1802LOGICAL :: lattr, lanaattr
1803integer :: nanaattr,nattr,nanavar,nvar
1804
1805
1806 ! ------------- prepare filter options
1807
1808!!
1809!! translate export option for dballe2003 api
1810!!
1811
1812if (present(var)) then
1813 nvar=count(c_e(var))
1814 if (nvar > 0) then
1815 allocate (vars%dcv(nvar))
1816 do i=1,size(var)
1817 if (c_e(var(i)))then
1818 allocate (vars%dcv(i)%dat,source=dbadatac(var(i))) !char is default
1819 end if
1820 end do
1821 end if
1822end if
1823
1824if (present(anavar)) then
1825 nanavar=count(c_e(anavar))
1826 if (nanavar > 0) then
1827 allocate (anavars%dcv(nanavar))
1828 do i=1,size(anavar)
1829 if (c_e(anavar(i)))then
1830 allocate (anavars%dcv(i)%dat,source=dbadatac(anavar(i))) !char is default
1831 end if
1832 end do
1833 end if
1834end if
1835
1836lattr = .false.
1837if (present(attr)) then
1838 nattr=count(c_e(attr))
1839 if (nattr > 0) then
1840 lattr = .true.
1841 allocate (starvars%dcv(nattr))
1842 do i=1,size(attr)
1843 if (c_e(attr(i)))then
1844 allocate (starvars%dcv(i)%dat,source=dbadatac(attr(i))) !char is default
1845 end if
1846 end do
1847 end if
1848end if
1849
1850lanaattr = .false.
1851if (present(anaattr)) then
1852 nanaattr=count(c_e(anaattr))
1853 if (nanaattr > 0) then
1854 lanaattr = .true.
1855 allocate (anastarvars%dcv(nanaattr))
1856 do i=1,size(anaattr)
1857 if (c_e(anaattr(i)))then
1858 allocate (anastarvars%dcv(i)%dat,source=dbadatac(anaattr(i))) !char is default
1859 end if
1860 end do
1861 end if
1862end if
1863
1864
1865 ! like a cast
1866mydbacoordmin=dbacoord()
1867if (present(coordmin)) mydbacoordmin%geo_coord=coordmin
1868mydbacoordmax=dbacoord()
1869if (present(coordmax)) mydbacoordmax%geo_coord=coordmax
1870mydbaana=dbaana()
1871if (present(ana)) mydbaana%vol7d_ana=ana
1872mydatetimemin=dbadatetime()
1873if (present(timei)) mydatetimemin%datetime=timei
1874mydatetimemax=dbadatetime()
1875if (present(timef)) mydatetimemax%datetime=timef
1876mydbatimerange=dbatimerange()
1877if (present(timerange)) mydbatimerange%vol7d_timerange=timerange
1878mydbalevel=dbalevel()
1879if (present(level)) mydbalevel%vol7d_level=level
1880mydbanetwork=dbanetwork()
1881if (present(network)) call init(mydbanetwork%vol7d_network,name=network)
1882
1883!!
1884!! here we have options ready for filter
1885!!
1886filter=dbafilter(coordmin=mydbacoordmin,coordmax=mydbacoordmax,ana=mydbaana, &
1887 datetimemin=mydatetimemin,datetimemax=mydatetimemax, &
1888 timerange=mydbatimerange,level=mydbalevel,network=mydbanetwork,&
1889 vars=vars,starvars=starvars,anavars=anavars,anastarvars=anastarvars,&
1890 dataonly=dataonly,anaonly=anaonly)
1891
1892!!$ print *, "filter:"
1893!!$ call filter%display()
1894
1895call export (this, filter,template,attr_only)
1896
1897end SUBROUTINE vol7d_dballe_export_old
1898
1899
1900subroutine vol7d_dballe_export (this, filter, template, attr_only)
1901
1902TYPE(vol7d_dballe),INTENT(inout) :: this !< oggetto contenente il volume e altre info per l'accesso al DSN
1903type(dbafilter),intent(in) :: filter !< filter o use
1904!> specificando category.subcategory.localcategory oppure un alias ("synop", "metar","temp","generic") forza l'exportazione ad uno specifico template BUFR/CREX"
1905!! the special value "generic-frag is used to generate bufr on file where ana data is reported only once at beginning and data in other bufr after
1906character(len=*),intent(in),optional :: template
1907logical, intent(in),optional :: attr_only !< set to .true. to export attr only (no data)
1908
1909character(len=40) :: ltemplate
1910
1911type(dbametaanddatalist) :: metaanddatal
1912logical :: stat
1913
1914metaanddatal=dbametaanddatalist()
1915
1916call v7d2dba(this%vol7d,metaanddatal)
1917!call metaanddatal%display()
1918
1919!clean memdb
1920if (this%file) call this%handle%remove_all()
1921
1922! using filter here can limit memory use for memdb
1923call metaanddatal%extrude(session=this%handle,filter=filter,attronly=attr_only,template=template)
1924
1925if (this%file) then
1926 !!!!! this if we have written in memdb and now we have to write the file
1927
1928 !filter is already in extrude
1929 !this%handle%set(filter=filter)
1930
1931 ! export to file
1932 !! TODO : revert template from init to export !!!!!!!!!!!!!!!!!!!!!
1933 !!call this%handle%messages_write_next(template)
1934
1935 ! note that you can use unsetall hera because the filter was used in extrude
1936 call filter%dbaset(this%handle)
1937
1938 ltemplate=this%handle%template
1939 if (present(template))then
1940 ltemplate=template
1941 end if
1942
1943 call this%handle%messages_write_next(ltemplate)
1944
1945 !clean memdb
1946 call this%handle%remove_all()
1947
1948end if
1949
1950stat = metaanddatal%delete()
1951
1952end subroutine vol7d_dballe_export
1953
1954
1955subroutine v7d2dba(v7d,metaanddatal)
1956TYPE(vol7d),INTENT(in) :: v7d !!!!!! dovrebbe essere intent(in)
1957type(dbametaanddatalist),intent(inout) :: metaanddatal
1958
1959TYPE(vol7d_serialize_dballe) :: serialize
1960
1961serialize = vol7d_serialize_dballe_new()
1962serialize%anaonly=.true.
1963call serialize%vol7d_serialize_setup(v7d)
1964call serialize%vol7d_serialize_export(metaanddatal)
1965
1966serialize = vol7d_serialize_dballe_new()
1967serialize%dataonly=.true.
1968call serialize%vol7d_serialize_setup(v7d)
1969call serialize%vol7d_serialize_export(metaanddatal)
1970
1971end subroutine v7d2dba
1972
1973
1974end MODULE vol7d_dballe_class
1975
1976!>\example esempio_v7ddballe.f90
1977!!/brief Programma esempio semplice per l'uso di vol7d con DB-All.e
1978!!
1979
1980!>\example esempio_v7ddballe_multi.f90
1981!!/brief Programma esempio per l'uso di vol7d con DB-All.e
1982!!
1983!!Vengono estratte più reti
1984
1985!>\example esempio_v7ddballe_import_export.f90
1986!!\brief Esempio di utilizzo della classe vol7d_dballe_class
1987!!
1988!! Vengono estratti i dati e riscritti in un nuovo DSN
classe per import ed export di volumi da e in DB-All.e

Generated with Doxygen.