subroutine wtarf1(ounit, chatter,
     &          nk_hist, hist,
     &          nk_comm, comment,arfversn,phafil,
     &          telescop, instrume, detnam, filter,
     &          maxen, ienerg, energ_lo, energ_hi,
     &          sprsp, ierr)

        integer chatter, ierr,maxen
        integer ounit, nk_hist, nk_comm
        integer ienerg
        real energ_lo(maxen), energ_hi(maxen)
        real sprsp(maxen)
        character*(*) arfversn, phafil
        character*(*) telescop, instrume, detnam, filter
        character*(*) hist(*), comment(*)
c Description:
c  Creates and Writes the SPECRESP extension for an ARF file one of the formats 
c  conforming to the HDUVERS2='1.*.*' family.
c Currently the following formats are supported (see OGIP/92-002a)
c   HDUVERS2 = '1.0.0'
c   HDUCERS2 = '1.1.0'
c The requested format is checked, and if belonging to the '1.*.*' family,
c but not included above, the extension is written in the last format listed.
c  Assumes the FITS file is open and has had the Primary Header written
c  !!! Note !!!! File is left open at the end  
c      and  MUST BE CLOSED               by FTCLOS 
c  in order to (automatically) write the mandatory END header keyword.
c Passed parameters
c  OUNIT         i   : FORTRAN unit number of open RMF file
c  CHATTER       i   : chattiness flag for o/p (5 quite,10 normal,>20 silly)
c  NK_HIST       i   : No. records to be written as HISTORY records
c  HIST          i   : Array of history strings to be written
c  NK_COMM       i   : No. records to be written as COMMENT records
c  COMMENT       i   : Array of comment strings to be written
c  ARFVERSN      i   : String denoting OGIP HDUVERS2 family
c  TELESCOP      i   : String listing telescope/mission
c  INSTRUME      i   : String listing instrument/detector
c  DETNAM        i   : String listing specific detector name   
c  FILTER        i   : String listing instrument filter in use
c  MAXEN         i   : Maximum Energy index array dimension
c  IENERG        i   : No. energy bins
c  ENERG_LO      i   : Array containing lower bound to each energy bin
c  ENERG_HI      i   : Array containing upper bound to each energy bin
c  SPRSP         i   : Array containing the specresp dataset
c  IERR            o : Error flag (0 = OK)
c Called Routines:
c  subroutine CRMVBLK    : (CALLIB) Removes blanks from a string
c  subroutine FCECHO     : (FTOOLS) Writes to standard o/p device
c  subroutine FTBDEF     : (FITSIO) Defines the BINTABLE data structure
c  subroutine FTCRHD     : (FITSIO) Creates a new FITS extension file
c  subroutine FTPHBN     : (FITSIO) Writes the required header keywords
c  subroutine FTPCOM     : (FITSIO) Writes a FITS comment keyword
c  subroutine FTPCLx     : (FITSIO) Writes the data 
c  subroutine FTPHIS     : (FITSIO) Writes a FITS history keyword
c  subroutine FTPKYS     : (FITSIO) Writes a keyword
c  subroutine WT_FERRMSG : (CALLIB) Writes FITSIO error message etc
c Compilation & Linking
c  link with FITSIO & CALLIB & FTOOLS
c Origin:
c  Code mostly hacked from within the BBRSP program
c Authors/Modification History:
c  Ian M George     (1.0.0: 1993 Oct 17), original "proper" version
c  Ian M George     (1.0.1: 1994 Jan 24), cosmetics
        character*7 version
        parameter (version = '1.0.1')