#!/usr/bin/csh -fe

# Rename the xtime variable in the MPAS ocean and sea-ice
# initial_condition files to overcome date conflicts when branching
# from a control simulation using arbitrary years to a transient
# simulation using actual years.

# Philip Cameron-Smith, 2019-11-7

set original_mpaso  = mpaso.rst.0056-01-01_00000.nc
set original_mpassi = mpascice.rst.0056-01-01_00000.nc

set new_mpaso       = ${original_mpaso}.no_xtime
set new_mpassi      = ${original_mpassi}.no_xtime


echo '--- Copying  '${original_mpaso} ' to ' ${new_mpaso} '---'
cp -f ${original_mpaso} ${new_mpaso}

echo '--- Renaming xtime to xtime_orig ---'
ncrename -v xtime,xtime_orig ${new_mpaso}

echo '--- Copying  '${original_mpassi} ' to ' ${new_mpassi} '---'
cp -f ${original_mpassi} ${new_mpassi}

echo '--- Renaming xtime to xtime_orig ---'
ncrename -v xtime,xtime_orig ${new_mpassi}

echo '--- Completed ---'

# --- End of Script ---
