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

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Tue Oct 9 19:17:46 CDT 2012


Author: wilde
Date: 2012-10-09 19:17:46 -0500 (Tue, 09 Oct 2012)
New Revision: 5956

Added:
   SwiftApps/ParVis/HiRAMTools/do_pfrepp.sh
   SwiftApps/ParVis/HiRAMTools/genpfrepps.sh
   SwiftApps/ParVis/HiRAMTools/pfrepp.csh
   SwiftApps/ParVis/HiRAMTools/pfrepp_template.csh
   SwiftApps/ParVis/HiRAMTools/pfrepps.swift
   SwiftApps/ParVis/HiRAMTools/runpfrepps.sh
Log:
Initial pfrepp scripts.

Added: SwiftApps/ParVis/HiRAMTools/do_pfrepp.sh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/do_pfrepp.sh	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/do_pfrepp.sh	2012-10-10 00:17:46 UTC (rev 5956)
@@ -0,0 +1,9 @@
+tcsh /home/wilde//LZ/HiRAMTools/pfrepp.csh  \
+    -a /intrepid-fs0/users/lzamboni/persistent/yearly-nco/en1eo12Ic3/run001/run001/ \
+    -b /home/wilde/LZ/pfout \
+    -s 1950 \
+    -i /intrepid-fs0/users/lzamboni/persistent/bin/fms/pfrepp/remap_file/C90_to_180x90/C90_mosaic.nc \
+    -x 180 -y 90  \
+    -r /intrepid-fs0/users/lzamboni/persistent/bin/fms/pfrepp/remap_file/C90_to_180x90/C90_to_180x90.nc \
+    -m 12 -n 50 -q \
+    -u
\ No newline at end of file


Property changes on: SwiftApps/ParVis/HiRAMTools/do_pfrepp.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftApps/ParVis/HiRAMTools/genpfrepps.sh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/genpfrepps.sh	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/genpfrepps.sh	2012-10-10 00:17:46 UTC (rev 5956)
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+realid=$1
+realdir=$2
+outdir=$3
+scriptlist=$PWD/$4
+
+mkdir -p $outdir/$realid/scripts
+cd       $outdir/$realid/scripts
+
+tcsh /home/wilde/LZ/HiRAMTools/pfrepp.csh  \
+    -a $realdir \
+    -b $outdir/$realid \
+    -s 1950 \
+    -i /intrepid-fs0/users/lzamboni/persistent/bin/fms/pfrepp/remap_file/C90_to_180x90/C90_mosaic.nc \
+    -x 180 -y 90  \
+    -r /intrepid-fs0/users/lzamboni/persistent/bin/fms/pfrepp/remap_file/C90_to_180x90/C90_to_180x90.nc \
+    -m 12 -n 50 -q \
+    -u
+
+echo id path >$scriptlist
+for f in pfrepp_script.*; do
+  id=$(echo $f | sed -e 's/pfrepp_script.//')
+  echo $id $PWD/$f >>$scriptlist
+done
+
+#    -a /intrepid-fs0/users/lzamboni/persistent/yearly-nco/en1eo12Ic3/run001/run001/ \


