Difference between revisions of "Compiling in Linux"

From OSUPDOCS
Jump to navigation Jump to search
(Created page with "This page explains several methods to compile code engines in Linux systems. == Introduction == The <tt>nairn-mpm-fea</tt> code engines can easi...")
 
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page explains several methods to [[Compile the Code Engines|compile code engines]] in Linux systems.
This page explains several command-line methods to [[Compile the Code Engines|compile the code engines]] in Linux or Unix systems.


== Introduction ==
== Introduction ==


The <tt>nairn-mpm-fea</tt> code engines can easily be compiled on any Linux system with a <tt>C++</tt> compiler and with <tt>xerces</tt> already installed. Below are details on specific systems that are already set up for compilation, already have <tt>xerces</tt>, and are currently in use for [[OSParticulas]], [[NairnMPM]], and [[NairnFEA]]. See the section on ][#Other Linux Systems|other systems]] for compilation on other Linux/Unix systems.
The <tt>nairn-mpm-fea</tt> code engines can easily be compiled on any Linux system with a <tt>C++</tt> compiler and with <tt>xerces</tt> already installed. Below are details on specific systems that are already set up for compilation, already have <tt>xerces</tt>, and are currently in use for [[OSParticulas]], [[NairnMPM]], and [[NairnFEA]]. See the section on [[#Other Linux Systems|other systems]] for compilation on other Linux/Unix systems.


In brief, each system simply requires a custom argument to the <tt>make</tt> command. After compilation is over see [[#Compilation on Supported Linux Systems|below]] for generic details that apply to all system.
In brief, each system simply requires a custom argument to the <tt>make</tt> command. After compilation is over see [[#Compilation on Supported Linux Systems|below]] for generic details that apply to all system.


== Carbon/Hedera Cluster (Oregon State University) ==
== HPC Cluster (Oregon State University) ==


If you are using the Carbon/Hedera cluster in the [http://www.oregonstate.edu/ Oregon State University], [http://woodscience.oregonstate.edu// Wood Science &amp; Engineering Department], use a simple <tt>make</tt> command. This system is the default system from compiling the code. The commands for [[OSParticulas]] and [[NairnMPM]] are:
If you are using the HPC cluster in the [http://www.oregonstate.edu/ Oregon State University], [http://woodscience.oregonstate.edu// Wood Science &amp; Engineering Department], use a simple <tt>make</tt> command. This system is the default system for compiling the code. The commands for [[OSParticulas]] and [[NairnMPM]] are:


  cd nairn-mpm-fea/NairnMPM/build
  cd nairn-mpm-fea/NairnMPM/build
  make
  make -j N


and for [[NairnFEA]] are:
and for [[NairnFEA]] are:


  cd nairn-mpm-fea/NairnFEA/build
  cd nairn-mpm-fea/NairnFEA/build
  make
  make -j N
 
where the <tt>-j N</tt> tells the make to compile in parallel using <tt>N</tt> cores.


== MPM Workstation (Oregon State University) ==
== MPM Workstation (Oregon State University) ==
Line 24: Line 26:


  cd nairn-mpm-fea/NairnMPM/build
  cd nairn-mpm-fea/NairnMPM/build
  make SYSTEM=mpm
  make -j 12 SYSTEM=mpm


and for [[NairnFEA]] are:
and for [[NairnFEA]] are:


   cd nairn-mpm-fea/NairnFEA/build
   cd nairn-mpm-fea/NairnFEA/build
   make SYSTEM=mpm
   make -j 12 SYSTEM=mpm
 
where the <tt>-j 12</tt> tells the make to compile in parallel using the 12 cores on this workstation.


== Zia Workstation (CISRO) ==
== Zia Workstation (CISRO) ==
Line 36: Line 40:


  cd nairn-mpm-fea/NairnMPM/build
  cd nairn-mpm-fea/NairnMPM/build
  make SYSTEM=zia
  make -j N SYSTEM=zia


and for [[NairnFEA]] are:
and for [[NairnFEA]] are:


   cd nairn-mpm-fea/NairnFEA/build
   cd nairn-mpm-fea/NairnFEA/build
   make SYSTEM=zia
   make -j N SYSTEM=zia


== Inferno (University of Utah) ==
where the <tt>-j N</tt> tells the make to compile in parallel using <tt>N</tt> cores.


If you are using Inferno in the [http://www.utah.edu/ University or Utah], [http://www.csafe.utah.edu/ CSAFE Group], the commands for [[OSParticulas]] and [[NairnMPM]] are:
== Compilation on Supported Linux Systems ==


cd nairn-mpm-fea/NairnMPM/build
The commands for the above system will compile all source code and install the executables in <tt>nairn-mpm-fea/NairnMPM/input</tt> or <tt>nairn-mpm-fea/NairnFEA/input</tt>, respectively. If you follow successful compilation with
make SYSTEM=inferno


and for [[NairnFEA]] are:
  make install


  cd nairn-mpm-fea/NairnFEA/build
the relevant executable and DTD file will be copied to a <tt>bin</tt> folder in your home directory (which should exist). It is convenient to have that directory in your default <tt>$PATH</tt> variable such that launching calculations only needs the binary name.
  make SYSTEM=inferno


== Compilation on Supported Linux Systems ==
Besides the <tt>SYSTEM</tt> parameter to specify a supported system, you can pass additional parameters to the <tt>make</tt> command to alter the compilation process. See comments in the <tt>makefile</tt> for all the latest options.
 
The commands for the above system will compile all source code and install the executables in <tt>nairn-mpm-fea/NairnMPM/input</tt> or <tt>nairn-mpm-fea/NairnFEA/input</tt>, respectively.  


== Other Linux Systems ==
== Other Linux Systems ==


Compiling on any Linux/Unix system should be straightforward, with the most difficult step usually being installing and linking to the <code>xerces</code> library. The key steps needed for successful compilation:
Compiling on any Linux/Unix system should be straightforward, with the most difficult step usually being installing and link to the <tt>xerces</tt> library. The key steps needed for successful compilation:
 
<ol>
<li>Use a compatible <code>C++</code> compiler. The code has been tested with at least <code>gcc 3.2</code> through <code>gcc 4.3.1</code>). It is possible other compilers will need minor changes for compilation.</li>
 
<li>Validation and parsing of the <code>XML</code> files are handled using free third party software from the <a href="http://www.apache.org/">Apache Software Foundation</a> called the
<a href="http://xml.apache.org/xerces-c/index.html"><code>xerces</code> validating XML parser</a>. You will need to download <code>xerces</code> and install it on your system. It is available in <a href="http://xml.apache.org/xerces-c/install.html">binary installs</a> for some systems (<i>e.g.</i>, Linux and Windows). For others systems (<i>e.g.</i>, MacOS X) you need to download the source code and <a href="http://xml.apache.org/xerces-c/build.html">build</a> it. Since revision 274 of the <code>nairn-mpm-fea</code> project, the codes require <code>xerces 3.0</code> or newer. Prior to this revision, the codes requied <code>xerces 2.8</code> or older. Unfortunately, the new versions of <code>xerces</code> are not compatible with the older ones.
</li>
 
<li>Compiling of <code>NairnMPM</code> or <code>NairnFEA</code> needs access to all the <code>xerces</code> header files. These are provided in the <code>xerces</code> source code downloads. Even iff your system has the xerces binary installed, it may not have the header files. You can get them by  <a href="http://xml.apache.org/dist/xerces-c/stable/">downloading the xerces source code</a>, even though you will not need to build it.</li>


</ol>
# Use a compatible <tt>C++</tt> compiler. To compile parallel version of the code, you need a compiler that supports <tt>OpenMP</tt>. For gcc, the version should be 4.8 or newer. Non-gcc compilers such as clang-mp work as well.
# Validation and parsing of the <tt>XML</tt> files are handled using free third party software from the [http://www.apache.org/ Apache Software Foundation] called the [http://xml.apache.org/xerces-c/index.html <tt>xerces</tt> validating XML parser]. You will need to download <tt>xerces</tt> and install it on your system. It is available in [http://xml.apache.org/xerces-c/install.html binary installs] for many systems. For others systems you will need to download the source code and [http://xml.apache.org/xerces-c/build.html build] it. Since revision 274 of the <tt>nairn-mpm-fea</tt> project, the codes require <tt>xerces 3.0</tt> or newer. Prior to this revision, the codes requied <tt>xerces 2.8</tt> or older. Unfortunately, the new versions of <tt>xerces</tt> are not compatible with the older ones.
# Compiling of [[OSParticulas]], [[NairnMPM]], and [[NairnFEA]] needs access to all the <tt>xerces</tt> header files. These are provided in the <tt>xerces</tt> source code downloads. Even if your system has the <tt>xerces</tt> binary installed, it may not have the header files. You can get them by  [http://xml.apache.org/dist/xerces-c/stable/ downloading the xerces source code], even though you will not need to build it.


<p>Once a suitable compiler, the <code>xerces</code> binary, and <code>xerces</code> header files are installed, compilation may require editing the <code>makefile</code>s in the <code>nairn-mpm-fea</code> folders. Specifically, you will need to edit the <code>makefile</code>s in the <code>build</code> directories (<code>NairnMPM</code> and <code>NairnFEA</code>) and set the following variables:</p>
Once a suitable compiler, the <tt>xerces</tt> binary, and <tt>xerces</tt> header files are installed, compilation may require editing the <tt>makefile</tt>s in the <tt>nairn-mpm-fea</tt> folders. Specifically, you will need to edit the <tt>makefile</tt>s in the <tt>NairnMPM/build</tt>and <tt>NairnFEA/build</tt> directories and set at least the following variables if the default settings are not correct for your system:


<ol>
# The variable <tt>CC</tt>: set it to the desired <tt>C++</tt> compiler.
<li>The variable <code>CC</code>: set it to the desired <code>C++</code> compiler.</li>
# The variable <tt>xercesSo</tt>: set it to the path name to the <tt>xerces</tt> library binary file.
<li>The variable <code>xercesSo</code>: set it to the path name to the <code>xerces</code> library binary file.</li>
# The variable <tt>headersPath</tt>: set it to the path name to the folder containing the <tt>xercesc</tt> folder of header files.
<li>The variable <code>headersPath</code>: set it to the path name to the folder containing the <code>xercesc</code> folder of header files.</li>
</ol>


<p>After setting the variables, use a standard <code>make</code> command to compile the code.
After setting the variables, use a standard <tt>make</tt> command to compile the code. If it compiles, but will not load the <tt>xerces</tt> library at runtime, you will have to find the system-dependent method to provide the path to the <tt>xerces</tt> library and make sure the system can find the <tt>xerces</tt> library.
Once the code is compiled, do a <a href="../running/index.html">test run</a> to verify it worked.
If it compiles, but will not load the <code>xerces</code> library at runtime, you will have to find the system-dependent method to provide the path to the <code>xerces</code> library and make sure the system can find the <code>xerces</code> library.</p>


<p>If you successfully get the code compiled and running on a system that is not listed above, please send email to <a href="mailto:John.Nairn@oregonstate.edu">John.Nairn@oregonstate.edu</a> with the system name and step-by-step instructions for compiling and running the code.</p>
If you successfully get the code compiled and running on a system that is not listed above, please edit this wiki page to document it, or send email to [mailto:John.Nairn@oregonstate.edu John.Nairn@oregonstate.edu] with the system name and step-by-step instructions for compiling and running the code.

Latest revision as of 12:51, 4 March 2023

This page explains several command-line methods to compile the code engines in Linux or Unix systems.

Introduction

The nairn-mpm-fea code engines can easily be compiled on any Linux system with a C++ compiler and with xerces already installed. Below are details on specific systems that are already set up for compilation, already have xerces, and are currently in use for OSParticulas, NairnMPM, and NairnFEA. See the section on other systems for compilation on other Linux/Unix systems.

In brief, each system simply requires a custom argument to the make command. After compilation is over see below for generic details that apply to all system.

HPC Cluster (Oregon State University)

If you are using the HPC cluster in the Oregon State University, Wood Science & Engineering Department, use a simple make command. This system is the default system for compiling the code. The commands for OSParticulas and NairnMPM are:

cd nairn-mpm-fea/NairnMPM/build
make -j N

and for NairnFEA are:

cd nairn-mpm-fea/NairnFEA/build
make -j N

where the -j N tells the make to compile in parallel using N cores.

MPM Workstation (Oregon State University)

If you are using mpm in the Oregon State University, Wood Science & Engineering Department, the commands for OSParticulas and NairnMPM are:

cd nairn-mpm-fea/NairnMPM/build
make -j 12 SYSTEM=mpm

and for NairnFEA are:

 cd nairn-mpm-fea/NairnFEA/build
 make -j 12 SYSTEM=mpm

where the -j 12 tells the make to compile in parallel using the 12 cores on this workstation.

Zia Workstation (CISRO)

If you are using Zia Linux system, the commands for OSParticulas and NairnMPM are:

cd nairn-mpm-fea/NairnMPM/build
make -j N SYSTEM=zia

and for NairnFEA are:

 cd nairn-mpm-fea/NairnFEA/build
 make -j N SYSTEM=zia

where the -j N tells the make to compile in parallel using N cores.

Compilation on Supported Linux Systems

The commands for the above system will compile all source code and install the executables in nairn-mpm-fea/NairnMPM/input or nairn-mpm-fea/NairnFEA/input, respectively. If you follow successful compilation with

 make install

the relevant executable and DTD file will be copied to a bin folder in your home directory (which should exist). It is convenient to have that directory in your default $PATH variable such that launching calculations only needs the binary name.

Besides the SYSTEM parameter to specify a supported system, you can pass additional parameters to the make command to alter the compilation process. See comments in the makefile for all the latest options.

Other Linux Systems

Compiling on any Linux/Unix system should be straightforward, with the most difficult step usually being installing and link to the xerces library. The key steps needed for successful compilation:

  1. Use a compatible C++ compiler. To compile parallel version of the code, you need a compiler that supports OpenMP. For gcc, the version should be 4.8 or newer. Non-gcc compilers such as clang-mp work as well.
  2. Validation and parsing of the XML files are handled using free third party software from the Apache Software Foundation called the xerces validating XML parser. You will need to download xerces and install it on your system. It is available in binary installs for many systems. For others systems you will need to download the source code and build it. Since revision 274 of the nairn-mpm-fea project, the codes require xerces 3.0 or newer. Prior to this revision, the codes requied xerces 2.8 or older. Unfortunately, the new versions of xerces are not compatible with the older ones.
  3. Compiling of OSParticulas, NairnMPM, and NairnFEA needs access to all the xerces header files. These are provided in the xerces source code downloads. Even if your system has the xerces binary installed, it may not have the header files. You can get them by downloading the xerces source code, even though you will not need to build it.

Once a suitable compiler, the xerces binary, and xerces header files are installed, compilation may require editing the makefiles in the nairn-mpm-fea folders. Specifically, you will need to edit the makefiles in the NairnMPM/buildand NairnFEA/build directories and set at least the following variables if the default settings are not correct for your system:

  1. The variable CC: set it to the desired C++ compiler.
  2. The variable xercesSo: set it to the path name to the xerces library binary file.
  3. The variable headersPath: set it to the path name to the folder containing the xercesc folder of header files.

After setting the variables, use a standard make command to compile the code. If it compiles, but will not load the xerces library at runtime, you will have to find the system-dependent method to provide the path to the xerces library and make sure the system can find the xerces library.

If you successfully get the code compiled and running on a system that is not listed above, please edit this wiki page to document it, or send email to John.Nairn@oregonstate.edu with the system name and step-by-step instructions for compiling and running the code.