123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- #! /bin/sh
- # exit on error
- set -e
- # --- init -----------------------------------------------
- # set program name and location:
- case $0 in
- /* ) script=$0 ;;
- * ) script="`/bin/pwd`/$0" ;;
- esac
- bindir=`/usr/bin/dirname ${script}`
- prog=`/bin/basename ${script}`
- # --- help ---
- DisplayHelp ()
- {
- ${PAGER:-less} << EOF
- NAME
- $prog - store output
- USAGE
- #$prog <rcfile> <outputdir> <runname> <compdir>
- $prog <rcfile> <outputdir> <compdir>
- Post process output files.
- The script is called with this arguments from the 'run-tm5.jb' script.
- Arguments have the following meaning:
- <rcfile> : settings
- <outputdir> : main directory for output ('outputdir' in rcfile), e.g.
- \$TEMP/run.TM5-OUTPUT
- #<runname> : subdirectory created by 'run-tm5.jb' within <outputdir>
- # with a name including start and end time, e.g.
- # TM5_2002110100_2002110300
-
- <compdir> : directory with sources and scripts for this run, e.g.
- \$TEMP/run.TM5/xlf90-fast-R64
-
- $prog -h,--help
-
- Display this help text.
- RCFILE
- The following settings are read from the rcfile :
- ! current implementation creates a tar file of <runname> directory
- ! and stores this in one or more destination directories (gss descriptions)
- output.store.destdirs : \${TEMP}/archive/ ecfs:/klm/archive
- ! gzip files before storage (T|F) ?
- output.store.compress : F
- ! remove files after store (T|F) ?
- output.store.clean : F
- EOF
- exit 0
- }
- # err 'help text'
- err ()
- {
- echo "$1" 1>&2
- }
- # errit <exit-status>
- errit ()
- {
- err "$prog - ERROR - Use '$prog --help' for more info."
- exit $1
- }
- # --- arguments ------------------------
- # set empty values
- rcfile=''
- outputdir=''
- #runname=''
- compdir=''
- # extract settings
- for arg in "$@" ; do
- case ${arg} in
- --help | -h ) DisplayHelp ;;
- * ) if [ -z "${rcfile}" ]; then
- rcfile=${arg}
- elif [ -z "${outputdir}" ]; then
- outputdir=${arg}
- #elif [ -z "${runname}" ]; then
- # runname=${arg}
- elif [ -z "${compdir}" ]; then
- compdir=${arg}
- else
- err "$prog - ERROR - unknown argument '${arg}'"
- errit 1
- fi
- esac
- done
- if [ -z "${compdir}" ]; then
- err "$prog - ERROR - missing arguments ..."
- errit 1
- fi
- # --- settings -----------------------------------------------------------
- # read list with destinations:
- destdirs=`${bindir}/go_readrc ${rcfile} 'output.store.destdirs'`
- # compress ?
- compress=`${bindir}/go_readrc ${rcfile} 'output.store.compress' 'F'`
- # clean ?
- clean=`${bindir}/go_readrc ${rcfile} 'output.store.clean' 'F'`
- # extern:
- tar='/usr/bin/tar'
- gzip='/usr/bin/gzip'
- # --- begin -----------------------------------------------------------
- echo "$prog - store output ..."
- # name of output directory includes time range:
- #outdir="${outputdir}/${runname}"
- outdir="${outputdir}"
- # tar file to contain sources:
- src_tar="${outdir}/src.tar"
- # tar sources:
- echo "$prog - tar sources ..."
- /bin/rm -f ${src_tar} ${src_tar}.gz
- ( cd ${compdir}/src ; ${tar} cf ${src_tar} *.[Ff]* *.h Makefile* )
- ${gzip} -f ${src_tar}
- # goto main output directory:
- cd ${outputdir}
- ## tar output files:
- #tarfile="${runname}.tar"
- #echo "$prog - tar run output :"
- #${tar} cvf ${tarfile} ${runname}
- # compress ?
- if [ "${compress}" = "T" ]; then
- echo "$prog - compress ..."
- # loop over output files:
- for outfile in `/bin/ls` ; do
- case ${outfile} in
- *.gz ) ;;
- * ) ${gzip} -f ${outfile} ;;
- esac
- done
- fi
- # loop over all destinations:
- for destdir in ${destdirs} ; do
- echo "$prog - store in ${destdir} ..."
- #${bindir}/gss copy --mkdir ${tarfile} ${destdir}/${tarfile}
-
- # loop over output files:
- for outfile in `/bin/ls` ; do
-
- # skip some files ...
- skip=''
- case ${destdir}/${outfile} in
- ecfs:*/regions_*.hdf.gz ) skip='true' ;;
- ecfs:*/budget_*_glb3x2.hdf.gz ) skip='true' ;;
- esac
- if [ "${skip}" ]; then
- echo "$prog - ${outfile} (skip)"
- continue
- fi
- echo "$prog - ${outfile} ..."
- ${bindir}/gss copy --mkdir --force ${outfile} ${destdir}/${outfile}
- done
- done
- # clean
- if [ "${clean}" == "T" ]; then
- echo "$prog - clean ..."
- /bin/rm -f *
- #/bin/rm -f ${tarfile}
- fi
- # --- end --------------------------------------------------------------
- echo "$prog - end"
|