Personal tools
You are here: Home Codes ZEUS 3D zeus34
Document Actions

zeus34

by streeter last modified 2005-08-31 05:44

Click here to get the file

Size 87.0 kB - File type text/plain

File contents

#!/bin/csh
#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>> BEGIN GENERIC XZEUS34 BLOCK 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#
# zeus34.s for ZEUS-3D Version 3.4.2
#
# This script creates the ZEUS-3D executable "xzeus34" on many systems.
#
# Written by Robert Fiedler
# Last revised: 20 May 97
#
# Laboratory for Computational Astrophysics
# National Center for Supercomputing Applications
# University of Illinois at Urbana-Champaign
#
################################################################
# Modified by Dave McWilliams
#    6 April 1999
#
# ZEUS3D is no longer available from space.ncsa.uiuc.edu.
# It is now available only via anonymous FTP from
# ftp://ftp.ncsa.uiuc.edu/lca/zeus3d.  I have modified 
# this script so it gets ZEUS3d from NCSA's anonymous FTP 
# server.  
################################################################
#
# TO OBTAIN ZEUS-3D FOR YOUR SYSTEM AND RUN A SMALL TEST PROBLEM:
#
#   1) Download this script
#   2) Give yourself execute permission ("chmod 700 zeus34.s")
#   3) Type "zeus34.s"
#   4) Wait for your system to compile the many ZEUS-3D routines
#   5) Type "xzeus34" to run ZEUS-3D
#
# This script will try to identify your system and connect to 
# space.ncsa.uiuc.edu for any files needed to build xzeus34.
#
# A test problem is set up by this script as it executes the
# statements in the "SETUP BLOCK" included below.
#
# TO CUSTOMIZE ZEUS-3D FOR THE SIMULATION YOU WISH TO PERFORM:
#
#   1) Create or download from space.ncsa.uiuc.edu a "setup block" file
#      that you have edited as described in the ZEUS-3D USER MANUAL.
#
#   2) Type "zeus34.s <setup block filename>", where
#      <setup block filename> is the name of the file.
#
#  More examples of setup blocks may be found at 
#    ftp://ftp.ncsa.uiuc.edu/lca/zeus3d/tests
#  Their names are "shkset_XYZ", "blast_XYZ", "blast_ZRP", and
#  "blast_RTP". 
#   
#  The setup block contains the input file "inzeus", the
#  macro definition file "zeus34.mac", and the master change deck
#  "chgzeus" described in the USER MANUAL.  I have put them together
#  in one block to make it easier to set up different problems --
#  now you need to edit just one file, and there is just one version
#  of zeus34.s!  See the comments in the setup block below for details.
#
# TO RUN BENCHMARKS:
#
#    In ftp://ftp.ncsa.uiuc.edu/lca/zeus3d/tests/blast/XYZ
#    there is a setup block called blast_HY and several scripts
#    that make benchmarking easier.  See results for many systems at
#
#      http://zeus.ncsa.uiuc.edu:8080/lca_benchmarks.html
#
# ADDITIONAL INFORMATION
#
# This script works automatically for the following machines (hosts):
#
#   c3          Convex 3880               at NCSA
#   uxh         Convex 240                at UIUC
#
#   ella        Convex Exemplar SPP-2000  at NCSA
#   billie      Convex Exemplar SPP-2000  at NCSA
#   tuvok       Convex Exemplar SPP-2000  at NRL
#   dax         Convex Exemplar SPP-2000  at NRL
#   lena        Convex Exemplar SPP-1200  at NCSA
#
#   mario       Cray C90                  at PSC
#   wind        Cray J90                  at Eagan, MN
#
#   loki        SGI Challenge             at NCSA  <--(running IRIX 6.2)
#
#   bragi       SGI Power Challenge R8000 at NCSA  |--(running IRIX 6.2)
#   idun        SGI Power Challenge R8000 at NCSA  |
#   odin        SGI Power Challenge R8000 at NCSA  |
#   thor        SGI Power Challenge R8000 at NCSA  |
#
#   sif         SGI Pwr. Challenge R10000 at NCSA  |--(running IRIX 6.2)
#   freya       SGI Pwr. Challenge R10000 at NCSA  |
#   magna       SGI Pwr. Challenge R10000 at NCSA  |
#   vidar       SGI Pwr. Challenge R10000 at NCSA  |
#   vali        SGI Pwr. Challenge R10000 at NCSA  |
#   picasso     SGI Pwr. Challenge R10000 at NCSA  |
#
#   modi1       SGI Origin 2000 at NCSA            |--(running IRIX 6.4)
#   modi2       SGI Origin 2000 at NCSA            |
#   modi3       SGI Origin 2000 at NCSA            |
#   modi4       SGI Origin 2000 at NCSA            |
#
#   athena      HP PA-RISC 715/80         at NCSA  |
#   nl-ibm1     IBM RS/6000 (public)      at NCSA  |
#   sangamon    Sun Solaris (public)      at NCSA  |--(workstations)
#   space       Sun SUNOS   (public)      at NCSA  |
#   zeus        SGI Indigo 2 Extreme      at NCSA  |
#
# When used with other hosts, the user is prompted for additional info.
#
# If asked to identify the operating system, type one of the following:
#
# "ALPHA"    (for DEC ALPHA workstations)
# "CONVEXOS" (for Convex C Series vector supercomputers)
# "EXEMPLAR" (for Convex Exemplar PA-RSIC multiprocessors)
# "HP"       (for Hewlett Packard PA-RISC workstations)
# "IBM"      (for IBM RS/6000 workstations)
# "IRIX"     (or "IRIX, SGIMP" for SGI multiprocessors)
# "SOLARIS"  (for Sun workstations running Sun Solaris)
# "SUNOS"    (for Sun workstations running Sun OS)
# "UNICOS"   (or "UNICOS, CALMATH" for a Cray with the CALMATH library)
#
# To create the executable xzeus34, the following files are needed
# and will be retrieved if necessary by this script via AFS or ftp:
#
# zeus34.s          This script
# zeus34.mac        Macro definitions (one version is included below)
# zeus34            ZEUS-3D source code, version 3.4.2.
# fixes34           Bug fixes for version 3.4.2 of the source code.
# xedit22           EDITOR executable to edit files
# namelist.a        Library to simulate FORTRAN namelist
# cfiles.a          C program that checks for tty input
# ncar(d).a         Library of (dummy) NCAR interface routines
#
# The above files (or sources to generate them) are stored on AFS and
# will be copied to the current working directory by this script if
# they don't exist there already.
#
# For machines without NCSA AFS access, files will be retrieved from
# NCSA's anonymous FTP site at ftp://ftp.ncsa.uiuc.edu/lca/.  
#
# If you have access to AFS but no account on NCSA's AFS servers, you
# can also use the 'zeus3d' account, provided your AFS server has the
# cell ncsa.uiuc.edu mounted (check your local /afs directory for a
# subdirectory by that name). This script issues the command
#
#   "klog zeus3d -cell ncsa.uiuc.edu"
#
# to access ZEUS-3D source codes and executables.  You are prompted for
# the password for this account, but do not need to enter any other AFS
# commands.
#
# For "unknown" machines (i.e., other than mario, loki, odin, etc.),
# this script gets the source codes edit22, namelist,
# checkin.c (and move.c or ttimer.c), and ncar(d) to generate the 
# EDITOR executable xedit22 and to create the libraries namelist.a, 
# cfiles.a, and ncar(d).a.
#
# ENVIRONMENT VARIABLES
#
# There are numerous environment variables defined and used in this
# script.  These varibles can be set to non-default values before
# running the script, in order to define the operating system or to
# change compiler options, for example.  This feature is used mainly
# when attempting to port ZEUS-3D to a new machine.  Below is a list of
# the environment variables that COULD be set.  If your machine name is
# not recognized, the script prompts you for the values of the variables
# whose names are marked by "*".  Default values for compliler and
# loader names, options, and libraries are determined from the operating
# system name.
#
#   HOST_NAME    Name of your machine (before the first ".")
# * OP_SYS       Operating system name
#   SERVER       Machine to retrieve files from (ftp.ncsa.uiuc.edu)
#   User         Your signon on SERVER (normally ftp)
# * ACCESS       Type of file transfer (AFS or ftp)
#   F_COMP       FORTRAN compiler name
#   F_COMP_OPTS  FORTRAN compiler options
#   F_C_OPTS     FORTRAN compiler options for compiling EDITOR
#   REAL         set to "real" for single precision, "real*8" for
#                double precision.  Always "real" for UNICOS.
#   IUTASK       EDITOR flag to insert parallelization directives
#                Default value is 0 except for SGI and EXEMPLAR multi-
#                processors
#   C_COMP       C compiler name
#   C_COMP_OPTS  C compiler options
#   LDR          Loader name (./ncargf77 with NCAR 3.1.2 or 3.2.1)
#   LDR_OPTS     Loader options
#   LD           Loader for loading EDITOR, including options
# * HDF          Set to "-ldf" with NCSA HDF library, "" without
# * NCAR_LIB     Set to "ncar" with NCAR v3.x.x, "ncard" without
#   LIBS         Libraries to load including HDF and NCAR
#   NZX1         Number of zones in the "1" direction
#   NZX2         Number of zones in the "2" direction
#   NZX3         Number of zones in the "3" direction
#   NXPX         Number of x-pixels in pixel dumps
#   NYPX         Number of y-pixels in pixel dumps
#   ENVIRONMENT  Set to "BATCH" for no interactive editing of input 
#                files (default: INTERACTIVE)
#   PAGER        Utility to display text on the terminal (default: more)
#   EDITOR       Text editor to use on input files (default: vi)  Please
#                do not confuse this with the EDITOR preprocessor!
#.......................................................................
#
onintr QUIT
echo ""
echo "BEGIN zeus3.4 ${*}:"
echo ""
unset noclobber
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ begin generic host identification block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Identify host, operating system, and means of accessing files on AFS.
#
if (! $?HOST_NAME) setenv HOST_NAME `hostname | sed -e 's/\..*//'`
if (! $?SERVER) setenv SERVER "ftp.ncsa.uiuc.edu"
if (! $?User) setenv User "ftp"
if (! ($?OSYS && $?OP_SYS && $?ACCESS && $?HDF && $?NCAR_LIB)) then
#
# Identify the system and set machine-specific variables.
#
  switch ($HOST_NAME)
  case uxh:
    if (! $?OSYS)     setenv OSYS      "CONVEXOS"
    if (! $?OP_SYS)   setenv OP_SYS    "CONVEXOS"
    if (! $?ACCESS)   setenv ACCESS    "ftp"
    if (! $?HDF)      setenv HDF       ""
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    breaksw
  case c3:
    if (! $?OSYS)     setenv OSYS      "CONVEXOS"
    if (! $?OP_SYS)   setenv OP_SYS    "CONVEXOS"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-ldf"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncar"
    if (! $?LDR)      setenv LDR       "./ncargf77"
    if (! $?NCARG_ROOT) setenv NCARG_ROOT "/usr/local/apps/graphics/ncar_3.1.2"
    breaksw
  case tuvok:
  case dax:
    if (! $?OSYS)     setenv OSYS      "EXEMPLAR"
    if (! $?OP_SYS)   setenv OP_SYS    "EXEMPLAR"
    if (! $?ACCESS)   setenv ACCESS    "ftp"
    if (! $?HDF)      setenv HDF       "-Wl,-L/scratch/fiedler/hdf/lib -ldf -ljpeg -lz"
    if (! $?NCAR_LIB)    setenv NCAR_LIB  "ncard"
    if (! $?F_COMP)      setenv F_COMP '/opt/fortran/bin/f77 -c'
    if (! $?F_COMP_OPTS) setenv F_COMP_OPTS '+O3 +Oparallel +Olibcalls +U77 +Odataprefetch'
    if (! $?C_COMP)      setenv C_COMP '/opt/ansic/bin/cc -c'
    if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  '-D_CONVEX_SOURCE'
    if (! $?LDR)         setenv LDR       "/opt/fortran/bin/f77"
    if (! $?LDR_OPTS)    setenv LDR_OPTS     '+O3 +Oparallel +Olibcalls +Odataprefetch -Wl,-a,archive_shared,+FPD,+vallcompatwarnings'
    if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a -lU77 -ldld -lcps -lail -lcnx_syscall -lpthread $HDF"
    breaksw
  case ella:
  case billie:
    if (! $?OSYS)     setenv OSYS      "EXEMPLAR"
    if (! $?OP_SYS)   setenv OP_SYS    "EXEMPLAR"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-Wl,-L/afs/ncsa/packages/hdf/exemplar/lib -ldf -ljpeg -lz"
    if (! $?NCAR_LIB)    setenv NCAR_LIB  "ncard"
    if (! $?F_COMP)      setenv F_COMP '/opt/fortran/bin/f77 -c'
    if (! $?F_COMP_OPTS) setenv F_COMP_OPTS '+O3 +Oparallel +Olibcalls +U77 +Odataprefetch'
    if (! $?C_COMP)      setenv C_COMP '/opt/ansic/bin/cc -c'
    if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  '-D_CONVEX_SOURCE'
    if (! $?LDR)         setenv LDR       "/opt/fortran/bin/f77"
    if (! $?LDR_OPTS)    setenv LDR_OPTS     '+O3 +Oparallel +Olibcalls +Odataprefetch -Wl,-a,archive_shared,+FPD,+vallcompatwarnings'
    if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a -lU77 -ldld -lcps -lail -lcnx_syscall -lpthread $HDF"
    breaksw
  case lena:
    if (! $?OSYS)     setenv OSYS      "EXEMPLAR"
    if (! $?OP_SYS)   setenv OP_SYS    "EXEMPLAR"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-L/afs/ncsa/packages/hdf/exemplar/lib -ldf -ljpeg -lz"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    if (! $?LDR)      setenv LDR       "/usr/convex/bin/fc"
    breaksw
  case loki:
    if (! $?OSYS)     setenv OSYS      "IRIX"
    if (! $?OP_SYS)   setenv OP_SYS    "IRIX, SGIMP"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-L/afs/ncsa/packages/hdf/IRIX_5.2/lib -ldf -ljpeg -lz"
    if (! $?F_COMP_OPTS)  setenv F_COMP_OPTS '-O2 -w -g3 -32 -mips2 -pfa list -WK,-ro=3,-so=3,-o=5,-as=l'
    if (! $?C_COMP_OPTS)  setenv C_COMP_OPTS '-g3 -32 -mips2'
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    breaksw
  case freya:
  case magna:
  case picasso:
  case sif:
  case vali:
  case vidar:
    setenv HOST_NAME sgipc
    if (! $?OSYS)     setenv OSYS      "IRIX"
    if (! $?OP_SYS)   setenv OP_SYS    "IRIX, SGIMP"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-L/afs/ncsa/packages/hdf/IRIX_6.2/lib -ldf -ljpeg -lz"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncar"
    if (! $?F_COMP_OPTS)  setenv F_COMP_OPTS '-O3 -w -g3 -64 -mips4 -r10000 -pfa list -WK,-ro=3,-so=3,-o=5,-as=l -OPT:roundoff=3,IEEE_arithmetic=3'
    if (! $?C_COMP_OPTS)  setenv C_COMP_OPTS '-g3 -64 -mips4 -r10000 -OPT:roundoff=3,IEEE_arithmetic=3'
    if (! $?LDR)      setenv LDR       "./ncargf77"
    if (! $?LDR_OPTS) setenv LDR_OPTS  "-mp -64 -mips4 -r10000"
    if (! $?NCARG_ROOT) setenv NCARG_ROOT "/afs/ncsa/packages/ncar/IRIX_6.0"
    breaksw
  case bragi:
  case idun:
  case odin:
  case thor:
    setenv HOST_NAME sgipc
    if (! $?OSYS)     setenv OSYS      "IRIX"
    if (! $?OP_SYS)   setenv OP_SYS    "IRIX, SGIMP"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-L/afs/ncsa/packages/hdf/IRIX_6.2/lib -ldf -ljpeg -lz"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncar"
    if (! $?F_COMP_OPTS)  setenv F_COMP_OPTS '-O3 -w -g3 -64 -mips4 -r8000 -pfa list -WK,-ro=3,-so=3,-o=5,-as=l -OPT:roundoff=3,IEEE_arithmetic=3'
    if (! $?C_COMP_OPTS)  setenv C_COMP_OPTS '-g3 -64 -mips4 -r8000 -OPT:roundoff=3,IEEE_arithmetic=3'
    if (! $?LDR)      setenv LDR       "./ncargf77"
    if (! $?LDR_OPTS) setenv LDR_OPTS  "-mp -64 -mips4 -r10000"
    if (! $?NCARG_ROOT) setenv NCARG_ROOT "/afs/ncsa/packages/ncar/IRIX_6.0"
    breaksw
  case modi1:
  case modi2:
  case modi3:
  case modi4:
    setenv HOST_NAME origin
    if (! $?OSYS)     setenv OSYS      "IRIX"
    if (! $?OP_SYS)   setenv OP_SYS    "IRIX, SGIMP"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-L/afs/ncsa/packages/hdf/IRIX_6.4/lib -ldf -ljpeg -lz"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    if (! $?F_COMP_OPTS)  setenv F_COMP_OPTS '-O3 -w -64 -mips4 -r10000 -mp -OPT:roundoff=3,IEEE_arithmetic=3,fast_sqrt=on -LNO:prefetch_ahead=4'
    if (! $?C_COMP_OPTS)  setenv C_COMP_OPTS '-64 -mips4 -r10000 -OPT:roundoff=3,IEEE_arithmetic=3'
    if (! $?LDR)      setenv LDR       "f77"
    if (! $?LDR_OPTS) setenv LDR_OPTS  "-mp -64 -mips4 -r10000"
    breaksw
  case zeus:
    if (! $?OSYS)     setenv OSYS      "IRIX"
    if (! $?OP_SYS)   setenv OP_SYS    "IRIX"
    if (! $?ACCESS)   setenv ACCESS    "ftp"
    if (! $?HDF)      setenv HDF       "-ldf"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    breaksw
  case space:
    if (! $?OSYS)     setenv OSYS      "SUNOS"
    if (! $?OP_SYS)   setenv OP_SYS    "SUNOS"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-ldf"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    breaksw
  case mario:
    if (! $?OSYS)     setenv OSYS      "UNICOS"
    if (! $?OP_SYS)   setenv OP_SYS    "UNICOS"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-ldf"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncar"
    if (! $?LDR)      setenv LDR       "SHELL=/bin/sh ; export SHELL ; setup ncargks ; cf77"
    if (! $?LIBS)     setenv LIBS      "-lncargks -lX11 $HDF namelist.a cfiles.a ${NCAR_LIB}.a"
    breaksw
  case wind:
    if (! $?OSYS)     setenv OSYS      "UNICOS"
    if (! $?OP_SYS)   setenv OP_SYS    "UNICOS"
    if (! $?ACCESS)   setenv ACCESS    "ftp"
    if (! $?HDF)      setenv HDF       ""
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    if (! $?LDR)      setenv LDR       "cf77"
    if (! $?LIBS)     setenv LIBS      "$HDF namelist.a cfiles.a ${NCAR_LIB}.a"
    breaksw
  case nl-ibm1:
    if (! $?OSYS)     setenv OSYS      "IBM"
    if (! $?OP_SYS)   setenv OP_SYS    "IBM"
    if (! $?ACCESS)   setenv ACCESS    "ftp"
    if (! $?HDF)      setenv HDF       "-L/usr/local/lib -ldf"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    breaksw
  case athena:
    if (! $?OSYS)     setenv OSYS      "HP"
    if (! $?OP_SYS)   setenv OP_SYS    "HP"
    if (! $?ACCESS)   setenv ACCESS    "AFS"
    if (! $?HDF)      setenv HDF       "-ldf"
    if (! $?NCAR_LIB) setenv NCAR_LIB  "ncard"
    breaksw
  default:
    setenv HOST_NAME "unknown"
