****************************************************************************
*
*  IHABBS linux installation for version 3.18+ with PostgreSQL
*
*  History:
*  Anders Nilsson, VV,   06/18/04, Created
*  Anders Nilsson, UCAR, 02/22/06, Adapted for PostgreSQL
*
****************************************************************************


1) Get the following and put them into the same directory:

   Download tarred nohrsc_pg_docs.tar.gz
   Download tarred nohrsc_pg_executables.tar.gz
   Download tarred nohrsc_static_layers.tar.gz
   Download tarred XXrfc/XXrfc_layers.tar.gz

2) Uncompress the files by using the following:

   tar xvzf nohrsc_pg_docs.tar.gz
   tar xvzf nohrsc_pg_executables.tar.gz
   tar xvzf nohrsc_static_layers.tar.gz
   tar xvzf XXrfc_layers.tar.gz

These will create an "install" directory, and fill it with files.


3) Next, some environment variables have to be set for the rest of the
   installation process. These variables will also need to be set in the shell
   before a NOHRSC application can be run. Some RFCs define these variables in
   the user's profiles (files such as .profile, .appsdefaults, or .bashrc),
   while others place these in a script which then calls the nohrsc launcher.
   The general PATH environment variable will also need to have the directory
   containing the executables in it (described below).

"export" the following variables:

File path info:

   GISRS_HOME=
      a parent master directory into which IHABBS-related subdirectories will
      be placed.
   GISRS_COMMON_DATA=
      a parent directory into which static "common" data 
      (State outlines, county boundaries, etc...) will be placed. 
      (This is often the same as $GISRS_HOME)
   GISRS_BASIN_DATA=
      a parent directory into which IHABBS static data 
      (flow accumulation grids) and more dynamic data (basin vectors) i
      will be placed. (This is often the same as $GISRS_COMMON_DATA)
   GISRS_ARCHIVE=
      a directory to contain archived and shared layers (and often
      installation packages) (This is often $GISRS_HOME/archive)
   GISRS_SCRATCH_PATH=
      a directory to contain scratch files. 
      Preferably located on a local disk.
   IHABBS=
      a directory to contain all the binary executables
      (This is often $GISRS_HOME/bin)
   PATH=$PATH:$IHABBS


Database info:

   export PGHOST=
      ( the name of the database machine)
   PGUSER=ihabbs
   PGCONNECT_TIMEOUT=0
   GISRS_DATABASE=
      ( the name of the database that you wish to use ) 
      (This can be gisrs)
   GISRS_SCHEMA=
      ( the name of the database schema that you wish to use )
      (This can be gisrs)

Misc. Preferences:

   GISRS_DATABASE_WAIT_SECONDS=60 
      (duration in seconds for an overly long database transaction)
   GISRS_FILE_SIZE_PAUSE_SECONDS=1 
      (duration after which, if a file size has not changed, 
       it is assumedly finished copying)
   GISRS_MINIMUM_RASTER_COMPRESSION_LEVEL=100 
      (Maximum percentage size of a compressed raster. A value of 100
      means that the programs will compress a raster file if the 
      compressed file is smaller than the original file)
   GISRS_USER=`whoami`
   GISRS_MAIL=`whoami`

4) Database Setup

    Once these variables are set, the database and the database use $PGUSER
    can be created using an database administrator account. The database 
    creation step is shown below. 

   psql template1 << NOHRSC
   create database $GISRS_DATABASE TABLESPACE tablespace ;
   grant temporary on database $GISRS_DATABASE to $PGUSER ;
   \q
   NOHRSC

   psql $GISRS_DATABASE << NOHRSC
   create schema $GISRS_SCHEMA ;
   grant usage on schema $GISRS_SCHEMA to $PGUSER ;
   grant create on schema $GISRS_SCHEMA to $PGUSER ;
   \q
   NOHRSC
   

5) Once the database has been created, run the following three scripts:

   ./make_directories.sh

   (This will create the directories specified by the environment variables.)

   ./copy_files.sh

   (This will move the executables and the documentation to their places. This
   will also update the nohrsc.cfg configuration file with the values
   specified in the environment variables.)

   ./install_script.sh

   (This will create tables within the newly created database, and then
    populate it with restored layers.)



