00001 /* ***************************************************** */ 00002 /* Show banners for execution of a program. */ 00003 /* banner.c */ 00004 /* ***************************************************** */ 00005 /* Author: Christian Page, CERFACS, Toulouse, France. */ 00006 /* ***************************************************** */ 00011 /* LICENSE BEGIN 00012 00013 Copyright Cerfacs (Christian Page) (2015) 00014 00015 christian.page@cerfacs.fr 00016 00017 This software is a computer program whose purpose is to downscale climate 00018 scenarios using a statistical methodology based on weather regimes. 00019 00020 This software is governed by the CeCILL license under French law and 00021 abiding by the rules of distribution of free software. You can use, 00022 modify and/ or redistribute the software under the terms of the CeCILL 00023 license as circulated by CEA, CNRS and INRIA at the following URL 00024 "http://www.cecill.info". 00025 00026 As a counterpart to the access to the source code and rights to copy, 00027 modify and redistribute granted by the license, users are provided only 00028 with a limited warranty and the software's author, the holder of the 00029 economic rights, and the successive licensors have only limited 00030 liability. 00031 00032 In this respect, the user's attention is drawn to the risks associated 00033 with loading, using, modifying and/or developing or reproducing the 00034 software by the user in light of its specific status of free software, 00035 that may mean that it is complicated to manipulate, and that also 00036 therefore means that it is reserved for developers and experienced 00037 professionals having in-depth computer knowledge. Users are therefore 00038 encouraged to load and test the software's suitability as regards their 00039 requirements in conditions enabling the security of their systems and/or 00040 data to be ensured and, more generally, to use and operate it in the 00041 same conditions as regards security. 00042 00043 The fact that you are presently reading this means that you have had 00044 knowledge of the CeCILL license and that you accept its terms. 00045 00046 LICENSE END */ 00047 00048 00049 00050 00051 00052 00053 00054 #include <misc.h> 00055 00057 void 00058 banner(char *pgm, char *verstat, char *type) 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 }