diff --git a/scripts/exgdas_enkf_earc.sh b/scripts/exgdas_enkf_earc.sh index a1bcba4d799..3820de74558 100755 --- a/scripts/exgdas_enkf_earc.sh +++ b/scripts/exgdas_enkf_earc.sh @@ -114,8 +114,23 @@ if [ "${ENSGRP}" -eq 0 ]; then set +e ${TARCMD} -P -cvf "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" $(cat "${ARCH_LIST}/${RUN}.txt") status=$? - ${HSICMD} chgrp rstprod "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" - ${HSICMD} chmod 640 "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" + + has_rstprod="NO" + while IFS= read -r file; do + if [[ -f ${file} ]]; then + group=$( stat -c "%G" "${file}" ) + if [[ "${group}" == "rstprod" ]]; then + has_rstprod="YES" + break + fi + fi + done < "${ARCH_LIST}/${RUN}.txt" + + if [[ "${has_rstprod}" == "YES" ]]; then + ${HSICMD} chgrp rstprod "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" + ${HSICMD} chmod 640 "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" + fi + if (( status != 0 && ${PDY}${cyc} >= firstday )); then echo "FATAL ERROR: ${TARCMD} ${PDY}${cyc} ${RUN}.tar failed" exit "${status}" diff --git a/scripts/exglobal_archive.sh b/scripts/exglobal_archive.sh index 78a6d60b655..966ddc8b907 100755 --- a/scripts/exglobal_archive.sh +++ b/scripts/exglobal_archive.sh @@ -266,8 +266,21 @@ if [[ ${HPSSARCH} = "YES" || ${LOCALARCH} = "YES" ]]; then status=$? case ${targrp} in 'gdas'|'gdas_restarta') - ${HSICMD} chgrp rstprod "${ATARDIR}/${CDATE}/${targrp}.tar" - ${HSICMD} chmod 640 "${ATARDIR}/${CDATE}/${targrp}.tar" + has_rstprod="NO" + while IFS= read -r file; do + if [[ -f ${file} ]]; then + group=$( stat -c "%G" "${file}" ) + if [[ "${group}" == "rstprod" ]]; then + has_rstprod="YES" + break + fi + fi + done < "${ARCH_LIST}/${targrp}.txt" + + if [[ "${has_rstprod}" == "YES" ]]; then + ${HSICMD} chgrp rstprod "${ATARDIR}/${CDATE}/${targrp}.tar" + ${HSICMD} chmod 640 "${ATARDIR}/${CDATE}/${targrp}.tar" + fi ;; *) ;; esac