====
nemo
====

Information about `nemo <http://www.hpc.uni-freiburg.de/nemo>`__.

Building GPAW
=============

We assume that the installation will be located in ``$HOME/source``.

Setups
------

The setups of your choice must be installed
(see also :ref:`installation of paw datasets`)::

  cd
  GPAW_SETUP_SOURCE=$PWD/source/gpaw-setups
  mkdir -p $GPAW_SETUP_SOURCE
  cd $GPAW_SETUP_SOURCE
  wget https://wiki.fysik.dtu.dk/gpaw-files/gpaw-setups-0.9.11271.tar.gz
  tar xzf gpaw-setups-0.9.11271.tar.gz

Let gpaw know about the setups::
  
  export GPAW_SETUP_PATH=$GPAW_SETUP_SOURCE/gpaw-setups-0.9.11271

Using the module environment
----------------------------

It is very handy to add our installation to the module environment::

  cd
  mkdir -p modulefiles/gpaw-setups
  cd modulefiles/gpaw-setups
  echo -e "#%Module1.0\nprepend-path       GPAW_SETUP_PATH    $GPAW_SETUP_SOURCE/gpaw-setups-0.9.11271" > 0.9.11271
  
We need to let the system know about our modules
(add this command to ``~/.profile`` or ``~/.bashrc`` to execute automatically)::

  module use $HOME/modulefiles

such that we also see them with::

  module avail

libxc
-----

GPAW relies on libxc (see the `libxc web site <http://www.tddft.org/programs/octopus/wiki/index.php/Libxc:download>`__). 
To install libxc we assume that ``MYLIBXCDIR`` is set to 
the directory where you want to install 
(e.g. ``MYLIBXCDIR=$HOME/source/libxc``)::

 mkdir -p $MYLIBXCDIR
 cd $MYLIBXCDIR
 wget http://www.tddft.org/programs/libxc/down.php?file=4.3.4/libxc-4.3.4.tar.gz -O libxc-4.3.4.tar.gz
 tar xvzf libxc-4.3.4.tar.gz
 cd libxc-4.3.4
 mkdir install
 ./configure CFLAGS="-fPIC" --prefix=$PWD/install -enable-shared
 make |tee make.log
 make install

This will have installed the libs ``$MYLIBXCDIR/libxc-4.3.4/install/lib`` 
and the C header
files to ``$MYLIBXCDIR/libxc-4.3.4/install/include``.
We create a module for libxc::

  cd	
  mkdir modulefiles/libxc
  cd modulefiles/libxc

and edit the module file  :file:`4.3.4` that should read::

  #%Module1.0

  #                                    change this to your path
  set             libxchome            /home/fr/fr_fr/fr_mw767/source/libxc/libxc-4.3.4/install
  prepend-path    C_INCLUDE_PATH       $libxchome/include
  prepend-path    LIBRARY_PATH         $libxchome/lib
  prepend-path    LD_LIBRARY_PATH      $libxchome/lib

ASE release
-----------

You might want to install a stable version of ASE::

  cd
  ASE_SOURCE=$PWD/source/ase
  mkdir -p $ASE_SOURCE
  cd $ASE_SOURCE
  git clone -b 3.18.1 https://gitlab.com/ase/ase.git 3.18.1

We add our installation to the module environment::

  cd
  mkdir -p modulefiles/ase
  cd modulefiles/ase
  
Edit the module file  :file:`3.18.1` that should read::

  #%Module1.0

  module load devel/python/3.6.9

  #           change this to your path
  set asehome /home/fr/fr_fr/fr_mw767/source/ase/3.18.1
  prepend-path       PYTHONPATH    $asehome
  prepend-path       PATH          $asehome/tools

ASE trunk
---------

We get ASE trunk::

  cd
  ASE_SOURCE=$PWD/source/ase
  mkdir -p $ASE_SOURCE
  cd $ASE_SOURCE
  git clone https://gitlab.com/ase/ase.git trunk

which can be updated using::

  cd $ASE_SOURCE/trunk
  git pull

We add our installation to the module environment::

  cd
  mkdir -p modulefiles/ase
  cd modulefiles/ase

and edit the module file  :file:`trunk` that should read::

  #%Module1.0

  module load devel/python/3.6.9

  #           change this to your path
  set asehome /home/fr/fr_fr/fr_mw767/source/ase/trunk
  prepend-path       PYTHONPATH    $asehome
  prepend-path       PATH          $asehome/tools

Building GPAW
-------------

We create a place for gpaw and get the trunk version::

 cd
 GPAW_SOURCE=$PWD/source/gpaw
 mkdir -p $GPAW_SOURCE
 cd $GPAW_SOURCE
 git clone https://gitlab.com/gpaw/gpaw.git trunk

The current trunk version can then be updated by::

 cd $GPAW_SOURCE/trunk
 git pull

A specific tag can be loaded by::

 cd $GPAW_SOURCE/trunk
 # list tags
 git tag
 # load version 1.2.0
 git checkout 1.2.0

To build the current trunk version of GPAW we need to create
a file :file:`siteconfig.py` that reads

.. literalinclude:: nemo_siteconfig.py

Then we build the executable::

 module purge
 module load libxc
 module load mpi/impi
 module load numlib/mkl
 module load ase

 cd $GPAW_SOURCE/trunk
 python3 setup.py build

which builds GPAW to ``$GPAW_SOURCE/trunk/build``.
We create a module that creates the necessary definitions::

  cd
  mkdir -p modulefiles/gpaw
  cd modulefiles/gpaw

The file  :file:`trunk` that should read::

 #%Module1.0

 if {![is-loaded ase]} {module load ase}
 if {![is-loaded libxc]} {module load libxc}
 if {![is-loaded mpi]}  {module load mpi/impi}
 if {![is-loaded numlib/mkl]}  {module load numlib/mkl}
 if {![is-loaded gpaw-setups]}  {module load gpaw-setups}

 # change the following directory definition to your needs
 set gpawhome /home/fr/fr_fr/fr_mw767/source/gpaw/trunk
 # this can stay as is
 prepend-path    PATH                 $gpawhome/tools:$gpawhome/build/scripts-3.6
 prepend-path    PYTHONPATH           $gpawhome:$gpawhome/build/lib.linux-x86_64-3.6
 

Running GPAW
------------

A gpaw script :file:`test.py` can be submitted with the help
of :file:`gpaw-runscript` to run on 20 cpus like this::

  > module load gpaw
  > gpaw-runscript test.py 20
  using nemo
  run.nemo written
  > msub run.nemo

See options of :file:`gpaw-runscript` with::

  > gpaw-runscript -h

