dustem_read_calor.pro
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FUNCTION dustem_read_calor,file,silent=silent
; READ(UNIT = fspecem%unit,FMT = *) COEFFISRF, NTEMP,NSPINC,NIT
;num_char=['1.','2.','3.','4.','5.']+' pour '
num_char=['1.','2.','3.','5.','4.']+' pour '
openr,unit,file,/get_lun
str=' '
all_str=['']
WHILE not eof(unit) DO BEGIN
readf,unit,str
all_str=[all_str,str]
ENDWHILE
close,unit
free_lun,unit
all_str=all_str(1:*)
all_str=strtrim(all_str,2)
ind=where(strlen(all_str) NE 0,count)
all_str=all_str(ind)
first_char=strmid(all_str,0,8)
match,first_char,num_char,ind1,ind2,count=count
order=sort(ind1)
ind1=ind1(order)
ind2=ind2(order)
eptr=ptr_new()
one_st={type:0,st:'',lnC:eptr,lnT:eptr}
st=replicate(one_st,count)
FOR i=0L,count-1 DO BEGIN
IF i NE count-1 THEN Nel=ind1(i+1)-ind1(i)-1 ELSE Nel=n_elements(all_str)-ind1(i)-1
lnT=fltarr(Nel)
lnC=fltarr(Nel)
FOR j=0L,Nel-1 DO BEGIN
sst=strcompress(all_str(ind1(i)+j+1))
toto=strsplit(strcompress(sst))
lnT(j)=float(strmid(sst,toto(0),toto(1)-toto(0)))
lnC(j)=float(strmid(sst,toto(1),100))
; print,float(strmid(sst,toto(0),toto(1)-toto(0))),float(strmid(sst,toto(1),100))
ENDFOR
st(i).type=strmid(first_char(ind1(i)),0,1)
st(i).st=all_str(ind1(i))
st(i).lnC=ptr_new(LnC)
st(i).lnT=ptr_new(LnT)
ENDFOR
return,st
END