<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.bwhpc.de/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=K+Kuck</id>
	<title>bwHPC Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.bwhpc.de/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=K+Kuck"/>
	<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/e/Special:Contributions/K_Kuck"/>
	<updated>2026-04-15T00:54:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R/terra&amp;diff=15519</id>
		<title>BwUniCluster3.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R/terra&amp;diff=15519"/>
		<updated>2025-11-25T14:48:18Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: Created page with &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.5.1!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;  = General information = [https://rspatial.github.io/terra/ &amp;#039;&amp;#039;&amp;#039;terra&amp;#039;&amp;#039;&amp;#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.  [https://github.com/r-spatial/sf &amp;#039;&amp;#039;&amp;#039;sf&amp;#039;&amp;#039;&amp;#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.  In order to install those, we need to fulfill the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.5.1!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&lt;br /&gt;
CXXFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17 -fPIC&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17 -fPIC&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/python/3.13.3-gnu-14.2&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 14.2 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the Python 3.13.3 module is missing some required packages, we install them in a virtual environment in &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We create a virtual environment &amp;quot;terra&amp;quot; for additional dependencies&lt;br /&gt;
python3.13 -m venv terra&lt;br /&gt;
source terra/bin/activate&lt;br /&gt;
python -m pip install --upgrade pip&lt;br /&gt;
pip install numpy setuptools ruamel.yaml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them:&lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.7.0&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.4.4&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.12.0&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.14.1&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
UDUNITS_VER=2.2.28&lt;br /&gt;
&lt;br /&gt;
wget https://downloads.unidata.ucar.edu/udunits/$UDUNITS_VER/udunits-$UDUNITS_VER.tar.gz&lt;br /&gt;
tar -xzf udunits-$UDUNITS_VER.tar.gz&lt;br /&gt;
cd udunits-$UDUNITS_VER&lt;br /&gt;
&lt;br /&gt;
./configure --prefix=&amp;quot;$HOME/sw/R&amp;quot;&lt;br /&gt;
make -j 8&lt;br /&gt;
make check -j 8&lt;br /&gt;
make install&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$HOME/sw/R/lib:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS+=-I$HOME/sw/R/include&lt;br /&gt;
#export CXXFLAGS+=-I$HOME/sw/R/include&lt;br /&gt;
export UDUNITS2_INCLUDE=$HOME/sw/R/include&lt;br /&gt;
export UDUNITS2_LIBS=$HOME/sw/R/lib&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;, type = &amp;quot;source&amp;quot;, configure.args = c(&amp;quot;--with-udunits2-include=$HOME/sw/R/include&amp;quot;, &amp;quot;--with-udunits2-lib=$HOME/sw/R/lib&amp;quot;))&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparations to use the terra and sf packages =&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib:$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
export UDUNITS2_LIBS=$HOME/sw/R/lib&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to  use them in an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;br /&gt;
&lt;br /&gt;
Furthermore, Python 3.13 and the virtual environment terra (created above) should be loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load devel/python/3.13.3-gnu-14.2&lt;br /&gt;
source terra/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, R can be loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.5.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15518</id>
		<title>BwUniCluster3.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15518"/>
		<updated>2025-11-25T14:25:40Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing&lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a free and open-source statistical programming environment based on S, originally developed by John Chambers and colleagues at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) in the 1970s. R can be considered a modern implementation of S and is known to be highly backward-compatible, meaning that code developed in a previous version will still run in a new version.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) techniques and is highly extensible through packages.&lt;br /&gt;
&lt;br /&gt;
Furthermore, R allows to produce well-designed publication-quality plots, including mathematical symbols and formulae, where needed.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation&#039;s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), as well as Windows and macOS.&lt;br /&gt;
&lt;br /&gt;
= Use R on bwUniCluster 3.0 =&lt;br /&gt;
The &#039;&#039;&#039;centrally maintained R module(s)&#039;&#039;&#039; should be &#039;&#039;&#039;preferred&#039;&#039;&#039; over alternatives like Conda or containerized setups when the &#039;&#039;&#039;computational performance is of major concern&#039;&#039;&#039;. The R installation(s) provided by these module(s) are built and optimized for the specific architecture and libraries of the cluster (e.g., OpenBLAS, MPI).&lt;br /&gt;
&lt;br /&gt;
By contrast, if the &#039;&#039;&#039;focus&#039;&#039;&#039; is on &#039;&#039;&#039;portability&#039;&#039;&#039; of a data analytical workflow and &#039;&#039;&#039;maintaining many (external) dependencies&#039;&#039;&#039;, &#039;&#039;&#039;containerized setups&#039;&#039;&#039; or &#039;&#039;&#039;Conda&#039;&#039;&#039; may provide useful alternatives to the native R installation.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the R installation also provides the standalone library &amp;lt;code&amp;gt;libRmath&amp;lt;/code&amp;gt;. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Loading the R software module ==&lt;br /&gt;
It is generally recommended to load a specific version of R, e.g.,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$  module load math/R/4.4.2-openblas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in data-analytical workflows instead of the default version which may change from time to time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One option for doing this is from within an interactive R session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies&lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as&lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions.&lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
&lt;br /&gt;
== Installation instructions for selected R packages ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions for building selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.5.1 (the current default version)&#039;&#039;&#039;. Please write a [https://www.bwhpc.de/supportportal ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster3.0/Software/R/Rjags]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15160</id>
		<title>BwUniCluster3.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15160"/>
		<updated>2025-07-17T10:22:46Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing&lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a free and open-source statistical programming environment based on S, originally developed by John Chambers and colleagues at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) in the 1970s. R can be considered a modern implementation of S and is known to be highly backward-compatible, meaning that code developed in a previous version will still run in a new version.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) techniques and is highly extensible through packages.&lt;br /&gt;
&lt;br /&gt;
Furthermore, R allows to produce well-designed publication-quality plots, including mathematical symbols and formulae, where needed.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation&#039;s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), as well as Windows and macOS.&lt;br /&gt;
&lt;br /&gt;
= Use R on bwUniCluster 3.0 =&lt;br /&gt;
The &#039;&#039;&#039;centrally maintained R module(s)&#039;&#039;&#039; should be &#039;&#039;&#039;preferred&#039;&#039;&#039; over alternatives like Conda or containerized setups when the &#039;&#039;&#039;computational performance is of major concern&#039;&#039;&#039;. The R installation(s) provided by these module(s) are built and optimized for the specific architecture and libraries of the cluster (e.g., OpenBLAS, MPI).&lt;br /&gt;
&lt;br /&gt;
By contrast, if the &#039;&#039;&#039;focus&#039;&#039;&#039; is on &#039;&#039;&#039;portability&#039;&#039;&#039; of a data analytical workflow and &#039;&#039;&#039;maintaining many (external) dependencies&#039;&#039;&#039;, &#039;&#039;&#039;containerized setups&#039;&#039;&#039; or &#039;&#039;&#039;Conda&#039;&#039;&#039; may provide useful alternatives to the native R installation.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the R installation also provides the standalone library &amp;lt;code&amp;gt;libRmath&amp;lt;/code&amp;gt;. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Loading the R software module ==&lt;br /&gt;
It is generally recommended to load a specific version of R, e.g.,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$  module load math/R/4.4.2-openblas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in data-analytical workflows instead of the default version which may change from time to time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One option for doing this is from within an interactive R session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies&lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as&lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions.&lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
&lt;br /&gt;
== Installation instructions for selected R packages ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions for building selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.4.2&#039;&#039;&#039;. Please write a [https://www.bwhpc.de/supportportal ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster3.0/Software/R/Rjags]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software&amp;diff=15159</id>
		<title>BwUniCluster3.0/Software</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software&amp;diff=15159"/>
		<updated>2025-07-17T10:21:19Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Environment Modules ==&lt;br /&gt;
