<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/how-to-install-wgrib2-in-osx/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://bovineaerospace.wordpress.com/2017/08/20/how-to-install-wgrib2-in-osx/"> R – Bovine Aerospace</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Prompted by both my own struggles with wgrib2 compilation and a plea on the rNOMADS email listserv, I’m going to describe how to compile and install wgrib2 on Mac OS.</p>
<p>First of all, some background: wgrib2 is an excellent utility written by Wesley Ebisuzaki at NOAA.  It allows for a number of swift and stable operations on GRIB2 files (a common file format for weather and climate data).  It is also a requirement for using grib files in rNOMADS (the function ReadGrib() in particular).</p>
<p>So here’s how to install it on Mac OS.</p>
<ol>
<li> Get Command Line Tools for Xcode (search for it on Duckduckgo or your engine of choice) and also make sure <code>gcc</code> is installed. If you don’t know what <code>gcc</code> is, stop now and find someone who does (it will save you a lot of time).</li>
<li>Download wgrib2 <a rel="nofollow" href="http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/" target="_blank">here</a> (note download links are pretty far down the page).</li>
<li>Untar the tarball somewhere, and roll up your sleeves.  <code>cd</code> into the resulting <code>wgrib</code> directory.</li>
<li> In the makefile, uncomment the lines<br>
<code><br>
#export cc=gcc<br>
#export FC=gfortran<br>
</code>Also search for <code>makefile.darwin</code> in the makefile and uncomment the line containing it.  You’ll see instructions to this effect in the makefile anyway.</li>
<li>Now we have to edit the included <code>libpng</code> package, since it is untarred by the makefile and doesn’t inherit our compiler specifications in step 4. Ensuring that we’re in the <code>wgrib</code> directory:<br>
<code><br>
tar -xvf libpng-1.2.57.tar.gz<br>
cd libpng-1.2.57/scripts/<br>
</code><br>
now edit the <code>makefile.darwin</code> file, changing<br>
<code><br>
CC=cc<br>
</code><br>
to<br>
<code><br>
CC=gcc<br>
</code><br>
Now, return to the <code>wgrib</code> directory, and re-tar libpng!<br>
<code><br>
tar -cf libpng-1.2.57.tar libpng-1.2.57<br>
gzip libpng-1.2.57.tar<br>
</code><br>
If it asks you if you want to replace the original tar.gz file, say “yes”.  What we’ve done here is edited <code>libpng</code> to make sure it uses the right compiler.</li>
<li>Finally, type<code> make</code> to build wgrib2.</li>
</ol>
<p>If you are still having problems (for example, <code>libaec</code> complaining that there is no c compiler), make sure that all the compiler commands (<code>gcc</code>, <code>cc</code>, etc.) all point to something other than <code>clang</code> (the default compiler that comes with OSX).  You may have to edit your <code>bash_profile</code> file to ensure this.</p>
<p>As always, contact me on the form below if you’re having unresolvable issues.</p>
<p>[contact-form]<br> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bovineaerospace.wordpress.com/44781/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/bovineaerospace.wordpress.com/44781/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://bovineaerospace.wordpress.com/2017/08/20/how-to-install-wgrib2-in-osx/"> R – Bovine Aerospace</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/n9DFmlWL1xk" height="1"></a></div>