#!/bin/bash
#PBS -o /scratchout/grupos/grpeta/projetos/tempo/oper/GEF_v1.0.0_oper/2020082112/../err/err.etapost
#PBS -N Post_GEF_KF
#PBS -q pesq.q
#PBS -lselect=1:ncpus=1
#PBS -A CPTEC
#PBS -j oe

. /opt/modules/default/etc/modules.sh
module swap pgi  pgi/12.2.0
set -aeux

ulimit -c unlimited

TMP_DIR=/scratchin/grupos/grpeta/projetos/tempo/oper/GEF_v1.0.0_oper/gef_trunk/PRP/gef_tmp
ETA_RUN=/scratchout/grupos/grpeta/projetos/tempo/oper/GEF_v1.0.0_oper/2020082112
daym10=3108202012

data3=`echo ${ETA_RUN} | cut -c1- | wc -c`
let data2=${data3}-10
data=`echo ${ETA_RUN} | cut -c${data2}-${data3} `


cd ${ETA_RUN}


${TMP_DIR}/../exe/etapost_aux.exe 1> ${ETA_RUN}/../err/err.etapost_aux 2>&1 


LastArq="False"

while [ "${LastArq}" != "True" ] ; do

  if [ -s ${ETA_RUN}/../GLOBRUN/${data}/globrun${daym10}.dat ] ; then

    echo "Gerando Figuras"
    cd ${TMP_DIR}/../../Figuras
    ./Gera_Figuras.ksh ${data}

      LastArq="True"

  else

    sleep 20

  fi

done


