int main(void) { memset(&sys, 0, sizeof(sys)); sys.param = CheckMalloc(50*sizeof(sys.param[0])); sys.entity = CheckMalloc(50*sizeof(sys.entity[0])); sys.constraint = CheckMalloc(50*sizeof(sys.constraint[0])); sys.failed = CheckMalloc(50*sizeof(sys.failed[0])); sys.faileds = 50; /*Example3d();*/ for(;;) { Example2d(); sys.params = sys.constraints = sys.entities = 0; break; } return 0; }
static void EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) { register TIFFDirEntry *dp; register TIFFDirectory *td = &tif->tif_dir; uint16 i; if (td->td_stripbytecount) _TIFFfree(td->td_stripbytecount); td->td_stripbytecount = (uint32*) CheckMalloc(tif, td->td_nstrips * sizeof (uint32), "for \"StripByteCounts\" array"); if (td->td_compression != COMPRESSION_NONE) { uint32 space = (uint32)(sizeof (TIFFHeader) + sizeof (uint16) + (dircount * sizeof (TIFFDirEntry)) + sizeof (uint32)); toff_t filesize = TIFFGetFileSize(tif); uint16 n; /* calculate amount of space used by indirect values */ for (dp = dir, n = dircount; n > 0; n--, dp++) { uint32 cc = dp->tdir_count*tiffDataWidth[dp->tdir_type]; if (cc > sizeof (uint32)) space += cc; } space = filesize - space; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) space /= td->td_samplesperpixel; for (i = 0; i < td->td_nstrips; i++) td->td_stripbytecount[i] = space; /* * This gross hack handles the case were the offset to * the last strip is past the place where we think the strip * should begin. Since a strip of data must be contiguous, * it's safe to assume that we've overestimated the amount * of data in the strip and trim this number back accordingly. */ i--; if (((toff_t)(td->td_stripoffset[i]+td->td_stripbytecount[i])) > filesize) td->td_stripbytecount[i] = filesize - td->td_stripoffset[i]; } else { uint32 rowbytes = TIFFScanlineSize(tif); uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; for (i = 0; i < td->td_nstrips; i++) td->td_stripbytecount[i] = rowbytes*rowsperstrip; } TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) td->td_rowsperstrip = td->td_imagelength; }
/* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ int TIFFReadDirectory(TIFF* tif) { register TIFFDirEntry* dp; register int n; register TIFFDirectory* td; TIFFDirEntry* dir; int iv; long v; double dv; const TIFFFieldInfo* fip; int fix; uint16 dircount; toff_t nextdiroff; char* cp; int diroutoforderwarning = 0; tif->tif_diroff = tif->tif_nextdiroff; if (tif->tif_diroff == 0) /* no more directories */ return (0); /* * Cleanup any previous compression state. */ (*tif->tif_cleanup)(tif); tif->tif_curdir++; nextdiroff = 0; if (!isMapped(tif)) { if (!SeekOK(tif, tif->tif_diroff)) { TIFFError(tif->tif_name, "Seek error accessing TIFF directory"); return (0); } if (!ReadOK(tif, &dircount, sizeof (uint16))) { TIFFError(tif->tif_name, "Can not read TIFF directory count"); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); if (dir == NULL) return (0); if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { TIFFError(tif->tif_name, "Can not read TIFF directory"); goto bad; } /* * Read offset to next directory for sequential scans. */ (void) ReadOK(tif, &nextdiroff, sizeof (uint32)); } else { toff_t off = tif->tif_diroff; if (off + sizeof (uint16) > tif->tif_size) { TIFFError(tif->tif_name, "Can not read TIFF directory count"); return (0); } else _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16)); off += sizeof (uint16); if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); if (dir == NULL) return (0); if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { TIFFError(tif->tif_name, "Can not read TIFF directory"); goto bad; } else _TIFFmemcpy(dir, tif->tif_base + off, dircount*sizeof (TIFFDirEntry)); off += dircount* sizeof (TIFFDirEntry); if (off + sizeof (uint32) <= tif->tif_size) _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32)); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&nextdiroff); tif->tif_nextdiroff = nextdiroff; tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ /* * Setup default value and then make a pass over * the fields to check type and tag information, * and to extract info required to size data * structures. A second pass is made afterwards * to read in everthing not taken in the first pass. */ td = &tif->tif_dir; /* free any old stuff and reinit */ TIFFFreeDirectory(tif); TIFFDefaultDirectory(tif); /* * Electronic Arts writes gray-scale TIFF files * without a PlanarConfiguration directory entry. * Thus we setup a default value here, even though * the TIFF spec says there is no default value. */ TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); /* * Sigh, we must make a separate pass through the * directory for the following reason: * * We must process the Compression tag in the first pass * in order to merge in codec-private tag definitions (otherwise * we may get complaints about unknown tags). However, the * Compression tag may be dependent on the SamplesPerPixel * tag value because older TIFF specs permited Compression * to be written as a SamplesPerPixel-count tag entry. * Thus if we don't first figure out the correct SamplesPerPixel * tag value then we may end up ignoring the Compression tag * value because it has an incorrect count value (if the * true value of SamplesPerPixel is not 1). * * It sure would have been nice if Aldus had really thought * this stuff through carefully. */ for (dp = dir, n = dircount; n > 0; n--, dp++) { if (tif->tif_flags & TIFF_SWAB) { TIFFSwabArrayOfShort(&dp->tdir_tag, 2); TIFFSwabArrayOfLong(&dp->tdir_count, 2); } if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) { if (!TIFFFetchNormalTag(tif, dp)) goto bad; dp->tdir_tag = IGNORE; } } /* * First real pass over the directory. */ fix = 0; for (dp = dir, n = dircount; n > 0; n--, dp++) { /* * Find the field information entry for this tag. * Added check for tags to ignore ... [BFC] */ if( TIFFReassignTagToIgnore(TIS_EXTRACT, dp->tdir_tag) ) dp->tdir_tag = IGNORE; if (dp->tdir_tag == IGNORE) continue; /* * Silicon Beach (at least) writes unordered * directory tags (violating the spec). Handle * it here, but be obnoxious (maybe they'll fix it?). */ if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) { if (!diroutoforderwarning) { TIFFWarning(tif->tif_name, "invalid TIFF directory; tags are not sorted in ascending order"); diroutoforderwarning = 1; } fix = 0; /* O(n^2) */ } while (fix < tif->tif_nfields && tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) fix++; if (fix == tif->tif_nfields || tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { TIFFWarning(tif->tif_name, "unknown field with tag %d (0x%x) ignored", dp->tdir_tag, dp->tdir_tag); dp->tdir_tag = IGNORE; fix = 0; /* restart search */ continue; } /* * Null out old tags that we ignore. */ if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { ignore: dp->tdir_tag = IGNORE; continue; } /* * Check data type. */ fip = tif->tif_fieldinfo[fix]; while (dp->tdir_type != (u_short) fip->field_type) { if (fip->field_type == TIFF_ANY) /* wildcard */ break; fip++, fix++; if (fix == tif->tif_nfields || fip->field_tag != dp->tdir_tag) { TIFFWarning(tif->tif_name, "wrong data type %d for \"%s\"; tag ignored", dp->tdir_type, fip[-1].field_name); goto ignore; } } /* * Check count if known in advance. */ if (fip->field_readcount != TIFF_VARIABLE) { uint32 expected = (fip->field_readcount == TIFF_SPP) ? (uint32) td->td_samplesperpixel : (uint32) fip->field_readcount; if (!CheckDirCount(tif, dp, expected)) goto ignore; } switch (dp->tdir_tag) { case TIFFTAG_COMPRESSION: /* * The 5.0 spec says the Compression tag has * one value, while earlier specs say it has * one value per sample. Because of this, we * accept the tag if one value is supplied. */ if (dp->tdir_count == 1) { v = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) goto bad; break; } if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || !TIFFSetField(tif, dp->tdir_tag, iv)) goto bad; dp->tdir_tag = IGNORE; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEOFFSETS: case TIFFTAG_TILEBYTECOUNTS: TIFFSetFieldBit(tif, fip->field_bit); break; case TIFFTAG_IMAGEWIDTH: case TIFFTAG_IMAGELENGTH: case TIFFTAG_IMAGEDEPTH: case TIFFTAG_TILELENGTH: case TIFFTAG_TILEWIDTH: case TIFFTAG_TILEDEPTH: case TIFFTAG_PLANARCONFIG: case TIFFTAG_ROWSPERSTRIP: if (!TIFFFetchNormalTag(tif, dp)) goto bad; dp->tdir_tag = IGNORE; break; case TIFFTAG_EXTRASAMPLES: (void) TIFFFetchExtraSamples(tif, dp); dp->tdir_tag = IGNORE; break; } } /* * Allocate directory structure and setup defaults. */ if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { MissingRequired(tif, "ImageLength"); goto bad; } if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { MissingRequired(tif, "PlanarConfiguration"); goto bad; } /* * Setup appropriate structures (by strip or by tile) */ if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { td->td_nstrips = TIFFNumberOfStrips(tif); td->td_tilewidth = td->td_imagewidth; td->td_tilelength = td->td_rowsperstrip; td->td_tiledepth = td->td_imagedepth; tif->tif_flags &= ~TIFF_ISTILED; } else { td->td_nstrips = TIFFNumberOfTiles(tif); tif->tif_flags |= TIFF_ISTILED; } td->td_stripsperimage = td->td_nstrips; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets"); goto bad; } /* * Second pass: extract other information. */ for (dp = dir, n = dircount; n > 0; n--, dp++) { if (dp->tdir_tag == IGNORE) continue; switch (dp->tdir_tag) { case TIFFTAG_MINSAMPLEVALUE: case TIFFTAG_MAXSAMPLEVALUE: case TIFFTAG_BITSPERSAMPLE: /* * The 5.0 spec says the Compression tag has * one value, while earlier specs say it has * one value per sample. Because of this, we * accept the tag if one value is supplied. * * The MinSampleValue, MaxSampleValue and * BitsPerSample tags are supposed to be written * as one value/sample, but some vendors incorrectly * write one value only -- so we accept that * as well (yech). */ if (dp->tdir_count == 1) { v = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) goto bad; break; } /* fall thru... */ case TIFFTAG_DATATYPE: case TIFFTAG_SAMPLEFORMAT: if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || !TIFFSetField(tif, dp->tdir_tag, iv)) goto bad; break; case TIFFTAG_SMINSAMPLEVALUE: case TIFFTAG_SMAXSAMPLEVALUE: if (!TIFFFetchPerSampleAnys(tif, dp, &dv) || !TIFFSetField(tif, dp->tdir_tag, dv)) goto bad; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: if (!TIFFFetchStripThing(tif, dp, td->td_nstrips, &td->td_stripoffset)) goto bad; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: if (!TIFFFetchStripThing(tif, dp, td->td_nstrips, &td->td_stripbytecount)) goto bad; break; case TIFFTAG_COLORMAP: case TIFFTAG_TRANSFERFUNCTION: /* * TransferFunction can have either 1x or 3x data * values; Colormap can have only 3x items. */ v = 1L<<td->td_bitspersample; if (dp->tdir_tag == TIFFTAG_COLORMAP || dp->tdir_count != (uint32) v) { if (!CheckDirCount(tif, dp, (uint32)(3*v))) break; } v *= sizeof (uint16); cp = CheckMalloc(tif, dp->tdir_count * sizeof (uint16), "to read \"TransferFunction\" tag"); if (cp != NULL) { if (TIFFFetchData(tif, dp, cp)) { /* * This deals with there being only * one array to apply to all samples. */ uint32 c = (uint32)1 << td->td_bitspersample; if (dp->tdir_count == c) v = 0; TIFFSetField(tif, dp->tdir_tag, cp, cp+v, cp+2*v); } _TIFFfree(cp); } break; case TIFFTAG_PAGENUMBER: case TIFFTAG_HALFTONEHINTS: case TIFFTAG_YCBCRSUBSAMPLING: case TIFFTAG_DOTRANGE: (void) TIFFFetchShortPair(tif, dp); break; #ifdef COLORIMETRY_SUPPORT case TIFFTAG_REFERENCEBLACKWHITE: (void) TIFFFetchRefBlackWhite(tif, dp); break; #endif /* BEGIN REV 4.0 COMPATIBILITY */ case TIFFTAG_OSUBFILETYPE: v = 0; switch (TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset)) { case OFILETYPE_REDUCEDIMAGE: v = FILETYPE_REDUCEDIMAGE; break; case OFILETYPE_PAGE: v = FILETYPE_PAGE; break; } if (v) (void) TIFFSetField(tif, TIFFTAG_SUBFILETYPE, (int)v); break; /* END REV 4.0 COMPATIBILITY */ default: (void) TIFFFetchNormalTag(tif, dp); break; } } /* * Verify Palette image has a Colormap. */ if (td->td_photometric == PHOTOMETRIC_PALETTE && !TIFFFieldSet(tif, FIELD_COLORMAP)) { MissingRequired(tif, "Colormap"); goto bad; } /* * Attempt to deal with a missing StripByteCounts tag. */ if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { /* * Some manufacturers violate the spec by not giving * the size of the strips. In this case, assume there * is one uncompressed strip of data. */ if ((td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_nstrips > 1) || (td->td_planarconfig == PLANARCONFIG_SEPARATE && td->td_nstrips != td->td_samplesperpixel)) { MissingRequired(tif, "StripByteCounts"); goto bad; } TIFFWarning(tif->tif_name, "TIFF directory is missing required \"%s\" field, calculating from imagelength", _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); EstimateStripByteCounts(tif, dir, dircount); #define BYTECOUNTLOOKSBAD \ ((td->td_stripbytecount[0] == 0 && td->td_stripoffset[0] != 0) || \ (td->td_compression == COMPRESSION_NONE && \ td->td_stripbytecount[0] > TIFFGetFileSize(tif) - td->td_stripoffset[0])) } else if (td->td_nstrips == 1 && BYTECOUNTLOOKSBAD) { /* * Plexus (and others) sometimes give a value * of zero for a tag when they don't know what * the correct value is! Try and handle the * simple case of estimating the size of a one * strip image. */ TIFFWarning(tif->tif_name, "Bogus \"%s\" field, ignoring and calculating from imagelength", _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); EstimateStripByteCounts(tif, dir, dircount); } if (dir) _TIFFfree((char *)dir); if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) td->td_maxsamplevalue = (uint16)((1L<<td->td_bitspersample)-1); /* * Setup default compression scheme. */ if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); /* * Some manufacturers make life difficult by writing * large amounts of uncompressed data as a single strip. * This is contrary to the recommendations of the spec. * The following makes an attempt at breaking such images * into strips closer to the recommended 8k bytes. A * side effect, however, is that the RowsPerStrip tag * value may be changed. */ if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE && (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP) ChopUpSingleUncompressedStrip(tif); /* * Reinitialize i/o since we are starting on a new directory. */ tif->tif_row = (uint32) -1; tif->tif_curstrip = (tstrip_t) -1; tif->tif_col = (uint32) -1; tif->tif_curtile = (ttile_t) -1; tif->tif_tilesize = TIFFTileSize(tif); tif->tif_scanlinesize = TIFFScanlineSize(tif); return (1); bad: if (dir) _TIFFfree(dir); return (0); }
void TriaLoop(int MaximumTrials, int nTrialsPerPhaseSet) { T_PhaseCode *PhaseCode, *FixedCode; T_FourierParameters FP[1]; T_PeakFlags *PeakFlags; Fprec *Surface; int StatLoadNextPhaseSet, iTrialsPerPhaseSet; long PosLoadNextPhaseSet; T_Ticks Ticks; long CheckTime = -SignalFileCheckInterval; nTrials = 0; nConvergedPhases = 0; nNotConvergedPhases = 0; StatLoadNextPhaseSet = 0; PosLoadNextPhaseSet = 1; iTrialsPerPhaseSet = 0; CheckMalloc(PhaseCode, nActivePhase); FixedCode = NULL; if (F_PhaseSetsFileName) CheckMalloc(FixedCode, nActivePhase); InitFourierParameters(FP, CodeTransl, nActivePhase); CheckMalloc(PeakFlags, Nx * Ny * Nz); DS_MarkEquiv(&SpgrInfo, PeakFlags, Nx, Ny, Nz); Surface = NULL; if (F_SurfaceFileName) { CheckMalloc(Surface, Nx * Ny * Nz); LoadSurface(Surface, Nx, Ny, Nz, PeakFlags); } /* initialize random number generator */ DoRandomInitialization(); (void) GetTicks(&Ticks); PrintTicks(stdout, &Ticks, "# Time ", " Start of TriaLoop\n"); Fflush(stdout); for (;;) { if (F_SignalFileName) { if (Ticks.sec_since_some_day - CheckTime >= SignalFileCheckInterval) { CheckSignalFile(); CheckTime = Ticks.sec_since_some_day; } } if (QuitProgram) break; if ( FixedCode && ( StatLoadNextPhaseSet == 0 || iTrialsPerPhaseSet >= nTrialsPerPhaseSet)) { PosLoadNextPhaseSet = LoadNextPhaseSet(NULL) + 1; Fprintf(stdout, "# Looking for next phase set, starting at line #%ld in file %s\n", PosLoadNextPhaseSet, F_PhaseSetsFileName); StatLoadNextPhaseSet = LoadNextPhaseSet(FixedCode); if (StatLoadNextPhaseSet == -1) break; iTrialsPerPhaseSet = 0; } Fprintf(stdout, "WoT %d", nTrials); if (FixedCode) Fprintf(stdout, " PosPhaseSet %ld Fixed %ld Random %d Trial %d", PosLoadNextPhaseSet, (long) nActivePhase - StatLoadNextPhaseSet, StatLoadNextPhaseSet, iTrialsPerPhaseSet); putc('\n', stdout); Fflush(stdout); CurrPhaseCode_nCallRanmar = NextPhaseCode(PhaseCode, FixedCode); RecyclePhases(FP, PeakFlags, Surface, PhaseCode); nTrials++; if (FixedCode) iTrialsPerPhaseSet++; (void) GetTicks(&Ticks); PrintTicks(stdout, &Ticks, "# Time ", "\n"); Fflush(stdout); if (MaximumTrials && MaximumTrials <= nTrials) break; } if (Surface) AppFree(Surface, Nx * Ny * Nz); AppFree(PeakFlags, Nx * Ny * Nz); FreeFourierParameters(FP); PrintTicks(stdout, NULL, "# Time ", " End of TriaLoop\n"); }
static void BuildListFcal(Fprec FcalMaxQ) { int h, k, l, pass, iListFcal; int Minh, Mink, Minl; int Maxh, Maxk, Maxl; int restriction; Fprec dmin, Qmax, Q; Fprec FcalAbs2; CmplxFprec Fcal; T_ListFcal *lfcal; if (FcalMaxQ > 0.) dmin = 1. / AppSqrt(FcalMaxQ); else dmin = 0.; CalcMaxhkl(&LatConR, &dmin, LambdaLength, &Maxh, &Maxk, &Maxl); Qmax = 1. / Square(dmin); (void) SetListMin_hkl(&SpgrInfo, 1, Maxh, Maxk, Maxl, &Minh, &Mink, &Minl); MaxFcal = 0; nListFcal = iListFcal = 0; for (pass = 0; pass < 2; pass++) { if (pass == 1 && nListFcal > 0) CheckMalloc(ListFcal, nListFcal); lfcal = ListFcal; for (h = Minh; h <= Maxh; h++) for (k = Mink; k <= Maxk; k++) for (l = Minl; l <= Maxl; l++) { Q = Q_hkl(h, k, l, &LatConR); if (Q > Qmax) continue; if (IsSysAbsent_hkl(&SpgrInfo, h, k, l, &restriction) != 0) continue; if (IsHidden_hkl(&SpgrInfo, 1, Minh, Mink, Minl, Maxh, Maxk, Maxl, h, k, l) != 0) continue; if (pass == 0) nListFcal++; else { if (iListFcal >= nListFcal) InternalError("iListFcal >= nListFcal"); CalcFcal(&Fcal, h, k, l); FcalAbs2 = Fcal.r * Fcal.r + Fcal.i * Fcal.i; if (MaxFcal < FcalAbs2) MaxFcal = FcalAbs2; lfcal->h = h; lfcal->k = k; lfcal->l = l; lfcal->restriction = restriction; lfcal->Fcal.r = Fcal.r; lfcal->Fcal.i = Fcal.i; lfcal->Q = Q; lfcal++; iListFcal++; } } } MaxFcal = AppSqrt(MaxFcal); if (iListFcal != nListFcal) InternalError("iListFcal != nListFcal"); if (nListFcal > 1) qsort((void *) ListFcal, nListFcal, sizeof (*ListFcal), (SortFunction) ListFcalSortFunction); }
void CollectionLists(int FlagPrintList_hkl, int PowderStepScan, const char *fnStdPeak) { Fprec FcalMaxQ; int nProfileSteps; Fprec *ProfileCounts, PeakRange; T_StdPeak *StdPeak, StdPeakBuf[1]; StdPeak = NULL; if (PowderStepScan) { if (ProfilePeakShape == PPS_StdPeak) { StdPeak = StdPeakBuf; LoadStdPeak(fnStdPeak, StdPeak); PeakRange = StdPeak->Range; } else PeakRange = PseudoVoigtPeakRange; FcalMaxQ = DetFcalMaxQ(1, PeakRange); } else FcalMaxQ = DetFcalMaxQ(1, 0.); EchoProfileSettings(stdout); PrepListSE(); BuildListFcal(FcalMaxQ); Fprintf(stdout, "# FcalMaxQ = %.6g => 2-theta %.6g\n", FcalMaxQ, TwoThetaDeg(FcalMaxQ)); Fprintf(stdout, "# nListFcal = %d\n\n", nListFcal); SetProfileReferenceReflIndex(); if (FlagPrintList_hkl) PrintListCollection(); if (PowderStepScan) { nProfileSteps = INT_ROUNDED(ProfileGenEnd / ProfileStep) + 1; CheckMalloc(ProfileCounts, nProfileSteps); Fprintf(stdout, "# nProfileSteps = %d\n\n", nProfileSteps); CalcProfile(ProfileCounts, nProfileSteps, StdPeak); PrintProfile(ProfileCounts, nProfileSteps, StdPeak); AppFree(ProfileCounts, nProfileSteps); } AppFree(ListFcal, nListFcal); ListFcal = NULL; nListFcal = 0; FreeListSE(); if (StdPeak) { AppFree(StdPeak->Title, strlen(StdPeak->Title) + 1); AppFree(StdPeak->C, StdPeak->nSteps); } }
static void PrepListSE(void) { int iS, iSE, AtomsPerUnitCell; T_Site *S; T_fVector *SymEquiv; int MaxSymEquiv; T_ListSymEquiv *LSE; Fprec Dist2ConsiderSame; Fprec MaxDist2ConsideredSame; Fprec MinDist2Distinct; if (ListSE != NULL) InternalError("ListSE != NULL"); CheckMalloc(ListSE, nSite); MaxSymEquiv = SpgrInfo.OrderL; CheckMalloc(SymEquiv, MaxSymEquiv); Dist2ConsiderSame = .01 * .01; /* ARBITRARY */ MaxDist2ConsideredSame = -1.; MinDist2Distinct = MaxLatticeTr2; LSE = ListSE; for (iS = 0, S = Site; iS < nSite; iS++, S++) { LSE->nSE = CalcSymEquiv(S->x, S->y, S->z, SymEquiv, MaxSymEquiv, Dist2ConsiderSame, &MaxDist2ConsideredSame, &MinDist2Distinct, NULL, 0); CheckMalloc(LSE->SE, LSE->nSE); for (iSE = 0; iSE < LSE->nSE; iSE++) { LSE->SE[iSE].x = SymEquiv[iSE].x; LSE->SE[iSE].y = SymEquiv[iSE].y; LSE->SE[iSE].z = SymEquiv[iSE].z; } LSE++; } AppFree(SymEquiv, MaxSymEquiv); Fprintf(stdout, ">Begin UnitCellContents\n"); AtomsPerUnitCell = 0; LSE = ListSE; for (iS = 0, S = Site; iS < nSite; iS++, S++) { Fprintf(stdout, " %4d %-6s %7.4f %7.4f %7.4f %-4.4s %5.2f %7.3f\n", LSE->nSE, S->Label, S->x, S->y, S->z, S->SF_Info.Lbl, S->Occ, S->Uiso); for (iSE = 1; iSE < LSE->nSE; iSE++) Fprintf(stdout, " %7.4f %7.4f %7.4f\n", LSE->SE[iSE].x, LSE->SE[iSE].y, LSE->SE[iSE].z); AtomsPerUnitCell += LSE->nSE; LSE++; } Fprintf(stdout, "# Atoms / UnitCell = %d\n", AtomsPerUnitCell); if (MaxDist2ConsideredSame >= 0.) Fprintf(stdout, "# MaxDist_ConsideredSame = %.4f\n", sqrt(MaxDist2ConsideredSame)); Fprintf(stdout, "# MinDist_Distinct = %.4f\n", sqrt(MinDist2Distinct)); Fprintf(stdout, ">End UnitCellContents\n\n"); }