/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * This file is distributed subject to a Software License Agreement found * in the file LICENSE that is included with this distribution. \*************************************************************************/ /* program: sddsseparate * purpose: takes an SDDS file with many columns in one page and * separates the columns onto multiple pages, under common names. * * $Log: sddsseparate.c,v $ * Revision 1.9 2007/06/26 20:29:39 shang * fixed the bug in the loop of checking datatypes of original columns which caused it * does not accept more than one columns. * * Revision 1.8 2006/12/14 22:22:00 soliday * Updated a bunch of programs because SDDS_SaveLayout is now called by * SDDS_WriteLayout and it is no longer required to be called directly. * Also the AutoCheckMode is turned off by default now so I removed calls to * SDDS_SetAutoCheckMode that would attempt to turn it off. It is now up to * the programmer to turn it on in new programs until debugging is completed * and then remove the call to SDDS_SetAutoCheckMode. * * Revision 1.7 2005/11/07 21:48:11 soliday * Updated to remove Linux compiler warnings. * * Revision 1.6 2005/11/04 22:46:18 soliday * Updated code to be compiled by a 64 bit processor. * * Revision 1.5 2004/01/26 02:36:52 borland * Removed initialization for variable defined in a for loop; the compiler * is incorrectly initializing the variable on each pass through the loop. * * Revision 1.4 2003/09/02 19:16:07 soliday * Cleaned up code for Linux. * * Revision 1.3 2003/02/19 18:10:46 soliday * Fixed nameing conflict with Borland C * * Revision 1.2 2002/08/14 17:12:54 soliday * Added Open License * * Revision 1.1 2001/10/28 01:06:50 borland * First version. * * */ #include "mdb.h" #include "SDDS.h" #include "scan.h" typedef struct { char *newName, **usersOldName, **oldName, *parameterName; long usersOldNames; int32_t oldNames; } GROUPS; #define SET_GROUP 0 #define SET_COPY 1 #define SET_PIPE 2 #define N_OPTIONS 3 char *option[N_OPTIONS] = { "group", "copy", "pipe", }; static char *USAGE="sddsseparate [] []\n\ [-pipe=[input][,output]]\n\ [-group=,] [-copy=] \ \n\ Reorganizes the column data in the input so that data from different\n\ columns ends up on different pages. For each -group option, a column\n\ is created in the output that contains data from the columns \n\ on sequential pages. Columns named with the -copy option are duplicated on\n\ each page.\n\n\ Program by Michael Borland. (This is version 1, October 2001.)\n"; int main(int argc, char **argv) { char *input, *output; char **copyColumnName, **usersCopyColumnName; GROUPS *group; int32_t copyColumns; long usersCopyColumns, groups; long iArg, i, rows, readCode, items; unsigned long flags, pipeFlags; SCANNED_ARG *scArg; SDDS_DATASET SDDSin, SDDSout; SDDS_RegisterProgramName(argv[0]); argc = scanargs(&scArg, argc, argv); if (argc<2) bomb(USAGE, NULL); output = input = NULL; flags = pipeFlags = 0; group = NULL; copyColumnName = usersCopyColumnName = NULL; usersCopyColumns = copyColumns = groups = 0; for (iArg=1; iArg0) { if ((rows = SDDS_CountRowsOfInterest(&SDDSin))<0) SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors|SDDS_EXIT_PrintErrors); if (!rows) continue; for (i=0; i