Property changes on: SwiftApps/ParVis/HiRAMTools/genpfrepps.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftApps/ParVis/HiRAMTools/pfrepp.csh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/pfrepp.csh	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/pfrepp.csh	2012-10-10 00:17:46 UTC (rev 5956)
@@ -0,0 +1,454 @@
+#!/bin/csh 
+
+set echo
+set verbose
+
+set FMSBIN = /home/lzamboni/bin/fms/scripts
+
+#NOTE : Currently this tool will only postprocess atmos data and assume the name
+#       of the files starts with "atmos". 
+
+  set template  = $0:h/pfrepp_template.csh
+  set environ   = INTERACTIVE
+  set remapfile = "none"
+
+#  ----- parse input argument list ------
+  set historydir = ""
+  set ppdir = ""
+  set starttime = ""
+  @ numyears   = 5
+  @ nummonths  = 12
+  set zinterp_atm   = "ncep"
+  set zinterp_ocn   = "none"
+
+  set do_not_run = 0
+  @ ntiles_lnd = 6
+  @ ntiles_atm = 6
+  @ ntiles_ocn = 1
+  set nlon_atm       = 0
+  set nlat_atm       = 0
+  set nlon_ocn       = 0
+  set nlat_ocn       = 0
+  set mosaic_atm = ""
+  set mosaic_ocn = ""
+  set remapfile_atm = "none"
+  set remapfile_ocn = "none"   
+  set remove_tmp = 1
+  set time_average_only = 0
+  set use_bbcp = 0
+
+# currently there is no horizontal interpolation for ocean/ice data.
+#set argv = (`getopt a:s:n:m:t:T:i:I:x:y:r:z:qdh $*`)
+
+set argv = (`getopt a:b:cs:n:m:t:T:i:I:x:X:y:Y:r:R:z:Z:uqdwh $*`)
+
+while ("$argv[1]" != "--")
+    switch ($argv[1])
+        case -a:
+            set historydir = $argv[2]; shift argv; breaksw;
+        case -b:
+            set ppdir = $argv[2]; shift argv; breaksw;
+        case -c:
+            set use_bbcp = 1; breaksw;
+        case -s:
+            set starttime = $argv[2]; shift argv; breaksw;
+        case -n:
+            @ numyears  = $argv[2]; shift argv; breaksw;
+        case -m:
+            @ nummonths  = $argv[2]; shift argv; breaksw;
+        case -t:
+            @ ntiles_atm = $argv[2]; shift argv; breaksw;
+        case -T:
+            @ ntiles_ocn = $argv[2]; shift argv; breaksw;
+        case -i:
+            set mosaic_atm = $argv[2]; shift argv; breaksw;
+        case -I:
+            set mosaic_ocn = $argv[2]; shift argv; breaksw;
+        case -x:
+            set nlon_atm = $argv[2]; shift argv; breaksw;
+        case -y:
+            set nlat_atm = $argv[2]; shift argv; breaksw;
+        case -X:
+            set nlon_ocn = $argv[2]; shift argv; breaksw;
+        case -Y:
+            set nlat_ocn = $argv[2]; shift argv; breaksw;	    
+        case -r:
+            set remapfile_atm = $argv[2]; shift argv; breaksw;
+        case -R:
+            set remapfile_ocn = $argv[2]; shift argv; breaksw;
+        case -z:
+            set zinterp_atm =$argv[2]; shift argv; breaksw;
+        case -Z:
+            set zinterp_ocn =$argv[2]; shift argv; breaksw;
+        case -u:
+            set do_not_run = 1; breaksw;
+        case -q:
+            set environ = BATCH; breaksw;
+        case -d:
+            set remove_tmp = 0; breaksw;
+        case -w:
+            set time_average_only = 1; breaksw;
+        case -h:
+            set help ; breaksw
+    endsw
+    shift argv
+end
+
+#---- print out user guide when -h option is selected.
+if( ! $?help) then
+   if ($historydir == "") then
+      echo "ERROR from pfrepp.csh: historydir is not set through -a"
+      set help
+   endif
+
+   if ($starttime == "") then
+      echo "ERROR from pfrepp.csh: starttime is not set through -s"
+      set help
+   endif
+
+   if($zinterp_atm != "ncep" ) then
+      echo "ERROR from pfrepp.csh: zinterp_atm set through -z should be 'ncep', contact developer"
+      exit 1
+   endif
+
+   # when mosaic_atm is defined, nlon_atm, nlat_atm should be defined.
+   if( $mosaic_atm != "" ) then
+      #first check to make sure mosaic_atm exist
+      if( ! -e $mosaic_atm ) then
+         echo "ERROR from pfrepp.csh: $mosaic_atm does not exist"
+         exit 1
+      endif
+
+      if (${ntiles_atm} != 6 ) then
+         echo "ERROR from pfrepp.csh: ntiles_atm set through -t should be 6 when mosaic_atm is set, contact developer"
+         exit 1
+      endif
+
+      if ($nlon_atm == 0) then
+         echo "ERROR from pfrepp.csh: nlon_atm is not set through -x"
+         set help
+      endif
+
+      if ($nlat_atm == 0) then
+         echo "ERROR from pfrepp.csh: nlat_atm is not set through -y"
+         set help
+      endif
+   else
+      if ( $ntiles_atm != 1 ) then
+         echo "Error from pfrepp.csh: ntiles_atmos should be 1 when mosaic_atm is not set"
+         exit 1
+      endif
+
+      if ($nlon_atm != 0) then
+         echo "NOTE from pfrepp.csh: there will be no horizontal interpolation when input grid is lat-lon, nlon_atm need not to be set"
+         @ nlon_atm = 0
+      endif
+	 
+      if ($nlat_atm != 0) then
+         echo "NOTE from pfrepp.csh: there will be no horizontal interpolation when input grid is lat-lon, nlat_atm need not to be set"
+         @ nlat_atm = 0
+      endif
+
+   endif
+
+   # currently there will be no horizontal and vertical interpolation for ocean/ice data.
+   if( $ntiles_ocn != 1 ) then
+      echo "Error from pfrepp.csh: ntiles_ocn should be 1"
+      exit 1
+   endif
+
+   if( $mosaic_ocn != "" ) then
+      echo "NOTE from pfrepp.csh: there will be no horizontal interpolation for ocean/ice data, mosaic_ocn need not to be set"
+      set mosaic_ocn = ""
+   endif
+
+   if ($nlon_ocn != 0) then
+      echo "NOTE from pfrepp.csh: there will be no horizontal interpolation for ocean/ice data, nlon_ocn need not to be set"
+      @ nlon_ocn = 0
+   endif
+
+   if ($nlat_ocn != 0) then
+      echo "NOTE from pfrepp.csh: there will be no horizontal interpolation for ocean/ice data, nlat_ocn need not to be set"
+      @ nlat_ocn = 0
+   endif
+
+   if ( $remapfile_ocn != "none" ) then
+      echo "NOTE from pfrepp.csh: there will be no horizontal interpolation for ocean/ice data, remapfile_ocn need not to be set"
+      set remapfile_ocn = "none"
+   endif
+
+   if ($zinterp_ocn != "none") then
+      echo "NOTE from pfrepp.csh: there will be no vertical interpolation for ocean/ice data, zinterp_ocn need not to be set"
+      set  zinterp_ocn = "none"
+   endif
+
+   set len = `echo ${starttime} | awk '{print length($0)}'`
+
+   if( $numyears == 0 ) then
+      if( $len == 4 ) then
+         set starttime = ${starttime}0101
+      endif
+   else
+      if( $len != 4 ) then
+          echo "ERROR from pfrepp.csh: starttime must be in the format 'yyyy' when numyears is not zero"
+          exit 1
+      endif
+   endif
+endif
+
+if ($?help) then
+cat<<EOF
+
+  USAGE:  ./pfrepp.csh -a historydir -s starttime [-b ppdir] [-n numyears] [-m nummonths]
+           [-i mosaic_atm] [-x nlon_atm] [-y nlat_atm] [-t ntiles_atm] [-r remapfile_atm]
+	   [-I mosaic_ocn] [-X nlon_ocn] [-Y nlat_ocn] [-T ntiles_ocn] [-R remapfile_atm]
+           [-q] [-u] [-w] [-h] 
+
+  Required arguments:
+
+          -a historydir    : source directory of the files to be combined
+          
+          -s starttime     : starting time to be processed. starttime could be in the
+                             format yyyymmdd or yyyy ( the date will be assumed as yyyy0101).
+                             starttime must be in the format yyyy when you want to do time
+                             averaging.
+			   
+  Optional arguments:
+			   
+          -b ppdir         : directory to store post-processing data. The default will be historydir:h/pp
+
+          -n numyears      : number of years data to be processed. 
+                             The default value is 5 and time averaging will be performed only
+                             when numyears is greater than 0. When numyears = 0, the starttime could be in the 
+                             format yyyymmdd or yyyy ( the date will be assumed as yyyy0101). 
+                             When starttime is in the format yyyymmdd, numyears will be assumed to 
+                             be 0. 
+
+          -m nummonths     : number of months of output data in each history files. Its
+                             value must be divided by 12. Default value is 1.
+			   
+          -i mosaic_atm    : atmos mosaic grid file for atmos input data: historydir/date
+
+          -x nlon_atm      : number of longitude grid cells of the uniform lat-lon atmos output grid 
+
+          -y nlat_atm      : number of latitude grid cells of the uniform lat-lon atmos output grid 
+
+          -t ntiles_atm    : number of tiles in the atmos input data. The default is 6.
+	                     Its value could be 1 or 6.
+                                    
+          -r remapfile_atm : contains remap information to regrid atmos data from input cubic sphere grid 
+                             to lat-lon grid. It is strongly recommended to use the option to 
+                             improve performance. 
+
+          -I mosaic_ocn    : ocean mosaic grid file for ocean input data: historydir/date
+
+          -X nlon_ocn      : number of longitude grid cells of the uniform lat-lon ocean output grid 
+
+          -Y nlat_ocn      : number of latitude grid cells of the uniform lat-lon ocean output grid 
+
+          -T ntiles_ocn    : number of tiles in the ocean input data. The default is 6.
+	                     Its value could be 1 or 6.
+                                    
+          -R remapfile_ocn : contains remap information to regrid ocean data from input tripolar grid 
+                             to lat-lon grid. It is strongly recommended to use the option to 
+                             improve performance. 
+
+          -u               : When set, all the runscripts will be generated but will not be executed.
+	  
+          -q               : execute in BATCH mode; INTERACTIVE mode is default
+
+          -d               : do not remove the tmpdir when -d is set. Default will remove the tmpdir.
+
+          -w               : When set, will only process time averaging ( no time series ).
+
+          -h               : print out help message
+
+    Example (remap data from C720 onto 1/4 degree lat-lon grid):
+
+      pfrepp.csh -a /project/k14/zliang/bin/scripts/pfrepp/test -s 1980 
+                 -i /project/k14/zliang/bin/scripts/pfrepp/test/grid/C48_mosaic.nc
+                 -x 144 -y 90 -r /project/k14/zliang/bin/scripts/pfrepp/test/grid/C48_to_144x90.nc
+
+      Frequently used remap files are maintained in the standard location: /home/project/k14/ckerr/bin/fms/remap_files
+EOF
+exit 1
+endif
+
+ if( $ppdir == "" ) then
+    set ppdir = $historydir:h/pp
+ endif
+
+  echo "ENVIRONMENT IS:     $environ"
+
+setenv architecture `uname -m`
+
+if  ( $architecture == "x86_64" ) then
+  set FREGRID =  $FMSBIN/fregrid/fregrid.csh
+  set NCCOMBINE = $FMSBIN/combine/combine.csh
+  set TIMEAVG = $FMSBIN/time_average/time_average.csh
+  set PLEVEL = $FMSBIN/plevel/plevel.csh
+  set MERGE  = $FMSBIN/merge/merge.csh
+else
+  echo "ERROR: pfrepp.csh is only supported on x86_64"
+  exit 1
+endif
+
+# Submit a post-processing job for each atmosphere data.
+# for monthly data, need to do both time averging and
+# time series when numyears is non-zero.
+
+#foreach component ( "atmos" "land" "ocean" "ice" )
+foreach component ( "atmos" "ice" )
+   if( $component == "atmos" ) then
+      set inputmosaic = ${mosaic_atm}
+      set nlon = ${nlon_atm}
+      set nlat = ${nlat_atm}
+      set remapfile = ${remapfile_atm}
+      set ntiles = ${ntiles_atm}
+      set zinterp = ${zinterp_atm}
+      set interp_method = "conserve_order2"
+   else if( $component == "land" ) then
+      set inputmosaic = ${mosaic_atm}
+      set nlon = ${nlon_atm}
+      set nlat = ${nlat_atm}
+      set remapfile = ${remapfile_atm}
+      set ntiles = ${ntiles_atm}
+      set zinterp = "none"
+      set interp_method = "conserve_order1"
+   else # ocean or ice
+      set inputmosaic = ${mosaic_ocn}
+      set nlon = ${nlon_ocn}
+      set nlat = ${nlat_ocn}
+      set remapfile = ${remapfile_ocn}
+      set ntiles = ${ntiles_ocn}
+      set zinterp = ${zinterp_ocn}
+      set interp_method = "none"
+   endif
+
+   if( $numyears == 0 ) then
+      set datedir = $historydir/$starttime
+   else
+      set datedir = $historydir/${starttime}0101
+   endif
+   if( ! -d $datedir ) then
+      echo "pfrepp: $datedir does not exist" 
+      exit 1 
+   endif
+
+   set curdir = $cwd
+echo $0 curdir: $curdir
+   cd $datedir
+   
+   if( $ntiles == 1 ) then
+      set filelist = (`ls -1 ${component}*.nc`)
+   else
+      set filelist = (`ls -1 ${component}*.tile1.nc`)
+   endif
+
+   if( $#filelist == 0 ) then
+      continue 
+   endif
+
+   cd $curdir
+
+   foreach file ( $filelist )
+      set filename = `echo $file | sed 's/\./ /g' | awk '{printf $1}'`
+      set name = `echo $filename | sed 's/_/ /' | awk '{printf $2}'`
+      if( ${time_average_only} == 0 ) then
+         set mode = "time_series"
+
+         if( $numyears == 0 ) then
+            set yearname = $starttime
+         else
+            set yearname = `echo $starttime | awk '{printf("%04s", $1)}'`
+         endif
+         set runscript = pfrepp_script.$filename.$mode.$yearname
+         echo "\
+            s|AAAAAAA|${historydir}|g\
+            s|BBBBBBB|${yearname}|g \
+            s|CCCCCCC|${inputmosaic}|g \
+            s|DDDDDDD|${nlon}|g \
+            s|EEEEEEE|${nlat}|g \
+            s|FFFFFFF|${remapfile}|g \
+            s|GGGGGGG|${numyears}|g \
+            s|HHHHHHH|${ntiles}|g \
+            s|IIIIIII|${component}|g \
+            s|JJJJJJJ|${FREGRID}|g \
+            s|LLLLLLL|${NCCOMBINE}|g \
+            s|MMMMMMM|${TIMEAVG}|g \
+            s|NNNNNNN|${PLEVEL}|g \
+            s|OOOOOOO|${zinterp}|g \
+            s|PPPPPPP|${remove_tmp}|g\
+            s|QQQQQQQ|${MERGE}|g\
+            s|RRRRRRR|${nummonths}|g\
+            s|SSSSSSS|${filename}|g \
+            s|TTTTTTT|${mode}|g \
+            s|VVVVVVV|${use_bbcp}|g \
+            s|WWWWWWW|${interp_method}|g \
+            s|UUUUUUU|${ppdir}|g"  \
+         > sed_file
+         cat $template | sed -f sed_file > $runscript
+         rm sed_file
+         chmod +x $runscript
+
+         if( $do_not_run == 1 ) then
+            echo "pfrepp.csh: -u is set, will not execute ./$runscript"
+         else if ( $environ == "BATCH" ) then
+            echo " submitting  $runscript"
+       #       qsub -A prec_sense -n 1 -t 480 -M lzamboni at mcs.anl.gov ./$runscript 
+       #      qsub -A SU_Climate -n 1 -t 480 -M lzamboni at mcs.anl.gov ./$runscript
+             qsub -A MTCScienceApps -n 1 -t 480 -M lzamboni at mcs.anl.gov ./$runscript
+       #      qsub -q R.climate -A SU_Climate -n 1 -t 300 -M lzamboni at mcs.anl.gov ./$runscript 
+            else
+            echo " running $runscript interactively "
+            ./$runscript
+         endif
+      endif
+
+      #when name is month and numyears is greater than 0, need to do time average.
+      if( $numyears > 0 && $name == "month" ) then
+
+         set mode = "time_average"
+         set runscript = pfrepp_script.$filename.$mode.$starttime
+         echo "\
+            s|AAAAAAA|${historydir}|g\
+            s|BBBBBBB|${starttime}|g \
+            s|CCCCCCC|${inputmosaic}|g \
+            s|DDDDDDD|${nlon}|g \
+            s|EEEEEEE|${nlat}|g \
+            s|FFFFFFF|${remapfile}|g \
+            s|GGGGGGG|${numyears}|g \
+            s|HHHHHHH|${ntiles}|g \
+            s|IIIIIII|${component}|g \
+            s|JJJJJJJ|${FREGRID}|g \
+            s|LLLLLLL|${NCCOMBINE}|g \
+            s|MMMMMMM|${TIMEAVG}|g \
+            s|NNNNNNN|${PLEVEL}|g \
+            s|OOOOOOO|${zinterp}|g \
+            s|PPPPPPP|${remove_tmp}|g\
+            s|QQQQQQQ|${MERGE}|g\
+            s|RRRRRRR|${nummonths}|g\
+            s|SSSSSSS|${filename}|g \
+            s|TTTTTTT|${mode}|g \
+            s|VVVVVVV|${use_bbcp}|g \
+            s|WWWWWWW|${interp_method}|g \
+            s|UUUUUUU|${ppdir}|g" \
+         > sed_file
+         cat $template | sed -f sed_file > $runscript
+         rm sed_file
+         chmod +x $runscript
+         if( $do_not_run == 1 ) then
+            echo "pfrepp.csh: -u is set, will not execute ./$runscript"
+         else if ( $environ == "BATCH" ) then
+            echo " submitting  $runscript"
+            qsub -A SU_Climate -n 1 -t 480 ./$runscript
+         else
+            echo " running $runscript interactively "
+            ./$runscript
+         endif
+      endif
+  
+   end   
+end
+
+exit 0


Property changes on: SwiftApps/ParVis/HiRAMTools/pfrepp.csh
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftApps/ParVis/HiRAMTools/pfrepp_template.csh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/pfrepp_template.csh	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/pfrepp_template.csh	2012-10-10 00:17:46 UTC (rev 5956)
@@ -0,0 +1,482 @@
+#!/bin/csh 
+
+### Using modified  template!
+
+set FMS = /home/lzamboni
+set FMS = $HOME
+
+# source $FMS/bin/fms/sys/environ.cshrc - expanded below and modified:
+
+# set up netcdf-4.1.2.beta2 and nco-3.9.2
+
+unlimit stacksize
+
+# setenv PATH /soft/apps/cdo-1.4.7/bin:/soft/apps/nco-4.0.9/bin:/soft/apps/netcdf-4.1.2-beta2/bin:$PATH
+# nco-3.9.2 for pfrepp
+
+setenv PATH /soft/apps/nco-3.9.2/bin:/soft/apps/netcdf-4.1.2-beta2/bin:$PATH
+
+setenv LIBRARY_PATH /soft/apps/netcdf-4.1.2-beta2/lib:/soft/apps/intel-fc-11.0.074/lib/intel64:/soft/apps/intel-cc-11.0.074/lib/intel64:/usr/lib:/usr/X11R6/lib:/usr/local/lib
+setenv LD_LIBRARY_PATH $LIBRARY_PATH
+setenv CPATH /soft/apps/netcdf-4.1.2-beta2/include
+setenv FPATH /soft/apps/netcdf-4.1.2-beta2/include
+
+# end of modified environ.cshrc 
+
+set GCP = /bin/cp
+
+set init_clock = `date +%s`
+
+set history_dir = AAAAAAA
+set starttime   = BBBBBBB
+set inputmosaic = CCCCCCC
+set nlon        = DDDDDDD
+set nlat        = EEEEEEE
+set remapfile   = FFFFFFF
+set numyears    = GGGGGGG
+set numtiles    = HHHHHHH
+set component   = IIIIIII
+set FREGRID     = JJJJJJJ 
+set nccombine   = LLLLLLL
+set TIMEAVG     = MMMMMMM
+set PLEV        = NNNNNNN
+set zinterp     = OOOOOOO
+set removetmp   = PPPPPPP
+set MERGE       = QQQQQQQ
+set nummonths   = RRRRRRR
+set filename    = SSSSSSS
+set mode        = TTTTTTT
+set root_ppdir  = UUUUUUU
+set use_bbcp    = VVVVVVV
+set interp_method = WWWWWWW
+set MONTH_IN_A_YEAR = 12
+
+#set scratch = /scratch/$USER
+#set scratch = /intrepid-fs1/users/$USER/scratch
+set scratch = /intrepid-fs0/users/$USER/scratch
+
+mkdir -p $scratch
+
+#tmpdir could be changed depending on system
+#set tmpdir = /intrepid-fs0/users/$USER/scratch/pfrepp
+ set tmpdir = `mktemp -d $scratch/pfrepp.XXXXXX`
+
+echo pfrepp: running in tmpdir $tmpdir
+
+# print out all the arguments
+echo "*****     NOTE from pfrepp.csh: Below are the list of arguments     ******"
+echo "**************************************************************************"
+echo ""
+echo "history_dir = $history_dir"
+echo "starttime   = $starttime"
+echo "inputmosaic = $inputmosaic"
+echo "nlon        = $nlon"
+echo "nlat        = $nlat"
+echo "remapfile   = $remapfile"
+echo "numyears    = $numyears"
+echo "numtiles    = $numtiles"
+echo "component   = $component"
+echo "FREGRID     = $FREGRID"
+echo "nccombine   = $nccombine"
+echo "TIMEAVG     = $TIMEAVG"
+echo "PLEV        = $PLEV"
+echo "zinterp     = $zinterp"
+echo "removetmp   = $removetmp"
+echo "MERGE       = $MERGE"
+echo "nummonths   = $nummonths"
+echo "filename    = $filename"
+echo "mode        = $mode"
+echo "use_bbcp    = $use_bbcp"
+echo ""
+echo "**************************************************************************"
+
+set yearname = `echo $starttime | awk '{printf("%04s", $1)}'`
+set begindate = ${starttime}0101
+set begindate_dir = $history_dir/$begindate
+set workdir = $tmpdir/tmp.$component.$filename.$mode.$yearname
+set mydir = $cwd
+
+if( $mode != "time_series" && $mode != "time_average" ) then
+   echo "Error from pfrepp_template.csh: mode should be time_series or time_arerage"
+endif
+
+# when inputmosaic is none, there will be no horizontal interpolation.
+set do_horiz_interp = 1
+if( $inputmosaic == "" ) set do_horiz_interp = 0
+# when zinterp is "none", there will be no vertical interpolation.
+set do_vert_interp = 1
+if( $zinterp == "none" ) set do_vert_interp = 0
+#make sure workdir does not exist
+if( -e $workdir ) then
+   echo "pfrepp: $workdir already exist, please remove this directory before running pfrepp"
+   exit 1
+endif
+mkdir -p $workdir
+if( $status != 0 ) then
+   echo "Failed at make directory $workdir"
+   exit 1
+endif
+cd $workdir
+
+   #first copy the data to workdir
+if($numyears != 0) then
+   @ year = $starttime
+   @ end_year = $starttime + $numyears - 1
+   @ runningtime_cp = 0
+   while ( $year <= $end_year )
+      set yearname = `echo $year | awk '{printf("%04s", $1)}'`
+
+      @ month = 1
+      while ( $month <= ${MONTH_IN_A_YEAR} )
+         set monthname = `echo $month | awk '{printf("%02s", $1)}'`
+         set datename = ${yearname}${monthname}01
+         set datedir = $history_dir/${datename}
+         cd $datedir
+
+         set filelist = (`ls -1 ${filename}.*nc`)
+         cd $workdir
+         foreach file ( $filelist)
+            set clock1 = `date +%s`
+            if( $use_bbcp == 1 ) then
+               $GCP $datedir/$file ${datename}.$file
+            else
+              ln -s $datedir/$file ${datename}.$file
+            endif
+            set clock2 = `date +%s`
+            @ runningtime_cp = ${runningtime_cp} + $clock2 - $clock1
+            if( $status != 0 ) then
+               echo "Failed at cp $datedir/$file ${datename}.$file"
+               exit 1
+            endif
+         end
+         @ month = $month + $nummonths
+      end
+      @ year = $year + 1
+   end
+   echo "pfrepp: the running time for cp timeseries is ${runningtime_cp} seconds"
+endif
+
+set name = `echo $filename | sed 's/_/ /' | awk '{printf $2}'`
+
+if($numyears == 0) then
+   set datedir = $history_dir/$starttime
+   if( ! -e $datedir ) then
+      #nccombine must be executed before pfrepp is executed.
+      echo "directory $history_dir/$starttime does not exist, which means the data is combined"
+      exit 1
+   endif
+   cd $datedir
+   set filelist = (`ls -1 ${filename}.*nc`)   
+   cd $workdir
+   foreach file ( $filelist )
+      if( $use_bbcp == 1 ) then
+         $GCP $datedir/$file ${starttime}.$file
+      else
+         ln -s $datedir/$file ${starttime}.$file
+      endif
+      if( $status != 0 ) then
+         echo "Failed at cp $datedir/$file ${starttime}.$file"
+         exit 1
+      endif
+   end
+   #timeseries
+   set ppdir = $root_ppdir/${component}/ts/$name
+   if( ! -e $ppdir ) mkdir -p $ppdir
+   if( $do_vert_interp == 0 ) then
+      set output_file = ${starttime}.$filename
+   else
+      set output_file = ${component}.${starttime}
+      set clock1 = `date +%s`
+      $PLEV -a -i ${starttime}.$filename -o ${output_file} -n $numtiles
+      if( $status != 0 ) then
+        echo "Failed at running $PLEV -a -i ${starttime}.$filename -o ${output_file}  -n $numtiles"
+        exit 1
+      endif
+      set clock2 = `date +%s`
+      @ runningtime = $clock2 - $clock1
+      echo "pfrepp: the running time for PLEV is $runningtime seconds"
+   endif
+
+   if( $do_horiz_interp == 0 ) then
+      set fregrid_out = ${output_file}.nc
+   else
+      set fregrid_out = $filename.${starttime}.nc
+      set clock1 = `date +%s`
+      $FREGRID -a ${output_file} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}
+      if( $status != 0 ) then
+         echo "Failed at running $FREGRID -a plev.$filename.${starttime} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}"
+         exit 1
+      endif
+      set clock2 = `date +%s`
+      @ runningtime = $clock2 - $clock1
+      echo "pfrepp: the running time for fregrid is $runningtime seconds"  
+   endif
+   # mv $fregrid_out $ppdir/${component}.${starttime}.nc
+   foreach i(1 2 3 4 5 6 7 8 9 0)
+     dd if=$fregrid_out of=$ppdir/${component}.${starttime}.nc bs=4M
+     if ( $status == 0 ) then
+        break
+     endif
+   end
+
+else if( $mode == "time_average" ) then # numyears > 0, time average
+   @ endtime = $starttime + $numyears - 1
+   set start_year = `echo $starttime | awk '{printf("%04s", $1)}'`
+   set end_year =  `echo $endtime | awk '{printf("%04s", $1)}'`
+
+   #merge the files
+   set clock1 = `date +%s`
+   $MERGE -s $start_year -n $numyears -m $nummonths -c $filename -t $numtiles
+   if( $status != 0 ) then
+      echo "Failed at running $MERGE -a $history_dir -s $start_year -n $numyears -m $nummonths -c $filename -t $numtiles"
+      exit 1
+   endif
+   set clock2 = `date +%s`
+   @ runningtime = $clock2 - $clock1
+   echo "pfrepp: the running time for merge is $runningtime seconds"      
+
+   # timeAverage (monthly  averages)
+   set clock1 = `date +%s`
+   $TIMEAVG -s $starttime -f monthly -c $component -t $numtiles -n $numyears # the output will be in the format $starttime-$endtime.${component}.$month.tile#.nc.
+
+   if( $status != 0 ) then
+      echo "Failed at running $TIMEAVG -s $starttime -f monthly -c $component -t $numtiles -n $numyears"
+      exit 1
+   endif
+
+   set clock2 = `date +%s`
+   @ runningtime = $clock2 - $clock1
+   echo "pfrepp: the running time for timeAverage monthly_${numyears}yr is $runningtime seconds"
+
+   set ppdir = $root_ppdir/$component/av/monthly_${numyears}yr/
+   if( ! -e $ppdir ) mkdir -p $ppdir
+   #loop through 12 months
+   @ month = 0
+   @ runningtime_plev = 0
+   @ runningtime_fregrid = 0
+   while ( $month < $MONTH_IN_A_YEAR )
+      @ month = $month + 1
+      set monthname = `echo $month | awk '{printf("%02s", $1)}'`
+      if( $do_vert_interp == 0 ) then
+         set output_file = $start_year-$end_year.${component}.$monthname
+      else
+      	 set output_file = plev.${component}.$monthname
+         set clock1 = `date +%s`
+         $PLEV -a -i $start_year-$end_year.${component}.$monthname -o ${output_file}  -n $numtiles
+         if( $status != 0 ) then
+            echo "Failed at running $PLEV -a -i $start_year-$end_year.${component}.$monthname -o ${output_file} -n $numtiles"
+            exit 1
+         endif
+         set clock2 = `date +%s`
+         @ runningtime_plev = ${runningtime_plev} + $clock2 - $clock1
+      endif
+
+      if( $do_horiz_interp == 0 ) then
+         set fregrid_out = ${output_file}.nc
+      else
+         set fregrid_out = ${component}.$start_year-$end_year.$monthname.nc
+         set clock1 = `date +%s`
+         $FREGRID -a ${output_file} -b $fregrid_out  -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}
+         if( $status != 0 ) then
+            echo "Failed at running $FREGRID -a ${output_file} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}"
+            exit 1
+         endif
+         set clock2 = `date +%s`
+         @ runningtime_fregrid = ${runningtime_fregrid} + $clock2 - $clock1
+      endif
+      
+      #move data to pp directory.
+#     mv ${fregrid_out} $ppdir/${component}.$start_year-$end_year.$monthname.nc
+      foreach i(1 2 3 4 5 6 7 8 9 0)
+        dd if=${fregrid_out} of=$ppdir/${component}.$start_year-$end_year.$monthname.nc bs=4M
+        if ( $status == 0 ) then
+          break
+        endif
+      end
+   end
+
+   echo "pfrepp: the running time for plev monthly_${numyears}yr is ${runningtime_plev} seconds"
+   echo "pfrepp: the running time for fregrid monthly_${numyears}yr is ${runningtime_fregrid} seconds"
+
+   # timeAverage (annual averages)
+   # first check if the nanual average file exist or not.
+   set clock1 = `date +%s`
+
+   set ppdir = $root_ppdir/${component}/av/annual_1year
+   if( ! -e $ppdir ) mkdir -p $ppdir
+   @ year = $start_year - 1
+   set annual_exist = 0
+   while ( $year < $end_year )
+      @ year = $year + 1
+      set yearname = `echo $year | awk '{printf("%04s", $1)}'`
+      set output_file = $ppdir/${component}.$yearname.ann.nc
+      if( ${annual_exist} == 0 ) then
+         if( -f $output_file ) then
+            set annual_exist = 1
+         endif
+      else
+         if( ! -f $output_file ) then
+            echo "ERROR from pfrepp.csh: $output_file does not exist"
+            exit 1
+         endif
+      endif
+   end
+
+   if( $annual_exist == 1 ) then
+      echo "NOTE from pfrepp.csh: annual_1year already created"
+   else
+      set clock1 = `date +%s`
+      $TIMEAVG -s $starttime -f annual_1year -c ${component} -t $numtiles -n $numyears # the output will be in the format $starttime-$endtime.${component}.$month.tile#.nc   
+      if( $status != 0 ) then
+         echo "Failed at running $TIMEAVG -s $starttime -f annual -c ${component} -t $numtiles -n $numyears"
+         exit 1
+      endif
+      set clock2 = `date +%s`
+      @ runningtime = $clock2 - $clock1
+      echo "pfrepp: the running time for timeAverage annual is $runningtime seconds"
+   
+      @ year = $start_year - 1
+      @ runningtime_plev = 0
+      @ runningtime_fregrid = 0
+   
+      while ( $year < $end_year )
+         @ year = $year + 1
+         set yearname = `echo $year | awk '{printf("%04s", $1)}'`
+         if( $do_vert_interp == 0 ) then
+            set output_file = $yearname.${component}
+         else
+            set output_file =  plev.${component}.$yearname
+            set clock1 = `date +%s`
+            $PLEV -a -i $yearname.${component} -o ${output_file} -n $numtiles
+            if( $status != 0 ) then
+               echo "Failed at running $PLEV -a -i $yearname.${component} -o ${output_file} -n $numtiles"
+               exit 1
+            endif
+            set clock2 = `date +%s`
+            @ runningtime_plev = ${runningtime_plev} + $clock2 - $clock1
+         endif
+
+         if( $do_horiz_interp == 0 ) then
+            set fregrid_out = ${output_file}.nc
+         else
+            set fregrid_out = ${component}.$yearname.ann.nc     
+            set clock1 = `date +%s`
+            $FREGRID -a ${output_file} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}
+            if( $status != 0 ) then
+               echo "Failed at running $FREGRID -a ${output_file} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}"
+               exit 1
+            endif
+            set clock2 = `date +%s`
+            @ runningtime_fregrid = ${runningtime_fregrid} + $clock2 - $clock1
+         endif
+      
+         #move data to pp directory.
+#        mv ${fregrid_out} $ppdir/${component}.$yearname.ann.nc
+         foreach i(1 2 3 4 5 6 7 8 9 0)
+           dd if=${fregrid_out} of=$ppdir/${component}.$yearname.ann.nc bs=4M
+           if ( $status == 0 ) then
+             break
+           endif
+         end
+      end
+
+      echo "pfrepp: the running time for plev annual is ${runningtime_plev} seconds"
+      echo "pfrepp: the running time for fregrid annual is ${runningtime_fregrid} seconds"
+   endif
+
+   #timeAverage (annual $numyears averages), only when numyears != 1
+   if( $numyears != 1 ) then
+      set ppdir = $root_ppdir/${component}/av/annual_${numyears}year
+      if( ! -e $ppdir ) mkdir -p $ppdir
+      set clock1 = `date +%s`
+      $TIMEAVG -s $starttime -f annual -i $root_ppdir/${component}/av/annual_1year -c ${component}  -t $numtiles -n ${numyears}
+      if( $status != 0 ) then
+         echo "Failed at running $TIMEAVG -s $starttime -f annual -i $root_ppdir/${component}/av/annual_1year -c ${component}  -t $numtiles -n ${numyears}"
+         exit 1
+      endif
+      set clock2 = `date +%s`
+      @ runningtime = $clock2 - $clock1
+      echo "pfrepp: the running time for timeAverage annual_${numyears}year is $runningtime seconds"
+   
+#     mv ${component}.$start_year-$end_year.ann.nc $ppdir
+      foreach i(1 2 3 4 5 6 7 8 9 0)
+        dd if=${component}.$start_year-$end_year.ann.nc of=$ppdir/$start_year-$end_year.ann.nc bs=4M
+        if ( $status == 0 ) then
+          break
+	endif
+      end
+   endif
+else  # timeseries, numyears > 0 
+   @ runningtime_plev = 0
+   @ runningtime_fregrid = 0
+   set ppdir = $root_ppdir/$component/ts/$name
+   if( ! -e $ppdir ) mkdir -p $ppdir
+
+   @ year = $starttime
+   @ end_year = $starttime + $numyears - 1
+   while ( $year <= $end_year ) 
+      set yearname = `echo $year | awk '{printf("%04s", $1)}'`
+	          
+      @ month = 1
+      while ( $month <= ${MONTH_IN_A_YEAR} )
+         set monthname = `echo $month | awk '{printf("%02s", $1)}'`
+         set datename = ${yearname}${monthname}01
+         set datedir = $history_dir/${datename}
+
+         if( $do_vert_interp == 0 ) then
+            set output_file = ${datename}.$filename
+         else
+            set output_file = ${component}.${datename}
+            set clock1 = `date +%s`
+            $PLEV -a -i ${datename}.$filename -o ${output_file} -n $numtiles
+            if( $status != 0 ) then
+               echo "Failed at running $PLEV -a -i ${datename}.$filename -o ${output_file} -n $numtiles"
+               exit 1
+            endif
+            set clock2 = `date +%s`
+            @ runningtime_plev = ${runningtime_plev} + $clock2 - $clock1   
+         endif
+
+         if( $do_horiz_interp == 0 ) then
+            set fregrid_out = ${output_file}.nc
+         else
+            set fregrid_out = $filename.${datename}.nc
+            set clock1 = `date +%s`
+            $FREGRID -a ${output_file} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}
+            if( $status != 0 ) then
+               echo "Failed at running $FREGRID -a ${output_file} -b $fregrid_out -g $inputmosaic -n $nlon -m $nlat -r $remapfile -p ${interp_method}"
+               exit 1
+            endif
+            set clock2 = `date +%s`
+            @ runningtime_fregrid = ${runningtime_fregrid} + $clock2 - $clock1
+         endif
+#        mv $fregrid_out $ppdir/${component}.${datename}.nc
+         foreach i(1 2 3 4 5 6 7 8 9 0)
+           dd if=$fregrid_out of=$ppdir/${component}.${datename}.nc bs=4M
+	   if ( $status == 0 ) then
+             break
+	   endif
+         end
+         if( $status != 0 ) then
+            echo "Failed at mv $fregrid_out $ppdir/${component}.${datename}.nc"
+            exit 1
+         endif
+
+         @ month = $month + $nummonths
+      end
+      @ year = $year + 1
+   end
+   echo "pfrepp: the running time for plev timeseries  is ${runningtime_plev} seconds"
+   echo "pfrepp: the running time for fregrid timeseries is ${runningtime_fregrid} seconds"
+endif
+
+set end_clock = `date +%s`
+@ runningtime = $end_clock - $init_clock
+echo "pfrepp: the total running time is $runningtime seconds"
+
+if( $removetmp == 1 ) then
+   cd $mydir
+   rm -rf $workdir
+endif
+
+exit 0


Property changes on: SwiftApps/ParVis/HiRAMTools/pfrepp_template.csh
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftApps/ParVis/HiRAMTools/pfrepps.swift
===================================================================
--- SwiftApps/ParVis/HiRAMTools/pfrepps.swift	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/pfrepps.swift	2012-10-10 00:17:46 UTC (rev 5956)
@@ -0,0 +1,41 @@
+type file;
+
+type realization {
+  string path;
+  string id;
+}
+
+type script {
+  string path;
+  string id;
+}
+
+global string outdir = @arg("outdir","/intrepid-fs0/users/wilde/LZ/pfrepps");
+string reallist = @arg("reallist","NO-REALIZATION-LIST-SPECIFIED");
+
+app (file scripts, file std_out, file std_err) genpfrepps (string realid, string realpath)
+{
+  genpfrepps realid realpath outdir @scripts stdout=@std_out stderr=@std_err;
+}
+
+app (file std_out, file std_err) sh (string script)
+{
+  sh "-c" script stdout=@std_out stderr=@std_err;
+}
+
+realization reali[] = readData(reallist);
+
+foreach r,i in reali {
+  tracef("%s %s\n", r.id, r.path);
+  file sofile <single_file_mapper; file=@strcat(outdir,"/",r.id,".gen.out")>;
+  file sefile <single_file_mapper; file=@strcat(outdir,"/",r.id,".gen.err")>;
+  file scriptlist <single_file_mapper; file=@strcat(outdir,"/",r.id,"/scripts/scriptlist")>;
+  (scriptlist,sofile,sefile) = genpfrepps(r.id, r.path);
+  script scripts[] = readData(scriptlist);
+  foreach s in scripts {
+    file ssofile <single_file_mapper; file=@strcat(outdir,"/",r.id,".",s.id,".out")>;
+    file ssefile <single_file_mapper; file=@strcat(outdir,"/",r.id,".",s.id,".err")>;
+    // (ssofile, ssefile) = sh(s.path);
+    tracef("Running script: %s: %s\n", s.id, s.path);
+  }
+}

