#!/bin/sh
#MOVE h1 files to long-term archiving directory
#by C Todd Rhodes
#02/12/2019

expName="ExpC"
runName="En008_20001215"

#lastRestName="2009-04-27-00000"
#lastRestName="2009-03-16-00000"
lastRestName="2001-04-01-00000" #"2013-04-01-00000"

str1="/home/ctrhodes/mydata2/CESM_Ensemble/experiments/"
str2="/rest/"
orig_dir=$str1$expName$str2

str3="/home/ctrhodes/mydata2/CESM_Ensemble/Nudge_0km_p4km/20001215_Set/"
str4="/."
dest_dir=$str3$runName$str4

str5=".cam.h1*"
file_pattern=$expName$str5
prox_file=".prox_fileMOVEh1.txt"

mkdir $str3$runName

#COPY OVER LAST RESTART FOLDER
cp -r $orig_dir$lastRestName $dest_dir

#FIND AND MOVE ALL .cam.h1 files
find $orig_dir -name $file_pattern > $prox_file

xargs mv -t $dest_dir < $prox_file

rm $prox_file

