Index: trunk/Ohana/src/relphot/src/TGroupOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/TGroupOps.c	(revision 41561)
+++ trunk/Ohana/src/relphot/src/TGroupOps.c	(revision 41562)
@@ -6,4 +6,5 @@
 // tgroupTimes carries the times of the tgroups (initially, just the photometric nights)
 static     int  NtgroupTimes = 0;
+static     int  NTGROUPTIMES = 0;
 static TGTimes **tgroupTimes = NULL;
 
@@ -59,5 +60,6 @@
   // given photcode, it is left empty (no images)
 
-  ALLOCATE (tgroupTimes, TGTimes *, NtgroupTimes);
+  NTGROUPTIMES = NtgroupTimes; // if we have loaded a list of times, use that as the starting alloc number
+  ALLOCATE (tgroupTimes, TGTimes *, NTGROUPTIMES);
 
   // the start of an MJD day is 14:00 HST, so the end time can be the start time + 23h 59m 59s (86399s)
@@ -118,11 +120,13 @@
 
   if (!TGROUP_ZEROPT) return;
-  myAssert (tgroupTimes, "oops, tgroupTimes not allocated");
 
   // index of the new entry
   int Ntgt = NtgroupTimes;
-
   NtgroupTimes ++;
-  REALLOCATE (tgroupTimes, TGTimes *, NtgroupTimes);
+
+  if (NtgroupTimes >= NTGROUPTIMES) {
+    NTGROUPTIMES += 100;
+    REALLOCATE (tgroupTimes, TGTimes *, NTGROUPTIMES);
+  }
   
   double mjd = ohana_sec_to_mjd (tzero);
@@ -187,4 +191,9 @@
    * internal construct that defines a group of related images 
    */
+
+  if (!tgroupTimes) {
+    NTGROUPTIMES = 100; 
+    ALLOCATE (tgroupTimes, TGTimes *, NTGROUPTIMES);
+  } 
 
   ALLOCATE (ImageToTGroup, TGroup *, Nsubset); // tgroup to which image belongs
@@ -362,4 +371,6 @@
 // assume a 1day range for now
 TGroup *findTGroup (unsigned int start, int photcode) {
+
+  if (!NtgroupTimes) return NULL; // if none are yet defined, do not even try
 
   // find index of matching photcode from our list of active secondary photcodes
Index: trunk/Ohana/src/relphot/src/args.c
===================================================================
--- trunk/Ohana/src/relphot/src/args.c	(revision 41561)
+++ trunk/Ohana/src/relphot/src/args.c	(revision 41562)
@@ -359,10 +359,17 @@
     TGROUP_ZEROPT = TRUE;
     remove_argument (N, &argc, argv);
-    TGROUP_FILENAME = strcreate(argv[N]);
-    remove_argument (N, &argc, argv);
     // if we fit for TGROUPS, start with the images and mosaics frozen
     TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_ALL;
     IMAGE_ZPT_MODE  = IMAGE_ZPT_MODE_NONE;
     MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_NONE;
+  }
+  if ((N = get_argument (argc, argv, "-tgroup-list"))) {
+    if (!TGROUP_ZEROPT) {
+      fprintf (stderr, "-tgroup-list (filename) requires -tgroup option\n");
+      exit (2);
+    }
+    remove_argument (N, &argc, argv);
+    TGROUP_FILENAME = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
   }
   if ((N = get_argument (argc, argv, "-tgroup")) || (N = get_argument (argc, argv, "-tgroups"))) {
@@ -567,5 +574,6 @@
   if (argc != 1) relphot_usage ();
 
-  if (TGROUP_ZEROPT) {
+  // if we supplied a file, we need to load it now
+  if (TGROUP_FILENAME) {
     loadTGroups (TGROUP_FILENAME);
     free (TGROUP_FILENAME);