Added: SwiftApps/ParVis/HiRAMTools/runpfrepps.sh
===================================================================
--- SwiftApps/ParVis/HiRAMTools/runpfrepps.sh	                        (rev 0)
+++ SwiftApps/ParVis/HiRAMTools/runpfrepps.sh	2012-10-10 00:17:46 UTC (rev 5956)
@@ -0,0 +1,79 @@
+#! /bin/bash
+
+reallist=$1                   # full pathname of list of realizations to pfrepp
+outdir=$2                     # full pathname of output dir
+
+# reallist must have format:
+# path id (with this header line)
+
+bindir=$(dirname $0)
+bindir=$(cd $bindir; pwd)
+
+echo bindir=$bindir
+
+# Create new runNNN directory
+
+rundir=$( echo run??? | sed -e 's/^.*run//' | awk '{ printf("run%03d\n", $1+1)}' )
+mkdir $rundir
+
+cat >$rundir/cf <<END
+
+wrapperlog.always.transfer=true
+sitedir.keep=true
+execution.retries=10
+lazy.errors=true
+
+END
+
+cat >$rundir/sites.xml <<END
+
+<config>
+
+   <pool handle="local">
+     <execution provider="local" />
+     <profile namespace="karajan" key="jobThrottle">.01</profile>
+     <profile namespace="karajan" key="initialScore">10000</profile>
+     <filesystem provider="local"/>
+     <workdirectory>$PWD/swiftwork</workdirectory>
+   </pool>
+
+  <pool handle="cobalt">
+    <execution provider="coaster" jobmanager="local:cobalt" url="eureka.alcf.anl.gov" />
+    <filesystem provider="local" />
+    <!-- <profile namespace="globus"key="internalHostname">172.17.3.11</profile> -->
+    <profile namespace="globus"  key="project">SU_Climate</profile>
+    <!-- <profile namespace="globus"  key="project">MTCScienceApps</profile> -->
+    <profile namespace="globus"  key="queue">default</profile>
+    <profile namespace="karajan" key="jobthrottle">2.56</profile>
+    <profile namespace="karajan" key="initialScore">10000</profile>
+    <profile namespace="globus"  key="jobsPerNode">8</profile>
+    <!-- <profile namespace="globus"  key="workerLoggingLevel">DEBUG</profile> -->
+    <!-- <profile namespace="globus"  key="workerLoggingDirectory">/home/jonmon/Workspace/Swift/tests/catsnsleep</profile> -->
+    <profile namespace="globus"  key="slots">32</profile>
+    <profile namespace="globus"  key="maxTime">28800</profile> <!-- 8hrs -->
+    <profile namespace="globus"  key="maxWallTime">00:20:00</profile>
+    <profile namespace="globus"  key="lowoverallocation">100</profile>
+    <profile namespace="globus"  key="highoverallocation">100</profile>
+    <profile namespace="globus"  key="nodeGranularity">1</profile>
+    <profile namespace="globus"  key="maxNodes">1</profile>
+    <workdirectory>$PWD/$rundir/swiftwork</workdirectory>
+  </pool>
+
+</config>
+
+END
+
+cat >$rundir/tc <<END
+
+local   genpfrepps  $bindir/genpfrepps.sh
+cobalt  sh          /bin/sh
+
+END
+
+cp $1 $bindir/pfrepps.swift $rundir
+
+cd $rundir
+echo Running in directory $rundir
+runid=$(basename $rundir)
+
+swift -config cf -tc.file tc -sites.file sites.xml pfrepps.swift -outdir=$outdir -reallist=$reallist  >& swift.out


Property changes on: SwiftApps/ParVis/HiRAMTools/runpfrepps.sh
___________________________________________________________________
Added: svn:executable
   + *




More information about the Swift-commit mailing list