Changes between Version 3 and Version 4 of Libsrc_functions
 Timestamp:
 01/20/12 09:00:23 (10 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Libsrc_functions
v3 v4 194 194 195 195 At the moment, the Earthworm library routines are not a true library. Instead, they exist as object files in the vx.x/lib directory. After a module is compiled, it must be linked with the library objects that contain the library functions that have been called within the module. In this section, we give a synopsis of the functions within each of the library source file listed above. More details can be found in the comments within the source code. Many library function prototypes are given in vx.x/include/earthworm.h. Others are given in separate include files in vx.x/include. 196 chron3.c 196 197 === chron3.c === 197 198 198 199 This file contains timeconversion routines written by Carl Johnson, modified by Will Kohler and Lynn Dietz. In these routines, `julian' refers to the number of days (or minutes or seconds) since January 1, 1600. `Gregorian' dates consist of the fourdigit year (1997), month numbered 1 through 12, day of the month, hours, minutes, and fractional seconds. 200 {{{ 199 201 #include <chron3.h> 200 202 … … 239 241 double tnow( void ); 240 242 Return current system time in julian seconds. 241 fft_prep.c 243 }}} 244 245 === fft_prep.c === 242 246 243 247 fft_prep contains routines for setting up the structures needed for the Singleton FFT package, sing.c. The Singleton FFT's can be applied to sequence that are multiples of any prime integers. This provides much greater flexibility than the usual powerof2 FFTs. However, if the sequence size is a multiple of large primes, or is prime itself, then the `fft' is no longer a `fast' Fourier transform. So fft_prep is used to build up a list of numbers that are multiples of powers of 2, 3 and 5. Then for any given sequence size, you can do a Singleton FFT using the next largest number in this list, padding your data to make up the difference. This saves CPU time and space. prepFFT() is the main function of interest. Other functions are primarily for debugging or internal use. prepFFT() is not required for sing.c; it's just a convenience. 248 {{{ 244 249 #include <fft_prep.h> 245 250 long prepFFT( long n, FACT **pf ) … … 257 262 * 2 on other errors, logged here 258 263 */ 259 fft99.c 264 }}} 265 266 === fft99.c === 260 267 261 268 This file provides the Temperton FFT (Fast Fourier Transform) package, written by Cleve Temperton at ECMWF, modified and documented by Russ Rew at NCAR in 1980. This packages includes two important (but not unique) features: it will do FFTs on sequence that are multiples of any prime integers, not just powers of 2. Secondly, it will transform a sequence of real data efficiently. Theory tells us that the Fourier transform of a real sequence is a conjugatesymmetric complex sequence. So instead of calculating and saving the repeated conjugatesymmetric values, these routines save that time and space. (See Cooley, Lewis & Welch, J. Sound Vib. (1970) 12(3) or any digital signal processing text.) For use of these routines, see the extensive comments in the source file fft99.c. 269 {{{ 262 270 #include <fft99.h> 263 271 getutil.c … … 290 298 module ids, and message types from the file earthworm.d 291 299 in the EW_PARAMS directory. 292 geo_to_km.c 300 }}} 301 302 '''geo_to_km.c''' 293 303 Contributed by Harley Benz. 294 304 PURPOSE: To compute the distance and azimuth between locations. … … 305 315 Calculations are based upon the reference spheroid of 1968 and 306 316 are defined by the major radius (RAD) and the flattening (FL). 307 kom.c 317 === kom.c === 308 318 309 319 Functions in this file, written by Carl Johnson, are used to open and parse configuration files. 320 {{{ 310 321 #include <kom.h> 311 322 … … 336 347 337 348 long k_long( void ); Return next token as a long integer. 338 logit.c 349 }}} 350 351 === logit.c === 339 352 340 353 Functions in logit.c maintain and write daily log files and optionally onscreen messages. First call logit_init(), then call logit(). 341 354 The logit functions are compiled in two versions, one is multithread safe, the other is not. When linking with the threadsafe version (logit_mt.o), the program must also link with time_ew.o and sema_ew.o. When linking with the nonthreadsafe version (logit.o), the program only needs to link with time_ew.o. 342 355 356 {{{ 343 357 #include <earthworm.h> 344 358 … … 361 375 If any character is 'd', output is stamped with the process id. 362 376 The rest of calling sequence is identical to printf(). 363 mem_circ_queue.c 377 }}} 378 379 === mem_circ_queue.c === 364 380 365 381 This is son of in 'queue_max_size.c', which is son of queue, which Will got from Kelley and Pohl. These were clever linked list schemes which allocated as needed. This was too scary: the system could run out of memory and fail after running for a long time. So, out with the cleverness, and in with brute force: this version pre allocates the max amount of memory it will ever use at startup, and does the buffering in an array of message slots. The buffering is circular, as before: When we run out of message slots, we overwrite the oldest message. 382 {{{ 366 383 #include <mem_circ_queue.h> 367 384 … … 383 400 Returns 0 if no error; 384 401 1 if the queue is empty. 385 parse_trig.c 402 }}} 403 404 === parse_trig.c === 386 405 387 406 parseSnippet() parses a trigger message. Inspired by, and uses, strtok. Therefore, IT IS NOT MULTITHREAD SAFE. It must be mutex protected against concurrent calls to strtok.