[Swift-commit] r6031 - SwiftApps/ParVis/HiRAMTools

tmoore at ci.uchicago.edu tmoore at ci.uchicago.edu
Tue Nov 13 15:12:57 CST 2012


Author: tmoore
Date: 2012-11-13 15:12:56 -0600 (Tue, 13 Nov 2012)
New Revision: 6031

Added:
   SwiftApps/ParVis/HiRAMTools/makeyearly_semi.sh
   SwiftApps/ParVis/HiRAMTools/makeyearly_semi.swift
Modified:
   SwiftApps/ParVis/HiRAMTools/makeyearly_realization_semi.sh
Log:
Updated new semi-annual cases for testing

Modified: SwiftApps/ParVis/HiRAMTools/makeyearly_realization_semi.sh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/makeyearly_realization_semi.sh	2012-11-13 20:02:02 UTC (rev 6030)
+++ SwiftApps/ParVis/HiRAMTools/makeyearly_realization_semi.sh	2012-11-13 21:12:56 UTC (rev 6031)
@@ -52,8 +52,8 @@
 
 done >>ncfiles
 
-exit
 
+
 #now we have a list of the 2 year files and the outdir
 
 # Create new runNNN directory
@@ -114,13 +114,13 @@
 
 cat >$rundir/tc <<END
 
-cobalt makeyearly_2yr $bindir/makeyearly_2yr.sh
+cobalt makeyearly_semi $bindir/makeyearly_semi.sh
 
 END
 
 # Place file list and swift script in run dir, set params, make output dir, and run script
 
-cp ncfiles $bindir/makeyearly2yr.swift $rundir
+cp ncfiles $bindir/makeyearly_semi.swift $rundir
 
 cd $rundir
 echo Running in directory $rundir
@@ -128,5 +128,5 @@
 outdir=$outbase/$outsuffix/$runid
 mkdir -p $outdir
 
-swift -config cf -tc.file tc -sites.file sites.xml makeyearly2yr.swift -rundir=$outdir -ncfiles=ncfiles >& swift.out
+swift -config cf -tc.file tc -sites.file sites.xml makeyearly_semi.swift -rundir=$outdir -ncfiles=ncfiles >& swift.out
 

Added: SwiftApps/ParVis/HiRAMTools/makeyearly_semi.sh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/makeyearly_semi.sh	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/makeyearly_semi.sh	2012-11-13 21:12:56 UTC (rev 6031)
@@ -0,0 +1,84 @@
+#! /bin/bash
+
+# Create a fast (local-filesystem) working dir 
+
+if mkdir -p /scratch/wilde; then
+  scratch=/scratch/wilde
+elif mkdir -p $HOME/scratch; then
+  scratch=$HOME/scratch
+else
+  echo $0: cant create scratch dir
+  exit 11
+fi
+
+tmp=$(mktemp -d $scratch/makeyearly_XXXXXX)
+startdir=$PWD
+cd $tmp
+
+echo running in $PWD
+
+qtrdec1=$1  # 1st quarter-decade dir
+qtrdec2=$2  # 2nd quarter-decade dir
+qtrdec3=$3  # 2nd quarter-decade dir
+destbase=$4 # base dir for output years
+
+echo destbase=$destbase qtrdec1=$1 qtrdec2=$2 qtrdec3=$3
+
+# Add cdo and nco tools to PATH and Intel compiler v11 libs to LD_LIBRARY_PATH
+
+#export PATH=/soft/apps/cdo-1.4.7/bin:/soft/apps/nco-4.0.9/bin:$PATH
+export PATH=/soft/apps/nco-4.0.9/bin:$PATH
+export LD_LIBRARY_PATH=/soft/apps/intel-fc-11.0.074/lib/intel64:/soft/apps/intel-cc-11.0.074/lib/intel64:/soft/apps/netcdf-3.6.3/lib:/usr/lib:/usr/X11R6/lib:/usr/local/lib
+
+fname=$(basename $qtrdec1 .nc)
+#file 2 should always be the target year
+firstyear=$(basename $(dirname $qtrdec2) | sed -e 's/....$//')
+
+# process only the time-based files
+
+if echo $fname | egrep -v 'grid_spec|scalar'; then
+
+  # Merge 2 quarter-decade files into one half-decade file
+#for simplicity at this point, keep the script the same
+
+  ncrcat $qtrdec1 $qtrdec2 $qtrdec1 theyears.nc
+
+  # Extract each year from the half-decade file
+
+  ncks -d time,"${firstyear}-01-01 00:00:00","${firstyear}-12-31 23:59:59" theyears.nc  $y.nc
+  
+
+fi  
+
+# Copy the years from temporary to permanent filesystem
+
+
+  destdir=$destbase/${firstyear}0101
+  mkdir -p $destdir
+  if echo $fname | egrep -v 'grid_spec|scalar'; then
+    dd if=$firstyear.nc of=$destdir/$fname.nc bs=8M
+  else
+    dd if=$qtrdec1 of=$destdir/$fname.nc bs=8M
+  fi
+
+
+rm -rf $tmp
+
+# Delete when this works:
+
+  # Old method:
+  #
+  # cdo mergetime $qtrdec1 $qtrdec2 ${fname}.nc
+  # cdo splityear ${fname}.nc ${fname}.
+  # Yields, eg, from atmos_month.tile1:
+  # atmos_month.tile1.1950.nc
+  # atmos_month.tile1.1951.nc
+  # atmos_month.tile1.1952.nc
+  # atmos_month.tile1.1953.nc
+  # atmos_month.tile1.1954.nc
+
+  # New method:
+  #
+  # ncrcat input1.nc input2.nc 5years.nc 
+  # ncks -d time,"$yyyy-01-01 00:00:00","$yyyy-12-31 23:59:59" 5years.nc  year1.nc
+

Added: SwiftApps/ParVis/HiRAMTools/makeyearly_semi.swift
===================================================================
--- SwiftApps/ParVis/HiRAMTools/makeyearly_semi.swift	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/makeyearly_semi.swift	2012-11-13 21:12:56 UTC (rev 6031)
@@ -0,0 +1,24 @@
+
+type file;
+
+type ncrec {
+  string f1;
+  string f2;
+  string f3
+}
+
+string rundir=@arg("rundir","NO-OUTDIR-SPECIFIED");
+string ncfile=@arg("ncfile","ncfiles");
+
+app (file sout, file serr) makeyearly_semi (string dir, string f1, string f2, string f3)
+{
+  makeyearly_semi f1 f2 f3 dir stdout=@sout stderr=@serr;
+}
+
+ncrec nc[] = readData(ncfile);
+
+foreach n,i in nc {
+  file so <single_file_mapper; file=@strcat("stdlog/stdout.",i)>;
+  file se <single_file_mapper; file=@strcat("stdlog/stderr.",i)>;
+  (so,se) = makeyearly_semi(rundir,n.f1,n.f2,,n.f3);
+}




More information about the Swift-commit mailing list