Added spinit file under custom/models to get the correct startup
options for ngspice.  Made a "create_project" script to create some
basic project subdirectories and seed them with links to the
appropriate startup files.  Modified the "preproc" script so that
it maintains the file permissions from input to output.
diff --git a/Makefile.in b/Makefile.in
index ac398c8..a98af99 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -80,11 +80,15 @@
 
 #---------------------------------------------------
 
+CPP = common/preproc.py
+
 common_install:
 	mkdir -p @prefix@/pdk/bin/
 	cp common/cleanup_unref.py @prefix@/pdk/bin/
 	cp common/soc_floorplanner.py @prefix@/pdk/bin/
-
+	${CPP} -DPREFIX=@prefix@ common/create_project.py \
+		@prefix@/pdk/bin/create_project.py
+	
 #---------------------------------------------------
 
 tech_sky130:
diff --git a/VERSION b/VERSION
index 75c0b87..9632c46 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.139
+1.0.140
diff --git a/common/create_project.py b/common/create_project.py
new file mode 100755
index 0000000..3c4cb4a
--- /dev/null
+++ b/common/create_project.py
@@ -0,0 +1,161 @@
+#!/usr/bin/env python3
+#-----------------------------------------------------------------------
+# create_project.py
+#-----------------------------------------------------------------------
+#
+# Create a project in the form preferred by open_pdks.
+#
+#---------------------------------------------------------------------
+# Written by Tim Edwards
+# March 15, 2021
+# Version 1.0
+#---------------------------------------------------------------------
+
+import os
+import re
+import sys
+import json
+
+def usage():
+    print('Usage:')
+    print('	create_project.py <project_name> [<pdk_name>] [-options]')
+    print('')
+    print('Arguments:')
+    print('	<project_name> is the name of the project and the top-level directory')
+    print('	<pdk_name> is the name of the PDK')
+    print('')
+    print('     <pdk_name> can be a full path to the PDK')
+    print('     <project_name> can be a full path to the project, otherwise use cwd.')
+    print('')
+    print('Options:')
+    print('	-help	Print this help text.')
+
+# Main procedure
+
+if __name__ == '__main__':
+
+    # Parse command line for options and arguments
+    optionlist = []
+    arguments = []
+    for item in sys.argv[1:]:
+        if item.find('-', 0) == 0:
+            optionlist.append(item)
+        else:
+            arguments.append(item)
+
+    if len(arguments) > 0:
+        projectname = arguments[0]
+        if len(arguments) > 1:
+            pdkname = arguments[1]
+        else:
+            pdkname = None
+    else:
+        usage()
+        sys.exit(0)
+
+    if pdkname:
+        if pdkname.startswith('/'):
+            pdkpath = pdkname
+        else:
+            pdkpath = os.path.join('PREFIX', 'pdk', pdkname)
+    else:
+        try:
+            pdkpath = os.getenv()['PDK_PATH']
+        except:
+            try:
+                pdkpath = os.getenv()['PDKPATH']
+            except:
+                print('If PDK name is not specified, then PDKPATH must be set.')
+                sys.exit(1)
+
+    if not os.path.isdir(pdkpath):
+        print('Path to PDK ' + pdkpath + ' does not exist or is not readable.')
+        sys.exit(1)
+
+    for item in optionlist:
+        result = item.split('=')
+        if result[0] == '-help':
+            usage()
+            sys.exit(0)
+        else:
+            usage()
+            sys.exit(1)
+
+    if projectname.startswith('/'):
+        projectpair = os.path.split(projectname)
+        projectparent = projectpair[0]
+        projectname = projectpair[1]
+    else:
+        projectparent = os.getcwd()
+
+    if not os.path.isdir(projectparent):
+        print('Path to project ' + projectpath + ' does not exist or is not readable.')
+        sys.exit(1)
+
+    projectpath = os.path.join(projectparent, projectname)
+
+    # Check that files to be linked to exist in the PDK
+    if not os.path.isfile(pdkpath + '/libs.tech/magic/' + pdkname + '.magicrc'):
+        print(pdkname + '.magicrc not found;  not installing.')
+        domagic = False
+    else:
+        domagic = True
+
+    if not os.path.isfile(pdkpath + '/libs.tech/netgen/' + pdkname + '_setup.tcl'):
+        print(pdkname + '_setup.tcl for netgen not found;  not installing.')
+        donetgen = False
+    else:
+        donetgen = True
+
+    if not os.path.isfile(pdkpath + '/libs.tech/xschem/xschemrc'):
+        print('xschemrc for xschem not found;  not installing.')
+        doxschem = False
+    else:
+        doxschem = True
+
+    if not os.path.isfile(pdkpath + '/libs.tech/ngspice/spinit'):
+        print('spinit for ngspice not found;  not installing.')
+        dongspice = False
+    else:
+        dongspice = True
+
+    if domagic or donetgen or doxschem or dongspice:
+        print('Creating project ' + projectname)
+        os.makedirs(projectpath)
+    else:
+        print('No setup files were found . . .  bailing.')
+        sys.exit(1)
+
+    if domagic:
+        magpath = os.path.join(projectpath, 'mag')
+        os.makedirs(magpath)
+        os.symlink(pdkpath + '/libs.tech/magic/' + pdkname + '.magicrc',
+		magpath + '/.magicrc')
+
+    if doxschem:
+        xschempath = os.path.join(projectpath, 'xschem')
+        os.makedirs(xschempath)
+        os.symlink(pdkpath + '/libs.tech/xschem/xschemrc',
+		xschempath + '/xschemrc')
+
+    if donetgen:
+        netgenpath = os.path.join(projectpath, 'netgen')
+        os.makedirs(netgenpath)
+        os.symlink(pdkpath + '/libs.tech/netgen/' + pdkname + '_setup.tcl',
+		netgenpath + '/setup.tcl')
+
+    if dongspice:
+        ngspicepath = os.path.join(projectpath, 'ngspice')
+        os.makedirs(ngspicepath)
+        os.symlink(pdkpath + '/libs.tech/ngspice/spinit',
+		ngspicepath + '/.spiceinit')
+
+    with open(projectpath + '/info.yaml', 'w') as ofile:
+        print('---', file=ofile)
+        print('project:', file=ofile)
+        print('   description: "(Add project description here)"', file=ofile)
+        print('   process: "' + pdkname + '"', file=ofile)
+        print('   project_name: "' + projectname + '"', file=ofile)
+        
+    print('Done!')
+    sys.exit(0)
diff --git a/common/preproc.py b/common/preproc.py
index 709ea11..9612921 100755
--- a/common/preproc.py
+++ b/common/preproc.py
@@ -584,4 +584,11 @@
     runpp(keys, keyrex, defines, ccomm, incdirs, inputfile, ofile)
     if ofile != sys.stdout:
         ofile.close()
