Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 23365)
+++ trunk/ippTools/src/chiptool.c	(revision 23381)
@@ -209,5 +209,5 @@
             return false;
         }
-
+        //
         // queue the exp
         if (!pxchipQueueByExpTag(config, exp_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) {
@@ -415,4 +415,5 @@
     PXOPT_LOOKUP_F32(n_cr, config->args,       	   "-n_cr", false, false);
     PXOPT_LOOKUP_STR(path_base, config->args,  	   "-path_base", false, false);
+    PXOPT_LOOKUP_BOOL(magicked, config->args,  	   "-magicked", false);
 
     // default values
@@ -490,5 +491,5 @@
                                    path_base,
                                    code,
-                                   0    // magic_ds_id
+                                   magicked
             )) {
         // rollback
@@ -540,4 +541,5 @@
     PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
     PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE");
+    PXOPT_COPY_S32(config->args, where, "-magicked", "chipRun.magicked", "==");
 
     psString query = pxDataGet("chiptool_processedimfile.sql");
@@ -1137,6 +1139,6 @@
         }
 
-        // set chipRun.state to 'stop'
-        if (!pxchipRunSetState(config, chipRun->chip_id, "full")) {
+        // set chipRun.state to 'stop' and update the magicked state
+        if (!pxchipRunSetState(config, chipRun->chip_id, "full", chipRun->magicked)) {
             psError(PS_ERR_UNKNOWN, false, "failed to change chipRun.state for chip_id: %" PRId64, chipRun->chip_id);
             psFree(chipRun);
@@ -1209,6 +1211,12 @@
     }
 
-    // note only updates if chipRun.state = run_state
-    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) {
+    psString set_magic = "";
+    if (!strcmp(data_state, "full")) {
+        // copy the magicked state from the input to the output when transitioning to full state
+        set_magic = "\n , chipProcessedImfile.magicked = rawImfile.magicked";
+    }
+
+    if (!p_psDBRunQueryF(config->dbh, query, data_state, set_magic, chip_id, class_id)) {
+        psFree(query);
         psError(PS_ERR_UNKNOWN, false, "database error");
         // rollback
@@ -1227,4 +1235,5 @@
     query = pxDataGet("chiptool_change_exp_state.sql");
     if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, data_state)) {
+        psFree(query);
         // rollback
         if (!psDBRollback(config->dbh)) {
@@ -1234,4 +1243,5 @@
         return false;
     }
+    psFree(query);
 
     if (!psDBCommit(config->dbh)) {
Index: trunk/ippTools/src/chiptoolConfig.c
===================================================================
--- trunk/ippTools/src/chiptoolConfig.c	(revision 23365)
+++ trunk/ippTools/src/chiptoolConfig.c	(revision 23381)
@@ -147,4 +147,5 @@
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-path_base",  0,            "define base output location", NULL);
     psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddBool(addprocessedimfileArgs, PS_LIST_TAIL, "-magicked",  0,        "define magicked status", false);
 
     // -processedimfile
@@ -155,4 +156,5 @@
     psMetadataAddStr(processedimfileArgs,  PS_LIST_TAIL, "-reduction",          0, "search by reduction class", NULL);
     psMetadataAddStr(processedimfileArgs,  PS_LIST_TAIL, "-label",              0, "search by chipRun label (LIKE comparison)", NULL);
+    psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-magicked",  0,        "search by magicked status", false);
     pxchipSetSearchArgs(processedimfileArgs);
     psMetadataAddU64(processedimfileArgs, PS_LIST_TAIL, "-limit",  0,           "limit result set to N items", 0);
Index: trunk/ippTools/src/pxchip.h
===================================================================
--- trunk/ippTools/src/pxchip.h	(revision 23365)
+++ trunk/ippTools/src/pxchip.h	(revision 23381)
@@ -25,5 +25,5 @@
 #include "pxtools.h"
 
-bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state);
+bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked);
 bool pxchipRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state);
 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label);
