ILOC INSTALLATION INTRUCTIONS
Version 3.1
#
# Istvan Bondar, 2020 ibondar2014@gmail.com
#
#
Read the iloc documentation.

1. Download and unpack the iLoc3.1 tarball
==========================================

Download the latest release of the iLoc package from
https://seiscode.iris.washington.edu/projects/iloc
or from
http://www.seismology.hu/data/iLoc/

Open the terminal application and unpack the iLoc tarball:

    tar xzvf iLoc3.1.tgz

Files will be extracted to the ~/iLoc3.1 directory.


2. Set the required environment variables
=========================================

ILOCROOT - directory pathname for the iLoc root directory.

Edit your ~/.bashrc file using a text editor (gedit, vi, BBedit)
so that it includes

    MacOS X
        #
        # RSTT, iLoc
        #
        export ILOCROOT=~/iLoc3.1
        export PATH=$PATH:~/bin
    Linux
        #
        # RSTT, iLoc
        #
        export ILOCROOT=~/iLoc3.1
        export PATH=$PATH:~/bin
        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$HOME/lib:

Close terminal application and open it again to get your ~/.bashrc sourced.

3. Set/check optional environment variables
===========================================

    PostgreSQL specific: required for ISC, and NIOB databases.
        PGPORT
    Oracle specific: required for IDC Oracle database access.
        ORACLE_HOME
        ORACLE_SID
            Required for IDC Oracle database access.
    MYSQL specific:
        iLoc expects the MYSQL connection parameters in the ~/.my.cnf file

Close terminal application and open it again to get your ~/.bashrc sourced.

4. Install dependencies
=======================

4.1 LAPACK and BLAS libraries (required)
----------------------------------------
    MacOSX
        The lapack and lblas libraries are part of MacOS X Accelerate framework,
        no action is required.
    linux CentOS
        sudo yum groupinstall 'Development Tools' -y
        sudo yum install lapack.x86_64 -y
    linux Ubuntu
        sudo apt-get update
        sudo apt-get install liblapack3

4.2 RSTT package (required)
---------------------------
    The RSTT model and software bundle is part of the iLoc package. The iLoc
    installation process compiles the necessary libraries to run iLoc:
        libgeotesscpp, libslbm and libslbmCshell
    and makes a symbolic link to them in ~/lib.

    If you want to use the RSTT utilities or other interfaces (fortran, java),
    compile the full RSTT by issuing make all in the $ILOCROOT/rstt directory.

    Check for the latest releases of RSTT at www.sandia.gov/rstt

    On linux machines you may have to install the g++-multilib library:

    linux CentOS
        sudo yum install g++-multilib
    linux Ubuntu
        sudo apt-get update
        sudo apt-get install g++-multilib

4.3 MySQL client (optional)
---------------------------
    Only required if the standard SeisComp MySQL database interface is used.

    https://dev.mysql.com/doc/mysql-osx-excerpt/8.0/en/osx-installation.html

    macOS:
        brew install mysql-client
    linux CentOS
        sudo yum install mysql-devel -y
    linux Ubuntu
        sudo apt-get update

    For using mysql interactively, store the MySQL connection info in ~/.my.cnf.
    iLoc reads the MySQL connection info from ~/.my.cnf.

4.4 PostgreSQL client (optional)
--------------------------------
    Only required if the CTBTO NDC-in-a-Box IDC or the ISC database interface
    is to be used. For installation instructions see the PostgreSQL website:
    https://www.postgresql.org/download/

    Note that you need the developer package, because only that includes the
    necessary include files (libpq-fe.h and postgres_ext.h) for the iLoc
    compilation.

    iLoc expects that the PGPORT environment variable is set to the port
    PostgreSQL uses (typically 5432). For using psql interactively, you may
    want to store the PostgreSQL connection info in ~/.pgpass.

4.5 Oracle client (optional)
----------------------------
    Only required if the CTBTO IDC database interface is to be used. Download
    and install the Oracle instant client from
    http://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html
    or alternatively, the Oracle database express edition 11g from
    https://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
    iLoc expects that the ORACLE_HOME, and ORACLE_SID environment
    variables are set.

4.6 Fix IDC database schema issue
---------------------------------

    The IDC NIOB and Oracle databases have a unique index on the assoc table
    by arid, which prevents iLoc to store multiple solutions for the same
    event. To solve the problem, connect to the database with psql or sqlplus
    and delete the assaridx index.

        drop index assaridx;

5. Install iLoc
===============

    The iLoc installation process
    - creates the ~/bin and ~/lib directories if they don’t exist yet
    - compiles the RSTT libraries needed to run iLoc
    - finds out whether MySQL, Postgresql or Oracle clients are installed
    - creates symbolic links to the libraries needed by iLoc in ~/lib
    - compiles the iLoc source code and builds various iLoc executables
      depending on the database clients it found
    - writes the executables to the ~/bin directory

    cd $ILOCROOT
    make

    iLoc variations in ~/bin
        iLoc: iLoc with no database interface (ISF I/O)
        iLocSC: iLoc with SeisComp MySQl DB interface
        iLocIDC: iLoc with IDC Oracle DB interface
        iLocNiab: iLoc with IDC NDC-in-a-Box Postgresql DB interface
        iLocISC: iLoc with ISC Postgresql DB interface

    Check if everything is ok

        cd ~/bin

        Linux:
            ldd iloc
        MacOS
            otool -L iloc

    Edit $ILOCROOT/auxdata/iLocpars/Config.txt
        Make sure that especially these parameters are set to your preferences:
        - StationFile
        - RSTTmodel, UseRSTTPnSn, UseRSTTPgLg
        - LocalVmodelFile, MaxLocalTTDelta
        - DoGridSearch
        - OutAgency.
        For PostgreSQL and Oracle database interfaces make sure that the
        - DBuser, DBpasswd and DBname
        parameters are properly set.

           cd $ILOCROOT/auxdata/iLocpars
           gedit Config.txt

Perl utility dependencies
=========================

install cpanm

    linux CentOS
        sudo yum install cpanminus
    linux Ubuntu
        sudo apt install cpanminus

install Perl PostgreSQL and Oracle modules with cpanm

    cpanm --sudo DBD::Pg
    cpanm --sudo DBI/Oracle.pm



Read the iloc documentation.
