#!/bin/bash

[ $IRSPP_INSTALL ] || { echo "Please define environment variable IRSPP_INSTALL"; exit 1; }

[ -f $IRSPP_INSTALL/bin/irspp_env.sh ] || { echo "Error: cannot find $IRSPP_INSTALL/bin/irspp_env.sh"; exit 1; }

. $IRSPP_INSTALL/bin/irspp_env.sh

TOPDIR=$(cd ..; pwd)

#input and output files

outdir=$TOPDIR/output_fullres_netcdf
mkdir -p $outdir
infiles=$(ls $TOPDIR/input/*1B-PC*BODY*.nc)
namelistfile=irs_main_fullres.nl

#process each file with reconstructed radiances

for file in $infiles; do
  echo $file
  cp -p $file $outdir
  irs_main.exe -io $outdir/$(basename $file) -n $namelistfile
done
