00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include <jsoc_main.h>
00057 #include <stdio.h>
00058 #include <stdlib.h>
00059 #include <math.h>
00060 #include <astro.h>
00061 #include <sys/time.h>
00062 #include <sys/resource.h>
00063
00064 #define DTOR (M_PI / 180.)
00065
00066 #define ARRLENGTH(ARR) (sizeof(ARR) / sizeof(ARR[0]))
00067 #define DIE(msg) {fflush(stdout); fprintf(stderr, "%s, status=%d\n", msg, status); return(status);}
00068 #define SHOW(msg) {printf("%s", msg); fflush(stdout);}
00069
00070 #include "pfss.h"
00071 #include "wsa_pkg.h"
00072
00073 #include "timing.c"
00074
00075
00076
00077
00078
00079 float time2solarb(TIME t)
00080 {
00081 int crot;
00082 double L, B;
00083 HeliographicLocation(t, &crot, &L, &B);
00084 return (float)B;
00085 }
00086
00087
00088 TIME carlon2time(int car, float lon)
00089 {
00090 return HeliographicTime(car, (double)lon);
00091 }
00092
00093
00094
00095
00096 char *module_name = "jgh2wsa";
00097
00098 ModuleArgs_t module_args[] =
00099 {
00100 {ARG_STRING, "in", NULL, "Input data series."},
00101 {ARG_STRING, "out", NULL, "Output data series."},
00102 {ARG_INT, "LMAX", "9", "Maximum l number desired."},
00103 {ARG_INT, "NP", "144", "Number of Grid points in longitude."},
00104 {ARG_INT, "NT", "72", "Number of Grid points in latitude."},
00105 {ARG_INT, "RK4", "0", "Set non zero to use RK4 in field line tracing; default is 0."},
00106 {ARG_INT, "TSLEN", "120", "Number of points in 1AU series, default is 120."},
00107 {ARG_DOUBLE, "TSTEP", "14400.0", "Step of 1AU time series in seconds"},
00108 {ARG_FLOAT, "LON_CMP", "60.0", "CMP lon of the last mag wrt left edge, default is 60."},
00109 {ARG_DOUBLE, "DAYSINADV", "5.0", "Dt of last point in TS (1AU) wrt CMP lon (source surface)."},
00110 {ARG_INT, "VERB", "1", "Level of verbosity: 0=errors/warnings; 1=all messages"},
00111 {ARG_END}
00112 };
00113
00114
00115
00116
00117
00118 int DoIt(void)
00119 {
00120 int status = DRMS_SUCCESS;
00121 char *inQuery, *outQuery;
00122 DRMS_RecordSet_t *inRS, *outRS;
00123 int irec, nrecs;
00124 DRMS_Record_t *inRec, *outRec, *linkedRec;
00125 DRMS_Segment_t *inSegG, *inSegH;
00126 DRMS_Segment_t *outSegGlb_v, *outSegGlb_brss, *outSegGlb_f, *outSegGlb_ph, *outSegGlb_th;
00127 DRMS_Segment_t *outSegSub_v, *outSegSub_brss, *outSegSub_f, *outSegSub_ph, *outSegSub_th;
00128 DRMS_Segment_t *outSegTS1AU_vx, *outSegTS1AU_imf;
00129 DRMS_Array_t *inArrayG, *inArrayH;
00130 DRMS_Array_t *outArrayGlb_v, *outArrayGlb_brss, *outArrayGlb_f, *outArrayGlb_ph, *outArrayGlb_th;
00131 DRMS_Array_t *outArraySub_v, *outArraySub_brss, *outArraySub_f, *outArraySub_ph, *outArraySub_th;
00132 DRMS_Array_t *outArrayTS1AU_vx, *outArrayTS1AU_imf;
00133 DRMS_Link_t *synopLink, *ghLink;
00134 float *inDataG, *inDataH;
00135 float *g, *h;
00136 float *v_g, *brss_g, *fte_g, *fpph_g, *fpth_g;
00137 float *v_s, *brss_s, *fte_s, *fpph_s, *fpth_s;
00138 double *date;
00139 float *speed;
00140 int *imf;
00141
00142 char *inchecklist[] = {"CAR_ROT", "LON0", "LMAX"};
00143 char *outchecklist[] = {"CAR_ROT", "LMAX"};
00144 DRMS_Record_t *inRec_tmp, *outRec_tmp;
00145 DRMS_Keyword_t *inkeytest, *outkeytest;
00146
00147 int verbflag;
00148 int outDimsGlb[2], outDimsSub[2], outDimsTS1AU[2];
00149 int lmax, lmax1;
00150 int want_lmax, have_lmax;
00151 int np, nt, npnt, np3;
00152 float dph, dth;
00153 int rk4;
00154 int tslen;
00155 double tstep, t_frst, t_last, t_cmp;
00156 float lon_cmp;
00157 double daysinadv;
00158 int car_rot;
00159 float lon0;
00160
00161 int i, j, n, itest;
00162 int l, m;
00163 int n0, n1;
00164
00165 struct Grid *grid;
00166 struct Gridsub *gridsub;
00167
00168
00169 double wt0, wt1, wt;
00170 double ut0, ut1, ut;
00171 double st0, st1, st;
00172 double ct0, ct1, ct;
00173 wt0 = getwalltime();
00174 ct0 = getcputime(&ut0, &st0);
00175
00176
00177 inQuery = (char *)params_get_str(&cmdparams, "in");
00178 outQuery = (char *)params_get_str(&cmdparams, "out");
00179 want_lmax = params_get_int(&cmdparams, "LMAX");
00180 np = params_get_int(&cmdparams, "NP");
00181 nt = params_get_int(&cmdparams, "NT");
00182 rk4 = params_get_int(&cmdparams, "RK4");
00183 tslen = params_get_int(&cmdparams, "TSLEN");
00184 tstep = params_get_double(&cmdparams, "TSTEP");
00185 lon_cmp = params_get_float(&cmdparams, "LON_CMP");
00186 daysinadv = params_get_double(&cmdparams, "DAYSINADV");
00187 verbflag = params_get_int(&cmdparams, "VERB");
00188
00189 npnt = np * nt; np3 = np * 3;
00190 dph = 360. / np;
00191 dth = 180. / nt;
00192
00193
00194
00195 outDimsGlb[0] = np; outDimsGlb[1] = nt;
00196
00197 outDimsSub[0] = np; outDimsSub[1] = 3;
00198
00199 outDimsTS1AU[0] = tslen; outDimsTS1AU[1] = 3;
00200
00201
00202 inRS = drms_open_records(drms_env, inQuery, &status);
00203 if (status || inRS->n == 0) DIE("No input data found");
00204 nrecs = inRS->n;
00205
00206
00207 inRec_tmp = inRS->records[0];
00208 for (itest = 0; itest < ARRLENGTH(inchecklist); itest++) {
00209 inkeytest = hcon_lookup_lower(&inRec_tmp->keywords, inchecklist[itest]);
00210 if (!inkeytest) {
00211 fprintf(stderr, "ERROR: required input keyword %s is missing\n", inchecklist[itest]);
00212 return 0;
00213 }
00214 }
00215 have_lmax = drms_getkey_int(inRec_tmp, "LMAX", &status);
00216 if (want_lmax > have_lmax) DIE("Request lmax greater than input lmax");
00217
00218
00219 outRec_tmp = drms_create_record(drms_env, outQuery, DRMS_TRANSIENT, &status);
00220 if (status) DIE("Unable to open record in output series");
00221 for (itest = 0; itest < ARRLENGTH(outchecklist); itest++) {
00222 outkeytest = hcon_lookup_lower(&outRec_tmp->keywords, outchecklist[itest]);
00223 if (!outkeytest || outkeytest->info->islink || outkeytest->info->recscope == 1) {
00224 fprintf(stderr, "Output keyword %s is missing/constant/a link.\n", outchecklist[itest]);
00225 return 0;
00226 }
00227 }
00228 drms_close_record(outRec_tmp, DRMS_FREE_RECORD);
00229
00230
00231 outRS = drms_create_records(drms_env, nrecs, outQuery, DRMS_PERMANENT, &status);
00232 if (status) DIE("Output recordset not created");
00233
00234
00235 grid = (struct Grid *)(malloc(sizeof(struct Grid)));
00236 grid->np = np; grid->nt = nt;
00237 grid->ph = (float *)(calloc(np, sizeof(float)));
00238 grid->th = (float *)(calloc(nt, sizeof(float)));
00239 for (i = 0; i < np; i++)
00240 grid->ph[i] = (i + 0.5) / np * 2 * M_PI;
00241 for (j = 0; j < nt; j++)
00242 grid->th[j] = (nt - j - 0.5) / nt * M_PI;
00243
00244
00245 gridsub = (struct Gridsub *)(malloc(sizeof(struct Gridsub)));
00246 gridsub->np = np; gridsub->nt = nt;
00247 gridsub->time = (double *)(calloc(np, sizeof(double)));
00248 gridsub->b0 = (float *)(calloc(np, sizeof(float)));
00249 gridsub->ph = (float *)(calloc(np, sizeof(float)));
00250 gridsub->th = (float *)(calloc(np3, sizeof(float)));
00251
00252
00253 for (irec = 0; irec < nrecs; irec++)
00254 {
00255
00256 if (verbflag) {
00257 wt1 = getwalltime();
00258 ct1 = getcputime(&ut1, &st1);
00259 printf("processing record %d...\n", irec);
00260 }
00261
00262
00263 inRec = inRS->records[irec];
00264 inSegG = drms_segment_lookup(inRec, "g");
00265 inArrayG = drms_segment_read(inSegG, DRMS_TYPE_FLOAT, &status);
00266 if (status) {
00267 printf("No data file found. \n");
00268 drms_free_array(inArrayG);
00269 continue;
00270 }
00271 inDataG = (float *)inArrayG->data;
00272 inSegH = drms_segment_lookup(inRec, "h");
00273 inArrayH = drms_segment_read(inSegH, DRMS_TYPE_FLOAT, &status);
00274 if (status) {
00275 printf("No data file found. \n");
00276 drms_free_array(inArrayH);
00277 continue;
00278 }
00279 inDataH = (float *)inArrayH->data;
00280
00281
00282 car_rot = drms_getkey_int(inRec, "CAR_ROT", &status);
00283 lon0 = drms_getkey_float(inRec, "LON0", &status);
00284 for (i = 0; i < np; i++) {
00285 gridsub->ph[i] = (i + 0.5) / np * 2 * M_PI;
00286 gridsub->time[i] = carlon2time(car_rot, lon0 + gridsub->ph[i] / DTOR);
00287 gridsub->b0[i] = time2solarb(gridsub->time[i]);
00288 gridsub->th[np + i] = M_PI / 2. - gridsub->b0[i] * DTOR;
00289 gridsub->th[i] = gridsub->th[np + i] + dth * DTOR;
00290 gridsub->th[2 * np + i] = gridsub->th[np + i] - dth * DTOR;
00291 }
00292
00293
00294 n0 = inArrayG->axis[0];
00295 n1 = inArrayG->axis[1];
00296 if (n0 != n1 || (n0 - 1) != have_lmax || inArrayH->axis[0] != inArrayH->axis[1] || inArrayH->axis[0] != n0)
00297 DIE("Wrong input data dimension");
00298 if (want_lmax > have_lmax)
00299 DIE("Request lmax greater than available lmax");
00300 lmax = want_lmax;
00301 lmax1 = lmax + 1;
00302 g = (float *)(calloc(lmax1 * lmax1, sizeof(float)));
00303 h = (float *)(calloc(lmax1 * lmax1, sizeof(float)));
00304 for (int l = 0; l <= lmax; l++) {
00305 for (int m = 0; m <= l; m++) {
00306 g[l * lmax1 + m] = inDataG[l * n0 + m];
00307 h[l * lmax1 + m] = inDataH[l * n0 + m];
00308 }
00309 }
00310 g[0] = 0.0; h[0] = 0.0;
00311 drms_free_array(inArrayG); drms_free_array(inArrayH);
00312
00313
00314 outArrayGlb_v = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsGlb, NULL, &status);
00315 outArrayGlb_brss = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsGlb, NULL, &status);
00316 outArrayGlb_f = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsGlb, NULL, &status);
00317 outArrayGlb_ph = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsGlb, NULL, &status);
00318 outArrayGlb_th = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsGlb, NULL, &status);
00319
00320 outArraySub_v = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsSub, NULL, &status);
00321 outArraySub_brss = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsSub, NULL, &status);
00322 outArraySub_f = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsSub, NULL, &status);
00323 outArraySub_ph = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsSub, NULL, &status);
00324 outArraySub_th = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsSub, NULL, &status);
00325
00326 outArrayTS1AU_vx = drms_array_create(DRMS_TYPE_FLOAT, 2, outDimsTS1AU, NULL, &status);
00327 outArrayTS1AU_imf = drms_array_create(DRMS_TYPE_INT, 2, outDimsTS1AU, NULL, &status);
00328
00329 v_g = (float *)outArrayGlb_v->data;
00330 brss_g = (float *)outArrayGlb_brss->data;
00331 fte_g = (float *)outArrayGlb_f->data;
00332 fpph_g = (float *)outArrayGlb_ph->data;
00333 fpth_g = (float *)outArrayGlb_th->data;
00334
00335 v_s = (float *)outArraySub_v->data;
00336 brss_s = (float *)outArraySub_brss->data;
00337 fte_s = (float *)outArraySub_f->data;
00338 fpph_s = (float *)outArraySub_ph->data;
00339 fpth_s = (float *)outArraySub_th->data;
00340
00341 speed = (float *)outArrayTS1AU_vx->data;
00342 imf = (int *)outArrayTS1AU_imf->data;
00343
00344 date = (double *)calloc(tslen, sizeof(double));
00345
00346
00347 t_cmp = carlon2time(car_rot, lon0 + lon_cmp);
00348 t_last = t_cmp + (daysinadv + 0.5) * SECSINDAY;
00349 t_last = (int)(t_last / tstep) * tstep;
00350 t_frst = t_last - (tslen - 1) * tstep;
00351 for (i = 0; i < tslen; i++) {
00352 date[i] = t_last - (tslen - i - 1) * tstep;
00353 }
00354
00355
00356
00357
00358
00359 if (verbflag) SHOW("tracing from source surface... ");
00360 wsa_ss(g, h, lmax, rk4, grid, gridsub,
00361 v_g, brss_g, fte_g, fpph_g, fpth_g,
00362 v_s, brss_s, fte_s, fpph_s, fpth_s);
00363 if (verbflag) SHOW("done.\n");
00364
00365
00366
00367 if (verbflag) SHOW("propagating to 1AU... ");
00368 wsa_1AU(gridsub, v_s, brss_s, date, speed, imf, tslen);
00369 if (verbflag) SHOW("done.\n");
00370
00371
00372 outRec = outRS->records[irec];
00373 outSegGlb_v = drms_segment_lookup(outRec, "Glb_v");
00374 outSegGlb_brss = drms_segment_lookup(outRec, "Glb_brss");
00375 outSegGlb_f = drms_segment_lookup(outRec, "Glb_f");
00376 outSegGlb_ph = drms_segment_lookup(outRec, "Glb_ph");
00377 outSegGlb_th = drms_segment_lookup(outRec, "Glb_th");
00378 outSegSub_v = drms_segment_lookup(outRec, "Sub_v");
00379 outSegSub_brss = drms_segment_lookup(outRec, "Sub_brss");
00380 outSegSub_f = drms_segment_lookup(outRec, "Sub_f");
00381 outSegSub_ph = drms_segment_lookup(outRec, "Sub_ph");
00382 outSegSub_th = drms_segment_lookup(outRec, "Sub_th");
00383 outSegTS1AU_vx = drms_segment_lookup(outRec, "TS1AU_vx");
00384 outSegTS1AU_imf = drms_segment_lookup(outRec, "TS1AU_imf");
00385 for (i = 0; i < 2; i++) {
00386 outSegGlb_v->axis[i] = outArrayGlb_v->axis[i];
00387 outSegGlb_brss->axis[i] = outArrayGlb_brss->axis[i];
00388 outSegGlb_f->axis[i] = outArrayGlb_f->axis[i];
00389 outSegGlb_ph->axis[i] = outArrayGlb_ph->axis[i];
00390 outSegGlb_th->axis[i] = outArrayGlb_th->axis[i];
00391 outSegSub_v->axis[i] = outArraySub_v->axis[i];
00392 outSegSub_brss->axis[i] = outArraySub_brss->axis[i];
00393 outSegSub_f->axis[i] = outArraySub_f->axis[i];
00394 outSegSub_ph->axis[i] = outArraySub_ph->axis[i];
00395 outSegSub_th->axis[i] = outArraySub_th->axis[i];
00396 outSegTS1AU_vx->axis[i] = outArrayTS1AU_vx->axis[i];
00397 outSegTS1AU_imf->axis[i] = outArrayTS1AU_imf->axis[i];
00398 }
00399 outArrayGlb_v->parent_segment = outSegGlb_v;
00400 outArrayGlb_brss->parent_segment = outSegGlb_brss;
00401 outArrayGlb_f->parent_segment = outSegGlb_f;
00402 outArrayGlb_ph->parent_segment = outSegGlb_ph;
00403 outArrayGlb_th->parent_segment = outSegGlb_th;
00404 outArraySub_v->parent_segment = outSegSub_v;
00405 outArraySub_brss->parent_segment = outSegSub_brss;
00406 outArraySub_f->parent_segment = outSegSub_f;
00407 outArraySub_ph->parent_segment = outSegSub_ph;
00408 outArraySub_th->parent_segment = outSegSub_th;
00409 outArrayTS1AU_vx->parent_segment = outSegTS1AU_vx;
00410 outArrayTS1AU_imf->parent_segment = outSegTS1AU_imf;
00411
00412
00413 status = drms_segment_write(outSegGlb_v, outArrayGlb_v, 0);
00414 if (status) DIE("problem writing Glb_v");
00415 drms_free_array(outArrayGlb_v);
00416 status = drms_segment_write(outSegGlb_brss, outArrayGlb_brss, 0);
00417 if (status) DIE("problem writing Glb_brss");
00418 drms_free_array(outArrayGlb_brss);
00419 status = drms_segment_write(outSegGlb_f, outArrayGlb_f, 0);
00420 if (status) DIE("problem writing Glb_f");
00421 drms_free_array(outArrayGlb_f);
00422 status = drms_segment_write(outSegGlb_ph, outArrayGlb_ph, 0);
00423 if (status) DIE("problem writing Glb_ph");
00424 drms_free_array(outArrayGlb_ph);
00425 status = drms_segment_write(outSegGlb_th, outArrayGlb_th, 0);
00426 if (status) DIE("problem writing Glb_th");
00427 drms_free_array(outArrayGlb_th);
00428 status = drms_segment_write(outSegSub_v, outArraySub_v, 0);
00429 if (status) DIE("problem writing Sub_v");
00430 drms_free_array(outArraySub_v);
00431 status = drms_segment_write(outSegSub_brss, outArraySub_brss, 0);
00432 if (status) DIE("problem writing Sub_brss");
00433 drms_free_array(outArraySub_brss);
00434 status = drms_segment_write(outSegSub_f, outArraySub_f, 0);
00435 if (status) DIE("problem writing Sub_f");
00436 drms_free_array(outArraySub_f);
00437 status = drms_segment_write(outSegSub_ph, outArraySub_ph, 0);
00438 if (status) DIE("problem writing Sub_ph");
00439 drms_free_array(outArraySub_ph);
00440 status = drms_segment_write(outSegSub_th, outArraySub_th, 0);
00441 if (status) DIE("problem writing Sub_th");
00442 drms_free_array(outArraySub_th);
00443 status = drms_segment_write(outSegTS1AU_vx, outArrayTS1AU_vx, 0);
00444 if (status) DIE("problem writing TS1AU_vx");
00445 drms_free_array(outArrayTS1AU_vx);
00446 status = drms_segment_write(outSegTS1AU_imf, outArrayTS1AU_imf, 0);
00447 if (status) DIE("problem writing TS1AU_imf");
00448 drms_free_array(outArrayTS1AU_imf);
00449
00450
00451 drms_setkey_string(outRec, "BLD_VERS", jsoc_version);
00452 drms_setkey_time(outRec, "DATE", CURRENT_SYSTEM_TIME);
00453
00454 drms_copykey(outRec, inRec, "CAR_ROT");
00455 drms_copykey(outRec, inRec, "LON0");
00456 drms_setkey_int(outRec, "LMAX", lmax);
00457 drms_setkey_float(outRec, "RSS", RS);
00458 drms_setkey_int(outRec, "RK4", rk4);
00459 drms_setkey_float(outRec, "FL_STEP", STEP);
00460 drms_setkey_float(outRec, "LON_CMP", lon_cmp);
00461
00462 drms_setkey_time(outRec, "T_CMP", t_cmp);
00463 drms_setkey_double(outRec, "DAYSINADV", daysinadv);
00464 drms_setkey_time(outRec, "T_START", t_frst);
00465 drms_setkey_time(outRec, "T_END", t_last);
00466 drms_setkey_double(outRec, "T_STEP", tstep);
00467
00468 drms_setkey_float(outRec, "CRPIX1_Glb", 1.0);
00469 drms_setkey_float(outRec, "CRVAL1_Glb", car_rot * 360. - 180. / np);
00470 drms_setkey_float(outRec, "CDELT1_Glb", - 360. / np);
00471 drms_setkey_float(outRec, "CRPIX2_Glb", nt / 2.0 + 0.5);
00472 drms_setkey_float(outRec, "CRVAL2_Glb", 0.0);
00473 drms_setkey_float(outRec, "CDELT2_Glb", 180. / nt);
00474
00475 drms_setkey_float(outRec, "CRPIX1_Sub", 1.0);
00476 drms_setkey_float(outRec, "CRVAL1_Sub", car_rot * 360. - 180. / np);
00477 drms_setkey_float(outRec, "CDELT1_Sub", - 360. / np);
00478 drms_setkey_float(outRec, "CRPIX2_Sub", 2.0);
00479 drms_setkey_float(outRec, "CRVAL2_FRST_Sub", gridsub->b0[0]);
00480 drms_setkey_float(outRec, "CRVAL2_LAST_Sub", gridsub->b0[nt - 1]);
00481 drms_setkey_float(outRec, "CDELT2_Glb", 180. / nt);
00482
00483 drms_setkey_float(outRec, "CRPIX1_TS1AU", 1.0);
00484 drms_setkey_time(outRec, "CRVAL1_TS1AU", t_frst);
00485 drms_setkey_double(outRec, "CDELT1_TS1AU", tstep);
00486 drms_setkey_float(outRec, "CRPIX2_TS1AU", 2.0);
00487 drms_setkey_float(outRec, "CRVAL2_TS1AU", 0.0);
00488 drms_setkey_float(outRec, "CDELT2_TS1AU", 180. / nt);
00489
00490
00491 ghLink = hcon_lookup_lower(&outRec->links, "HARMONICS");
00492 if (ghLink) {
00493 drms_setlink_static(outRec, "HARMONICS", inRec->recnum);
00494 linkedRec = drms_link_follow(outRec, "HARMONICS", &status);
00495 }
00496 if (!status) {
00497 synopLink = hcon_lookup_lower(&linkedRec->links, "SYNOP");
00498 if (synopLink) {
00499 drms_setlink_static(outRec, "SYNOP", linkedRec->recnum);
00500 }
00501 }
00502
00503
00504 if (verbflag) {
00505 wt = getwalltime();
00506 ct = getcputime(&ut, &st);
00507 printf("record %d done, %.2f ms wall time, %.2f ms cpu time\n",
00508 irec, wt - wt1, ct - ct1);
00509 }
00510 }
00511
00512
00513 free(grid->th); free(grid->ph);
00514 free(grid);
00515 free(gridsub->time); free(gridsub->b0); free(gridsub->th); free(gridsub->ph);
00516 free(gridsub);
00517
00518 drms_close_records(inRS, DRMS_FREE_RECORD);
00519 drms_close_records(outRS, DRMS_INSERT_RECORD);
00520
00521 if (verbflag) {
00522 wt = getwalltime();
00523 ct = getcputime(&ut, &st);
00524 printf("total time spent: %.2f ms wall time, %.2f ms cpu time\n",
00525 wt - wt0, ct - ct0);
00526 }
00527
00528 return(DRMS_SUCCESS);
00529 }