Blame view

src/idl/dustem_read_calor.pro 2.21 KB
eafc1f8f   Annie Hughes   updated help info
1
FUNCTION dustem_read_calor,file,silent=silent,help=help
427f1205   Jean-Michel Glorian   version 4.2 merged
2

eafc1f8f   Annie Hughes   updated help info
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
55
56
;+
; NAME:
;   dustem_read_calor
;
; PURPOSE:
;   reads information relating to grain heat capacities from the
;    .DAT file to a dustem data structure
;
; CATEGORY:
;    DustEMWrap, Distributed, LowLevel, Initialization
;
; CALLING SEQUENCE:
;   st=dustem_read_calor(file)
;
; INPUTS:
;    file  : input file to be read
;
; OPTIONAL INPUT PARAMETERS:
;    None
;
; OUTPUTS:
;    st   : dustem data structure
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    help     : writes this help
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:  
;
; EXAMPLES:
;
; MODIFICATION HISTORY:
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-
  
  IF keyword_set(help) THEN BEGIN
     doc_library,'dustem_read_calor'
     st=0.
     goto,the_end
  ENDIF
  
  
427f1205   Jean-Michel Glorian   version 4.2 merged
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
;  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

eafc1f8f   Annie Hughes   updated help info
105
the_end:
427f1205   Jean-Michel Glorian   version 4.2 merged
106
107
108
return,st

END