#include "focas1.h" /* TOTMAG -- Recompute totat magnitudes */ totmag (catalog) char *catalog; { int i, diag, nsbr, entnum; long szrec, pos, szobjrec(); float Ltotal, sum; struct objrec ob, ob1; static struct areas area; cfd = catopen (catalog, 2); cmmnt ("totmag"); wtcathdr (cfd, 0); szrec = szobjrec (); for (;;) { if (rdcatob (cfd, 0L, &ob)) break; if (ffilter (&ob) != 1) continue; if (ob.class[0] != 'm') continue; if (ob.subent == 0) /* Ltotal = ob.Li; */ Ltotal = ob.Ltotal; else Ltotal = ob.Ltotal; pos = ftell (cfd); for (sum=0.;;) { if (rdcatob (cfd, 0L, &ob1)) break; if (ob1.entnum != ob.entnum || ob1.subent / 10 > ob.subent) break; if (ob1.subent / 10 < ob.subent) continue; sum += ob1.Li; } fseek (cfd, pos, 0); for (;;) { if (rdcatob (cfd, 0L, &ob1)) break; if (ob1.entnum != ob.entnum || ob1.subent / 10 > ob.subent) break; if (ob1.subent / 10 < ob.subent) continue; /*printf ("%d.%-d: %d.%-d %g", ob.entnum, ob.subent, ob1.entnum, ob1.subent, ob1.Ltotal);*/ if (sum > 0) ob1.Ltotal = Ltotal * ob1.Li / sum; else ob1.Ltotal = 0.; /*printf (" %g\n", ob1.Ltotal);*/ fseek (cfd, -szrec, 1); wtcat (&ob1, cfd); } fseek (cfd, pos, 0); } fclose (cfd); }