PRO RDPRMSEL,period,nbselprm,nbcond,param,paramcond,filename
;***
;##############################################################################
;#Procedure_name  : RDPRMSEL                                                  #
;#                                                                            #
;#Author          : Jacqueline Platzer                                        #
;#Language        : IDL                                                       #
;#Purpose         : read a file including  descriptions of selected HK param. #
;#Creation date   : MAY 1992                                                  #
;#Update date     : OCT 1992 (conditioning parameters)                        #
;#Version         : 2.0                                                       #
;#External Modules: SUMER_IDL_LIB   :                                         #
;#                                                                            #
;#Call sequence   : RDPRMSEL,period,nbselprm,nbcond,param,paramcond,filename  #
;#                                                                            #
;#Arguments       :                                                           #
;#        PERIOD  : (output) intarr(12)                                       #
;#                  period(0),period(6) : year of begin. and end. time        #
;#                  period(1),period(7) : month     "                         #
;#                  period(2),period(8) : day       "                         #
;#                  period(3),period(9) : hour      "                         #
;#                  period(4),period(10): minut     "                         #
;#                  period(5),period(11): second    "                         #
;#       NBSELPRM : (output) integer:number of selected param.                # 
;#       NBCOND   : (output) integer:number of conditioning param.            #
;#        PARAM   : (output) array of structure including description         #
;#                  of selected parameters                                    #
;#                  array of structures of 13 descriptors for the n parameters#
;#                *  param(n).prec : (int) record type                        #
;#                *  param(n).ppos : (int) offset in byte in the record       #
;#                *  param(n).pf   : (string) format                          #
;#                *  param(n).pn   : (string) short name                      #
;#                *  param(n).ps   : (string) composition level               #
;#                *  param(n).pu   : (string) unit                            #
;#                *  param(n).plmin: (int) limit min                          # 
;#                *  param(n).plmax: (int) limit max                          # 
;#                *  param(n).pfb  : (int) first bit for split param          # 
;#                *  param(n).plb  : (int) last bit        "                  # 
;#                *  param(n).pln  : (string) long name                       # 
;#                *  param(n).pcond(0): (string) conditional param            # 
;#                *  param(n).pcond(1): (string) value of cond. param         #
;#       PARAMCOND: same that param                                           #
;#        FILENAME: (optional param)name of the file including description    #
;#                  default filename='CHOSENPRM.DAT'                          #
;#                                                                            #
;# External files reading :                                                   #
;#                                                                            # 
;#   CHOSENPRM.DAT: ASCII file including  number and characteritics of        #
;#                  selected parameters to be displayed.                      #
;#                                                                            # 
;# Description    : write the file including characteristics of HK param.     #
;#                  selected to be displayed                                  #
;#                  the beginning time and the ending time of selected period #
;#                  number of selected parameters  with name of combinaition  #
;#                  and a complete description of all selected parameters     #
;#                  allowing to display them and available in an array of     #
;#                  of structure PARAM :                                      #
;#                  numb_param=nbselprm+nbcond                                # 
;#                  param=replicate(a,nbselprm)                               #
;#                  paramcond=replicate(a,nbcond)                             #
;#                                                                            # 
;##############################################################################

;***

    period=intarr(12)
    combin_name=''        
    close,2
        if N_PARAMS() lt 6  then filename='chosenprm.dat'        
    openr,2,filename
        readf,2,format='(12i3)',period
        readf,2,format='(i3,a31)',nbselprm,combin_name

    a={prm,prec:0,ppos:0,pf:'',pn:'',ps:'',pu:'',plmin:0,plmax:0,$
       pfb:0,plb:0,pln:'',pcond:strarr(2) }
    param=replicate(a,nbselprm)

    space=''
    rpr=0 & rppos=0 & rpf='' & rpn=''  & rps='' & rpu='' 
    rplmax=0 & rpfb=0 & rplb=0 & rpln='' & rplmin=0
    rpcond='' & rvcond=''

    n=0
        repeat begin 
        readf,2,format='(i3,i4,a5,a8,a5,a5,i6,i6,i3,i3,a31)',$
                rpr,rppos,rpf,rpn,rps,rpu,rplmin,rplmax,rpfb,rplb,rpln
        readf,2,format='(a1,a8,a1,a8)',space,rpcond,space,rvcond
                         param(n).prec=rpr
                         param(n).ppos=rppos
                         param(n).pf=rpf
                         param(n).pn=rpn
                         param(n).ps=rps
                         param(n).pu=rpu
                         param(n).plmin=rplmin 
                         param(n).plmax=rplmax
                         param(n).pfb=rpfb
                         param(n).plb=rplb
                         param(n).pln=rpln
                         param(n).pcond(0)=rpcond
                         param(n).pcond(1)=rvcond
        n=n+1
    endrep until n eq nbselprm or eof(2)
        readf,2,format='(i3)',nbcond
    if nbcond ne 0 then begin
        paramcond=replicate(a,nbcond)
        n=0
        repeat begin 
        readf,2,format='(i3,i4,a5,a8,a5,a5,i6,i6,i3,i3,a31)',$
                rpr,rppos,rpf,rpn,rps,rpu,rplmin,rplmax,rpfb,rplb,rpln
        readf,2,format='(a1,a8,a1,a8)',space,rpcond,space,rvcond
                         paramcond(n).prec=rpr
                         paramcond(n).ppos=rppos
                         paramcond(n).pf=rpf
                         paramcond(n).pn=rpn
                         paramcond(n).ps=rps
                         paramcond(n).pu=rpu
                         paramcond(n).plmin=rplmin 
                         paramcond(n).plmax=rplmax
                         paramcond(n).pfb=rpfb
                         paramcond(n).plb=rplb
                         paramcond(n).pln=rpln
                         paramcond(n).pcond(0)=rpcond
                         paramcond(n).pcond(1)=rvcond
        n=n+1
    endrep until n eq nbcond or eof(2)
    endif
    close,2
return
end
