#!/bin/csh
# CVS: $Id$
#
# Name:   svn-add-rundir
# Author: joishi (joishi@amnh.org) (modified from W. Dobler's cvs-add-rundir)
# Date:   23-may-2006
# Description:
#   Add the current run directory to a SVN repository. Assumes that the
#   directory above (`..') is already under SVN.
# Usage:
#   [create new run directory; pc_setupsrc; mkinpars; tune parameters]
#   newrundir>  svn-add-rundir
#
set rundir = `pwd`
set commit = 0
set extended = 0
set simdir = 0
set cmdname = $0
set cmdname = $cmdname:t

if ($#argv > 0) then
  if (("$1" == "-h") || ("$1" == "--help")) then
    goto usage
  endif
  if (("$1" == "-c") || ("$1" == "--commit")) then
    set commit = 1
  endif
  if (("$1" == "-x") || ("$1" == "--extended")) then
    set extended = 1
  endif
  if (("$1" == "-s") || ("$1" == "--simulation")) then
    set simdir = 1
  endif
endif

(cd ..; svn add -N $rundir:t)
svn add *.in
svn add -N src
svn propset svn:keywords "Id" *.in

if ($simdir) then
    svn add --depth=empty ./data/proc0/
    svn add ./data/proc0/grid.dat
    svn add ./data/proc0/dim.dat
    set extended = 1
endif

if ($extended) then
    svn add k.dat
    svn add -N ./data/
    svn add ./data/*.nml
    svn add ./data/time_series.dat
    svn add ./data/pdim.dat
    svn add ./data/dim.dat
endif

svn add src/*.local
svn propset svn:keywords "Id" src/*.local

if ($commit) then
  svn commit
endif

exit:
exit

usage:

echo "Usage:"
echo "  $cmdname [-c|--commit]"
echo "Add the current run directory to the SVN repository. Assumes that the"
echo "directory above (..) is already under SVN."
echo "With -c (--commit) do 'svn commit', too."
echo "With -x (-extended) add the data directory, the timeseries, and "
echo "    namelists and dimensional data for basic postprocessing"

# End of file svn-add-rundir