contents

utils

The utils file contains small functions that may be used by more than one other function.  The functions included that are called from external functions are:
print_sol
print_pha
calc_delta
calc_esaz
calc_dircos
dsort
read_time
write_time
split_time
join_time
add_to_error
handle_error

print_sol

Called by:   main

Input arguments: Pointer to solution structure.

Calls: Function write_time from utils.

Return:  None

This function prints the current solution as a one line diagnostic message on the logfile output stream.


print_pha

Called by:   main, read_isf_event, calc_delaz, calc_weight, get_weight_factor, mark_duplicates, purge_pha

Input arguments:
Number of phases in the array.
Array of phase structures.

Calls: Function write_time from utils

Return:  None

This function prints a table to the logfile output stream with all the phases for one event. Only called by the above functions when they are in diagnostic mode, apart from main which uses this function to print the phases after a solution has been reached.


calc_delta

Called by:   calc_gap and calc_delaz

Input arguments:
Array of 3 direction cosines for the station.
Array of 3 direction cosines for the source.

Return:   Distance between the station and source  in degrees, delta


calc_esaz

Called by:   calc_gap and calc_delaz

Input arguments:
Array of 6 direction cosines for the station.
Array of 6 direction cosines for the source.
Station longitude.
Source longitude.
Distance between the two in degrees, delta

Return:   Back azimuth between epicentre and station, esaz


calc_dircos

Called by:   get_pha, get_hyp, read_isf_event, init_sol, and solve

Input arguments:
Latitude
Longitude
Array for 6 direction cosines.

Return:   None.

This function calculates the direction cosines for a point on the Earth's surface and enters them into the array sent as an argument.


dsort

Called by:   calc_error, calc_gap and itself, recursively.

Input arguments:
Array to be sorted.
Index of first value to be included in sort.
Index of last value to be included in sort.

Calls: Function dswap from utils and itself, recursively.

Return:   None.

This function sorts an array of doubles into descending order.



dswap

Called by:   dsort

Input arguments:
Array to be sorted.
Two indexes on this array.

Return:   None.

This function is part of the function dsort - it simply swaps two array elements.



read_time

Called by:   read_instruction

Input arguments: String containing date and time in format yyyy/mm/dd_hh:mm:ss.sss

Calls: Function join_time from utils.

Return:  0 on error or number of seconds since epoch.

This function parses a string with a date and time and returns the number of seconds since epoch.  It is used to allow the operator to fix the source time on the instruction line.


write_time

Called by:   print_hyp, print_sol and print_pha

Input arguments:
Time since epoch in seconds.
Pointer to memory allocated for 24 characters.

Calls: Function split_time from utils.

Return:   "" on error or string containing date and time in format yyyy/mm/dd_hh:mm:ss.sss


split_time

Called by:  write_isf_event and write_time

Input arguments:
Time since epoch in seconds.
Pointers to memory allocated for each of yyyy, mm, dd, hh, mi, ss, and msec.

Calls: Functions days_per_month and days_per_year from utils.

Return: 0/1 for success/failure

This function converts times from seconds since epoch to separate integers and assigns them to pointers sent as arguments.


join_time

Called by:  read_isf_event and read_time

Input arguments: yyyy, mm, dd, hh, mi, ss, msec

Calls:   Functions days_per_month and days_per_year from utils.

Return: Time since epoch in seconds.


days_per_month

Called by:  join_time and split_time

Input arguments: mm, yyyy

Return: Number of days in month.


days_per_year

Called by:  join_time and split_time

Input arguments: yyyy

Return: Number of days in year.


add_to_error

Called by:  calc_pP_resid, calc_resid, find_pP, id_jb, read_ttime

Input arguments:  String with part of an error message

Return: None.

This function concatenates the string that it gets as its argument to the end of the global string variable errstr.


handle_error

Called by:  main, calc_depdp, calc_pP_resid, calc_resid, correct_ttime, id_jb, read_isf_event, write_isf_event

Input arguments:  None.

Return: None.

This function prints the global string variable errstr to the output streams logfile and errfile and then sets it to "".


back to top