#
# Ask the user about the system and access to the server.
#
    if (! $?OP_SYS) then
      echo "Please identify your machine's operating system. Enter one of:"
      echo "ALPHA           - for DEC ALPHA workstations"
      echo "CONVEXOS        - for Convex C Series"
      echo "EXEMPLAR        - for Convex Exemplar multiprocessors"
      echo "HP              - for HP workstations"
      echo "IBM             - for IBM RS/6000 workstations"
      echo "IRIX            - for SGI workstations"
      echo "IRIX, SGIMP     - for SGI multiprocessors"
      echo "SUNOS           - for SUN workstations running SUNOS"
      echo "SOLARIS         - for SUN workstations running SOALRIS"
      echo "UNICOS          - for Cray X-MP, Y-MP, or C90"
      echo "UNICOS, CALMATH - for Cray with the CALMATH library"
      echo ""
      echo -n "Your system: "
#
      LOOP_S:
      setenv OP_SYS "$<"
      if ("$OP_SYS" != "CONVEXOS" && "$OP_SYS" != "HP" && \
          "$OP_SYS" != "EXEMPLAR" && "$OP_SYS" != "ALPHA" && \
          "$OP_SYS" != "IRIX" && "$OP_SYS" != "IRIX, SGIMP" && \
          "$OP_SYS" != "UNICOS" && "$OP_SYS" != "UNICOS, CALMATH" && \
          "$OP_SYS" != "SOLARIS" && \
          "$OP_SYS" != "SUNOS"  && "$OP_SYS" != "IBM") then
        echo "This script may not work for $OP_SYS.  Please type"
        echo -n "QUIT to quit or a carriage return to continue.: " 
        set CONTIN = "$<"
        if ("$CONTIN" == "QUIT") goto QUIT
      endif
    endif
#
# Derive OSYS from OP_SYS
#
    set OPSYS = ($OP_SYS)
    if ($#OPSYS > 1) then
      setenv OSYS `echo $OPSYS[1] | sed -e 's/,//'`
      shift OPSYS
      echo "System identified as ${OSYS}, ${OPSYS}."
    else
      setenv OSYS $OPSYS
      echo "System identified as $OSYS."
    endif
#
    if (! $?ACCESS) then
      echo -n \
        "Specify file transfer method (AFS or ftp; default:ftp): "
      LOOP_A:
      setenv ACCESS "$<"
      if ("$ACCESS" == "QUIT") goto QUIT
      if ("$ACCESS" != "AFS" && "$ACCESS" != "ftp" && "$ACCESS" != "") then
        echo -n "Please type AFS, ftp, or QUIT: "
        goto LOOP_A
      endif
      if ($ACCESS == "") setenv ACCESS ftp
    endif
    echo "If necessary, files will be copied from $SERVER using $ACCESS."
#
# Ask about Graphics libraries.
#
    if (! $?HDF) then
      echo -n "Does your system have the NCSA HDF library (y/n; default n)? "
      setenv HDF "$<"
      if ("$HDF" == "y") then
        setenv HDF "-ldf"
      else
        setenv HDF ""
      endif
    endif
    if (! $?NCAR_LIB) then
      echo -n "Does your system have NCAR Graphics (y/n; default n)? "
      setenv NCAR_LIB "$<"
      if ($NCAR_LIB == "y") then
        setenv NCAR_LIB "ncar"
        if (! $?LDR) then
          echo  "Name the loader to use.  Default is ./ncargf77, but ncargf77 or"
          echo  "SHELL=/bin/sh ; export SHELL ; setup ncargks ; cf77"
          echo -n "may be preferable: "
          setenv LDR "$<"
          if ("$LDR" == "") setenv LDR "./ncargf77"
          if ("$LDR" == "./ncargf77" || "$LDR" == "ncargf77") then
            if (! $?NCARG_ROOT) then
              echo "The NCAR environment variable NCARG_ROOT is not set."
              echo "If your PATH does not allow access to the ncargpar"
              echo "command, I will be unable to locate the NCAR libraries"
              echo "and commands I need."
            endif
          endif
          set TEST = `echo "$LDR" | grep "setup ncargks"`
          if ("$TEST" != "") then
            echo ""
            echo "Be sure to include these libraries in LIBS: -lncargks -lX11"
            echo ""
          endif
        endif
      else
        setenv NCAR_LIB "ncard"
      endif
    endif
    breaksw
  endsw
endif
#
# To help keep compiler options the same between scripts, we define a
# set of environment variables for FORTRAN compiler, C compiler,
# and loader options.  If these compiler options are changed, the
# libraries namelist.a, cfiles.a, and ncar.a should be
# recreated by rerunning the appropriate scripts.
#
switch ($OSYS)
case CONVEXOS:
  if (! $?F_COMP)      setenv F_COMP 'fc -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS  '-fi -O2 -nw -or none -cxdb'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  '-fi -O2 -cxdb'
  if (! $?LDR)         setenv LDR       "fc"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     '-fi -O2'
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF -lveclib"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case EXEMPLAR:
  if (! $?F_COMP)      setenv F_COMP '/usr/convex/bin/fc -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS '-O3 -na -nw -or none -cxdb'
  if (! $?C_COMP)      setenv C_COMP '/usr/convex/bin/cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  '-cxdb'
  if (! $?LDR)         setenv LDR       "/usr/convex/bin/fc"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     ''
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF -lveclib"
  if (! $?IUTASK)      setenv IUTASK 1
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case UNICOS:
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?F_COMP)      setenv F_COMP 'cf77 -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS  '-M0726 -ez'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR     "cf77"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     ''
  if (! $?LIBS)        setenv LIBS "$HDF namelist.a cfiles.a ${NCAR_LIB}.a"
  set TEST = `echo "$LDR" | grep "setup ncargks"`
  if ("$TEST" != "") setenv LIBS "-lncargks -lX11 $LIBS"
  if ("$OP_SYS" == "UNICOS, CALMATH") setenv LIBS "-lcalmath $LIBS"
  if (! $?REAL)        setenv REAL "real"
  breaksw
