libsim Versione 8.0.0

◆ 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 1731 del file vol7d_dballe_class.F03.

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