# include <stdlib.h>1# include <stdio.h>2# include <math.h>3# include <time.h>45double cpu_time ( );6void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );7double ddot ( int n, double dx[], int incx, double dy[], int incy );8int dgefa ( double a[], int lda, int n, int ipvt[] );9void dgesl ( double a[], int lda, int n, int ipvt[], double b[], int job );10void dscal ( int n, double sa, double x[], int incx );11int idamax ( int n, double dx[], int incx );12double r8_abs ( double x );13double r8_epsilon ( );14double r8_max ( double x, double y );15double r8_random ( int iseed[4] );16double *r8mat_gen ( int lda, int n );17void timestamp ( );1819/******************************************************************************/2021int main(int argc, char **argv) {2223/******************************************************************************/24/*25Purpose:2627MAIN is the main program for LINPACK_BENCH.2829Discussion:3031LINPACK_BENCH drives the double precision LINPACK benchmark program.3233Modified:343525 July 20083637Parameters:3839N is the problem size.40*/41# define N 200042# define LDA ( N + 1 )4344double *a;45double a_max;46double *b;47double b_max;48double cray = 0.056;49double eps;50int i;51int info;52int *ipvt;53int j;54int job;55double ops;56double *resid;57double resid_max;58double residn;59double *rhs;60double t1;61double t2;62double time[6];63double total;64double *x;6566int arg = argc > 1 ? argv[1][0] - '0' : 3;67if (arg == 0) return 0;6869timestamp ( );70printf ( "\n" );71printf ( "LINPACK_BENCH\n" );72printf ( " C version\n" );73printf ( "\n" );74printf ( " The LINPACK benchmark.\n" );75printf ( " Language: C\n" );76printf ( " Datatype: Double precision real\n" );77printf ( " Matrix order N = %d\n", N );78printf ( " Leading matrix dimension LDA = %d\n", LDA );7980ops = ( double ) ( 2.0 * N * N * N ) / 3.0 + 2.0 * ( double ) ( N * N );81/*82Allocate space for arrays.83*/84a = r8mat_gen ( LDA, N );85b = ( double * ) malloc ( N * sizeof ( double ) );86ipvt = ( int * ) malloc ( N * sizeof ( int ) );87resid = ( double * ) malloc ( N * sizeof ( double ) );88rhs = ( double * ) malloc ( N * sizeof ( double ) );89x = ( double * ) malloc ( N * sizeof ( double ) );9091a_max = 0.0;92for ( j = 0; j < N; j++ )93{94for ( i = 0; i < N; i++ )95{96a_max = r8_max ( a_max, a[i+j*LDA] );97}98}99100for ( i = 0; i < N; i++ )101{102x[i] = 1.0;103}104105for ( i = 0; i < N; i++ )106{107b[i] = 0.0;108for ( j = 0; j < N; j++ )109{110b[i] = b[i] + a[i+j*LDA] * x[j];111}112}113t1 = cpu_time ( );114115info = dgefa ( a, LDA, N, ipvt );116117if ( info != 0 )118{119printf ( "\n" );120printf ( "LINPACK_BENCH - Fatal error!\n" );121printf ( " The matrix A is apparently singular.\n" );122printf ( " Abnormal end of execution.\n" );123return 1;124}125126t2 = cpu_time ( );127time[0] = t2 - t1;128129t1 = cpu_time ( );130131job = 0;132dgesl ( a, LDA, N, ipvt, b, job );133134t2 = cpu_time ( );135time[1] = t2 - t1;136137total = time[0] + time[1];138139free ( a );140/*141Compute a residual to verify results.142*/143a = r8mat_gen ( LDA, N );144145for ( i = 0; i < N; i++ )146{147x[i] = 1.0;148}149150for ( i = 0; i < N; i++ )151{152rhs[i] = 0.0;153for ( j = 0; j < N; j++ )154{155rhs[i] = rhs[i] + a[i+j*LDA] * x[j];156}157}158159for ( i = 0; i < N; i++ )160{161resid[i] = -rhs[i];162for ( j = 0; j < N; j++ )163{164resid[i] = resid[i] + a[i+j*LDA] * b[j];165}166}167168resid_max = 0.0;169for ( i = 0; i < N; i++ )170{171resid_max = r8_max ( resid_max, r8_abs ( resid[i] ) );172}173174b_max = 0.0;175for ( i = 0; i < N; i++ )176{177b_max = r8_max ( b_max, r8_abs ( b[i] ) );178}179180eps = r8_epsilon ( );181182residn = resid_max / ( double ) N / a_max / b_max / eps;183184time[2] = total;185if ( 0.0 < total )186{187time[3] = ops / ( 1.0E+06 * total );188}189else190{191time[3] = -1.0;192}193time[4] = 2.0 / time[3];194time[5] = total / cray;195196printf ( "\n" );197printf ( " Norm. Resid Resid MACHEP X[1] X[N]\n" );198printf ( "\n" );199printf ( " %14f %14f %14e %14f %14f\n", residn, resid_max, eps, b[0], b[N-1] );200printf ( "\n" );201printf ( " Factor Solve Total Unit Cray-Ratio\n" );202printf ( "\n" );203printf ( " %9f %9f %9f %9f %9f\n",204time[0], time[1], time[2], time[4], time[5] );205printf ( "\n" );206printf ( "Unrolled Double Precision %9f Mflops\n", time[3]);207printf ( "\n" );208209free ( a );210free ( b );211free ( ipvt );212free ( resid );213free ( rhs );214free ( x );215/*216Terminate.217*/218printf ( "\n" );219printf ( "LINPACK_BENCH\n" );220printf ( " Normal end of execution.\n" );221222printf ( "\n" );223timestamp ( );224225return 0;226# undef LDA227# undef N228}229/******************************************************************************/230231double cpu_time ( void )232233/******************************************************************************/234/*235Purpose:236237CPU_TIME returns the current reading on the CPU clock.238239Discussion:240241The CPU time measurements available through this routine are often242not very accurate. In some cases, the accuracy is no better than243a hundredth of a second.244245Licensing:246247This code is distributed under the GNU LGPL license.248249Modified:25025106 June 2005252253Author:254255John Burkardt256257Parameters:258259Output, double CPU_TIME, the current reading of the CPU clock, in seconds.260*/261{262double value;263264value = ( double ) clock ( )265/ ( double ) CLOCKS_PER_SEC;266267return value;268}269/******************************************************************************/270271void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy )272273/******************************************************************************/274/*275Purpose:276277DAXPY computes constant times a vector plus a vector.278279Discussion:280281This routine uses unrolled loops for increments equal to one.282283Modified:28428530 March 2007286287Author:288289FORTRAN77 original by Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart.290C version by John Burkardt291292Reference:293294Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart,295LINPACK User's Guide,296SIAM, 1979.297298Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,299Basic Linear Algebra Subprograms for Fortran Usage,300Algorithm 539,301ACM Transactions on Mathematical Software,302Volume 5, Number 3, September 1979, pages 308-323.303304Parameters:305306Input, int N, the number of elements in DX and DY.307308Input, double DA, the multiplier of DX.309310Input, double DX[*], the first vector.311312Input, int INCX, the increment between successive entries of DX.313314Input/output, double DY[*], the second vector.315On output, DY[*] has been replaced by DY[*] + DA * DX[*].316317Input, int INCY, the increment between successive entries of DY.318*/319{320int i;321int ix;322int iy;323int m;324325if ( n <= 0 )326{327return;328}329330if ( da == 0.0 )331{332return;333}334/*335Code for unequal increments or equal increments336not equal to 1.337*/338if ( incx != 1 || incy != 1 )339{340if ( 0 <= incx )341{342ix = 0;343}344else345{346ix = ( - n + 1 ) * incx;347}348349if ( 0 <= incy )350{351iy = 0;352}353else354{355iy = ( - n + 1 ) * incy;356}357358for ( i = 0; i < n; i++ )359{360dy[iy] = dy[iy] + da * dx[ix];361ix = ix + incx;362iy = iy + incy;363}364}365/*366Code for both increments equal to 1.367*/368else369{370m = n % 4;371372for ( i = 0; i < m; i++ )373{374dy[i] = dy[i] + da * dx[i];375}376377for ( i = m; i < n; i = i + 4 )378{379dy[i ] = dy[i ] + da * dx[i ];380dy[i+1] = dy[i+1] + da * dx[i+1];381dy[i+2] = dy[i+2] + da * dx[i+2];382dy[i+3] = dy[i+3] + da * dx[i+3];383}384}385return;386}387/******************************************************************************/388389double ddot ( int n, double dx[], int incx, double dy[], int incy )390391/******************************************************************************/392/*393Purpose:394395DDOT forms the dot product of two vectors.396397Discussion:398399This routine uses unrolled loops for increments equal to one.400401Modified:40240330 March 2007404405Author:406407FORTRAN77 original by Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart.408C version by John Burkardt409410Reference:411412Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart,413LINPACK User's Guide,414SIAM, 1979.415416Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,417Basic Linear Algebra Subprograms for Fortran Usage,418Algorithm 539,419ACM Transactions on Mathematical Software,420Volume 5, Number 3, September 1979, pages 308-323.421422Parameters:423424Input, int N, the number of entries in the vectors.425426Input, double DX[*], the first vector.427428Input, int INCX, the increment between successive entries in DX.429430Input, double DY[*], the second vector.431432Input, int INCY, the increment between successive entries in DY.433434Output, double DDOT, the sum of the product of the corresponding435entries of DX and DY.436*/437{438double dtemp;439int i;440int ix;441int iy;442int m;443444dtemp = 0.0;445446if ( n <= 0 )447{448return dtemp;449}450/*451Code for unequal increments or equal increments452not equal to 1.453*/454if ( incx != 1 || incy != 1 )455{456if ( 0 <= incx )457{458ix = 0;459}460else461{462ix = ( - n + 1 ) * incx;463}464465if ( 0 <= incy )466{467iy = 0;468}469else470{471iy = ( - n + 1 ) * incy;472}473474for ( i = 0; i < n; i++ )475{476dtemp = dtemp + dx[ix] * dy[iy];477ix = ix + incx;478iy = iy + incy;479}480}481/*482Code for both increments equal to 1.483*/484else485{486m = n % 5;487488for ( i = 0; i < m; i++ )489{490dtemp = dtemp + dx[i] * dy[i];491}492493for ( i = m; i < n; i = i + 5 )494{495dtemp = dtemp + dx[i ] * dy[i ]496+ dx[i+1] * dy[i+1]497+ dx[i+2] * dy[i+2]498+ dx[i+3] * dy[i+3]499+ dx[i+4] * dy[i+4];500}501}502return dtemp;503}504/******************************************************************************/505506int dgefa ( double a[], int lda, int n, int ipvt[] )507508/******************************************************************************/509/*510Purpose:511512DGEFA factors a real general matrix.513514Modified:51551616 May 2005517518Author:519520C version by John Burkardt.521522Reference:523524Jack Dongarra, Cleve Moler, Jim Bunch and Pete Stewart,525LINPACK User's Guide,526SIAM, (Society for Industrial and Applied Mathematics),5273600 University City Science Center,528Philadelphia, PA, 19104-2688.529ISBN 0-89871-172-X530531Parameters:532533Input/output, double A[LDA*N].534On intput, the matrix to be factored.535On output, an upper triangular matrix and the multipliers used to obtain536it. The factorization can be written A=L*U, where L is a product of537permutation and unit lower triangular matrices, and U is upper triangular.538539Input, int LDA, the leading dimension of A.540541Input, int N, the order of the matrix A.542543Output, int IPVT[N], the pivot indices.544545Output, int DGEFA, singularity indicator.5460, normal value.547K, if U(K,K) == 0. This is not an error condition for this subroutine,548but it does indicate that DGESL or DGEDI will divide by zero if called.549Use RCOND in DGECO for a reliable indication of singularity.550*/551{552int info;553int j;554int k;555int l;556double t;557/*558Gaussian elimination with partial pivoting.559*/560info = 0;561562for ( k = 1; k <= n-1; k++ )563{564/*565Find L = pivot index.566*/567l = idamax ( n-k+1, a+(k-1)+(k-1)*lda, 1 ) + k - 1;568ipvt[k-1] = l;569/*570Zero pivot implies this column already triangularized.571*/572if ( a[l-1+(k-1)*lda] == 0.0 )573{574info = k;575continue;576}577/*578Interchange if necessary.579*/580if ( l != k )581{582t = a[l-1+(k-1)*lda];583a[l-1+(k-1)*lda] = a[k-1+(k-1)*lda];584a[k-1+(k-1)*lda] = t;585}586/*587Compute multipliers.588*/589t = -1.0 / a[k-1+(k-1)*lda];590591dscal ( n-k, t, a+k+(k-1)*lda, 1 );592/*593Row elimination with column indexing.594*/595for ( j = k+1; j <= n; j++ )596{597t = a[l-1+(j-1)*lda];598if ( l != k )599{600a[l-1+(j-1)*lda] = a[k-1+(j-1)*lda];601a[k-1+(j-1)*lda] = t;602}603daxpy ( n-k, t, a+k+(k-1)*lda, 1, a+k+(j-1)*lda, 1 );604}605606}607608ipvt[n-1] = n;609610if ( a[n-1+(n-1)*lda] == 0.0 )611{612info = n;613}614615return info;616}617/******************************************************************************/618619void dgesl ( double a[], int lda, int n, int ipvt[], double b[], int job )620621/******************************************************************************/622/*623Purpose:624625DGESL solves a real general linear system A * X = B.626627Discussion:628629DGESL can solve either of the systems A * X = B or A' * X = B.630631The system matrix must have been factored by DGECO or DGEFA.632633A division by zero will occur if the input factor contains a634zero on the diagonal. Technically this indicates singularity635but it is often caused by improper arguments or improper636setting of LDA. It will not occur if the subroutines are637called correctly and if DGECO has set 0.0 < RCOND638or DGEFA has set INFO == 0.639640Modified:64164216 May 2005643644Author:645646C version by John Burkardt.647648Reference:649650Jack Dongarra, Cleve Moler, Jim Bunch and Pete Stewart,651LINPACK User's Guide,652SIAM, (Society for Industrial and Applied Mathematics),6533600 University City Science Center,654Philadelphia, PA, 19104-2688.655ISBN 0-89871-172-X656657Parameters:658659Input, double A[LDA*N], the output from DGECO or DGEFA.660661Input, int LDA, the leading dimension of A.662663Input, int N, the order of the matrix A.664665Input, int IPVT[N], the pivot vector from DGECO or DGEFA.666667Input/output, double B[N].668On input, the right hand side vector.669On output, the solution vector.670671Input, int JOB.6720, solve A * X = B;673nonzero, solve A' * X = B.674*/675{676int k;677int l;678double t;679/*680Solve A * X = B.681*/682if ( job == 0 )683{684for ( k = 1; k <= n-1; k++ )685{686l = ipvt[k-1];687t = b[l-1];688689if ( l != k )690{691b[l-1] = b[k-1];692b[k-1] = t;693}694695daxpy ( n-k, t, a+k+(k-1)*lda, 1, b+k, 1 );696697}698699for ( k = n; 1 <= k; k-- )700{701b[k-1] = b[k-1] / a[k-1+(k-1)*lda];702t = -b[k-1];703daxpy ( k-1, t, a+0+(k-1)*lda, 1, b, 1 );704}705}706/*707Solve A' * X = B.708*/709else710{711for ( k = 1; k <= n; k++ )712{713t = ddot ( k-1, a+0+(k-1)*lda, 1, b, 1 );714b[k-1] = ( b[k-1] - t ) / a[k-1+(k-1)*lda];715}716717for ( k = n-1; 1 <= k; k-- )718{719b[k-1] = b[k-1] + ddot ( n-k, a+k+(k-1)*lda, 1, b+k, 1 );720l = ipvt[k-1];721722if ( l != k )723{724t = b[l-1];725b[l-1] = b[k-1];726b[k-1] = t;727}728}729}730return;731}732/******************************************************************************/733734void dscal ( int n, double sa, double x[], int incx )735736/******************************************************************************/737/*738Purpose:739740DSCAL scales a vector by a constant.741742Modified:74374430 March 2007745746Author:747748FORTRAN77 original by Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart.749C version by John Burkardt750751Reference:752753Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart,754LINPACK User's Guide,755SIAM, 1979.756757Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,758Basic Linear Algebra Subprograms for Fortran Usage,759Algorithm 539,760ACM Transactions on Mathematical Software,761Volume 5, Number 3, September 1979, pages 308-323.762763Parameters:764765Input, int N, the number of entries in the vector.766767Input, double SA, the multiplier.768769Input/output, double X[*], the vector to be scaled.770771Input, int INCX, the increment between successive entries of X.772*/773{774int i;775int ix;776int m;777778if ( n <= 0 )779{780}781else if ( incx == 1 )782{783m = n % 5;784785for ( i = 0; i < m; i++ )786{787x[i] = sa * x[i];788}789790for ( i = m; i < n; i = i + 5 )791{792x[i] = sa * x[i];793x[i+1] = sa * x[i+1];794x[i+2] = sa * x[i+2];795x[i+3] = sa * x[i+3];796x[i+4] = sa * x[i+4];797}798}799else800{801if ( 0 <= incx )802{803ix = 0;804}805else806{807ix = ( - n + 1 ) * incx;808}809810for ( i = 0; i < n; i++ )811{812x[ix] = sa * x[ix];813ix = ix + incx;814}815}816return;817}818/******************************************************************************/819820int idamax ( int n, double dx[], int incx )821822/******************************************************************************/823/*824Purpose:825826IDAMAX finds the index of the vector element of maximum absolute value.827828Discussion:829830WARNING: This index is a 1-based index, not a 0-based index!831832Modified:83383430 March 2007835836Author:837838FORTRAN77 original by Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart.839C version by John Burkardt840841Reference:842843Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart,844LINPACK User's Guide,845SIAM, 1979.846847Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,848Basic Linear Algebra Subprograms for Fortran Usage,849Algorithm 539,850ACM Transactions on Mathematical Software,851Volume 5, Number 3, September 1979, pages 308-323.852853Parameters:854855Input, int N, the number of entries in the vector.856857Input, double X[*], the vector to be examined.858859Input, int INCX, the increment between successive entries of SX.860861Output, int IDAMAX, the index of the element of maximum862absolute value.863*/864{865double dmax;866int i;867int ix;868int value;869870value = 0;871872if ( n < 1 || incx <= 0 )873{874return value;875}876877value = 1;878879if ( n == 1 )880{881return value;882}883884if ( incx == 1 )885{886dmax = r8_abs ( dx[0] );887888for ( i = 1; i < n; i++ )889{890if ( dmax < r8_abs ( dx[i] ) )891{892value = i + 1;893dmax = r8_abs ( dx[i] );894}895}896}897else898{899ix = 0;900dmax = r8_abs ( dx[0] );901ix = ix + incx;902903for ( i = 1; i < n; i++ )904{905if ( dmax < r8_abs ( dx[ix] ) )906{907value = i + 1;908dmax = r8_abs ( dx[ix] );909}910ix = ix + incx;911}912}913914return value;915}916/******************************************************************************/917918double r8_abs ( double x )919920/******************************************************************************/921/*922Purpose:923924R8_ABS returns the absolute value of a R8.925926Modified:92792802 April 2005929930Author:931932John Burkardt933934Parameters:935936Input, double X, the quantity whose absolute value is desired.937938Output, double R8_ABS, the absolute value of X.939*/940{941double value;942943if ( 0.0 <= x )944{945value = x;946}947else948{949value = -x;950}951return value;952}953/******************************************************************************/954955double r8_epsilon ( )956957/******************************************************************************/958/*959Purpose:960961R8_EPSILON returns the R8 round off unit.962963Discussion:964965R8_EPSILON is a number R which is a power of 2 with the property that,966to the precision of the computer's arithmetic,9671 < 1 + R968but9691 = ( 1 + R / 2 )970971Licensing:972973This code is distributed under the GNU LGPL license.974975Modified:97697701 September 2012978979Author:980981John Burkardt982983Parameters:984985Output, double R8_EPSILON, the R8 round-off unit.986*/987{988const double value = 2.220446049250313E-016;989990return value;991}992/******************************************************************************/993994double r8_max ( double x, double y )995996/******************************************************************************/997/*998Purpose:9991000R8_MAX returns the maximum of two R8's.10011002Modified:1003100418 August 200410051006Author:10071008John Burkardt10091010Parameters:10111012Input, double X, Y, the quantities to compare.10131014Output, double R8_MAX, the maximum of X and Y.1015*/1016{1017double value;10181019if ( y < x )1020{1021value = x;1022}1023else1024{1025value = y;1026}1027return value;1028}1029/******************************************************************************/10301031double r8_random ( int iseed[4] )10321033/******************************************************************************/1034/*1035Purpose:10361037R8_RANDOM returns a uniformly distributed random number between 0 and 1.10381039Discussion:10401041This routine uses a multiplicative congruential method with modulus10422**48 and multiplier 33952834046453 (see G.S.Fishman,1043'Multiplicative congruential random number generators with modulus10442**b: an exhaustive analysis for b = 32 and a partial analysis for1045b = 48', Math. Comp. 189, pp 331-344, 1990).1046104748-bit integers are stored in 4 integer array elements with 12 bits1048per element. Hence the routine is portable across machines with1049integers of 32 bits or more.10501051Parameters:10521053Input/output, integer ISEED(4).1054On entry, the seed of the random number generator; the array1055elements must be between 0 and 4095, and ISEED(4) must be odd.1056On exit, the seed is updated.10571058Output, double R8_RANDOM, the next pseudorandom number.1059*/1060{1061int ipw2 = 4096;1062int it1;1063int it2;1064int it3;1065int it4;1066int m1 = 494;1067int m2 = 322;1068int m3 = 2508;1069int m4 = 2549;1070double one = 1.0;1071double r = 1.0 / 4096.0;1072double value;1073/*1074Multiply the seed by the multiplier modulo 2**48.1075*/1076it4 = iseed[3] * m4;1077it3 = it4 / ipw2;1078it4 = it4 - ipw2 * it3;1079it3 = it3 + iseed[2] * m4 + iseed[3] * m3;1080it2 = it3 / ipw2;1081it3 = it3 - ipw2 * it2;1082it2 = it2 + iseed[1] * m4 + iseed[2] * m3 + iseed[3] * m2;1083it1 = it2 / ipw2;1084it2 = it2 - ipw2 * it1;1085it1 = it1 + iseed[0] * m4 + iseed[1] * m3 + iseed[2] * m2 + iseed[3] * m1;1086it1 = ( it1 % ipw2 );1087/*1088Return updated seed1089*/1090iseed[0] = it1;1091iseed[1] = it2;1092iseed[2] = it3;1093iseed[3] = it4;1094/*1095Convert 48-bit integer to a real number in the interval (0,1)1096*/1097value =1098r * ( ( double ) ( it1 )1099+ r * ( ( double ) ( it2 )1100+ r * ( ( double ) ( it3 )1101+ r * ( ( double ) ( it4 ) ) ) ) );11021103return value;1104}1105/******************************************************************************/11061107double *r8mat_gen ( int lda, int n )11081109/******************************************************************************/1110/*1111Purpose:11121113R8MAT_GEN generates a random R8MAT.11141115Modified:1116111706 June 200511181119Parameters:11201121Input, integer LDA, the leading dimension of the matrix.11221123Input, integer N, the order of the matrix.11241125Output, double R8MAT_GEN[LDA*N], the N by N matrix.1126*/1127{1128double *a;1129int i;1130int init[4] = { 1, 2, 3, 1325 };1131int j;11321133a = ( double * ) malloc ( lda * n * sizeof ( double ) );11341135for ( j = 1; j <= n; j++ )1136{1137for ( i = 1; i <= n; i++ )1138{1139a[i-1+(j-1)*lda] = r8_random ( init ) - 0.5;1140}1141}11421143return a;1144}1145/******************************************************************************/11461147void timestamp ( void )11481149/******************************************************************************/1150/*1151Purpose:11521153TIMESTAMP prints the current YMDHMS date as a time stamp.11541155Example:1156115731 May 2001 09:45:54 AM11581159Licensing:11601161This code is distributed under the GNU LGPL license.11621163Modified:1164116524 September 200311661167Author:11681169John Burkardt11701171Parameters:11721173None1174*/1175{1176# define TIME_SIZE 4011771178static char time_buffer[TIME_SIZE];1179const struct tm *tm;1180size_t len;1181time_t now;11821183now = time ( NULL );1184tm = localtime ( &now );11851186len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm );11871188printf ( "%s\n", time_buffer );11891190return;1191# undef TIME_SIZE1192}1193119411951196