运行RegCM大气模型时遇libmpi_mpifh.so.12加载失败问题求助
Let's break down why this error is popping up and walk through practical fixes to get your RegCM model running smoothly.
Why this happens
The error means your system can’t locate the libmpi_mpifh.so.12 shared library. This file is tied to a specific version of OpenMPI—usually the 3.x series (like 3.1.x). The openmpi-dev and libopenmpi packages you installed are probably a newer or older version that doesn’t include this exact library file.
Step 1: Check if the library exists on your system
First, let’s confirm whether the library is already hiding somewhere on your machine. Run this search command:
find / -name libmpi_mpifh.so.12 2>/dev/null
- If the command returns a path (e.g.,
/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_mpifh.so.12), skip to Step 3. - If no results show up, the library isn’t installed—head to Step 2.
Step 2: Install the correct OpenMPI version
Since libmpi_mpifh.so.12 belongs to OpenMPI 3.x, we’ll install that specific version to match:
- First, remove existing OpenMPI packages to avoid conflicts:
sudo apt-get purge openmpi-dev libopenmpi* - Install the 3.x version of OpenMPI:
sudo apt-get install libopenmpi3 libopenmpi-dev
This should install the exact missing library onto your system.
Step 3: Add the library path to your system’s search path
If you found the library in Step 1 but still get the error, it means your system isn’t checking the right directory for it. We’ll add the library’s path to LD_LIBRARY_PATH:
- Temporary fix (works only for your current terminal session):
Replace/path/to/mpi/libwith the actual path you found in Step 1, then run:export LD_LIBRARY_PATH=/path/to/mpi/lib:$LD_LIBRARY_PATH ./regcmMPI - Permanent fix (applies to all future sessions):
Open your~/.bashrcfile with a text editor:
Add this line at the end (replace the path with your actual library path):nano ~/.bashrc
Save and exit, then reload the file to apply changes:export LD_LIBRARY_PATH=/path/to/mpi/lib:$LD_LIBRARY_PATHsource ~/.bashrc
Step 4: Recompile RegCM with the correct MPI (if needed)
If you still hit issues, it’s possible RegCM was compiled with a different MPI version than what’s on your system now. To fix this:
- Navigate to your RegCM source directory.
- Clean previous build files:
make clean - Reconfigure RegCM to use your current MPI setup. If you installed via apt, run:
If you compiled MPI from source, specify its installation path:./configure --with-mpi./configure --with-mpi=/path/to/your/mpi/installation - Recompile and install:
make make install
Try these steps in order—most likely Step 2 or 3 will resolve your issue quickly.
内容的提问来源于stack exchange,提问作者Carlos Madrigal

