#!/bin/sh      
#!/usr/bin/ksh 
#           file: dirdif < dirdif.script                   15 Aug. 2008
#                 ------ < -------------
# /bin/sh :Bourne shell for HP, IBM Risc, Silicon Gr., and Sun machines
# /usr/bin/ksh :  Korn shell for DEC machines

    DDSYST=$HOME/dirdif   
#   DDSYST=/NSRlab/dirdif
 
# |--------------------------------------------------------------------|
# |--------------------------------------------------------------------|
# |                          DIRDIF-2008                             |
# |                                                                    |
# |      Crystal Structure Determination by Patterson Methods and      |
# |      Direct Methods  applied to  Difference Structure Factors      |
# |                                                                    |
# |      Paul T. Beurskens,   Gezina Beurskens,   Rene de Gelder,      |
# |      Jan M.M. Smits (Nijmegen),   S. Garcia-Granda (Oviedo) &      |
# |                       R.O. Gould (Edinburgh)                       |
# |                                                                    |
# |      Crystallography Laboratory, Radbout University, Nijmegen      |
# |          Toernooiveld 1, 6525 ED Nijmegen, The Netherlands         |
# |                                                                    |
# |--------------------------------------------------------------------|
# |--------------------------------------------------------------------|
# |                                                                    |
# |  Script for EXECUTING the program system DIRDIF-2008               |
# |  Specifications of this script:   Bourne shell  or  Korn shell     |
# |                                                                    |
# |  The present unified version (one program replacing ten separately |
# |  operating programs) should be running on all computer platforms ! |
# |                                                                    |
# |  Acknowledgements for earlier implementations and script files for |
# |  DEC Alpha, DEC 5000, IBM Risc, Silicon Graphics Indigo and Irix,  |
# |  Sun, HP, various PC's, etcetera, with unix, Linex, Ultrix, aix,   |
# |  etcetera under Bourne and Korn shells.                            |
# |       We thank A.L. Spek, J.P. Declerq, G. Baudoux, R. Driessen,   |
# |  A. Meetsma and R.A. de Graaff for their kind help in implementing |
# |  the former complicated program systems DIRDIF 1992 through -1999. 
# |                                                                    |
# |--------------------------------------------------------------------|
# |                                                                    |
# |  Please, report/questions: PTBeurskens[AT]hetnet.nl  subject: DIRDIF
# |--------------------------------------------------------------------|
#
# NOTE: The execution of dirdif has to be from the directory with the 
#       structural data ! No parallel runs in the same directory !! 
#
#    -  Check the definition of the shell to be used for this script:
#       for some machines it may be necessary to remove the first
#       line of this script, to change from Bourne to Korn shell.
#    -  chmod  to make this script file executable.
#    -  The dirdif files are stored in the directory 'dirdif'
#       and the path to this directory must be defined like:
#          DDSYST=$HOME/dirdif       or, in Nijmegen:
#          DDSYST=/NSRlab/dirdif
 
                                            #   check user environment
    if [ `pwd` = $DDSYST ]; then
    echo "ATTENTION !!! Your working directory is `pwd`,  however,"
    echo "dirdif has to be called from a structure data directory."
    echo "Please, change your working directory to the appropriate"
    echo "structure data directory (CCODE)  and call dirdif again."
    exit 1 ; fi
    echo "Execute DIRDIF-2008.3 from pwd:  `pwd` "
 
    INDEX=$#                   # number of parameters given in the call
                                            # write these to file ddjob
    if [ -f ddjob ]; then rm ddjob; fi
    if [ $INDEX -gt 0 ]; then echo $1 $2 $3 $4 $5 > ddjob; fi         

    if [ ! -f oruser ]; then cp $DDSYST/oruser oruser; fi
    cp $DDSYST/orbase orbase        # make fragment data base available

    $DDSYST/DDEXE/DIRDIF                                 # Start dirdif 
    exit                  # End of dirdif script ----------------------
