Back to Installation

MCNP — Linux Installation

Building and configuring MCNP on Linux with GCC/GFortran

System Requirements

Hardware

CPU: 2+ cores, 2.0 GHz minimum

RAM: 4 GB minimum, 16 GB recommended

Storage: 20 GB free space

Network: Internet access for downloads

Software

OS: Any modern Linux distribution

Compiler: GCC / GFortran 7.0+

MPI: OpenMPI 4.0+ or MPICH (parallel runs)

Build tools: Make

Install Prerequisites

Ubuntu / Debian

bash
sudo apt update
sudo apt install build-essential gfortran openmpi-bin libopenmpi-dev

CentOS / RHEL

bash
sudo yum groupinstall "Development Tools"
sudo yum install gcc-gfortran openmpi-devel

Verify versions

bash
gcc --version        # Should be 7.0+
gfortran --version   # Should be 7.0+
mpirun --version     # Should be 4.0+

Build and Install

Extract and compile

bash
# Extract distribution
mkdir -p ~/mcnp
cd ~/mcnp
tar -xzf MCNP6.2-Source.tar.gz
cd MCNP6.2/Source

# Configure compiler environment
export FC=gfortran
export CC=gcc
export CXX=g++
export MPIFC=mpif90
export MPICC=mpicc

# Build and install
make
make install PREFIX=/opt/mcnp

Add to PATH

bash
echo 'export PATH=/opt/mcnp/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

# Confirm the binary is found
mcnp6 --version

Cross-Section Data

Nuclear data libraries are distributed separately by RSICC. The most common libraries are:

Essential Libraries

ENDF/B-VIII.0: Latest US evaluation — library suffix .80c

ENDF/B-VII.1: Well-validated library — library suffix .71c

Thermal Data: S(α,β) scattering libraries for bound moderators

Photon Data: Atomic relaxation data for photon transport

Setup data path

bash
# Extract cross-section libraries
mkdir -p /opt/mcnp/data
cd /opt/mcnp/data
tar -xzf ENDF80SaB.tar.gz

# Set the DATAPATH environment variable
export DATAPATH=/opt/mcnp/data
echo 'export DATAPATH=/opt/mcnp/data' >> ~/.bashrc
source ~/.bashrc

# Verify the xsdir file is present
ls -la /opt/mcnp/data/xsdir

Verify the Installation

Run a minimal sphere problem to confirm MCNP and the cross-section data are both configured correctly.

Basic test

bash
# Create a simple sphere input
cat > test.i << EOF
Simple sphere test
1 1 -1.0 -1 imp:n=1
2 0      1  imp:n=0

1 so 10

m1 1001.70c 1
sdef
nps 1000
EOF

# Run the test
mcnp6 i=test.i o=test.o

# Check for successful completion
grep "run terminated normally" test.o

A successful run prints run terminated normally in the output file.

Test parallel execution

bash
mpirun -np 4 mcnp6 i=test.i o=test_parallel.o tasks 4

Common Issues

Compiler errors

Ensure GCC / GFortran is version 7.0 or newer. Run gcc --version and update via your package manager if needed.

Missing libraries

Install the build-essential and gfortran development packages for your distribution.

MPI problems

Verify OpenMPI is installed and that mpirun is in your PATH. Re-source your ~/.bashrc after installation.

Cross-section errors

Check that DATAPATH is set and points to a directory containing a valid xsdir file.

Permission errors

Use sudo for system-wide installation to /opt/mcnp, or install to your home directory by setting PREFIX=~/mcnp.

For additional troubleshooting, see the MCNP Troubleshooting guide. Document your installation steps and keep the original source archive — it saves time when setting up on additional systems.