; pro plot

; Input files:
cloud='HOT_CORE.'
model='full.'
phys='2d_7cm_3.100K.'
;phys='low_metals_'
point=''   ; '2.'

renorm_dens=2.0e+4

if (cloud eq 'DISK.') and (point eq '1') then begin
  renorm_dens=541321927.37706625
endif

if (cloud eq 'DISK.') and (point eq '2') then begin
  renorm_dens=25883567.574824639
endif

if (cloud eq 'DISK.') and (point eq '3')  then begin
  renorm_dens=3668669.2449275707
endif

if (cloud eq 'TMC1.')  then begin
  renorm_dens=2.0e+4
endif

if (cloud eq 'HOT_CORE.')  then begin
  renorm_dens=2.0e+7
endif

char1='../Bordeaux/'+cloud+model+phys+point+'dat'
char2='../osu_2008_03/'+cloud+'osu0803.'+model+phys+'1.3d_17s_1.1G0.low_metals_1.idl'
;char2='../osu_2008_03/Disk/'+cloud+'osu0803.'+model+phys+point+'.idl'
suff='_'+cloud+model+phys+point+'.ps'

aa=' '

; Open first file (Bordeaux):
ns=655
ntime=38
spec1=strarr(ns)
table=fltarr(ns+1,ntime)

openr,1,char1
readf,1,format='(11x,655(a10))',spec1
readf,1,table
close,1


; Open second file (MPIA):
openr,2,char2
for i=0,33 do readf,2,aa

readf,2,format='(i16)',ns2
spec2=strarr(ns2)
readf,2,format='(9(A8,2X))',spec2

readf,2,format='(i16)',nt
time=fltarr(nt)
readf,2,time

readf,2,format='(i16)',nr
akr=fltarr(nr)
readf,2,format='(10(d12.5))',akr
ab2=fltarr(nt,ns2)
readf,2,format='(10(d12.5))',ab2

ab2=ab2/renorm_dens

close,2

spec1=strcompress(spec1, /remove_all)

; Unify species names:
iE = where(spec1 eq 'E') + 1
spec1(iE-1) = 'ELECTR'
iE = where(spec1 eq 'GRAIN0') + 1
spec1(iE-1) = 'G0'
iE = where(spec1 eq 'GRAIN-') + 1
spec1(iE-1) = 'G-'

spec2=strcompress(spec2, /remove_all)

; Plot species:
!P.FONT = 0

for i=0, ns2-1 do begin

species=spec2(i)

set_plot,'ps'
device,filename=species+suff, /landscape, scale_factor=1

ispec1=where(spec1 eq species)+1
ispec2=where(spec2 eq species)


print, spec1(ispec1-1)

cmin = min(table(ispec1,*)) < min(ab2(*,ispec2))
cmax = max(table(ispec1,*)) > max(ab2(*,ispec2))
;cmin = alog10( cmin ) -1.0e0
;cmax = alog10( cmax ) +1.0e0
cmin = cmin/3.0e0
cmax = cmax*3.0e0

plot,table(0,*),table(ispec1,*),xtitle='log(time)',$
ytitle='log(abundance)', thick=8, xthick=8, ythick=8, charthick=5,charsize=3, $
;xrange=[3,7],ystyle=1,xstyle=12, yrange=[cmin,cmax], xticklen=0.05, yticklen=0.05, line=0, $
xrange=[1.0e0,1.0e9], yrange=[cmin,cmax],ystyle=1,xstyle=1, xticklen=0.05, yticklen=0.05, line=0, $
/xlog, /ylog

oplot,time,ab2(*,ispec2),line=3, thick=8
oplot,time,ab2(*,ispec2),thick=8, psym=1, symsize=3.0

XYOUTS, 0.3, 0.8, /norm, species, charsize=3

device,/close
set_plot,'x'


endfor

end
