Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

If you try to load the samples file "gg_ml.tmpl", it can fail because that one is not in the usual samples location but in "ifs_samples". Normally you extend the ECCODES_SAMPLES_PATH to include the ifs_samples directory. But with MEMFS the samples (and also definitions) are not installed (instead they are all embeddedwithin the library.

So for example let's say we have the following Fortran program that loads 2 samples:

HTML
<pre class="hljs" style="display: block; overflow-x: auto; padding: 0.5em; background-color: rgb(240, 240, 240); color: rgb(68, 68, 68);"><span class="hljs-function"><span class="hljs-keyword" style="font-weight: 700;">program</span></span> sample
   <span class="hljs-keyword" style="font-weight: 700;">use</span> eccodes
   <span class="hljs-keyword" style="font-weight: 700;">implicit</span> <span class="hljs-keyword" style="font-weight: 700;">none</span>
   <span class="hljs-keyword" style="font-weight: 700;">integer</span>  :: s1, s2, section4Length
 
   <span class="hljs-comment" style="color: rgb(136, 136, 136);">! Try to load an IFS sample: ifs_samples/grib1_mlgrib2/gg_ml.tmpl</span>
   <span class="hljs-keyword" style="font-weight: 700;">call</span> codes_grib_new_from_samples(s1, <span class="hljs-string" style="color: rgb(136, 0, 0);">"gg_ml"</span>)
   <span class="hljs-keyword" style="font-weight: 700;">call</span> codes_get(s1, <span class="hljs-string" style="color: rgb(136, 0, 0);">'section4Length'</span>, section4Length)
   <span class="hljs-built_in" style="color: rgb(57, 115, 0);">write</span> (*, *) <span class="hljs-string" style="color: rgb(136, 0, 0);">'IFS sample gg_ml:  section4Length='</span>, section4Length
   <span class="hljs-keyword" style="font-weight: 700;">call</span> codes_release(s1)
 
   <span class="hljs-comment" style="color: rgb(136, 136, 136);">! Try to load a core sample: samples/GRIB2.tmpl</span>
   <span class="hljs-keyword" style="font-weight: 700;">call</span> codes_grib_new_from_samples(s2, <span class="hljs-string" style="color: rgb(136, 0, 0);">"GRIB2"</span>)
   <span class="hljs-keyword" style="font-weight: 700;">call</span> codes_get(s2, <span class="hljs-string" style="color: rgb(136, 0, 0);">'section4Length'</span>, section4Length)
   <span class="hljs-built_in" style="color: rgb(57, 115, 0);">write</span> (*, *) <span class="hljs-string" style="color: rgb(136, 0, 0);">'Core sample GRIB2: section4Length='</span>, section4Length
   <span class="hljs-keyword" style="font-weight: 700;">call</span> codes_release(s2)
<span class="hljs-keyword" style="font-weight: 700;">end</span> <span class="hljs-function"><span class="hljs-keyword" style="font-weight: 700;">program</span></span> sample</pre>


Compile and run the program. It should fail:

Code Block
languagetext
% ./sample.exe
ECCODES ERROR   :  Unable to load sample file 'gg_ml.tmpl'
                   from /MEMFS/samples
ECCODES ERROR   :  grib_new_from_samples: (gg_ml) File not found

Solution

Extend the samples path to search in the IFS samples location too (by setting the ECCODES_SAMPLES_PATH environment variable):

Code Block
languagebash
% export ECCODES_SAMPLES_PATH=/MEMFS/ifs_samples/grib1_mlgrib2:/MEMFS/samples
% ./sample.exe
 IFS sample gg_ml:   section4Length=         770
 Core sample GRIB2:  section4Length=          34
 
# Now it works fine


Content by Label
showLabelsfalse
max5
spacesUDOC
showSpacefalse
sortmodified
reversetrue
typepage
excludeCurrenttrue
cqllabel in ("kb-troubleshooting-article","kb-how-to-article") and label = "grib" and label = "memory" and type = "page" and space = "UDOC"
labelskb-how-to-article kb-troubleshooting-article


Page properties
hiddentrue


Related issues