#!/bin/csh
#=====================================================================
# install_helio_cr: Compile and install heliospheric model.
#
# Usage: install_helio_cone <resolution>
#---------------------------------------------------------------------

# Usage message
  if ($#argv != 1 || ($1 != 'low' && $1 != 'medium')) then
    echo "Usage: install_helio_cr <resolution>"
    echo "    <resolution> is either 'low' or 'medium'"
    exit 1
  endif

# Set parameters
  set resolution = $1

# Set environment variables
  source ./set.sh make

#=====================================================================
# YOU SHOULD NOT EDIT BELOW
#---------------------------------------------------------------------
# Set numerical code parameters

# Numerical model and code names
  set numo = mp3m
  set enlil = enlil
  set amb2bc = mas2bc

# Grid resolution
  if ($resolution == 'low') then 
    set n1 = 128
    set n2 = 30
    set n3 = 90
  endif
  if ($resolution == 'medium') then 
    set n1 = 256
    set n2 = 60
    set n3 = 180
  endif

# Grid name
  set grd = $n1'x'$n2'x'$n3

# Parallel and multi-grid computations
  set procs = 1
  set levels = 1
  set nblk = 1
  set n1x = $n1/$procs

#---------------------------------------------------------------------
# Compile the codes

# Change directory
  cd $ENLIL_BIN

# Generate maximum array dimensions
  source $ENLIL_DIR/aux/commax.F.sh

# Compose makefile and compile ENLIL
  source $ENLIL_DIR/aux/make.sh $numo $enlil

# Compose makefile and compile AMB2BC
  source $ENLIL_DIR/aux/make.sh $numo $amb2bc

# Save versions for different grid resolutions
  /bin/mv commax.F commax.$grd.F
  /bin/mv $enlil $enlil.$grd
  /bin/mv $amb2bc $amb2bc.$grd

# Clean
  /bin/rm *.mod *.o

#---------------------------------------------------------------------
exit 0
