static void printfile(int fileid, int verbose, int humanized) { struct kld_file_stat stat; int modid; char buf[5]; stat.version = sizeof(struct kld_file_stat); if (kldstat(fileid, &stat) < 0) { err(1, "can't stat file id %d", fileid); } else { if (humanized) { humanize_number(buf, sizeof(buf), stat.size, "", HN_AUTOSCALE, HN_DECIMAL | HN_NOSPACE); printf("%2d %4d %p %5s %s", stat.id, stat.refs, stat.address, buf, stat.name); } else { printf("%2d %4d %p %8zx %s", stat.id, stat.refs, stat.address, stat.size, stat.name); } } if (verbose) { printf(" (%s)\n", stat.pathname); printf("\tContains modules:\n"); printf("\t\tId Name\n"); for (modid = kldfirstmod(fileid); modid > 0; modid = modfnext(modid)) printmod(modid); } else printf("\n"); }
static void printfile(int fileid, int verbose) { struct kld_file_stat stat; int modid; stat.version = sizeof(struct kld_file_stat); if (kldstat(fileid, &stat) < 0) warn("can't stat file id %d", fileid); else printf("%2d %4d %p %-8jx %s\n", stat.id, stat.refs, stat.address, (uintmax_t)stat.size, stat.name); if (verbose) { printf("\tContains modules:\n"); printf("\t\tId Name\n"); for (modid = kldfirstmod(fileid); modid > 0; modid = modfnext(modid)) printmod(modid); } }
/* \fcnfh Obtains the quantity that is observable, but before being convolved to telescope resolution @returns 0 on success -1 if impact parameter sampling is not equispaced */ int modulation(struct transit *tr) /* Main structure */ { static struct outputray st_out; tr->ds.out=&st_out; transitcheckcalled(tr->pi,"modulation",3, "tau",TRPI_TAU, "makeipsample",TRPI_MAKEIP, "makewnsample",TRPI_MAKEWN ); //initial variables and check that impact parameters was a monospaced //array. Stop otherwise. long w; prop_samp *ip=&tr->ips; prop_samp *wn=&tr->wns; transit_ray_solution *sol=tr->sol; if(ip->d==0&&sol->monoip) { transiterror(TERR_SERIOUS|TERR_ALLOWCONT, "To compute %s modulation, the impact parameter has to\n" "be an equispaced array\n" ,sol->name); return -1; } //output and geometry variables. PREC_RES *out=st_out.o=(PREC_RES *)calloc(wn->n,sizeof(PREC_RES)); struct geometry *sg=tr->ds.sg; struct optdepth *tau=tr->ds.tau; //set time to the user hinted default, and other user hints setgeom(sg,HUGE_VAL,&tr->pi); const int modlevel=tr->modlevel=tr->ds.th->modlevel; //integrate for each wavelength transitprint(1,verblevel, "\nIntegrating for each wavelength...\n"); int nextw=wn->n/10; for(w=0; w<wn->n; w++) { out[w]=sol->obsperwn(tau->t[w],tau->last[w],tau->toomuch, ip,sg,modlevel); if(out[w]<0) { switch(-(int)out[w]) { case 1: if(modlevel==-1) transiterror(TERR_SERIOUS, "Optical depth didn't reach limiting %g at wavenumber %g[cm-1]\n" " (Only reached %g)." " Cannot use critical radius technique (-1)\n" ,tau->toomuch,tau->t[w][tau->last[w]],wn->v[w]*wn->fct); default: transiterror(TERR_SERIOUS, "There was a problem while calculating modulation\n" " at wavenumber %g[cm-1]. Error code %i\n" ,wn->v[w]*wn->fct,(int)out[w]); break; } exit(EXIT_FAILURE); } if(w==nextw) { nextw+=wn->n/10; transitprint(2,verblevel, "%i%%\r" ,(10*(int)(10*w/wn->n+0.9999999999))); } } transitprint(1,verblevel," done\n"); //frees no longer needed memory. freemem_idexrefrac(tr->ds.ir,&tr->pi); freemem_extinction(tr->ds.ex,&tr->pi); freemem_tau(tr->ds.tau,&tr->pi); //set progress indicator, and print output tr->pi&=TRPI_MODULATION; printmod(tr); return 0; }
/* \fcnfh Calculate the transit modulation at each wavenumber Return: 0 on success, else -1 if impact parameter sampling is not equispaced */ int modulation(struct transit *tr){ struct optdepth *tau = tr->ds.tau; struct geometry *sg = tr->ds.sg; static struct outputray st_out; tr->ds.out = &st_out; long w; prop_samp *ip = &tr->ips; prop_samp *wn = &tr->wns; ray_solution *sol = tr->sol; /* Check that impact parameter and wavenumber samples exist: */ transitcheckcalled(tr->pi, "modulation", 3, "tau", TRPI_TAU, "makeipsample", TRPI_MAKEIP, "makewnsample", TRPI_MAKEWN); /* Allocate the modulation array: */ PREC_RES *out = st_out.o = (PREC_RES *)calloc(wn->n, sizeof(PREC_RES)); /* Set time to the user hinted default, and other user hints: */ setgeom(sg, HUGE_VAL, &tr->pi); /* Integrate for each wavelength: */ transitprint(1, verblevel, "Integrating over wavelength.\n"); int nextw = wn->n/10; /* Calculate the modulation spectrum at each wavenumber: */ for(w=0; w < wn->n; w++){ out[w] = sol->spectrum(tr, tau->t[w], wn->v[w], tau->last[w], tau->toomuch, ip); if (out[w] < 0){ switch(-(int)out[w]){ case 1: if(tr->modlevel == -1) transiterror(TERR_SERIOUS, "Optical depth didn't reach limiting " "%g at wavenumber %g cm-1 (only reached %g). Cannot " "use critical radius technique (-1).\n", tau->toomuch, tau->t[w][tau->last[w]], wn->v[w]*wn->fct); default: transiterror(TERR_SERIOUS, "There was a problem while calculating " "modulation at wavenumber %g cm-1. Error code %i.\n", wn->v[w]*wn->fct, (int)out[w]); break; } exit(EXIT_FAILURE); } /* Print to screen the progress status: */ if(w==nextw){ nextw += wn->n/10; transitprint(2, verblevel, "%i%% ", (10*(int)(10*w/wn->n+0.9999999999))); } } transitprint(1, verblevel, "\nDone.\n"); /* Set progress indicator, and print output: */ tr->pi |= TRPI_MODULATION; printmod(tr); return 0; }