case IRIX:
  if (! $?F_COMP)      setenv F_COMP 'f77 -c'
  if (! $?F_COMP_OPTS) then
    if ("$HOST_NAME" == "sgipc") then
      if ("$OP_SYS" == "IRIX, SGIMP") then
        setenv F_COMP_OPTS  '-O3 -w -g3 -64 -mips4 -r10000 -pfa list -WK,-ro=3,-so=3,-o=5,-as=l -OPT:roundoff=3,IEEE_arithmetic=3'
      else
        setenv F_COMP_OPTS  '-O3 -w -g3 -64 -mips4 -r10000 -OPT:roundoff=3,IEEE_arithmetic=3'
      endif
    else if ("$HOST_NAME" == "loki") then
      if ("$OP_SYS" == "IRIX, SGIMP") then
        setenv F_COMP_OPTS  '-O2 -w -g3 -32 -mips2 -pfa list -WK,-ro=3,-so=3,-o=5,-as=l'
      else
        setenv F_COMP_OPTS  '-O2 -w -g3 -32 -mips2'
      endif
    else
      setenv F_COMP_OPTS  '-O2 -w -g3 -Nq9999'
    endif
  endif
  if (! $?C_COMP_OPTS) then
    if ("$HOST_NAME" == "sgipc") then
      setenv C_COMP_OPTS  '-g3 -w -g3 -64 -mips4 -r10000 -OPT:roundoff=3,IEEE_arithmetic=3'
    else if ("$HOST_NAME" == "loki") then
      setenv C_COMP_OPTS  '-g3 -w -g3 -32 -mips2'
    else
      setenv C_COMP_OPTS  '-g3'
    endif
  endif
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?LDR)         setenv LDR       "f77"
  if (! $?LDR_OPTS) then
    if ("$OP_SYS" == "IRIX, SGIMP") then
      setenv LDR_OPTS     '-mp'
    else
      setenv LDR_OPTS     ''
    endif
  endif
  if (! $?LIBS) then
    setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
    if ("$HOST_NAME" == loki) then
      setenv LIBS "$LIBS -lcomplib.sgimath -lfastm"
    else if ("$HOST_NAME" == sgipc) then
      setenv LIBS "$LIBS -lblas"
    endif
  endif
  if (! $?IUTASK) then
    if ("$OP_SYS" == "IRIX, SGIMP") then
      setenv IUTASK 1
    else
      setenv IUTASK 0
    endif
  endif
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case HP:
  if (! $?F_COMP)      setenv F_COMP 'f77 -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS '+O3'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR       "f77"
  if (! $?LDR_OPTS)    setenv LDR_OPTS '+U77'
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case IBM:
  if (! $?F_COMP)      setenv F_COMP 'xlf -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS '-O3'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR       "xlf"
  if (! $?LDR_OPTS)    setenv LDR_OPTS ''
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case SUNOS:
  if (! $?F_COMP)      setenv F_COMP 'f77 -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS  '-Nq999 -Nl100 -w -fast'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR       "f77"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     '-fast'
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case ALPHA:
  if (! $?F_COMP)      setenv F_COMP 'f77 -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS  '-C -O4'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR       "f77"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     ""
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
case SOLARIS:
  if (! $?F_COMP)      setenv F_COMP 'f77 -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS  '-O3 -native -Nq999 -w -g'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR       "f77"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     '-O3 -native -g'
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
default:
#
# Same as SUNOS
#
  if (! $?F_COMP)      setenv F_COMP 'f77 -c'
  if (! $?F_COMP_OPTS) setenv F_COMP_OPTS  '-Nq999 -Nl100 -w -fast'
  if (! $?C_COMP)      setenv C_COMP 'cc -c'
  if (! $?C_COMP_OPTS) setenv C_COMP_OPTS  ''
  if (! $?LDR)         setenv LDR       "f77"
  if (! $?LDR_OPTS)    setenv LDR_OPTS     '-fast'
  if (! $?LIBS)        setenv LIBS "namelist.a cfiles.a ${NCAR_LIB}.a $HDF"
  if (! $?IUTASK)      setenv IUTASK 0
  if (! $?REAL)        setenv REAL "real*8"
  breaksw
endsw
#
# Verify compilers and options for unknown hosts.
#
if ($HOST_NAME == "unknown" && ! $?VERIFIED) then
  setenv VERIFIED ""
  echo ""
  echo "Using the following compilers, options and libraries:"
  echo ""
  echo "Item Number     Description           Variable       Value"
  echo "-----------     -----------           --------       -----"
  echo "    1       FORTRAN Compiler          F_COMP      = $F_COMP"
  echo "    2       FORTRAN Compiler Options  F_COMP_OPTS = $F_COMP_OPTS"
  echo "    3          C    Compiler          C_COMP      = $C_COMP"
  echo "    4          C    Compiler Options  C_COMP_OPTS = $C_COMP_OPTS"
  echo "    5                 Loader          LDR         = $LDR"
  echo "    6                 Loader Options  LDR_OPTS    = $LDR_OPTS"
  echo "    7                      Libraries  LIBS        = $LIBS"
  if (! -e xedit22) then
    if ($?F_C_OPTS) then
  echo "    8   EDITOR FORTRAN Compiler Opts  F_C_OPTS    = $F_C_OPTS"
    else
  echo "    8   EDITOR FORTRAN Compiler Opts  F_C_OPTS    = <default>"
    endif
    if ($?LD) then
  echo "    9          EDITOR Loader          LD          = $LD"
    else
  echo "    9          EDITOR Loader          LD          = <default>"
    endif
  endif
LOOP_V:
  echo ""
  echo -n "To change a value, enter its item number (default:no changes): "
  set TEST = "$<"
  if ("$TEST" == "") goto BREAK
  if ("$TEST" == "QUIT") goto QUIT
  switch("$TEST")
  case 1:
    set NAME = F_COMP
    breaksw
  case 2:
    set NAME = F_COMP_OPTS 
    breaksw
  case 3:
    set NAME = C_COMP
    breaksw
  case 4:
    set NAME = C_COMP_OPTS
    breaksw
  case 5:
    set NAME = LDR
    breaksw
  case 6:
    set NAME = LDR_OPTS
    breaksw
  case 7:
    set NAME = LIBS
    breaksw
  case 8:
    set NAME = F_C_OPTS
    breaksw
  case 9:
    set NAME = LD
    breaksw
  default:
    echo "Please enter an integer, a carriage return, or QUIT."
    goto LOOP_V
    breaksw
  endsw
  echo "Enter the desired value (default: null)"
  echo -n "$NAME =: "
  set VALUE = "$<"
  setenv $NAME "$VALUE"
  echo "$NAME set to $VALUE"
  goto LOOP_V
BREAK:
  echo ""
endif
#
# Set variables for file transfer.
#
if ($ACCESS == "AFS") then
  setenv COPY "cp"
else
  setenv ZEUS3D  "/lca/zeus3d"
  setenv COPY "get"
endif
if (! $?ZEUS3D)   setenv ZEUS3D   "/afs/ncsa/projects/lca/codes/zeus3d"
if (! $?EDIT22)   setenv EDIT22    ${ZEUS3D}/editor
if (! $?NCAR)     setenv NCAR      ${ZEUS3D}/ncar
if (! $?NAMELIST) setenv NAMELIST  ${ZEUS3D}/namelist
#
# The system is identified and the machine-specific variables are set.
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ end generic host identification block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ begin generic file retrieval block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# See that all files needed to produce xzeus34 are on local disk.
#
if (! (-e zeus34 && -e fixes34 && -e xedit22 && \
    -e namelist.a && -e cfiles.a && -e ${NCAR_LIB}.a && \
    ("$LDR" != "./ncargf77" || "$LDR" == "./ncargf77" && -e ncargf77))) then
#
# Create a script GETS to get the missing files from the server.
#
  echo "#\!/bin/csh" > GETS
  if ($ACCESS == "ftp") then
    echo "ftp -n ${SERVER} << EOF" >> GETS
    echo "user $User" >> GETS
    echo "bin" >> GETS
    set D = ""
  else
    set D = "${cwd}/"
  endif
  if (! -e zeus34) then
    echo "cd ${ZEUS3D}/source" >> GETS
    echo "$COPY zeus34 ${D}zeus34" >> GETS
  endif
  if (! -e fixes34) then
    echo "cd ${ZEUS3D}/source" >> GETS
    echo "$COPY fixes34 ${D}fixes34" >> GETS
  endif
  if (! -e xedit22) then
    if ($HOST_NAME != "unknown") then
      echo "cd ${EDIT22}/xeq/${HOST_NAME}" >> GETS
      echo "$COPY xedit22 ${D}xedit22" >> GETS
    else
      echo "cd ${EDIT22}/source" >> GETS
      if (! -e edit22) echo "$COPY edit22 ${D}edit22" >> GETS
      if (! -e edit22.f) echo "$COPY edit22.f ${D}edit22.f" >> GETS
      echo "cd ${NAMELIST}/source" >> GETS
      if (! -e namelist) echo "$COPY namelist ${D}namelist" >> GETS
      if (! -e namelist.f) echo "$COPY namelist.f ${D}namelist.f" >> GETS
    endif
  endif
  if (! -e namelist.a) then
    if ($HOST_NAME != "unknown") then
      echo "cd ${NAMELIST}/xeq/${HOST_NAME}" >> GETS
      echo "$COPY namelist.a ${D}namelist.a" >> GETS
    else
      if (-e xedit22) then
        echo "cd ${NAMELIST}/source" >> GETS
        if (! -e namelist) echo "$COPY namelist ${D}namelist" >> GETS
      endif
    endif
  endif
  if (! -e cfiles.a) then
    if ($HOST_NAME != "unknown") then
      echo "cd ${ZEUS3D}/cfiles/xeq/${HOST_NAME}" >> GETS
      echo "$COPY cfiles.a ${D}cfiles.a" >> GETS
    else
      echo "cd ${ZEUS3D}/cfiles/source" >> GETS
      if ($OSYS == "UNICOS") then
        if (! -e checkin.c) echo "$COPY ucheckin.c ${D}checkin.c" >> GETS
        if (! -e move.c) echo "$COPY move.c ${D}move.c" >> GETS
      else if ($OSYS == EXEMPLAR) then
        if (! -e checkin.c) echo "$COPY checkin.c ${D}checkin.c" >> GETS
        if (! -e ttimer.c ) echo "$COPY ttimer.c  ${D}ttimer.c"  >> GETS
      else
        if (! -e checkin.c) echo "$COPY checkin.c ${D}checkin.c" >> GETS
      endif
    endif
  endif
  if (! -e ${NCAR_LIB}.a) then
    if ($HOST_NAME != "unknown") then
      echo "cd ${NCAR}/xeq/${HOST_NAME}" >> GETS
      echo "$COPY ${NCAR_LIB}.a ${D}${NCAR_LIB}.a" >> GETS
    else
      echo "cd ${NCAR}/source" >> GETS
      if (! -e $NCAR_LIB) echo "$COPY $NCAR_LIB ${D}${NCAR_LIB}" >> GETS
    endif
  endif
  if ($HOST_NAME == "unknown" && (! -e xedit22 || ! -e namelist.a || \
      ! -e cfiles.a || ! -e ${NCAR_LIB}.a) && ! -e bld_lib) then
    echo "cd ${ZEUS3D}/util" >> GETS
    echo "$COPY bld_lib ${D}bld_lib" >> GETS
  endif
  if ($ACCESS == "ftp") echo "EOF" >> GETS
  echo "exit" >> GETS
