c  transform model (IMOD = 13) to *.det format
c IMOD = 13     *.krz
c IMOD = 10     *.det
c IMOD = 1      *.mod   Kurucz, 72
      character filein*80,fileout*80,text*80,atom*2
      dimension atom(72),abund(99)
      data atom/'H ','HE','LI','BE','B ','C ','N ','O ','F ','NE',
     &          'NA','MG','AL','SI','P ','S ','CL','AR','K ','CA',
     &          'SC','TI','V ','CR','MN','FE','CO','NI','CU','ZN',
     &          'GA','GE','AS','SE','BR','KR','RB','SR','Y ','ZR',
     &          'NB','MO','TC','RU','RH','PD','AG','CD','IN','SN',
     &          'SB','TE','I ','XE','CS','BA','LA','CE','PR','ND',
     &          'PM','SM','EU','GD','TB','DY','HO','ER','TM','YB',
     &          'LU','HF'/
      data bolz/1.38062D-16/
      do i=1,99
        abund(i)=-20.0
      enddo
      open(1,file='model.inp')   
      read(1,1) filein,fileout
      read(1,*) nd,imod
 1    format(a80)
 11   format(a80)
111   format('ABUNDANCE',2(3x,a2,f6.3),'  0')
1111  format('TITLE model',f8.0,f5.2)
112   format(('ABUNDANCE ',5(2x,a2,f7.2),'  0'))
 5888 FORMAT(i3,E13.6,F9.1,2E13.6,'  0.0  0.0')                                      
2     FORMAT(':V2'/'MODEL TEFF',f8.1,' GRAVITY',f6.3,
     &    ' WMOL 0.216037E-23'/
     &    '      YHE  0.907858E-01 ZME 0.135606E-02'/
     &    'ABUNDANCE  O   0.755123E-03   0.'/
     &    'TURBULENCE   1.00'/'STRUCTURE',i5,' TITLE           ') 
12     FORMAT(':V2'/'MODEL TEFF',f8.1,' GRAVITY',f6.3,
     &    '      YHE  0.907858E-01')
121   FORMAT('STRUCTURE',i5,' TITLE           ') 
13     FORMAT(6x,f6.0,6x,f5.2)
2312  FORMAT(6x,f6.0,9x,f8.2) 
2112  FORMAT(17x,f8.5,19x,f8.2,2x,f8.2) 
2313  FORMAT((17x,6(3x,f7.2))) 
 2314 format(10x,i3)
      open(2,file=filein)   
      open(3,file=fileout)
      if(imod.eq.13) then
        READ(2,11) text
        READ(2,13) TEFF,aLOGG
        READ(2,11) 
        READ(2,*) abund,ndd
        write(3,12) TEFF,aLOGG
        write(3,1111) TEFF,aLOGG
        write(3,121) nd
        sclf=0
      else if(imod.eq.1) then
        READ(2,2312) TEFF,alOGG
        write(3,12) TEFF,aLOGG
c         print *,TEFF,LOGG
c         fehlog=0.0
c         mgfe=0.0
        READ(2,11) text
        write(3,11) text
        READ(2,*)
        READ(2,*)
        READ(2,2112) sclf,abund(1),abund(2)
        sclf=alog10(sclf)
c         print *,eps_ll(1),eps_ll(2)
        READ(2,2313) (abund(i),i=3,92)
        print *,abund(8),abund(26)
        READ(2,*)
        READ(2,*)
        READ(2,*)
c        READ(2,2314) nd
        write(3,121) nd
      else
        READ(2,*) TEFF,aLOGG,feh,mgfe
        write(3,2) TEFF,aLOGG,nd
      endif
c      endif
      do id=1,nd  
         if(imod.eq.13) READ(2,*) TAUS,TEMP,aNE,antot
         if(imod.eq.1) then
           READ(2,*) TAUS,TEMP,pg,aNE
           antot=pg/(TEMP*bolz)
         endif
         write(3,5888) id,TAUS,TEMP,antot,aNE
      enddo 
c      if(imod.eq.13) then
        write(3,111) (atom(i),abund(i),i=1,2)
        write(3,112) (atom(i),(abund(i)+sclf),i=6,30)
c      endif
      close(2)
      close(3)
      stop
      end
