Jed Brown avatar Jed Brown committed 6a4bb4b Merge

Merge bug fix/patch releases up to 3.2-p7 into maint-3.2

* commit 'a9157d915ed96804280c3dc077186a2a633fd603': (157 commits)
Fix PyPI download URL to help pip figure out the release version
#110990 fix timestamp order for .so vs .a during 'make install'
Update FFTW download
Increase patchlevel to 3.2-p7
...

Comments (0)

Files changed (194)

 c59a3fc37afcdecc00f6d8b1a00b096a553e75dd release-2.3.3
 621178841b37ec449714d5f456a6033822dd0c13 release-3.0.0
 f6965e7f147c4902ba70feb4e5da29d07e18085a release-3.1
+cad0859b4453006ec8374bbbf2838e7d14764faf release-3.2

bin/TOPSInstaller.py

              if f > 0: i = i[0:f]
              args.append('--download-'+i+'=1')
 
-        packages = ["Spooles (parallel sparse direct solvers)","  MUMPS","Parmetis (parallel partitioning)","  Chaco","  Jostle","  Party","  PTScotch","Prometheus (parallel preconditioner)","  ml","  SPAI","Matlab"]
+        packages = ["Spooles (parallel sparse direct solvers)","  MUMPS","Parmetis (parallel partitioning)","  Chaco","  Party","  PTScotch","Prometheus (parallel preconditioner)","  ml","  SPAI","Matlab"]
         reply = multchoicebox("Pick the other packages to install.\n\nAgain, only select the packages you truly need.",title, packages)
         for i in reply:
              i = i.lower().replace(' ','')

bin/maint/builddist

 chmod -R a+r petsc$version
 find petsc$version -type d -name "*" -exec chmod a+x {} \;
 
+# fixup canonical redirection of webpages to the proper location
+cd petsc$version
+find * -name \*.html -type f -exec perl -pi -e 's^(<head>)^$1 <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/{}" />^i' {} \;
+
 # Now create the tar files
 cd $tmpdir
 /bin/tar -czf ~/petsc$version.tar.gz petsc$version

bin/maint/package-test.sh

 # missing package tests:
 # party - ?
 # scotch - binary?
-# jostle - binary?
 # cblas/fblas ??
 
 GNUCOMP='CC=gcc FC=gfortran CXX=g++'

bin/maint/rebuildtar

   /bin/ln -s petsc-lite-${VERSION}.tar.gz petsc-lite-${RELEASE}.tar.gz"
 
 # Update download/index.html as well
-ssh petsc@login.mcs.anl.gov chmod u+w /mcs/web/research/projects/petsc/petsc-as/download/index.html
-scp ${PETSC_DIR}/src/docs/website/download/index.html petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/petsc-as/download
+ssh petsc@login.mcs.anl.gov chmod u+w /mcs/web/research/projects/petsc/download/index.html
+scp ${PETSC_DIR}/src/docs/website/download/index.html petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/download
 
 #######################################
 # M bin/maint/createpatch

bin/maint/toclapack.sh

 LAPACKSRC="$2"
 ORIG=$PWD
 MAXPROCS="16"
+TESTING="0"   # 0: don't include second, dsecnd and qsecnd
 
 # 0) Create the temp directory and compile some scripts
 mkdir $TMP
 # Specify options to compile and create libraries
 ########################################################################################
 CC         = cc
-COPTFLAGS  = -O -DDOUBLE=double -DLONG=""
-CNOOPT     = -O0 -DDOUBLE=double -DLONG=""
+COPTFLAGS  = -O
+CNOOPT     = -O0
 RM         = /bin/rm
 AR         = ar
 AR_FLAGS   = cr
 		SRC=$BLASSRC
 		DES=$BLASDIR
 		NOOP=""
+		echo "pow_ii" > ${TMP}/AUX.list
+		echo $'pow_si\nsmaxloc\nsf__cabs' > ${TMP}/SINGLE.list
+		echo $'pow_di\ndmaxloc\ndf__cabs' > ${TMP}/DOUBLE.list
 		cd $SRC
 		files="`ls *.f`"
 		cd -
 		SRC=$TMP
 		DES=$BLASDIR
 		NOOP=""
+		echo $'pow_qi\nqmaxloc\nqf__cabs' > ${TMP}/QUAD.list
 		files="`cat ${TMP}/ql.list`"
 		;;
 
 		DES=$LAPACKDIR
 		NOOP="slaruv dlaruv slamch dlamch"
 		rm ${TMP}/AUX.list
-		echo $'slamch\nsecond' > ${TMP}/SINGLE.list
-		echo $'dlamch\ndsecnd' > ${TMP}/DOUBLE.list
+		echo 'slamch' > ${TMP}/SINGLE.list
+		echo 'dlamch' > ${TMP}/DOUBLE.list
+		if [[ ${TESTING} != "0" ]]; then
+			echo 'second' > ${TMP}/SINGLE.list
+			echo 'dsecnd' > ${TMP}/DOUBLE.list
+		fi
 		rm ${TMP}/QUAD.list
 		cd $SRC
 		files="`ls *.f`"
 		# - Replace CHARACTER(1) by CHARACTER
 		# - Replace the intrinsic functions exit and maxloc by the macros myexit and mymaxloc
 		# - Replace sqrt, sin, cos, log and exp by M(*)
