File: keys__iterator__fortran_8_f-example.html

package info (click to toggle)
grib-api 1.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 217,848 kB
  • ctags: 16,929
  • sloc: ansic: 111,244; sh: 14,785; makefile: 5,307; f90: 3,583; perl: 3,160; python: 2,830; yacc: 712; fortran: 468; lex: 330; cpp: 305; awk: 66
file content (99 lines) | stat: -rw-r--r-- 6,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: keys_iterator_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul>
</div>
<h1>keys_iterator_fortran.F</h1>keys_iterator_fortran.F How to get the names of all the keys defined in a message and how to iterate through them.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C 
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C
<a name="l00009"></a>00009 C  Fortran 77 Implementation: keys_iterator
<a name="l00010"></a>00010 C
<a name="l00011"></a>00011 C  Description:
<a name="l00012"></a>00012 C  Example on how to use keys_iterator functions and the
<a name="l00013"></a>00013 C  <a name="a0"></a><a class="code" href="group__keys__iterator.html#gfa22412541f9d2df9680a82371036dbb">grib_keys_iterator</a> structure to <span class="keyword">get</span> all the available
<a name="l00014"></a>00014 C  keys in a message.
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 C  Author: Enrico Fucile
<a name="l00017"></a>00017 C
<a name="l00018"></a>00018 C
<a name="l00019"></a>00019 C
<a name="l00020"></a>00020       program keys_iterator
<a name="l00021"></a>00021       implicit none
<a name="l00022"></a>00022       include 'grib_api_f77.h'
<a name="l00023"></a>00023       character*20 name_space
<a name="l00024"></a>00024       integer kiter,ifile,igrib,iret
<a name="l00025"></a>00025       character*256 key
<a name="l00026"></a>00026       character*256 value
<a name="l00027"></a>00027       character*512 all
<a name="l00028"></a>00028       integer len,strlen
<a name="l00029"></a>00029       integer grib_count
<a name="l00030"></a>00030       len=256
<a name="l00031"></a>00031 
<a name="l00032"></a>00032       ifile=5
<a name="l00033"></a>00033 
<a name="l00034"></a>00034       call grib_check(grib_open_file(ifile,
<a name="l00035"></a>00035      X'../../data/regular_latlon_surface.grib1<span class="charliteral">','</span>r'))
<a name="l00036"></a>00036 
<a name="l00037"></a>00037       grib_count=0
<a name="l00038"></a>00038 C     Loop on all the messages in a file.
<a name="l00039"></a>00039   10  iret=grib_new_from_file(ifile,igrib)
<a name="l00040"></a>00040       if (igrib .eq. -1 )  then
<a name="l00041"></a>00041         if (iret .ne.0) then
<a name="l00042"></a>00042            call grib_check(iret)
<a name="l00043"></a>00043         endif
<a name="l00044"></a>00044         stop
<a name="l00045"></a>00045       endif
<a name="l00046"></a>00046 
<a name="l00047"></a>00047       grib_count=grib_count+1
<a name="l00048"></a>00048       write(*,'("-- GRIB N.",I4," --")') grib_count
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 C     valid name_spaces are ls and mars
<a name="l00051"></a>00051       name_space='ls'
<a name="l00052"></a>00052 C     name_space=' ' to get all the keys */
<a name="l00053"></a>00053 C     name_space=' '
<a name="l00054"></a>00054 
<a name="l00055"></a>00055       call grib_check(
<a name="l00056"></a>00056      Xgrib_keys_iterator_new(igrib,kiter,name_space))
<a name="l00057"></a>00057 C     call grib_check(grib_keys_iterator_skip_read_only(kiter))
<a name="l00058"></a>00058 C     call grib_check(grib_keys_iterator_skip_function(kiter))
<a name="l00059"></a>00059 C     call grib_check(grib_keys_iterator_skip_not_coded(kiter))
<a name="l00060"></a>00060 
<a name="l00061"></a>00061   20  if (<a name="a1"></a><a class="code" href="group__keys__iterator.html#g28f6ac808ecdc324fa3a47bc7b3f6dec">grib_keys_iterator_next</a>(kiter) .ne. 1) goto 10
<a name="l00062"></a>00062 
<a name="l00063"></a>00063       call grib_check(<a name="a2"></a><a class="code" href="group__keys__iterator.html#gec3348471f770965c07964e286249e12">grib_keys_iterator_get_name</a>(kiter,key))
<a name="l00064"></a>00064       call grib_check(<a name="a3"></a><a class="code" href="group__get__set.html#g8aeaf9f930eea1cc0f15e92f18a25053" title="Get a string value from a key, if several keys of the same name are present, the...">grib_get_string</a>(igrib,key,value))
<a name="l00065"></a>00065       all='|' <span class="comment">// trim(key)//'|' //  ' = ' //'|' //  trim(value) // '|' </span>
<a name="l00066"></a>00066       write(*,*) trim(all)
<a name="l00067"></a>00067 
<a name="l00068"></a>00068       goto 20
<a name="l00069"></a>00069 
<a name="l00070"></a>00070       call grib_check(<a name="a4"></a><a class="code" href="group__keys__iterator.html#g79716d2b701c3dbb3d3a8e633f35a40a">grib_keys_iterator_delete</a>(kiter))
<a name="l00071"></a>00071 
<a name="l00072"></a>00072       call grib_check(grib_release(igrib))
<a name="l00073"></a>00073 
<a name="l00074"></a>00074       call grib_check(grib_close_file(ifile))
<a name="l00075"></a>00075 
<a name="l00076"></a>00076       end
<a name="l00077"></a>00077 
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>