+
+    # Set mode of outputfile to be equal to that of inputfile (if not stdout)
+    if outputfile:
+        statinfo = os.stat(inputfile)
+        mode = statinfo.st_mode
+        os.chmod(outputfile, mode)
+
     sys.exit(0)
diff --git a/sky130/Makefile.in b/sky130/Makefile.in
index 2d94f6d..2557f6b 100644
--- a/sky130/Makefile.in
+++ b/sky130/Makefile.in
@@ -382,109 +382,19 @@
 
 all-a: prerequisites
 	echo "Starting sky130A PDK staging on "`date` > ${SKY130A}_make.log
+	${MAKE} general-a
 	${MAKE} tools-a
 	${MAKE} vendor-a
 	echo "Ended sky130A PDK staging on "`date` >> ${SKY130A}_make.log
 
-tools-a: $(addsuffix -a, $(TOOLS))
-
 general-a: ${TECH}.json
 	mkdir -p ${STAGING_PATH}/${SKY130A}/${CONFIG_DIR}
 	rm -f ${STAGING_PATH}/${SKY130A}/${CONFIG_DIR}/nodeinfo.json
 	${CPP} ${SKY130A_DEFS} ${TECH}.json \
 		${STAGING_PATH}/${SKY130A}/${CONFIG_DIR}/nodeinfo.json
 
