Friday, June 22, 2018

Parflow-CLM installation guide on Widows machines using the “Windows Subsystem for Linux”


Interesting, but not surprising, many current ParFlow users one day never knew how to use the Linux environment. This post is not about you can now install and run ParFlow on Windows, but introduces a compatibility layer for running Linux binary executables on a Windows machine. This is called “Windows Subsystem for Linux” which has been included with Windows 10 version 1607 and later. The following instruction walks you through a step-by-step guide on how to install ParFlow-CLM on a Windows machine using this platform. It is pretty straightforward and has been tested successfully on different machines to assure functionality. Please notice that you must follow the steps below exactly in order, and every step must pass successfully before proceeding to the next one.

Step 1. Install the Windows Subsystem for Linux

Taken from the Microsoft page, you first need to enable the "Windows Subsystem for Linux" optional feature and reboot. To do so,
  • Open PowerShell as Administrator and run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • Restart your computer when prompted.
  • Open the Microsoft Store and download Ubuntu.
  • Once the download has completed, select "Launch". This will open a console window. Wait for installation to complete then you will be prompted to create your LINUX user account.
  • Create your LINUX username and password. This user account has no relationship to your Windows username and password and hence can be different.
  • You're done! Now you can use your Linux environment.
Step 2. Download ParFlow-CLM manual

This manual includes the instructions on how to install ParFlow-CLM using cmake.

https://github.com/parflow/parflow/blob/master/parflow-manual.pdf

Step 3. Setup environment variables 

In the terminal, navigate to your home directory and edit your ".bash_profile" as follows:

> cd ~
> vim ~/.bash_profile

Press "i" to enter the insert mode, put the cursor to the end of this file, and add the following lines: 

export PARFLOW_SILO_DIR=~/pfdir/silo/
export PARFLOW_HYPRE_DIR=~/pfdir/hypre/
export PARFLOW_DIR=~/pfdir/install/
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
export PATH=/usr/local/bin/:$PATH

Press esc, and then :wq to save and exit the bash file. Then type:

> source ~/.bash_profile

Step 4. Download parflow-clm package

In your Ubuntu shell, type:

mkdir ~/pfdir
cd ~/pfdir
git clone https://github.com/parflow/parflow.git

Step 5. Install gcc

In your Ubuntu shell, type:

> cd
> sudo apt-get update
> sudo apt-get install gcc
> sudo apt-get install g++
> sudo apt-get install gdc
> sudo apt-get install tcl-dev
> sudo apt-get install tk-dev
> sudo apt-get install build-essential
> sudo apt-get install libgcc1 lib32gcc1 libx32gcc1
> sudo apt-get install build-essential autoconf automake libtool
sudo apt-get install libibnetdisc-dev
> sudo apt-get install binutils
> sudo apt-get install binutils-dev
> sudo apt install gfortran

(When you use the sudo command, it probably asks for your UNIX password.)
Note that it might take a while to install all features depending on your internet speed, etc. Also, whenever asked for “Do you want to continue? [Y/n]”, press Y.

Step 6. Install or update OpenMPI

In your Ubuntu shell, type:

> cd
> cd ~/pfdir
> wget https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.0.tar.gz
> tar -xvf openmpi-3.1.0.tar.gz
> cd openmpi-3.1.0
> ./configure --prefix=/usr/local/
Then proceed with:

> sudo apt-get install make
> sudo make all install

Please notice that you must not face any error during the installation. Also, stay patient with OpenMPI installation; it might take a fairly good amount of time.

Step 7. Download and install SILO

In your Ubuntu shell, type:

> cd
> cd ~/pfdir
> wgehttps://wci.llnl.gov/content/assets/docs/simulation/computer-codes/silo/silo-4.10.2/silo-4.10.2.tar.gz
chmod 777 silo-4.10.2.tar.gz
> tar -xvf silo-4.10.2.tar.gz
> mv silo-4.10.2 silo
> cd silo
./configure --disable-silex
> sudo make all install
Step 8. Download and install HYPRE
In your Ubuntu shell, type:

> cd
> cd ~/pfdir
> wget https://computation.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods/download/hypre-2.9.0b.tar.gz
> tar -xvf hypre-2.9.0b.tar.gz
> mv hypre-2.9.0b hypre
> cd hypre/src
> ./configure --prefix=$PARFLOW_HYPRE_DIR --with-MPI
sudo make install

Step 9. Install Parflow-clm

In your Ubuntu shell, type:

> cd
> cd ~/pfdir
> mkdir build
> cd build
> sudo apt install cmake
> cmake ../parflow -DPARFLOW_AMPS_LAYER=mpi1 -DPARFLOW_HAVE_CLM=ON -DSILO_ROOT=$PARFLOW_SILO_DIR -DHYPRE_ROOT=$PARFLOW_HYPRE_DIR -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR -DPARFLOW_AMPS_SEQUENTIAL_IO=true
> make
> make install

Note: For some reason, Ubuntu doesn't understand the dashes before each option when copying them into the shell. Hence instead of copying and pasting from this instruction, I recommend users to type the above cmake line manually. Otherwise, you might face the following error:

CMake Error: The source directory "/home/mdanesh/pfdir/build/–DHYPRE_ROOT=/home/mdanesh/pfdir/hypre" does not exist.

Step 10. Check if ParfFow-CLM is working

> make test

This will run some test cases that come with ParFlow package. If some tests fail, don't worry; they probably need a total number of processors that your machine doesn't support.

ParFlow-CLM should be now ready to go! Enjoy and let me know if you faced any issues at danesh[@]sharif[dot]edu.



6 comments:

Unknown said...

Hi,
Great guide!
I just wanted to let you know I may have found a small error in step 5:hypre. I changed computation to computing because the sourced link was slightly different than in the guide. After that it downloaded.

curl "https://computing.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods/download/hypre-2.11.2.tar.gz" -o "hypre-2.11.2.tar.gz"

Eva Smith said...

Thanks for sharing this beautiful blog. I am really appreciate your effort and dedication keep sharing this information.
If you facing with your Epson printer just dial our Epson Printer Toll Free Number 1800-436-0509 and get free Tech Support For Epson Printer

Andrew said...

Hi. Thank you for this fantastic guide. I am encountering an error in the installation of Parflow-clm. When I get to the following command: 'make', the process gets to about 81% but then throws errors relating to MPI, such as:
"../parflow_lib/libpfsimulator.a(general.c.o): In function `printMaxMemory':
general.c:(.text+0x11c): undefined reference to `ompi_mpi_comm_world'
general.c:(.text+0x193): undefined reference to `ompi_mpi_comm_world'
../parflow_lib/libpfsimulator.a(input_database.c.o): In function `IDB_NewDB':"
with the final error:
"collect2: error: ld returned 1 exit status
pfsimulator/parflow_exe/CMakeFiles/parflow.dir/build.make:101: recipe for target 'pfsimulator/parflow_exe/parflow' failed
make[2]: *** [pfsimulator/parflow_exe/parflow] Error 1
CMakeFiles/Makefile2:1186: recipe for target 'pfsimulator/parflow_exe/CMakeFiles/parflow.dir/all' failed
make[1]: *** [pfsimulator/parflow_exe/CMakeFiles/parflow.dir/all] Error 2
Makefile:140: recipe for target 'all' failed"

Any help you could provide would be appreciated

Andrew said...

I overcame this problem by using the command:

sudo cmake ../parflow -DPARFLOW_AMPS_LAYER=mpi1 -DPARFLOW_HAVE_CLM=ON -DSILO_ROOT=$PARFLOW_SILO_DIR -DHYPRE_ROOT=$PARFLOW_HYPRE_DIR -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR -DPARFLOW_AMPS_SEQUENTIAL_IO=true

followed by

sudo make

and
sudo make install

Jaeyoung Song said...

For MPI problem, you need to install "mpi-default-dev".

Unknown said...

when I am running the "make install" command i am getting this error.

"CMake Error at pfsimulator/amps/cmake_install.cmake:46 (file):
file INSTALL cannot copy file
"/home/vaibhavgupta/pfdir/build/pfsimulator/amps/libamps.a" to
"/lib/libamps.a": Permission denied.
Call Stack (most recent call first):
pfsimulator/cmake_install.cmake:47 (include)
cmake_install.cmake:47 (include)"

what should i do?