PROGRAM g12abfe ! G12ABF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : g12abf, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: p, ts INTEGER :: df, i, ifail, ldn, lfreq, lwt, n, & nd, ngrp CHARACTER (1) :: freq, weight ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: expt(:), obsd(:), t(:), wt(:) INTEGER, ALLOCATABLE :: di(:), grp(:), ic(:), ifreq(:), ni(:) ! .. Executable Statements .. WRITE (nout,*) 'G12ABF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Read in the problem size READ (nin,*) n, ngrp, freq, weight IF (freq=='F' .OR. freq=='f') THEN lfreq = n ELSE lfreq = 0 END IF IF (weight=='W' .OR. weight=='w') THEN lwt = n ELSE lwt = 0 END IF ldn = n ALLOCATE (t(n),ic(n),grp(n),ifreq(lfreq),obsd(ngrp),expt(ngrp),di(ldn), & ni(ldn),wt(lwt)) ! Read in data IF (lfreq==0) THEN READ (nin,*) (t(i),ic(i),grp(i),i=1,n) ELSE READ (nin,*) (t(i),ic(i),grp(i),ifreq(i),i=1,n) END IF ! Calculate the statistic ifail = 0 CALL g12abf(n,t,ic,grp,ngrp,freq,ifreq,weight,wt,ts,df,p,obsd,expt,nd, & di,ni,ldn,ifail) ! Display results WRITE (nout,99999) 'Observed', 'Expected' WRITE (nout,99998) ('Group',i,obsd(i),expt(i),i=1,ngrp) WRITE (nout,*) WRITE (nout,99996) 'No. Unique Failure Times = ', nd WRITE (nout,*) WRITE (nout,99997) 'Test Statistic = ', ts WRITE (nout,99996) 'Degrees of Freedom = ', df WRITE (nout,99997) 'p-value = ', p 99999 FORMAT (11X,A,2X,A) 99998 FORMAT (1X,A,1X,I1,1X,F8.2,2X,F8.2) 99997 FORMAT (1X,A,1X,F8.4) 99996 FORMAT (1X,A,1X,I3) END PROGRAM g12abfe