#!/bin/ksh # Apr 2010 edited for new ckopus - no more o2bq # coad.k June 2001 jwh # This script is to be used with o2bqx and coad to average spectra from OPUS # files into a bnr3 file and produce the o2bqx.out for fitbatch # input file coad.inp has the form # n # of files # path/file1 # path/filen # open input file and get number of files, lat, lon exec 9< coad.inp read -u9 nfiles read -u9 block junk read -u9 loc junk print "Files to coad: " $nfiles print " Location & block : " $loc $block n=0 for locvar in TAB SGP MLO FL0 MSA PKF KPK DEF do if [[ ${loc} = ${locvar} ]] then n=1 fi done if (( n == 0 )) then print "No Location match : " ${loc} exit 1 fi integer n=0 while read -u9 OPUSfile sUTC do # increase counter ((n = n + 1)) if ((n > nfiles)) then continue fi print -R " Running ckopus..." rm -rf ${block}.bnr o2b_out=$(ckopus -S${loc} -t${sUTC} -F${block} ${OPUSfile} 2>>ckopus.err) bnrOK=$? # We should end with a single bnr if (( $bnrOK == 0 )) then mv -f ${block}.bnr $n.bnr else print " Error with ckopus : " $bnrOK exit 1 fi exec 8coad.i print -u8 -R $nfiles # number of bnr files while ((i <= nfiles)) do print -u8 $i.bnr ((i = i + 1)) done exec 8>&- print " Running coad..." coad_out=$(coad) bnrOK=$? # We should end with a single bnr if (( $bnrOK == 0 )) then mv -f temp.bnr ${block}.bnr else print " Error with coad : " $bnrOK exit 1 fi # get output to display header, its the last line exec 8>coad.out # clean up intermediate bnr files integer i=1 while ((i <= nfiles)) do rm -f $i.bnr ((i = i + 1)) done print "Coad.k Done." exit