#! /bin/bash

# Run this script to install a lammps-icms in a user's home directory, ~/.
# A folder lamps-icms will be created in ~/.
# Choose either scp from www2 (not current version) or git (current/latest version) or wget. By default, wget is used.
# Make sure you have git installed, or yum install git.x86_64 as root, if you wish to download with git clone (instead of scp)

cd ~/
#scp -r tlyoon@www2.fizik.usm.my:/home/tlyoon/repo/lammps-icms .
#git clone http://git.icms.temple.edu/lammps-icms.git lammps-icms  #git clone takes a bit longer time to complete.
wget http://www2.fizik.usm.my/configrepo/howto/lammps-icms/lammps-icms.tar
tar -xvf lammps-icms.tar
#################################################################

cd lammps-icms

cd lib
cd atc
wget http://www2.fizik.usm.my/configrepo/howto/lammps-icms/Makefile.g++.lammps.atc.rocks53
mv Makefile.g++ Makefile.g++.bk
cp Makefile.g++.lammps.atc.rocks53 Makefile.g++
make -f Makefile.g++

cd ..
cd linalg
wget http://www2.fizik.usm.my/configrepo/howto/lammps-icms/Makefile.gfortran.linalg.rocks53
mv Makefile.gfortran Makefile.gfortran.bk
cp Makefile.gfortran.linalg.rocks53 Makefile.gfortran
make -f Makefile.gfortran

cd ..
cd meam  
make -f Makefile.gfortran


cd ..
cd reax  
wget http://www2.fizik.usm.my/configrepo/howto/lammps-icms/Makefile.gfortran.reax.rocks53
mv Makefile.gfortran Makefile.gfortran.bk
cp Makefile.gfortran.reax.rocks53 Makefile.gfortran
make -f Makefile.gfortran

cd ..
cd poems
make -f Makefile.g++

cd ..
cd ..

cd src
make yes-all 
make no-gpu

cd MAKE
wget http://www2.fizik.usm.my/configrepo/howto/lammps-icms/Makefile.g++.MAKE.CENTOS6
cp Makefile.g++ Makefile.g++.bk
cp Makefile.g++.MAKE.CENTOS6 Makefile.g++
cd ..
make g++

echo 'alias lg++='~/lammps-icms/src/lmp_g++' >> ~/.bashrc
