Include file for miscellaneous library. More...
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
Go to the source code of this file.
Defines | |
#define | _GNU_SOURCE |
GNU extensions. | |
Functions | |
void | alloc_error (char *filename, int line) |
Subroutine to dump the core of the program (to debug) in the event of a memory allocation error. | |
void | banner (char *pgm, char *verstat, char *type) |
Output banner on terminal for BEGIN and END of programs. |
Include file for miscellaneous library.
Definition in file misc.h.
void alloc_error | ( | char * | filename, | |
int | line | |||
) |
Subroutine to dump the core of the program (to debug) in the event of a memory allocation error.
[in] | filename | Filename of source code file. |
[in] | line | Line number. |
Print error on standard error along with source code filename and line number.
Kill process and dump core for debugging purposes.
Definition at line 59 of file alloc_error.c.
Referenced by best_clusters(), change_date_origin(), clim_daily_tserie_climyear(), compute_time_info(), create_netcdf(), data_to_gregorian_cal_d(), data_to_gregorian_cal_f(), extract_subdomain(), extract_subperiod_months(), filter(), filter_window(), find_the_days(), generate_clusters(), get_attribute_str(), get_time_attributes(), get_time_info(), load_conf(), main(), mean_variance_dist_clusters(), mean_variance_field_spatial(), merge_seasons(), output_downscaled_analog(), project_field_eof(), read_analog_data(), read_field_subdomain_period(), read_large_scale_fields(), read_learning_fields(), read_learning_obs_eof(), read_learning_rea_eof(), read_netcdf_dims_3d(), read_netcdf_dims_eof(), read_netcdf_latlon(), read_netcdf_var_1d(), read_netcdf_var_2d(), read_netcdf_var_3d(), read_netcdf_var_3d_2d(), read_netcdf_var_generic_val(), read_netcdf_xy(), read_obs_period(), regress(), remove_clim(), remove_seasonal_cycle(), save_analog_data(), show_license(), sub_period_common(), write_learning_fields(), write_netcdf_dims_3d(), write_netcdf_var_3d(), write_netcdf_var_3d_2d(), write_regression_fields(), wt_downscaling(), wt_learning(), and xml_load_config().
void banner | ( | char * | pgm, | |
char * | verstat, | |||
char * | type | |||
) |
Output banner on terminal for BEGIN and END of programs.
[in] | pgm | Program name. |
[in] | verstat | Program version. |
[in] | type | Type of banner: BEGIN or END. |
Definition at line 58 of file banner.c.
Referenced by main().
00059 { 00066 static clock_t clk; /* Store CPU clock time. */ 00067 time_t tim; /* To compute clock time. */ 00068 char buf[50]; /* Temporary buffer for reentrant subroutine access. */ 00069 char *ctim; /* Date/time string. */ 00070 00071 /* Get current time */ 00072 tim = time(NULL); 00073 00074 /* Create date/time string */ 00075 ctim = ctime_r(&tim, buf); 00076 ctim[strlen(ctim)-1] = '\0'; 00077 00078 /* Output banner */ 00079 if ( !strcmp(type, "BEGIN") ) { 00080 /* Initialize CPU clock time */ 00081 clk = clock(); 00082 /* (void) printf("1\n"); */ 00083 (void) printf(" ********************************************************************************************\n"); 00084 (void) printf(" * *\n"); 00085 (void) printf(" * %-50s V%-10s *\n", pgm, verstat); 00086 (void) printf(" * *\n"); 00087 (void) printf(" * *\n"); 00088 (void) printf(" * %-24s *\n", ctim); 00089 (void) printf(" * *\n"); 00090 (void) printf(" * BEGIN EXECUTION *\n"); 00091 (void) printf(" * *\n"); 00092 (void) printf(" ********************************************************************************************\n"); 00093 } 00094 else if ( !strcmp(type, "END") ) { 00095 00096 float clktime; 00097 00098 /* Compute elapsed CPU clock time */ 00099 clktime = (float) (clock() - clk) / (float) CLOCKS_PER_SEC; 00100 /* (void) printf("1\n"); */ 00101 (void) printf(" ********************************************************************************************\n"); 00102 (void) printf(" * *\n"); 00103 (void) printf(" * %-50s %-10s *\n", pgm, verstat); 00104 (void) printf(" * *\n"); 00105 (void) printf(" * %-24s *\n", ctim); 00106 (void) printf(" * *\n"); 00107 (void) printf(" * END EXECUTION *\n"); 00108 (void) printf(" * *\n"); 00109 (void) printf(" * CP SECS = %-10.3f *\n", 00110 clktime); 00111 (void) printf(" * *\n"); 00112 (void) printf(" ********************************************************************************************\n"); 00113 } 00114 }