#......................................................................
#
# Connect to the server if necessary.
#
  set TEST = "`grep $COPY GETS`"
  if ("$TEST" != "") then
    echo ""
    echo "Getting files from the server ($ACCESS - $SERVER; signon: $User)."
    echo ""
    if (($COPY == "get") && ($SERVER == "ftp.ncsa.uiuc.edu")) then
      echo "Enter your e-mail address as the password to NCSA's FTP server."
    endif
    if ($COPY == "cp" && ! -r $ZEUS3D/source/zeus34) then
      echo "Enter the password for user $User on NCSA's AFS server."
      echo ""
      klog $User -cell ncsa.uiuc.edu
    endif
    chmod 700 GETS
    GETS
    echo ""
  endif
  \rm -f GETS
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ end generic file retrieval block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ begin generic utility/library generation block ~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# If necessary, create xedit22 and/or namelist.a.  
#
  if (! -e xedit22 || ! -e namelist.a || ! -e ${NCAR_LIB}.a) then
    set FC_OPTS = "$F_COMP_OPTS"
    set FCOMP = ($F_COMP)
    set FCOMPP = "$F_COMP"
    switch ($OSYS)
    case CONVEXOS:
      if (! $?F_C_OPTS) setenv F_C_OPTS '-fi -O2 -nw -or none -cxdb'
      if (! $?LD)       setenv LD "$FCOMP[1] -fi"
      breaksw
    case EXEMPLAR:
# 
# On EXEMPLAR, use HP compiler for EDITOR only.
#
      if ("$HOST_NAME" == lena) then
        setenv F_COMP "f77 -c"
      else
        setenv F_COMP "/opt/fortran/bin/f77 -c"
      endif
      set FCOMP = ($F_COMP)
      if (! $?F_C_OPTS) setenv F_C_OPTS '+O2'
      if (! $?LD)       setenv LD "$FCOMP[1] +U77"
      breaksw
    case HP:
      if (! $?F_C_OPTS) setenv F_C_OPTS '+O2'
      if (! $?LD)       setenv LD "$FCOMP[1] +U77"
      breaksw
    case UNICOS:
#
# On UNICOS, optimization is turned off for EDITOR only
#
      setenv F_COMP "cft77"
      set FCOMP = ($F_COMP)
      if (! $?F_C_OPTS) setenv F_C_OPTS '-ez -ooff'
      if (! $?LD)       setenv LD "segldr"
      breaksw
    case IRIX:
      if (! $?F_C_OPTS) then
#
# On the SGI Power Change (odin and sif as of 8/18/95), EDITOR and/or
# namelist may not work unless compiled with optimization turned off
# and static storage.
#
        if ($HOST_NAME == sgipc) then
          setenv F_C_OPTS '-O0 -static -64 -mips4 -g3'
        else if ($HOST_NAME == loki) then
          setenv F_C_OPTS '-O0 -static -32 -mips2 -g3'
        else
          setenv F_C_OPTS '-O2 -g3'
        endif
      endif
      if (! $?LD) then
        if ($HOST_NAME == sgipc) then
          setenv LD "$FCOMP[1] -64 -mips4"
        else if ($HOST_NAME == loki) then
          setenv LD "$FCOMP[1] -32 -mips2"
        else
          setenv LD $FCOMP[1]
        endif
      endif
      breaksw
    case SUNOS:
      if (! $?F_C_OPTS) setenv F_C_OPTS ''
      if (! $?LD)       setenv LD $FCOMP[1]
      breaksw
    case SOLARIS:
      if (! $?F_C_OPTS) setenv F_C_OPTS ''
      if (! $?LD)       setenv LD $FCOMP[1]
      breaksw
    case ALPHA:
      if (! $?F_C_OPTS) setenv F_C_OPTS ''
      if (! $?LD)       setenv LD $FCOMP[1]
      breaksw
    case IBM:
#
# For IBM, turn off optimization and allow character strings of 
# length up to 512 for EDITOR only
#
      if (! $?F_C_OPTS) setenv F_C_OPTS '-g -qcharlen=512'
      if (! $?LD)       setenv LD $FCOMP[1]
      breaksw
    default:
#
# Same as SUNOS
#
      if (! $?F_C_OPTS) setenv F_C_OPTS ''
      if (! $?LD)       setenv LD $FCOMP[1]
      breaksw
    endsw
  endif
#
#.......................................................................
#
  if (! -e xedit22) then
    echo ""
    echo "Creating xedit22"
    echo ""
#
# Create a working version of EDITOR called xedit22.
#
    setenv F_COMP_OPTS "$F_C_OPTS"
#
# For UNICOS, modify the EDITOR source code so that the proper 
# system-call and timing routines are used.
#
    if ($OSYS == "UNICOS") then
      ex - edit22.f << EOF
/integer       system/s/system/ishell
/external      system/s/system/ishell
%s/istat = system/istat = ishell
wq
EOF
      cat >> edit22.f << EOF
      real function etime ( tarray )
c
c etime =========================================================
c 
c Cray substitute for UNIX etime function.
c Returns system plus user CPU time in etime.
c NOTE: tarray values are NOT set to system and user CPU time.
c
      real tarray(2), second
      external second
c
      etime = second ( )
      return
c
c End of etime ==================================================
c
      end
      subroutine itime ( iarray )
c
c itime =========================================================
c 
c Cray substitiute for UNIX itime.  
c Returns time in iarray as hr, min, sec.
c
      integer iarray(3)
      real rtime, secondr
      external secondr
c
      rtime = secondr ( )
      iarray(1) = ifix(rtime/3600.0)
      rtime = rtime - iarray(1) * 3600.0
      iarray(2) = ifix(rtime/60.0)
      iarray(3) = rtime - iarray(2) * 60.0
      return
c
c End of itime ==================================================
c
      end
      subroutine idate ( iarray )
c
c idate =========================================================
c 
c Cray substitiute for UNIX idate.  
c Returns time in iarray as dd, mm, yy.
c
      integer iarray(3)
      character*8 cdate
      external date
c
      call date( cdate )
      iarray(1) = ichar(cdate(4:5))
      iarray(2) = ichar(cdate(1:2))
      iarray(3) = ichar(cdate(7:8))
      return
c
c End of idate ==================================================
c
      end
EOF
    endif
#
# For HP, IBM, and EXEMPLAR, modify the EDITOR source to add
# underscores to the system timing routine names.
#
    if ("$OSYS" == HP || "$OSYS" == IBM || \
       ("$OSYS" == EXEMPLAR && "$FCOMP[1]" == f77) ) then
      ex - edit22.f << EOF
%s/etime /etime_ /g
%s/etime\$/etime_/
%s/itime /itime_ /g
%s/ idate / idate_ /g
%s/ idate\$/ idate_/
wq
EOF
    endif