+		# - Replace max and min by f2cmax and f2cmin
 		$SED -r -e "
 			s/RECURSIVE//g;
 			s/CHARACTER\\(1\\)/CHARACTER/g;
 			s/myexit_\\(void\\)/mecago_()/g;
 			$( for i in sqrt sin cos log exp; do
 				echo "s/([^a-zA-Z_1-9]+)${i}([^a-zA-Z_1-9]+)/\\1M(${i})\\2/g;"
-			done )" |
+			done )
+			s/([^a-zA-Z_1-9]+)max([^a-zA-Z_1-9]+)/\\1f2cmax\\2/g;
+			s/([^a-zA-Z_1-9]+)min([^a-zA-Z_1-9]+)/\\1f2cmin\\2/g;" |
 		$AWK '
 			BEGIN {	a=1; }
 			{
 /*            ( Non twos-complement machines, with gradual underflow; */
 /*              e.g., IEEE standard followers ) */
 	    } else {
-		lemin = min(ngpmin,gpmin);
+		lemin = f2cmin(ngpmin,gpmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else if (ngpmin == gpmin && ngnmin == gnmin) {
 	    if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1) {
-		lemin = max(ngpmin,ngnmin);
+		lemin = f2cmax(ngpmin,ngnmin);
 /*            ( Twos-complement machines, no gradual underflow; */
 /*              e.g., CYBER 205 ) */
 	    } else {
-		lemin = min(ngpmin,ngnmin);
+		lemin = f2cmin(ngpmin,ngnmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1 && gpmin == gnmin)
 		 {
-	    if (gpmin - min(ngpmin,ngnmin) == 3) {
-		lemin = max(ngpmin,ngnmin) - 1 + lt;
+	    if (gpmin - f2cmin(ngpmin,ngnmin) == 3) {
+		lemin = f2cmax(ngpmin,ngnmin) - 1 + lt;
 /*            ( Twos-complement machines with gradual underflow; */
 /*              no known machine ) */
 	    } else {
-		lemin = min(ngpmin,ngnmin);
+		lemin = f2cmin(ngpmin,ngnmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else {
 /* Computing MIN */
-	    i__1 = min(ngpmin,ngnmin), i__1 = min(i__1,gpmin);
-	    lemin = min(i__1,gnmin);
+	    i__1 = f2cmin(ngpmin,ngnmin), i__1 = f2cmin(i__1,gpmin);
+	    lemin = f2cmin(i__1,gnmin);
 /*         ( A guess; no known machine ) */
 	    iwarn = TRUE_;
 	}
 /*            ( Non twos-complement machines, with gradual underflow; */
 /*              e.g., IEEE standard followers ) */
 	    } else {
-		lemin = min(ngpmin,gpmin);
+		lemin = f2cmin(ngpmin,gpmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else if (ngpmin == gpmin && ngnmin == gnmin) {
 	    if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1) {
-		lemin = max(ngpmin,ngnmin);
+		lemin = f2cmax(ngpmin,ngnmin);
 /*            ( Twos-complement machines, no gradual underflow; */
 /*              e.g., CYBER 205 ) */
 	    } else {
-		lemin = min(ngpmin,ngnmin);
+		lemin = f2cmin(ngpmin,ngnmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1 && gpmin == gnmin)
 		 {
-	    if (gpmin - min(ngpmin,ngnmin) == 3) {
-		lemin = max(ngpmin,ngnmin) - 1 + lt;
+	    if (gpmin - f2cmin(ngpmin,ngnmin) == 3) {
+		lemin = f2cmax(ngpmin,ngnmin) - 1 + lt;
 /*            ( Twos-complement machines with gradual underflow; */
 /*              no known machine ) */
 	    } else {
-		lemin = min(ngpmin,ngnmin);
+		lemin = f2cmin(ngpmin,ngnmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else {
 /* Computing MIN */
-	    i__1 = min(ngpmin,ngnmin), i__1 = min(i__1,gpmin);
-	    lemin = min(i__1,gnmin);
+	    i__1 = f2cmin(ngpmin,ngnmin), i__1 = f2cmin(i__1,gpmin);
+	    lemin = f2cmin(i__1,gnmin);
 /*         ( A guess; no known machine ) */
 	    iwarn = TRUE_;
 	}
 /*            ( Non twos-complement machines, with gradual underflow; */
 /*              e.g., IEEE standard followers ) */
 	    } else {
-		lemin = min(ngpmin,gpmin);
+		lemin = f2cmin(ngpmin,gpmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else if (ngpmin == gpmin && ngnmin == gnmin) {
 	    if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1) {
-		lemin = max(ngpmin,ngnmin);
+		lemin = f2cmax(ngpmin,ngnmin);
 /*            ( Twos-complement machines, no gradual underflow; */
 /*              e.g., CYBER 205 ) */
 	    } else {
-		lemin = min(ngpmin,ngnmin);
+		lemin = f2cmin(ngpmin,ngnmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1 && gpmin == gnmin)
 		 {
-	    if (gpmin - min(ngpmin,ngnmin) == 3) {
-		lemin = max(ngpmin,ngnmin) - 1 + lt;
+	    if (gpmin - f2cmin(ngpmin,ngnmin) == 3) {
+		lemin = f2cmax(ngpmin,ngnmin) - 1 + lt;
 /*            ( Twos-complement machines with gradual underflow; */
 /*              no known machine ) */
 	    } else {
-		lemin = min(ngpmin,ngnmin);
+		lemin = f2cmin(ngpmin,ngnmin);
 /*            ( A guess; no known machine ) */
 		iwarn = TRUE_;
 	    }
 
 	} else {
 /* Computing MIN */
-	    i__1 = min(ngpmin,ngnmin), i__1 = min(i__1,gpmin);
-	    lemin = min(i__1,gnmin);
+	    i__1 = f2cmin(ngpmin,ngnmin), i__1 = f2cmin(i__1,gpmin);
+	    lemin = f2cmin(i__1,gnmin);
 /*         ( A guess; no known machine ) */
 	    iwarn = TRUE_;
 	}
 } /* qlamc5_ */
 EOF
 
-	cat << EOF > ${LAPACKDIR}/second.c
+	if [[ $TESTING != 0 ]]; then
+		cat << EOF > ${LAPACKDIR}/second.c
 #include "f2c.h"
 #include <sys/times.h>
 #include <sys/types.h>
 } /* second_ */
 EOF
 
-	cat << EOF > ${LAPACKDIR}/dsecnd.c
+		cat << EOF > ${LAPACKDIR}/dsecnd.c
 #include "f2c.h"
 #include <sys/times.h>
 #include <sys/types.h>
   return (doublereal)(rusage.tms_utime) / CLK_TCK;
 
 } /* dsecnd_ */
-
 EOF
-
+	fi
 
 	cat << EOF > ${BLASDIR}/lsame.c
 #include "f2c.h"
 #	define M(A) A##q
 	typedef __float128 quadreal;
 	typedef struct { quadreal r, i; } quadcomplex;
+#	define scalar __float128
+#	define scalarcomplex quadcomplex
+#	define dscalar __float128
 #elif defined( __LAPACK_PRECISION_SINGLE)
 #	define M(A) A##f
+#	define scalar float
+#	define scalarcomplex complex
+#	define dscalar double
 #else
 #	define M(A) A
+#	define scalar double
+#	define scalarcomplex doublecomplex
+#	define dscalar double
 #endif
 #include <stdlib.h>
 #include <string.h>
 	};
 typedef struct Namelist Namelist;
 
-#define abs(x) ({ typeof(x) __x=(x); __x >= 0 ? __x : -__x; })
+#define abs(x) ((x) >= 0 ? (x) : -(x))
 #define dabs(x) (abs(x))
-#define min(a,b) ({ typeof(a) __a=(a), __b=(b); __a <= __b ? __a : __b; })
-#define max(a,b) ({ typeof(a) __a=(a), __b=(b); __a >= __b ? __a : __b; })
-#define dmin(a,b) (min(a,b))
-#define dmax(a,b) (max(a,b))
+#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
+#define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
+#define dmin(a,b) (f2cmin(a,b))
+#define dmax(a,b) (f2cmax(a,b))
 #define bit_test(a,b)	((a) >> (b) & 1)
 #define bit_clear(a,b)	((a) & ~((uinteger)1 << (b)))
 #define bit_set(a,b)	((a) |  ((uinteger)1 << (b)))
 #define abort_() { \
 sig_die("Fortran abort routine called", 1); \
 }
-#define f__cabs(_r, _i) ({ \
-	typeof(_r) __r=(_r), __i=(_i), __temp; \
-	if(__r < 0) \
-		__r = -__r; \
-	if(__i < 0) \
-		__i = -__i; \
-	if(__i > __r){ \
-		__temp = __r; \
-		__r = __i; \
-		__i = __temp; \
-	} \
-	if((__r+__i) == __r) \
-		__temp = __r; \
-	else { \
-		__temp = __i/__r; \
-		__temp = __r*M(sqrt)(M(1.0) + __temp*__temp);  /*overflow!!*/ \
-	} \
-	__temp; })
+#if defined(__LAPACK_PRECISION_QUAD)
+#	define f__cabs(r,i) qf__cabs((r),(i))
+	extern scalar qf__cabs(scalar r, scalar i);
+#elif defined( __LAPACK_PRECISION_SINGLE)
+#	define f__cabs(r,i) sf__cabs((r),(i))
+	extern scalar sf__cabs(scalar r, scalar i);
+#else
+#	define f__cabs(r,i) df__cabs((r),(i))
+	extern scalar df__cabs(scalar r, scalar i);
+#endif
 #define c_abs(z) ( f__cabs( (z)->r, (z)->i ) )
 #define c_cos(R,Z) {(R)->r = (M(cos)((Z)->r) * M(cosh)((Z)->i)); (R)->i = (-M(sin)((Z)->r) * M(sinh)((Z)->i));}
 #define c_div(c, a, b) { \
-	typeof((c)->r) __ratio, __den, __abr, __abi, __cr; \
+	scalar __ratio, __den, __abr, __abi, __cr; \
 	if( (__abr = (b)->r) < 0.) \
 		__abr = - __abr; \
 	if( (__abi = (b)->i) < 0.) \
 #define c_log(R, Z) { (R)->i = M(atan2)((Z)->i, (Z)->r); (R)->r = M(log)( f__cabs((Z)->r, (Z)->i) ); }
 #define c_sin(R, Z) { (R)->r = (M(sin)((Z)->r) * M(cosh)((Z)->i)); (R)->i = (M(cos)((Z)->r) * M(sinh)((Z)->i)); }
 #define c_sqrt(R, Z) { \
-	typeof((R)->r) __mag, __t, __zi = (Z)->i, __zr = (Z)->r; \
+	scalar __mag, __t, __zi = (Z)->i, __zr = (Z)->r; \
 	if( (__mag = f__cabs(__zr, __zi)) == 0.) (R)->r = (R)->i = 0.; \
 	else if(__zr > 0) { \
 		(R)->r = __t = M(sqrt)(M(0.5) * (__mag + __zr) ); \
 		(R)->r = M(0.5) * __t; \
 	} \
 }
-#define d_abs(x) abs(*(x)
+#define d_abs(x) abs(*(x))
 #define d_acos(x) (M(acos)(*(x)))
 #define d_asin(x) (M(asin)(*(x)))
 #define d_atan(x) (M(atan)(*(x)))
 #define d_cnjg(R, Z) { (R)->r = (Z)->r;	(R)->i = -((Z)->i); }
 #define d_cos(x) (M(cos)(*(x)))
 #define d_cosh(x) (M(cosh)(*(x)))
-#define d_dim(a, b) ({typeof(*(a)) __a=*(a), __b=*(b); __a > __b ? __a - __b : 0.0; })
+#define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
 #define d_exp(x) (M(exp)(*(x)))
 #define d_imag(z) ((z)->i)
-#define d_int(x) ({ typeof(*(x)) __x=*(x); __x>0 ? M(floor)(__x) : -M(floor)(- __x); })
+#define d_int(__x) (*(__x)>0 ? M(floor)(*(__x)) : -M(floor)(- *(__x)))
 #define d_lg10(x) ( M(0.43429448190325182765) * M(log)(*(x)) )
 #define d_log(x) (M(log)(*(x)))
 #define d_mod(x, y) (M(fmod)(*(x), *(y)))
-#define u_nint(x) ({ typeof(x) __x=(x); __x>=0 ? M(floor)(__x + M(.5)) : -M(floor)(M(.5) - __x); })
+#define u_nint(__x) ((__x)>=0 ? M(floor)((__x) + M(.5)) : -M(floor)(M(.5) - (__x)))
 #define d_nint(x) u_nint(*(x))
-#define u_sign(a,b) ({ typeof(a) __a=(a), __b=(b), __c=__a >= 0 ? __a : -__a; __b >= 0 ? __c : -__c; })
+#define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
 #define d_sign(a,b) u_sign(*(a),*(b))
 #define d_sin(x) (M(sin)(*(x)))
 #define d_sinh(x) (M(sinh)(*(x)))
 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
 #define pow_ci(p, a, b) { pow_zi((p), (a), (b)); }
 #define pow_dd(ap, bp) (M(pow)(*(ap), *(bp)))
-#define pow_di(B,E) pow_ui(*(B),*(E))
-#define pow_ii(B,E) ({ \
-	integer __x=*(B), __n=*(E), __pow; unsigned long int __u; \
-	if (__n <= 0) { \
-		if (__n == 0 || __x == 1) __pow = 1; \
-		else if (__x != -1) __pow = __x == 0 ? 1/__x : 0; \
-		else __n = -__n; \
-	} \
-	if ((__n > 0) || !(__n == 0 || __x == 1 || __x != -1)) { \
-		__u = __n; \
-		for(__pow = 1; ; ) { \
-			if(__u & 01) __pow *= __x; \
-			if(__u >>= 1) __x *= __x; \
-			else break; \
-		} \
-	} \
-	__pow; })
-#define pow_ri(B,E) pow_ui((doublereal)/*critical casting*/*(B),*(E))
-#define pow_ui(B,E) ({ \
-	typeof(B)  __x = (B); integer __n = (E); typeof(B) __pow=1.0; unsigned long int __u; \
-	if(__n != 0) { \
-		if(__n < 0) __n = -__n, __x = 1/__x; \
-		for(__u = __n; ; ) { \
-			if(__u & 01) __pow *= __x; \
-			if(__u >>= 1) __x *= __x; \
-			else break; \
-		} \
-	} \
-	__pow; })
+#if defined(__LAPACK_PRECISION_QUAD)
+#	define pow_di(B,E) qpow_ui((B),*(E))
+	extern dscalar qpow_ui(scalar *_x, integer n);
+#elif defined( __LAPACK_PRECISION_SINGLE)
+#	define pow_ri(B,E) spow_ui((B),*(E))
+	extern dscalar spow_ui(scalar *_x, integer n);
+#else
+#	define pow_di(B,E) dpow_ui((B),*(E))
+	extern dscalar dpow_ui(scalar *_x, integer n);
+#endif
+extern integer pow_ii(integer*,integer*);
 #define pow_zi(p, a, b) { \
-	integer __n=*(b); unsigned long __u; typeof((p)->r) __t; typeof(*(p)) __x; \
-	static typeof(*(p)) one = {1.0, 0.0}; \
+	integer __n=*(b); unsigned long __u; scalar __t; scalarcomplex __x; \
+	static scalarcomplex one = {1.0, 0.0}; \
 	(p)->r = 1; (p)->i = 0; \
 	if(__n != 0) { \
 		if(__n < 0) { \
 	} \
 }
 #define pow_zz(R,A,B) { \
-	typeof((R)->r) __logr, __logi, __x, __y; \
+	scalar __logr, __logi, __x, __y; \
 	__logr = M(log)( f__cabs((A)->r, (A)->i) ); \
 	__logi = M(atan2)((A)->i, (A)->r); \
 	__x = M(exp)( __logr * (B)->r - __logi * (B)->i ); \
         } \
 	while(--ll >= 0) *lp++ = ' '; \
 }
-#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),min((c),(d))))
-#define s_copy(A,B,C,D) { strncpy((A),(B),min((C),(D))); }
+#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
+#define s_copy(A,B,C,D) { strncpy((A),(B),f2cmin((C),(D))); }
 #define sig_die(s, kill) { exit(1); }
 #define s_stop(s, n) {exit(0);}
 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
 #define z_abs(z) c_abs(z)
 #define z_exp(R, Z) c_exp(R, Z)
 #define z_sqrt(R, Z) c_sqrt(R, Z)
-//#define myexit_() exit(EXIT_FAILURE)
 #define myexit_() break;
-#define mymaxloc_(w,s,e,n) ({ \
-	typeof(*(w)) __m; integer __i, __mi; \
-	for(__m=(w)[*(s)-1], __mi=*(s), __i=*(s)+1; __i<=*(e); __i++) \
-		if ((w)[__i-1]>__m) __mi=__i ,__m=(w)[__i-1]; \
-	__mi-*(s)+1; })
+#if defined(__LAPACK_PRECISION_QUAD)
+#	define mymaxloc_(w,s,e,n) qmaxloc_((w),*(s),*(e),n)
+	extern integer qmaxloc_(scalar *w, integer s, integer e, integer *n);
+#elif defined( __LAPACK_PRECISION_SINGLE)
+#	define mymaxloc_(w,s,e,n) smaxloc_((w),*(s),*(e),n)
+	extern integer smaxloc_(scalar *w, integer s, integer e, integer *n);
+#else
+#	define mymaxloc_(w,s,e,n) dmaxloc_((w),*(s),*(e),n)
+	extern integer dmaxloc_(scalar *w, integer s, integer e, integer *n);
+#endif
 
 /* procedure parameter types for -A and -C++ */
 
 	cp ${TMP}/f2c.h ${BLASDIR}
 	cp ${TMP}/f2c.h ${LAPACKDIR}
 
+
+	cat <<EOF > ${BLASDIR}/pow_ii.c
+#include "f2c.h"
+integer pow_ii(integer *_x, integer *_n) {
+	integer x=*_x, n=*_n, pow; unsigned long int u;
+	if (n <= 0) {
+		if (n == 0 || x == 1) pow = 1;
+		else if (x != -1) pow = x == 0 ? 1/x : 0;
+		else n = -n;
+	}
+	if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
+		u = n;
+		for(pow = 1; ; ) {
+			if(u & 01) pow *= x;
+			if(u >>= 1) x *= x;
+			else break;
+		}
+	}
+	return pow;
+}
+EOF
+
+	for i in s d q; do
+		case $i in
+		s) P="SINGLE";;
+		d) P="DOUBLE";;
+		q) P="QUAD";;
+		esac
+
+		cat <<EOF > ${BLASDIR}/pow_${i}i.c
+#define __LAPACK_PRECISION_${P}
+#include "f2c.h"
+dscalar ${i}pow_ui(scalar *_x, integer n) {
+	dscalar x = *_x; dscalar pow=1.0; unsigned long int u;
+	if(n != 0) {
+		if(n < 0) n = -n, x = 1/x;
+		for(u = n; ; ) {
+			if(u & 01) pow *= x;
+			if(u >>= 1) x *= x;
+			else break;
+		}
+	}
+	return pow;
+}
+EOF
+		cat <<EOF > ${BLASDIR}/${i}maxloc.c
+#define __LAPACK_PRECISION_${P}
+#include "f2c.h"
+integer ${i}maxloc_(scalar *w, integer s, integer e, integer *n)
+{
+	scalar m; integer i, mi;
+	for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
+		if (w[i-1]>m) mi=i ,m=w[i-1];
+	return mi-s+1;
+}
+EOF
+
+		cat <<EOF > ${BLASDIR}/${i}f__cabs.c
+#define __LAPACK_PRECISION_${P}
+#include "f2c.h"
+scalar ${i}f__cabs(scalar r, scalar i) {
+	scalar temp;
+	if(r < 0) r = -r;
+	if(i < 0) i = -i;
+	if(i > r){
+		temp = r;
+		r = i;
+		i = temp;
+	}
+	if((r+i) == r)
+		temp = r;
+	else {
+		temp = i/r;
+		temp = r*M(sqrt)(M(1.0) + temp*temp);  /*overflow!!*/
+	}
+	return temp;
+}
+EOF
+	done
+
+		
 # 3) Make the package, copy it to the current directory
 #	 and remove temp directory
 cd $TMP
 petsc-dist/src/mat/impls/csn
 petsc-dist/config/BuildSystem/BitKeeper
 petsc-dist/config/BuildSystem/ChangeSet
-petsc-dist/src/dm/mesh/examples/tutorials/illinois
-petsc-dist/src/dm/mesh/examples/tutorials/data
+petsc-dist/src/dm/impls/mesh/examples/tutorials/illinois
+petsc-dist/src/dm/impls/mesh/examples/tutorials/data

bin/matlab/@PetscOpenSocket/read.m

 %
 %   O = read(sreader,count,datatype) - reads data from a socket opened with sreader(socketnumber)
 %
+datatype
   switch (datatype)
   case 'int32'
     datatype = 0;
   case 'double'
     datatype = 1;
+  case 'float64'
+    datatype = 1;
   case 'uchar'
     datatype = 6;
   otherwise

bin/matlab/@PetscOpenSocket/write.m

     datatype = 0;
   case 'double'
     datatype = 1;
+  case 'float64'
+    datatype = 1;
   case 'uchar'
     datatype = 6;
     data     = data';

bin/pythonscripts/PetscBinaryIO.py

 
 Provides
   1. PETSc-named objects Vec, Mat, and IS that inherit numpy.ndarray
-  2. Functions to read and write these objects from PETSc binary files.
+  2. A class to read and write these objects from PETSc binary files.
 
 The standard usage of this module should look like:
 
   >>> import PetscBinaryIO
-  >>> objects = PetscBinaryIO.readBinaryFile('file.dat')
+  >>> io = PetscBinaryIO.PetscBinaryIO()
+  >>> objects = io.readBinaryFile('file.dat')
 
 or
 
   >>> import PetscBinaryIO
   >>> import numpy
   >>> vec = numpy.array([1., 2., 3.]).view(PetscBinaryIO.Vec)
-  >>> PetscBinaryIO.writeBinaryFile('file.dat', [vec,])
+  >>> io = PetscBinaryIO.PetscBinaryIO()
+  >>> io.writeBinaryFile('file.dat', [vec,])
 
-See also readBinaryFile.__doc__ and writeBinaryFile.__doc__ 
+See also PetscBinaryIO.__doc__ and methods therein.
 """
 
 import numpy as np
 import types
+import functools
+
+def update_wrapper_with_doc(wrapper, wrapped):
+    """Similar to functools.update_wrapper, but also gets the wrapper's __doc__ string"""
+    wdoc = wrapper.__doc__
+
+    functools.update_wrapper(wrapper, wrapped)
+    if wdoc is not None:
+        if wrapper.__doc__ is None:
+            wrapper.__doc__ = wdoc
+        else:
+            wrapper.__doc__ = wrapper.__doc__ + wdoc
+    return wrapper
+
+def wraps_with_doc(wrapped):
+    """Similar to functools.wraps, but also gets the wrapper's __doc__ string"""
+    return functools.partial(update_wrapper_with_doc, wrapped=wrapped)
+
+def decorate_with_conf(f):
+    """Decorates methods to take kwargs for precisions."""
+    @wraps_with_doc(f)
+    def decorated_f(self, *args, **kwargs):
+        """
+        Additional kwargs:
+          precision: 'single', 'double', 'longlong' for scalars
+          indices: '32bit', '64bit' integer size
+          complexscalars: True/False
+
+          Note these are set in order of preference:
+            1. kwargs if given here
+            2. PetscBinaryIO class __init__ arguments
+            3. PETSC_DIR/PETSC_ARCH defaults
+        """
+
+        changed = False
+        old_precision = self.precision
+        old_indices = self.indices
+        old_complexscalars = self.complexscalars
+
+        try:
+            self.precision = kwargs.pop('precision')
+        except KeyError:
+            pass
+        else:
+            changed = True
+
+        try:
+            self.indices = kwargs.pop('indices')
+        except KeyError:
+            pass
+        else:
+            changed = True
+
+        try:
+            self.complexscalars = kwargs.pop('complexscalars')
+        except KeyError:
+            pass
+        else:
+            changed = True
+
+        if changed:
+            self._update_dtypes()
+
+        result = f(self, *args, **kwargs)
+
+        if changed:
+            self.precision = old_precision
+            self.indices = old_indices
+            self.complexscalars = old_complexscalars
+            self._update_dtypes()
+
+        return result
+    return decorated_f
 
-IntType    = np.dtype('>i4')   # big-endian, 4 byte integer
-ScalarType = np.dtype('>f8')   # big-endian, 8 byte real floating
-_classid = {1211216:'Mat',
-            1211214:'Vec',
-            1211218:'IS',
-            1211219:'Bag'}
 
 class DoneWithFile(Exception): pass
 
+
 class Vec(np.ndarray):
     """Vec represented as 1D numpy array
 
     """
     _classid = 1211214
 
+
 class MatDense(np.matrix):
     """Mat represented as 2D numpy array
 
     """
     _classid = 1211216
 
+
 class MatSparse(tuple):
     """Mat represented as CSR tuple ((M, N), (rowindices, col, val))
 
     def __repr__(self):
         return 'MatSparse: %s'%super(MatSparse, self).__repr__()
 
+
 class IS(np.ndarray):
     """IS represented as 1D numpy array
 
     """
     _classid = 1211218
 
-def readVec(fh):
-    """Reads a PETSc Vec from a binary file handle, returning just the data."""
-
-    nz = np.fromfile(fh, dtype=IntType, count=1)[0]
-    try:
-        vals = np.fromfile(fh, dtype=ScalarType, count=nz)
-    except MemoryError:
-        raise IOError('Inconsistent or invalid Vec data in file')
-    if (len(vals) is 0):
-        raise IOError('Inconsistent or invalid Vec data in file')
-    return vals.view(Vec)
-
-def writeVec(fh, vec):
-    """Writes a PETSc Vec to a binary file handle."""
-
-    metadata = np.array([Vec._classid, len(vec)], dtype=IntType)
-    metadata.tofile(fh)
-    vec.astype(ScalarType).tofile(fh)
-    return
-
-def readMatSparse(fh):
-    """Reads a PETSc Mat, returning a sparse representation of the data.
-
-    (M,N), (I,J,V) = readMatSparse(fid)
-
-    Input:
-      fid : file handle to open binary file.
-    Output:
-      M,N : matrix size
-      I,J : arrays of row and column for each nonzero
-      V: nonzero value
-    """
-    try:
-        M,N,nz = np.fromfile(fh, dtype=IntType, count=3)
-        #
-        I = np.empty(M+1, dtype=IntType)
-        I[0] = 0
-        rownz = np.fromfile(fh, dtype=IntType, count=M)
-        np.cumsum(rownz, out=I[1:])
-        assert I[-1] == nz
-        #
-        J = np.fromfile(fh, dtype=IntType,    count=nz)
-        assert len(J) == nz
-        V = np.fromfile(fh, dtype=ScalarType, count=nz)
-        assert len(V) == nz
-    except (AssertionError, MemoryError, IndexError):
-        raise IOError('Inconsistent or invalid Mat data in file')
-    #
-    return MatSparse(((M, N), (I, J, V)))
-
-def writeMatSparse(fh, mat):
-    """Writes a Mat into a PETSc binary file handle"""
-
-    ((M,N), (I,J,V)) = mat
-    metadata = np.array([MatSparse._classid,M,N,I[-1]], dtype=IntType)
-    rownz = I[1:] - I[:-1]
-
-#    try:
-    assert len(J.shape) == len(V.shape) == len(I.shape) == 1
-    assert len(J) == len(V) == I[-1] == rownz.sum()
-    assert (rownz > -1).all()
-
-#    except AssertionError:
-#        raise ValueError('Invalid Mat data given')
-
-    metadata.tofile(fh)
-    rownz.astype(IntType).tofile(fh)
-    J.astype(IntType).tofile(fh)
-    V.astype(ScalarType).tofile(fh)
-    return
-
-def readMatDense(fh):
-    """Reads a PETSc Mat, returning a dense represention of the data."""
-    try:
-        M,N,nz = np.fromfile(fh, dtype=IntType, count=3)
-        #
-        I = np.empty(M+1, dtype=IntType)
-        I[0] = 0
-        rownz = np.fromfile(fh, dtype=IntType, count=M)
-        np.cumsum(rownz, out=I[1:])
-        assert I[-1] == nz
-        #
-        J = np.fromfile(fh, dtype=IntType, count=nz)
-        assert len(J) == nz
-        V = np.fromfile(fh, dtype=ScalarType, count=nz)
-        assert len(V) == nz
-
-    except (AssertionError, MemoryError, IndexError):
-        raise IOError('Inconsistent or invalid Mat data in file')
-    #
-    mat = np.zeros((M,N), dtype=ScalarType)
-    for row in range(M):
-        rstart, rend = I[row:row+2]
-        mat[row, J[rstart:rend]] = V[rstart:rend]
-    return mat.view(MatDense)
-
-def readMatSciPy(fh):
-    from scipy.sparse import csr_matrix
-    (M, N), (I, J, V) = readMatSparse(fh)
-    return csr_matrix((V, J, I), shape=(M, N))
-
-def writeMatSciPy(fh, mat):
-    from scipy.sparse import csr_matrix
-    assert isinstance(mat, csr_matrix)
-    V = mat.data
-    M,N = mat.shape
-    J = mat.indices
-    I = mat.indptr
-    return writeMatSparse(fh, (mat.shape, (mat.indptr,mat.indices,mat.data)))
-
-def readMat(fh, mattype='sparse'):
-    """Reads a PETSc Mat from binary file handle.
-
-    optional mattype: 'sparse" or 'dense'
-
-    See also: readMatSparse, readMatDense
-    """
-    if mattype == 'sparse':
-        return readMatSparse(fh)
-    elif mattype == 'dense':
-        return readMatDense(fh)
-    elif mattype == 'scipy.sparse':
-        return readMatSciPy(fh)
-    else:
-        raise RuntimeError('Invalid matrix type requested: choose sparse/dense')
-
-def readIS(fh):
-    """Reads a PETSc Index Set from binary file handle."""
-    try:
-        nz = np.fromfile(fh, dtype=IntType, count=1)[0]
-        v = np.fromfile(fh, dtype=IntType, count=nz)
-        assert len(v) == nz
-    except (MemoryError,IndexError):
-        raise IOError('Inconsistent or invalid IS data in file')
-    return v.view(IS)
-
-def writeIS(fh, anis):
-    """Writes a PETSc IS to binary file handle."""
-
-    metadata = np.array([IS._classid, len(anis)], dtype=IntType)
-    metadata.tofile(fh)
-    anis.astype(IntType).tofile(fh)
-    return
-
-def readBinaryFile(fid, mattype='sparse'):
-    """Reads a PETSc binary file, returning a tuple of the contained objects.
-
-    objects = readBinaryFile(fid, mattype='sparse')
-
-    Input:
-      fid : either file handle to an open binary file, or filename.
-      mattype :
-         'sparse': Return matrices as raw CSR: (M, N), (row, col, val).
-         'dense': Return matrices as MxN numpy arrays.
-         'scipy.sparse': Return matrices as scipy.sparse objects.
-
-    Output:
-      objects : tuple of objects representing the data in numpy arrays.
-    """
-    close = False
-
-    if type(fid) is types.StringType:
-        fid = open(fid, 'rb')
-        close = True
-
-    objects = []
-    try:
-        while True:
-            # read header
-            try:
-                header = np.fromfile(fid, dtype=IntType, count=1)[0]
-            except (MemoryError, IndexError):
-                raise DoneWithFile
-            try:
-                objecttype = _classid[header]
-            except KeyError:
-                raise IOError('Invalid PetscObject CLASSID or object not implemented for python')
-
-            if objecttype == 'Vec':
-                objects.append(readVec(fid))
-            elif objecttype == 'IS':
-                objects.append(readIS(fid))
-            elif objecttype == 'Mat':
-                objects.append(readMat(fid,mattype))
-            elif objecttype == 'Bag':
-                raise NotImplementedError('Bag Reader not yet implemented')
-    except DoneWithFile:
-        pass
-    finally:
-        if close:
-            fid.close()
-    #
-    return tuple(objects)
 
-def writeBinaryFile(fid, objects):
-    """Writes a PETSc binary file containing the objects given.
+class PetscBinaryIO(object):
+    """Reader/Writer class for PETSc binary files.
 
-    readBinaryFile(fid, objects)
+    Note that by default, precisions for both scalars and indices, as well as 
+    complex scalars, are picked up from the PETSC_DIR/PETSC_ARCH configuration
+    as set by environmental variables.
 
-    Input:
-      fid : either file handle to an open binary file, or filename.
-      objects : list of objects representing the data in numpy arrays,
-                which must be of type Vec, IS, MatSparse, or MatSciPy.
+    Alternatively, defaults can be overridden at class instantiation, or for
+    a given method call.
     """
-    close = False
-    if type(fid) is types.StringType:
-        fid = open(fid, 'wb')
-        close = True
-
-    for petscobj in objects:
-        if (isinstance(petscobj, Vec)):
-            writeVec(fid, petscobj)
-        elif (isinstance(petscobj, IS)):
-            writeIS(fid, petscobj)
-        elif (isinstance(petscobj, MatSparse)):
-            writeMatSparse(fid, petscobj)
-        elif (isinstance(petscobj, MatDense)):
+
+    _classid = {1211216:'Mat',
+                1211214:'Vec',
+                1211218:'IS',
+                1211219:'Bag'}
+
+    def __init__(self, precision=None, indices=None, complexscalars=None):
+        if (precision is None) or (indices is None) or (complexscalars is None):
+            import petsc_conf
+            defaultprecision, defaultindices, defaultcomplexscalars = petsc_conf.get_conf()
+            if precision is None:
+                if defaultprecision is None:
+                    precision = 'double'
+                else:
+                    precision = defaultprecision
+
+            if indices is None:
+                if defaultindices is None:
+                    indices = '32bit'
+                else:
+                    indices = defaultindices
+
+            if complexscalars is None:
+                if defaultcomplexscalars is None:
+                    complexscalars = False
+                else:
+                    complexscalars = defaultcomplexscalars
+
+        self.precision = precision
+        self.indices = indices
+        self.complexscalars = complexscalars
+        self._update_dtypes()
+
+    def _update_dtypes(self):
+        if self.indices == '64bit':
+            self._inttype = np.dtype('>i8')
+        else:
+            self._inttype = np.dtype('>i4')
+
+        if self.complexscalars:
+            name = 'c'
+        else:
+            name = 'f'
+
+        if self.precision == 'longlong':
+            self._scalartype = '>%s16'%name
+        if self.precision == 'single':
+            self._scalartype = '>%s4'%name
+        else:
+            self._scalartype = '>%s8'%name
+
+    @decorate_with_conf
+    def readVec(self, fh):
+        """Reads a PETSc Vec from a binary file handle, returning just the data."""
+
+        nz = np.fromfile(fh, dtype=self._inttype, count=1)[0]
+        try:
+            vals = np.fromfile(fh, dtype=self._scalartype, count=nz)
+        except MemoryError:
+            raise IOError('Inconsistent or invalid Vec data in file')
+        if (len(vals) is 0):
+            raise IOError('Inconsistent or invalid Vec data in file')
+        return vals.view(Vec)
+
+    @decorate_with_conf
+    def writeVec(self, fh, vec):
+        """Writes a PETSc Vec to a binary file handle."""
+
+        metadata = np.array([Vec._classid, len(vec)], dtype=self._inttype)
+        metadata.tofile(fh)
+        vec.astype(self._scalartype).tofile(fh)
+        return
+
+    @decorate_with_conf
+    def readMatSparse(self, fh):
+        """Reads a PETSc Mat, returning a sparse representation of the data.
+
+        (M,N), (I,J,V) = readMatSparse(fid)
+
+        Input:
+          fid : file handle to open binary file.
+        Output:
+          M,N : matrix size
+          I,J : arrays of row and column for each nonzero
+          V: nonzero value
+        """
+
+        try:
+            M,N,nz = np.fromfile(fh, dtype=self._inttype, count=3)
+            I = np.empty(M+1, dtype=self._inttype)
+            I[0] = 0
+            rownz = np.fromfile(fh, dtype=self._inttype, count=M)
+            np.cumsum(rownz, out=I[1:])
+            assert I[-1] == nz
+
+            J = np.fromfile(fh, dtype=self._inttype,    count=nz)
+            assert len(J) == nz
+            V = np.fromfile(fh, dtype=self._scalartype, count=nz)
+            assert len(V) == nz
+        except (AssertionError, MemoryError, IndexError):
+            raise IOError('Inconsistent or invalid Mat data in file')
+
+        return MatSparse(((M, N), (I, J, V)))
+
+    @decorate_with_conf
+    def writeMatSparse(self, fh, mat):
+        """Writes a Mat into a PETSc binary file handle"""
+
+        ((M,N), (I,J,V)) = mat
+        metadata = np.array([MatSparse._classid,M,N,I[-1]], dtype=self._inttype)
+        rownz = I[1:] - I[:-1]
+
+        assert len(J.shape) == len(V.shape) == len(I.shape) == 1
+        assert len(J) == len(V) == I[-1] == rownz.sum()
+        assert (rownz > -1).all()
+
+        metadata.tofile(fh)
+        rownz.astype(self._inttype).tofile(fh)
+        J.astype(self._inttype).tofile(fh)
+        V.astype(self._scalartype).tofile(fh)
+        return
+
+    @decorate_with_conf
+    def readMatDense(self, fh):
+        """Reads a PETSc Mat, returning a dense represention of the data."""
+
+        try:
+            M,N,nz = np.fromfile(fh, dtype=self._inttype, count=3)
+            I = np.empty(M+1, dtype=self._inttype)
+            I[0] = 0
+            rownz = np.fromfile(fh, dtype=self._inttype, count=M)
+            np.cumsum(rownz, out=I[1:])
+            assert I[-1] == nz
+
+            J = np.fromfile(fh, dtype=self._inttype, count=nz)
+            assert len(J) == nz
+            V = np.fromfile(fh, dtype=self._scalartype, count=nz)
+            assert len(V) == nz
+
+        except (AssertionError, MemoryError, IndexError):
+            raise IOError('Inconsistent or invalid Mat data in file')
+
+        mat = np.zeros((M,N), dtype=self._scalartype)
+        for row in range(M):
+            rstart, rend = I[row:row+2]
+            mat[row, J[rstart:rend]] = V[rstart:rend]
+        return mat.view(MatDense)
+
+    @decorate_with_conf
+    def readMatSciPy(self, fh):
+        from scipy.sparse import csr_matrix
+        (M, N), (I, J, V) = self.readMatSparse(fh)
+        return csr_matrix((V, J, I), shape=(M, N))
+
+    @decorate_with_conf
+    def writeMatSciPy(self, fh, mat):
+        from scipy.sparse import csr_matrix
+        assert isinstance(mat, csr_matrix)
+        V = mat.data
+        M,N = mat.shape
+        J = mat.indices
+        I = mat.indptr
+        return writeMatSparse(fh, (mat.shape, (mat.indptr,mat.indices,mat.data)))
+
+    @decorate_with_conf
+    def readMat(self, fh, mattype='sparse'):
+        """Reads a PETSc Mat from binary file handle.
+
+        optional mattype: 'sparse" or 'dense'
+
+        See also: readMatSparse, readMatDense
+        """
+
+        if mattype == 'sparse':
+            return self.readMatSparse(fh)
+        elif mattype == 'dense':
+            return self.readMatDense(fh)
+        elif mattype == 'scipy.sparse':
+            return self.readMatSciPy(fh)
+        else:
+            raise RuntimeError('Invalid matrix type requested: choose sparse/dense')
+
+    @decorate_with_conf
+    def readIS(self, fh):
+        """Reads a PETSc Index Set from binary file handle."""
+
+        try:
+            nz = np.fromfile(fh, dtype=self._inttype, count=1)[0]
+            v = np.fromfile(fh, dtype=self._inttype, count=nz)
+            assert len(v) == nz
+        except (MemoryError,IndexError):
+            raise IOError('Inconsistent or invalid IS data in file')
+        return v.view(IS)
+
+    @decorate_with_conf
+    def writeIS(self, fh, anis):
+        """Writes a PETSc IS to binary file handle."""
+
+        metadata = np.array([IS._classid, len(anis)], dtype=self._inttype)
+        metadata.tofile(fh)
+        anis.astype(self._inttype).tofile(fh)
+        return
+
+    @decorate_with_conf
+    def readBinaryFile(self, fid, mattype='sparse'):
+        """Reads a PETSc binary file, returning a tuple of the contained objects.
+
+        objects = self.readBinaryFile(fid, **kwargs)
+
+        Input:
+          fid : either file name or handle to an open binary file.
+
+        Output:
+          objects : tuple of objects representing the data in numpy arrays.
+
+        Optional:
+          mattype :
+            'sparse': Return matrices as raw CSR: (M, N), (row, col, val).
+            'dense': Return matrices as MxN numpy arrays.
+            'scipy.sparse': Return matrices as scipy.sparse objects.
+        """
+
+        close = False
+
+        if type(fid) is types.StringType:
+            fid = open(fid, 'rb')
+            close = True
+
+        objects = []
+        try:
+            while True:
+                # read header
+                try:
+                    header = np.fromfile(fid, dtype=self._inttype, count=1)[0]
+                except (MemoryError, IndexError):
+                    raise DoneWithFile
+                try:
+                    objecttype = self._classid[header]
+                except KeyError:
+                    raise IOError('Invalid PetscObject CLASSID or object not implemented for python')
+
+                if objecttype == 'Vec':
+                    objects.append(self.readVec(fid))
+                elif objecttype == 'IS':
+                    objects.append(self.readIS(fid))
+                elif objecttype == 'Mat':
+                    objects.append(self.readMat(fid,mattype))
+                elif objecttype == 'Bag':
+                    raise NotImplementedError('Bag Reader not yet implemented')
+        except DoneWithFile:
+            pass
+        finally:
             if close:
                 fid.close()
-            raise NotImplementedError('Writing a dense matrix is not yet supported')
-        else:
-            try:
-                writeMatSciPy(fid, petscobj)
-            except AssertionError:
+
+        return tuple(objects)
+
+    @decorate_with_conf
+    def writeBinaryFile(self, fid, objects):
+        """Writes a PETSc binary file containing the objects given.
+
+        readBinaryFile(fid, objects)
+
+        Input:
+          fid : either file handle to an open binary file, or filename.
+          objects : list of objects representing the data in numpy arrays,
+                    which must be of type Vec, IS, MatSparse, or MatSciPy.
+        """
+        close = False
+        if type(fid) is types.StringType:
+            fid = open(fid, 'wb')
+            close = True
+
+        for petscobj in objects:
+            if (isinstance(petscobj, Vec)):
+                self.writeVec(fid, petscobj)
+            elif (isinstance(petscobj, IS)):
+                self.writeIS(fid, petscobj)
+            elif (isinstance(petscobj, MatSparse)):
+                self.writeMatSparse(fid, petscobj)
+            elif (isinstance(petscobj, MatDense)):
                 if close:
                     fid.close()
-                raise TypeError('Object %s is not a valid PETSc object'%(petscobj.__repr__()))
-    if close:
-        fid.close()
-    return
+                raise NotImplementedError('Writing a dense matrix is not yet supported')
+            else:
+                try:
+                    self.writeMatSciPy(fid, petscobj)
+                except AssertionError:
+                    if close:
+                        fid.close()
+                    raise TypeError('Object %s is not a valid PETSc object'%(petscobj.__repr__()))
+        if close:
+            fid.close()
+        return

bin/pythonscripts/petsc_conf.py

+import warnings
+
+def get_conf():
+    """Parses various PETSc configuration/include files to get data types.
+
+    precision, indices, complexscalars = get_conf()
+
+    Output:
+      precision: 'single', 'double', 'longlong' indicates precision of PetscScalar
+      indices: '32', '64' indicates bit-size of PetscInt
+      complex: True/False indicates whether PetscScalar is complex or not.
+    """
+
+    import sys, os
+    precision = None
+    indices = None
+    complexscalars = None
+
+    try:
+        petscdir = os.environ['PETSC_DIR']
+    except KeyError:
+        warnings.warn('Nonexistent or invalid PETSc installation, using defaults')
+        return
+
+    try:
+        petscdir = os.path.join(petscdir, os.environ['PETSC_ARCH'])
+    except KeyError:
+        pass
+
+    petscvariables = os.path.join(petscdir, 'conf', 'petscvariables')
+    petscconfinclude = os.path.join(petscdir, 'include', 'petscconf.h')
+
+    try:
+        fid = file(petscvariables, 'r')
+    except IOError:
+        warnings.warn('Nonexistent or invalid PETSc installation, using defaults')
+        return None, None, None
+    else:
+        for line in fid:
+            if line.startswith('PETSC_PRECISION'):
+                precision = line.strip().split('=')[1].strip('\n').strip()
+
+        fid.close()
+
+    try:
+        fid = file(petscconfinclude, 'r')
+    except IOError:
+        warnings.warn('Nonexistent or invalid PETSc installation, using defaults')
+        return None, None, None
+    else:
+        for line in fid:
+            if line.startswith('#define PETSC_USE_64BIT_INDICES 1'):
+                indices = '64bit'
+            elif line.startswith('#define PETSC_USE_COMPLEX 1'):
+                complexscalars = True
+
+        if indices is None:
+            indices = '32bit'
+        if complexscalars is None:
+            complexscalars = False
+        fid.close()
+
+    return precision, indices, complexscalars
 
 # Performs the specified action throughout the directory tree
 tree_basic: ${ACTION}
-	@-if [ "${DIRS}" != "" ]; then \
-	for dir in ${DIRS} foo ; do if [ -d $$dir ]; then \
+	-@for dir in ${DIRS} ftn-custom ; do if [ -d $$dir ]; then \
 	(cd $$dir ; echo ${ACTION} in: `pwd`; \
 	${OMAKE}  tree_basic ACTION=${ACTION}  \
 	PETSC_ARCH=${PETSC_ARCH}  LOC=${LOC}) ;fi; \
-	done ; fi
+	done
 
 #This target goes through all the dirs that contains a makefile
 alltree_makefile: ${ACTION}
               -e "s/ierr [ ]*= //g"  -e "s/PETSC[A-Z]*_DLLEXPORT//g" $$i | ${C2HTML} -n  | \
               sed "s?splicer.begin(\([_A-Za-z0-9.]*\))?splicer.begin(\1)  <a name=\1></p>?g" | \
               ${PETSC_DIR}/bin/maint/fixinclude $$i $${ROOT} | \
-              egrep -v '(PetscValid|PetscFunctionBegin|PetscCheck|PetscErrorCode ierr;|#if !defined\(__|#define __|#undef __|EXTERN_C|extern )' | \
+              egrep -v '(PetscValid|PetscFunctionBegin|PetscCheck|PetscErrorCode ierr;|#if !defined\(__|#define __|#undef __|EXTERN_C )' | \
               ${MAPNAMES} -map /tmp/$$USER.htmlmap -inhtml | sed -e s?ROOT?$${IROOT}?g >> $${loc}/$$i.html ; \
 	    fi; \
          done
         if [ "${LIBNAME}" = "libpetsc" ]; then OTHERLIBS="${PETSC_EXTERNAL_LIB_BASIC}   ${SYS_LIB}  ${OTHERSHAREDLIBS}  ${SL_LINKER_LIBS} -lm -lc "; fi;\
         if [ "${LIBNAME}" = "libpetscsys" ]; then OTHERLIBS="  ${SYS_LIB}  ${OTHERSHAREDLIBS}  ${SL_LINKER_LIBS} -lm -lc "; fi;\
         if [ "${LIBNAME}" = "libpetscvec" ]; then OTHERLIBS="${HYPRE_LIB} ${PETSC_SYS_LIB_BASIC}"  ; fi;\
-        if [ "${LIBNAME}" = "libpetscmat" ]; then OTHERLIBS="${PLAPACK_LIB} ${SCOTCH_LIB} ${PARTY_LIB} ${CHACO_LIB} ${JOSTLE_LIB} ${SUPERLU_LIB} ${SUPERLU_DIST_LIB} ${SPOOLES_LIB} ${MUMPS_LIB} ${SCALAPACK_LIB} ${BLACS_LIB} ${PARMETIS_LIB} ${UMFPACK_LIB} ${LUSOL_LIB} ${PETSC_VEC_LIB_BASIC}"  ; fi;\
+        if [ "${LIBNAME}" = "libpetscmat" ]; then OTHERLIBS="${PLAPACK_LIB} ${SCOTCH_LIB} ${PARTY_LIB} ${CHACO_LIB} ${SUPERLU_LIB} ${SUPERLU_DIST_LIB} ${SPOOLES_LIB} ${MUMPS_LIB} ${SCALAPACK_LIB} ${BLACS_LIB} ${PARMETIS_LIB} ${UMFPACK_LIB} ${LUSOL_LIB} ${PETSC_VEC_LIB_BASIC}"  ; fi;\
         if [ "${LIBNAME}" = "libpetscdm" ]; then OTHERLIBS="${TRIANGLE_LIB} ${TETGEN_LIB} ${HYPRE_LIB} ${PETSC_MAT_LIB_BASIC} ${MPI_LIB}"  ; fi;\
         if [ "${LIBNAME}" = "libpetscksp" ]; then OTHERLIBS="${HYPRE_LIB} ${PETSC_CHARACTERISTIC_LIB_BASIC}"  ; fi;\
         if [ "${LIBNAME}" = "libpetscsnes" ]; then OTHERLIBS="${PETSC_KSP_LIB_BASIC}"  ; fi;\

config/PETSc/Configure.py

                                             'unistd', 'sys/sysinfo', 'machine/endian', 'sys/param', 'sys/procfs', 'sys/resource',
                                             'sys/systeminfo', 'sys/times', 'sys/utsname','string', 'stdlib','memory',
                                             'sys/socket','sys/wait','netinet/in','netdb','Direct','time','Ws2tcpip','sys/types',
