NOAA-EMC / AQM-utils

0 stars 6 forks source link

Add chem LBC variables using Python #10

Closed zmoon closed 11 months ago

zmoon commented 1 year ago

Replacing ncks -A chem.nc met.nc (append) usage in workflow.

With this script, all the gfs_bndy file paths can be passed in one call. The call in the workflow could be adjusted something like this to accommodate this feature:

+  met_fps=()
   for hr in 0 ${LBC_SPEC_FCST_HRS[@]}; do
     fhr=$( printf "%03d" "${hr}" )
-    if [ -r ${INPUT_DATA}/${NET}.${cycle}${dot_ensmem}.gfs_bndy.tile7.f${fhr}.nc ]; then
-      ncks -A ${chem_lbcs_fn} ${INPUT_DATA}/${NET}.${cycle}${dot_ensmem}.gfs_bndy.tile7.f${fhr}.nc
-      export err=$?
-      if [ $err -ne 0 ]; then
-        message_txt="Call to NCKS returned with nonzero exit code."
-        if [ "${RUN_ENVIR}" = "nco" ] && [ "${MACHINE}" = "WCOSS2" ]; then
-          err_exit "${message_txt}"
-        else
-          print_err_msg_exit "${message_txt}"
-        fi
-      fi
+    met_fp="${INPUT_DATA}/${NET}.${cycle}${dot_ensmem}.gfs_bndy.tile7.f${fhr}.nc"
+    if [ -r "${met_fp}" ]; then
+      met_fps+=("${met_fp}")
     fi
   done
+  append-chem-lbc.py --chem "${chem_lbcs_fn}" --met "${met_fps[@]}"
+  export err=$?
+  if [ $err -ne 0 ]; then
+    message_txt="Call to append-chem-lbc.py returned with nonzero exit code."
+    if [ "${RUN_ENVIR}" = "nco" ] && [ "${MACHINE}" = "WCOSS2" ]; then
+      err_exit "${message_txt}"
+    else
+      print_err_msg_exit "${message_txt}"
+    fi
+  fi

Also seems like it might be good to do something if the -r fails instead of leaving it silent?

chan-hoo commented 11 months ago

@zmoon, isn't this pr ready for review yet? or if it is not necessary any more, please close this pr.