#! /bin/sh
########################################################################################
# Name of Script: exverf_g2g_cloud.sh.sms
# Purpose of Script: To generate the verification products for the g2g verification
#                    on the model cloud output to be used by the Forecast Verification System
# Arguments: exverf_g2g_cloud.sh.sms $yyyy$mm$dd
# Log history:
########################################################################################
set -x

cd $DATA

echo "$0 STRDATE "`date`

msg="$job HAS BEGUN"
postmsg "$jlogfile" "$msg"

export vday=$1

################################################
# Get the observation AFWA and CLAVR cloud data 
################################################
$USHverf_g2g/verf_g2g_get_cloud.sh afwa $vday
$USHverf_g2g/verf_g2g_get_cloud.sh clavr $vday

## Read in the model information
cp $PARMverf_g2g/verf_g2g_cloud.modelinfo g2g.modelinfo

cat g2g.modelinfo |while read line
do
  vmodel=`echo $line |awk -F"|" '{print $1}'`

  export vgrid=${vgrid:-212}

  # Get the input model data
  $USHverf_g2g/verf_g2g_get_cloud.sh $vmodel $vday
  
  domains=`echo $line |awk -F"|" '{print $2}'`
  for model in $domains
  do
  
     #################################################################
     # Part I: Verification of the model output against the AFWA data:
     #################################################################
     # Turn off cloud base for the afwa data
     export cloud_base_from_sfc=no
     $USHverf_g2g/verf_g2g_cloud.sh $vday $model afwa

     #################################################################
     # Part II: Verification of the model output against the CLAVR data:
     #################################################################
     # Turn on cloud base for the clavr data
     export cloud_base_from_sfc=yes
     $USHverf_g2g/verf_g2g_cloud.sh $vday $model clavr
  done
done

#####################################################################
# GOOD RUN
set +x
echo "**************$job COMPLETED NORMALLY on `date`"
set -x
#####################################################################

msg="HAS COMPLETED NORMALLY!"
echo $msg
postmsg "$jlogfile" "$msg"

############## END OF SCRIPT #######################

