#!/bin/sh # $Id: imosflm,v 1.79 2015/06/26 13:59:57 harry Exp $ # echo $USER `date` | cat >> /public/xtal/imosflm/users.lst # At LMB (and probably elsewhere!) ignore the following 3 lines - this should # be set up in a site-wide setup file. # # N.B. If you want to setup a site-wide installation, you'll probably want to # edit and uncomment the following lines to point to the site-wide wish8.4 # and Mosflm executables #export MOSFLM_WISH=/path/to/your/wish8.4 #if [ -z "${MOSFLM_EXEC}" ]; then # MOSFLM_EXEC="ipmosflm" # export MOSFLM_EXEC #fi #echo "MOSFLM_EXEC set to "$MOSFLM_EXEC STARTDIR= IMAGEDIR= FILE= SITE= TEMPLATESET= SINGLESET= STARTDIRSET= IMAGEDIRSET= FILEGIVEN= SITEGIVEN= MOSFLM_LOGGING=0 MOSFLMFILE="" CCP4I2=0 EXPERTDETECTORSETTINGS=0 FASTLOAD=0 LMBNAMEFORMOSFLM='mosflm' CCP4NAMEFORMOSFLM='ipmosflm' RUNBYTOPLEVELIMOSFLMTCL='0' # next line is over-ridden by "./release.csh" thisVersion="iMosflm version 7.2.1, 26th June 2015" IMOSFLM_VERSION="iMosflm version 7.2.1, 21st September 2015" export MOSFLM_LOGGING export MOSFLMFILE export CCP4I2 export EXPERTDETECTORSETTINGS export FASTLOAD export IMOSFLM_VERSION export LMBNAMEFORMOSFLM export CCP4NAMEFORMOSFLM export RUNBYTOPLEVELIMOSFLMTCL usage() { echo "Usage: imosflm [options]..." echo "Options:" echo "--allimages, -a " echo " Starts mosflm loading all files that match the template" echo " generated from " # echo "--ccp4i2 Autosaves an iMosflm session file upon exit" echo " with an XML list of all iMosflm output files." # echo "--debug, -d Creates a large output file for debugging purposes" echo " Don't use this unless asked to by a developer" # echo "--expert, -e Permits access to advanced detector settings." echo " This should not normally be required" # echo "--fastload, -f Attempt to speed loading of many images offline" echo " while indexing two default images separated by" echo " 90 degrees" # echo "--help, -h Displays this message, then exits" # echo "--imagedir, -I " echo " Starts the image browser in this directory; if " echo " is given as an environment variable, it will be expanded" echo " to its full value" # echo "--init, -i " echo " Starts Mosflm and reads from the given saved session file" # echo "--mosflm-debug, -m" echo " activates hidden debugging messages (for developers only)" # echo "--startdir, -S " echo " Starts mosflm in directory rather than the current" echo " directory. This will only work if the directory exists and " echo " you have write permission to it, otherwise iMosflm will exit." echo " All the normal mosflm output files will be in this directory" # echo "--singleimage, -s " echo " Starts mosflm loading only the image from " # echo "--site, -X " echo " Reads any/all of the following lines from the file given" echo " WAVELENGTH " echo " DISPERSION " echo " POLARISATION [PINHOLE | MIRRORS | MONOCHROMATOR | SYNCHROTRON ]" echo " DIVERGENCE " echo " BEAM " echo " DISTANCE " echo " DISTORTION TILT " echo " DISTORTION TWIST " echo " GAIN " echo " DETECTOR REVERSEPHI" echo " DETECTOR OMEGA " # echo "--version, -v Displays the program version and required Mosflm version, " echo " then exits" echo "" echo "These can be abbreviated to the shortest unambiguous string" exit } # Remove any previous copy of the startup file if [ -e $HOME/.mosflm/initfile ] then /bin/rm -f $HOME/.mosflm/initfile fi # Remove any previous copy of the site file if [ -e $HOME/.mosflm/sitefile ] then /bin/rm -f $HOME/.mosflm/sitefile fi # command-line options for X do case $X in --ccp4i2|--ccp*) echo "* CCP4i2 mode on - be VERY sure you want this" CCP4I2=1 export CCP4I2 ;; --debug|--d*) #echo "* full debugging turned on - a log of your session will be stored in a" #echo " datestamped file called something like \"logfile`date \"+%Y%m%d_%H%M%S\"`.debug\"" MOSFLM_LOGGING=1 export MOSFLM_LOGGING sleep 2 ;; --expert|--e*|-e) echo "* Expert mode on - be VERY sure you want this" EXPERTDETECTORSETTINGS=1 export EXPERTDETECTORSETTINGS ;; --fastload|--fast*|--f*|-f) echo "* FASTLOAD mode on" FASTLOAD=1 export FASTLOAD ;; --help|-h) usage ;; --allimages|--a*|-a) TEMPLATESET=1 ;; --imagedir|--im*|-I) IMAGEDIRSET=1 ;; --init|--in*|-i) FILEGIVEN=1 ;; --mosflm-debug|--m*|-m) MOSFLM_DEBUG=1 export MOSFLM_DEBUG ;; --singleimage|--sin*|-s) SINGLESET=1 ;; --site|--sit*|-X) SITEGIVEN=1 ;; --startdir|--st*|-S) STARTDIRSET=1 ;; --version|--v*|-v) echo "* ${IMOSFLM_VERSION}" exit ;; *) if [ "$IMAGEDIRSET" != "" ] then IMAGEDIR=$X export IMAGEDIR if [ -d $IMAGEDIR ] then if [ -r $IMAGEDIR ] then echo "* mosflm will start by looking for images in $IMAGEDIR" else echo "" echo "You don't have read permission for directory $IMAGEDIR" echo "iMosflm will revert to the current start directory " IMAGEDIR= export IMAGEDIR fi else echo "" echo "$IMAGEDIR is not a directory" echo "iMosflm will revert to the current start directory " IMAGEDIR= export IMAGEDIR fi IMAGEDIRSET= elif [ "$TEMPLATESET" != "" ] then /bin/rm -f $HOME/.mosflm/template TEMPLATE=$X export TEMPLATE if [ -z $IMAGEDIR ] then IMAGEDIR=${PWD} fi if [ -e $IMAGEDIR/$TEMPLATE ] then if [ -r $IMAGEDIR/$TEMPLATE ] then echo "* mosflm will load all images from $IMAGEDIR" echo " matching the template from file $TEMPLATE" TEMPLATE=$IMAGEDIR/$TEMPLATE export TEMPLATE else echo "" echo "You don't have read permission for template file $IMAGEDIR/$TEMPLATE" echo "" TEMPLATE= export TEMPLATE fi else echo "" echo "The template file $IMAGEDIR/$TEMPLATE does not exist" echo "" TEMPLATE= export TEMPLATE fi TEMPLATESET= elif [ "$SINGLESET" != "" ] then /bin/rm -f $HOME/.mosflm/SINGLE SINGLE=$X export SINGLE if [ ! -z $IMAGEDIR ] then SINGLE=$IMAGEDIR/$SINGLE fi if [ -e $SINGLE ] then if [ -r $SINGLE ] then echo "* mosflm will load the image in $SINGLE" else echo "" echo "You don't have read permission for the file $SINGLE" echo "" SINGLE= export SINGLE fi else echo "" echo "The file $SINGLE does not exist" echo "" SINGLE= export SINGLE fi SINGLESET= elif [ "$STARTDIRSET" != "" ] then STARTDIR=$X export STARTDIR if [ -d $STARTDIR ] then if [ -w $STARTDIR ] then echo "* mosflm will start in directory $STARTDIR" echo " all the mosflm log files will be there" else echo "" echo "You don't have write permission for directory $STARTDIR" echo "exiting iMosflm now" exit fi else echo "" echo "$STARTDIR is not a directory" echo "exiting iMosflm now" exit fi STARTDIRSET= elif [ "$FILEGIVEN" != "" ] then FILE=$X export FILE if [ "$STARTDIR" != "" ]; then :; else STARTDIR=${PWD} export STARTDIR fi if [ -e $STARTDIR/$FILE ] then if [ -r $STARTDIR/$FILE ] then echo "* mosflm will initialize values from file $STARTDIR/$FILE" export MOSFLMFILE if [ -d $HOME/.mosflm ]; then :; else /bin/mkdir $HOME/.mosflm fi /bin/cp -f $STARTDIR/$FILE $HOME/.mosflm/initfile MOSFLMFILE=1 export MOSFLMFILE else echo "" echo "You don't have read permission for file $STARTDIR/$FILE" echo "exiting iMosflm now" exit fi else echo "" echo "File $STARTDIR/$FILE does not exist" echo "exiting iMosflm now" exit fi FILEGIVEN= elif [ "$SITEGIVEN" != "" ] then SITE=$X export SITE if [ "$STARTDIR" != "" ]; then :; else STARTDIR=${PWD} export STARTDIR fi if [ -e $STARTDIR/$SITE ] then if [ -r $STARTDIR/$SITE ] then echo "* mosflm will read site specific parameters from file $STARTDIR/$SITE" export MOSFLMSITE if [ -d $HOME/.mosflm ]; then :; else /bin/mkdir $HOME/.mosflm fi /bin/cp -f $STARTDIR/$SITE $HOME/.mosflm/sitefile MOSFLMSITE=1 export MOSFLMSITE else echo "" echo "You don't have read permission for file $STARTDIR/$SITE" echo "exiting iMosflm now" exit fi else echo "" echo "File $STARTDIR/$SITE does not exist" echo "exiting iMosflm now" exit fi SITEGIVEN= else echo "$X is not an option" usage fi ;; esac done # if [ "`uname`" = "Darwin" ] # echo looks like an Intel Mac to me... # then # echo looks like an Intel Mac to me..looks like an Intel Mac to me.... # export GFORTRAN_UNBUFFERED_ALL=1 # fi case $0 in /*) abspath=$0 ;; *) abspath=$PWD/$0 ;; esac # function to test wish executable test_wish() { WISH_FAIL=0 $1< /dev/null if [ $? -eq 0 ] then echo testing MOSFLM_WISH \($MOSFLM_WISH\) # Test that it has all require packages test_wish $MOSFLM_WISH if [ $WISH_FAIL -eq 1 ] then echo "" echo "Cannot use wish8.4 executable pointed to by" echo "MOSFLM_WISH environment variable." echo "Your tcl/tk installation ($MOSFLM_WISH) is" echo "missing the following required tcl/tk packages:" diagnoze_failure echo "To use a different tcl/tk installation set the" echo "environment variable \"MOSFLM_WISH\" to the" echo "full pathname of your prefered wish8.4 executable" echo "" else FOUND_WISH=1 # normal start of iMosflm here if [ "$STARTDIR" != "" ] then cd $STARTDIR fi exec $MOSFLM_WISH ${abspath}.tcl fi else echo "" echo "Environment variable MOSFLM_WISH does not point to" echo "a valid wish8.4 executable!" echo "" fi fi if [ $FOUND_WISH != 1 ] then # Test wish8.4 in path type wish8.4 &> /dev/null if [ $? -eq 0 ] then # Test found wish8.4 DEFAULT_WISH=`which wish8.4` echo "Testing default wish8.4 executable ($DEFAULT_WISH)." test_wish $DEFAULT_WISH if [ $WISH_FAIL -eq 1 ] then echo "The default wish8.4 installation is missing the" echo "following required tcl/tk packages:" diagnoze_failure echo "" else echo "Running imosflm with default wish8.4 executable ($DEFAULT_WISH)." FOUND_WISH=1 # normal start of iMosflm here if [ "$STARTDIR" != "" ] then cd $STARTDIR fi exec $DEFAULT_WISH ${abspath}.tcl fi fi fi if [ $FOUND_WISH != 1 ] then echo "Please enter the path of a wish8.4 executable from" echo "the tcl/tk installation you wish to use:" echo "(Or just hit to exit):" read MY_WISH if [ "$MY_WISH" != "" ] then type $MY_WISH &> /dev/null if [ $? -eq 0 ] then test_wish $MY_WISH if [ $WISH_FAIL -eq 1 ] then echo "Your wish8.4 executable ($MY_WISH) is missing" echo "the following required packages:" diagnoze_failure echo "" else FOUND_WISH=1 # normal start of iMosflm here if [ "$STARTDIR" != "" ] then cd $STARTDIR fi exec $MY_WISH ${abspath}.tcl fi else echo "Could not run $MY_WISH" echo "Please check file permissions and try again." echo "" exit fi fi fi if [ $FOUND_WISH -ne 1 ] then echo "No wish8.4 executable with all required packages was found." echo "You can download a \"batteries included\" tcl/tk distribution" echo "which includes wish8.4 executable and all require packages from:" echo "www.activestate.com" echo "" fi