Most software is provided as Modules.&lt;br /&gt;
&lt;br /&gt;
Required reading to use: [[BwUniCluster3.0/Software Modules|Software Environment Modules]]&lt;br /&gt;
&lt;br /&gt;
== Available Software ==&lt;br /&gt;
Visit [https://www.bwhpc.de/software.php https://www.bwhpc.de/software.php], select &amp;lt;code&amp;gt;Cluster → bwUniCluster 3.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On cluster: &amp;lt;code&amp;gt;module avail&amp;lt;/code&amp;gt;&lt;br /&gt;
== Software in Containers ==&lt;br /&gt;
&lt;br /&gt;
Instructions for loading software in containers: [[BwUniCluster3.0/Containers]]&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
Documentation for environment modules is available on the cluster: &lt;br /&gt;
* with command &amp;lt;code&amp;gt;module help&amp;lt;/code&amp;gt;&lt;br /&gt;
* examples in &amp;lt;code&amp;gt;$SOFTNAME_EXA_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Documentation in the Wiki ==&lt;br /&gt;
For some software modules, additional documentation is provided here:&lt;br /&gt;
&lt;br /&gt;
{{Special:PrefixIndex/BwUniCluster3.0/Software/|stripprefix=yes}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- * [[bwUniCluster3.0/Software/R | R]]&lt;br /&gt;
** [[bwUniCluster3.0/Software/R/Rjags | RJAGS]]&lt;br /&gt;
---&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=R&amp;diff=15158</id>
		<title>R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=R&amp;diff=15158"/>
		<updated>2025-07-17T10:05:04Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. Please refer to the corresponding cluster-specific page:&lt;br /&gt;
&lt;br /&gt;
* bwUniCluster 3.0: &lt;br /&gt;
** [[BwUniCluster3.0/Software/R | R on bwUniCluster 3.0]]&lt;br /&gt;
* Helix:&lt;br /&gt;
** [[Helix/Software/R | R on Helix]]&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15157</id>
		<title>BwUniCluster3.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15157"/>
		<updated>2025-07-16T16:19:38Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing&lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a free and open-source statistical programming environment based on S, developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues in the 1970s. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R&#039;s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation&#039;s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and macOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Loading the R software module ==&lt;br /&gt;
It is generally recommended to load a specific version of R, e.g.,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$  module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in data-analytical workflows instead of the default version which may change from time to time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One option for doing this is from within an interactive R session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies&lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as&lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions.&lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
&lt;br /&gt;
== Installation instructions for selected R packages ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions for building selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.4.2&#039;&#039;&#039;. Please write a [https://www.bwhpc.de/supportportal ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster3.0/Software/R/Rjags]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15156</id>
		<title>BwUniCluster3.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R&amp;diff=15156"/>
		<updated>2025-07-16T15:37:48Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: Created page with &amp;quot;{{Softwarepage|math/R}}  {| width=600px class=&amp;quot;wikitable&amp;quot; |- ! Description !! Content |- | module load | math/R |- | License | GPL |- | Citing | n/a |- | Links | [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation] |- | Graphical Interface | No |- | Plugins | User dependent |}  = Description =  &amp;#039;&amp;#039;&amp;#039;R&amp;#039;&amp;#039;&amp;#039; is a free and open-source statistical programming environment based on S, developed at Bell Laboratories (formerly AT&amp;amp;T, now...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing&lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a free and open-source statistical programming environment based on S, developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues in the 1970s. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R&#039;s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation&#039;s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and macOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One option for doing this is from within an interactive R session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies&lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as&lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions.&lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use.&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$  module load math/R/4.4.2-openblas&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.4.2&#039;&#039;&#039;. Please write a [https://www.bwhpc.de/supportportal ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster3.0/Software/R/Rjags]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R/Rjags&amp;diff=15078</id>
		<title>BwUniCluster3.0/Software/R/Rjags</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster3.0/Software/R/Rjags&amp;diff=15078"/>
		<updated>2025-07-15T08:20:11Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: Created page with &amp;quot;= General information =  rjags is an R interface to use JAGS, [https://mcmc-jags.sourceforge.io/ Just another Gibbs Sampler], a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation  = Installation instructions = &amp;lt;code&amp;gt;rjags&amp;lt;/code&amp;gt; needs a working JAGS installation. The following instructions will build and install JAGS 4.3.2 to &amp;lt;code&amp;gt;$JAGS_HOME&amp;lt;/code&amp;gt; on bwUniCluster 3.0.  First, in order to compile them on a compute node,...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General information =&lt;br /&gt;
&lt;br /&gt;
rjags is an R interface to use JAGS, [https://mcmc-jags.sourceforge.io/ Just another Gibbs Sampler], a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
&amp;lt;code&amp;gt;rjags&amp;lt;/code&amp;gt; needs a working JAGS installation. The following instructions will build and install JAGS 4.3.2 to &amp;lt;code&amp;gt;$JAGS_HOME&amp;lt;/code&amp;gt; on bwUniCluster 3.0.&lt;br /&gt;
&lt;br /&gt;
First, in order to compile them on a compute node, we obtain an interactive session:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive batch session&lt;br /&gt;
salloc -p dev_cpu -N1 --ntasks-per-node 4 -t 30 --mem=4096&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external dependencies ==&lt;br /&gt;
Then we download and compile JAGS using GCC 11.4:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load math/R&lt;br /&gt;
&lt;br /&gt;
# Set up JAGS installation directory.&lt;br /&gt;
export JAGS_HOME=&amp;quot;$HOME/sw/jags&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Set up source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
cd ~/src&lt;br /&gt;
&lt;br /&gt;
# Download JAGS source.&lt;br /&gt;
wget https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.3.2.tar.gz&lt;br /&gt;
tar -xf JAGS-4.3.2.tar.gz&lt;br /&gt;
rm JAGS-4.3.2.tar.gz&lt;br /&gt;
cd JAGS-4.3.2&lt;br /&gt;
&lt;br /&gt;
# Compile JAGS.&lt;br /&gt;
export CFLAGS=&amp;quot;-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&amp;quot;&lt;br /&gt;
export CXXFLAGS=&amp;quot;-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -std=c++23 -Wno-implicit-function-declaration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
./configure  --prefix=&amp;quot;$JAGS_HOME&amp;quot; --with-blas=&amp;quot;-lopenblas&amp;quot;&lt;br /&gt;
make -j 4&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install &amp;lt;code&amp;gt;rjags&amp;lt;/code&amp;gt; in R ==&lt;br /&gt;
&lt;br /&gt;
=== Preparations ===&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&lt;br /&gt;
CXXFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17 -fPIC&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS+=-O3 -fPIC -malign-data=cacheline -finline-functions -m64 -Wno-implicit-function-declaration&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17 -fPIC&amp;quot; &amp;gt;&amp;gt; $HOME/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install &amp;lt;code&amp;gt;rjags&amp;lt;/code&amp;gt; package ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Set up environment and install JAGS within R session.&lt;br /&gt;
export PKG_CONFIG_PATH=$JAGS_HOME/lib/pkgconfig&lt;br /&gt;
export LD_RUN_PATH=$JAGS_HOME/lib&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;rjags&amp;quot;, configure.args=&amp;quot;--enable-rpath&amp;quot;)&lt;br /&gt;
&amp;gt; library(rjags)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Use &amp;lt;code&amp;gt;rjags&amp;lt;/code&amp;gt;=&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Set up environment&lt;br /&gt;
export JAGS_HOME=&amp;quot;$HOME/sw/jags&amp;quot;&lt;br /&gt;
export PATH=$JAGS_HOME/bin:$PATH&lt;br /&gt;
export PKG_CONFIG_PATH=$JAGS_HOME/lib/pkgconfig&lt;br /&gt;
export LD_RUN_PATH=$JAGS_HOME/lib&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; library(rjags)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13277</id>
		<title>BwUniCluster2.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13277"/>
		<updated>2024-11-25T15:32:39Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing &lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies &lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as &lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir -p ~/R_libs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R_LIBS_USER=&amp;quot;~/R_libs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. &lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. &lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$  module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3 &lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* Rcpp (R 4.4.1 only)&lt;br /&gt;
* RcppEigen (R 4.4.1 only)&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
* &amp;lt;s&amp;gt;cummeRbund&amp;lt;/s&amp;gt; (see [https://wiki.bwhpc.de/e/BwUniCluster2.0/Software/R/cummeRbund &#039;&#039;&#039;installation instructions&#039;&#039;&#039;] below)&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.1.2&#039;&#039;&#039;. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rjags]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rstan]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Glmnet]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/stringi]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/cummeRbund]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Rjags&amp;diff=13119</id>
		<title>BwUniCluster2.0/Software/R/Rjags</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Rjags&amp;diff=13119"/>
		<updated>2024-10-30T16:13:33Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.2.1 (but not R 4.4.1)! We are currently updating our guides for R 4.4.1.&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
rjags is a R interface to use JAGS, [https://mcmc-jags.sourceforge.io/ Just another Gibbs Sampler]. JAGS is a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation&lt;br /&gt;
&lt;br /&gt;
rjags needs a JAGS installation on the side. We recommend to compile via Intel compiler and with the Intel MKL library (Intel Math Kernel Library), which allows JAGS to use various efficient implementations of mathematical computations. These are, as of now, loaded alongside with the module R 4.1.2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the following code, presented in the boxes below, directly into your shell/command line on bwUniCluster &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Load R module&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set up JAGS installation directory &lt;br /&gt;
export JAGS_HOME=$HOME/sw/jags&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Prepare JAGS source directory (if not yet existing) &lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
cd ~/src&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Get JAGS source&lt;br /&gt;
wget https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.3.1.tar.gz&lt;br /&gt;
tar xf JAGS-4.3.1.tar.gz&lt;br /&gt;
cd JAGS-4.3.1&lt;br /&gt;
rm JAGS-4.3.1.tar.gz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Install JAGS &lt;br /&gt;
export CFLAGS=&amp;quot;-O3 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot;&lt;br /&gt;
export CXXFLAGS=&amp;quot;-O3  -std=c++14 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot;&lt;br /&gt;
./configure  --prefix=$JAGS_HOME --with-blas=&amp;quot;-lmkl_rt -lpthread -lm&amp;quot;&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
cd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set up environment&lt;br /&gt;
export PKG_CONFIG_PATH=$JAGS_HOME/lib/pkgconfig&lt;br /&gt;
export LD_RUN_PATH=$JAGS_HOME/lib&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Install rjags package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;rjags&amp;quot;, configure.args=&amp;quot;--enable-rpath&amp;quot;)&lt;br /&gt;
&amp;gt; library(rjags)&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Rstan&amp;diff=13118</id>
		<title>BwUniCluster2.0/Software/R/Rstan</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Rstan&amp;diff=13118"/>
		<updated>2024-10-30T16:08:44Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rstan&amp;lt;/code&amp;gt; provides the R interface for [https://mc-stan.org/ Stan], a platform for statistical modeling and high-performance statistical computation.&lt;br /&gt;
&lt;br /&gt;
To be compatible with our R installation, we recommend to install the development version of rstan.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
&lt;br /&gt;
Please enter the following code, presented in the boxes below, directly in your shell/command line on &#039;&#039;&#039;bwUniCluster2.0&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Within the interactive session, load the R 4.4.1 module and provide configuration information to install the R package &amp;lt;code&amp;gt;v8&amp;lt;/code&amp;gt;, rstan depends on.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load the R software module:&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
# Provide configuration information for the v8 R package&lt;br /&gt;
export DOWNLOAD_STATIC_LIBV8=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R package(s) [takes roughly 20 min] ==&lt;br /&gt;
Now, start &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; and install &amp;lt;code&amp;gt;RStan&amp;lt;/code&amp;gt; using the lines of code below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;remotes&amp;quot;)&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;RcppParallel&amp;quot;)&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;V8&amp;quot;)&lt;br /&gt;
&amp;gt; remotes::install_github(&amp;quot;hsbadr/rstan/StanHeaders@develop&amp;quot;, force = TRUE)&lt;br /&gt;
&amp;gt; remotes::install_github(&amp;quot;hsbadr/rstan/rstan/rstan@develop&amp;quot;, force = TRUE)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing the installation ==&lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(rstan)&lt;br /&gt;
&amp;gt; example(stan_model, package = &amp;quot;rstan&amp;quot;, run.dontrun = TRUE)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Rstan&amp;diff=13117</id>
		<title>BwUniCluster2.0/Software/R/Rstan</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Rstan&amp;diff=13117"/>
		<updated>2024-10-30T13:23:01Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.2.1 (but not R 4.4.1)! We are currently updating our guides for R 4.4.1.&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
rstan provides the R interface for [https://mc-stan.org/ Stan], a platform for statistical modeling and high-performance statistical computation.&lt;br /&gt;
&lt;br /&gt;
To be compatible with our R installation, we recommend to install the development version of rstan.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the following code, presented in the boxes below, directly in your shell/command line on &#039;&#039;&#039;bwUniCluster2.0&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare .R directory (if it does not already exists). This is then filled with information how R should compile the packages (&#039;compilation flags&#039;). These are written (and can be reviewed) into the (text) file Makevars. &lt;br /&gt;
&lt;br /&gt;
If you already have a .R/Makevars file, check whether these flags are already set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this case, skip the following block of five commands. If this is not the case, enter the following commands in your shell (command line).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS=-O3 -fPIC -std=c++14 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS += -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;PKG_CXXFLAGS += -std=c++14 -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation of rstan and its dependencies makes use other libraries (TBB, Threading Building Blocks) which need to be loaded before installation (and R, of course).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge 	&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load devel/tbb/2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation process of rstan and its dependencies (Rcpp) needs input of how to use the TBB module. This is provided via specific environment variables. We also need to provide a further configuration information to install the R package v8 rstan depends on.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export TBB_LIB=$TBB_LIB_DIR&lt;br /&gt;
export TBB_INC=$TBB_INC_DIR&lt;br /&gt;
export TBB_INTERFACE_NEW=&#039;true&#039;&lt;br /&gt;
export DOWNLOAD_STATIC_LIBV8=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R package(s) [takes roughly 20 min] ==&lt;br /&gt;
We can now install rstan (in its development version) and its dependencies within a R session&lt;br /&gt;
&lt;br /&gt;
Consider starting an interactive job for compiling. You need at most 5000MB total memory, e.g. start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -t 30 -n 1 --mem=5000 -p dev_single &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, start R and install &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;remotes&amp;quot;)&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;RcppParallel&amp;quot;)&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;V8&amp;quot;)&lt;br /&gt;
&amp;gt; remotes::install_github(&amp;quot;hsbadr/rstan/StanHeaders@develop&amp;quot;, force = TRUE)&lt;br /&gt;
&amp;gt; remotes::install_github(&amp;quot;hsbadr/rstan/rstan/rstan@develop&amp;quot;, force = TRUE)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(rstan)&lt;br /&gt;
&amp;gt; example(stan_model, package = &amp;quot;rstan&amp;quot;, run.dontrun = TRUE)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparations to use the rstan package = &lt;br /&gt;
To run its applications, rstan compiles new scripts. For this, it again uses TBB, so you need to set the corresponding environment variables whenever you use rstan - as well as to load the R and TBB modules.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For this, we recommend to add the modules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load devel/tbb/2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
as well as the three export commands &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export TBB_LIB=$TBB_LIB_DIR&lt;br /&gt;
export TBB_INC=$TBB_INC_DIR&lt;br /&gt;
export TBB_INTERFACE_NEW=&#039;true&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use rstan or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/cummeRbund&amp;diff=13116</id>
		<title>BwUniCluster2.0/Software/R/cummeRbund</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/cummeRbund&amp;diff=13116"/>
		<updated>2024-10-30T13:20:33Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General information =&lt;br /&gt;
[https://compbio.mit.edu/cummeRbund/ &#039;&#039;&#039;&amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt;&#039;&#039;&#039;] is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package  designed to aid and simplify the task of analyzing Cufflinks RNA-Seq output.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Installing &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From within the interactive session, load R 4.4.1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
The &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; package is not available from CRAN but can be installed from [https://www.bioconductor.org/packages/release/bioc/html/cummeRbund.html &#039;&#039;&#039;BioConductor&#039;&#039;&#039;]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if (!require(&amp;quot;BiocManager&amp;quot;, quietly = TRUE))&lt;br /&gt;
    install.packages(&amp;quot;BiocManager&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
BiocManager::install(&amp;quot;cummeRbund&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
### R code from vignette source &#039;cummeRbund-example-workflow.Rnw&#039;&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 1: init&lt;br /&gt;
###################################################&lt;br /&gt;
options(width=65)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 2: loadLib&lt;br /&gt;
###################################################&lt;br /&gt;
library(cummeRbund)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 3: read&lt;br /&gt;
###################################################&lt;br /&gt;
cuff &amp;lt;- readCufflinks(dir=system.file(&amp;quot;extdata&amp;quot;, package=&amp;quot;cummeRbund&amp;quot;))&lt;br /&gt;
cuff&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 4: model_fit_1&lt;br /&gt;
###################################################&lt;br /&gt;
d&amp;lt;-dispersionPlot(genes(cuff))&lt;br /&gt;
d&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 5: model_fit_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
d&amp;lt;-dispersionPlot(genes(cuff))&lt;br /&gt;
d&lt;br /&gt;
print(d)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 6: rep_boxplot_1&lt;br /&gt;
###################################################&lt;br /&gt;
pBoxRep&amp;lt;-csBoxplot(genes(cuff),replicates=T)&lt;br /&gt;
pBoxRep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 7: rep_dendro_1&lt;br /&gt;
###################################################&lt;br /&gt;
pDendro&amp;lt;-csDendro(genes(cuff),replicates=T)&lt;br /&gt;
pDendro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 8: rep_boxplot_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pBoxRep&amp;lt;-csBoxplot(genes(cuff),replicates=T)&lt;br /&gt;
pBoxRep&lt;br /&gt;
print(pBoxRep)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 9: rep_dendro_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pDendro&amp;lt;-csDendro(genes(cuff),replicates=T)&lt;br /&gt;
pDendro&lt;br /&gt;
print(pDendro)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 10: boxplot_1&lt;br /&gt;
###################################################&lt;br /&gt;
pBox&amp;lt;-csBoxplot(genes(cuff))&lt;br /&gt;
pBox&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 11: boxplot_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pBox&amp;lt;-csBoxplot(genes(cuff))&lt;br /&gt;
pBox&lt;br /&gt;
print(pBox)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 12: diff_exp_genes_1&lt;br /&gt;
###################################################&lt;br /&gt;
sigGeneIds&amp;lt;-getSig(cuff,alpha=0.05,level=&amp;quot;genes&amp;quot;)&lt;br /&gt;
head(sigGeneIds)&lt;br /&gt;
length(sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 13: diff_exp_genes_2&lt;br /&gt;
###################################################&lt;br /&gt;
hESCvsFibroblast.sigGeneIds&amp;lt;-getSig(cuff,&amp;quot;hESC&amp;quot;,&amp;quot;Fibroblasts&amp;quot;,alpha=0.05,level=&amp;quot;genes&amp;quot;)&lt;br /&gt;
head(hESCvsFibroblast.sigGeneIds)&lt;br /&gt;
length(hESCvsFibroblast.sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 14: diff_exp_genes_3&lt;br /&gt;
###################################################&lt;br /&gt;
sigGenes&amp;lt;-getGenes(cuff,sigGeneIds)&lt;br /&gt;
sigGenes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 15: diff_exp_feat_1&lt;br /&gt;
###################################################&lt;br /&gt;
sigGeneIds&amp;lt;-getSig(cuff,alpha=0.05,level=&amp;quot;isoforms&amp;quot;)&lt;br /&gt;
head(sigGeneIds)&lt;br /&gt;
length(sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 16: ind_gene_1&lt;br /&gt;
###################################################&lt;br /&gt;
Pink1&amp;lt;-getGene(cuff,&#039;PINK1&#039;)&lt;br /&gt;
Pink1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13115</id>
		<title>BwUniCluster2.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13115"/>
		<updated>2024-10-30T13:18:15Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Pre-installed R-packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing &lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies &lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as &lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir -p ~/R_libs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R_LIBS_USER=&amp;quot;~/R_libs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. &lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. &lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R/3.6.3&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* Rcpp (R 4.4.1 only)&lt;br /&gt;
* RcppEigen (R 4.4.1 only)&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
* &amp;lt;s&amp;gt;cummeRbund&amp;lt;/s&amp;gt; (see [https://wiki.bwhpc.de/e/BwUniCluster2.0/Software/R/cummeRbund &#039;&#039;&#039;installation instructions&#039;&#039;&#039;] below)&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.1.2&#039;&#039;&#039;. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rjags]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rstan]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Glmnet]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/stringi]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/cummeRbund]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/cummeRbund&amp;diff=13114</id>
		<title>BwUniCluster2.0/Software/R/cummeRbund</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/cummeRbund&amp;diff=13114"/>
		<updated>2024-10-30T13:13:38Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;&amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt;&#039;&#039;&#039;] is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package  designed to aid and simplify the task of analyzing Cufflinks RNA-Seq output.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Installing &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From within the interactive session, load R 4.4.1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
The &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; package is not available from CRAN but can be installed from [https://www.bioconductor.org/packages/release/bioc/html/cummeRbund.html &#039;&#039;&#039;BioConductor&#039;&#039;&#039;]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if (!require(&amp;quot;BiocManager&amp;quot;, quietly = TRUE))&lt;br /&gt;
    install.packages(&amp;quot;BiocManager&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
BiocManager::install(&amp;quot;cummeRbund&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
### R code from vignette source &#039;cummeRbund-example-workflow.Rnw&#039;&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 1: init&lt;br /&gt;
###################################################&lt;br /&gt;
options(width=65)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 2: loadLib&lt;br /&gt;
###################################################&lt;br /&gt;
library(cummeRbund)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 3: read&lt;br /&gt;
###################################################&lt;br /&gt;
cuff &amp;lt;- readCufflinks(dir=system.file(&amp;quot;extdata&amp;quot;, package=&amp;quot;cummeRbund&amp;quot;))&lt;br /&gt;
cuff&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 4: model_fit_1&lt;br /&gt;
###################################################&lt;br /&gt;
d&amp;lt;-dispersionPlot(genes(cuff))&lt;br /&gt;
d&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 5: model_fit_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
d&amp;lt;-dispersionPlot(genes(cuff))&lt;br /&gt;
d&lt;br /&gt;
print(d)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 6: rep_boxplot_1&lt;br /&gt;
###################################################&lt;br /&gt;
pBoxRep&amp;lt;-csBoxplot(genes(cuff),replicates=T)&lt;br /&gt;
pBoxRep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 7: rep_dendro_1&lt;br /&gt;
###################################################&lt;br /&gt;
pDendro&amp;lt;-csDendro(genes(cuff),replicates=T)&lt;br /&gt;
pDendro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 8: rep_boxplot_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pBoxRep&amp;lt;-csBoxplot(genes(cuff),replicates=T)&lt;br /&gt;
pBoxRep&lt;br /&gt;
print(pBoxRep)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 9: rep_dendro_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pDendro&amp;lt;-csDendro(genes(cuff),replicates=T)&lt;br /&gt;
pDendro&lt;br /&gt;
print(pDendro)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 10: boxplot_1&lt;br /&gt;
###################################################&lt;br /&gt;
pBox&amp;lt;-csBoxplot(genes(cuff))&lt;br /&gt;
pBox&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 11: boxplot_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pBox&amp;lt;-csBoxplot(genes(cuff))&lt;br /&gt;
pBox&lt;br /&gt;
print(pBox)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 12: diff_exp_genes_1&lt;br /&gt;
###################################################&lt;br /&gt;
sigGeneIds&amp;lt;-getSig(cuff,alpha=0.05,level=&amp;quot;genes&amp;quot;)&lt;br /&gt;
head(sigGeneIds)&lt;br /&gt;
length(sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 13: diff_exp_genes_2&lt;br /&gt;
###################################################&lt;br /&gt;
hESCvsFibroblast.sigGeneIds&amp;lt;-getSig(cuff,&amp;quot;hESC&amp;quot;,&amp;quot;Fibroblasts&amp;quot;,alpha=0.05,level=&amp;quot;genes&amp;quot;)&lt;br /&gt;
head(hESCvsFibroblast.sigGeneIds)&lt;br /&gt;
length(hESCvsFibroblast.sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 14: diff_exp_genes_3&lt;br /&gt;
###################################################&lt;br /&gt;
sigGenes&amp;lt;-getGenes(cuff,sigGeneIds)&lt;br /&gt;
sigGenes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 15: diff_exp_feat_1&lt;br /&gt;
###################################################&lt;br /&gt;
sigGeneIds&amp;lt;-getSig(cuff,alpha=0.05,level=&amp;quot;isoforms&amp;quot;)&lt;br /&gt;
head(sigGeneIds)&lt;br /&gt;
length(sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 16: ind_gene_1&lt;br /&gt;
###################################################&lt;br /&gt;
Pink1&amp;lt;-getGene(cuff,&#039;PINK1&#039;)&lt;br /&gt;
Pink1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/cummeRbund&amp;diff=13113</id>
		<title>BwUniCluster2.0/Software/R/cummeRbund</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/cummeRbund&amp;diff=13113"/>
		<updated>2024-10-30T13:12:49Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: Created page with &amp;quot;= General information = [https://rspatial.github.io/terra/ &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;] is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package  designed to aid and simplify the task of analyzing Cufflinks RNA-Seq output.   = Installation instructions =  == Preparations ==  Installing &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:  &amp;lt;pre&amp;gt; cat ~/.R/Makevars  CXX14=g++ CXX17=g++ CXX14FLAGS += -std=c++14 C...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;&amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt;&#039;&#039;&#039;] is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package  designed to aid and simplify the task of analyzing Cufflinks RNA-Seq output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
Installing &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From within the interactive session, load R 4.4.1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; package is not available from CRAN but can be installed from [https://www.bioconductor.org/packages/release/bioc/html/cummeRbund.html &#039;&#039;&#039;BioConductor&#039;&#039;&#039;]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if (!require(&amp;quot;BiocManager&amp;quot;, quietly = TRUE))&lt;br /&gt;
    install.packages(&amp;quot;BiocManager&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
BiocManager::install(&amp;quot;cummeRbund&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;CummeRbund&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
### R code from vignette source &#039;cummeRbund-example-workflow.Rnw&#039;&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 1: init&lt;br /&gt;
###################################################&lt;br /&gt;
options(width=65)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 2: loadLib&lt;br /&gt;
###################################################&lt;br /&gt;
library(cummeRbund)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 3: read&lt;br /&gt;
###################################################&lt;br /&gt;
cuff &amp;lt;- readCufflinks(dir=system.file(&amp;quot;extdata&amp;quot;, package=&amp;quot;cummeRbund&amp;quot;))&lt;br /&gt;
cuff&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 4: model_fit_1&lt;br /&gt;
###################################################&lt;br /&gt;
d&amp;lt;-dispersionPlot(genes(cuff))&lt;br /&gt;
d&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 5: model_fit_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
d&amp;lt;-dispersionPlot(genes(cuff))&lt;br /&gt;
d&lt;br /&gt;
print(d)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 6: rep_boxplot_1&lt;br /&gt;
###################################################&lt;br /&gt;
pBoxRep&amp;lt;-csBoxplot(genes(cuff),replicates=T)&lt;br /&gt;
pBoxRep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 7: rep_dendro_1&lt;br /&gt;
###################################################&lt;br /&gt;
pDendro&amp;lt;-csDendro(genes(cuff),replicates=T)&lt;br /&gt;
pDendro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 8: rep_boxplot_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pBoxRep&amp;lt;-csBoxplot(genes(cuff),replicates=T)&lt;br /&gt;
pBoxRep&lt;br /&gt;
print(pBoxRep)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 9: rep_dendro_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pDendro&amp;lt;-csDendro(genes(cuff),replicates=T)&lt;br /&gt;
pDendro&lt;br /&gt;
print(pDendro)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 10: boxplot_1&lt;br /&gt;
###################################################&lt;br /&gt;
pBox&amp;lt;-csBoxplot(genes(cuff))&lt;br /&gt;
pBox&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 11: boxplot_1_plot&lt;br /&gt;
###################################################&lt;br /&gt;
pBox&amp;lt;-csBoxplot(genes(cuff))&lt;br /&gt;
pBox&lt;br /&gt;
print(pBox)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 12: diff_exp_genes_1&lt;br /&gt;
###################################################&lt;br /&gt;
sigGeneIds&amp;lt;-getSig(cuff,alpha=0.05,level=&amp;quot;genes&amp;quot;)&lt;br /&gt;
head(sigGeneIds)&lt;br /&gt;
length(sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 13: diff_exp_genes_2&lt;br /&gt;
###################################################&lt;br /&gt;
hESCvsFibroblast.sigGeneIds&amp;lt;-getSig(cuff,&amp;quot;hESC&amp;quot;,&amp;quot;Fibroblasts&amp;quot;,alpha=0.05,level=&amp;quot;genes&amp;quot;)&lt;br /&gt;
head(hESCvsFibroblast.sigGeneIds)&lt;br /&gt;
length(hESCvsFibroblast.sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 14: diff_exp_genes_3&lt;br /&gt;
###################################################&lt;br /&gt;
sigGenes&amp;lt;-getGenes(cuff,sigGeneIds)&lt;br /&gt;
sigGenes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 15: diff_exp_feat_1&lt;br /&gt;
###################################################&lt;br /&gt;
sigGeneIds&amp;lt;-getSig(cuff,alpha=0.05,level=&amp;quot;isoforms&amp;quot;)&lt;br /&gt;
head(sigGeneIds)&lt;br /&gt;
length(sigGeneIds)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
### code chunk number 16: ind_gene_1&lt;br /&gt;
###################################################&lt;br /&gt;
Pink1&amp;lt;-getGene(cuff,&#039;PINK1&#039;)&lt;br /&gt;
Pink1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13112</id>
		<title>BwUniCluster2.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13112"/>
		<updated>2024-10-30T13:12:33Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Optional packages for R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing &lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies &lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as &lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir -p ~/R_libs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R_LIBS_USER=&amp;quot;~/R_libs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. &lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. &lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R/3.6.3&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* Rcpp (R 4.4.1 only)&lt;br /&gt;
* RcppEigen (R 4.4.1 only)&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
* &amp;lt;s&amp;gt;cummeRbund&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.1.2&#039;&#039;&#039;. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rjags]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rstan]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Glmnet]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/stringi]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/cummeRbund]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13109</id>
		<title>BwUniCluster2.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13109"/>
		<updated>2024-10-30T09:32:47Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Pre-installed R-packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing &lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies &lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as &lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir -p ~/R_libs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R_LIBS_USER=&amp;quot;~/R_libs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. &lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. &lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R/3.6.3&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* Rcpp (R 4.4.1 only)&lt;br /&gt;
* RcppEigen (R 4.4.1 only)&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
* &amp;lt;s&amp;gt;cummeRbund&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.1.2&#039;&#039;&#039;. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rjags]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rstan]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Glmnet]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/stringi]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13108</id>
		<title>BwUniCluster2.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13108"/>
		<updated>2024-10-30T09:32:09Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Pre-installed R-packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing &lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies &lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as &lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir -p ~/R_libs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R_LIBS_USER=&amp;quot;~/R_libs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. &lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. &lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R/3.6.3&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* Rcpp (R 4.4.1 only)&lt;br /&gt;
* RcppEigen (R 4.4.1 only)&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
* &amp;lt;stroke&amp;gt;cummeRbund&amp;lt;/stroke&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.1.2&#039;&#039;&#039;. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rjags]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rstan]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Glmnet]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/stringi]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13107</id>
		<title>BwUniCluster2.0/Software/R</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R&amp;diff=13107"/>
		<updated>2024-10-30T09:30:52Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Pre-installed R-packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Softwarepage|math/R}}&lt;br /&gt;
&lt;br /&gt;
{| width=600px class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Content&lt;br /&gt;
|-&lt;br /&gt;
| module load&lt;br /&gt;
| math/R&lt;br /&gt;
|-&lt;br /&gt;
| License&lt;br /&gt;
| GPL&lt;br /&gt;
|-&lt;br /&gt;
| Citing &lt;br /&gt;
| n/a&lt;br /&gt;
|-&lt;br /&gt;
| Links&lt;br /&gt;
| [http://www.r-project.org/ Homepage] &amp;amp;#124; [http://cran.r-project.org/manuals.html  Documentation]&lt;br /&gt;
|-&lt;br /&gt;
| Graphical Interface&lt;br /&gt;
| No&lt;br /&gt;
|-&lt;br /&gt;
| Plugins&lt;br /&gt;
| User dependent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;R&#039;&#039;&#039; is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&amp;amp;T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.&lt;br /&gt;
&lt;br /&gt;
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.&lt;br /&gt;
&lt;br /&gt;
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.&lt;br /&gt;
&lt;br /&gt;
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the &#039;R Installation and Administration&#039; manual).&lt;br /&gt;
&lt;br /&gt;
== Installing R-Packages into your home folder ==&lt;br /&gt;
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library()                                                                # List preinstalled packages&lt;br /&gt;
&amp;gt; install.packages(&#039;package_name&#039;, repos=&amp;quot;http://cran.r-project.org&amp;quot;)      # Installing your R package and the dependencies &lt;br /&gt;
&amp;gt; library(package_name)                                                    # Loading the package into you R instance&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The package is now installed permanently in your home folder and is available every time you start R. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default R uses a version (and platform) specific path for personal libraries, such as &lt;br /&gt;
&amp;quot;$HOME/R/x86_64-pc-linux-gnu-library/x.y&amp;quot; for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.&lt;br /&gt;
&lt;br /&gt;
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir -p ~/R_libs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R_LIBS_USER=&amp;quot;~/R_libs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. &lt;br /&gt;
&lt;br /&gt;
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. &lt;br /&gt;
&lt;br /&gt;
The drawback is that, whenever switching to a new R release, the personal library stack &#039;&#039;&#039;must&#039;&#039;&#039; be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).&lt;br /&gt;
&lt;br /&gt;
Special care has also to be taken by users who always load the default version, i.e. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ module load math/R/3.6.3&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Pre-installed R-packages ==&lt;br /&gt;
* Rmpi&lt;br /&gt;
* Rcpp (R 4.4.1 only)&lt;br /&gt;
* RcppEigen (R 4.4.1 only)&lt;br /&gt;
* iterators&lt;br /&gt;
* foreach&lt;br /&gt;
* doMPI&lt;br /&gt;
* doParallel&lt;br /&gt;
* -cummeRbund-&lt;br /&gt;
&lt;br /&gt;
== Optional packages for R ==&lt;br /&gt;
&lt;br /&gt;
The following guides provide detailed instructions about how to build selected optional R packages on &#039;&#039;&#039;bwUniCluster&#039;&#039;&#039; for &#039;&#039;&#039;R version 4.1.2&#039;&#039;&#039;. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated.&lt;br /&gt;
&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rgdal]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rjags]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Rstan]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/Glmnet]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/stringi]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]]&lt;br /&gt;
* [[BwUniCluster2.0/Software/R/terra]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13106</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13106"/>
		<updated>2024-10-30T08:48:42Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Install glmnet */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load the R software module:&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13103</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13103"/>
		<updated>2024-10-28T17:28:33Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Install glmnet */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load the R software module:&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;RcppEigen&amp;quot;, configure.vars = &amp;quot;CXXFLAGS=&#039;-O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&#039;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13102</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13102"/>
		<updated>2024-10-28T16:48:59Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load the R software module:&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13101</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13101"/>
		<updated>2024-10-28T16:48:37Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Install &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load the R software module:&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test the installation ==&lt;br /&gt;
As a quick test of the installation of &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; the following lines of code can be run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13100</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13100"/>
		<updated>2024-10-28T16:32:06Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, the appropriate compiler flags can be set by running the following lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Load the R software module, e.g.&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
&lt;br /&gt;
# Prepare .R directory (if it does not already exists)&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
&lt;br /&gt;
# Write the following environment variables to Makevars&lt;br /&gt;
# Skip the 2nd and 3rd commands below if Makevars already consist these variables (1st command shows content of Makevars)&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;, dependencies=TRUE)&lt;br /&gt;
&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13099</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13099"/>
		<updated>2024-10-28T16:28:45Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Load the R software module, e.g.&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
&lt;br /&gt;
# Prepare .R directory (if it does not already exists)&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
&lt;br /&gt;
# Write the following environment variables to Makevars&lt;br /&gt;
# Skip the 2nd and 3rd commands below if Makevars already consist these variables (1st command shows content of Makevars)&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;, dependencies=TRUE)&lt;br /&gt;
&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13098</id>
		<title>BwUniCluster2.0/Software/R/Glmnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/Glmnet&amp;diff=13098"/>
		<updated>2024-10-28T16:28:35Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation instructions =&lt;br /&gt;
&lt;br /&gt;
== Preparations == &lt;br /&gt;
Installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling source code. Therefore, ensure that the following flags are set in &amp;lt;code&amp;gt;$HOME/.R/Makevars&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since installing &amp;lt;code&amp;gt;glmnet&amp;lt;/code&amp;gt; involves compiling, we start an &amp;lt;b&amp;gt;interactive session&amp;lt;/b&amp;gt; on one of the compute nodes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
salloc -n 1 -t 30  -p dev_single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Load the R software module, e.g.&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
&lt;br /&gt;
# Prepare .R directory (if it does not already exists)&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
&lt;br /&gt;
# Write the following environment variables to Makevars&lt;br /&gt;
# Skip the 2nd and 3rd commands below if Makevars already consist these variables (1st command shows content of Makevars)&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Install the glmnet package from within R session&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;glmnet&amp;quot;, dependencies=TRUE)&lt;br /&gt;
&lt;br /&gt;
# Run a quick test&lt;br /&gt;
&amp;gt; library(glmnet)&lt;br /&gt;
&amp;gt; data(QuickStartExample)&lt;br /&gt;
&amp;gt; x &amp;lt;- QuickStartExample$x&lt;br /&gt;
&amp;gt; y &amp;lt;- QuickStartExample$y&lt;br /&gt;
&amp;gt; fit &amp;lt;- glmnet(x, y)&lt;br /&gt;
&amp;gt; print(fit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13097</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13097"/>
		<updated>2024-10-28T16:17:51Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the appropriate flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
We can now install &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; and its dependencies within a R session. To get the most out of &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;, you are strongly encouraged to rely on the custom ICU4C 74.1 implementation bundled with &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;stringi&amp;quot;, configure.args=&amp;quot;--disable-pkg-config&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures maximum portability across all platforms (Windows and macOS users fetch the pre-compiled binaries from CRAN built precisely this way).&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13096</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13096"/>
		<updated>2024-10-28T16:04:43Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Testing the installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! We are currently updating our guides for R 4.3.3. &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the appropriate flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
We can now install &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; and its dependencies within a R session. To get the most out of &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;, you are strongly encouraged to rely on the custom ICU4C 74.1 implementation bundled with &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;stringi&amp;quot;, configure.args=&amp;quot;--disable-pkg-config&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures maximum portability across all platforms (Windows and macOS users fetch the pre-compiled binaries from CRAN built precisely this way).&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13095</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13095"/>
		<updated>2024-10-28T16:04:08Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Install the R package */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! We are currently updating our guides for R 4.3.3. &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the appropriate flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
We can now install &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; and its dependencies within a R session. To get the most out of &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;, you are strongly encouraged to rely on the custom ICU4C 74.1 implementation bundled with &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;stringi&amp;quot;, configure.args=&amp;quot;--disable-pkg-config&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures maximum portability across all platforms (Windows and macOS users fetch the pre-compiled binaries from CRAN built precisely this way).&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that you always need to load&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13094</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13094"/>
		<updated>2024-10-28T16:03:28Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Installing the R package */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! We are currently updating our guides for R 4.3.3. &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the appropriate flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R package ==&lt;br /&gt;
We can now install &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; and its dependencies within a R session. To get the most out of &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;, you are strongly encouraged to rely on the custom ICU4C 74.1 implementation bundled with &amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;stringi&amp;quot;, configure.args=&amp;quot;--disable-pkg-config&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures maximum portability across all platforms (Windows and macOS users fetch the pre-compiled binaries from CRAN built precisely this way).&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that you always need to load&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13093</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13093"/>
		<updated>2024-10-28T16:00:48Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! We are currently updating our guides for R 4.3.3. &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the appropriate flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R package ==&lt;br /&gt;
We can now install stringi (in its development version) and its dependencies within a R session&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;stringi&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that you always need to load&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13092</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13092"/>
		<updated>2024-10-28T15:58:14Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! We are currently updating our guides for R 4.3.3. &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case, skip the following block of five commands. If this is not the case, enter the following commands in your shell (command line).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS=-O3 -fPIC -std=c++14 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS += -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;PKG_CXXFLAGS += -std=c++14 -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation of stringi makes use other libraries ([https://icu.unicode.org/ C/C++ and Java libraries for Unicode and globalization], icu4c Intel) which need to be loaded before installation (and R, of course).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge 	&lt;br /&gt;
module load math/R&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R package ==&lt;br /&gt;
We can now install stringi (in its development version) and its dependencies within a R session&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;stringi&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that you always need to load&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13091</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13091"/>
		<updated>2024-10-28T15:57:07Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! We are currently updating our guides for R 4.3.3. &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++ &lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case, skip the following block of five commands. If this is not the case, enter the following commands in your shell (command line).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS=-O3 -fPIC -std=c++14 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS += -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;PKG_CXXFLAGS += -std=c++14 -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation of stringi makes use other libraries ([https://icu.unicode.org/ C/C++ and Java libraries for Unicode and globalization], icu4c Intel) which need to be loaded before installation (and R, of course).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge 	&lt;br /&gt;
module load math/R&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installing the R package ==&lt;br /&gt;
We can now install stringi (in its development version) and its dependencies within a R session&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;stringi&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that you always need to load&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13090</id>
		<title>BwUniCluster2.0/Software/R/stringi</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/stringi&amp;diff=13090"/>
		<updated>2024-10-28T15:52:46Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.2.1 (but not R 4.3.3)! We are currently updating our guides for R 4.3.3.&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;stringi&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare .R directory (if it does not already exists). This is then filled with information how R should compile the packages (&#039;compiler flags&#039;). These are written (and can be reviewed) into the (text) file Makevars. &lt;br /&gt;
&lt;br /&gt;
If you already have a .R/Makevars file, check whether these flags are already set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this case, skip the following block of five commands. If this is not the case, enter the following commands in your shell (command line).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=icpc&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS=-O3 -fPIC -std=c++14 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS=-O3 -fPIC -std=c++17 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS += -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;PKG_CXXFLAGS += -std=c++14 -wd308&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation of stringi makes use other libraries ([https://icu.unicode.org/ C/C++ and Java libraries for Unicode and globalization], icu4c Intel) which need to be loaded before installation (and R, of course).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module purge 	&lt;br /&gt;
module load math/R&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installing the R package ==&lt;br /&gt;
We can now install stringi (in its development version) and its dependencies within a R session&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R -q&lt;br /&gt;
&amp;gt; install.packages(&amp;quot;stringi&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing the installation == &lt;br /&gt;
&lt;br /&gt;
To check whether the installation worked, make a test run in R&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; library(stringi)&lt;br /&gt;
&amp;gt; stri_length(c(&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;!&amp;quot;))&lt;br /&gt;
[1] 5 5 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that you always need to load&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.1.2&lt;br /&gt;
module load lib/icu4c/74.1_intel2021.4.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13089</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13089"/>
		<updated>2024-10-28T15:44:17Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them:&lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparations to use the terra and sf packages =&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to  use them in an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13088</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13088"/>
		<updated>2024-10-28T15:43:37Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them:&lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to  use them in an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13087</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13087"/>
		<updated>2024-10-28T15:42:59Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to  use them in an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13086</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13086"/>
		<updated>2024-10-28T15:42:23Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to  use them in an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13085</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13085"/>
		<updated>2024-10-28T15:40:59Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations to use the terra and sf packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to  use them in an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13084</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13084"/>
		<updated>2024-10-28T15:40:23Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations to use the terra and sf packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13083</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13083"/>
		<updated>2024-10-28T15:39:04Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Installing the R packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13082</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13082"/>
		<updated>2024-10-28T15:38:30Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Install GEOS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13081</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13081"/>
		<updated>2024-10-28T15:38:08Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Install GEOS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last external package that needs to be compiled and installed is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13080</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13080"/>
		<updated>2024-10-28T15:36:29Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last package that needs to be compiled is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13079</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13079"/>
		<updated>2024-10-28T15:35:40Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ensure that the ~/.R/Makevars file has the following lines:&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last package that needs to be compiled is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13078</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13078"/>
		<updated>2024-10-28T15:35:20Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session with multiple cores (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exists). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ensure that the ~/.R/Makevars file has the following lines:&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last package that needs to be compiled is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13077</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13077"/>
		<updated>2024-10-28T15:34:52Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exists). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ensure that the ~/.R/Makevars file has the following lines:&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last package that needs to be compiled is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13076</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13076"/>
		<updated>2024-10-28T15:33:02Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Installing the R packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exists). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ensure that the ~/.R/Makevars file has the following lines:&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last package that needs to be compiled is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
	<entry>
		<id>https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13075</id>
		<title>BwUniCluster2.0/Software/R/terra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bwhpc.de/wiki/index.php?title=BwUniCluster2.0/Software/R/terra&amp;diff=13075"/>
		<updated>2024-10-28T15:31:19Z</updated>

		<summary type="html">&lt;p&gt;K Kuck: /* Installing the R packages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! UNDER CONSTRUCTION!!!&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= General information =&lt;br /&gt;
[https://rspatial.github.io/terra/ &#039;&#039;&#039;terra&#039;&#039;&#039;] is a R package for spatial data analysis with vectors (points, lines, polygons) and raster (grid) data.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/r-spatial/sf &#039;&#039;&#039;sf&#039;&#039;&#039;] is a R package that provides [https://en.wikipedia.org/wiki/Simple_Features simple feature] access for R.&lt;br /&gt;
&lt;br /&gt;
In order to install those, we need to fulfill the following [https://cran.r-project.org/web/packages/terra/index.html system requirements]:&lt;br /&gt;
* [https://gdal.org/ GDAL] 2.2.3 or higher&lt;br /&gt;
* [https://proj.org/ PROJ] 4.9.3 or higher&lt;br /&gt;
* [https://libgeos.org/ GEOS] 3.4.0 or higher&lt;br /&gt;
&lt;br /&gt;
These packages are not available centrally on the cluster, but can be installed manually (to the &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;-directory). Specifically, to install these packages, they need to be built from source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Please enter (or copy &amp;amp; paste) the code, presented in the boxes below, directly into your shell/command line on bwUniCluster. The whole process will take approximately 45 minutes.&lt;br /&gt;
&lt;br /&gt;
First, for compilation we obtain an interactive session (on a compute node):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Obtain interactive session&lt;br /&gt;
salloc -n 8 -t 60 -p single&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
Prepare an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file (if it does not already exists). This file specifies how R should compile the packages (i.e., sets some &#039;compiler flags&#039;).&lt;br /&gt;
&lt;br /&gt;
If an &amp;lt;code&amp;gt;.R/Makevars&amp;lt;/code&amp;gt; file is present in your home directory (&amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;), check whether the flags displayed below are already set and apply adjustments, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ensure that the ~/.R/Makevars file has the following lines:&lt;br /&gt;
cat $HOME/.R/Makevars&lt;br /&gt;
&lt;br /&gt;
CXX14=g++&lt;br /&gt;
CXX17=g++&lt;br /&gt;
CXX14FLAGS += -std=c++14&lt;br /&gt;
CXX17FLAGS += -std=c++17&lt;br /&gt;
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please run the following lines of code to set the flags, if necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~/.R&lt;br /&gt;
echo &amp;quot;CXX14=g++&amp;quot; &amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17=g++&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX14FLAGS += -std=c++14&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
echo &amp;quot;CXX17FLAGS += -std=c++17&amp;quot; &amp;gt;&amp;gt; ~/.R/Makevars&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we create the directories for the source code and installation targets, respectively. Furthermore, we load all (software) modules relevant for compilation and ensure that the compilers are found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# We install the libraries into the ~/sw/R directory.&lt;br /&gt;
mkdir -p ~/sw/R&lt;br /&gt;
&lt;br /&gt;
# Source directory.&lt;br /&gt;
mkdir -p ~/src&lt;br /&gt;
&lt;br /&gt;
# Load required modules.&lt;br /&gt;
module purge&lt;br /&gt;
module load devel/cmake/3.29.3&lt;br /&gt;
module load devel/python/3.12.3_gnu_13.3&lt;br /&gt;
&lt;br /&gt;
# Check that the GNU compiler 13.3 is loaded.&lt;br /&gt;
gcc --version&lt;br /&gt;
&lt;br /&gt;
# Set compiler for cmake and make.&lt;br /&gt;
export CC=$(which gcc)&lt;br /&gt;
export CXX=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Python 3.12.3 module is missing some required packages which are included in the Python default module. Therefore, we install them in the user environment:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pip3 install --user numpy setuptools&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Install external programs ==&lt;br /&gt;
&lt;br /&gt;
First, we download the sources of GDAL, PROJ, GEOS (and their dependencies) and install them: &lt;br /&gt;
&lt;br /&gt;
=== Install PROJ ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the PROJ source code:&lt;br /&gt;
PROJ_VER=9.4.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz&lt;br /&gt;
tar xf proj-$PROJ_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd proj-$PROJ_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile and install PROJ:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GDAL ===&lt;br /&gt;
Building GDAL requires newer versions of &amp;lt;code&amp;gt;OpenEXR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;libdeflate&amp;lt;/code&amp;gt; then available on the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the libdeflate source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
git clone https://github.com/ebiggers/libdeflate&lt;br /&gt;
&lt;br /&gt;
cd libdeflate&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile libdeflate&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Download and unpack the OpenEXR source code:&lt;br /&gt;
OPENEXR_VER=3.3.1&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
wget https://github.com/AcademySoftwareFoundation/openexr/releases/download/v$OPENEXR_VER/openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
tar xf openexr-$OPENEXR_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd openexr-$OPENEXR_VER/&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile OpenEXR:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, all necessary dependencies are available and we can build &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GDAL source code:&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GDAL_VER=3.9.3&lt;br /&gt;
wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz&lt;br /&gt;
tar xf gdal-$GDAL_VER.tar.gz&lt;br /&gt;
&lt;br /&gt;
cd gdal-$GDAL_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
cmake --build . -j 8&lt;br /&gt;
cmake --build . --target install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install GEOS ===&lt;br /&gt;
&lt;br /&gt;
The last package that needs to be compiled is GEOS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Download and unpack the GEOS source code.&lt;br /&gt;
cd $HOME/src&lt;br /&gt;
GEOS_VER=3.13.0&lt;br /&gt;
wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2&lt;br /&gt;
tar xf geos-$GEOS_VER.tar.bz2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd geos-$GEOS_VER&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
&lt;br /&gt;
# Compile GEOS:&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_PREFIX_PATH=&amp;quot;$HOME/sw/R&amp;quot; \&lt;br /&gt;
      -DCMAKE_BUILD_TYPE=Release ..&lt;br /&gt;
make -j 8&lt;br /&gt;
ctest -j 8&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing the R packages ==&lt;br /&gt;
&lt;br /&gt;
In order to install the two R packages, we need to inform R where to find &amp;lt;code&amp;gt;PROJ&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GDAL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;GEOS&amp;lt;/code&amp;gt;, so we export the necessary paths: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options (&#039;compiler flags&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export CFLAGS=-I$HOME/sw/R/include&lt;br /&gt;
export CXX=&amp;quot;{$(which g++)} -std=c++11&amp;quot;&lt;br /&gt;
export CXX17=$(which g++)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we install &amp;lt;code&amp;gt;terra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sf&amp;lt;/code&amp;gt; from within &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R -q&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;terra&amp;quot;)&lt;br /&gt;
R&amp;gt; library(terra)&lt;br /&gt;
terra 1.7.83&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
R&amp;gt; install.packages(&amp;quot;sf&amp;quot;)&lt;br /&gt;
R&amp;gt; library(sf)&lt;br /&gt;
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preparations to use the terra and sf packages ==&lt;br /&gt;
Since terra and sf depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.&lt;br /&gt;
&lt;br /&gt;
We recommend to add the export commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LD_LIBRARY_PATH=$HOME/sw/R/lib64:$LD_LIBRARY_PATH&lt;br /&gt;
export PATH=$PATH:$HOME/sw/R/bin&lt;br /&gt;
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib64/pkgconfig&lt;br /&gt;
export GDAL_DATA=$HOME/sw/R/share/gdal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use terra and sf or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]].&lt;/div&gt;</summary>
		<author><name>K Kuck</name></author>
	</entry>
</feed>