
#======================================================================
# Clear coupler log files for validation test
#======================================================================
unsetenv CPLLOG_INIT
unsetenv CPLNML_INIT
unsetenv COMPARE_NAMELISTS

set stat = "PASS"
#======================================================================
# Just run build of namelists and check that files exist
#======================================================================
cd $CASEROOT
echo "just check that namelists build and files exist" >>& $TESTSTATUS_LOG 

./preview_namelists
if ( $status != 0 ) set stat = "FAIL"
./check_input_data -check -inputdata $DIN_LOC_ROOT
if ( $status != 0 ) set stat = "FAIL"
set CplNmlFile = `ls -1t $CASEROOT/CaseDocs/drv_in`
setenv CPLNML_INIT $CplNmlFile
setenv COMPARE_NAMELISTS 1

#======================================================================
# Copy namelist files to RUNDIR and create a CPL "log" file
#======================================================================
if ( $?CPLNML_INIT ) then
   echo $stat > $RUNDIR/cpl.log
endif

set CplLogFile = `ls -1t $RUNDIR/cpl.log* | head -1`
setenv CPLLOG_INIT    $CplLogFile
setenv BASEGEN_FILE01 $CplLogFile

#======================================================================
# Check case validation first
#======================================================================

set basestatus = "UNDEF"
if ( $?CPLNML_INIT ) then
  set basestatus = $stat
else
  echo "ERROR in ${0}:  initial coupler namelist file NOT set" >>& $TESTSTATUS_LOG
  set basestatus = "ERROR"
endif

echo "$basestatus ${CASEBASEID} " >&! $TESTSTATUS_OUT

