Changeset 37067 for branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi
- Timestamp:
- Jul 17, 2014, 12:32:26 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-ops-20130712/Ohana
- Files:
-
- 72 edited
- 19 copied
-
. (modified) (1 prop)
-
src/opihi (modified) (1 prop)
-
src/opihi/cmd.astro (modified) (1 prop)
-
src/opihi/cmd.astro/Makefile (modified) (2 diffs)
-
src/opihi/cmd.astro/cdensify.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/cdensify.c )
-
src/opihi/cmd.astro/fitplx.c (modified) (6 diffs)
-
src/opihi/cmd.astro/fitpm.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/fitpm.c )
-
src/opihi/cmd.astro/gauss.c (modified) (3 diffs)
-
src/opihi/cmd.astro/init.c (modified) (4 diffs)
-
src/opihi/cmd.astro/region.c (modified) (1 diff)
-
src/opihi/cmd.astro/sersic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/sersic.c )
-
src/opihi/cmd.astro/star.c (modified) (2 diffs)
-
src/opihi/cmd.basic/Makefile (modified) (1 diff)
-
src/opihi/cmd.basic/init.c (modified) (2 diffs)
-
src/opihi/cmd.basic/list.c (modified) (9 diffs)
-
src/opihi/cmd.basic/strmatch.c (copied) (copied from trunk/Ohana/src/opihi/cmd.basic/strmatch.c )
-
src/opihi/cmd.data (modified) (1 prop)
-
src/opihi/cmd.data/Makefile (modified) (5 diffs)
-
src/opihi/cmd.data/cast.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/cast.c )
-
src/opihi/cmd.data/densify.c (modified) (5 diffs)
-
src/opihi/cmd.data/impeaks.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/impeaks.c )
-
src/opihi/cmd.data/imsmooth.2d.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.2d.c )
-
src/opihi/cmd.data/imsmooth.generic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.generic.c )
-
src/opihi/cmd.data/init.c (modified) (10 diffs)
-
src/opihi/cmd.data/join.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/join.c )
-
src/opihi/cmd.data/match2d.c (modified) (3 diffs)
-
src/opihi/cmd.data/medimage.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage.c )
-
src/opihi/cmd.data/medimage_commands.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage_commands.c )
-
src/opihi/cmd.data/print_vectors.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/print_vectors.c )
-
src/opihi/cmd.data/read_vectors.c (modified) (20 diffs)
-
src/opihi/cmd.data/rebin.c (modified) (1 diff)
-
src/opihi/cmd.data/test/join.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/join.sh )
-
src/opihi/cmd.data/test/medimage.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/medimage.sh )
-
src/opihi/cmd.data/vellipse.c (modified) (1 diff)
-
src/opihi/cmd.data/vgauss.c (modified) (2 diffs)
-
src/opihi/cmd.data/vlist.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vlist.c )
-
src/opihi/dvo/Makefile (modified) (2 diffs)
-
src/opihi/dvo/avextract.c (modified) (1 diff)
-
src/opihi/dvo/avmatch.c (modified) (3 diffs)
-
src/opihi/dvo/coordimage.c (copied) (copied from trunk/Ohana/src/opihi/dvo/coordimage.c )
-
src/opihi/dvo/coordmosaic.c (copied) (copied from trunk/Ohana/src/opihi/dvo/coordmosaic.c )
-
src/opihi/dvo/dvo_client.c (modified) (1 diff)
-
src/opihi/dvo/find_matches.c (modified) (1 diff)
-
src/opihi/dvo/fitsed.c (modified) (1 diff)
-
src/opihi/dvo/gimages.c (modified) (1 diff)
-
src/opihi/dvo/gstar.c (modified) (11 diffs)
-
src/opihi/dvo/hosts.c (modified) (8 diffs)
-
src/opihi/dvo/imdata.c (modified) (4 diffs)
-
src/opihi/dvo/imextract.c (modified) (1 diff)
-
src/opihi/dvo/init.c (modified) (2 diffs)
-
src/opihi/dvo/lcurve.c (modified) (1 diff)
-
src/opihi/dvo/lightcurve.c (modified) (1 diff)
-
src/opihi/dvo/photcode_ops.c (copied) (copied from trunk/Ohana/src/opihi/dvo/photcode_ops.c )
-
src/opihi/dvo/photometry.c (modified) (13 diffs)
-
src/opihi/dvo/pmeasure.c (modified) (1 diff)
-
src/opihi/dvo/showtile.c (modified) (1 diff)
-
src/opihi/dvo/simage.c (modified) (1 diff)
-
src/opihi/dvo/subpix.c (modified) (1 diff)
-
src/opihi/include/data.h (modified) (4 diffs)
-
src/opihi/include/dvomath.h (modified) (3 diffs)
-
src/opihi/include/dvoshell.h (modified) (1 diff)
-
src/opihi/include/pantasks.h (modified) (2 diffs)
-
src/opihi/include/pcontrol.h (modified) (3 diffs)
-
src/opihi/include/shell.h (modified) (1 diff)
-
src/opihi/lib.data/Makefile (modified) (1 diff)
-
src/opihi/lib.data/MedImageOps.c (copied) (copied from trunk/Ohana/src/opihi/lib.data/MedImageOps.c )
-
src/opihi/lib.data/starfuncs.c (modified) (2 diffs)
-
src/opihi/lib.shell/ListOps.c (modified) (1 diff)
-
src/opihi/lib.shell/VectorIO.c (modified) (3 diffs)
-
src/opihi/lib.shell/check_stack.c (modified) (5 diffs)
-
src/opihi/lib.shell/convert_to_RPN.c (modified) (6 diffs)
-
src/opihi/lib.shell/dvomath.c (modified) (1 diff)
-
src/opihi/lib.shell/evaluate_stack.c (modified) (7 diffs)
-
src/opihi/lib.shell/macro_list.c (modified) (1 diff)
-
src/opihi/lib.shell/stack_math.c (modified) (62 diffs)
-
src/opihi/lib.shell/string.c (modified) (1 diff)
-
src/opihi/pantasks/CheckController.c (modified) (2 diffs)
-
src/opihi/pantasks/ControllerOps.c (modified) (1 diff)
-
src/opihi/pantasks/JobOps.c (modified) (1 diff)
-
src/opihi/pantasks/LocalJob.c (modified) (1 diff)
-
src/opihi/pantasks/TaskOps.c (modified) (1 diff)
-
src/opihi/pantasks/init.c (modified) (1 diff)
-
src/opihi/pantasks/init_server.c (modified) (1 diff)
-
src/opihi/pantasks/task_nice.c (modified) (2 diffs)
-
src/opihi/pclient/job.c (modified) (2 diffs)
-
src/opihi/pcontrol/CheckBusyJob.c (modified) (1 diff)
-
src/opihi/pcontrol/JobOps.c (modified) (3 diffs)
-
src/opihi/pcontrol/StartJob.c (modified) (1 diff)
-
src/opihi/pcontrol/job.c (modified) (4 diffs)
-
src/opihi/pcontrol/jobstack.c (modified) (1 diff)
-
src/opihi/pcontrol/status.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-ops-20130712/Ohana
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/Makefile
r35416 r37067 28 28 $(SRC)/cval.$(ARCH).o \ 29 29 $(SRC)/czplot.$(ARCH).o \ 30 $(SRC)/cdensify.$(ARCH).o \ 30 31 $(SRC)/drizzle.$(ARCH).o \ 31 32 $(SRC)/flux.$(ARCH).o \ 32 33 $(SRC)/fitplx.$(ARCH).o \ 34 $(SRC)/fitpm.$(ARCH).o \ 33 35 $(SRC)/fixwrap.$(ARCH).o \ 34 36 $(SRC)/fixcols.$(ARCH).o \ … … 60 62 $(SRC)/scale.$(ARCH).o \ 61 63 $(SRC)/sexigesimal.$(ARCH).o \ 64 $(SRC)/sersic.$(ARCH).o \ 62 65 $(SRC)/spec.$(ARCH).o \ 63 66 $(SRC)/specpairfit.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/fitplx.c
r35416 r37067 41 41 remove_argument (N, &argc, argv); 42 42 VERBOSE = TRUE; 43 } 44 if ((N = get_argument (argc, argv, "-vv"))) { 45 remove_argument (N, &argc, argv); 46 VERBOSE = 2; 43 47 } 44 48 … … 108 112 coords.pc1_2 = coords.pc2_1 = 0.0; 109 113 coords.Npolyterms = 1; 110 strcpy (coords.ctype, " RA---SIN");114 strcpy (coords.ctype, "DEC--SIN"); 111 115 112 116 double *X, *Y, *t, *pX, *pY, *dX, *dY; … … 145 149 146 150 PlxFit fit; 147 FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE); 151 if (!FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE)) { 152 return FALSE; 153 } 148 154 149 155 // fprintf (stderr, "Roff, Doff: %f, %f; dRo, dDo: %f, %f\n", fit.Ro, fit.Do, fit.dRo, fit.dDo); … … 204 210 for (i = 0; i < Npts; i++) { 205 211 206 if (VERBOSE ) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], dX[i], Y[i], dY[i], T[i], pR[i], pD[i]);212 if (VERBOSE == 2) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], dX[i], Y[i], dY[i], T[i], pR[i], pD[i]); 207 213 208 214 /* handle case where dX or dY = 0.0 */ 209 wx = 1.0 / SQ(dX[i]);210 wy = 1.0 / SQ(dY[i]);215 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 216 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 211 217 212 218 Wx += wx; … … 266 272 B[4][0] = PRX + PDY; 267 273 268 dgaussjordan ((double **)A, (double **)B, 5, 1); 274 if (!dgaussjordan ((double **)A, (double **)B, 5, 1)) { 275 if (VERBOSE) fprintf (stderr, "error in fit\n"); 276 if (VERBOSE == 2) { 277 int j; 278 for (i = 0; i < 5; i++) { 279 for (j = 0; j < 5; j++) { 280 fprintf (stderr, "%e ", A[i][j]); 281 } 282 fprintf (stderr, " : %e\n", A[i][0]); 283 } 284 } 285 return FALSE; 286 } 269 287 270 288 fit[0].Ro = B[0][0]; … … 285 303 Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i]; 286 304 Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i]; 287 chisq += SQ(X[i] - Xf) / SQ(dX[i]); 288 chisq += SQ(Y[i] - Yf) / SQ(dY[i]); 289 if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 305 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 306 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 307 chisq += SQ(X[i] - Xf) * wx; 308 chisq += SQ(Y[i] - Yf) * wy; 309 // if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 290 310 } 291 311 fit[0].Nfit = Npts; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/gauss.c
r34088 r37067 10 10 Buffer *buf; 11 11 KapaImageData data; 12 int VERBOSE; 13 14 VERBOSE = TRUE; 15 if ((N = get_argument (argc, argv, "-q"))) { 16 VERBOSE = FALSE; 17 remove_argument (N, &argc, argv); 18 } 19 if ((N = get_argument (argc, argv, "-quiet"))) { 20 VERBOSE = FALSE; 21 remove_argument (N, &argc, argv); 22 } 12 23 13 24 name = NULL; … … 58 69 KiiCursorRead (kapa, &X, &Y, &ZP, &RA, &DEC, key); 59 70 if (!strcasecmp (key, "Q")) break; 60 get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max );71 get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max, VERBOSE); 61 72 } 62 73 KiiCursorOff (kapa); … … 64 75 } 65 76 77 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/init.c
r35757 r37067 13 13 int czplot PROTO((int, char **)); 14 14 int czcplot PROTO((int, char **)); 15 int cdensify PROTO((int, char **)); 15 16 int drizzle PROTO((int, char **)); 16 17 int flux PROTO((int, char **)); 17 18 int fitplx PROTO((int, char **)); 19 int fitpm PROTO((int, char **)); 18 20 int fixwrap PROTO((int, char **)); 19 21 int fiximage PROTO((int, char **)); … … 49 51 int scale PROTO((int, char **)); 50 52 int sexigesimal PROTO((int, char **)); 53 int sersic PROTO((int, char **)); 51 54 int spec PROTO((int, char **)); 52 55 int specpairfit PROTO((int, char **)); … … 72 75 {1, "czplot", czplot, "plot scaled vectors in sky coordinates"}, 73 76 {1, "czcplot", czcplot, "plot color-scaled vectors in sky coordinates"}, 77 {1, "cdensify", cdensify, "vectors to density history on projection"}, 74 78 {1, "drizzle", drizzle, "transform image to image"}, 75 79 {1, "flux", flux, "flux in a convex contour"}, 76 80 {1, "fitplx", fitplx, "fit proper motion and parallax"}, 81 {1, "fitpm", fitpm, "fit proper motion only"}, 77 82 {1, "fixwrap", fixwrap, "fix megacam over-wrapped pixels"}, 78 83 {1, "fiximage", fiximage, "fix pixels in an image by interpolation"}, … … 107 112 {1, "scale", scale, "get / set real bzero / bscale values"}, 108 113 {1, "sexigesimal", sexigesimal, "convert to/from sexigesimal/decimal"}, 114 {1, "sersic", sersic, "generate sub-pixel resolved sersic model"}, 109 115 {1, "spec", spec, "extract a spectrum"}, 110 116 {1, "specpairfit", specpairfit, "fit spectrum to another spectrum"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/region.c
r31160 r37067 80 80 if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE); 81 81 Radius = atof (argv[3]); 82 strcpy (graphmode.coords.ctype, " RA---TAN");82 strcpy (graphmode.coords.ctype, "DEC--TAN"); 83 83 if (argc == 5) { 84 84 if (!strcasecmp (argv[4], "TAN")) 85 strcpy (graphmode.coords.ctype, " RA---TAN");85 strcpy (graphmode.coords.ctype, "DEC--TAN"); 86 86 if (!strcasecmp (argv[4], "SIN")) 87 strcpy (graphmode.coords.ctype, " RA---SIN");87 strcpy (graphmode.coords.ctype, "DEC--SIN"); 88 88 if (!strcasecmp (argv[4], "ARC")) 89 strcpy (graphmode.coords.ctype, " RA---ARC");89 strcpy (graphmode.coords.ctype, "DEC--ARC"); 90 90 if (!strcasecmp (argv[4], "STG")) 91 strcpy (graphmode.coords.ctype, " RA---STG");91 strcpy (graphmode.coords.ctype, "DEC--STG"); 92 92 if (!strcasecmp (argv[4], "ZEA")) 93 strcpy (graphmode.coords.ctype, " RA---ZEA");93 strcpy (graphmode.coords.ctype, "DEC--ZEA"); 94 94 if (!strcasecmp (argv[4], "AIT")) 95 strcpy (graphmode.coords.ctype, " RA---AIT");95 strcpy (graphmode.coords.ctype, "DEC--AIT"); 96 96 if (!strcasecmp (argv[4], "GLS")) 97 strcpy (graphmode.coords.ctype, " RA---GLS");97 strcpy (graphmode.coords.ctype, "DEC--GLS"); 98 98 if (!strcasecmp (argv[4], "PAR")) 99 strcpy (graphmode.coords.ctype, " RA---PAR");99 strcpy (graphmode.coords.ctype, "DEC--PAR"); 100 100 } 101 101 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/star.c
r34088 r37067 6 6 double max; 7 7 Buffer *buf; 8 int VERBOSE; 9 10 VERBOSE = TRUE; 11 if ((N = get_argument (argc, argv, "-q"))) { 12 VERBOSE = FALSE; 13 remove_argument (N, &argc, argv); 14 } 15 if ((N = get_argument (argc, argv, "-quiet"))) { 16 VERBOSE = FALSE; 17 remove_argument (N, &argc, argv); 18 } 8 19 9 20 Nborder = 3; … … 36 47 } 37 48 38 get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max );49 get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max, VERBOSE); 39 50 40 51 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.basic/Makefile
r35237 r37067 55 55 $(SRC)/substr.$(ARCH).o \ 56 56 $(SRC)/strhash.$(ARCH).o \ 57 $(SRC)/strmatch.$(ARCH).o \ 57 58 $(SRC)/strpop.$(ARCH).o \ 58 59 $(SRC)/strsub.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.basic/init.c
r35237 r37067 40 40 int fprintf_opihi PROTO((int, char **)); 41 41 int strlen_func PROTO((int, char **)); 42 int strmatch PROTO((int, char **)); 42 43 int substr_func PROTO((int, char **)); 43 44 int strpop PROTO((int, char **)); … … 97 98 {1, "strpop", strpop, "pop a string"}, 98 99 {1, "strsub", strsub, "replace instances of a key in a string"}, 100 {1, "strmatch", strmatch, "string length"}, 99 101 {1, "wait", wait_func, "wait until return is typed"}, 100 102 {1, "which", which, "show command *"} -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.basic/list.c
r33662 r37067 21 21 } 22 22 23 int EXCEL_STYLE = FALSE; 24 if ((N = get_argument (argc, argv, "-excel-style"))) { 25 remove_argument (N, &argc, argv); 26 EXCEL_STYLE = TRUE; 27 } 28 if ((N = get_argument (argc, argv, "-excel"))) { 29 remove_argument (N, &argc, argv); 30 EXCEL_STYLE = TRUE; 31 } 32 23 33 if ((N = get_argument (argc, argv, "-vectors"))) { 24 34 remove_argument (N, &argc, argv); … … 49 59 50 60 for (i = 0; i < argc - 3; i++) { 51 s printf (line, "%s:%d", argv[1], i);61 set_list_varname (line, argv[1], i, EXCEL_STYLE); 52 62 set_str_variable (line, argv[i+3]); 53 63 } … … 83 93 if (!word) break; 84 94 85 sprintf (line, "%s:%d", argv[1], nWords); 95 // sprintf (line, "%s:%d", argv[1], nWords); 96 set_list_varname (line, argv[1], nWords, EXCEL_STYLE); 97 86 98 set_str_variable (line, word); 87 99 FREE (word); … … 120 132 sprintf (line, "%s:%d", argv[3], i); 121 133 value = get_variable (line); 122 sprintf (line, "%s:%d", argv[1], i); 134 // sprintf (line, "%s:%d", argv[1], i); 135 set_list_varname (line, argv[1], i, EXCEL_STYLE); 123 136 set_str_variable (line, value); 124 137 } … … 136 149 N = get_int_variable (line, &found); 137 150 for (i = 0; i < argc - 3; i++) { 138 sprintf (line, "%s:%d", argv[1], N + i); 151 // sprintf (line, "%s:%d", argv[1], N + i); 152 set_list_varname (line, argv[1], N + i, EXCEL_STYLE); 139 153 set_str_variable (line, argv[i+3]); 140 154 } … … 159 173 N = get_int_variable (line, &found); 160 174 for (i = 0; i < N; i++) { 161 sprintf (line, "%s:%d", argv[1], i); 175 // sprintf (line, "%s:%d", argv[1], i); 176 set_list_varname (line, argv[1], i, EXCEL_STYLE); 162 177 value = get_variable (line); 163 178 if (value == NULL) continue; … … 165 180 free (value); 166 181 for (j = i + 1; j < N; j++) { 167 sprintf (line2, "%s:%d", argv[1], j); 182 // sprintf (line2, "%s:%d", argv[1], j); 183 set_list_varname (line2, argv[1], j, EXCEL_STYLE); 168 184 next_value = get_variable (line2); 169 185 set_str_variable (line, next_value); … … 235 251 if (B != (char *) NULL) { *B = 0; } 236 252 if (*A != 0) { 237 sprintf (line, "%s:%d", argv[1], i); 253 // sprintf (line, "%s:%d", argv[1], i); 254 set_list_varname (line, argv[1], i, EXCEL_STYLE); 238 255 set_str_variable (line, A); 239 256 A = B + 1; … … 283 300 284 301 if (*input) { 285 sprintf (line, "%s:%d", argv[1], i); 302 // sprintf (line, "%s:%d", argv[1], i); 303 set_list_varname (line, argv[1], i, EXCEL_STYLE); 286 304 set_str_variable (line, input); 287 305 free (input); 288 306 i++; 289 }307 } 290 308 } 291 309 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/Makefile
r35416 r37067 25 25 $(SRC)/book.$(ARCH).o \ 26 26 $(SRC)/book_commands.$(ARCH).o \ 27 $(SRC)/cast.$(ARCH).o \ 27 28 $(SRC)/center.$(ARCH).o \ 28 29 $(SRC)/clear.$(ARCH).o \ … … 63 64 $(SRC)/imcut.$(ARCH).o \ 64 65 $(SRC)/imhist.$(ARCH).o \ 66 $(SRC)/impeaks.$(ARCH).o \ 65 67 $(SRC)/imsmooth.$(ARCH).o \ 68 $(SRC)/imsmooth.generic.$(ARCH).o \ 69 $(SRC)/imsmooth.2d.$(ARCH).o \ 66 70 $(SRC)/integrate.$(ARCH).o \ 67 71 $(SRC)/interpolate.$(ARCH).o \ 72 $(SRC)/join.$(ARCH).o \ 68 73 $(SRC)/jpeg.$(ARCH).o \ 69 74 $(SRC)/kern.$(ARCH).o \ … … 84 89 $(SRC)/mget.$(ARCH).o \ 85 90 $(SRC)/minterpolate.$(ARCH).o \ 91 $(SRC)/medimage.$(ARCH).o \ 92 $(SRC)/medimage_commands.$(ARCH).o \ 86 93 $(SRC)/mset.$(ARCH).o \ 87 94 $(SRC)/peak.$(ARCH).o \ … … 91 98 $(SRC)/point.$(ARCH).o \ 92 99 $(SRC)/ps.$(ARCH).o \ 100 $(SRC)/print_vectors.$(ARCH).o \ 93 101 $(SRC)/queuedelete.$(ARCH).o \ 94 102 $(SRC)/queuedrop.$(ARCH).o \ … … 143 151 $(SRC)/vmaxwell.$(ARCH).o \ 144 152 $(SRC)/vgrid.$(ARCH).o \ 153 $(SRC)/vlist.$(ARCH).o \ 145 154 $(SRC)/vload.$(ARCH).o \ 146 155 $(SRC)/vzload.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/densify.c
r34088 r37067 2 2 3 3 # define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); } 4 enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS}; 4 5 5 6 int densify (int argc, char **argv) { 6 7 7 int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;8 int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph; 8 9 double Xmin, Xmax, dX, Ymin, Ymax, dY; 9 10 float *val; … … 24 25 } 25 26 27 float scale = 0.0; 28 if ((N = get_argument (argc, argv, "-scale"))) { 29 remove_argument (N, &argc, argv); 30 scale = atof(argv[N]); 31 remove_argument (N, &argc, argv); 32 } 33 34 int PSFTYPE = IS_DOT; 35 if ((N = get_argument (argc, argv, "-psf"))) { 36 remove_argument (N, &argc, argv); 37 if (!strcasecmp(argv[N], "dot")) PSFTYPE = IS_DOT; 38 if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE; 39 if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE; 40 if (!strcasecmp(argv[N], "gauss")) PSFTYPE = IS_GAUSS; 41 remove_argument (N, &argc, argv); 42 } 43 26 44 good = UseGraph ? (argc == 4) : (argc == 10); 27 45 if (!good) { 28 46 gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n"); 29 47 gprint (GP_ERR, " OR: densify buffer x y -graph\n"); 48 gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n"); 30 49 return (FALSE); 31 50 } … … 69 88 CHECKVAL(dY); 70 89 90 float scaleX = (scale > 0.0) ? scale / dX : 3.0; 91 float scaleY = (scale > 0.0) ? scale / dY : 3.0; 92 71 93 Nx = (Xmax - Xmin) / dX + 1; 72 94 Ny = (Ymax - Ymin) / dY + 1; … … 76 98 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0); 77 99 strcpy (bf[0].file, "(empty)"); 100 101 float scale2 = (scaleX + 1.0) * (scaleY + 1.0); 102 float fSquare = 1.0 / scale2; 103 float fCircle = 1.0 / (3.141592 * scale2); 104 float fSigma = 0.5 / scale2; 105 float fGauss = 1.0 / (2.0 * 3.141592 * scale2); 78 106 79 107 x = vx[0].elements.Flt; … … 83 111 Xb = (*x - Xmin) / dX; 84 112 Yb = (*y - Ymin) / dY; 85 if (Xb >= Nx) continue; 86 if (Yb >= Ny) continue; 87 if (Xb < 0) continue; 88 if (Yb < 0) continue; 89 val[Xb + Yb*Nx] ++; 113 switch (PSFTYPE) { 114 case IS_DOT: 115 if (Xb >= Nx) continue; 116 if (Yb >= Ny) continue; 117 if (Xb < 0) continue; 118 if (Yb < 0) continue; 119 val[Xb + Yb*Nx] ++; 120 break; 121 case IS_SQUARE: 122 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 123 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 124 if (ix >= Nx) continue; 125 if (iy >= Ny) continue; 126 if (ix < 0) continue; 127 if (iy < 0) continue; 128 val[ix + iy*Nx] += fSquare; 129 } 130 } 131 break; 132 case IS_CIRCLE: 133 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 134 float dX = ix - Xb; 135 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 136 float dY = iy - Yb; 137 float r2 = dX*dX + dY*dY; 138 if (r2 > 9) continue; 139 if (ix >= Nx) continue; 140 if (iy >= Ny) continue; 141 if (ix < 0) continue; 142 if (iy < 0) continue; 143 val[ix + iy*Nx] += fCircle; 144 } 145 } 146 break; 147 case IS_GAUSS: 148 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 149 float dX = ix - Xb; 150 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 151 float dY = iy - Yb; 152 float r2 = dX*dX + dY*dY; 153 if (ix >= Nx) continue; 154 if (iy >= Ny) continue; 155 if (ix < 0) continue; 156 if (iy < 0) continue; 157 val[ix + iy*Nx] += fGauss*exp(-fSigma*r2); 158 } 159 } 160 break; 161 } 90 162 } 91 163 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/init.c
r35416 r37067 10 10 int center PROTO((int, char **)); 11 11 int parity PROTO((int, char **)); 12 int cast PROTO((int, char **)); 12 13 int circstats PROTO((int, char **)); 13 14 int clear PROTO((int, char **)); … … 52 53 int imcut PROTO((int, char **)); 53 54 int imhist PROTO((int, char **)); 55 int impeaks PROTO((int, char **)); 54 56 int imsmooth PROTO((int, char **)); 57 int imsmooth_generic PROTO((int, char **)); 58 int imsmooth_2d PROTO((int, char **)); 55 59 int integrate PROTO((int, char **)); 56 60 int interpolate PROTO((int, char **)); 61 int join PROTO((int, char **)); 57 62 int jpeg PROTO((int, char **)); 58 63 int kern PROTO((int, char **)); … … 74 79 int mget PROTO((int, char **)); 75 80 int minterp PROTO((int, char **)); 81 int medimage_command PROTO((int, char **)); 76 82 int mset PROTO((int, char **)); 77 83 int peak PROTO((int, char **)); … … 81 87 int point PROTO((int, char **)); 82 88 int ps PROTO((int, char **)); 89 int print_vectors PROTO((int, char **)); 83 90 int queuelist PROTO((int, char **)); 84 91 int queueload PROTO((int, char **)); … … 133 140 int vmaxwell PROTO((int, char **)); 134 141 int vload PROTO((int, char **)); 142 int vlist PROTO((int, char **)); 135 143 int vzload PROTO((int, char **)); 136 144 int vstats PROTO((int, char **)); … … 160 168 {1, "buffers", list_buffers, "list the currently allocated buffers (images)"}, 161 169 {1, "center", center, "center image on coords"}, 170 {1, "cast", cast, "cast input vector to specified type"}, 162 171 {1, "circstats", circstats, "circular statistics"}, 163 172 {1, "clear", clear, "erase plot"}, … … 205 214 {1, "imcut", imcut, "linear image cut between arbitrary coords"}, 206 215 {1, "imhistogram", imhist, "histogram of an image region"}, 216 {1, "impeaks", impeaks, "find peaks in an image (return vectors)"}, 207 217 {1, "imsmooth", imsmooth, "circular gaussian smoothing"}, 218 {1, "imsmooth.generic", imsmooth_generic, "circular non-gaussian smoothing"}, 219 {1, "imsmooth.2d", imsmooth_2d, "circular non-gaussian smoothing"}, 208 220 {1, "imstats", imstats, "statistics on a portion of an image"}, 209 221 {1, "integrate", integrate, "integrate a vector"}, 210 222 {1, "interpolate", interpolate, "interpolate between vector pairs"}, 223 {1, "join", join, "find the join of two ID vectors"}, 211 224 {1, "jpeg", jpeg, "convert display image to JPEG"}, 212 225 {1, "kern", kern, "convolve with 3x3 kernel"}, … … 224 237 {1, "minterp", minterp, "interpolate image pixels"}, 225 238 {1, "iminterp", minterp, "interpolate image pixels"}, 239 {1, "medimage", medimage_command, "median image manipulation"}, 226 240 {1, "matrix", matrix, "matrix math operations"}, 227 241 {1, "match2d", match2d, "match 2 pairs of X,Y vectors and return matched indexes"}, … … 237 251 {1, "ppm", jpeg, "convert display graphic to PPM"}, 238 252 {1, "ps", ps, "convert display to PostScript"}, 253 {1, "print_vectors", print_vectors, "print a set of vectors"}, 239 254 {1, "queuedelete", queuedelete, "delete a queue"}, 240 255 {1, "queuedrop", queuedrop, "drop values from queue matching a key"}, … … 290 305 {1, "vgrid", vgrid, "generate an image from a triplet of vectors"}, 291 306 {1, "vhistogram", histogram, "generate histogram from vector"}, 307 {1, "vlist", vlist, "append values to a vector from command line"}, 292 308 {1, "vload", vload, "load vectors as overlay on image display"}, 293 309 {1, "vmaxwell", vmaxwell, "fit a Maxwellian to a vector"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/match2d.c
r33963 r37067 14 14 Vector *index1, *index2; 15 15 16 if ((N = get_argument (argc, argv, "-h"))) goto usage; 17 if ((N = get_argument (argc, argv, "--help"))) goto usage; 18 16 19 CLOSEST = FALSE; 17 20 if ((N = get_argument (argc, argv, "-closest"))) { … … 38 41 if (argc != 6) { 39 42 gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n"); 40 gprint (GP_ERR, " if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n"); 41 gprint (GP_ERR, " with either the index of the match or a value of -1 for non-matches\n"); 43 gprint (GP_ERR, " use -h or --help for more detail\n"); 42 44 return (FALSE); 43 45 } … … 90 92 91 93 return (TRUE); 94 95 usage: 96 gprint (GP_ERR, "we have two modes of operation:\n\n"); 97 98 gprint (GP_ERR, "without -closest, we are finding all matched pairs within the match radius. in this\n"); 99 gprint (GP_ERR, "case, the two index vectors have the same length, one entry per matched pair.\n"); 100 gprint (GP_ERR, "x1[index1],y1[index1] matches to x2[index2],y2[index2].\n\n"); 101 102 gprint (GP_ERR, "with -closest selected, we are finding the closest element of set 1 to each of set 2\n"); 103 gprint (GP_ERR, "and vice versa. in this case, index1 is always the same length as x1,y1, while index2\n"); 104 gprint (GP_ERR, "is the same lengths as x2,y2. x2[index1],y2[index1] matches x1,y1 while\n"); 105 gprint (GP_ERR, "x1[index2],y1[index2] matches x2,y2\n\n"); 106 107 gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n"); 108 gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n"); 109 110 return FALSE; 92 111 } 93 112 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/read_vectors.c
r34753 r37067 3 3 FILE *f = (FILE *) NULL; 4 4 char filename[2048]; 5 6 void read_vectors_cleanup (); 5 7 6 8 int datafile (int argc, char **argv) { … … 24 26 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 27 28 static int Nvec = 0; 29 static Vector **vec = NULL; 30 static char **listname = NULL; 31 static int *col = NULL; 32 static int *coltype = NULL; 33 static char *buffer = NULL; 34 26 35 int read_vectors (int argc, char **argv) { 27 36 28 37 int TimeFormat; 29 38 time_t TimeReference; 30 int i, j, Nskip, Narg, Nvec, *col,IsCSV, VERBOSE;31 int Nbytes, Nstart, NELEM, Nelem, nread , *coltype;39 int i, j, Nskip, Narg, IsCSV, VERBOSE; 40 int Nbytes, Nstart, NELEM, Nelem, nread; 32 41 char *colstr, *c0, *c1, *extname; 33 Vector **vec; 34 35 char *buffer = NULL; 42 char varname[1024]; // used as a buffer for the names of string fields 36 43 37 44 /* auto-sense table type */ … … 81 88 82 89 Nvec = (argc - 1) / 2; 90 ALLOCATE (listname, char *, Nvec); 83 91 ALLOCATE (vec, Vector *, Nvec); 84 92 ALLOCATE (col, int, Nvec); 85 93 ALLOCATE (coltype, int, Nvec); 94 for (i = 0; i < Nvec; i++) { 95 listname[i] = NULL; 96 vec[i] = NULL; 97 } 86 98 87 99 for (i = 0; i < Nvec; i++) { … … 108 120 } 109 121 110 if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) { 111 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 112 free (vec); 113 free (col); 114 return (FALSE); 122 if (coltype[i] == COLTYPE_CHAR) { 123 listname[i] = strcreate (argv[2*i + 1]); 124 } else { 125 if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) { 126 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 127 read_vectors_cleanup(); 128 return (FALSE); 129 } 115 130 } 116 131 … … 137 152 bad_colname: 138 153 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 139 free (vec); 140 free (col); 154 read_vectors_cleanup(); 141 155 return (FALSE); 142 156 } … … 146 160 NELEM = 1000; 147 161 for (i = 0; i < Nvec; i++) { 148 if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) { 149 ResetVector (vec[i], OPIHI_INT, NELEM); 150 } else { 151 // note that COLTYPE_TIME is a type of float 152 ResetVector (vec[i], OPIHI_FLT, NELEM); 162 switch (coltype[i]) { 163 case COLTYPE_INT: 164 ResetVector (vec[i], OPIHI_INT, NELEM); 165 break; 166 case COLTYPE_FLT: 167 case COLTYPE_TIME: 168 // note that COLTYPE_TIME is a type of float 169 ResetVector (vec[i], OPIHI_FLT, NELEM); 170 break; 171 case COLTYPE_CHAR: 172 default: 173 break; 153 174 } 154 175 } … … 159 180 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) { 160 181 gprint (GP_ERR, "problem reading file %s\n", filename); 161 free (vec); 162 free (col); 182 read_vectors_cleanup(); 163 183 return FALSE; 164 184 } … … 206 226 for (i = 0; i < Nvec; i++) { 207 227 int ivalue; 208 char cvalue;209 228 double dvalue; 210 229 time_t tvalue; … … 217 236 break; 218 237 case COLTYPE_CHAR: 219 readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0); 220 vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0; 221 break; 238 { 239 // I need to get an isolated word in 'value' with the string value of this field 240 char *ptr = IsCSV ? ptrparse_csv (col[i], c0) : ptrparse (col[i], c0); 241 char *value = NULL; 242 if (IsCSV) { 243 char *end = parse_nextword_csv (ptr); 244 if (end) { 245 value = end ? strncreate (ptr, end - ptr) : strcreate (ptr); 246 } 247 } else { 248 value = thisword(ptr); 249 } 250 set_list_varname (varname, listname[i], Nelem, FALSE); 251 set_str_variable (varname, value); 252 free (value); 253 break; 254 } 222 255 case COLTYPE_FLT: 223 256 readStatus = IsCSV ? dparse_csv (&dvalue, col[i], c0) : dparse (&dvalue, col[i], c0); … … 249 282 NELEM += 1000; 250 283 for (i = 0; i < Nvec; i++) { 251 if (coltype[i] == COLTYPE_INT) { 252 REALLOCATE (vec[i][0].elements.Int, opihi_int, NELEM); 253 } else { 254 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM); 284 switch (coltype[i]) { 285 case COLTYPE_INT: 286 ResetVector (vec[i], OPIHI_INT, NELEM); 287 break; 288 case COLTYPE_FLT: 289 case COLTYPE_TIME: 290 ResetVector (vec[i], OPIHI_FLT, NELEM); 291 break; 292 case COLTYPE_CHAR: 293 default: 294 break; 255 295 } 256 296 } … … 259 299 } 260 300 } 301 // set the final vector / list length 261 302 for (i = 0; i < Nvec; i++) { 262 if (coltype[i] == COLTYPE_INT) { 263 REALLOCATE (vec[i][0].elements.Int, opihi_int, MAX (Nelem,1)); 264 } else { 265 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (Nelem,1)); 266 } 267 vec[i][0].Nelements = Nelem; 268 } 269 270 free (vec); 271 free (col); 272 if (buffer) free (buffer); 303 switch (coltype[i]) { 304 case COLTYPE_INT: 305 ResetVector (vec[i], OPIHI_INT, Nelem); 306 break; 307 case COLTYPE_FLT: 308 case COLTYPE_TIME: 309 ResetVector (vec[i], OPIHI_FLT, Nelem); 310 break; 311 case COLTYPE_CHAR: 312 sprintf (varname, "%s:n", listname[i]); 313 set_int_variable (varname, Nelem); 314 break; 315 default: 316 break; 317 } 318 } 319 read_vectors_cleanup(); 273 320 return (TRUE); 274 275 321 } 276 322 277 # define ESCAPE( MSG) {\278 gprint (GP_ERR, "%s\n", MSG); \323 # define ESCAPE(...) { \ 324 gprint (GP_ERR, __VA_ARGS__); \ 279 325 if (CCDKeyword != NULL) free (CCDKeyword); \ 280 326 gfits_free_table (&table); \ … … 285 331 286 332 off_t Nbytes; 287 int i, j, k,N, Nextend, Ny, Binary, vecType, padIfShort;333 int i, j, N, Nextend, Ny, Binary, vecType, padIfShort; 288 334 char type[16], ID[80], *CCDKeyword; 289 335 FTable table; 290 336 Header header; 291 337 Vector **vec; 338 int FITS_TRANSPOSE; 292 339 293 340 table.buffer = NULL; 294 341 header.buffer = NULL; 342 343 FITS_TRANSPOSE = FALSE; 344 if ((N = get_argument (argc, argv, "-transpose"))) { 345 remove_argument (N, &argc, argv); 346 FITS_TRANSPOSE = TRUE; 347 } 295 348 296 349 CCDKeyword = NULL; … … 321 374 // } 322 375 323 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ... ");324 325 if (f == NULL) ESCAPE ("file not found ");376 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...\n"); 377 378 if (f == NULL) ESCAPE ("file not found\n"); 326 379 fseeko (f, 0LL, SEEK_SET); 327 380 table.header = &header; … … 331 384 // first extension is PHU, cannot be a table. 332 385 // Nextend counts from 0 for first extension 333 if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file ");386 if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file\n"); 334 387 Nbytes = gfits_data_size (&header); 335 388 fseeko (f, Nbytes, SEEK_CUR); … … 337 390 338 391 for (i = 0; i < Nextend; i++) { 339 if (!gfits_load_header (f, &header)) ESCAPE ("extension not found");392 if (!gfits_load_header (f, &header)) ESCAPE ("extension %d not found\n", i); 340 393 Nbytes = gfits_data_size (&header); 341 394 /* skip the prior data buffers */ … … 343 396 gfits_free_header (&header); 344 397 } 345 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension ");346 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension ");398 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend); 399 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 347 400 348 401 } else { … … 375 428 continue; 376 429 } 377 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension ");430 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n"); 378 431 break; 379 432 } … … 384 437 gfits_scan (&header, "XTENSION", "%s", 1, type); 385 438 if (strcmp (type, "BINTABLE") && strcmp (type, "TABLE")) { 386 ESCAPE ("specified extension is not a table\n");439 ESCAPE ("specified extension %s is not a table\n", type); 387 440 } 388 441 Binary = !strcmp (type, "BINTABLE"); … … 410 463 } 411 464 412 // define the multifield vector names 413 ALLOCATE (vec, Vector *, Nval); 414 for (j = 0; j < Nval; j++) { 415 if (Nval == 1) 416 sprintf (name, "%s", argv[i]); 417 else 418 sprintf (name, "%s:%d", argv[i], j); 419 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 420 ResetVector (vec[j], vecType, Ny); 421 } 422 423 if (!strcmp (type, "char")) { 424 char *Ptr = data; 465 if (!FITS_TRANSPOSE) { 466 // read string column into a list rather than a vector 467 if (!strcmp (type, "char")) { 468 char *fieldName = argv[i]; 469 char *Ptr = data; 470 char varname[1024]; // used as a buffer for the names of string fields 471 for (j = 0; j < Ny; j++) { 472 set_list_varname (varname, fieldName, j, FALSE); 473 char *value = strncreate (&Ptr[j*Nval], Nval); 474 // replace instances of $ with _ 475 char *p = strchr (value, '$'); 476 while (p) { 477 *p = '_'; 478 p = strchr (p, '$'); 479 } 480 set_str_variable (varname, value); 481 free (value); 482 } 483 sprintf (varname, "%s:n", fieldName); 484 set_int_variable (varname, Ny); 485 continue; 486 } 487 488 // define the multifield vector names (Nval vectors x Ny elements) 489 ALLOCATE (vec, Vector *, Nval); 490 for (j = 0; j < Nval; j++) { 491 if (Nval == 1) 492 sprintf (name, "%s", argv[i]); 493 else 494 sprintf (name, "%s:%d", argv[i], j); 495 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 496 ResetVector (vec[j], vecType, Ny); 497 } 498 499 if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 500 501 } else { 502 // define the multifield vector names (Ny vectors x Nval elements) 503 ALLOCATE (vec, Vector *, Ny); 425 504 for (j = 0; j < Ny; j++) { 426 for (k = 0; k < Nval; k++, Ptr++) { 427 vec[k][0].elements.Int[j] = *Ptr; 428 } 429 } 430 } 431 if (!strcmp (type, "short")) { 432 short *Ptr = data; 433 for (j = 0; j < Ny; j++) { 434 for (k = 0; k < Nval; k++, Ptr++) { 435 vec[k][0].elements.Int[j] = *Ptr; 436 } 437 } 438 } 439 if (!strcmp (type, "int")) { 440 int *Ptr = data; 441 for (j = 0; j < Ny; j++) { 442 for (k = 0; k < Nval; k++, Ptr++) { 443 vec[k][0].elements.Int[j] = *Ptr; 444 } 445 } 446 } 447 if (!strcmp (type, "int64_t")) { 448 int64_t *Ptr = data; 449 for (j = 0; j < Ny; j++) { 450 for (k = 0; k < Nval; k++, Ptr++) { 451 vec[k][0].elements.Int[j] = *Ptr; 452 } 453 } 454 } 455 if (!strcmp (type, "float")) { 456 float *Ptr = data; 457 for (j = 0; j < Ny; j++) { 458 for (k = 0; k < Nval; k++, Ptr++) { 459 vec[k][0].elements.Flt[j] = *Ptr; 460 } 461 } 462 } 463 if (!strcmp (type, "double")) { 464 double *Ptr = data; 465 for (j = 0; j < Ny; j++) { 466 for (k = 0; k < Nval; k++, Ptr++) { 467 vec[k][0].elements.Flt[j] = *Ptr; 468 } 469 } 505 if (Ny == 1) 506 sprintf (name, "%s", argv[i]); 507 else 508 sprintf (name, "%s:%d", argv[i], j); 509 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 510 ResetVector (vec[j], vecType, Nval); 511 } 512 513 if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 470 514 } 471 515 free (data); … … 477 521 return (TRUE); 478 522 } 523 524 void read_vectors_cleanup () { 525 526 int i; 527 528 if (col) free (col); 529 if (coltype) free (coltype); 530 if (buffer) free (buffer); 531 if (listname) { 532 for (i = 0; i < Nvec; i++) { 533 if (listname[i]) free (listname[i]); 534 } 535 free (listname); 536 } 537 if (vec) free (vec); 538 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/rebin.c
r28241 r37067 133 133 *Vout += *Vin; 134 134 if (Normalize) {(*Vn) ++;} 135 // if ((i == 1) && (j == 1)) fprintf (stderr, "%d,%d : %d,%d : %f : %f : %d\n", i, j, x, y, *Vin, *Vout, *Vn); 135 136 } 136 137 if (Normalize) {Vn ++;} -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vellipse.c
r25757 r37067 228 228 */ 229 229 230 // XXX NOTE that PHI is defined with the wrong sign, should fix this... 230 231 opihi_flt fellipseOD (opihi_flt alpha, opihi_flt *par, int Npar, opihi_flt *dpar) { 231 232 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vgauss.c
r35109 r37067 48 48 if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 49 49 50 CastVector (xvec, OPIHI_FLT); 51 CastVector (yvec, OPIHI_FLT); 52 50 53 int Nsvec = strlen(argv[3]); 51 54 … … 69 72 } 70 73 71 CastVector (xvec, OPIHI_FLT);72 CastVector (yvec, OPIHI_FLT);73 74 CastVector (svec, OPIHI_FLT); 74 75 // XXX Cast is failing. -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/Makefile
r34461 r37067 25 25 $(SRC)/dvo_host_utils.$(ARCH).o \ 26 26 $(SRC)/region_list.$(ARCH).o \ 27 $(SRC)/find_matches.$(ARCH).o \ 28 $(SRC)/photometry.$(ARCH).o 27 $(SRC)/photcode_ops.$(ARCH).o \ 28 $(SRC)/find_matches.$(ARCH).o 29 30 # $(SRC)/photometry.$(ARCH).o 31 32 broken = \ 33 $(SRC)/calextract.$(ARCH).o \ 34 $(SRC)/calmextract.$(ARCH).o \ 35 $(SRC)/ccd.$(ARCH).o \ 36 $(SRC)/cmd.$(ARCH).o \ 37 $(SRC)/dmagaves.$(ARCH).o \ 38 $(SRC)/dmagmeas.$(ARCH).o \ 39 $(SRC)/dmags.$(ARCH).o \ 40 $(SRC)/ddmags.$(ARCH).o \ 41 $(SRC)/fitcolors.$(ARCH).o 29 42 30 43 cmds = \ … … 32 45 $(SRC)/avmatch.$(ARCH).o \ 33 46 $(SRC)/badimages.$(ARCH).o \ 34 $(SRC)/calextract.$(ARCH).o \35 $(SRC)/calmextract.$(ARCH).o \36 47 $(SRC)/catdir.$(ARCH).o \ 37 $(SRC)/ccd.$(ARCH).o \38 48 $(SRC)/cmatch.$(ARCH).o \ 39 $(SRC)/cmd.$(ARCH).o \40 49 $(SRC)/cmpload.$(ARCH).o \ 41 50 $(SRC)/cmpread.$(ARCH).o \ 42 $(SRC)/ddmags.$(ARCH).o \ 51 $(SRC)/coordimage.$(ARCH).o \ 52 $(SRC)/coordmosaic.$(ARCH).o \ 43 53 $(SRC)/detrend.$(ARCH).o \ 44 $(SRC)/dmagaves.$(ARCH).o \45 $(SRC)/dmagmeas.$(ARCH).o \46 $(SRC)/dmags.$(ARCH).o \47 54 $(SRC)/dmt.$(ARCH).o \ 48 55 $(SRC)/elixir.$(ARCH).o \ 49 $(SRC)/fitcolors.$(ARCH).o \50 56 $(SRC)/fitsed.$(ARCH).o \ 51 57 $(SRC)/gcat.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/avextract.c
r35416 r37067 166 166 needMeasures = FALSE; 167 167 for (i = 0; !needMeasures && (i < Nfields); i++) { 168 if (fields[i].magMode == MAG_NONE) continue; 169 if (fields[i].photcode == NULL) continue; // assert this? 168 if (fields[i].photcode == NULL) continue; // non-measure fields do not have a photcode 170 169 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 171 170 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/avmatch.c
r35416 r37067 70 70 dbExtractAveragesInit (); 71 71 72 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results73 72 RAvec = NULL; 74 73 DECvec = NULL; 75 if (PARALLEL && !HOST_ID) {76 if (!CoordsFile) {77 // get vectors corresponding to coordinates of interest78 if ((RAvec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;79 if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;80 81 ALLOCATE (vec, Vector *, 2);82 vec[0] = RAvec;83 vec[1] = DECvec;84 85 CoordsFile = abspath("coords.fits", 1024);86 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);87 if (!status) goto escape;88 }89 90 char *targv1 = argv[1];91 char *targv2 = argv[2];92 argv[1] = strcreate ("-coords");93 argv[2] = strcreate (CoordsFile);94 free (CoordsFile);95 96 // I need to pass the RA & DEC vectors to the remote clients...97 int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);98 if (vec) free (vec);99 100 free (argv[1]);101 free (argv[2]);102 argv[1] = targv1;103 argv[2] = targv2;104 105 return status;106 }107 108 74 // get vectors corresponding to coordinates of interest 109 75 if (CoordsFile) { … … 120 86 remove_argument (1, &argc, argv); 121 87 } 88 89 /* load regions which contain all supplied RA,DEC coordinates */ 90 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape; 91 92 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 93 if (PARALLEL && !HOST_ID) { 94 95 // We need to copy the args to a temp array and modify them so that we send the 96 // correct set to the remote client. The args list looks like this: 97 // if (!CoordsFile) : avmatch (RADIUS) field, ... [we removed RA & DEC above] 98 // if ( CoordsFile) : avmatch (RADIUS) field, ... [because we stripped off the -coords filename elements] 99 100 // allocate the temp array and copy all but (RA) (DEC) 101 int targc = 0; 102 char **targv = NULL; 103 ALLOCATE (targv, char *, argc + 2); 104 for (i = 0; i < argc; i++) { 105 targv[targc] = strcreate (argv[i]); 106 targc ++; 107 } 108 109 // if not specified, create the coords.fits input file 110 // NOTE: RAvec, DECvec were set above 111 if (!CoordsFile) { 112 ALLOCATE (vec, Vector *, 2); 113 vec[0] = RAvec; 114 vec[1] = DECvec; 115 116 CoordsFile = abspath("coords.fits", 1024); 117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL); 118 if (!status) goto escape; 119 } 120 121 // add the coords file to the args list 122 targv[targc+0] = strcreate ("-coords"); 123 targv[targc+1] = CoordsFile; // this gets freed with targv 124 targc += 2; 125 126 // I need to pass the RA & DEC vectors to the remote clients... 127 int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE); 128 if (vec) free (vec); 129 130 // free up targv 131 for (i = 0; i < targc; i++) { 132 free (targv[i]); 133 } 134 free (targv); 135 136 return status; 137 } 138 122 139 RADIUS = atof (argv[1]); 123 140 remove_argument (1, &argc, argv); … … 135 152 int needMeasures = FALSE; 136 153 for (i = 0; !needMeasures && (i < Nfields); i++) { 137 if (fields[i].magMode == MAG_NONE) continue;138 154 if (fields[i].photcode == NULL) continue; // assert this? 139 155 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 140 156 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 141 157 } 142 143 /* load regions which contain all supplied RA,DEC coordinates */144 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;145 158 146 159 /* create output storage vectors */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/dvo_client.c
r35263 r37067 90 90 } 91 91 92 // these are set in 'startup.c' for readline-based programs 93 set_variable ("PID", getpid()); 94 set_str_variable ("KAPA", "kapa"); 95 set_int_variable ("UNSIGN", 0); 96 gfits_set_unsign_mode (FALSE); 97 92 98 return; 93 99 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/find_matches.c
r29759 r37067 50 50 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 51 51 tcoords.Npolyterms = 1; 52 strcpy (tcoords.ctype, " RA---ARC");52 strcpy (tcoords.ctype, "DEC--ARC"); 53 53 54 54 // this region includes a boundary layer of size RADIUS -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/fitsed.c
r34088 r37067 83 83 /* interpret command-line options */ 84 84 if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape; 85 if (!SetPhotSelections (&argc, argv, 4)) goto usage;85 // if (!SetPhotSelections (&argc, argv, 4)) goto usage; 86 86 87 87 PLOT = FALSE; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/gimages.c
r34844 r37067 136 136 local.pc2_1 = local.pc1_2 = 0.0; 137 137 local.Npolyterms = 1; 138 strcpy (local.ctype, " RA---TAN");138 strcpy (local.ctype, "DEC--TAN"); 139 139 140 140 if (typehash == DistortImage) { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/gstar.c
r35109 r37067 15 15 GSTAR_UCDIST, 16 16 GSTAR_AVE_AP_MAG, 17 GSTAR_AVE_MAG_ 20,18 GSTAR_AVE_MAG_ 80,17 GSTAR_AVE_MAG_MIN, 18 GSTAR_AVE_MAG_MAX, 19 19 GSTAR_AVE_KRON_MAG, 20 20 GSTAR_AVE_KRON_MAG_ERR, … … 307 307 gprint (GP_LOG, "\n"); 308 308 309 /* M _20*/310 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_ 20);311 gprint (GP_LOG, "\n"); 312 313 /* M _80*/314 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_ 80);;309 /* Mmin */ 310 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MIN); 311 gprint (GP_LOG, "\n"); 312 313 /* Mmax */ 314 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MAX);; 315 315 gprint (GP_LOG, "\n"); 316 316 … … 374 374 int Nv = index[j]; 375 375 376 Mcat = PhotCat (&catalog.measure[Nv] );376 Mcat = PhotCat (&catalog.measure[Nv], MAG_CLASS_PSF); 377 377 if (INST) { 378 Mrel = PhotInst (&catalog.measure[Nv] );378 Mrel = PhotInst (&catalog.measure[Nv], MAG_CLASS_PSF); 379 379 } else { 380 Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt] );380 Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_PSF); 381 381 } 382 383 float dRoff = dvoOffsetR(&catalog.measure[Nv], &catalog.average[k]); 384 float dDoff = dvoOffsetD(&catalog.measure[Nv], &catalog.average[k]); 382 385 383 386 if (GetMeasures && !QUIET) { … … 387 390 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dM); 388 391 gprint (GP_LOG, "%20s ", date); 389 gprint (GP_LOG, "%7.4f ", catalog.measure[Nv].dR); 390 gprint (GP_LOG, "%7.4f ", catalog.measure[Nv].dD); 392 393 gprint (GP_LOG, "%7.4f ", dRoff); 394 gprint (GP_LOG, "%7.4f ", dDoff); 391 395 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].photFlags); 392 396 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].dbFlags); … … 447 451 vec3[0].elements.Flt[N] = catalog.measure[Nv].airmass; 448 452 vec4[0].elements.Flt[N] = catalog.measure[Nv].photcode; 449 vec5[0].elements.Flt[N] = catalog.measure[Nv].dR;450 vec6[0].elements.Flt[N] = catalog.measure[Nv].dD;453 vec5[0].elements.Flt[N] = dRoff; 454 vec6[0].elements.Flt[N] = dDoff; 451 455 N ++; 452 456 if (N == NPTS - 1) { … … 561 565 case GSTAR_AVE_MAG_CHISQ: /* average mag chisq */ 562 566 if (seq == -1) { 563 print_ short (NAN_S_SHORT, NAN_S_SHORT);564 } else { 565 print_ short (pow (10.0, 0.01*secfilt[seq].Xm), secfilt[seq].Xm);567 print_double (NAN); 568 } else { 569 print_double (secfilt[seq].Mchisq); 566 570 } 567 571 break; … … 596 600 break; 597 601 598 case GSTAR_AVE_MAG_ 20: /* average ap mags */599 if (seq == -1) { 600 print_double (NAN); 601 } else { 602 print_ short (0.001*secfilt[seq].M_20, secfilt[seq].M_20);603 } 604 break; 605 606 case GSTAR_AVE_MAG_ 80: /* average ap mags */607 if (seq == -1) { 608 print_double (NAN); 609 } else { 610 print_ short (0.001*secfilt[seq].M_80, secfilt[seq].M_80);602 case GSTAR_AVE_MAG_MIN: /* average ap mags */ 603 if (seq == -1) { 604 print_double (NAN); 605 } else { 606 print_double (secfilt[seq].Mmin); 607 } 608 break; 609 610 case GSTAR_AVE_MAG_MAX: /* average ap mags */ 611 if (seq == -1) { 612 print_double (NAN); 613 } else { 614 print_double (secfilt[seq].Mmax); 611 615 } 612 616 break; … … 632 636 print_double (NAN); 633 637 } else { 634 print_double_exp (secfilt[seq].F luxPSF);638 print_double_exp (secfilt[seq].FpsfStk); 635 639 } 636 640 break; … … 640 644 print_double (NAN); 641 645 } else { 642 print_double_exp (secfilt[seq].dF luxPSF);646 print_double_exp (secfilt[seq].dFpsfStk); 643 647 } 644 648 break; … … 648 652 print_double (NAN); 649 653 } else { 650 print_double_exp (secfilt[seq].F luxKron);654 print_double_exp (secfilt[seq].FkronStk); 651 655 } 652 656 break; … … 656 660 print_double (NAN); 657 661 } else { 658 print_double_exp (secfilt[seq].dF luxKron);659 } 660 break; 661 662 } 663 } 662 print_double_exp (secfilt[seq].dFkronStk); 663 } 664 break; 665 666 } 667 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/hosts.c
r35757 r37067 3 3 # define DVO_MAX_PATH 1024 4 4 5 enum {TEMP_NONE, TEMP_DVO_RESULTS, TEMP_DVO_LOG, TEMP_RELASTRO_CATALOG, TEMP_RELPHOT_CATALOG, TEMP_RELPHOT_LOG, TEMP_DVOPSPS_DET, TEMP_FIXSTKIDS_RESULTS}; 5 enum {TEMP_NONE, TEMP_DVO_RESULTS, TEMP_DVO_LOG, 6 TEMP_RELASTRO_CATALOG, TEMP_RELPHOT_CATALOG, TEMP_RELPHOT_LOG, TEMP_DVOPSPS_DET, TEMP_FIXSTKIDS_RESULTS, 7 TEMP_RELASTRO_CAT_FULL, TEMP_RELPHOT_CAT_FULL, TEMP_CHECKASTRO_CAT_FULL, 8 }; 6 9 7 10 // functions to manage the remote hosts … … 12 15 gprint (GP_ERR, " commands:\n"); 13 16 gprint (GP_ERR, " purge-temp : delete all tempfiles for this shell\n"); 14 gprint (GP_ERR, " : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] \n");17 gprint (GP_ERR, " : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] [-age hours]\n"); 15 18 gprint (GP_ERR, " get-results : determine name of RESULTS file\n"); 16 19 return FALSE; … … 33 36 } 34 37 38 struct timeval now; 39 gettimeofday (&now, NULL); 40 41 float AGE = 0; 42 int NOW = now.tv_sec; 43 if ((N = get_argument (argc, argv, "-age"))) { 44 remove_argument (N, &argc, argv); 45 AGE = atof(argv[N]); 46 remove_argument (N, &argc, argv); 47 } 48 35 49 int VERBOSE = FALSE; 36 50 if ((N = get_argument (argc, argv, "-v"))) { … … 60 74 if (!strcasecmp(argv[N], "dvo.results")) TEMP_TYPE = TEMP_DVO_RESULTS; 61 75 if (!strcasecmp(argv[N], "dvo.log")) TEMP_TYPE = TEMP_DVO_LOG; 62 if (!strcasecmp(argv[N], "relastro.catalog")) TEMP_TYPE = TEMP_RELASTRO_CATALOG;76 if (!strcasecmp(argv[N], "relastro.catalog")) TEMP_TYPE = TEMP_RELASTRO_CATALOG; 63 77 if (!strcasecmp(argv[N], "relphot.catalog")) TEMP_TYPE = TEMP_RELPHOT_CATALOG; 78 if (!strcasecmp(argv[N], "relastro.catfull")) TEMP_TYPE = TEMP_RELASTRO_CAT_FULL; 79 if (!strcasecmp(argv[N], "checkastro.catfull"))TEMP_TYPE = TEMP_CHECKASTRO_CAT_FULL; 80 if (!strcasecmp(argv[N], "relphot.catfull")) TEMP_TYPE = TEMP_RELPHOT_CAT_FULL; 64 81 if (!strcasecmp(argv[N], "relphot.log")) TEMP_TYPE = TEMP_RELPHOT_LOG; 65 82 if (!strcasecmp(argv[N], "dvopsps.det")) TEMP_TYPE = TEMP_DVOPSPS_DET; … … 67 84 if (TEMP_TYPE == TEMP_NONE) { 68 85 gprint (GP_ERR, "USAGE: hosts purge-temp [-type (type)]\n"); 69 gprint (GP_ERR, " allowed types dvo.results, dvo.log, relphot. results, relphot.log]\n");86 gprint (GP_ERR, " allowed types dvo.results, dvo.log, relphot.catalog, relphot.log, relphot.catfull, relastro.catalog, relastro.catfull, checkastro.catfull, dvopsps.det, fixstkids.results]\n"); 70 87 return FALSE; 71 88 } … … 107 124 if (TEMP_TYPE == TEMP_RELPHOT_CATALOG) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname); 108 125 if (TEMP_TYPE == TEMP_RELPHOT_LOG) snprintf (name, DVO_MAX_PATH, "%s/log.rlpc.*", table->hosts[i].pathname); 126 if (TEMP_TYPE == TEMP_RELASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relastro.catalog.?????.?????.dat", table->hosts[i].pathname); 127 if (TEMP_TYPE == TEMP_CHECKASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/checkastro.catalog.?????.?????.dat", table->hosts[i].pathname); 128 if (TEMP_TYPE == TEMP_RELPHOT_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.?????.?????.dat", table->hosts[i].pathname); 109 129 if (TEMP_TYPE == TEMP_DVOPSPS_DET) snprintf (name, DVO_MAX_PATH, "%s/dvopsps.*.det.dat", table->hosts[i].pathname); 110 130 if (TEMP_TYPE == TEMP_FIXSTKIDS_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/fixstkids.results.*.dat", table->hosts[i].pathname); … … 115 135 if (TEMP_TYPE == TEMP_RELPHOT_CATALOG) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname); 116 136 if (TEMP_TYPE == TEMP_RELPHOT_LOG) snprintf (name, DVO_MAX_PATH, "%s/log.rlpc.*", table->hosts[i].pathname); 137 if (TEMP_TYPE == TEMP_RELASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relastro.catalog.%05d.?????.dat", table->hosts[i].pathname, PID); 138 if (TEMP_TYPE == TEMP_CHECKASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/checkastro.catalog.%05d.?????.dat", table->hosts[i].pathname, PID); 139 if (TEMP_TYPE == TEMP_RELPHOT_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.%05d.?????.dat", table->hosts[i].pathname, PID); 117 140 if (TEMP_TYPE == TEMP_DVOPSPS_DET) snprintf (name, DVO_MAX_PATH, "%s/dvopsps.%05d.*.det.dat", table->hosts[i].pathname, PID); 118 141 if (TEMP_TYPE == TEMP_FIXSTKIDS_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/fixstkids.results.%05d.*.dat", table->hosts[i].pathname, PID); … … 121 144 glob (name, 0, NULL, &pglob); 122 145 int j; 146 struct stat filestats; 123 147 for (j = 0; j < pglob.gl_pathc; j++) { 148 if (AGE > 0) { 149 if (stat(pglob.gl_pathv[j], &filestats)) { 150 gprint (GP_ERR, "failed to get stats for %s\n", pglob.gl_pathv[j]); 151 continue; 152 } 153 float myAge = (NOW - filestats.st_mtime) / 3600.0; 154 if (myAge < AGE) continue; 155 } 124 156 if (VERBOSE) gprint (GP_ERR, "unlink %s\n", pglob.gl_pathv[j]); 125 157 if (!DRYRUN) unlink (pglob.gl_pathv[j]); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/imdata.c
r34088 r37067 3 3 int imdata (int argc, char **argv) { 4 4 5 off_t i, j, k, n,I;5 off_t i, j, k, I; 6 6 int N, NPTS, found, mode, TimeSelect, TimeFormat; 7 7 off_t Nregions, NREGIONS; … … 152 152 for (i = 0; i < catalog.Nmeasure; i++) { 153 153 if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue; 154 n = catalog.measure[i].averef; 155 vec[0].elements.Flt[N] = catalog.average[n].R - catalog.measure[i].dR / 3600.0; 154 vec[0].elements.Flt[N] = catalog.measure[i].R; 156 155 N++; 157 156 CHECK_REALLOCATE (vec[0].elements.Flt, opihi_flt, NPTS, N, 1000); … … 161 160 for (i = 0; i < catalog.Nmeasure; i++) { 162 161 if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue; 163 n = catalog.measure[i].averef; 164 vec[0].elements.Flt[N] = catalog.average[n].D - catalog.measure[i].dD / 3600.0; 162 vec[0].elements.Flt[N] = catalog.measure[i].D; 165 163 N++; 166 164 CHECK_REALLOCATE (vec[0].elements.Flt, opihi_flt, NPTS, N, 1000); … … 194 192 for (i = 0; i < catalog.Nmeasure; i++) { 195 193 if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue; 196 n = catalog.measure[i].averef;194 //n = catalog.measure[i].averef; 197 195 // vec[0].elements.Flt[N] = catalog.average[n].M; 198 196 N++; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/imextract.c
r34088 r37067 185 185 gprint (GP_ERR, " Mcal : photometry calibration (mags)\n"); 186 186 gprint (GP_ERR, " dMcal : photometry calibration error (mags)\n"); 187 gprint (GP_ERR, " Xm: chisq of photometry calibration\n");187 gprint (GP_ERR, " Mchisq : chisq of photometry calibration\n"); 188 188 gprint (GP_ERR, " photcode : numeric photcode value for image\n"); 189 189 gprint (GP_ERR, " exptime : exposure duration (seconds)\n"); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/init.c
r34461 r37067 13 13 int cmpload PROTO((int, char **)); 14 14 int cmpread PROTO((int, char **)); 15 int coordimage PROTO((int, char **)); 16 int coordmosaic PROTO((int, char **)); 17 int psastro_model PROTO((int, char **)); 15 18 int ddmags PROTO((int, char **)); 16 19 int detrend PROTO((int, char **)); … … 63 66 {1, "avmatch", avmatch, "extract average data values matched to RA,DEC points"}, 64 67 {1, "badimages", badimages, "look for images with anomalous astrometry"}, 65 {1, "calextract", calextract, "extract photometry calibration"},66 {1, "calmextract", calmextract, "extract photometry calibration"},68 // {1, "calextract", calextract, "extract photometry calibration"}, 69 // {1, "calmextract", calmextract, "extract photometry calibration"}, 67 70 {1, "catdir", catdir_define,"re-define CATDIR"}, 68 {1, "ccd", ccd, "plot color-color diagram"},71 // {1, "ccd", ccd, "plot color-color diagram"}, 69 72 {1, "cmatch", cmatch, "match two catalogs"}, 70 {1, "cmd", cmd, "plot cmd of stars in current region"},73 // {1, "cmd", cmd, "plot cmd of stars in current region"}, 71 74 {1, "cmpload", cmpload, "load cmp file into ?"}, 72 75 {1, "cmpread", cmpread, "read data from cmp format files"}, 73 {1, "ddmags", ddmags, "plot magnitude differences"}, 76 {1, "coordimage", coordimage, "generate a map of the transformation residuals"}, 77 {1, "coordmosaic", coordmosaic, "generate a map of the distortion"}, 78 {1, "psastro_model", psastro_model, "save psastro-format astrometry model"}, 79 // {1, "ddmags", ddmags, "plot magnitude differences"}, 74 80 {1, "detrend", detrend, "extract from detrend database?"}, 75 {1, "dmagaves", dmagaves, "foo"},76 {1, "dmagmeas", dmagmeas, "foo"},77 {1, "dmags", dmags, "plot differential magnitudes between filters"},81 // {1, "dmagaves", dmagaves, "foo"}, 82 // {1, "dmagmeas", dmagmeas, "foo"}, 83 // {1, "dmags", dmags, "plot differential magnitudes between filters"}, 78 84 {1, "dmt", dmt, "plot mag scatter"}, 79 85 {1, "elixir", elixir, "talk to elixir"}, 80 {1, "fitcolors", fitcolors, "fit chip-to-chip color terms"},86 // {1, "fitcolors", fitcolors, "fit chip-to-chip color terms"}, 81 87 {1, "fitsed", fitsed, "fit stellar SEDs to objects"}, 82 88 {1, "gcat", gcat, "get catalog at location"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/lcurve.c
r34584 r37067 129 129 if (ErrorBars) dYvec.elements.Flt[N] = catalog.measure[m].dM; 130 130 Xvec.elements.Flt[N] = TimeValue (catalog.measure[m].t, TimeReference, TimeFormat); 131 Yvec.elements.Flt[N] = PhotCat (&catalog.measure[m] );131 Yvec.elements.Flt[N] = PhotCat (&catalog.measure[m], MAG_CLASS_PSF); 132 132 /**** need to use PhotRel optionally here ****/ 133 133 N++; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/lightcurve.c
r27435 r37067 121 121 dmvec[0].elements.Flt[N] = catalog.measure[m].dM; 122 122 if (RELPHOT) { 123 mvec[0].elements.Flt[N] = PhotCat (&catalog.measure[m] );123 mvec[0].elements.Flt[N] = PhotCat (&catalog.measure[m], MAG_CLASS_PSF); 124 124 } else { 125 mvec[0].elements.Flt[N] = PhotRel (&catalog.measure[m], &catalog.average[k], &catalog.secfilt[k*Nsecfilt] );125 mvec[0].elements.Flt[N] = PhotRel (&catalog.measure[m], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_PSF); 126 126 } 127 127 N++; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/photometry.c
r35416 r37067 41 41 } 42 42 43 # if (0) 43 44 /* selection criteria */ 44 45 /* selections based on Measure quantities */ … … 78 79 static time_t TimeReference; 79 80 static int TimeFormat; 80 81 # endif 82 83 # if (0) 81 84 int GetTimeSelection (time_t *tz, time_t *te) { 82 85 *tz = tzero; … … 298 301 return; 299 302 } 300 301 /* (re)load photcodes from photcode table */ 302 int InitPhotcodes () { 303 304 double ZERO_POINT; 305 char MasterPhotcodeFile[256]; 306 char CatdirPhotcodeFile[256]; 307 char *catdir; 308 309 if (VarConfig ("ZERO_PT", "%lf", &ZERO_POINT) == (char *) NULL) { 310 gprint (GP_ERR, "ZERO_PT undefined in config\n"); 311 return (FALSE); 312 } 313 SetZeroPoint (ZERO_POINT); 314 315 catdir = GetCATDIR(); 316 if (catdir == NULL) { 317 CatdirPhotcodeFile[0] = 0; 318 } else { 319 sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir); 320 } 321 322 if (VarConfig ("PHOTCODE_FILE", "%s", MasterPhotcodeFile) == (char *) NULL) { 323 gprint (GP_ERR, "PHOTCODE_FILE undefined in config\n"); 324 return (FALSE); 325 } 326 327 // XXX now that DVO does not allow write access, we can drop the MasterPhotcodeFile 328 if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) { 329 gprint (GP_ERR, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile); 330 return (FALSE); 331 } 332 return (TRUE); 333 } 334 303 # endif 304 305 # if (0) 335 306 int ListPhotSelections () { 336 307 … … 662 633 break; 663 634 case AVE_dMAG: 664 value = Phot dM(code, average, secfilt);635 value = PhotAveErr (code, average, secfilt); 665 636 break; 666 637 case AVE_Xm: … … 865 836 /* for ErrSelect, check average errors */ 866 837 if (ErrSelect) { 867 dM = Phot dM(code, average, secfilt);838 dM = PhotAveErr (code, average, secfilt); 868 839 if (dM > ErrValue) return (FALSE); 869 840 } … … 1121 1092 return (list); 1122 1093 } 1123 1094 # endif 1095 1096 # if (0) 1124 1097 double GetMeasure (int param, Average *average, Measure *measure, double mag) { 1125 1098 … … 1135 1108 break; 1136 1109 case MEAS_RA: /* OK */ 1137 value = average[0].R - measure[0].dR / 3600.0;1110 value = measure[0].R; 1138 1111 break; 1139 1112 case MEAS_DEC: /* OK */ 1140 value = average[0].D - measure[0].dD / 3600.0;1113 value = measure[0].D; 1141 1114 break; 1142 1115 case MEAS_DOPHOT: /* OK */ … … 1156 1129 break; 1157 1130 case MEAS_RA_OFFSET: /* OK */ 1158 value = measure[0].dR;1131 value = dvoOffsetR(measure, average); 1159 1132 break; 1160 1133 case MEAS_DEC_OFFSET: /* OK */ 1161 value = measure[0].dD;1134 value = dvoOffsetD(measure, average); 1162 1135 break; 1163 1136 case MEAS_FWHM: /* OK */ … … 1172 1145 value = measure[0].Xccd; 1173 1146 # else 1174 ra = average[0].R - measure[0].dR / 3600.0;1175 dec = average[0].D - measure[0].dD / 3600.0;1147 ra = measure[0].R; 1148 dec = measure[0].D; 1176 1149 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 1177 1150 if (image == NULL) break; … … 1185 1158 value = measure[0].Yccd; 1186 1159 # else 1187 ra = average[0].R - measure[0].dR / 3600.0;1188 dec = average[0].D - measure[0].dD / 3600.0;1160 ra = measure[0].R; 1161 dec = measure[0].D; 1189 1162 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 1190 1163 if (image == NULL) break; … … 1195 1168 # if 0 1196 1169 case MEAS_XMOSAIC: /* OK */ 1197 ra = average[0].R - measure[0].dR / 3600.0;1198 dec = average[0].D - measure[0].dD / 3600.0;1170 ra = measure[0].R; 1171 dec = measure[0].D; 1199 1172 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); // XXX not used anymore 1200 1173 if (mosaic == NULL) break; … … 1203 1176 break; 1204 1177 case MEAS_YMOSAIC: /* OK */ 1205 ra = average[0].R - measure[0].dR / 3600.0;1206 dec = average[0].D - measure[0].dD / 3600.0;1178 ra = measure[0].R; 1179 dec = measure[0].D; 1207 1180 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); // XXX not used anymore 1208 1181 if (mosaic == NULL) break; … … 1214 1187 return (value); 1215 1188 } 1189 # endif 1216 1190 1217 1191 /** the mosaic entries do not use the registered mosaic found -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/pmeasure.c
r34088 r37067 203 203 if (TimeSelect && (catalog.measure[m+k].t > tzero + trange)) continue; 204 204 if ((PhotcodeClip != -1) && (catalog.measure[m+k].photcode != PhotcodeClip)) continue; 205 mag = PhotCat (&catalog.measure[m+k] );205 mag = PhotCat (&catalog.measure[m+k], MAG_CLASS_PSF); 206 206 Zvec[Npts] = MIN (1.0, MAX (0.01, (mag - Mz) / Mr)); 207 207 if (LimExclude && (Zvec[Npts] > 0.99)) continue; 208 208 if (Zvec[Npts] < 0.011) continue; 209 R = catalog. average[i].R - catalog.measure[m+k].dR/3600.0;210 D = catalog. average[i].D - catalog.measure[m+k].dD/3600.0;209 R = catalog.measure[m+k].R; 210 D = catalog.measure[m+k].D; 211 211 // XXX drop this check 212 212 if ((R < Rmin) || (R > Rmax) || (D < -90.0) || (D > 90.0)) { 213 213 char *date; 214 214 date = ohana_sec_to_date (catalog.measure[m+k].t); 215 gprint (GP_LOG, "out: %f, %f : %s : (%f, %f) + (%f, %f)\n", R, D, date, catalog.average[i].R, catalog.average[i].D, catalog.measure[m+k]. dR/3600.0, catalog.measure[m+k].dD/3600.0);215 gprint (GP_LOG, "out: %f, %f : %s : (%f, %f) + (%f, %f)\n", R, D, date, catalog.average[i].R, catalog.average[i].D, catalog.measure[m+k].R, catalog.measure[m+k].D); 216 216 free (date); 217 217 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/showtile.c
r34584 r37067 34 34 coords.pc1_2 = coords.pc2_1 = 0.0; 35 35 coords.Npolyterms = 0; 36 strcpy (coords.ctype, " RA---TAN");36 strcpy (coords.ctype, "DEC--TAN"); 37 37 38 38 /* fill in top-left region */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/simage.c
r34584 r37067 43 43 /* get astrometry information */ 44 44 strcpy (coords.ctype, "NONE"); 45 gfits_scan (&header, "CTYPE 1", "%s", 1, coords.ctype);46 if (strcmp (coords.ctype, " RA---PLY")) {45 gfits_scan (&header, "CTYPE2", "%s", 1, coords.ctype); 46 if (strcmp (coords.ctype, "DEC--PLY")) { 47 47 gprint (GP_ERR, "ERROR: wrong astrometric info in header\n"); 48 48 return (FALSE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/subpix.c
r31635 r37067 138 138 for (j = 0; j < Nmeasure; j++) { 139 139 if (measure[j].t == Timage) { 140 Mabs = PhotCat (&measure[j] );140 Mabs = PhotCat (&measure[j], MAG_CLASS_PSF); 141 141 RD_to_XY (&X, &Y, Ra, Dec, &image[I].coords); 142 142 t = TimeValue (measure[j].t, TimeReference, TimeFormat); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/data.h
r34584 r37067 33 33 char **pageIDs; 34 34 } Book; 35 36 // the interpolating spline has valu 37 typedef struct { 38 int Nknots; 39 opihi_flt *xk; 40 opihi_flt *yk; 41 opihi_flt *y2; 42 char *name; 43 } Spline; 44 45 typedef struct { 46 char *name; 47 int Ninput; 48 int Nx; 49 int Ny; 50 float **buffers; 51 } MedImageType; 35 52 36 53 void InitData (void); … … 144 161 145 162 /* starfuncs.c */ 146 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max );163 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE); 147 164 int set_rough_radii (double Ra, double Ri, double Ro); 148 165 int get_rough_star (float *data, int Nx, int Ny, int x, int y, opihi_flt *xc, opihi_flt *yc, opihi_flt *sx, opihi_flt *sy, opihi_flt *sxy, opihi_flt *zs, opihi_flt *zp, opihi_flt *sk); … … 170 187 void FreeQueues (void); 171 188 void FreeBooks (void); 172 173 // the interpolating spline has valu174 typedef struct {175 int Nknots;176 opihi_flt *xk;177 opihi_flt *yk;178 opihi_flt *y2;179 char *name;180 } Spline;181 189 182 190 /* in SplineOps.c */ … … 207 215 double hermitian_10(double x); 208 216 217 /* in MedImageOps.c */ 218 void InitMedImages (); 219 void FreeMedImages (); 220 void FreeMedImage (MedImageType *medimage); 221 MedImageType *FindMedImage (char *name); 222 MedImageType *CreateMedImage (char *name, int Nx, int Ny); 223 int DeleteMedImage (MedImageType *medimage); 224 void ListMedImages (); 225 209 226 # endif -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/dvomath.h
r33662 r37067 55 55 } Buffer; 56 56 57 typedef enum { 58 ST_NONE, 59 ST_LEFT, 60 ST_RIGHT, 61 ST_COMMA, 62 ST_TRINARY, 63 ST_OR, 64 ST_AND, 65 ST_LOGIC, 66 ST_BITWISE, 67 ST_ADD, 68 ST_TIMES, 69 ST_POWER, 70 ST_UNARY, 71 ST_BINARY, 72 73 ST_VALUE, 74 ST_SCALAR_INT, 75 ST_SCALAR_FLT, 76 ST_VECTOR, 77 ST_VECTOR_TMP, 78 ST_MATRIX, 79 ST_MATRIX_TMP, 80 81 ST_STRING, 82 ST_STRING_TMP, 83 } StackVarType; 84 57 85 typedef struct { /* math stack structure */ 58 86 char *name; 59 chartype;87 StackVarType type; 60 88 Buffer *buffer; 61 89 Vector *vector; … … 77 105 void delete_stack PROTO((StackVar *stack, int Nstack)); 78 106 void clear_stack PROTO((StackVar *stack)); 79 void assign_stack PROTO((StackVar *stack, char *name, int type)); 107 void assign_stack PROTO((StackVar *stack, char *name, StackVarType type)); 108 109 int SSS_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 110 int VVV_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 111 int MMM_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 80 112 81 113 int VV_binary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, char *op)); … … 138 170 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 139 171 172 int VectorAssignData PROTO((Vector **vec, char *type, void *data, int Nrows, int Nval)); 173 int VectorAssignDataTranspose PROTO((Vector **vec, char *type, void *data, int Nrows, int Nval)); 174 140 175 /* buffer handling */ 141 176 Buffer *InitBuffer PROTO((void)); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/dvoshell.h
r35416 r37067 90 90 int wordhash PROTO((char *word)); 91 91 92 int GetMagMode PROTO((char *string));93 PhotCode *ParsePhotcodeField PROTO((char *field, int *mode, int def));94 int ParseMeasureField PROTO((dbField *field, char *fieldName));95 int ParseAverageField PROTO((dbField *field, char *fieldName));96 int ParseImageField PROTO((dbField *field, char *fieldName));97 98 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));99 dbValue dbExtractImages PROTO((Image *image, off_t Nimage, off_t N, dbField *field));100 101 92 int HostTableLaunchJobs PROTO((SkyList *sky, HostTable *table, char *basecmd, char *options, int VERBOSE)); 102 93 int HostTableParallelOps PROTO((SkyList *sky, int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE)); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/pantasks.h
r32632 r37067 116 116 117 117 int active; 118 int priority;118 int nicelevel; 119 119 120 120 } Task; … … 161 161 162 162 JobMode mode; /* local or controller? */ 163 int priority;163 int nicelevel; 164 164 char *realhost; 165 165 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/pcontrol.h
r33662 r37067 8 8 /** job status values **/ 9 9 typedef enum { 10 PCONTROL_JOB_NONE, // XXX OK? 10 11 PCONTROL_JOB_ALLJOBS, 11 12 PCONTROL_JOB_PENDING, … … 119 120 int exit_status; 120 121 int Reset; 121 int priority;122 int nicelevel; 122 123 JobMode mode; 123 124 JobStat state; … … 309 310 char *GetJobStackName (int StackID); 310 311 Stack *GetJobStackByName (char *name); 312 int GetJobStackIDbyName (char *name); 311 313 int PutJob (Job *job, int StackID, int where); 312 314 int PutJobSetState (Job *job, int StackID, int where, int state); 313 315 Job *PullJobByID (IDtype JobID, int *StackID); 314 316 Job *PullJobFromStackByID (int StackID, int ID); 315 IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts);317 IDtype AddJob (char *hostname, JobMode mode, int timeout, int nicelevel, int argc, char **argv, int Nxhosts, char **xhosts); 316 318 void DelJob (Job *job); 317 319 Host *UnlinkJobAndHost (Job *job); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/shell.h
r33662 r37067 166 166 // wrap readline in ohana mem functions: 167 167 char *opihi_readline PROTO((char *prompt)); 168 169 int set_list_varname (char *line, char *base, int N, int excelStyle); 168 170 169 171 /* gprint functions */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.data/Makefile
r34584 r37067 24 24 $(SDIR)/spline.$(ARCH).o \ 25 25 $(SDIR)/SplineOps.$(ARCH).o \ 26 $(SDIR)/MedImageOps.$(ARCH).o \ 26 27 $(SDIR)/mrqmin.$(ARCH).o \ 27 28 $(SDIR)/mrq2dmin.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.data/starfuncs.c
r34088 r37067 1 1 # include "data.h" 2 2 3 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max ) {3 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE) { 4 4 5 5 double *ring; … … 95 95 set_int_variable ("Npts", Npts); 96 96 97 gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag);97 if (VERBOSE) gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag); 98 98 99 99 return (mag); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/ListOps.c
r33963 r37067 185 185 186 186 // list (word) : nested list 187 // list (word) -x : not nested list 188 // list (word) -split : not nested list187 // list (word) -x : not nested list [-x may be the list of options below] 188 // list -excel (word) -x : 189 189 int is_list_data (char *line) { 190 190 191 char *comm, *temp; 192 193 temp = thisword (nextword (nextword (line))); 194 comm = thisword (line); 195 191 char *comm = NULL; 192 char *temp = NULL; 193 char *name = NULL; 194 char *opts = NULL; 195 196 comm = thisword (line); 196 197 if (comm == NULL) goto escape; 197 198 198 if (strcmp (comm, "list")) goto escape; 199 200 // name == name of the list in question 201 name = nextword (line); 202 203 // skip a -excel or -excel-style modifier 204 if (!strncmp("-excel", name, strlen("-excel"))) name = nextword (name); 205 if (!strncmp("-excel-style", name, strlen("-excel-style"))) name = nextword (name); 206 207 // get the thing following ptr, if any (opts points at a substring, temp is a new string) 208 opts = nextword (name); 209 temp = thisword (opts); 199 210 200 211 /* if (cond) (command) does not define a complete block */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/VectorIO.c
r35109 r37067 134 134 FTable ftable; 135 135 136 int i, j , k;136 int i, j; 137 137 FILE *f = NULL; 138 138 … … 202 202 assert (status); 203 203 204 # define ASSIGN_DATA(TYPE,OPTYPE) \ 205 /* assign the data to the actual vector */ \ 206 if (!strcmp (type, #TYPE)) { \ 207 TYPE *Ptr = data; \ 208 for (k = 0; k < Nrows; k++) { \ 209 for (j = 0; j < Nval; j++, Ptr++) { \ 210 vec[Nvec + j][0].elements.OPTYPE[k] = *Ptr; \ 211 } } } 212 213 // assign the data to the actual vector 214 ASSIGN_DATA(char, Int); 215 ASSIGN_DATA(short, Int); 216 ASSIGN_DATA(int, Int); 217 ASSIGN_DATA(int64_t, Int); 218 ASSIGN_DATA(float, Flt); 219 ASSIGN_DATA(double, Flt); 204 if (!VectorAssignData(&vec[Nvec], type, data, Nrows, Nval)) { 205 // free unneeded things 206 gprint (GP_ERR, "trouble parsing data block type %s\n", type); 207 return (NULL); 208 } 220 209 221 210 free (data); … … 241 230 // return (FALSE); 242 231 } 232 233 # define ASSIGN_DATA(TYPE,DTYPE,OPTYPE) \ 234 /* assign the data to the actual vector */ \ 235 if (!strcmp (type, #TYPE)) { \ 236 DTYPE *Ptr = data; \ 237 for (k = 0; k < Nrows; k++) { \ 238 for (j = 0; j < Nval; j++, Ptr++) { \ 239 vec[j][0].elements.OPTYPE[k] = *Ptr; \ 240 } } return TRUE; } 241 242 int VectorAssignData (Vector **vec, char *type, void *data, int Nrows, int Nval) { 243 244 int j, k; 245 246 // assign the data to the actual vector 247 ASSIGN_DATA(byte, char, Int); 248 ASSIGN_DATA(char, char, Int); 249 ASSIGN_DATA(short, short, Int); 250 ASSIGN_DATA(int, int, Int); 251 ASSIGN_DATA(int64_t, int64_t, Int); 252 ASSIGN_DATA(float, float, Flt); 253 ASSIGN_DATA(double, double, Flt); 254 255 return FALSE; 256 } 257 258 # define ASSIGN_DATA_TRANSPOSE(TYPE,DTYPE,OPTYPE) \ 259 /* assign the data to the actual vector */ \ 260 if (!strcmp (type, #TYPE)) { \ 261 DTYPE *Ptr = data; \ 262 for (k = 0; k < Nrows; k++) { \ 263 for (j = 0; j < Nval; j++, Ptr++) { \ 264 vec[k][0].elements.OPTYPE[j] = *Ptr; \ 265 } } return TRUE; } 266 267 int VectorAssignDataTranspose (Vector **vec, char *type, void *data, int Nrows, int Nval) { 268 269 int j, k; 270 271 // assign the data to the actual vector 272 ASSIGN_DATA_TRANSPOSE(byte, char, Int); 273 ASSIGN_DATA_TRANSPOSE(char, char, Int); 274 ASSIGN_DATA_TRANSPOSE(short, short, Int); 275 ASSIGN_DATA_TRANSPOSE(int, int, Int); 276 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Int); 277 ASSIGN_DATA_TRANSPOSE(float, float, Flt); 278 ASSIGN_DATA_TRANSPOSE(double, double, Flt); 279 280 return FALSE; 281 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/check_stack.c
r34260 r37067 12 12 13 13 for (i = 0; i < Nstack; i++) { 14 if (stack[i].type == 'X') {14 if (stack[i].type == ST_VALUE) { 15 15 16 16 /** if this is a number, put it on the list of scalars and move on. assume value is … … 27 27 stack[i].IntValue = strtol (stack[i].name, &c2, 0); 28 28 if ((fabs(stack[i].FltValue) > MAX_INT) && (c1 == stack[i].name + strlen (stack[i].name))) { 29 stack[i].type = 'S'; // 'S' ==(float)29 stack[i].type = ST_SCALAR_FLT; // (float) 30 30 continue; 31 31 } 32 32 if (c2 == stack[i].name + strlen (stack[i].name)) { 33 stack[i].type = 's'; // 's' ==(int)33 stack[i].type = ST_SCALAR_INT; // (int) 34 34 continue; 35 35 } 36 36 if (c1 == stack[i].name + strlen (stack[i].name)) { 37 stack[i].type = 'S'; // 'S' ==(float)37 stack[i].type = ST_SCALAR_FLT; // (float) 38 38 continue; 39 39 } … … 42 42 if (IsBuffer (stack[i].name)) { 43 43 stack[i].buffer = SelectBuffer (stack[i].name, OLDBUFFER, TRUE); 44 stack[i].type = 'M';44 stack[i].type = ST_MATRIX; 45 45 if (Nx == -1) { 46 46 Nx = stack[i].buffer[0].matrix.Naxis[0]; … … 63 63 if (IsVector (stack[i].name)) { 64 64 stack[i].vector = SelectVector (stack[i].name, OLDVECTOR, FALSE); 65 stack[i].type = 'V';65 stack[i].type = ST_VECTOR; 66 66 67 67 if (Nv == -1) Nv = stack[i].vector[0].Nelements; … … 80 80 81 81 /* this is not a scalar, vector, or matrix. must be string */ 82 stack[i].type = 'W';82 stack[i].type = ST_STRING; 83 83 } 84 84 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r34088 r37067 4 4 StackVar *convert_to_RPN (int argc, char **argv, int *nstack) { 5 5 6 inttype;6 StackVarType type; 7 7 int i, j, Nstack, Nop_stack, NSTACK; 8 8 StackVar *stack, *op_stack; … … 21 21 22 22 /* decide on priority of object */ 23 type = 0; 23 type = ST_NONE; 24 25 /* trinary operations */ 26 if (!strcmp (argv[i], "?")) { type = ST_TRINARY; goto gotit; } 27 if (!strcmp (argv[i], ":")) { type = ST_COMMA; goto gotit; } 28 24 29 /* unary operations */ 25 if (!strcmp (argv[i], "abs")) { type = 9; goto gotit; }26 if (!strcmp (argv[i], "int")) { type = 9; goto gotit; }27 if (!strcmp (argv[i], " exp")) { type = 9; goto gotit; }28 if (!strcmp (argv[i], " ten")) { type = 9; goto gotit; }29 if (!strcmp (argv[i], " log")) { type = 9; goto gotit; }30 if (!strcmp (argv[i], " ln")) { type = 9; goto gotit; }31 if (!strcmp (argv[i], " sqrt")) { type = 9; goto gotit; }32 if (!strcmp (argv[i], " erf")) { type = 9; goto gotit; }33 34 if (!strcmp (argv[i], " sinh")) { type = 9; goto gotit; }35 if (!strcmp (argv[i], " cosh")) { type = 9; goto gotit; }36 if (!strcmp (argv[i], " asinh")) { type = 9; goto gotit; }37 if (!strcmp (argv[i], " acosh")) { type = 9; goto gotit; }38 39 if (!strcmp (argv[i], " sin")) { type = 9; goto gotit; }40 if (!strcmp (argv[i], " cos")) { type = 9; goto gotit; }41 if (!strcmp (argv[i], " tan")) { type = 9; goto gotit; }42 if (!strcmp (argv[i], " dsin")) { type = 9; goto gotit; }43 if (!strcmp (argv[i], " dcos")) { type = 9; goto gotit; }44 if (!strcmp (argv[i], "d tan")) { type = 9; goto gotit; }45 if (!strcmp (argv[i], " asin")) { type = 9; goto gotit; }46 if (!strcmp (argv[i], " acos")) { type = 9; goto gotit; }47 if (!strcmp (argv[i], "a tan")) { type = 9; goto gotit; }48 if (!strcmp (argv[i], " dasin")) { type = 9; goto gotit; }49 if (!strcmp (argv[i], " dacos")) { type = 9; goto gotit; }50 if (!strcmp (argv[i], "da tan")) { type = 9; goto gotit; }51 52 if (!strcmp (argv[i], " lgamma")) { type = 9; goto gotit; }53 54 if (!strcmp (argv[i], "rnd")) { type = 9; goto gotit; }55 if (!strcmp (argv[i], "xramp")) { type = 9; goto gotit; }56 if (!strcmp (argv[i], "yramp")) { type = 9; goto gotit; }57 if (!strcmp (argv[i], "ramp")) { type = 9; goto gotit; }58 if (!strcmp (argv[i], "zero")) { type = 9; goto gotit; }59 if (!strcmp (argv[i], "--")) { type = 9; goto gotit; }60 if (!strcmp (argv[i], "not")) { type = 9; goto gotit; }61 if (!strcmp (argv[i], "isinf")) { type = 9; goto gotit; }62 if (!strcmp (argv[i], "isnan")) { type = 9; goto gotit; }30 if (!strcmp (argv[i], "abs")) { type = ST_UNARY; goto gotit; } 31 if (!strcmp (argv[i], "int")) { type = ST_UNARY; goto gotit; } 32 if (!strcmp (argv[i], "floor")) { type = ST_UNARY; goto gotit; } 33 if (!strcmp (argv[i], "round")) { type = ST_UNARY; goto gotit; } 34 if (!strcmp (argv[i], "ceil")) { type = ST_UNARY; goto gotit; } 35 if (!strcmp (argv[i], "rint")) { type = ST_UNARY; goto gotit; } 36 if (!strcmp (argv[i], "exp")) { type = ST_UNARY; goto gotit; } 37 if (!strcmp (argv[i], "ten")) { type = ST_UNARY; goto gotit; } 38 if (!strcmp (argv[i], "log")) { type = ST_UNARY; goto gotit; } 39 if (!strcmp (argv[i], "ln")) { type = ST_UNARY; goto gotit; } 40 if (!strcmp (argv[i], "sqrt")) { type = ST_UNARY; goto gotit; } 41 if (!strcmp (argv[i], "erf")) { type = ST_UNARY; goto gotit; } 42 if (!strcmp (argv[i], "sinh")) { type = ST_UNARY; goto gotit; } 43 if (!strcmp (argv[i], "cosh")) { type = ST_UNARY; goto gotit; } 44 if (!strcmp (argv[i], "asinh")) { type = ST_UNARY; goto gotit; } 45 if (!strcmp (argv[i], "acosh")) { type = ST_UNARY; goto gotit; } 46 if (!strcmp (argv[i], "sin")) { type = ST_UNARY; goto gotit; } 47 if (!strcmp (argv[i], "cos")) { type = ST_UNARY; goto gotit; } 48 if (!strcmp (argv[i], "tan")) { type = ST_UNARY; goto gotit; } 49 if (!strcmp (argv[i], "dsin")) { type = ST_UNARY; goto gotit; } 50 if (!strcmp (argv[i], "dcos")) { type = ST_UNARY; goto gotit; } 51 if (!strcmp (argv[i], "dtan")) { type = ST_UNARY; goto gotit; } 52 if (!strcmp (argv[i], "asin")) { type = ST_UNARY; goto gotit; } 53 if (!strcmp (argv[i], "acos")) { type = ST_UNARY; goto gotit; } 54 if (!strcmp (argv[i], "atan")) { type = ST_UNARY; goto gotit; } 55 if (!strcmp (argv[i], "dasin")) { type = ST_UNARY; goto gotit; } 56 if (!strcmp (argv[i], "dacos")) { type = ST_UNARY; goto gotit; } 57 if (!strcmp (argv[i], "datan")) { type = ST_UNARY; goto gotit; } 58 if (!strcmp (argv[i], "lgamma")) { type = ST_UNARY; goto gotit; } 59 if (!strcmp (argv[i], "rnd")) { type = ST_UNARY; goto gotit; } 60 if (!strcmp (argv[i], "xramp")) { type = ST_UNARY; goto gotit; } 61 if (!strcmp (argv[i], "yramp")) { type = ST_UNARY; goto gotit; } 62 if (!strcmp (argv[i], "ramp")) { type = ST_UNARY; goto gotit; } 63 if (!strcmp (argv[i], "zero")) { type = ST_UNARY; goto gotit; } 64 if (!strcmp (argv[i], "--")) { type = ST_UNARY; goto gotit; } 65 if (!strcmp (argv[i], "not")) { type = ST_UNARY; goto gotit; } 66 if (!strcmp (argv[i], "isinf")) { type = ST_UNARY; goto gotit; } 67 if (!strcmp (argv[i], "isnan")) { type = ST_UNARY; goto gotit; } 63 68 64 69 /* binary operations */ 65 if (!strcmp (argv[i], "^")) { type = 8; goto gotit; } 66 67 if (!strcmp (argv[i], "@")) { type = 7; goto gotit; } 68 if (!strcmp (argv[i], "/")) { type = 7; goto gotit; } 69 if (!strcmp (argv[i], "*")) { type = 7; goto gotit; } 70 if (!strcmp (argv[i], "%")) { type = 7; goto gotit; } 71 72 if (!strcmp (argv[i], "+")) { type = 6; goto gotit; } 73 if (!strcmp (argv[i], "-")) { type = 6; goto gotit; } 70 if (!strcmp (argv[i], "^")) { type = ST_POWER; goto gotit; } 71 72 if (!strcmp (argv[i], "max")) { type = ST_BINARY; strcpy (argv[i], "U"); goto gotit; } 73 if (!strcmp (argv[i], "min")) { type = ST_BINARY; strcpy (argv[i], "D"); goto gotit; } 74 if (!strcmp (argv[i], "atan2")) { type = ST_BINARY; goto gotit; } 75 if (!strcmp (argv[i], ",")) { type = ST_COMMA; goto gotit; } 76 77 if (!strcmp (argv[i], "@")) { type = ST_TIMES; goto gotit; } 78 if (!strcmp (argv[i], "/")) { type = ST_TIMES; goto gotit; } 79 if (!strcmp (argv[i], "*")) { type = ST_TIMES; goto gotit; } 80 if (!strcmp (argv[i], "%")) { type = ST_TIMES; goto gotit; } 81 82 if (!strcmp (argv[i], "+")) { type = ST_ADD; goto gotit; } 83 if (!strcmp (argv[i], "-")) { type = ST_ADD; goto gotit; } 74 84 75 if (!strcmp (argv[i], "&")) { type = 5; goto gotit; }76 if (!strcmp (argv[i], "|")) { type = 5; goto gotit; }77 78 if (!strcmp (argv[i], "<")) { type = 4; goto gotit; }79 if (!strcmp (argv[i], ">")) { type = 4; goto gotit; }80 if (!strcmp (argv[i], "==")) { type = 4; strcpy (argv[i], "E"); goto gotit; }81 if (!strcmp (argv[i], "!=")) { type = 4; strcpy (argv[i], "N"); goto gotit; }82 if (!strcmp (argv[i], "<=")) { type = 4; strcpy (argv[i], "L"); goto gotit; }83 if (!strcmp (argv[i], ">=")) { type = 4; strcpy (argv[i], "G"); goto gotit; }84 if (!strcmp (argv[i], ">>")) { type = 4; strcpy (argv[i], "U"); goto gotit; }85 if (!strcmp (argv[i], "<<")) { type = 4; strcpy (argv[i], "D"); goto gotit; }86 87 if (!strcmp (argv[i], "&&")) { type = 3; strcpy (argv[i], "A"); goto gotit; }88 if (!strcmp (argv[i], "||")) { type = 3; strcpy (argv[i], "O"); goto gotit; }89 90 if (!strcmp (argv[i], "(")) { type = 2;goto gotit; }91 if (!strcmp (argv[i], ")")) { type = 1; goto gotit; }85 if (!strcmp (argv[i], "&")) { type = ST_BITWISE; goto gotit; } 86 if (!strcmp (argv[i], "|")) { type = ST_BITWISE; goto gotit; } 87 88 if (!strcmp (argv[i], "<")) { type = ST_LOGIC; goto gotit; } 89 if (!strcmp (argv[i], ">")) { type = ST_LOGIC; goto gotit; } 90 if (!strcmp (argv[i], "==")) { type = ST_LOGIC; strcpy (argv[i], "E"); goto gotit; } 91 if (!strcmp (argv[i], "!=")) { type = ST_LOGIC; strcpy (argv[i], "N"); goto gotit; } 92 if (!strcmp (argv[i], "<=")) { type = ST_LOGIC; strcpy (argv[i], "L"); goto gotit; } 93 if (!strcmp (argv[i], ">=")) { type = ST_LOGIC; strcpy (argv[i], "G"); goto gotit; } 94 if (!strcmp (argv[i], ">>")) { type = ST_LOGIC; strcpy (argv[i], "U"); goto gotit; } 95 if (!strcmp (argv[i], "<<")) { type = ST_LOGIC; strcpy (argv[i], "D"); goto gotit; } 96 97 if (!strcmp (argv[i], "&&")) { type = ST_AND; strcpy (argv[i], "A"); goto gotit; } 98 if (!strcmp (argv[i], "||")) { type = ST_OR ; strcpy (argv[i], "O"); goto gotit; } 99 100 if (!strcmp (argv[i], "(")) { type = ST_LEFT; goto gotit; } 101 if (!strcmp (argv[i], ")")) { type = ST_RIGHT; goto gotit; } 92 102 93 103 gotit: 94 104 /* choose how to deal with object */ 95 105 switch (type) { 96 case 8: /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */106 case ST_POWER: /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */ 97 107 /* pop previous, higher operators from OP stack to stack */ 98 108 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) { … … 105 115 Nop_stack ++; 106 116 break; 107 case 9: /* unary OPs */ 108 case 7: /* binary OPs */ 109 case 6: 110 case 5: 111 case 4: 112 case 3: 117 case ST_UNARY: 118 case ST_BINARY: 119 case ST_TRINARY: 120 case ST_TIMES: 121 case ST_ADD: 122 case ST_BITWISE: 123 case ST_LOGIC: 124 case ST_AND: 125 case ST_OR: 113 126 /* pop previous, higher or equal operators from OP stack to stack */ 114 127 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type >= type); j--) { … … 121 134 Nop_stack ++; 122 135 break; 123 case 2:136 case ST_LEFT: 124 137 /* push operator on OP stack */ 125 138 assign_stack (&op_stack[Nop_stack], argv[i], type); … … 127 140 Nop_stack ++; 128 141 break; 129 case 1:142 case ST_RIGHT: 130 143 /* pop rest of operators from OP stack to stack, looking for '(' */ 131 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != 2); j--) {132 move_stack (&stack[Nstack], &op_stack[j]); 133 Nstack ++; 134 Nop_stack --; 135 } 136 if ((j == -1) || (op_stack[j].type != 2)) {144 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != ST_LEFT); j--) { 145 move_stack (&stack[Nstack], &op_stack[j]); 146 Nstack ++; 147 Nop_stack --; 148 } 149 if ((j == -1) || (op_stack[j].type != ST_LEFT)) { 137 150 push_error ("syntax error: mismatched parenthesis"); 138 151 Nstack = 0; … … 144 157 Nop_stack --; 145 158 break; 146 case 0: 159 case ST_COMMA: 160 /* pop rest of operators from OP stack to stack, looking for '(' (but do not pop the '(')*/ 161 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != ST_LEFT) && (op_stack[j].type != ST_TRINARY); j--) { 162 move_stack (&stack[Nstack], &op_stack[j]); 163 Nstack ++; 164 Nop_stack --; 165 } 166 break; 167 case ST_NONE: 147 168 /* place the value (number or vector/matrix name) on stack */ 148 169 /* value of 'X' is used as sentinel until we sort out values */ 149 assign_stack (&stack[Nstack], argv[i], 'X');170 assign_stack (&stack[Nstack], argv[i], ST_VALUE); 150 171 Nstack ++; 151 172 break; 173 174 default: 175 push_error ("invalid stack typ"); 176 Nstack = 0; 177 goto cleanup; 152 178 } 153 179 } 154 180 155 /* dump remaining operators on stack, checking for ' )' */181 /* dump remaining operators on stack, checking for '(' */ 156 182 for (j = Nop_stack - 1; j >= 0; j--) { 157 if (op_stack[j].type == 2) {183 if (op_stack[j].type == ST_LEFT) { 158 184 push_error ("syntax error: mismatched parenthesis"); 159 185 Nstack = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/dvomath.c
r31635 r37067 80 80 sprintf (outname, "%s", stack[0].name); 81 81 } else { 82 if (stack[0].type == 's') {82 if (stack[0].type == ST_SCALAR_INT) { 83 83 sprintf (outname, "%d", stack[0].IntValue); 84 84 } else { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/evaluate_stack.c
r34088 r37067 2 2 # define VERBOSE 0 3 3 4 # define TWO_OP(A,B,FUNC) \ 5 if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \ 6 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 7 8 # define ONE_OP(A,FUNC) \ 9 if (!strncasecmp (&stack[i - 1].type, A, 1)) \ 10 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); 4 // all three operands must have the same type 5 # define THREE_OP(A,FUNC) \ 6 if ((stack[i - 3].type == A) && (stack[i - 2].type == A) && (stack[i - 1].type == A)) { \ 7 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 8 goto got_three_op; } \ 9 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A) && (stack[i - 1].type == A)) { \ 10 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 11 goto got_three_op; } \ 12 if ((stack[i - 3].type == A) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A)) { \ 13 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 14 goto got_three_op; } \ 15 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A)) { \ 16 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 17 goto got_three_op; } \ 18 if ((stack[i - 3].type == A) && (stack[i - 2].type == A) && (stack[i - 1].type == A+1)) { \ 19 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 20 goto got_three_op; } \ 21 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A) && (stack[i - 1].type == A+1)) { \ 22 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 23 goto got_three_op; } \ 24 if ((stack[i - 3].type == A) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A+1)) { \ 25 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 26 goto got_three_op; } \ 27 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A+1)) { \ 28 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 29 goto got_three_op; } \ 30 31 // A & B value types all have 2 possible values 32 # define TWO_OP(A,B,FUNC) { \ 33 if ((stack[i - 2].type == A) && (stack[i - 1].type == B)) { \ 34 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 35 goto got_two_op; } \ 36 if ((stack[i - 2].type == A+1) && (stack[i - 1].type == B)) { \ 37 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 38 goto got_two_op; } \ 39 if ((stack[i - 2].type == A) && (stack[i - 1].type == B+1)) { \ 40 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 41 goto got_two_op; } \ 42 if ((stack[i - 2].type == A+1) && (stack[i - 1].type == B+1)) { \ 43 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 44 goto got_two_op; } \ 45 } 46 47 # define ONE_OP(A,FUNC) \ 48 if (stack[i - 1].type == A) { \ 49 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); \ 50 goto got_one_op; } 11 51 12 52 int evaluate_stack (StackVar *stack, int *Nstack) { … … 20 60 21 61 if (*Nstack == 1) { 22 if ((stack[0].type == 'S') || (stack[0].type == 's')) {62 if ((stack[0].type == ST_SCALAR_INT) || (stack[0].type == ST_SCALAR_FLT)) { 23 63 clear_stack (&tmp_stack); 24 64 return (TRUE); 25 65 } 26 if (stack[0].type == 'V') {66 if (stack[0].type == ST_VECTOR) { 27 67 /* need to make a copy so we set output value? */ 28 68 V_unary (&tmp_stack, &stack[0], "="); … … 30 70 return (TRUE); 31 71 } 32 if (stack[0].type == 'M') {72 if (stack[0].type == ST_MATRIX) { 33 73 /* need to make a copy so we set output value? */ 34 74 M_unary (&tmp_stack, &stack[0], "="); … … 56 96 } 57 97 58 /***** binary operators *****/ 59 if ((stack[i].type >= 3) && (stack[i].type <= 8)) { 60 61 if (i < 2) { /* need two variables to operate on */ 62 sprintf (line, "syntax error: binary operator with one operand: %s\n", stack[i].name); 98 /***** trinary operators *****/ 99 switch (stack[i].type) { 100 case ST_TRINARY: 101 102 if (i < 3) { /* need two variables to operate on */ 103 snprintf (line, 512, "syntax error: trinary operator without three operands: %s\n", stack[i].name); 104 push_error (line); 105 clear_stack (&tmp_stack); 106 return (FALSE); 107 } 108 109 status = FALSE; 110 THREE_OP (ST_MATRIX,MMM_trinary); 111 THREE_OP (ST_VECTOR,VVV_trinary); 112 113 THREE_OP (ST_SCALAR_FLT,SSS_trinary); 114 THREE_OP (ST_SCALAR_INT,SSS_trinary); 115 116 /* there are no valid unary string operators */ 117 push_error ("invalid operands for trinary operator (mismatch types?)"); 118 clear_stack (&tmp_stack); 119 return (FALSE); 120 121 got_three_op: 122 if (!status) { 123 snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s or %s\n", stack[i-1].name, stack[i-2].name, stack[i-3].name); 124 push_error (line); 125 clear_stack (&tmp_stack); 126 return (FALSE); 127 } 128 move_stack (&stack[i-3], &tmp_stack); 129 delete_stack (&stack[i-2], 3); 130 for (j = i + 1; j < *Nstack; j++) { 131 move_stack (&stack[j-3], &stack[j]); 132 } 133 *Nstack -= 3; 134 i -= 3; 135 init_stack (&tmp_stack); 136 continue; 137 138 /***** binary operators *****/ 139 case ST_OR: 140 case ST_AND: 141 case ST_LOGIC: 142 case ST_BITWISE: 143 case ST_ADD: 144 case ST_TIMES: 145 case ST_POWER: 146 case ST_BINARY: 147 148 if (i < 2) { /* need two variables to operate on */ 149 snprintf (line, 512, "syntax error: binary operator with one operand: %s\n", stack[i].name); 150 push_error (line); 151 clear_stack (&tmp_stack); 152 return (FALSE); 153 } 154 155 status = FALSE; 156 TWO_OP (ST_MATRIX,ST_MATRIX,MM_binary); 157 TWO_OP (ST_MATRIX,ST_VECTOR,MV_binary); 158 TWO_OP (ST_MATRIX,ST_SCALAR_INT,MS_binary); 159 160 TWO_OP (ST_VECTOR,ST_MATRIX,VM_binary); 161 TWO_OP (ST_VECTOR,ST_VECTOR,VV_binary); 162 TWO_OP (ST_VECTOR,ST_SCALAR_INT,VS_binary); 163 164 TWO_OP (ST_SCALAR_INT,ST_MATRIX,SM_binary); 165 TWO_OP (ST_SCALAR_INT,ST_VECTOR,SV_binary); 166 TWO_OP (ST_SCALAR_INT,ST_SCALAR_INT,SS_binary); 167 168 TWO_OP (ST_SCALAR_FLT,ST_MATRIX,SM_binary); 169 TWO_OP (ST_SCALAR_FLT,ST_VECTOR,SV_binary); 170 TWO_OP (ST_SCALAR_FLT,ST_SCALAR_INT,SS_binary); 171 172 TWO_OP (ST_STRING,ST_STRING,WW_binary); 173 TWO_OP (ST_STRING,ST_SCALAR_INT,WW_binary); 174 TWO_OP (ST_SCALAR_INT,ST_STRING,WW_binary); 175 176 got_two_op: 177 if (!status) { 178 snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 179 push_error (line); 180 clear_stack (&tmp_stack); 181 return (FALSE); 182 } 183 move_stack (&stack[i-2], &tmp_stack); 184 delete_stack (&stack[i-1], 2); 185 for (j = i + 1; j < *Nstack; j++) { 186 move_stack (&stack[j - 2], &stack[j]); 187 } 188 *Nstack -= 2; 189 i -= 2; 190 init_stack (&tmp_stack); 191 continue; 192 193 /***** unary operators **/ 194 case ST_UNARY: 195 196 if (i < 1) { /* need one variable to operate on */ 197 push_error ("syntax error: unary operator with no operand"); 198 clear_stack (&tmp_stack); 199 return (FALSE); 200 } 201 202 ONE_OP (ST_MATRIX, M_unary); 203 ONE_OP (ST_MATRIX_TMP, M_unary); 204 205 ONE_OP (ST_VECTOR, V_unary); 206 ONE_OP (ST_VECTOR_TMP, V_unary); 207 208 ONE_OP (ST_SCALAR_INT, S_unary); 209 ONE_OP (ST_SCALAR_FLT, S_unary); 210 211 /* there are no valid unary string operators */ 212 push_error ("syntax error: no valid string unary ops"); 213 clear_stack (&tmp_stack); 214 return (FALSE); 215 216 got_one_op: 217 move_stack (&stack[i-1], &tmp_stack); 218 delete_stack (&stack[i], 1); 219 for (j = i + 1; j < *Nstack; j++) { 220 move_stack (&stack[j - 1], &stack[j]); 221 } 222 init_stack (&tmp_stack); 223 *Nstack -= 1; 224 i -= 1; 225 continue; 226 227 case ST_SCALAR_INT: 228 case ST_SCALAR_FLT: 229 case ST_VECTOR: 230 case ST_VECTOR_TMP: 231 case ST_MATRIX: 232 case ST_MATRIX_TMP: 233 case ST_STRING: 234 continue; 235 236 default: 237 snprintf (line, 512, "syntax error: unexpected operator type %s", stack[i].name); 63 238 push_error (line); 64 239 clear_stack (&tmp_stack); 65 240 return (FALSE); 66 } 67 68 status = FALSE; 69 TWO_OP ("M","M",MM_binary); 70 TWO_OP ("M","V",MV_binary); 71 TWO_OP ("M","S",MS_binary); 72 TWO_OP ("V","M",VM_binary); 73 TWO_OP ("V","V",VV_binary); 74 TWO_OP ("V","S",VS_binary); 75 TWO_OP ("S","M",SM_binary); 76 TWO_OP ("S","V",SV_binary); 77 TWO_OP ("S","S",SS_binary); 78 TWO_OP ("W","W",WW_binary); 79 TWO_OP ("W","S",WW_binary); 80 TWO_OP ("S","W",WW_binary); 81 82 if (!status) { 83 sprintf (line, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 84 push_error (line); 85 clear_stack (&tmp_stack); 86 return (FALSE); 87 } 88 move_stack (&stack[i-2], &tmp_stack); 89 delete_stack (&stack[i-1], 2); 90 for (j = i + 1; j < *Nstack; j++) { 91 move_stack (&stack[j - 2], &stack[j]); 92 } 93 *Nstack -= 2; 94 i -= 2; 95 init_stack (&tmp_stack); 96 continue; 97 } 98 99 /***** unary operators **/ 100 if (stack[i].type == 9) { 101 102 if (i < 1) { /* need one variable to operate on */ 103 push_error ("syntax error: unary operator with no operand"); 104 clear_stack (&tmp_stack); 105 return (FALSE); 106 } 107 108 ONE_OP ("M", M_unary); 109 ONE_OP ("V", V_unary); 110 ONE_OP ("S", S_unary); 111 112 /* there are no valid unary string operators */ 113 if (!strncasecmp (&stack[i - 1].type, "W", 1)) { 114 push_error ("syntax error: no valid string unary ops"); 115 clear_stack (&tmp_stack); 116 return (FALSE); 117 } 118 119 move_stack (&stack[i-1], &tmp_stack); 120 delete_stack (&stack[i], 1); 121 for (j = i + 1; j < *Nstack; j++) { 122 move_stack (&stack[j - 1], &stack[j]); 123 } 124 init_stack (&tmp_stack); 125 *Nstack -= 1; 126 i -= 1; 127 continue; 128 } 241 } 129 242 } 130 243 clear_stack (&tmp_stack); … … 160 273 161 274 for (i = 0; i < Nstack; i++) { 162 if (IsBufferPtr (stack[i].buffer) && (stack[i].type == 'm')) {275 if (IsBufferPtr (stack[i].buffer) && (stack[i].type == ST_MATRIX_TMP)) { 163 276 if (VERBOSE) gprint (GP_ERR, "free %s (buff) (%lx)\n", stack[i].name, (long) stack[i].buffer); 164 277 free (stack[i].buffer[0].header.buffer); … … 167 280 stack[i].buffer = NULL; 168 281 } 169 if (IsVectorPtr (stack[i].vector) && (stack[i].type == 'v')) {282 if (IsVectorPtr (stack[i].vector) && (stack[i].type == ST_VECTOR_TMP)) { 170 283 if (VERBOSE) gprint (GP_ERR, "free %s (vect) (%lx)\n", stack[i].name, (long) stack[i].vector); 171 284 free (stack[i].vector[0].elements.Ptr); … … 193 306 } 194 307 195 void assign_stack (StackVar *stack, char *name, inttype) {308 void assign_stack (StackVar *stack, char *name, StackVarType type) { 196 309 stack->name = strcreate (name); 197 310 stack->type = type; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/macro_list.c
r7917 r37067 11 11 } 12 12 13 macro = MatchMacro (argv[ 0], FALSE, TRUE);13 macro = MatchMacro (argv[1], FALSE, TRUE); 14 14 if (macro == NULL) { 15 15 gprint (GP_ERR, "%s: Macro not found\n", argv[1]); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/stack_math.c
r34342 r37067 6 6 */ 7 7 8 // XXX we temporarily drop the concept of using one of the temporary input vectors for 9 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 10 // as well as their temporary state 11 12 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 8 int SSS_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 9 10 char line[512]; // this is only used to report an error 11 12 // set up the possible operations : int OP int -> int, all else yield float 13 // OP is the operation performed on *M1 and *M2 14 # define SSS_FUNC(OP) { \ 15 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT) && (V3->type == ST_SCALAR_FLT)) { \ 16 opihi_flt M1 = V1[0].FltValue; \ 17 opihi_flt M2 = V2[0].FltValue; \ 18 opihi_flt M3 = V3[0].FltValue; \ 19 OUT[0].type = ST_SCALAR_FLT; \ 20 OUT[0].FltValue = OP; \ 21 break; \ 22 } \ 23 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT) && (V3->type == ST_SCALAR_INT)) { \ 24 opihi_int M1 = V1[0].IntValue; \ 25 opihi_int M2 = V2[0].IntValue; \ 26 opihi_int M3 = V3[0].IntValue; \ 27 OUT[0].type = ST_SCALAR_INT; \ 28 OUT[0].IntValue = OP; \ 29 break; \ 30 } \ 31 } 32 33 switch (op[0]) { 34 case '?': SSS_FUNC(M1 ? M2: M3); 35 default: 36 snprintf (line, 512, "error: op %c not defined!", op[0]); 37 push_error (line); 38 return (FALSE); 39 } 40 # undef SSS_FUNC 41 42 clear_stack (V1); 43 clear_stack (V2); 44 clear_stack (V3); 45 return (TRUE); 46 47 } 48 49 int VVV_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 13 50 14 51 int i, Nx; … … 19 56 return (FALSE); 20 57 } 58 if (V1[0].vector[0].Nelements != V3[0].vector[0].Nelements) { 59 return (FALSE); 60 } 21 61 22 62 Nx = V1[0].vector[0].Nelements; … … 24 64 // create the output vector guaranteed to be temporary until the very end 25 65 OUT[0].vector = InitVector (); 26 OUT[0].type = 'v'; 66 OUT[0].type = ST_VECTOR_TMP; 67 68 // set up the possible operations : int OP int -> int, all else yield float 69 // OP is the operation performed on *M1 and *M2 70 # define VVV_FUNC(OP) { \ 71 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_FLT)) { \ 72 CopyVector (OUT[0].vector, V1[0].vector); \ 73 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 74 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 75 opihi_flt *M3 = V3[0].vector[0].elements.Flt; \ 76 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 77 for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) { \ 78 *out = OP; \ 79 } \ 80 break; \ 81 } \ 82 if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_INT)) { \ 83 CopyVector (OUT[0].vector, V1[0].vector); \ 84 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 85 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 86 opihi_int *M3 = V3[0].vector[0].elements.Int; \ 87 opihi_int *out = OUT[0].vector[0].elements.Int; \ 88 for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) { \ 89 *out = OP; \ 90 } \ 91 break; \ 92 } \ 93 } 94 95 switch (op[0]) { 96 case '?': VVV_FUNC(*M1 ? *M2: *M3); 97 default: 98 snprintf (line, 512, "error: op %c not defined!", op[0]); 99 push_error (line); 100 return (FALSE); 101 } 102 # undef VVV_FUNC 103 104 /** free up any temporary buffers: **/ 105 106 if (V1[0].type == ST_VECTOR_TMP) { 107 free (V1[0].vector[0].elements.Ptr); 108 free (V1[0].vector); 109 } 110 if (V2[0].type == ST_VECTOR_TMP) { 111 free (V2[0].vector[0].elements.Ptr); 112 free (V2[0].vector); 113 } 114 if (V3[0].type == ST_VECTOR_TMP) { 115 free (V3[0].vector[0].elements.Ptr); 116 free (V3[0].vector); 117 } 118 /* at the end, V1 and V2 are deleted only if they were temporary */ 119 120 clear_stack (V1); 121 clear_stack (V2); 122 clear_stack (V3); 123 return (TRUE); 124 125 } 126 127 int MMM_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 128 129 int i, Nx, Ny; 130 float *out, *M1, *M2, *M3; 131 char line[512]; // this is only used to report an error 132 133 Nx = V1[0].buffer[0].matrix.Naxis[0]; 134 Ny = V1[0].buffer[0].matrix.Naxis[1]; 135 136 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 137 OUT[0].buffer = V1[0].buffer; 138 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 139 } else { 140 if (V2[0].type == ST_MATRIX_TMP) { /** use V2 as temp buffer, but header of V1 **/ 141 OUT[0].buffer = V2[0].buffer; 142 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 143 } else { /* no spare temp buffer */ 144 OUT[0].buffer = InitBuffer (); 145 CopyBuffer (OUT[0].buffer, V1[0].buffer); 146 } 147 } 148 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 149 150 M1 = (float *)V1[0].buffer[0].matrix.buffer; 151 M2 = (float *)V2[0].buffer[0].matrix.buffer; 152 M3 = (float *)V3[0].buffer[0].matrix.buffer; 153 out = (float *)OUT[0].buffer[0].matrix.buffer; 154 155 # define MMM_FUNC(OP) \ 156 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++, M3++) { \ 157 *out = OP; \ 158 } \ 159 break; 160 161 switch (op[0]) { 162 case '?': MMM_FUNC(*M1 ? *M2: *M3); 163 default: 164 snprintf (line, 512, "error: op %c not defined!", op[0]); 165 push_error (line); 166 return (FALSE); 167 } 168 # undef MMM_FUNC 169 170 /** free up any temporary buffers: **/ 171 172 if (V1[0].type == ST_MATRIX_TMP) { 173 free (V1[0].buffer[0].header.buffer); 174 free (V1[0].buffer[0].matrix.buffer); 175 free (V1[0].buffer); 176 } 177 if (V2[0].type == ST_MATRIX_TMP) { 178 free (V2[0].buffer[0].header.buffer); 179 free (V2[0].buffer[0].matrix.buffer); 180 free (V2[0].buffer); 181 } 182 if (V3[0].type == ST_MATRIX_TMP) { 183 free (V3[0].buffer[0].header.buffer); 184 free (V3[0].buffer[0].matrix.buffer); 185 free (V3[0].buffer); 186 } 187 188 /* at the end, V1 and V2 are deleted only if they were temporary */ 189 190 clear_stack (V1); 191 clear_stack (V2); 192 clear_stack (V3); 193 return (TRUE); 194 195 } 196 197 // XXX we temporarily drop the concept of using one of the temporary input vectors for 198 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 199 // as well as their temporary state 200 201 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 202 203 int i, Nx; 204 char line[512]; // this is only used to report an error 205 206 // the vectors have to match in length 207 if (V1[0].vector[0].Nelements != V2[0].vector[0].Nelements) { 208 return (FALSE); 209 } 210 211 Nx = V1[0].vector[0].Nelements; 212 213 // create the output vector guaranteed to be temporary until the very end 214 OUT[0].vector = InitVector (); 215 OUT[0].type = ST_VECTOR_TMP; 27 216 28 217 // set up the possible operations : int OP int -> int, all else yield float … … 59 248 break; \ 60 249 } \ 61 if ((FTYPE == 'S') && (V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \250 if ((FTYPE == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 62 251 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 63 252 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 82 271 83 272 switch (op[0]) { 84 case '+': VV_FUNC('s', *M1 + *M2); 85 case '-': VV_FUNC('s', *M1 - *M2); 86 case '*': VV_FUNC('s', *M1 * *M2); 87 case '/': VV_FUNC('S', *M1 / (opihi_flt) *M2); 88 case '%': VV_FUNC('s', (long long)*M1 % (long long)*M2); 89 case '^': VV_FUNC('S', pow (*M1, *M2)); 90 case '@': VV_FUNC('S', DEG_RAD*atan2 (*M1, *M2)); 91 case 'D': VV_FUNC('s', MIN (*M1, *M2)); 92 case 'U': VV_FUNC('s', MAX (*M1, *M2)); 93 case '<': VV_FUNC('s', (*M1 < *M2) ? 1 : 0); 94 case '>': VV_FUNC('s', (*M1 > *M2) ? 1 : 0); 95 case '&': VV_FUNC('s', ((long long)*M1 & (long long)*M2)); 96 case '|': VV_FUNC('s', ((long long)*M1 | (long long)*M2)); 97 case 'E': VV_FUNC('s', (*M1 == *M2) ? 1 : 0); 98 case 'N': VV_FUNC('s', (*M1 != *M2) ? 1 : 0); 99 case 'L': VV_FUNC('s', (*M1 <= *M2) ? 1 : 0); 100 case 'G': VV_FUNC('s', (*M1 >= *M2) ? 1 : 0); 101 case 'A': VV_FUNC('s', (*M1 && *M2) ? 1 : 0); 102 case 'O': VV_FUNC('s', (*M1 || *M2) ? 1 : 0); 273 case '+': VV_FUNC(ST_SCALAR_INT, *M1 + *M2); 274 case '-': VV_FUNC(ST_SCALAR_INT, *M1 - *M2); 275 case '*': VV_FUNC(ST_SCALAR_INT, *M1 * *M2); 276 case '/': VV_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) *M2); 277 case '%': VV_FUNC(ST_SCALAR_INT, (long long)*M1 % (long long)*M2); 278 case '^': VV_FUNC(ST_SCALAR_FLT, pow (*M1, *M2)); 279 case '@': VV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, *M2)); 280 case 'a': VV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, *M2)); 281 case 'D': VV_FUNC(ST_SCALAR_INT, MIN (*M1, *M2)); 282 case 'U': VV_FUNC(ST_SCALAR_INT, MAX (*M1, *M2)); 283 case '<': VV_FUNC(ST_SCALAR_INT, (*M1 < *M2) ? 1 : 0); 284 case '>': VV_FUNC(ST_SCALAR_INT, (*M1 > *M2) ? 1 : 0); 285 case '&': VV_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)*M2)); 286 case '|': VV_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)*M2)); 287 case 'E': VV_FUNC(ST_SCALAR_INT, (*M1 == *M2) ? 1 : 0); 288 case 'N': VV_FUNC(ST_SCALAR_INT, (*M1 != *M2) ? 1 : 0); 289 case 'L': VV_FUNC(ST_SCALAR_INT, (*M1 <= *M2) ? 1 : 0); 290 case 'G': VV_FUNC(ST_SCALAR_INT, (*M1 >= *M2) ? 1 : 0); 291 case 'A': VV_FUNC(ST_SCALAR_INT, (*M1 && *M2) ? 1 : 0); 292 case 'O': VV_FUNC(ST_SCALAR_INT, (*M1 || *M2) ? 1 : 0); 103 293 default: 104 s printf (line, "error: op %c not defined!", op[0]);294 snprintf (line, 512, "error: op %c not defined!", op[0]); 105 295 push_error (line); 106 296 return (FALSE); … … 110 300 /** free up any temporary buffers: **/ 111 301 112 if (V1[0].type == 'v') {302 if (V1[0].type == ST_VECTOR_TMP) { 113 303 free (V1[0].vector[0].elements.Ptr); 114 304 free (V1[0].vector); 115 305 } 116 if (V2[0].type == 'v') {306 if (V2[0].type == ST_VECTOR_TMP) { 117 307 free (V2[0].vector[0].elements.Ptr); 118 308 free (V2[0].vector); … … 134 324 135 325 OUT[0].vector = InitVector (); 136 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/326 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 137 327 138 328 // set up the possible operations : int OP int -> int, all else yield float 139 329 // OP is the operation performed on *M1 and *M2 140 330 # define SV_FUNC(FTYPE,OP) { \ 141 if ((V1->type == 'S') && (V2->vector->type == OPIHI_FLT)) { \331 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) { \ 142 332 CopyVector (OUT[0].vector, V2[0].vector); \ 143 333 opihi_flt M1 = V1[0].FltValue; \ … … 149 339 break; \ 150 340 } \ 151 if ((V1->type == 'S') && (V2->vector->type != OPIHI_FLT)) { \341 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 152 342 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 153 343 opihi_flt M1 = V1[0].FltValue; \ … … 159 349 break; \ 160 350 } \ 161 if ((V1->type == 's') && (V2->vector->type == OPIHI_FLT)) { \351 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) { \ 162 352 CopyVector (OUT[0].vector, V2[0].vector); \ 163 353 opihi_int M1 = V1[0].IntValue; \ … … 169 359 break; \ 170 360 } \ 171 if ((FTYPE == 'S') && (V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \361 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 172 362 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 173 363 opihi_int M1 = V1[0].IntValue; \ … … 179 369 break; \ 180 370 } \ 181 if ((V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \371 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 182 372 CopyVector (OUT[0].vector, V2[0].vector); \ 183 373 opihi_int M1 = V1[0].IntValue; \ … … 192 382 193 383 switch (op[0]) { 194 case '+': SV_FUNC('s', M1 + *M2); 195 case '-': SV_FUNC('s', M1 - *M2); 196 case '*': SV_FUNC('s', M1 * *M2); 197 case '/': SV_FUNC('S', M1 / (opihi_flt) *M2); 198 case '%': SV_FUNC('s', (long long) M1 % (long long) *M2); 199 case '^': SV_FUNC('S', pow (M1, *M2)); 200 case '@': SV_FUNC('S', DEG_RAD*atan2 (M1, *M2)); 201 case 'D': SV_FUNC('s', MIN (M1, *M2)); 202 case 'U': SV_FUNC('s', MAX (M1, *M2)); 203 case '<': SV_FUNC('s', (M1 < *M2) ? 1 : 0); 204 case '>': SV_FUNC('s', (M1 > *M2) ? 1 : 0); 205 case '&': SV_FUNC('s', ((long long)M1 & (long long)*M2)); 206 case '|': SV_FUNC('s', ((long long)M1 | (long long)*M2)); 207 case 'E': SV_FUNC('s', (M1 == *M2) ? 1 : 0); 208 case 'N': SV_FUNC('s', (M1 != *M2) ? 1 : 0); 209 case 'L': SV_FUNC('s', (M1 <= *M2) ? 1 : 0); 210 case 'G': SV_FUNC('s', (M1 >= *M2) ? 1 : 0); 211 case 'A': SV_FUNC('s', (M1 && *M2) ? 1 : 0); 212 case 'O': SV_FUNC('s', (M1 || *M2) ? 1 : 0); 384 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2); 385 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2); 386 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2); 387 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2); 388 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2); 389 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2)); 390 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 391 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 392 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2)); 393 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2)); 394 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0); 395 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0); 396 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2)); 397 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2)); 398 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0); 399 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0); 400 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0); 401 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0); 402 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0); 403 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0); 213 404 default: 214 s printf (line, "error: op %c not defined!", op[0]);405 snprintf (line, 512, "error: op %c not defined!", op[0]); 215 406 push_error (line); 216 407 return (FALSE); … … 219 410 220 411 /** free up any temporary buffers: **/ 221 if (V2[0].type == 'v') {412 if (V2[0].type == ST_VECTOR_TMP) { 222 413 free (V2[0].vector[0].elements.Ptr); 223 414 free (V2[0].vector); … … 240 431 241 432 OUT[0].vector = InitVector (); 242 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/433 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 243 434 244 435 // set up the possible operations : int OP int -> int, all else yield float 245 436 // OP is the operation performed on *M1 and *M2 246 437 # define VS_FUNC(FTYPE,OP) { \ 247 if ((V2->type == 'S') && (V1->vector->type == OPIHI_FLT)) { \438 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) { \ 248 439 CopyVector (OUT[0].vector, V1[0].vector); \ 249 440 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 255 446 break; \ 256 447 } \ 257 if ((V2->type == 'S') && (V1->vector->type != OPIHI_FLT)) { \448 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) { \ 258 449 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 259 450 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 265 456 break; \ 266 457 } \ 267 if ((V2->type == 's') && (V1->vector->type == OPIHI_FLT)) { \458 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) { \ 268 459 CopyVector (OUT[0].vector, V1[0].vector); \ 269 460 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 275 466 break; \ 276 467 } \ 277 if ((FTYPE == 'S') && (V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \468 if ((FTYPE == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 278 469 CopyVector (OUT[0].vector, V1[0].vector); \ 279 470 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 285 476 break; \ 286 477 } \ 287 if ((V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \478 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 288 479 CopyVector (OUT[0].vector, V1[0].vector); \ 289 480 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 298 489 299 490 switch (op[0]) { 300 case '+': VS_FUNC('s', *M1 + M2); 301 case '-': VS_FUNC('s', *M1 - M2); 302 case '*': VS_FUNC('s', *M1 * M2); 303 case '/': VS_FUNC('S', *M1 / (opihi_flt) M2); 304 case '%': VS_FUNC('s', (long long) *M1 % (long long) M2); 305 case '^': VS_FUNC('S', pow (*M1, M2)); 306 case '@': VS_FUNC('S', DEG_RAD*atan2 (*M1, M2)); 307 case 'D': VS_FUNC('s', MIN (*M1, M2)); 308 case 'U': VS_FUNC('s', MAX (*M1, M2)); 309 case '<': VS_FUNC('s', (*M1 < M2) ? 1 : 0); 310 case '>': VS_FUNC('s', (*M1 > M2) ? 1 : 0); 311 case '&': VS_FUNC('s', ((long long)*M1 & (long long)M2)); 312 case '|': VS_FUNC('s', ((long long)*M1 | (long long)M2)); 313 case 'E': VS_FUNC('s', (*M1 == M2) ? 1 : 0); 314 case 'N': VS_FUNC('s', (*M1 != M2) ? 1 : 0); 315 case 'L': VS_FUNC('s', (*M1 <= M2) ? 1 : 0); 316 case 'G': VS_FUNC('s', (*M1 >= M2) ? 1 : 0); 317 case 'A': VS_FUNC('s', (*M1 && M2) ? 1 : 0); 318 case 'O': VS_FUNC('s', (*M1 || M2) ? 1 : 0); 491 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2); 492 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2); 493 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2); 494 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2); 495 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2); 496 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2)); 497 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 498 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 499 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2)); 500 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2)); 501 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0); 502 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0); 503 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2)); 504 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2)); 505 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0); 506 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0); 507 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0); 508 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0); 509 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0); 510 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0); 319 511 default: 320 s printf (line, "error: op %c not defined!", op[0]);512 snprintf (line, 512, "error: op %c not defined!", op[0]); 321 513 push_error (line); 322 514 return (FALSE); … … 326 518 /** free up any temporary buffers: **/ 327 519 328 if (V1[0].type == 'v') {520 if (V1[0].type == ST_VECTOR_TMP) { 329 521 free (V1[0].vector[0].elements.Ptr); 330 522 free (V1[0].vector); … … 353 545 354 546 /* if possible, use V1 as temp buffer, otherwise create new one */ 355 if (V1[0].type == 'm') {547 if (V1[0].type == ST_MATRIX_TMP) { 356 548 OUT[0].buffer = V1[0].buffer; 357 V1[0].type = 'M'; /* prevent it from being freed below */549 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 358 550 } else { 359 551 /* do buffer.matrix.buffer and buffer.header.buffer get correctly zeroed? */ … … 361 553 CopyBuffer (OUT[0].buffer, V1[0].buffer); 362 554 } 363 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/555 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 364 556 365 557 float *M1 = (float *) V1[0].buffer[0].matrix.buffer; … … 395 587 case '^': MV_FUNC(pow (*M1, *M2)); 396 588 case '@': MV_FUNC(DEG_RAD*atan2 (*M1, *M2)); 589 case 'a': MV_FUNC(DEG_RAD*atan2 (*M1, *M2)); 397 590 case 'D': MV_FUNC(MIN (*M1, *M2)); 398 591 case 'U': MV_FUNC(MAX (*M1, *M2)); … … 408 601 case 'O': MV_FUNC((*M1 || *M2) ? 1 : 0); 409 602 default: 410 s printf (line, "error: op %c not defined!", op[0]);603 snprintf (line, 512, "error: op %c not defined!", op[0]); 411 604 push_error (line); 412 605 return (FALSE); … … 416 609 /** free up any temporary buffers: **/ 417 610 418 if (V1[0].type == 'm') {611 if (V1[0].type == ST_MATRIX_TMP) { 419 612 free (V1[0].buffer[0].header.buffer); 420 613 free (V1[0].buffer[0].matrix.buffer); 421 614 free (V1[0].buffer); 422 615 } 423 if (V2[0].type == 'v') {616 if (V2[0].type == ST_VECTOR_TMP) { 424 617 free (V2[0].vector[0].elements.Ptr); 425 618 free (V2[0].vector); … … 446 639 447 640 /* if possible, use V2 as temp buffer, otherwise create new one */ 448 if (V2[0].type == 'm') {641 if (V2[0].type == ST_MATRIX_TMP) { 449 642 OUT[0].buffer = V2[0].buffer; 450 V2[0].type = 'M'; /* prevent it from being freed below */643 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 451 644 } else { /* no spare temp buffer */ 452 645 OUT[0].buffer = InitBuffer (); 453 646 CopyBuffer (OUT[0].buffer, V2[0].buffer); 454 647 } 455 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/648 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 456 649 457 650 float *M2 = (float *) V2[0].buffer[0].matrix.buffer; … … 487 680 case '^': VM_FUNC(pow (*M1, *M2)); 488 681 case '@': VM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 682 case 'a': VM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 489 683 case 'D': VM_FUNC(MIN (*M1, *M2)); 490 684 case 'U': VM_FUNC(MAX (*M1, *M2)); … … 500 694 case 'O': VM_FUNC((*M1 || *M2) ? 1 : 0); 501 695 default: 502 s printf (line, "error: op %c not defined!", op[0]);696 snprintf (line, 512, "error: op %c not defined!", op[0]); 503 697 push_error (line); 504 698 return (FALSE); … … 508 702 /** free up any temporary buffers: **/ 509 703 510 if (V1[0].type == 'v') {704 if (V1[0].type == ST_VECTOR_TMP) { 511 705 free (V1[0].vector[0].elements.Ptr); 512 706 free (V1[0].vector); 513 707 } 514 if (V2[0].type == 'm') {708 if (V2[0].type == ST_MATRIX_TMP) { 515 709 free (V2[0].buffer[0].header.buffer); 516 710 free (V2[0].buffer[0].matrix.buffer); … … 535 729 Ny = V1[0].buffer[0].matrix.Naxis[1]; 536 730 537 if (V1[0].type == 'm') { /** use V1 as temp buffer **/731 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 538 732 OUT[0].buffer = V1[0].buffer; 539 V1[0].type = 'M'; /* prevent it from being freed below */733 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 540 734 } else { 541 if (V2[0].type == 'm') { /** use V2 as temp buffer, but header of V1 **/735 if (V2[0].type == ST_MATRIX_TMP) { /** use V2 as temp buffer, but header of V1 **/ 542 736 OUT[0].buffer = V2[0].buffer; 543 V2[0].type = 'M'; /* prevent it from being freed below */737 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 544 738 } else { /* no spare temp buffer */ 545 739 OUT[0].buffer = InitBuffer (); … … 547 741 } 548 742 } 549 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/743 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 550 744 551 745 M1 = (float *)V1[0].buffer[0].matrix.buffer; … … 567 761 case '^': MM_FUNC(pow (*M1, *M2)); 568 762 case '@': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 763 case 'a': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 569 764 case 'D': MM_FUNC(MIN (*M1, *M2)); 570 765 case 'U': MM_FUNC(MAX (*M1, *M2)); … … 580 775 case 'O': MM_FUNC((*M1 || *M2) ? 1 : 0); 581 776 default: 582 s printf (line, "error: op %c not defined!", op[0]);777 snprintf (line, 512, "error: op %c not defined!", op[0]); 583 778 push_error (line); 584 779 return (FALSE); … … 588 783 /** free up any temporary buffers: **/ 589 784 590 if (V1[0].type == 'm') {785 if (V1[0].type == ST_MATRIX_TMP) { 591 786 free (V1[0].buffer[0].header.buffer); 592 787 free (V1[0].buffer[0].matrix.buffer); 593 788 free (V1[0].buffer); 594 789 } 595 if (V2[0].type == 'm') {790 if (V2[0].type == ST_MATRIX_TMP) { 596 791 free (V2[0].buffer[0].header.buffer); 597 792 free (V2[0].buffer[0].matrix.buffer); … … 615 810 616 811 /* if possible, use V1 as temp buffer, otherwise create new one */ 617 if (V1[0].type == 'm') {812 if (V1[0].type == ST_MATRIX_TMP) { 618 813 OUT[0].buffer = V1[0].buffer; 619 V1[0].type = 'M'; /* prevent it from being freed below */814 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 620 815 } else { 621 816 OUT[0].buffer = InitBuffer (); 622 817 CopyBuffer (OUT[0].buffer, V1[0].buffer); 623 818 } 624 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/819 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 625 820 626 821 float *M1 = (float *)V1[0].buffer[0].matrix.buffer; … … 628 823 629 824 # define MS_FUNC(OP) { \ 630 if (V2->type == 'S') { \825 if (V2->type == ST_SCALAR_FLT) { \ 631 826 opihi_flt M2 = V2[0].FltValue; \ 632 827 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ … … 635 830 break; \ 636 831 } \ 637 if (V2->type == 's') { \832 if (V2->type == ST_SCALAR_INT) { \ 638 833 opihi_int M2 = V2[0].IntValue; \ 639 834 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ … … 652 847 case '^': MS_FUNC(pow (*M1, M2)); 653 848 case '@': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 849 case 'a': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 654 850 case 'D': MS_FUNC(MIN (*M1, M2)); 655 851 case 'U': MS_FUNC(MAX (*M1, M2)); … … 665 861 case 'O': MS_FUNC((*M1 || M2) ? 1 : 0); 666 862 default: 667 s printf (line, "error: op %c not defined!", op[0]);863 snprintf (line, 512, "error: op %c not defined!", op[0]); 668 864 push_error (line); 669 865 return (FALSE); … … 671 867 # undef MS_FUNC 672 868 673 if (V1[0].type == 'm') {869 if (V1[0].type == ST_MATRIX_TMP) { 674 870 free (V1[0].buffer[0].header.buffer); 675 871 free (V1[0].buffer[0].matrix.buffer); … … 691 887 Ny = V2[0].buffer[0].matrix.Naxis[1]; 692 888 693 if (V2[0].type == 'm') { /* V2[0] is NOT temporary, we can't use it for storage */889 if (V2[0].type == ST_MATRIX_TMP) { /* V2[0] is NOT temporary, we can't use it for storage */ 694 890 OUT[0].buffer = V2[0].buffer; 695 V2[0].type = 'M'; /* prevent it from being freed below */891 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 696 892 } else { 697 893 OUT[0].buffer = InitBuffer (); 698 894 CopyBuffer (OUT[0].buffer, V2[0].buffer); 699 895 } 700 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/896 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 701 897 702 898 float *M2 = (float *)V2[0].buffer[0].matrix.buffer; … … 704 900 705 901 # define SM_FUNC(OP) { \ 706 if (V1->type == 'S') { \902 if (V1->type == ST_SCALAR_FLT) { \ 707 903 opihi_flt M1 = V1[0].FltValue; \ 708 904 for (i = 0; i < Nx*Ny; i++, out++, M2++) { \ … … 711 907 break; \ 712 908 } \ 713 if (V1->type == 's') { \909 if (V1->type == ST_SCALAR_INT) { \ 714 910 opihi_int M1 = V1[0].IntValue; \ 715 911 for (i = 0; i < Nx*Ny; i++, out++, M2++) { \ … … 728 924 case '^': SM_FUNC(pow (M1, *M2)); 729 925 case '@': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 926 case 'a': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 730 927 case 'D': SM_FUNC(MIN (M1, *M2)); 731 928 case 'U': SM_FUNC(MAX (M1, *M2)); … … 741 938 case 'O': SM_FUNC((M1 || *M2) ? 1 : 0); 742 939 default: 743 s printf (line, "error: op %c not defined!", op[0]);940 snprintf (line, 512, "error: op %c not defined!", op[0]); 744 941 push_error (line); 745 942 return (FALSE); … … 747 944 # undef SM_FUNC 748 945 749 if (V2[0].type == 'm') {946 if (V2[0].type == ST_MATRIX_TMP) { 750 947 free (V2[0].buffer[0].header.buffer); 751 948 free (V2[0].buffer[0].matrix.buffer); … … 764 961 765 962 # define SS_FUNC(FTYPE,OP) { \ 766 if ((V1->type == 'S') && (V2->type == 'S')) { \963 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) { \ 767 964 opihi_flt M1 = V1[0].FltValue; \ 768 965 opihi_flt M2 = V2[0].FltValue; \ 769 OUT[0].type = 'S'; \966 OUT[0].type = ST_SCALAR_FLT; \ 770 967 OUT[0].FltValue = OP; \ 771 968 break; \ 772 969 } \ 773 if ((V1->type == 'S') && (V2->type == 's')) { \970 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) { \ 774 971 opihi_flt M1 = V1[0].FltValue; \ 775 972 opihi_int M2 = V2[0].IntValue; \ 776 OUT[0].type = 'S'; \973 OUT[0].type = ST_SCALAR_FLT; \ 777 974 OUT[0].FltValue = OP; \ 778 975 break; \ 779 976 } \ 780 if ((V1->type == 's') && (V2->type == 'S')) { \977 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) { \ 781 978 opihi_int M1 = V1[0].IntValue; \ 782 979 opihi_flt M2 = V2[0].FltValue; \ 783 OUT[0].type = 'S'; \980 OUT[0].type = ST_SCALAR_FLT; \ 784 981 OUT[0].FltValue = OP; \ 785 982 break; \ 786 983 } \ 787 if ((FTYPE == 'S') && (V1->type == 's') && (V2->type == 's')) { \984 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 788 985 opihi_int M1 = V1[0].IntValue; \ 789 986 opihi_int M2 = V2[0].IntValue; \ 790 OUT[0].type = 'S'; \987 OUT[0].type = ST_SCALAR_FLT; \ 791 988 OUT[0].FltValue = OP; \ 792 989 break; \ 793 990 } \ 794 if ((V1->type == 's') && (V2->type == 's')) { \991 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 795 992 opihi_int M1 = V1[0].IntValue; \ 796 993 opihi_int M2 = V2[0].IntValue; \ 797 OUT[0].type = 's'; \994 OUT[0].type = ST_SCALAR_INT; \ 798 995 OUT[0].IntValue = OP; \ 799 996 break; \ … … 802 999 803 1000 switch (op[0]) { 804 case '+': SS_FUNC('s', M1 + M2); 805 case '-': SS_FUNC('s', M1 - M2); 806 case '*': SS_FUNC('s', M1 * M2); 807 case '/': SS_FUNC('S', M1 / (opihi_flt) M2); 808 case '%': SS_FUNC('s', (long long) M1 % (long long) M2); 809 case '^': SS_FUNC('S', pow (M1, M2)); 810 case '@': SS_FUNC('S', DEG_RAD*atan2 (M1, M2)); 811 case 'D': SS_FUNC('s', MIN (M1, M2)); 812 case 'U': SS_FUNC('s', MAX (M1, M2)); 813 case '<': SS_FUNC('s', (M1 < M2) ? 1 : 0); 814 case '>': SS_FUNC('s', (M1 > M2) ? 1 : 0); 815 case '&': SS_FUNC('s', ((long long)M1 & (long long)M2)); 816 case '|': SS_FUNC('s', ((long long)M1 | (long long)M2)); 817 case 'E': SS_FUNC('s', (M1 == M2) ? 1 : 0); 818 case 'N': SS_FUNC('s', (M1 != M2) ? 1 : 0); 819 case 'L': SS_FUNC('s', (M1 <= M2) ? 1 : 0); 820 case 'G': SS_FUNC('s', (M1 >= M2) ? 1 : 0); 821 case 'A': SS_FUNC('s', (M1 && M2) ? 1 : 0); 822 case 'O': SS_FUNC('s', (M1 || M2) ? 1 : 0); 1001 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2); 1002 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2); 1003 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2); 1004 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2); 1005 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2); 1006 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2)); 1007 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1008 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1009 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2)); 1010 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2)); 1011 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0); 1012 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0); 1013 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2)); 1014 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2)); 1015 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0); 1016 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0); 1017 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0); 1018 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0); 1019 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0); 1020 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0); 823 1021 default: 824 s printf (line, "error: op %c not defined!", op[0]);1022 snprintf (line, 512, "error: op %c not defined!", op[0]); 825 1023 push_error (line); 826 1024 return (FALSE); … … 844 1042 845 1043 if ((op[0] != 'N') && (op[0] != 'E')) { 846 s printf (line, "error: op %c not defined for string operations!", op[0]);1044 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); 847 1045 push_error (line); 848 1046 return (FALSE); … … 853 1051 thus: string == number -> false */ 854 1052 855 if ( !strncasecmp (&V1[0].type, "S", 1)) {1053 if (V1[0].type == ST_SCALAR_INT) { 856 1054 value = (op[0] == 'N'); 857 1055 goto escape; 858 1056 } 859 if (!strncasecmp (&V2[0].type, "S", 1)) { 1057 if (V1[0].type == ST_SCALAR_FLT) { 1058 value = (op[0] == 'N'); 1059 goto escape; 1060 } 1061 if (V2[0].type == ST_SCALAR_INT) { 1062 value = (op[0] == 'N'); 1063 goto escape; 1064 } 1065 if (V2[0].type == ST_SCALAR_FLT) { 860 1066 value = (op[0] == 'N'); 861 1067 goto escape; … … 870 1076 break; 871 1077 default: 872 s printf (line, "error: op %c not defined for string operations!", op[0]);1078 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); 873 1079 push_error (line); 874 1080 return (FALSE); … … 877 1083 escape: 878 1084 OUT[0].FltValue = value; 879 OUT[0].type = 'S';1085 OUT[0].type = ST_SCALAR_FLT; 880 1086 881 1087 clear_stack (V1); … … 891 1097 892 1098 # define S_FUNC(OP,FTYPE) { \ 893 if (V1->type == 'S') { \1099 if (V1->type == ST_SCALAR_FLT) { \ 894 1100 opihi_flt M1 = V1[0].FltValue; \ 895 OUT[0].type = 'S'; \1101 OUT[0].type = ST_SCALAR_FLT; \ 896 1102 OUT[0].FltValue = OP; \ 897 1103 clear_stack (V1); \ 898 1104 return (TRUE); \ 899 1105 } \ 900 if ((FTYPE == 'S') && (V1->type == 's')) { \1106 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT)) { \ 901 1107 opihi_int M1 = V1[0].IntValue; \ 902 OUT[0].type = 'S'; \1108 OUT[0].type = ST_SCALAR_FLT; \ 903 1109 OUT[0].FltValue = OP; \ 904 1110 clear_stack (V1); \ 905 1111 return (TRUE); \ 906 1112 } \ 907 if ((FTYPE == 's') && (V1->type == 's')) { \1113 if ((FTYPE == ST_SCALAR_INT) && (V1->type == ST_SCALAR_INT)) { \ 908 1114 opihi_int M1 = V1[0].IntValue; \ 909 OUT[0].type = 's'; \1115 OUT[0].type = ST_SCALAR_INT; \ 910 1116 OUT[0].IntValue = OP; \ 911 1117 clear_stack (V1); \ … … 914 1120 } 915 1121 916 if (!strcmp (op, "=")) S_FUNC(M1, 's'); 917 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), 's'); 918 if (!strcmp (op, "int")) S_FUNC((long long)(M1), 's'); 919 if (!strcmp (op, "exp")) S_FUNC(exp (M1), 'S'); 920 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), 'S'); 921 if (!strcmp (op, "log")) S_FUNC(log10 (M1), 'S'); 922 if (!strcmp (op, "ln")) S_FUNC(log (M1), 'S'); 923 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), 'S'); 924 if (!strcmp (op, "erf")) S_FUNC(erf (M1), 'S'); 925 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), 'S'); 926 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), 'S'); 927 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), 'S'); 928 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), 'S'); 929 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), 'S'); 930 if (!strcmp (op, "sin")) S_FUNC(sin (M1), 'S'); 931 if (!strcmp (op, "cos")) S_FUNC(cos (M1), 'S'); 932 if (!strcmp (op, "tan")) S_FUNC(tan (M1), 'S'); 933 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), 'S'); 934 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), 'S'); 935 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), 'S'); 936 if (!strcmp (op, "asin")) S_FUNC(asin (M1), 'S'); 937 if (!strcmp (op, "acos")) S_FUNC(acos (M1), 'S'); 938 if (!strcmp (op, "atan")) S_FUNC(atan (M1), 'S'); 939 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, 'S'); 940 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, 'S'); 941 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, 'S'); 942 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), 'S'); 943 if (!strcmp (op, "not")) S_FUNC(!(M1), 's'); 944 if (!strcmp (op, "--")) S_FUNC(-1*M1, 's'); // NOTE: opihi_int is signed, 945 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), 'S'); // XXX modify in future 946 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), 'S'); // XXX modify in future 1122 if (!strcmp (op, "=")) S_FUNC(M1, ST_SCALAR_INT); 1123 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), ST_SCALAR_INT); 1124 if (!strcmp (op, "int")) S_FUNC((long long)(M1), ST_SCALAR_INT); 1125 if (!strcmp (op, "floor")) S_FUNC(floor (M1), ST_SCALAR_FLT); 1126 if (!strcmp (op, "ceil")) S_FUNC(ceil (M1), ST_SCALAR_FLT); 1127 // if (!strcmp (op, "rint")) S_FUNC(nearbyint (M1), ST_SCALAR_FLT); 1128 if (!strcmp (op, "exp")) S_FUNC(exp (M1), ST_SCALAR_FLT); 1129 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), ST_SCALAR_FLT); 1130 if (!strcmp (op, "log")) S_FUNC(log10 (M1), ST_SCALAR_FLT); 1131 if (!strcmp (op, "ln")) S_FUNC(log (M1), ST_SCALAR_FLT); 1132 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), ST_SCALAR_FLT); 1133 if (!strcmp (op, "erf")) S_FUNC(erf (M1), ST_SCALAR_FLT); 1134 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), ST_SCALAR_FLT); 1135 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), ST_SCALAR_FLT); 1136 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), ST_SCALAR_FLT); 1137 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), ST_SCALAR_FLT); 1138 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), ST_SCALAR_FLT); 1139 if (!strcmp (op, "sin")) S_FUNC(sin (M1), ST_SCALAR_FLT); 1140 if (!strcmp (op, "cos")) S_FUNC(cos (M1), ST_SCALAR_FLT); 1141 if (!strcmp (op, "tan")) S_FUNC(tan (M1), ST_SCALAR_FLT); 1142 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), ST_SCALAR_FLT); 1143 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), ST_SCALAR_FLT); 1144 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), ST_SCALAR_FLT); 1145 if (!strcmp (op, "asin")) S_FUNC(asin (M1), ST_SCALAR_FLT); 1146 if (!strcmp (op, "acos")) S_FUNC(acos (M1), ST_SCALAR_FLT); 1147 if (!strcmp (op, "atan")) S_FUNC(atan (M1), ST_SCALAR_FLT); 1148 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, ST_SCALAR_FLT); 1149 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT); 1150 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, ST_SCALAR_FLT); 1151 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), ST_SCALAR_FLT); 1152 if (!strcmp (op, "not")) S_FUNC(!(M1), ST_SCALAR_INT); 1153 if (!strcmp (op, "--")) S_FUNC(-1*M1, ST_SCALAR_INT); // NOTE: opihi_int is signed, 1154 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), ST_SCALAR_FLT); // XXX modify in future 1155 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), ST_SCALAR_FLT); // XXX modify in future 947 1156 948 1157 # undef S_FUNC 949 1158 950 1159 clear_stack (V1); 951 s printf (line, "error: op %s not defined!", op);1160 snprintf (line, 512, "error: op %s not defined!", op); 952 1161 push_error (line); 953 1162 return (FALSE); … … 962 1171 963 1172 OUT[0].vector = InitVector (); 964 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/1173 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 965 1174 966 1175 # define V_FUNC(OP,FTYPE) { \ … … 974 1183 goto escape; \ 975 1184 } \ 976 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) { \1185 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_FLT)) { \ 977 1186 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 978 1187 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 983 1192 goto escape; \ 984 1193 } \ 985 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) { \1194 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_INT)) { \ 986 1195 CopyVector (OUT[0].vector, V1[0].vector); \ 987 1196 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 993 1202 } } 994 1203 995 if (!strcmp (op, "=")) V_FUNC(*M1, 's'); 996 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), 's'); 997 if (!strcmp (op, "int")) V_FUNC((long long)(*M1), 's'); 998 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), 'S'); 999 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), 'S'); 1000 if (!strcmp (op, "log")) V_FUNC(log10(*M1), 'S'); 1001 if (!strcmp (op, "ln")) V_FUNC(log(*M1), 'S'); 1002 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), 'S'); 1003 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), 'S'); 1004 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), 'S'); 1005 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), 'S'); 1006 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), 'S'); 1007 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), 'S'); 1008 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), 'S'); 1009 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), 'S'); 1010 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), 'S'); 1011 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), 'S'); 1012 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), 'S'); 1013 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), 'S'); 1014 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), 'S'); 1015 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), 'S'); 1016 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), 'S'); 1017 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), 'S'); 1018 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, 'S'); 1019 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, 'S'); 1020 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, 'S'); 1021 if (!strcmp (op, "rnd")) V_FUNC(drand48(), 'S'); 1022 if (!strcmp (op, "ramp")) V_FUNC(i, 's'); 1023 if (!strcmp (op, "zero")) V_FUNC(0, 's'); 1024 if (!strcmp (op, "not")) V_FUNC(!(*M1), 's'); 1025 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), 's'); // NOTE: opihi_int is signed 1026 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), 'S'); 1027 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), 'S'); 1028 if (!strcmp (op, "xramp")) V_FUNC(i, 's'); 1029 if (!strcmp (op, "yramp")) V_FUNC(0, 's'); 1204 if (!strcmp (op, "=")) V_FUNC(*M1, ST_SCALAR_INT); 1205 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), ST_SCALAR_INT); 1206 if (!strcmp (op, "int")) V_FUNC((long long)(*M1), ST_SCALAR_INT); 1207 if (!strcmp (op, "floor")) V_FUNC(floor (*M1), ST_SCALAR_FLT); 1208 if (!strcmp (op, "ceil")) V_FUNC(ceil (*M1), ST_SCALAR_FLT); 1209 // if (!strcmp (op, "rint")) V_FUNC(nearbyint (*M1), ST_SCALAR_FLT); 1210 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), ST_SCALAR_FLT); 1211 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), ST_SCALAR_FLT); 1212 if (!strcmp (op, "log")) V_FUNC(log10(*M1), ST_SCALAR_FLT); 1213 if (!strcmp (op, "ln")) V_FUNC(log(*M1), ST_SCALAR_FLT); 1214 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), ST_SCALAR_FLT); 1215 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), ST_SCALAR_FLT); 1216 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), ST_SCALAR_FLT); 1217 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), ST_SCALAR_FLT); 1218 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), ST_SCALAR_FLT); 1219 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), ST_SCALAR_FLT); 1220 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), ST_SCALAR_FLT); 1221 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), ST_SCALAR_FLT); 1222 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), ST_SCALAR_FLT); 1223 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), ST_SCALAR_FLT); 1224 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), ST_SCALAR_FLT); 1225 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), ST_SCALAR_FLT); 1226 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), ST_SCALAR_FLT); 1227 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), ST_SCALAR_FLT); 1228 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), ST_SCALAR_FLT); 1229 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), ST_SCALAR_FLT); 1230 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, ST_SCALAR_FLT); 1231 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, ST_SCALAR_FLT); 1232 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, ST_SCALAR_FLT); 1233 if (!strcmp (op, "rnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1234 if (!strcmp (op, "ramp")) V_FUNC(i, ST_SCALAR_INT); 1235 if (!strcmp (op, "zero")) V_FUNC(0, ST_SCALAR_INT); 1236 if (!strcmp (op, "not")) V_FUNC(!(*M1), ST_SCALAR_INT); 1237 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), ST_SCALAR_INT); // NOTE: opihi_int is signed 1238 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), ST_SCALAR_FLT); 1239 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), ST_SCALAR_FLT); 1240 if (!strcmp (op, "xramp")) V_FUNC(i, ST_SCALAR_INT); 1241 if (!strcmp (op, "yramp")) V_FUNC(0, ST_SCALAR_INT); 1030 1242 /* xramp and yramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */ 1031 1243 … … 1034 1246 escape: 1035 1247 1036 if (V1[0].type == 'v') {1248 if (V1[0].type == ST_VECTOR_TMP) { 1037 1249 free (V1[0].vector[0].elements.Ptr); 1038 1250 free (V1[0].vector); … … 1053 1265 Ny = V1[0].buffer[0].matrix.Naxis[1]; 1054 1266 1055 if (V1[0].type == 'm') {1267 if (V1[0].type == ST_MATRIX_TMP) { 1056 1268 OUT[0].buffer = V1[0].buffer; 1057 V1[0].type = 'M'; /* prevent it from being freed below */1269 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 1058 1270 } else { 1059 1271 OUT[0].buffer = InitBuffer (); 1060 1272 CopyBuffer (OUT[0].buffer, V1[0].buffer); 1061 1273 } 1062 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/1274 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 1063 1275 M1 = (float *) V1[0].buffer[0].matrix.buffer; 1064 1276 out = (float *)OUT[0].buffer[0].matrix.buffer; … … 1067 1279 if (!strcmp (op, "abs")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1); }} 1068 1280 if (!strcmp (op, "int")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }} 1281 1282 if (!strcmp (op, "floor")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = floor (*M1); }} 1283 if (!strcmp (op, "ceil")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = ceil (*M1); }} 1284 // if (!strcmp (op, "rint")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = nearbyint (*M1); }} 1285 1069 1286 if (!strcmp (op, "exp")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1); }} 1070 1287 if (!strcmp (op, "ten")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = pow(10.0,*M1); }} … … 1116 1333 } 1117 1334 1118 if (V1[0].type == 'm') {1335 if (V1[0].type == ST_MATRIX_TMP) { 1119 1336 free (V1[0].buffer[0].header.buffer); 1120 1337 free (V1[0].buffer[0].matrix.buffer); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/string.c
r33662 r37067 322 322 } 323 323 324 int set_list_varname (char *line, char *base, int N, int excelStyle) { 325 326 int i; 327 328 // A-Z correspond to 0 - 25 329 330 if (excelStyle) { 331 float f = log(26.0); 332 float g = (N == 0) ? 0.0 : log(1.0*N); 333 int Ndigit = (int) (g / f) + 1; 334 if (Ndigit > 10) { 335 sprintf (line, "%s:ZZZZZZZZZZ", base); 336 return FALSE; 337 } 338 char name[12]; 339 memset (name, 0, 12); 340 for (i = 0; i < Ndigit; i++) { 341 float Npow = Ndigit - i - 1; 342 float g = pow(26.0, Npow); 343 int V = (int) (N / g); 344 name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1; 345 N -= V * g; 346 } 347 sprintf (line, "%s:%s", base, name); 348 } else { 349 sprintf (line, "%s:%d", base, N); 350 } 351 return TRUE; 352 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/CheckController.c
r23530 r37067 29 29 if (p != NULL) goto escape; 30 30 31 /** skip past any leading garbage? ***/ 32 33 /** find "Njobs: **/ 34 p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256)); 35 p += strlen("BEGIN BLOCK Njobs:"); 36 31 37 /** parse job list **/ 32 status = sscanf ( buffer.buffer, "%*s%d", &Njobs);38 status = sscanf (p, "%d", &Njobs); 33 39 if (status != 1) goto escape; 34 40 if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(&start, TRUE)); 35 41 36 p = buffer.buffer; 42 /* output looks like: 43 BEGIN BLOCK Njobs: NN\n 44 ID name machine\n 45 ID name machine\n 46 */ 47 48 // p is currently pointing at "BEGIN BLOCK Njobs" 49 37 50 for (i = 0; i < Njobs; i++) { 38 51 q = strchr (p, '\n'); … … 67 80 if (p != NULL) goto escape; 68 81 82 /** skip past any leading garbage? ***/ 83 84 /** find "Njobs: **/ 85 p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256)); 86 p += strlen("BEGIN BLOCK Njobs:"); 87 69 88 /** parse job list **/ 70 status = sscanf ( buffer.buffer, "%*s%d", &Njobs);89 status = sscanf (p, "%d", &Njobs); 71 90 if (status != 1) goto escape; 72 91 if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed(&start, TRUE)); 73 92 74 p = buffer.buffer; 93 /* output looks like: 94 BEGIN BLOCK Njobs: NN\n 95 ID name machine\n 96 ID name machine\n 97 */ 98 99 // p is currently pointing at "BEGIN BLOCK Njobs" 100 75 101 for (i = 0; i < Njobs; i++) { 76 102 q = strchr (p, '\n'); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/ControllerOps.c
r34088 r37067 259 259 } 260 260 261 if (job[0]. priority) {261 if (job[0].nicelevel) { 262 262 char tmp[64]; 263 snprintf (tmp, 64, " -nice %d", job[0]. priority);263 snprintf (tmp, 64, " -nice %d", job[0].nicelevel); 264 264 strcat (cmd, tmp); 265 265 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/JobOps.c
r32632 r37067 107 107 job[0].mode = JOB_CONTROLLER; 108 108 } 109 job[0]. priority = task[0].priority;109 job[0].nicelevel = task[0].nicelevel; 110 110 111 111 /* we need our own copy of task[0].argv argc is the number of valid args, like the usual command line. we -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/LocalJob.c
r32632 r37067 162 162 163 163 /* set nice level for the child process -- maybe I should not exit here... */ 164 if (job[0]. priority) {165 status = setpriority (PRIO_PROCESS, pid, job[0]. priority);164 if (job[0].nicelevel) { 165 status = setpriority (PRIO_PROCESS, pid, job[0].nicelevel); 166 166 if (status == -1) { 167 gprint (GP_ERR, "error setting priority\n");167 gprint (GP_ERR, "error setting nice level\n"); 168 168 perror ("setpriority: "); 169 169 exit (2); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/TaskOps.c
r32632 r37067 487 487 488 488 NewTask[0].active = TRUE; 489 NewTask[0]. priority= 0;489 NewTask[0].nicelevel = 0; 490 490 return (NewTask); 491 491 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/init.c
r32632 r37067 34 34 {1, "halt", halt, "halt the scheduler (no job harvesting)"}, 35 35 {1, "host", task_host, "define host machine for a task"}, 36 {1, "nice", task_nice, "set nice prioritylevel for a task"},36 {1, "nice", task_nice, "set nice level for a task"}, 37 37 {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"}, 38 38 {1, "kill", kill_job, "kill job"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/init_server.c
r32632 r37067 35 35 {1, "delete", delete_job, "delete job"}, 36 36 {1, "host", task_host, "define host machine for a task"}, 37 {1, "nice", task_nice, "set nice prioritylevel for a task"},37 {1, "nice", task_nice, "set nice level for a task"}, 38 38 {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"}, 39 39 {1, "kill", kill_job, "kill job"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/task_nice.c
r32632 r37067 4 4 5 5 char *endptr = NULL; 6 int priority;6 int nicelevel; 7 7 Task *task; 8 8 9 9 if (argc != 2) { 10 gprint (GP_ERR, "USAGE: nice ( priority)\n");10 gprint (GP_ERR, "USAGE: nice (nicelevel)\n"); 11 11 return (FALSE); 12 12 } … … 20 20 } 21 21 22 priority= strtol (argv[1], &endptr, 10);22 nicelevel = strtol (argv[1], &endptr, 10); 23 23 if (*endptr) goto fail; 24 if ( priority< 0) goto fail;25 if ( priority> 20) goto fail;24 if (nicelevel < 0) goto fail; 25 if (nicelevel > 20) goto fail; 26 26 27 task[0]. priority = priority;27 task[0].nicelevel = nicelevel; 28 28 JobTaskUnlock(); 29 29 return (TRUE); 30 30 31 31 fail: 32 gprint (GP_ERR, "ERROR: nice ( priority) -- prioritymust be an integer 0 to 20\n");32 gprint (GP_ERR, "ERROR: nice (nicelevel) -- nicelevel must be an integer 0 to 20\n"); 33 33 return (FALSE); 34 34 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pclient/job.c
r32632 r37067 3 3 int job (int argc, char **argv) { 4 4 5 int i, N, pid, status, priority;5 int i, N, pid, status, nicelevel; 6 6 char **targv; 7 7 8 priority= 0;8 nicelevel = 0; 9 9 if ((N = get_argument (argc, argv, "-nice"))) { 10 10 remove_argument (N, &argc, argv); 11 priority= atoi (argv[N]);11 nicelevel = atoi (argv[N]); 12 12 remove_argument (N, &argc, argv); 13 13 } … … 62 62 63 63 /* set nice level for the child process */ 64 if ( priority) {65 status = setpriority (PRIO_PROCESS, pid, priority);64 if (nicelevel) { 65 status = setpriority (PRIO_PROCESS, pid, nicelevel); 66 66 if (status == -1) { 67 gprint (GP_ERR, "error setting priority\n");67 gprint (GP_ERR, "error setting nicelevel\n"); 68 68 perror ("setpriority: "); 69 69 exit (2); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/CheckBusyJob.c
r28242 r37067 99 99 100 100 // XXX runaway job if output too large? 101 if (job[0].stdout_buf.size > 0x1000000 ) abort();102 if (job[0].stderr_buf.size > 0x1000000 ) abort();101 if (job[0].stdout_buf.size > 0x10000000) abort(); 102 if (job[0].stderr_buf.size > 0x10000000) abort(); 103 103 104 104 // job has exited : move to DONE stack -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/JobOps.c
r32632 r37067 61 61 } 62 62 63 int GetJobStackIDbyName (char *name) { 64 if (!strcasecmp (name, "ALLJOBS")) return PCONTROL_JOB_ALLJOBS; 65 if (!strcasecmp (name, "PENDING")) return PCONTROL_JOB_PENDING; 66 if (!strcasecmp (name, "BUSY")) return PCONTROL_JOB_BUSY ; 67 if (!strcasecmp (name, "RESP")) return PCONTROL_JOB_RESP ; 68 if (!strcasecmp (name, "DONE")) return PCONTROL_JOB_DONE ; 69 if (!strcasecmp (name, "KILL")) return PCONTROL_JOB_KILL ; 70 if (!strcasecmp (name, "EXIT")) return PCONTROL_JOB_EXIT ; 71 if (!strcasecmp (name, "CRASH")) return PCONTROL_JOB_CRASH ; 72 return (PCONTROL_JOB_NONE); 73 } 74 63 75 Stack *GetJobStack (int StackID) { 64 76 switch (StackID) { … … 195 207 } 196 208 197 IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts) {209 IDtype AddJob (char *hostname, JobMode mode, int timeout, int nicelevel, int argc, char **argv, int Nxhosts, char **xhosts) { 198 210 199 211 int JobID; … … 220 232 221 233 job[0].mode = mode; 222 job[0]. priority = priority;234 job[0].nicelevel = nicelevel; 223 235 224 236 job[0].state = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/StartJob.c
r32632 r37067 25 25 bzero (line, Nline); 26 26 strcpy (line, "job"); 27 if (job[0]. priority) {27 if (job[0].nicelevel) { 28 28 char tmp[64]; 29 snprintf (tmp, 64, " -nice %d", job[0]. priority);29 snprintf (tmp, 64, " -nice %d", job[0].nicelevel); 30 30 strcat (line, tmp); 31 31 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/job.c
r32632 r37067 5 5 char *Host = NULL; 6 6 char **targv = NULL; 7 int i, N, Mode, targc, Timeout, priority;7 int i, N, Mode, targc, Timeout, nicelevel; 8 8 IDtype JobID; 9 9 char **xhosts = NULL; … … 43 43 } 44 44 45 priority= 0;45 nicelevel = 0; 46 46 if ((N = get_argument (argc, argv, "-nice"))) { 47 47 remove_argument (N, &argc, argv); 48 priority= atoi (argv[N]);48 nicelevel = atoi (argv[N]); 49 49 remove_argument (N, &argc, argv); 50 50 } … … 76 76 77 77 // a JobID < 0 mean the job was not accepted 78 JobID = AddJob (Host, Mode, Timeout, priority, targc, targv, Nxhosts, xhosts);78 JobID = AddJob (Host, Mode, Timeout, nicelevel, targc, targv, Nxhosts, xhosts); 79 79 gprint (GP_LOG, "JobID: %d\n", (int) JobID); 80 80 return (TRUE); … … 82 82 usage: 83 83 gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n"); 84 gprint (GP_ERR, " options: -host, +host, -timeout, -xhost (host) \n");84 gprint (GP_ERR, " options: -host, +host, -timeout, -xhost (host) -nice (level)\n"); 85 85 gprint (GP_ERR, " arguments of the form @MAX_THREADS@ will be replaced when the job is launched\n"); 86 86 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/jobstack.c
r12470 r37067 22 22 /* print list */ 23 23 LockStack (stack); 24 gprint (GP_LOG, " Njobs: %d\n", stack[0].Nobject);24 gprint (GP_LOG, "BEGIN BLOCK Njobs: %d\n", stack[0].Nobject); 25 25 for (i = 0; i < stack[0].Nobject; i++) { 26 26 job = stack[0].object[i]; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/status.c
r32632 r37067 1 1 # include "pcontrol.h" 2 2 3 int PrintJobStack (int Nstack );3 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age); 4 4 int PrintHostStack (int Nstack); 5 5 6 6 int status (int argc, char **argv) { 7 7 8 PrintJobStack (PCONTROL_JOB_ALLJOBS); 9 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 8 int N; 9 10 if (get_argument (argc, argv, "-h")) goto usage; 11 if (get_argument (argc, argv, "-help")) goto usage; 12 if (get_argument (argc, argv, "--help")) goto usage; 13 14 /* I would like to add the following options: 15 * strsub on argv[0] 16 * strsub on hostname, realhost 17 * list hostname and realhost 18 * filter by state 19 * filter by dtime 20 */ 21 22 // -cmd (cmd) 23 // -host (hostname) 24 // -state (busy, pending, done, kill, exit, crash, resp, hung 25 // -age (seconds?) (minutes?) 26 // -nohost 27 28 char *COMMAND = NULL; 29 if ((N = get_argument (argc, argv, "-cmd"))) { 30 remove_argument (N, &argc, argv); 31 COMMAND = strcreate (argv[N]); 32 remove_argument (N, &argc, argv); 33 } 34 35 char *HOSTNAME = NULL; 36 if ((N = get_argument (argc, argv, "-host"))) { 37 remove_argument (N, &argc, argv); 38 HOSTNAME = strcreate (argv[N]); 39 remove_argument (N, &argc, argv); 40 } 41 42 int STATE = PCONTROL_JOB_ALLJOBS; 43 if ((N = get_argument (argc, argv, "-state"))) { 44 remove_argument (N, &argc, argv); 45 STATE = GetJobStackIDbyName (argv[N]); 46 remove_argument (N, &argc, argv); 47 if (STATE == PCONTROL_JOB_NONE) goto usage; 48 } 49 50 float AGE = 0.0; 51 if ((N = get_argument (argc, argv, "-age"))) { 52 remove_argument (N, &argc, argv); 53 AGE = atof (argv[N]); 54 remove_argument (N, &argc, argv); 55 } 56 57 int SHOWHOST = TRUE; 58 if ((N = get_argument (argc, argv, "-nohost"))) { 59 remove_argument (N, &argc, argv); 60 SHOWHOST = FALSE; 61 } 62 if ((N = get_argument (argc, argv, "+jobs"))) { 63 remove_argument (N, &argc, argv); 64 SHOWHOST = FALSE; 65 } 66 67 int SHOWJOBS = TRUE; 68 if ((N = get_argument (argc, argv, "-nojobs"))) { 69 remove_argument (N, &argc, argv); 70 SHOWJOBS = FALSE; 71 } 72 if ((N = get_argument (argc, argv, "+host"))) { 73 remove_argument (N, &argc, argv); 74 SHOWJOBS = FALSE; 75 } 76 77 if (SHOWJOBS) { 78 PrintJobStack (PCONTROL_JOB_ALLJOBS, COMMAND, HOSTNAME, STATE, AGE); 79 } 80 if (SHOWHOST) { 81 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 82 } 10 83 11 84 return (TRUE); 85 86 usage: 87 gprint (GP_ERR, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n"); 88 return FALSE; 12 89 } 13 90 14 int PrintJobStack (int Nstack ) {91 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age) { 15 92 16 93 int i, j, Nobject; … … 30 107 job = stack[0].object[i]; 31 108 ASSERT (job != NULL, "programming error"); 32 if (job[0].realhost == NULL) { 33 gprint (GP_LOG, "%3d %9s ", i, job[0].hostname); 34 } else { 35 gprint (GP_LOG, "%3d %9s ", i, job[0].realhost); 36 } 37 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 109 110 char *thishost = (job[0].realhost == NULL) ? job[0].hostname : job[0].realhost; 38 111 39 112 switch (job[0].state) { … … 45 118 gettimeofday (&now, (void *) NULL); 46 119 dtime = DTIME (now, job[0].start); 47 gprint (GP_LOG, "%8.2f ", dtime);48 120 break; 49 121 … … 55 127 default: 56 128 dtime = DTIME (job[0].stop, job[0].start); 57 gprint (GP_LOG, "%8.2f ", dtime);58 129 break; 59 130 } 60 131 132 // check on the filters 133 if (command) { 134 if (!strstr (job[0].argv[0], command)) continue; 135 } 136 if (hostname) { 137 if (!strstr (thishost, hostname)) continue; 138 } 139 if (age > 0.0) { 140 if (dtime < age) continue; 141 } 142 if (state != PCONTROL_JOB_ALLJOBS) { 143 // allow PCONTROL_JOB_RESP == BUSY 144 int validState = FALSE; 145 validState |= (state == PCONTROL_JOB_RESP) && (job[0].state == PCONTROL_JOB_BUSY); 146 validState |= (state == PCONTROL_JOB_BUSY) && (job[0].state == PCONTROL_JOB_RESP); 147 validState |= (state == job[0].state); 148 if (!validState) continue; 149 } 150 151 gprint (GP_LOG, "%3d %9s ", i, thishost); 152 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 153 gprint (GP_LOG, "%8.2f ", dtime); 154 61 155 PrintID (GP_LOG, job[0].JobID); 62 gprint (GP_LOG, " %2d ", job[0]. priority);156 gprint (GP_LOG, " %2d ", job[0].nicelevel); 63 157 for (j = 0; j < job[0].argc; j++) { 64 158 gprint (GP_LOG, "%s ", job[0].argv[j]);
Note:
See TracChangeset
for help on using the changeset viewer.
