Index: trunk/ppSub/src/ppSubConvolve.c
===================================================================
--- trunk/ppSub/src/ppSubConvolve.c	(revision 28565)
+++ trunk/ppSub/src/ppSubConvolve.c	(revision 28566)
@@ -29,4 +29,7 @@
     )
 {
+    if (!name) {
+        return;
+    }
     psArray *files = psArrayAlloc(1); // Array with file names
     files->data[0] = psStringCopy(name);
@@ -53,7 +56,9 @@
         psMetadataAddStr(arguments, PS_LIST_TAIL, "-image", 0, "Input image", NULL);
         psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask", 0, "Input mask", NULL);
+        psMetadataAddStr(arguments, PS_LIST_TAIL, "-variance", 0, "Input variance", NULL);
         psMetadataAddStr(arguments, PS_LIST_TAIL, "-kernel", 0, "Convolution kernel", NULL);
         psMetadataAddBool(arguments, PS_LIST_TAIL, "-reference", 0, "Input is actually reference?", false);
         psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Threads to use", 0);
+        psMetadataAddBool(arguments, PS_LIST_TAIL, "-save-all", 0, "Save all outputs?", false);
 
         if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) {
@@ -63,4 +68,5 @@
         const char *inImage = psMetadataLookupStr(NULL, arguments, "-image"); // Input image
         const char *inMask = psMetadataLookupStr(NULL, arguments, "-mask"); // Input mask
+        const char *inVariance = psMetadataLookupStr(NULL, arguments, "-variance"); // Input variance
         const char *inKernel = psMetadataLookupStr(NULL, arguments, "-kernel"); // Input kernel
         if (!inImage || !inKernel) {
@@ -72,4 +78,5 @@
         fileList("PPSUB.INPUT", inImage, "Input image", config);
         fileList("PPSUB.INPUT.MASK", inMask, "Input mask", config);
+        fileList("PPSUB.INPUT.VARIANCE", inVariance, "Input variance", config);
         fileList("PPSUB.INPUT.KERNEL", inKernel, "Input kernel", config);
         psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]);
@@ -81,9 +88,19 @@
             goto die;
         }
-        pmFPAfile *mask = pmFPAfileBindFromArgs(&status, image, config, "PPSUB.INPUT.MASK",
-                                                "PPSUB.INPUT.MASK");
-        if (!mask || !status || mask->type != PM_FPA_FILE_MASK) {
-            psError(PPSUB_ERR_CONFIG, false, "Unable to define input mask file.");
-            goto die;
+        if (inMask) {
+            pmFPAfile *mask = pmFPAfileBindFromArgs(&status, image, config, "PPSUB.INPUT.MASK",
+                                                    "PPSUB.INPUT.MASK");
+            if (!mask || !status || mask->type != PM_FPA_FILE_MASK) {
+                psError(PPSUB_ERR_CONFIG, false, "Unable to define input mask file.");
+                goto die;
+            }
+        }
+        if (inVariance) {
+            pmFPAfile *variance = pmFPAfileBindFromArgs(&status, image, config, "PPSUB.INPUT.VARIANCE",
+                                                        "PPSUB.INPUT.VARIANCE");
+            if (!variance || !status || variance->type != PM_FPA_FILE_VARIANCE) {
+                psError(PPSUB_ERR_CONFIG, false, "Unable to define input variance file.");
+                goto die;
+            }
         }
 
@@ -101,4 +118,20 @@
         }
         output->save = true;
+
+        if (psMetadataLookupBool(NULL, arguments, "-save-all")) {
+            pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.INPUT.CONV.MASK");
+            if (!outMask || outMask->type != PM_FPA_FILE_MASK) {
+                psError(PPSUB_ERR_CONFIG, false, "Unable to define output mask file.");
+                goto die;
+            }
+            outMask->save = true;
+
+            pmFPAfile *outVar = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.INPUT.CONV.VARIANCE");
+            if (!outVar || outVar->type != PM_FPA_FILE_VARIANCE) {
+                psError(PPSUB_ERR_CONFIG, false, "Unable to define output variance file.");
+                goto die;
+            }
+            outVar->save = true;
+        }
     }
 
