#!/usr/bin/env bash # Purpose: Climatology script tailored to E3SM (and hence CESM'ish) input and E3SM output guidelines # Produces (and optionally regrids) climatological monthly means, seasonal means, annual means, CMIP6-style timeseries, global-mean timeseries, diurnal cycles # Copyright (C) 2015--present Charlie Zender # This file is part of NCO, the netCDF Operators. NCO is free software. # You may redistribute and/or modify NCO under the terms of the # 3-Clause BSD License. # You are permitted to link NCO with the HDF, netCDF, OPeNDAP, and UDUnits # libraries and to distribute the resulting executables under the terms # of the BSD, but in addition obeying the extra stipulations of the # HDF, netCDF, OPeNDAP, and UDUnits licenses. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the 3-Clause BSD License for more details. # The original author of this software, Charlie Zender, seeks to improve # it with your suggestions, contributions, bug-reports, and patches. # Please contact the NCO project at http://nco.sf.net or write to # Charlie Zender # Department of Earth System Science # University of California, Irvine # Irvine, CA 92697-3100 # Prerequisites: Bash, NCO # Script could use other shells, e.g., dash (Debian default) after rewriting function definitions and loops # Debug with 'bash -x ncclimo --dbg=dbg_lvl' where 0 <= dbg_lvl <= 5 # Source: https://github.com/nco/nco/tree/master/data/ncclimo # Documentation: http://nco.sf.net/nco.html#ncclimo # Additional Documentation: # ncclimo HowTo: https://e3sm.atlassian.net/wiki/spaces/DOC/pages/31129737/Generate+Regrid+and+Split+Climatologies+climo+files+with+ncclimo # E3SM Climatology Requirements: https://acme-climate.atlassian.net/wiki/display/ATM/Climo+Files+-+v0.3+AMIP+runs # Insta-install: # scp ~/nco/data/ncclimo andes.olcf.ornl.gov:bin_andes # scp ~/nco/data/ncclimo ac.zender@bebop.lcrc.anl.gov:bin # scp ~/nco/data/ncclimo ac.zender@chrysalis.lcrc.anl.gov:bin_chrysalis # scp ~/nco/data/ncclimo compy.pnl.gov:bin # scp ~/nco/data/ncclimo derecho.hpc.ucar.edu:bin # scp ~/nco/data/ncclimo dust.ess.uci.edu:bin # scp ~/nco/data/ncclimo e3sm.ess.uci.edu:bin # scp ~/nco/data/ncclimo imua.ess.uci.edu:bin # scp ~/nco/data/ncclimo perlmutter-p1.nersc.gov:bin_perlmutter # scp ~/nco/data/ncclimo spectral.ess.uci.edu:bin # scp dust.ess.uci.edu:bin/ncclimo ~/bin # scp dust.ess.uci.edu:bin/ncclimo ${MY_BIN_DIR} # scp zender@dust.ess.uci.edu:bin/ncclimo ${MY_BIN_DIR} # Set script name, directory, PID, run directory drc_pwd=${PWD} # Security: Explicitly unset IFS before wordsplitting, so Bash uses default IFS= unset IFS # Set these before 'module' command which can overwrite ${BASH_SOURCE[0]} # NB: dash supports $0 syntax, not ${BASH_SOURCE[0]} syntax # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in spt_src="${BASH_SOURCE[0]}" [[ -z "${spt_src}" ]] && spt_src="${0}" # Use ${0} when BASH_SOURCE is unavailable (e.g., dash) while [ -h "${spt_src}" ]; do # Recursively resolve ${spt_src} until file is no longer a symlink drc_spt="$( cd -P "$( dirname "${spt_src}" )" && pwd )" spt_src="$(readlink "${spt_src}")" [[ ${spt_src} != /* ]] && spt_src="${drc_spt}/${spt_src}" # If ${spt_src} was relative symlink, resolve it relative to path where symlink file was located done cmd_ln="${spt_src} ${@}" drc_spt="$( cd -P "$( dirname "${spt_src}" )" && pwd )" spt_nm=$(basename ${spt_src}) # [sng] Script name (unlike $0, ${BASH_SOURCE[0]} works well with 'source