#
    echo ""
    echo "Compiling edit22.f and namelist.f using $F_COMP with options: $F_COMP_OPTS"
    echo ""
    chmod 700 bld_lib
    bld_lib edit22.a edit22.f
    if (-d editor.src) then
      \rm -rf editor.src/* >& /dev/null
      mv bld_lib.dir/* editor.src
    else
      mv bld_lib.dir editor.src
    endif
#
# Save any existing namelist.a and chgnml.  The one to be loaded with 
# the EDITOR source must be compiled in single precision.
#
    if (-e namelist.a) mv namelist.a namelist.a.$$
    if (-e chgnml) mv chgnml chgnml.$$
    bld_lib namelist.a namelist.f
    echo ""
    echo "$LD -o xedit22 editor.src/*.o namelist.a"
    echo ""
    $LD -o xedit22 editor.src/*.o namelist.a
    if (! -e xedit22) then
      echo "ERROR: Attempt to create low-quality xedit22 failed."
      echo "ERROR: Try changing compilers or options (F_C_OPTS)."
      if (-e namelist.a.$$) mv namelist.a.$$ namelist.a
      if (-e chgnml.$$) mv chgnml.$$ chgnml
      goto QUIT
    endif
#
# Create a customized version of namelist.a.  It must be compiled in
# single precision for compatiability with EDITOR.
#
    echo ""
    echo "Using generic xedit22 to create customized version of namelist.a."
    echo ""
    cat << EOF > chgnml
*alias REAL real
EOF
    echo "Writing new EDITOR change deck chgnml:"
    echo ""
    cat chgnml
    echo ""
#
# Create the input deck and invoke EDITOR to produce namelist.f.
#
    cat << EOF > inedit_namelist
 \$editpar   inname='namelist', ibanner=0, idump=1, job=3
           , ipre=1, inmlst=0, iupdate=0, iutask=0, chgdk='chgnml'     \$
EOF
    echo "Writing new EDITOR input deck inedit_namelist:"
    cp inedit_namelist inedit
    echo ""
    cat inedit
    echo ""
    chmod 700 xedit22
    xedit22
    echo ""
#
# Compile namelist.f and build namelist.a.
#
    echo ""
    echo "Compiling namelist.f using $F_COMP with options: ${F_COMP_OPTS}."
    echo ""
    chmod 700 bld_lib
    bld_lib namelist.a namelist.f
    mv bld_lib.dir/bld_log namelist.l
    if (! -e namelist.a) then
      if (-e namelist.a.$$) mv namelist.a.$$ namelist.a
      if (-e chgnml.$$) mv chgnml.$$ chgnml
      goto QUIT
    endif
#
# Now use the generic xedit22 to obtain the customized EDITOR source.
#
    echo ""
    echo "Creating customized version of xedit22."
    echo ""
#
# If necessary, create the directory "editor2.2".
#
    if (! -e editor2.2) mkdir editor2.2
#
# Create the EDITOR change deck.  Set aliases for the system
# timing routines as required.
#
    if (! -e chgedit) then
      cat << EOF > chgedit
*define $OP_SYS
EOF
      if ("$OSYS" != UNICOS && "$OSYS" != CONVEXOS) then
        if ("$OSYS" == HP || "$OSYS" == IBM || \
           ("$OSYS" == EXEMPLAR && "$FCOMP[1]" == f77 ) ) then
          cat << EOF >> chgedit
*alias ETIME   etime_
*alias ITIME   itime_
*alias IDATE   idate_
EOF
        else
          cat << EOF >> chgedit
*alias ETIME   etime
*alias ITIME   itime
*alias IDATE   idate
EOF
        endif
      endif
#
# Change array dimensions in EDITOR.  The one that may need to
# be different from its default value is k2.
#
      cat << EOF >> chgedit
*delete par.8,9
       parameter     (k1=500, k2=25000, k3=999, k4=250, k5=300, k6=128)
       parameter     (k7=100, k8=100, k9=200)
EOF
#
      echo "Writing new chgedit file:"
    else
      echo "Using existing chgedit file:"
    endif
    echo ""
    cat chgedit
    echo ""
#
# Create the input deck for EDITOR, and execute.
#
    set LD_OPTS = ($LD)
    shift LD_OPTS
    cat << EOF > inedit_edit22
 \$editpar   inname='edit22'
          , idump=1 ,job=3, ipre=1, inmlst=1, iutask=0, safety=0.2
          , chgdk='chgedit'
          , iupdate=1, ext='.f', branch='editor2.2'
          , makename='makeedit', xeq='xedit22'
          , coptions='$F_COMP_OPTS'
          , loptions='$LD_OPTS'
          , libs='namelist.a' \$
EOF
    echo "Writing new EDITOR input deck inedit_edit22:"
    cp inedit_edit22 inedit
    echo ""
    cat inedit
    echo ""
    echo "Invoking generic version of EDITOR to obtain customized EDITOR source."
    echo ""
    xedit22
    echo ""
#
# Create customized EDITOR executable.
#
# Edit makeedit to put in the correct compiler name (default is f77)
# and change '\\' to '\, if necessary'.
#
    if (("$OSYS" != "SUNOS" && "$OSYS" != "IRIX" &&     \
         "$OSYS" != "ALPHA" && "$OSYS" != "SOLARIS") || \
        "$FCOMP[1]" != "f77") then
      if ("$OSYS" != "UNICOS") then
        set COPT = "${F_COMP_OPTS}"' -o $*.o'
        set LOADER = "$LD"
      else
        set FCOMP = (cf77)
        set COPT = '-Wf,"'"${F_COMP_OPTS}"' -b $*.o"'
        set LOADER = "cf77"
      endif
      echo ""
      echo "Editing the makefile makeedit; ex should list the 3 lines to be changed."
      echo ""
      ex - makeedit << EOF
/COMP
d
i
COMP     = $FCOMP
.
/COPT
d
i
COPT     = $COPT
.
/LOAD
d
i
LOAD     = $LOADER
.
wq
EOF
      set TEST = `grep 'editor\.o...........$' makeedit`
      if ("$TEST" != "") then
#      if ("$OSYS" != SUNOS && "$OSYS" != IBM && "$OSYS" != ALPHA && \
#          "$OSYS" != SOLARIS) then
        ex - makeedit << EOF
%s/\\\//
wq
EOF
      endif
    endif
    echo ""
    echo "Invoking make."
    echo ""
#
# It is possible that the generic version of xedit22 works fine, but
# make will fail below.  Save the old xedit22 just in case.
#
    mv xedit22 xedit22_g
    if ("$OSYS" == IRIX) then
      smake -f makeedit
    else
      make -f makeedit
    endif
    if (-e xedit22) then
      \rm xedit22_g
      echo ""
      echo "You might want to save xedit22, edit22.f and namelist.f."
      echo "This namelist.a was compiled with options: $F_COMP_OPTS"
      echo "and renamed to edit22_nl.a.  This could be useful for"
      echo "creating a single-precison ZEUS-3D executable."
      echo ""
    else
      echo ""
      echo "WARNING: Make failed. Shall I continue the installation using"
      echo -n "the generic xedit22 instead (y/n)? "
      echo ""
      set CONTIN = "$<"
      if ("$CONTIN" != "y") goto QUIT
    endif
    mv namelist.a edit22_nl.a
#
# Restore any chgnml and namelist.a present before running this script
#
    \rm chgnml
    if (-e namelist.a.$$) mv namelist.a.$$ namelist.a
    if (-e chgnml.$$) mv chgnml.$$ chgnml
#
# Reset F_COMP_OPTS to what it was before this script was executed.
#
    setenv F_COMP_OPTS "$FC_OPTS"
    setenv F_COMP "$FCOMPP"
  endif
#.......................................................................
#
# If necessary, create namelist.a
#
  if (! -e namelist.a) then
    echo ""
    echo "Creating new namelist.a for loading xzeus34"
    echo ""
#
# Set compiler options as above for compiling EDITOR.
#
    setenv F_COMP "$FCOMP"
    setenv F_COMP_OPTS "$F_C_OPTS"
#
# Create the change deck for namelist.  The precision must match
# that used for xzeus34.
#
    echo ""
    if (! -e chgnml) then
      cat << EOF > chgnml
*alias REAL $REAL
EOF
      echo "Writing new EDITOR change deck chgnml:"
    else
      echo "Using existing EDITOR change deck chgnml:"
    endif
    echo ""
    cat chgnml
    echo ""
#
# Create the input deck and invoke EDITOR to produce namelist.f.
#
    cat << EOF > inedit_namelist
 \$editpar   inname='namelist', ibanner=0, idump=1, job=3
           , ipre=1, inmlst=0, iupdate=0, iutask=0, chgdk='chgnml'     \$
EOF
    echo "Writing new EDITOR input deck inedit_namelist:"
    cp inedit_namelist inedit
    echo ""
    cat inedit
    echo ""
    chmod 700 xedit22
    xedit22
    echo ""
#
# Compile namelist.f and build namelist.a.
#
    echo ""
    echo "Compiling namelist.f using $F_COMP with options: ${F_COMP_OPTS}."
    echo ""
    chmod 700 bld_lib
    bld_lib namelist.a namelist.f
    mv bld_lib.dir/bld_log namelist.l
    if (! -e namelist.a) goto QUIT
#
# Reset compiler options.
#
    setenv F_COMP "$FCOMPP"
    setenv F_COMP_OPTS "$FC_OPTS"
  endif
#.......................................................................
#
# If necessary, create cfiles.a
#
  if (! -e cfiles.a) then
    echo ""
    echo "Creating cfiles.a"
    echo ""
#
# Compile C source code(s) and create library cfiles.a.
#
    chmod 700 bld_lib
    if ($OSYS == "UNICOS") then
      bld_lib cfiles.a checkin.c move.c
    else if ($OSYS == "EXEMPLAR") then
      bld_lib cfiles.a checkin.c ttimer.c
    else
      bld_lib cfiles.a checkin.c
    endif
    mv bld_lib.dir/bld_log cfiles.l
    if (! -e cfiles.a) goto QUIT
  endif
#.......................................................................
#
# If necessary, create ncar.a
#
  if (! -e ${NCAR_LIB}.a) then
    echo ""
    echo "Creating ${NCAR_LIB}.a"
    echo ""
#
# Set compiler options as above for compiling EDITOR.
#
    setenv F_COMP "$FCOMP"
    setenv F_COMP_OPTS "$F_C_OPTS"
#
# Create the EDITOR change deck.  This library should always be
# compiled in single precision.
#
    if (! -e chgncar) then
      if ("$OSYS" == UNICOS) then
        cat << EOF > chgncar
*define $OSYS, GKS
*alias REAL real
EOF
      else
        cat << EOF > chgncar
*define $OSYS, GKS
*alias REAL real*4
EOF
      endif
      echo "Writing new chgncar:"
    else
      echo "Using existing chgncar:"
    endif
    echo ""
    cat chgncar
    echo ""
#
# Create the input deck for EDITOR, and execute.
#
    cat << EOF > inedit_ncar
 \$editpar   inname='$NCAR_LIB', ibanner=0, idump=1, job=3
          , ipre=1, inmlst=0, iupdate=0, iutask=0, chgdk='chgncar'     \$
EOF
    cp inedit_ncar inedit
    echo "Writing new EDITOR input deck for ${NCAR_LIB}:"
    echo ""
    cat inedit
    echo ""
    chmod 700 xedit22
    xedit22
    \rm inedit
#
# Compile ncar.f and build ncar.a.
#
    echo ""
    echo "Compiling ${NCAR_LIB}.f using $F_COMP with options: ${F_COMP_OPTS}."
    echo ""
    chmod 700 bld_lib
    bld_lib ${NCAR_LIB}.a ${NCAR_LIB}.f
    mv bld_lib.dir/bld_log ${NCAR_LIB}.l
    if (! -e ${NCAR_LIB}.a) goto QUIT
#
# Reset compiler options.
#
    setenv F_COMP "$FCOMPP"
    setenv F_COMP_OPTS "$FC_OPTS"
  endif
#.......................................................................
#
else
  echo "No files needed from the server."
  echo ""
endif
#
# For Convex or Sun, update table of contents for the libraries.
#
if ($OSYS == "CONVEXOS" || $OSYS == "SUNOS" || $OSYS == "ALPHA" || \
    $OSYS == "SOLARIS") then
  set RANLIB = (`which ranlib`)
  if ("`echo $RANLIB | egrep 'no ranlib|ranlib not'`" == "") then
    ranlib namelist.a
    ranlib cfiles.a
    ranlib ${NCAR_LIB}.a
  endif
endif
#
# If we are using NCAR graphics version 3.1.x with loader ./ncargf77,
# create ./ncargf77 customized for the current system.
#
if ("$LDR" != "./ncargf77") goto HOP
  cat << EOF > ./ncargf77
#!/bin/csh -f
#
# ncargf77
#
# Loads programs with NCAR graphics libraries.
# Abopted from the original scripts provided with NCAR versions 3.1.2
# and 3.2.1 -- compatiable with both versions at NCSA!
#
# If your system has another version of NCAR, this script may not be
# compatiable with it.  Try using your system's version of ncargf77 
# instead.  If you get an error message such as "word too long" when
# running your system's version, copy that version to your working
# directory and edit it so that the variable "newargv" is set using
# array syntax.  See comments below for details.
#
# Laboratory for Computational Astrophysics
# National Center for Supercomputing Applications
# University of Illinois, Urbana
#
# Written by Robert Fiedler, 4/25/95.
#
#................................................................
#
if (\$?OSYS) then
  set system = \$OSYS
else
  set system = $OSYS
endif
if (\$?F_COMP) then
  set fortran = \`echo \$F_COMP | awk '{print \$1}'\`
else
  set fortran = `echo $F_COMP | awk '{print \$1}'`
endif
set loadopts = ""
if (\$?NCARG_ROOT) then
  set libdir = \${NCARG_ROOT}/lib
  set bindir = \${NCARG_ROOT}/bin
  set ro     = \$libdir
  if (-d \$libdir/ncarg/robj) then
    set ro =   \$libdir/ncarg/robj
  else
    set ro =   \$libdir
  endif
else
  set Par = (\`which ncargpath\`)
  if ("\`echo \$Par | egrep 'no ncargpath|ncargpath not'\`" == "") then
#
# This system has NCAR version 3.2.1.
#
    setenv NCARG_ROOT  \`ncargpath root\`
    set libdir = \`ncargpath lib\`
    set bindir = \`ncargpath bin\`
    set ro     = \$libdir/ncarg/robj
  else
    set Par = (\`which ncargpar\`)
    if ("\`echo \$Par | egrep 'no ncargpar|ncargpar not'\`" == "") then
#
# This system has NCAR version 3.1.2.
#
      set libdir = \`ncargpar LIBDIR\`
      set bindir = \`ncargpar BINDIR\`
      set ro     = \$libdir
    else
      echo "NCARGF77: ERROR -- NCARG_ROOT was not set and the ncargpath"
      echo "NCARGF77:          or ncargpar command was not found, so I"
      echo "NCARGF77:          cannot find the NCAR commands and"
      echo "NCARGF77:          libraries I need.  See the man page."
      exit 1
    endif
  endif
endif
#
# Key modification: use array syntax for newargv to avoid getting
# a "word too long" error message.
#
if (\$system == UNICOS) then
  set newargv = (cf77)
else
  set newargv = (\$fortran)
endif
#
set XLIBPATH = ""
set libextra = ""
#
if (! -d "\$libdir") then
  echo "Library directory <\$libdir> does not exist."
  exit 1
endif
#
if ("\$system" == "Sun4Solaris") then
  set libextra = "/usr/ucblib/libucb.a"
  set XLIBPATH = "-L/usr/openwin/lib"
else if ("\$system" == "HPUX_snake") then
  set XLIBPATH = "-L/usr/lib/X11R5"
endif    
#
set newargv = (\$fortran \$loadopts)

set ctrans_libs = ""
set stub_file   = ""

#
# set up default libraries
#
set libncarg  =  "\$libdir/libncarg.a"
set libgks     = "\$libdir/libncarg_gks.a"
set liblocal   = "\$libdir/libncarg_loc.a"
if (-e "\$libdir/libncarg_c.a") then
  set libncarg_c = "\$libdir/libncarg_c.a"
else
  set libncarg_c = ""
endif
set libmath  = "-lm"
set libX11     = "\$XLIBPATH -lX11"
#
set smooth = "\$ro/libdashsmth.o"
set quick  = "\$ro/libdashline.o \$ro/libconrcqck.o \$ro/libconraq.o"
set super  = "\$ro/libdashsupr.o \$ro/libconrcspr.o \$ro/libconras.o"
#
set libs
#
foreach arg (\$argv)
#
    switch (\$arg)
#
    case "-sungks":
        echo "Using Sun GKS"
        set libgks="-lgks77 -lgks -lsuntool -lsunwindow -lpixrect -lm"
        breaksw
#
    case "-smooth":
        echo "Smooth f77 of NCAR Graphics"
        set libs = "\$libs \$smooth"
        breaksw
#
    case "-super":
        echo "Super f77 of NCAR Graphics"
        set libs = "\$libs \$super"
        breaksw
#
    case "-quick":
        echo "Quick f77 of NCAR Graphics"
        set libs = "\$libs \$quick"
        breaksw
#
    case "-agupwrtx":
        echo "Autograph with PWRITX"
        set libs = "\$libs \$ro/libagupwrtx.o"
        breaksw
#
    case "-conransmooth":
        echo "Smooth Conran"
        set libs = "\$libs \$smooth"
        breaksw
#
    case "-conranquick":
        echo "Quick Conran"
        set libs = "\$libs \$ro/libconraq.o"
        breaksw
#
    case "-conransuper":
        echo "Super Conran"
        set libs = "\$libs \$ro/libconras.o \$ro/libdashsupr.o"
        breaksw
#
    case "-conrecsmooth":
        echo "Smooth Conrec"
        set libs = "\$libs \$ro/libdashsmth.o"
        breaksw
#
    case "-conrecquick":
        echo "Quick Conrec"
        set libs = "\$libs \$ro/libconrcqck.o"
        breaksw
#
    case "-conrecsuper":
        echo "Super Conrec"
        set libs = "\$libs \$ro/libconrcspr.o \$ro/libdashsupr.o"
        breaksw
#
    case "-dashsmooth":
        echo "Smooth Dash"
        set libs = "\$libs \$ro/libdashsmth.o"
        breaksw
#
    case "-dashquick":
    case "-dashline":
        echo "Quick Dash"
        set libs = "\$libs \$ro/libdashline.o"
        breaksw
#
    case "-dashsuper":
        echo "Super Dash"
        set libs = "\$libs \$ro/libdashsupr.o"
        breaksw
#
    case "-dashchar":
        echo "Normal Dash"
        breaksw
#
    case "-ictrans":
        echo "Output to ictrans"
        set ctrans_libs = \`\$bindir/ctlib\`
        set libX11   = ""
        set libmath  = ""
        if (-e \$ro/ggkwdr_stub.o) then
          set stub_file = \$ro/ggkwdr_stub.o
        endif
        if ("\$system" == "Sun4") then
            set libextra = "-L/usr/lang/SC1.0/ansi_lib -lansi"
        endif
        breaksw
#
    case "-noX11"
        if (-e \$ro/ggkwdr_stub.o) then
          set stub_file = \$ro/ggkwdr_stub.o
        endif
        set libX11 = ""
        breaksw
#
    case "-*":
        set newargv = (\$newargv \$arg)
        breaksw
#
    default:
        set newargv = (\$newargv \$arg)
        breaksw
#
    endsw
end
#
set newargv = (\$newargv \$stub_file \$ctrans_libs \$libs \$libncarg \$libgks \$libncarg_c \$liblocal \$libX11 \$libmath \$libextra)
#
echo \$newargv
eval \$newargv
exit
EOF
  chmod 700 ./ncargf77
HOP:
#
# Create the Cat untility, which displays a file and gives you a chance
# to edit it.  It pauses after it writes the input file to the terminal.
#
cat << EOF > Cat
#!/bin/csh
#
# Cat <file_name>
#
# Cat examines the environment variable "ENVIRONMENT" to see if it is
# set to "BATCH"; if so, Cat behaves like cat.  If not, Cat uses the
# text display utility defined by the "PAGER" environment variable 
# (defaults to "more" if not set).  Finally, Cat asks if you would like
# to edit the file using the text editor defined by the "EDITOR"
# environment variable (deaults to vi).
#
set FILE = \$1
if (! \$?ENVIRONMENT) setenv ENVIRONMENT INTERACTIVE
if ("\$ENVIRONMENT" == BATCH) then
#
# Just cat the file in BATCH mode.
#
  cat \$FILE
  exit
else
#
# In INTERACTIVE mode, use the pager defined by PAGER if it is set,
# or "more" otherwise.
#
  if (\$?PAGER) then
    \$PAGER \$FILE
  else
    more \$FILE
  endif
#
# Ask if the user wants to edit the file.  Use the text editor defined 
# by the "EDITOR" environment variable, if set, or ask which text
# editor to use.
#
  echo ""
  echo -n "Enter y to edit \$FILE before proceeding (default:n): "
  set EDIT = "\$<"
  if ("\$EDIT" != "" && "\$EDIT" != "n" && "\$EDIT" != "no" && \
      "\$EDIT" != " ") then
    if (! \$?EDITOR) then
      setenv EDITOR vi
      echo -n "Enter the text editor to use (default: \$EDITOR): "
      set Editor = "\$<"
      if ("\$Editor" == "") set Editor = "\$EDITOR"
    else
      set Editor = "\$EDITOR"
    endif
    \$Editor \$FILE
  endif
endif
EOF
chmod 700 Cat
#
# All the necessary files are now on local disk.
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ end generic utility/library generation block ~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Create the EDITOR input decks and run EDITOR to produce the ZEUS-3D
# FORTRAN source code and the makefile.
#
echo ""
echo "Creating the executable xzeus34."
echo ""
#
# If needed, create a directory to hold the source code modules.
#
if (! -e zeus3.4) mkdir zeus3.4
#
# Append the bug fix change deck to chgz34 if necessary.
#
if (! -e chgz34) then
  cp fixes34 chgz34
else
  set TEST = (`grep -il "BUG FIX CHANGE DECK FOR ZEUS-3D" chgz34`)
  if ("$TEST" == "") then
    cat fixes34 >> chgz34
  endif
endif
#
# UNICOS and CONVEXOS machines should have the library routines
# ismax, ismin, and sasum.  On most other systems, source code
# for these routines will be added to chgz34 if it does not already
# contain them. (We used some goto statements here because the code 
# contains endifs which had been misinterpreted by some versions
# of the C Shell.)
#
if ("$OSYS" == "UNICOS" || "$OSYS" == "CONVEXOS") goto SKIP
  set TEST = (`grep -il "function ismax" chgz34`)
  if ("$TEST" != "") goto SKIP10
    cat << EOF >> chgz34
*insert zeus3d.9999
*deck ismax
      integer function ismax(n,x,is)
*ca imp
      integer       n, is, i
      REAL        x(n), xmax
      ismax = 1
      xmax = x(1)
      do 10 i=2,n
      if(x(i).gt.xmax) then
        ismax = i
        xmax = x(i)
      endif
   10 continue
      return
      end
EOF
SKIP10:
#  if ("$HOST_NAME" == loki) goto SKIP
  set TEST = (`grep -il "function ismin" chgz34`)
  if ("$TEST" != "") goto SKIP20
    cat << EOF >> chgz34
*insert zeus3d.9999
*deck ismin
      integer function ismin(n,x,is)
*ca imp
      integer       n, is, i
      REAL        x(n), xmin
      ismin = 1
      xmin = x(1)
      do 10 i=2,n
      if(x(i).lt.xmin) then
        ismin = i
        xmin = x(i)
      endif
   10 continue
      return
      end
EOF
SKIP20:
  set TEST = (`grep -il "function sasum" chgz34`)
  if ("$TEST" != "") goto SKIP30
    cat << EOF >> chgz34
*insert zeus3d.9999
*deck sasum
      REAL function sasum(n,x,is)
*ca imp
      integer       n, is, i
      REAL        x(n)
      sasum = abs(x(1))
      do 10 i=2,n
        sasum = sasum + abs(x(i))
   10 continue
      return
      end
EOF
SKIP30:
#
# PROBLEM deck "jetinit" is the only one in ZEUS-3D that calls
# isamax, but there is at least one routine in the ZEUS-3D
# "ncar" interface library that calls isamax.
#
# IRIX 6.1 does not seem to have isamax in libblas.a anymore.
#
#  if ("$HOST_NAME" == sgipc) goto SKIP
#
  set TEST = ""
  if (-e zeus34.mac) set TEST = (`grep -il "jetinit" zeus34.mac`)
  if ("$NCAR_LIB" == ncard && "$TEST" == "") goto SKIP
  set TEST = (`grep -il "function isamax" chgz34`)
  if ("$TEST" != "") goto SKIP
    cat << EOF >> chgz34
*insert zeus3d.9999
*deck isamax
      integer function isamax(n,x,is)
*ca imp
      integer       n, is, i
      REAL        x(n), xmax, ax
      isamax = 1
      xmax = abs(x(1))
      do 10 i=2,n
      ax = abs(x(i))
      if(ax.gt.xmax) then
        isamax = i
        xmax = ax
      endif
   10 continue
      return
      end
EOF
SKIP:
#
# Set up zeus34.mac, inzeus, and chgzeus to perform the desired 
# problem.  If this script is called with no file name on the command
# line, use the setup block included below, but do not overwrite
# any existing inzeus, zeus34.mac, or chgzeus.  
#
if ($#argv == 0) then
  if (-e zeus34.mac) setenv ZEUS34MAC ""
  if (-e inzeus)     setenv INZEUS    ""
  if (-e chgzeus)    setenv CHGZEUS   ""
#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>> END GENERIC XZEUS34 BLOCK 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>> BEGIN SETUP BLOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#
# Problem BLAST -- 3-D XYZ expanding bubble in a magnetic field.  
#                  This version uses the original CT algorithm.
#
# Execution should terminate upon reaching the physical problem time 
# limit "tlim" after several time steps.  Very little expansion occurs 
# until the problem runs for tens of steps.
#
# By default, only the timeslice file and display dump are output.  
#
# Create a new macro definition file "zeus34.mac", overwriting any 
# existing copy unless the zeus34.s script was invoked with no setup 
# block file name on the command line.
#
  if (! $?ZEUS34MAC) then
    echo ""
    echo "Writing new macro definition file zeus34.mac:"
    echo ""
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ BEGIN ZEUS34.MAC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#-----------------------------------------------------------------------
# CHANGE MACRO DEFINITIONS BELOW FOR YOUR PROBLEM AND DESIRED OUTPUT
#-----------------------------------------------------------------------
#
    cat << EOF > zeus34.mac
**==*====1====*====2====*====3====*==*====3====*====2====*====1====*====
**                                                                    **
******************  CONDITIONAL COMPILATION SWITCHES  ******************
**                                                                    **
**  1) symmetry axes:  ISYM, JSYM, KSYM
**
**define   KSYM, JSYM
**
**  2) geometry:  XYZ, or ZRP, or RTP
**
*define   XYZ
**
**  3) physics:  MHD, ISO, GRAV
**
*define   MHD
**
**  4) algorithms:  MOC, HSMOC
**
**define   MOC
**
**  5) data output modes:  PLT1D, PLT2D, PIX, VOX, HDF, DISP, RADIO,
**                         TIMESL
**
*define   DISP, TIMESL
**
**  6) operating system:  ALPHA, CONVEXOS, EXEMPLAR, HP, IBM, 
**                        IRIX[, SGIMP], SOLARIS, SUNOS, 
**                        UNICOS[, CALMATH]
**
*define   $OP_SYS
**
*************************  MODULE NAME ALIASES  ************************
**                                                                    **
**  The modules "BNDYUPDATE", "SPECIAL", "SPECIALSRC", "SPECIALTRN",
**  "USERDUMP", and "FINISH" are slots available to the user to help
**  adapt the code to the problem being solved.
**
*alias    START            mstart
*alias    BNDYUPDATE       empty
*alias    EXTENDGRID       empty
*alias    GRAVITY          empty
*alias    SPECIAL          empty
*alias    SOURCE           srcstep
*alias    SPECIALSRC       empty
*alias    TRANSPORT        transprt
*alias    SPECIALTRN       empty
*alias    NEWTIMESTEP      nudt
*alias    NEWGRID          empty
*alias    DATAOUTPUT       dataio
*alias    FINISH           empty
**
*alias    PROBLEM          blast
*alias    ATMOSPHERE       empty
*alias    PROBLEMRESTART   empty
*alias    ARTIFICIALVISC   viscous
*alias    USERDUMP         empty
**                                                                    **
************************  ERROR CRITERIA ALIASES  **********************
**                                                                    **
*alias    GRAVITYERROR     1.0e-6
*alias    GRIDERROR        1.0e-6
*alias    PDVCOOLERROR     1.0e-6
*alias    NEWVGERROR       1.0e-10
**                                                                    **
***********************  ITERATION LIMITS ALIASES  *********************
**                                                                    **
*alias    GRAVITYITER      4
*alias    GRIDITER         20
*alias    PDVCOOLITER      20
*alias    NEWVGITER        20
EOF
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ END ZEUS34.MAC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
  else
    echo ""
    echo "Using existing zeus34.mac:"
    echo ""
  endif
  Cat zeus34.mac
  echo ""
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ BEGIN INZEUS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Create a new input file "inzeus", overwriting any existing one
# unless the zeus34.s script was invoked with no setup block file
# name on the command line.
#
# Be sure to escape each dollar sign ($) with a backquote (\) here, 
# since otherwise the Shell will treat them as variables and try to 
# evaluate them before writing to the file.
#
# This version initializes many variables to their default values.  This
# is not necessary but should help you edit it to your liking.
#
# This example sets up a non-uniform 3-D grid from -1 to +1 in each
# of the three Cartesian coordinate directions.  
#
# Use variables NZX1, NZX2, NZX3 for the numbers of zones in each 
# direction.  This allows the script to automatically change all
# input parameters that are functions of grid size.  The default values 
# can be overridden with "setenv" before running this script.
#
#-----------------------------------------------------------------------
# CHANGE THE FOLLOWING NUMBERS TO OBTAIN THE DESIRED GRID SIZE 
#-----------------------------------------------------------------------
#
  if (! $?NZX1) set NZX1 = 32
  if (! $?NZX2) set NZX2 = 32
  if (! $?NZX3) set NZX3 = 32
#
#-----------------------------------------------------------------------
# CHECK THE GRID-RELATED VARIABLES BELOW
#-----------------------------------------------------------------------
# Array sizes (computational mesh plus 5 ghost zones)
#
  @ NAX1 = $NZX1 + 5
  @ NAX2 = $NZX2 + 5
  @ NAX3 = $NZX3 + 5
#
# Set NAXM to largest array size
#
  set NAXM = $NAX1
   if ($NAX2 > $NAXM) set NAXM = $NAX2
   if ($NAX3 > $NAXM) set NAXM = $NAX3
#
# Compute half the number of zones (for initializing the grid in blocks)
#
  @ NHX1 = $NZX1 / 2
  @ NHX2 = $NZX2 / 2
  @ NHX3 = $NZX3 / 2
#
# Compute grid indices of the origin, etc., for display dumps
# The first zone in the computational space normally has index 3
#
  @ NOX1 = $NHX1 + 3
  @ NOX2 = $NHX2 + 3
  @ NOX3 = $NHX3 + 3
  @ NOVD = $NOX2      # Vertical   direction in display dump <-> 2 axis
  @ NOHD = $NOX3      # Horizontal direction in display dump <-> 3 axis
  @ NMVD = $NOVD + 16 # Can fit this many numbers vertically on 24 lines
  @ NMHD = $NOHD +  9 # Can fit this many numbers horizontally on 80 col
#
# Number of pixels in each direction for pixel dumps
#
  if (! $?NXPX) setenv NXPX 100
  if (! $?NYPX) setenv NYPX 100
#
# Number of voxels in each direction.  Maximum values are:
# ( NAX1 - 1,  2 * NAX2 - 1,  2 * NAX3 - 1 )
#
  @ NVX1 = $NAX1 - 1
  @ NVX2 = $NVX1
  @ NVX3 = $NVX1
#
#-----------------------------------------------------------------------
# CHANGE INPUT PARAMETERS BELOW FOR YOUR PROBLEM AND DESIRED OUTPUT.
# IF, FOR EXAMPLE, dtplt1 IS SET TO ZERO, NO 1-D NCAR PLOTS WILL BE
# OUTPUT.  THIS ALSO HOLDS FOR THE OTHER dt* PARAMETERS.  IN ADDITION,
# THE CORRESPONDING MACROS IN zeus34.mac MUST BE DEFINED FOR THE
# OUTPUT TO BE PRODUCED.
#-----------------------------------------------------------------------
#
  if (! $?INZEUS) then
#
# Quantities in UPPER CASE (preceeded by a $ with no \) are grid-
# related variables whose values were set above.
#
    echo ""
    echo "Writing new zeus input file inzeus:"
    echo ""
    cat << EOF > inzeus
 \$iocon    iotty=6, iolog=2                                          \$
 \$rescon   dtdmp=0.1, id='ca', resfile='zr00ca', iaddz=-1            \$
 \$ggen1    nbl=$NHX1, x1min=-1.0, x1max= 0.0, igrid=-1, x1rat=1.02   \$
 \$ggen1    nbl=$NHX1, x1min= 0.0, x1max= 1.0, igrid= 1, x1rat=1.02
         , lgrid=.t.                                                  \$
 \$ggen2    nbl=$NHX2, x2min=-1.0, x2max= 0.0, igrid=-1, x2rat=1.02   \$
 \$ggen2    nbl=$NHX2, x2min= 0.0, x2max= 1.0, igrid= 1, x2rat=1.02
         , lgrid=.t.                                                  \$
 \$ggen3    nbl=$NHX3, x3min=-1.0, x3max= 0.0, igrid=-1, x3rat=1.02   \$
 \$ggen3    nbl=$NHX3, x3min= 0.0, x3max= 1.0, igrid= 1, x3rat=1.02
         , lgrid=.t.                                                  \$
 \$pcon     nlim= 17, tlim=0.001, ttotal=1000.0, tsave=10.0           \$
 \$hycon    qcon=0.2, qlin=0.0, dtrat=0.001, courno=0.5, iord=2
         , istp=0, icool=0, itote=0                                   \$
 \$iib      niib(1:$NAX2,1:$NAX3)=2                                   \$
 \$oib      noib(1:$NAX2,1:$NAX3)=2                                   \$
 \$ijb      nijb(1:$NAX3,1:$NAX1)=2                                   \$
 \$ojb      nojb(1:$NAX3,1:$NAX1)=2                                   \$
 \$ikb      nikb(1:$NAX1,1:$NAX2)=2                                   \$
 \$okb      nokb(1:$NAX1,1:$NAX2)=2                                   \$
 \$grvcon   g=6.67e-08, ptmass=0.0, x1ptm=0.0, x2ptm=0.0, x3ptm=0.0   \$
 \$eqos     gamma=1.6666667, niso=0, ciso=1.0                         \$
 \$gcon     x1fac=0.0, x2fac=0.0, x3fac=0.0, ia=3, ja=3, ka=3, igcon=0\$
 \$extcon   istretch(1:4)=0, jstretch(1:4)=0, kstretch(1:4)=0         \$
 \$plt1con  dtplt1=0.00000, iplt1dir=1, iplt1=$NOX1, jplt1=$NOX2
         , kplt1=$NOX3, plt1var='d ','p ','v1','v2','v3'
         , nlplt1=1,1,0,0,0                                           \$
 \$plt2con  dtplt2=0.00000, iplt2dir=1,2,3
         , lplt2=$NOX1,$NOX3,$NOX3, plt2var='d ','p ','vp','bp'
         , nlplt2=1,1,0,0, vscale=0.4                                 \$
 \$pixcon   dtpix=0.00000, ipixdir=1, lpix=$NOX1
         , pixvar='d ','p ','s1','s2', npi=$NXPX, npj=$NYPX
         , nlpix=1,1,0,0, rorhpix=2, iref=0, jref=0                   \$
 \$voxcon   dtvox=0.00000, nvi=$NVX1, nvj=$NVX2, nvk=$NVX3
         , voxvar='d ','v ', rorhvox=2                                \$
 \$usrcon   dtusr=0.0                                                 \$
 \$hdfcon   dthdf=0.00000, hdfvar='to'                                \$
 \$tslcon   dttsl=0.00001
         , dttslp=0.00000                                             \$
 \$discon   dtdis=0.00001, idisdir=1, ldis=$NOX1, disvar='p '
         , jdismn=$NOHD, jdismx=$NMHD, kdismn=$NOVD, kdismx=$NMVD     \$
 \$radcon                                                             \$
 \$pgen     r=0.20, x10=0.0, x20=0.0, x30=0.0, d0=1.0, drat=100.0
         , p0=0.6, prat=1.0e6, b10=140.0, b20=0.0, b30=0.0
         ,                     b11=140.0, b21=0.0, b31=0.0            \$
EOF
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ END INZEUS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
  else
    echo ""
    echo "Using existing zeus input file inzeus:"
    echo ""
  endif
  Cat inzeus
  echo ""
#
# Create a new change deck chgzeus, overwriting any existing one
# unless the zeus34.s script was invoked with no setup block file 
# name on the command line.  
#
# The one below sets array sizes appropriate for a 34-cubed grid 
# (excluding ghost zones).
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ BEGIN CHGZEUS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#-----------------------------------------------------------------------
# BELOW, SET THE DESIRED NUMBER OF PIXELS IN PIXEL AND RADIO DUMPS 
#-----------------------------------------------------------------------
  if (! $?CHGZEUS) then
    cat << EOF > chgzeus
*read zeus34.mac
*delete par.14,15
       parameter     ( in = $NAX1, jn = $NAX2, kn = $NAX3, ijkn = $NAXM)
       parameter     ( nxpx = 101, nypx = 101, nxrd =   1, nyrd =   1 )
EOF
  endif
#
# The zeus34.s script will add more lines to chgzeus, including:
# "*read chgz34" if the file "chgz34" exists.  You may place any
# user-written change decks in chgz34, or you can have chgzeus read
# in a change deck by placing: "*read <change deck file name>" 
# between the "cat" command and the "EOF" line above.  
#
# The script will add source code for the functions ismax, ismin, and 
# sasum to chgz34 if required.
#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>> END SETUP BLOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>> BEGIN GENERIC XZEUS34 BLOCK 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#
else
  source $argv
endif
#
# Set aliases in chgzeus which pertain to the arithmetic precision
# and the names of C and library routines.
#
# In the code, setting REAL to real*4 results in the line:
#       parameter ( isig = 5, tiny = 1.0e-34, huge = 1.0e+34)
# while setting REAL to real*8 gives:
#       parameter ( isig = 9, tiny = 1.0e-99, huge = 1.0e+99)
#
# If the system has ismax and the other similar functions in some
# library, their names should depend on the precision of the 
# real arrays being passed to them.
#
if (! $?CHGZEUS) then
  cat << EOF >> chgzeus
*alias REAL $REAL
EOF
  if ("$OSYS" == HP || "$OSYS" == EXEMPLAR || "$OSYS" == IBM) then
    cat << EOF >> chgzeus
*alias CHECKIN checkin_
EOF
  else
    cat << EOF >> chgzeus
*alias CHECKIN checkin
EOF
  endif
  if ("$OSYS" != UNICOS) then
    if ("$OSYS" == HP || "$OSYS" == IBM) then
      cat << EOF >> chgzeus
*alias ETIME   etime_
*alias ITIME   itime_
*alias IDATE   idate_
EOF
    else
    cat << EOF >> chgzeus
*alias ETIME   etime
*alias ITIME   itime
*alias IDATE   idate
EOF
    endif
  endif
  set TEST = (`echo "$LIBS" | egrep "sgimath|blas"`)
  if ("$REAL" == 'real*8' && ("$OSYS" == CONVEXOS || \
     ("$OSYS" == IRIX     &&  "$TEST" != "" ) ) ) then
    if ("$HOST_NAME" == loki || "$HOST_NAME" == sgipc || \
        "$HOST_NAME" == origin) then
#
# The SGI Challenge "loki" does not have idmax or idmin in its 
# complib.sgimath library.  Use the provided source for ismax and ismin
# compiled with REAL aliased to real*8.
#
      cat << EOF >> chgzeus
*alias ISMAX   ismax
*alias ISMIN   ismin
EOF
    endif
    cat << EOF >> chgzeus
*alias SASUM   dasum
*alias ISAMAX  idamax
EOF
  else
    cat << EOF >> chgzeus
*alias ISMAX   ismax
*alias ISMIN   ismin
*alias SASUM   sasum
*alias ISAMAX  isamax
EOF
  endif
  if (-e chgz34) then
    echo "Using existing or newly created chgz34."
    echo ""
    cat << EOF >> chgzeus
*read chgz34
EOF
    echo "Writing new change deck chgzeus:"
    echo ""
  endif
else
  echo "Using existing change deck chgzeus:"
  echo ""
endif
#
Cat chgzeus
echo ""
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ END CHGZEUS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ BEGIN INEDIT_ZEUS34 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# If needed, create a new input deck for EDITOR to write the makefile 
# makezeus and preprocess the ZEUS-3D source code zeus34.
#
echo "Writing new EDITOR input deck inedit_zeus34:"
echo ""
cat << EOF > inedit_zeus34
 \$editpar   inname='zeus34'
          , ibanner=0, idump=1, job=3, safety=0.20
          , ipre=1, inmlst=1, iupdate=1, iutask=$IUTASK
          , chgdk='chgzeus'
          , branch='zeus3.4'
          , makename='makezeus', xeq='xzeus34'
EOF
#
# If the line with "loader=" is longer than 72 characters, break 
# it at 72 and continue on the next line.  The actual loader 
# string must be .lt. 72-26=50 characters to fit on one line.
# If the string has 50 characters, there needs to be room for a
# terminal dollar sign, so a second line is still necessary.
# Note that wc -c counts a newline as a character.
#
set NCHAR = `echo "$LDR" | wc -c`
@ NCHAR = $NCHAR - 1
#echo "NCHAR = $NCHAR"
if ($NCHAR < 50) then
  cat << EOF >> inedit_zeus34
          , loader='$LDR'
EOF
else
#
# The continuation line will be everything in LDR after the 
# 52nd character.
#
  set LIB2 = `echo "$LDR" | sed -e 's/....................................................//'`
#
# If LDR has 50 to 52 characters, avoid a "'" in column 3 or 72.
#
  if ("$LIB2" == "$LDR" || "$LIB2" == "") then
    set LIB1 = "$LDR"
    set LIB2 = " "
  else
    set LIB3 = `echo "$LDR"  | sed -e 's/\//@/g'`
    set LIB2 = `echo "$LIB2" | sed -e 's/\//@/g'`
    set LIB1 = `echo "$LIB3" | sed -e "s/$LIB2"'$'"//"`
    set LIB1 = `echo "$LIB1" | sed -e 's/@/\//g'`
    set LIB2 = `echo "$LIB2" | sed -e 's/@/\//g'`
  endif
  cat << EOF >> inedit_zeus34
          , loader='$LIB1
  $LIB2'
EOF
endif
#
# If the line with "coptions=" is longer than 72 characters, break 
# it at 72 and continue on the next line.  The actual compiler 
# options string must be .lt. 72-24=48 characters to fit on one line.
# If the string has 48 characters, there needs to be room for a
# terminal dollar sign, so a second line is still necessary.
# Note that wc -c counts a newline as a character.
#
set NCHAR = "`echo $F_COMP_OPTS | wc -c`"
@ NCHAR = $NCHAR - 1
#echo "NCHAR = $NCHAR"
if ($NCHAR < 48) then
  cat << EOF >> inedit_zeus34
          , coptions='$F_COMP_OPTS'
EOF
else
#
# The continuation line will be everything in F_COMP_OPTS after the 
# 50th character.
#
  set LIB2 = `echo $F_COMP_OPTS | sed -e 's/..................................................//'`
#
# If F_COMP_OPTS has 48 to 50 characters, avoid a "'" in column 3 or 72.
#
  if ("$LIB2" == "$F_COMP_OPTS" || "$LIB2" == "") then
    set LIB1 = "$F_COMP_OPTS"
    set LIB2 = " "
  else
    set LIB3 = "`echo $F_COMP_OPTS | sed -e 's/\//@/g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/\//@/g'`"
    set LIB1 =  `echo $LIB3 | sed -e "s/$LIB2"'$'"//"`
    set LIB1 = "`echo $LIB1 | sed -e 's/@/\//g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/@/\//g'`"
  endif
  cat << EOF >> inedit_zeus34
          , coptions='$LIB1
  $LIB2'
EOF
endif
#
# If the line with "loptions=" is longer than 72 characters, break 
# it at 72 and continue on the next line.  The actual loader 
# options string must be .lt. 72-24=48 characters to fit on one line.
# If the string has 48 characters, there needs to be room for a
# terminal dollar sign, so a second line is still necessary.
# Note that wc -c counts a newline as a character.
#
set NCHAR = "`echo $LDR_OPTS | wc -c`"
@ NCHAR = $NCHAR - 1
#echo "NCHAR = $NCHAR"
if ($NCHAR < 48) then
  cat << EOF >> inedit_zeus34
          , loptions='$LDR_OPTS'
EOF
else
#
# The continuation line will be everything in LDR_OPTS after the 
# 50th character.
#
  set LIB2 = `echo $LDR_OPTS | sed -e 's/..................................................//'`
#
# If LDR_OPTS has 48 to 50 characters, avoid a "'" in column 3 or 72.
#
  if ("$LIB2" == "$LDR_OPTS" || "$LIB2" == "") then
    set LIB1 = "$LDR_OPTS"
    set LIB2 = " "
  else
    set LIB3 = "`echo $LDR_OPTS | sed -e 's/\//@/g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/\//@/g'`"
    set LIB1 =  `echo $LIB3 | sed -e "s/$LIB2"'$'"//"`
    set LIB1 = "`echo $LIB1 | sed -e 's/@/\//g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/@/\//g'`"
  endif
  cat << EOF >> inedit_zeus34
          , loptions='$LIB1
  $LIB2'
EOF
endif
#
# If the line with "libs=" is longer than 72 characters, 
# break it at 72 and continue on the next line.
#
set NCHAR = "`echo $LIBS | wc -c`"
@ NCHAR = $NCHAR - 1
if ($NCHAR < 52) then
  cat << EOF >> inedit_zeus34
          , libs='$LIBS'\$
EOF
else
#
# The continuation line will be everything in LIBS after the 54th character.
#
  set LIB2 = `echo $LIBS | sed -e 's/......................................................//'`
#
# If LIBS has 52 to 54 characters, avoid a "'" in column 3 or 72.
#
  if ("$LIB2" == "$LIBS" || "$LIB2" == "") then
    set LIB1 = "$LIBS"
    set LIB2 = " "
  else
    set LIB3 = "`echo $LIBS | sed -e 's/\//@/g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/\//@/g'`"
    set LIB1 =  `echo $LIB3 | sed -e "s/$LIB2"'$'"//"`
    set LIB1 = "`echo $LIB1 | sed -e 's/@/\//g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/@/\//g'`"
    set LIB2 = "`echo $LIB2 | sed -e 's/^-/ -/'`"
  endif
  cat << EOF >> inedit_zeus34
          , libs='$LIB1
  $LIB2'\$
EOF
endif
cp inedit_zeus34 inedit
#
Cat inedit
cp inedit inedit_zeus34
#
echo ""
echo "Invoking EDITOR."
echo ""
chmod 700 xedit22 
xedit22
echo ""
\rm -f inedit
#
# If needed, edit makezeus to put in the desired compiler and loader
# names.
#
set FCOMP = ($F_COMP)
if (("$OSYS" == "SUNOS"    && "$FCOMP[1]" != "f77"  ) || \
    ("$OSYS" == "CONVEXOS" && "$FCOMP[1]" != "fc"   ) || \
    ("$OSYS" == "EXEMPLAR" && "$FCOMP[1]" != "/usr/convex/bin/fc" ) || \
    ("$OSYS" == "HP"       && "$FCOMP[1]" != "f77"  ) || \
    ("$OSYS" == "ALPHA"    && "$FCOMP[1]" != "f77"  ) || \
    ("$OSYS" == "SOLARIS"  && "$FCOMP[1]" != "f77"  ) || \
    ("$OSYS" == "IBM"      && "$FCOMP[1]" != "xlf"  ) || \
    ("$OSYS" == "UNICOS"   && "$FCOMP[1]" != "cft77") || \
    ("$OSYS" == "IRIX"     && "$FCOMP[1]" != "f77"  )) then
  echo ""
  echo "Editing makezeus; the line to be changed should be listed below."
  echo ""
  ex - makezeus << EOF
/COMP
d
i
COMP     = $F_COMP
.
wq
EOF
endif
#
set TEST = `grep 'zeus3d\.o...........$' makezeus`
if ("$TEST" != "") then
#
# Now insert a switch to replace \\ with \ just as was done in the
# makeedit section.  
#
  ex - makezeus << EOF
%s/\\\//
wq
EOF
endif
#
# For UNICOS with cf77 instead of cft77, edit makezeus to put in the 
# correct syntax.
#
if ("$OSYS" == "UNICOS" && "$FCOMP[1]" != "cft77") then
  echo ""
  echo "Editing makezeus to use $FCOMP[1] syntax instead of cft77"
  echo ""
  if ($IUTASK == 1) then
    set UTASK = "-Zp "
  else
    set UTASK = ""
  endif
  ex - makezeus << EOF
/COPT
s/-l/${UTASK}-Wf"-l/
s/\$/"/
wq
EOF
endif
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~ END INEDIT_ZEUS34 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Modify the makefile "makezeus" for certain machines.
#
if ("$HOST_NAME" == sgipc || "$HOST_NAME" == origin) then
#
# The SGI Power Challenge may have problems with display dumps.  
# It also may crash when reading namelists for real*8 and -O3.
# Compile the troublesome routines without optimization.
# Lately having problems with routine "round".
#
  cat << EOF >> makezeus
\$(DIR)displayi.o: \$(DIR)displayi.f
	\$(COMP) -o \$*.o -O0 -w -64 -mips4 -OPT:roundoff=3,IEEE_arithmetic=3 \$<
\$(DIR)displayr.o: \$(DIR)displayr.f
	\$(COMP) -o \$*.o -O0 -w -64 -mips4 -OPT:roundoff=3,IEEE_arithmetic=3 \$<
\$(DIR)nmlsts.o: \$(DIR)nmlsts.f
	\$(COMP) -o \$*.o -O0 -w -64 -mips4 -OPT:roundoff=3,IEEE_arithmetic=3 \$<
\$(DIR)round.o: \$(DIR)round.f
	\$(COMP) -o \$*.o -O0 -w -64 -mips4 -OPT:roundoff=3,IEEE_arithmetic=3 \$<
EOF
endif
if ($HOST_NAME == lena) then
#
# On SPP-1200, routine "ran1" will never finish compiling with
# the 20 Apr. 95 version of fc at optimization level -O1 or higher.
# Routine voxdmp will cause a runtime error if compiled at -O1 or more.
# Also, routines "rawpix" and "rawvox" cause an error with fc at
# any optimization level, so use f77.
#
  cat << EOF >> makezeus
\$(DIR)ran1.o: \$(DIR)ran1.f
	\$(COMP) -o \$*.o -O0 \$<
\$(DIR)voxdmp.o: \$(DIR)voxdmp.f
	\$(COMP) -o \$*.o -O0 \$<
\$(DIR)rawpix.o: \$(DIR)rawpix.f
	f77 -c -o \$*.o +O2 \$<
\$(DIR)rawrad.o: \$(DIR)rawrad.f
	f77 -c -o \$*.o +O2 \$<
\$(DIR)rawvox.o: \$(DIR)rawvox.f
	f77 -c -o \$*.o +O2 \$<
EOF
endif
echo ""
echo "Making xzeus34 from makefile makezeus."
echo ""
if ("$OSYS" == "IRIX") then
  smake -f makezeus
else if ("$OSYS" == "EXEMPLAR") then
  /usr/contrib/bin/gmake -j 4 -f makezeus
else
  make -f makezeus
endif
if (! -e xzeus34) goto QUIT
#
# The ZEUS-3D executable xzeus34 should exist now.
#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>> END GENERIC XZEUS34 BLOCK 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#
QUIT:
if (-e Cat) then
  \rm -f Cat
endif
exit


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: