#!/usr/bin/env bash thismachine=$(cat /etc/cluster_name) prodcluster=$(grep 'primary:' /lfs/h1/ops/prod/config/prodmachinefile | sed 's/primary://') devcluster=$(grep 'backup:' /lfs/h1/ops/prod/config/prodmachinefile | sed 's/backup://') dev=${devcluster:0:1}'login08' echo "$dev" if [[ ${thismachine} != ${prodcluster} ]]; then echo "This script must be run on a production machine!" exit 0 fi echo "=====> Started sync prod/dev at `date`." pdy=`date +%Y%m%d` pdym1=`date --date 'now 1 day ago' +%Y%m%d` pdym2=`date --date 'now 2 day ago' +%Y%m%d` testcom=/lfs/f2/t2o/ptmp/nwm/Zhengtao.Cui/test/com/nwm/v3.0/nwm.${pdy} testcomm1=/lfs/f2/t2o/ptmp/nwm/Zhengtao.Cui/test/com/nwm/v3.0/nwm.${pdym1} testcomm2=/lfs/f2/t2o/ptmp/nwm/Zhengtao.Cui/test/com/nwm/v3.0/nwm.${pdym2} if [[ ! -d ${testcom} ]]; then exit fi ssh ${dev} "[ ! -d ${testcom} ] && mkdir -p ${testcom}" ssh ${dev} "[ ! -d ${testcomm1} ] && mkdir -p ${testcomm1}" echo "CONUS, Hawaii, Puertorico, Alaska AnA restarts!" #CONUS, Hawaii, Puertorico, Alaska domain for dir in ${testcom} ${testcomm1}; do echo ${dir} for domain in restart restart_hawaii restart_puertorico restart_alaska; do echo "$domain" if [[ -d ${dir}/${domain}/genericRst ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/${domain}/genericRst/ && rsync" ${dir}/${domain}/genericRst/ ${dev}:${dir}/${domain}/genericRst/ fi if [[ -d ${dir}/${domain}_no_da/genericRst ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/${domain}_no_da/genericRst/ && rsync" ${dir}/${domain}_no_da/genericRst/ ${dev}:${dir}/${domain}_no_da/genericRst/ fi done done #AnA long echo "CONUS, AnA long restarts!" for dir in ${testcom} ${testcomm1}; do if [[ -d ${dir}/restart_long ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_long && rsync" \ ${dir}/restart_long/ ${dev}:${dir}/restart_long/ fi if [[ -d ${dir}/restart_long_no_da ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_long_no_da && rsync" \ ${dir}/restart_long_no_da/ ${dev}:${dir}/restart_long_no_da/ fi done #Forecast restarts echo "All forecast restartss!" for dir in ${testcom} ${testcomm1}; do for restart in restart_forecast \ restart_long_forecast \ restart_alaska_forecast \ restart_hawaii_forecast \ restart_puertorico_forecast; do if [[ -d ${dir}/${restart} ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/${restart} && rsync" \ ${dir}/${restart}/ ${dev}:${dir}/${restart}/ fi done done echo "All coastal restartss!" #coastal restarts for dir in ${testcom} ${testcomm1}; do if [[ -d ${dir}/restart_coastal ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_coastal && rsync" \ ${dir}/restart_coastal/ ${dev}:${dir}/restart_coastal/ fi done #AnA forcing echo "AnA forcingss!" for dir in ${testcom} ${testcomm1}; do for ana in analysis_assim \ analysis_assim_alaska; do if [[ ${dir}/nwges/nwm/${ana} ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/nwges/nwm/${ana} && rsync" \ ${dir}/nwges/nwm/${ana}/ ${dev}:${dir}/nwges/nwm/${ana}/ fi done for sr in short_range_hawaii \ short_range \ short_range_puertorico; do if [[ -d ${dir}/nwges/nwm/${sr} ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/nwges/nwm/${sr} && rsync" \ ${dir}/nwges/nwm/${sr}/ ${dev}:${dir}/nwges/nwm/${sr}/ fi done done echo "AnA extended restarts!" for dir in ${testcom} ${testcomm1}; do if [[ -d ${dir}/restart_extend ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_extend && rsync" ${dir}/restart_extend/ ${dev}:${dir}/restart_extend/ fi if [[ -d ${dir}/restart_extend_no_da ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_extend_no_da && rsync" ${dir}/restart_extend_no_da/ ${dev}:${dir}/restart_extend_no_da/ fi done # #Medium range forcing echo "Medium range forcing" for dir in ${testcom} ${testcomm1} ${testcomm2}; do for md in medium_range \ medium_range_alasks; do if [[ -d ${dir}/nwges/nwm/${md} ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/nwges/nwm/${md} && rsync" \ ${dir}/nwges/nwm/${md}/ ${dev}:${dir}/nwges/nwm/${md}/ fi done done #coastal AnA forcing #included in AnA already in above #Short range forcing already been included above #medium range forcing already been included above #For coastal Extend AnA echo "Coastal Extended AnA NWM forcing" for dir in ${testcom} ${testcomm1}; do if [[ -d ${dir}/nwges/nwm/analysis_assim_extend ]]; then rsync -avz \ --rsync-path="mkdir -p ${dir}/nwges/nwm/analysis_assim_extend && rsync" \ ${dir}/restart_extend/ ${dev}:${dir}/nwges/nwm/analysis_assim_extend fi done #streamflows for coastal echo "Coastal streamflow" for dir in ${testcom} ${testcomm1}; do for d in analysis_assim_no_da \ analysis_assim_extend_no_da; do if [[ -d ${dir}/nwges/nwm/${d} ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/nwges/nwm/${d} && rsync" \ ${dir}/nwges/nwm/${d}/ ${dev}:${dir}/nwges/nwm/${d}/ fi done done echo "Coastal streamflow from \$COM" for dir in ${testcom} ${testcomm1}; do for d in analysis_assim \ analysis_assim_extend \ analysis_assim_hawaii \ analysis_assim_puertorico \ short_range \ short_range_hawaii \ short_range_puertorico \ medium_range_mem1 \ medium_range_blend; do if [[ -d ${dir}/${d} ]]; then rsync -avz \ --include="*/" --include="*.channel_rt*.*" --exclude="*" \ --rsync-path="mkdir -p ${dir}/${d} && rsync" \ ${dir}/${d}/ ${dev}:${dir}/${d}/ fi done done echo "=====> Done sync prod/dev at `date`."