-                                            'WindowsX', 'cxxabi','float','ieeefp','stdint','fenv','sched'])
+                                            'WindowsX', 'cxxabi','float','ieeefp','stdint','fenv','sched','pthread'])
     functions = ['access', '_access', 'clock', 'drand48', 'getcwd', '_getcwd', 'getdomainname', 'gethostname', 'getpwuid',
                  'gettimeofday', 'getwd', 'memalign', 'memmove', 'mkstemp', 'popen', 'PXFGETARG', 'rand', 'getpagesize',
                  'readlink', 'realpath',  'sigaction', 'signal', 'sigset', 'nanosleep', 'usleep', 'sleep', '_sleep', 'socket', 
       fd = file(conffile, 'w')
       fd.write('PETSC_ARCH='+self.arch.arch+'\n')
       fd.write('PETSC_DIR='+self.petscdir.dir+'\n')
-      fd.write('include ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables\n')
+      fd.write('include '+os.path.join(self.petscdir.dir,self.arch.arch,'conf','petscvariables')+'\n')
       fd.close()
       self.framework.actions.addArgument('PETSc', 'Build', 'Set default architecture to '+self.arch.arch+' in '+conffile)
     elif os.path.isfile(conffile):

config/PETSc/packages/Chaco.py

     self.needsMath    = 1
     self.complex      = 1
     self.liblist      = [['libchaco.a']]
-    self.license      = 'http://www.cs.sandia.gov/~web9200/9200_download.html'
+    self.license      = 'http://www.cs.sandia.gov/web1400/1400_download.html'
     self.worksonWindows    = 1
     self.downloadonWindows = 1
     return

config/PETSc/packages/MUMPS.py

   def Install(self):
     import os
 
+    if not self.compilers.FortranDefineCompilerOption:
+      raise RuntimeError('Fortran compiler cannot handle preprocessing directives from command line.')
     g = open(os.path.join(self.packageDir,'Makefile.inc'),'w')
     g.write('LPORDDIR   = $(topdir)/PORD/lib/\n')
     g.write('IPORD      = -I$(topdir)/PORD/include/\n')
     g.write('LPORD      = -L$(LPORDDIR) -lpord\n')
     g.write('IMETIS = '+self.headers.toString(self.parmetis.include)+'\n')
-    g.write('LMETIS = '+self.libraries.toString(self.parmetis.lib)+'\n') 
+    g.write('LMETIS = '+self.libraries.toString(self.parmetis.lib)+'\n')
     orderingsc = '-Dmetis -Dparmetis -Dpord'
     orderingsf = self.compilers.FortranDefineCompilerOption+'metis '+self.compilers.FortranDefineCompilerOption+'parmetis '+self.compilers.FortranDefineCompilerOption+'pord'
     # Disable threads on BGL
       orderingsf += ' '+self.compilers.FortranDefineCompilerOption+'scotch '+self.compilers.FortranDefineCompilerOption+'ptscotch'
 
     g.write('ORDERINGSC = '+orderingsc+'\n')
-    if self.compilers.FortranDefineCompilerOption:
-      g.write('ORDERINGSF = '+orderingsf+'\n')
-    else:
-      raise RuntimeError('Fortran compiler cannot handle preprocessing directives from command line.')     
+    g.write('ORDERINGSF = '+orderingsf+'\n')
     g.write('LORDERINGS  = $(LMETIS) $(LPORD) $(LSCOTCH)\n')
     g.write('IORDERINGSC = $(IMETIS) $(IPORD) $(ISCOTCH)\n')
     g.write('IORDERINGSF = $(ISCOTCH)\n')
     g.write('LIBSEQ  =  $(LAPACK) -L$(topdir)/libseq -lmpiseq\n')
     g.write('LIBBLAS = '+self.libraries.toString(self.blasLapack.dlib)+'\n')
     g.write('OPTL    = -O -I.\n')
-    g.write('INC = $(INCPAR)\n')
+    g.write('INCS = $(INCPAR)\n')
     g.write('LIB = $(LIBPAR)\n')
     g.write('LIBSEQNEEDED =\n')
     g.close()

config/PETSc/packages/Matlab.py

         
       output      = ''
       try:
-        output,err,ret = PETSc.package.NewPackage.executeShellCommand(interpreter+' -nojvm -nodisplay -r "[\'Version \' version]; exit"', log = self.framework.log)
+        output,err,ret = PETSc.package.NewPackage.executeShellCommand(interpreter+' -nojvm -nodisplay -r "display([\'Version \' version]); exit"', log = self.framework.log)
       except:
         self.framework.log.write('WARNING: Found Matlab at '+matlab+' but unable to run\n')
         continue

config/PETSc/packages/PARTY.py

     self.functions    = ['party_lib']
     self.includes     = ['party_lib.h']
     self.liblist      = [['libparty.a']]
-    self.license      = 'http://wwwcs.upb.de/fachbereich/AG/monien/RESEARCH/PART/party.html'
+    self.license      = 'http://www2.cs.uni-paderborn.de/cs/robsy/party.html'
     return
 
   def Install(self):

config/PETSc/packages/SuperLU.py

     self.complex      = 1
     # SuperLU has NO support for 64 bit integers, use SuperLU_Dist if you need that
     self.excludedDirs = ['SuperLU_DIST']
+    # SuperLU does not work with --download-f-blas-lapack with Compaqf90 compiler on windows.
+    # However it should work with intel ifort.
+    self.worksonWindows   = 1
+    self.downloadonWindows= 1
     return
 
   def setupDependencies(self, framework):
 
     g = open(os.path.join(self.packageDir,'make.inc'),'w')
     g.write('SuperLUroot  = '+self.packageDir+'\n')
-    g.write('TMGLIB       = tmglib.a\n')
-    g.write('SUPERLULIB   = $(SuperLUroot)/lib/libsuperlu_4.2.a\n')
+    g.write('TMGLIB       = tmglib.'+self.setCompilers.AR_LIB_SUFFIX+'\n')
+    g.write('SUPERLULIB   = $(SuperLUroot)/lib/libsuperlu_4.2.'+self.setCompilers.AR_LIB_SUFFIX+'\n')
     g.write('BLASLIB      = '+self.libraries.toString(self.blasLapack.dlib)+'\n')
     g.write('BLASDEF      = -DUSE_VENDOR_BLAS\n')
     g.write('LIBS         = $(SUPERLULIB) $(BLASLIB)\n')
         self.logPrintBox('Compiling superlu; this may take several minutes')
         if not os.path.exists(os.path.join(self.packageDir,'lib')):
           os.makedirs(os.path.join(self.packageDir,'lib'))
-        output,err,ret = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make clean && make lib LAAUX="" SLASRC="" DLASRC="" CLASRC="" ZLASRC="" SCLAUX="" DZLAUX="" && cp -f lib/*.a '+os.path.join(self.installDir,self.libdir,'')+' &&  cp -f SRC/*.h '+os.path.join(self.installDir,self.includedir,''), timeout=2500, log = self.framework.log)
+        output,err,ret = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make clean && make superlulib LAAUX="" SLASRC="" DLASRC="" CLASRC="" ZLASRC="" SCLAUX="" DZLAUX="" && cp -f lib/*.'+self.setCompilers.AR_LIB_SUFFIX+' '+os.path.join(self.installDir,self.libdir,'')+' &&  cp -f SRC/*.h '+os.path.join(self.installDir,self.includedir,''), timeout=2500, log = self.framework.log)
       except RuntimeError, e:
         raise RuntimeError('Error running make on SUPERLU: '+str(e))
       self.postInstall(output+err,'make.inc')

config/PETSc/packages/SuperLU_DIST.py

     self.functions  = ['set_default_options_dist']
     self.includes   = ['superlu_ddefs.h']
     self.liblist    = [['libsuperlu_dist_2.5.a']]
-    #
     #  SuperLU_dist supports 64 bit integers but uses ParMetis which does not, see the comment in ParMetis.py
     #  in the method configureLibrary()
     self.requires32bitint = 0
     self.complex          = 1
+    # SuperLU_Dist does not work with --download-f-blas-lapack with Compaqf90 compiler on windows.
+    # However it should work with intel ifort.
+    self.worksonWindows   = 1
+    self.downloadonWindows= 1
     return
 
   def setupDependencies(self, framework):
 
     g = open(os.path.join(self.packageDir,'make.inc'),'w')
     g.write('DSuperLUroot = '+self.packageDir+'\n')
-    g.write('DSUPERLULIB  = $(DSuperLUroot)/libsuperlu_dist_2.5.a\n')
+    g.write('DSUPERLULIB  = $(DSuperLUroot)/libsuperlu_dist_2.5.'+self.setCompilers.AR_LIB_SUFFIX+'\n')
     g.write('BLASDEF      = -DUSE_VENDOR_BLAS\n')
     g.write('BLASLIB      = '+self.libraries.toString(self.blasLapack.dlib)+'\n')
     g.write('IMPI         = '+self.headers.toString(self.mpi.include)+'\n')
         self.logPrintBox('Compiling superlu_dist; this may take several minutes')
         if not os.path.exists(os.path.join(self.packageDir,'lib')):
           os.makedirs(os.path.join(self.packageDir,'lib'))
-        output,err,ret  = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make clean && make lib LAAUX="" && mv -f *.a '+os.path.join(self.installDir,self.libdir,'')+' && cp -f SRC/*.h '+os.path.join(self.installDir,self.includedir,''), timeout=2500, log = self.framework.log)
+        output,err,ret  = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make clean && make lib LAAUX="" && mv -f *.'+self.setCompilers.AR_LIB_SUFFIX+' '+os.path.join(self.installDir,self.libdir,'')+' && cp -f SRC/*.h '+os.path.join(self.installDir,self.includedir,''), timeout=2500, log = self.framework.log)
       except RuntimeError, e:
         raise RuntimeError('Error running make on SUPERLU_DIST: '+str(e))
       self.postInstall(output+err,'make.inc')

config/PETSc/packages/X11.py

       if libraryDir:
         self.lib     = ['-L'+libraryDir,'-lX11']
       else:
-        self.lib     = '-lX11'
+        self.lib     = ['-lX11']
 
       self.addSubstitution('X_CFLAGS',     self.include)
       self.addSubstitution('X_LIBS',       self.lib)

config/PETSc/packages/afterimage.py

     self.includedir    = ''
     self.libdir        = '../../lib'
     self.double        = 0
+    self.complex       = 1
 
   def setupDependencies(self, framework):
     PETSc.package.NewPackage.setupDependencies(self, framework)

config/PETSc/packages/fftw.py

 class Configure(PETSc.package.NewPackage):
   def __init__(self, framework):
     PETSc.package.NewPackage.__init__(self, framework)
-    self.download  = ['http://www.fftw.org/fftw-3.3.1-beta1.tar.gz']
+    self.download  = ['http://www.fftw.org/fftw-3.3.1.tar.gz']
     self.functions = ['fftw_malloc'] 
     self.includes  = ['fftw3-mpi.h']  
     self.liblist   = [['libfftw3_mpi.a','libfftw3.a']]

config/PETSc/packages/hypre.py

     self.includes  = ['HYPRE.h']
     self.liblist   = [['libHYPRE.a']]
     self.license   = 'https://computation.llnl.gov/casc/linear_solvers/sls_hypre.html'
+    # Per hypre users guide section 7.5 - install manually on windows for MS compilers.
+    self.worksonWindows   = 1
+    self.downloadonWindows= 0
+
     return
 
   def setupDependencies(self, framework):

config/PETSc/packages/imagemagick.py

   def __init__(self, framework):
     PETSc.package.NewPackage.__init__(self, framework)
     self.functions     = ['IsMagickInstantiated']
-    self.includes      = ['MagicCore/MagickCore.h']
-    self.liblist       = [['libMagicCore.a']]
+    self.includes      = ['magick/MagickCore.h']
+    self.liblist       = [['libMagickCore.a']]
 
 
 

config/PETSc/packages/sowing.py

 class Configure(PETSc.package.NewPackage):
   def __init__(self, framework):
     PETSc.package.NewPackage.__init__(self, framework)
-    self.download          = ['http://ftp.mcs.anl.gov/pub/petsc/externalpackages/sowing-1.1.16b.tar.gz']
+    self.download          = ['http://ftp.mcs.anl.gov/pub/petsc/externalpackages/sowing-1.1.16c.tar.gz']
     self.complex           = 1
     self.double            = 0
     self.requires32bitint  = 0
   def setupHelp(self, help):
     import nargs
     PETSc.package.NewPackage.setupHelp(self, help)
-    help.addArgument('SOWING', '--download-sowing-cc=<prog>',                     nargs.Arg(None, None, 'C compiler for sowing configure'))
-    help.addArgument('SOWING', '--download-sowing-cxx=<prog>',                    nargs.Arg(None, None, 'CXX compiler for sowing configure'))
-    help.addArgument('SOWING', '--download-sowing-cpp=<prog>',                    nargs.Arg(None, None, 'CPP for sowing configure'))
-    help.addArgument('SOWING', '--download-sowing-cxxcpp=<prog>',                 nargs.Arg(None, None, 'CXX CPP for sowing configure'))
-    help.addArgument('SOWING', '--download-sowing-configure-options=<options>',   nargs.Arg(None, None, 'additional options for sowing configure'))
+    help.addArgument('SOWING', '-download-sowing-cc=<prog>',                     nargs.Arg(None, None, 'C compiler for sowing configure'))
+    help.addArgument('SOWING', '-download-sowing-cxx=<prog>',                    nargs.Arg(None, None, 'CXX compiler for sowing configure'))
+    help.addArgument('SOWING', '-download-sowing-cpp=<prog>',                    nargs.Arg(None, None, 'CPP for sowing configure'))
+    help.addArgument('SOWING', '-download-sowing-cxxcpp=<prog>',                 nargs.Arg(None, None, 'CXX CPP for sowing configure'))
+    help.addArgument('SOWING', '-download-sowing-configure-options=<options>',   nargs.Arg(None, None, 'additional options for sowing configure'))
     return
 
   def Install(self):

config/PETSc/utilities/scalarTypes.py

     elif self.precision == 'double':
       self.addDefine('USE_REAL_DOUBLE', '1')
     elif self.precision == '__float128':  # supported by gcc 4.6
-      self.addDefine('USE_REAL___FLOAT128', '1')
-      self.libraries.add('quadmath','logq',prototype='#include <quadmath.h>',call='__float128 f; logq(f);')
+      if self.libraries.add('quadmath','logq',prototype='#include <quadmath.h>',call='__float128 f; logq(f);'):
+        self.addDefine('USE_REAL___FLOAT128', '1')
+      else:
+        raise RuntimeError('quadmath support not found. --with-precision=__float128 works with gcc-4.6 and newer compilers.')
     else:
       raise RuntimeError('--with-precision must be single, double, longdouble')
     self.framework.logPrint('Precision is '+str(self.precision))

config/cmakeboot.py

  def cmakeboot(self, args, log):
    self.setup()
    options = deque()
+
+   output,error,retcode = self.executeShellCommand([self.cmake.cmake, '--version'], checkCommand=noCheck, log=log)
+   import re
+   m = re.match(r'cmake version (.+)$', output)
+   if not m:
+       self.logPrintBox('Could not parse CMake version: %s, falling back to legacy build' % output)
+       return False
+   from distutils.version import LooseVersion
+   version = LooseVersion(m.groups()[0])
+   if version < LooseVersion('2.6.2'):
+       self.logPrintBox('CMake version %s < 2.6.2, falling back to legacy build' % version.vstring)
+       return False
+   if self.languages.clanguage == 'Cxx' and version < LooseVersion('2.8'):
+       self.logPrintBox('Cannot use --with-clanguage=C++ with CMake version %s < 2.8, falling back to legacy build' % version.vstring)
+       return False # no support for: set_source_files_properties(${file} PROPERTIES LANGUAGE CXX)
+
    langlist = [('C','C')]
    if hasattr(self.compilers,'FC'):
      langlist.append(('FC','Fortran'))

config/install.py

     self.rootDir    = self.petscdir.dir
     self.destDir    = os.path.abspath(self.argDB['destDir'])
     self.installDir = self.framework.argDB['prefix']
-    print self.installDir
     self.arch       = self.arch.arch
     self.rootIncludeDir    = os.path.join(self.rootDir, 'include')
     self.archIncludeDir    = os.path.join(self.rootDir, self.arch, 'include')
     if os.path.splitext(dst)[1] == '.dylib' and os.path.isfile('/usr/bin/install_name_tool'):
       installName = re.sub(self.destDir, self.installDir, dst)
       self.executeShellCommand('/usr/bin/install_name_tool -id ' + installName + ' ' + dst)
+    # preserve the original timestamps - so that the .a vs .so time order is preserved
+    shutil.copystat(src,dst)
     return
 
   def installLib(self):

include/finclude/ftn-custom/makefile

+LOCDIR   = include/finclude/ftn-custom
+
 include ${PETSC_DIR}/conf/variables
 include ${PETSC_DIR}/conf/rules
 include ${PETSC_DIR}/conf/test

include/finclude/petscmat.h

 !
 !  Flags for PCSetOperators()
 !
-      PetscEnum SAME_NONZERO_PATTERN
       PetscEnum DIFFERENT_NONZERO_PATTERN
-      PetscEnum SAME_PRECONDITIONER
       PetscEnum SUBSET_NONZERO_PATTERN
+      PetscEnum SAME_NONZERO_PATTERN
+      PetscEnum SAME_PRECONDITIONER
 
-      parameter (SAME_NONZERO_PATTERN = 0,DIFFERENT_NONZERO_PATTERN = 1)
-      parameter (SAME_PRECONDITIONER = 2,SUBSET_NONZERO_PATTERN=3)
+      parameter (DIFFERENT_NONZERO_PATTERN = 0,SUBSET_NONZERO_PATTERN=1)
+      parameter (SAME_NONZERO_PATTERN = 2,SAME_PRECONDITIONER = 3)
 #if !(PETSC_USE_FORTRAN_DATATYPES_)
 #include "finclude/petscmatinfosize.h"
 #endif

include/finclude/petscsysdef.h

 #if defined (PETSC_MISSING_DREAL)
 #define PetscRealPart(a) real(a)
 #define PetscConj(a) conjg(a)
-#define PetscImaginaryPart(a) aimg(a)
+#define PetscImaginaryPart(a) aimag(a)
 #else
 #define PetscRealPart(a) dreal(a)
 #define PetscConj(a) dconjg(a)
-#define PetscImaginaryPart(a) daimg(a)
+#define PetscImaginaryPart(a) daimag(a)
 #endif
 #else
 #if defined (PETSC_USE_REAL_SINGLE)

include/finclude/petscts.h

 !
       external TSDEFAULTCOMPUTEJACOBIAN
       external TSDEFAULTCOMPUTEJACOBIANCOLOR
+      external TSCOMPUTERHSFUNCTIONLINEAR
+      external TSCOMPUTERHSJACOBIANCONSTANT
+      external TSCOMPUTEIFUNCTIONLINEAR
+      external TSCOMPUTEIJACOBIANCONSTANT
 
 !  End of Fortran include file for the TS package in PETSc
 

include/finclude/petsctsdef.h

 #define TSSSP             'ssp'
 #define TSARKIMEX         'arkimex'
 
+#define TSSSPType character*(80)
+#define TSSSPRKS2  'rks2'
+#define TSSSPRKS3  'rks3'
+#define TSSSPRK104 'rk104'
+
+#define TSGLAdaptType character*(80)
 #define TSGLADAPT_NONE 'none'
 #define TSGLADAPT_SIZE 'size'
 #define TSGLADAPT_BOTH 'both'
 
+#define TSARKIMEXType character*(80)
 #define TSARKIMEX2D '2d'
 #define TSARKIMEX2E '2e'
 #define TSARKIMEX3  '3'

include/finclude/petscviewer.h

       PetscEnum PETSC_VIEWER_ASCII_MATHEMATICA
       PetscEnum PETSC_VIEWER_ASCII_IMPL
       PetscEnum PETSC_VIEWER_ASCII_INFO
-      PetscEnum PETSC_VIEWER_ASCII_INFO_DETAIL 
+      PetscEnum PETSC_VIEWER_ASCII_INFO_DETAIL
       PetscEnum PETSC_VIEWER_ASCII_COMMON
       PetscEnum PETSC_VIEWER_ASCII_SYMMODU
       PetscEnum PETSC_VIEWER_ASCII_INDEX
       PetscEnum PETSC_VIEWER_ASCII_VTK_CELL
       PetscEnum PETSC_VIEWER_ASCII_VTK_COORDS
       PetscEnum PETSC_VIEWER_ASCII_PCICE
-      PetscEnum PETSC_VIEWER_ASCII_PYLITH
-      PetscEnum PETSC_VIEWER_ASCII_PYLITH_LOCAL
       PetscEnum PETSC_VIEWER_ASCII_PYTHON
       PetscEnum PETSC_VIEWER_ASCII_FACTOR_INFO
+      PetscEnum PETSC_VIEWER_DRAW_BASIC
+      PetscEnum PETSC_VIEWER_DRAW_LG
+      PetscEnum PETSC_VIEWER_DRAW_CONTOUR
+      PetscEnum PETSC_VIEWER_DRAW_PORTS
+      PetscEnum PETSC_VIEWER_NATIVE
+      PetscEnum PETSC_VIEWER_NOFORMAT
 
       parameter (PETSC_VIEWER_DEFAULT = 0)
       parameter (PETSC_VIEWER_ASCII_MATLAB = 1)
       parameter (PETSC_VIEWER_ASCII_VTK_CELL = 12)
       parameter (PETSC_VIEWER_ASCII_VTK_COORDS = 13)
       parameter (PETSC_VIEWER_ASCII_PCICE = 14)