#!/bin/bash # Purpose: Split CESM'ish and ACME'ish raw history tape files into (possibly regridded) single variable timeseries # Copyright (C) 2015-2016 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 # GNU General Public License (GPL) Version 3. # As a special exception to the terms of the GPL, you are permitted # to link the NCO source code with the HDF, netCDF, OPeNDAP, and UDUnits # libraries and to distribute the resulting executables under the terms # of the GPL, 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 GNU General Public 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 definition and looping constructs # Source: https://github.com/nco/nco/tree/master/data/ncsplit # Documentation: http://nco.sf.net/nco.html#ncsplit # Additional Documentation: # HowTo: https://acme-climate.atlassian.net/wiki/display/ATM/Generating+Climo+files # ACME Timeseries Requirements: https://acme-climate.atlassian.net/wiki/display/ATM/Climo+Files+-+v0.3+AMIP+runs # Direct install: # scp ~/nco/data/ncsplit aims4.llnl.gov:bin # scp ~/nco/data/ncsplit cooley.alcf.anl.gov:bin # scp ~/nco/data/ncsplit cori.nersc.gov:bin_cori # scp ~/nco/data/ncsplit edison.nersc.gov:bin_edison # scp ~/nco/data/ncsplit rhea.ccs.ornl.gov:bin_rhea # scp ~/nco/data/ncsplit yellowstone.ucar.edu:bin # scp dust.ess.uci.edu:nco/data/ncsplit ~/bin # Set script name, directory, PID, run directory drc_pwd=${PWD} # 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 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