#! /bin/bash

# This script installs a minimum version of lammps (without all user-packages) automatically in a directory ~/lammps_gnu_5May15. It is designed for automated installation of lammps downloaded on 5May15 in a centos7 machine.

## requirement (mandatory):
## CC =		/usr/lib64/mpich/bin/mpic++ -fopenmp
## CCFLAGS =	-g -O3 -fopenmp -DLAMMPS_MEMALIGN=64  
## LINK =		/usr/lib64/mpich/bin/mpic++ -fopenmp 
## LINKFLAGS =     -g -O3 -fopenmp 
## LIB = -lstdc++

#LMP_INC =	-DLAMMPS_GZIP
## MPI_INC =  -I/usr/include/mpich-x86_64/include -DLAMMPS_GZIP
## MPI_PATH = -L/usr/lib64/mpich/lib 

## MPI_LIB =  -lfmpich  -lmpichcxx -lmpichf90 -lmpl -lopa
## FFT_INC  =  -DFFT_FFTW3 -I/usr/include
## FFT_PATH = -L/usr/lib64
## FFT_LIB  = -lfftw3 -lfftw3_omp -lfftw3_threads
## default gcc of CENTOS7

####### begin installation ####################################################
cd ~/
mkdir mylammps_gnu_5May15
cd mylammps_gnu_5May15
mylammpsdir=$(echo $PWD)
echo mylammpsdir= $mylammpsdir

wget http://www2.fizik.usm.my/configrepo/howto/mylammps/mylammps_gnu_5May15.tar.gz
tar -xzvf mylammps_gnu_5May15.tar.gz
mv mylammps_gnu_5May15.tar.gz configrepo
mv mylammps/* .
rm -rf mylammps

# linalg #
cd $mylammpsdir/lib/linalg
rm -f *.a *.o
make -f Makefile.gfortran

# atc #
#cd $mylammpsdir/lib
#cd atc
#rm -f *.a *.o
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/gnu/Makefile.lammps.atc
#cp Makefile.lammps.atc Makefile.lammps.installed
#make -f Makefile.mpic++

# cuda #
#cd $mylammpsdir/lib
#cd cuda
#make 

# gpu #
#cd $mylammpsdir/lib
#cd gpu
#rm -f *.a *.o
#rm -f Makefile.lammps
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/lammps_tmpl_5March_12_gnu_sa/lib/gpu/Makefile.lammps .
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/lammps_tmpl_5March_12_gnu_sa/lib/gpu/Makefile.anicca .
#make -f Makefile.anicca

# meam #
cd $mylammpsdir/lib
cd meam
rm -f *.a *.o
make -f Makefile.gfortran

# poems #
cd $mylammpsdir/lib
cd poems
rm -f *.a *.o
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/lammps_tmpl_5March_12_gnu_sa/lib/poems/Makefile.anicca .
 make -f Makefile.g++


# reax #
#cd $mylammpsdir/lib/reax
#rm -f *.a *.o
#rm -f Makefile.lammps
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/lammps_tmpl_5March_12_gnu_sa/lib/reax/Makefile.lammps .
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/lammps_tmpl_5March_12_gnu_sa/lib/reax/Makefile.anicca .
#make -f Makefile.gfortran


#cd $mylammpsdir/lib/voronoi
#ln -s voro++-0.4.6/src /share/apps/voro++-0.4.6/include
#ln -s voro++-0.4.6/src /share/apps/voro++-0.4.6/include

#cd $mylammpsdir/lib/qmmm
#make -f Makefile.gfortran

#cd $mylammpsdir/lib/colvars
#make -f Makefile.g++

#cd $mylammpsdir/lib/awpmd
#make -f Makefile.mpicc


# Now exit /lib 

cd $mylammpsdir/src/MAKE
#wget http://www2.fizik.usm.my/configrepo/howto/mylammps/gnu/Makefile.gnu_centos7
cd ../

rm -f *.a *.o
make yes-all
make no-user-atc 
make no-user-awpmd 
make no-user-cg-cmm 
make no-user-colvars 
make no-user-cuda 
make no-user-eff 
make no-user-fep 
make no-user-intel 
make no-user-lb 
make no-user-misc 
make no-user-molfile 
make no-user-phonon 
make no-user-qmmm 
make no-user-quip 
make no-user-reaxc 
make no-user-sph 
make no-user-quip 
make no-gpu 
make no-kim 
make no-voronoi 
make no-kokkos 
make no-user-intel 
make no-user-reax 
make no-lib

make yes-user-omp
make -j4 omp

make gnu_centos7

### creating link
#cd $mylammpsdir/src
#rm -rf lmp_gnu
#ln -s lmp_gnu_centos7 lmp_gnu