-magic-a: magic/${TECH}.tech magic/${TECH}gds.tech magic/${TECH}.magicrc magic/${TECH}.tcl
-	mkdir -p ${MAGICTOP_STAGING_A}
-	mkdir -p ${MAGIC_STAGING_A}
-	rm -f ${MAGICTOP_STAGING_A}/current
-	rm -f ${MAGIC_STAGING_A}/${SKY130A}.tech
-	rm -f ${MAGIC_STAGING_A}/${SKY130A}-GDS.tech
-	rm -f ${MAGIC_STAGING_A}/${SKY130A}.tcl
-	rm -f ${MAGIC_STAGING_A}/${SKY130A}-BindKeys
-	rm -f ${MAGIC_STAGING_A}/magicrc
-	if "${EF_STYLE}" == "1" ; then \
-	    (cd ${MAGICTOP_STAGING_A} ; ln -s ${REV_DIR} current) ; \
-	fi
-	cp -rp custom/scripts/seal_ring_generator ${MAGIC_STAGING_A}/.
-	cp -rp custom/scripts/bump_bond_generator ${MAGIC_STAGING_A}/.
-	cp custom/scripts/generate_fill.py ${MAGIC_STAGING_A}/.
-	cp custom/scripts/check_density.py ${MAGIC_STAGING_A}/.
-	${CPP} ${SKY130A_DEFS} magic/${TECH}.tech ${MAGIC_STAGING_A}/${SKY130A}.tech
-	${CPP} ${SKY130A_DEFS} magic/${TECH}gds.tech ${MAGIC_STAGING_A}/${SKY130A}-GDS.tech
-	${CPP} ${SKY130A_DEFS} magic/${TECH}.magicrc ${MAGIC_STAGING_A}/${SKY130A}.magicrc
-	${CPP} ${SKY130A_DEFS} ../common/pdk.bindkeys ${MAGIC_STAGING_A}/${SKY130A}-BindKeys
-	${CPP} ${SKY130A_DEFS} magic/${TECH}.tcl ${MAGIC_STAGING_A}/${SKY130A}.tcl
-	${CPP} ${SKY130A_DEFS} ../common/pdk.tcl >> ${MAGIC_STAGING_A}/${SKY130A}.tcl
-
-qflow-a: qflow/${TECH}.sh qflow/${TECH}.par
-	mkdir -p ${QFLOWTOP_STAGING_A}
-	mkdir -p ${QFLOW_STAGING_A}
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hd.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hd.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hdll.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hdll.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hs.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hs.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hvl.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}hvl.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}ls.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}ls.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}lp.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}lp.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}ms.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}ms.par
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}osu.sh
-	rm -f ${QFLOW_STAGING_A}/${SKY130A}osu.par
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_hd qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}hd.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_hdll qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}hdll.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_hvl qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}hvl.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_hs qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}hs.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_lp qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}lp.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_ls qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}ls.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_fd_sc_ms qflow/${TECH}.sh \
-		${QFLOW_STAGING_A}/${SKY130A}ms.sh
-	${CPP} ${SKY130A_DEFS} -DLIBRARY=sky130_osu_sc_t18 qflow/sky130osu.sh \
-		${QFLOW_STAGING_A}/${SKY130A}osu.sh
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}hd.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}hdll.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}hvl.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}hs.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}ms.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}lp.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}ls.par
-	${CPP} ${SKY130A_DEFS} qflow/${TECH}.par ${QFLOW_STAGING_A}/${SKY130A}osu.par
-
-xschem-repo:
-	if test "x${XSCHEM_PATH}" != "x" ; then \
-		if test -d "${XSCHEM_PATH}" ; then \
-			echo "Using existing installation of xschem setup from ${XSCHEM_PATH}" ; \
-		else \
-			echo "Downloading xschem setup from ${XSCHEM_URL}" ; \
-			../scripts/download.sh ${XSCHEM_URL} ${XSCHEM_PATH} ; \
-		fi ; \
-	fi
-
-all-a: prerequisites
-	echo "Starting sky130A PDK staging on "`date` > ${SKY130A}_make.log
-	${MAKE} tools-a
-	${MAKE} vendor-a
-	echo "Ended sky130A PDK staging on "`date` >> ${SKY130A}_make.log
-
 tools-a: $(addsuffix -a, $(TOOLS))
 
-general-a: ${TECH}.json
-	mkdir -p ${STAGING_PATH}/${SKY130A}/${CONFIG_DIR}
-	rm -f ${STAGING_PATH}/${SKY130A}/${CONFIG_DIR}/nodeinfo.json
-	${CPP} ${SKY130A_DEFS} ${TECH}.json \
-		${STAGING_PATH}/${SKY130A}/${CONFIG_DIR}/nodeinfo.json
-
 magic-a: magic/${TECH}.tech magic/${TECH}gds.tech magic/${TECH}.magicrc magic/${TECH}.tcl
 	mkdir -p ${MAGICTOP_STAGING_A}
 	mkdir -p ${MAGIC_STAGING_A}
@@ -698,6 +608,10 @@
 	patch -p1 -f -d ${STAGING_PATH}/${SKY130A} \
 		< custom/patches/sky130_fd_pr.patch \
 		2>&1 | tee -a ${SKY130A}_make.log || true
+	# Custom:  Add "spinit" file
+	cat ./custom/models/spinit >> \
+		${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/spinit
+
 	# Install custom additions to I/O pad library
 	${STAGE} -source ./custom -target ${STAGING_PATH}/${SKY130A} \
 		-verilog %l/verilog/*.v \
diff --git a/sky130/custom/models/spinit b/sky130/custom/models/spinit
new file mode 100644
index 0000000..4f4b2f1
--- /dev/null
+++ b/sky130/custom/models/spinit
@@ -0,0 +1,3 @@
+* ngspice initialization for sky130
+* assert BSIM compatibility mode with "nf" vs. "W"
+set ngbehavior=spe