dustem_init_plugins.pro
3.18 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
55
56
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
PRO dustem_init_plugins,pd,fpd=fpd,help=help
;+
; NAME:
; dustem_init_plugins
; PURPOSE:
; initializes variable !dustem_plugin
; CATEGORY:
; DustEMWrap
; CALLING SEQUENCE:
; dustem_init_plugins,pd,[fpd=fpd,help=help]
; INPUTS:
; pd : variable parameters description
; OPTIONAL INPUT PARAMETERS:
; fpd : fixed parameters description
; OUTPUTS:
; None
; OPTIONAL OUTPUT PARAMETERS:
; None
; ACCEPTED KEY-WORDS:
; help
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; !dustem_plugin is set
; RESTRICTIONS:
; The DustEM fortran code must be installed
; The DustEMWrap IDL code must be installed
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
;
; MODIFICATION HISTORY:
; Written by Ilyes Choubani
; Evolution details on the DustEMWrap gitlab.
;-
IF keyword_set(help) THEN BEGIN
doc_library,'dustem_init_plugins'
goto,the_end
END
plugin_names=['']
;plugind_detect_string='dustem_plugin'
Nplugins=0L
plugin_start_str='dustem_'
Npd=n_elements(pd)
Nfpd=0
IF KEYWORD_SET(fpd) THEN Nfpd=n_elements(fpd)
parameter_types=strarr(Npd+Nfpd)
plugin_names=strarr(Npd+Nfpd)
all_par_names=pd
IF KEYWORD_SET(fpd) THEN all_par_names=[all_par_names,fpd]
FOR i=0L,Npd-1 DO BEGIN
parameter_types[i]=dustem_parameter_description2type(pd[i],string_name=string_name)
;print,string_name
pos=strposmulti(string_name,'_',ccount)
IF ccount NE 0 THEN BEGIN
plugin_name=plugin_start_str+strmid(string_name,0,pos[ccount-1])
ENDIF ELSE BEGIN
plugin_name='UNKNOWN'
ENDELSE
plugin_names[i]=plugin_name
ENDFOR
icount=i
IF KEYWORD_SET(fpd) THEN BEGIN
FOR i=0L,n_elements(fpd)-1 DO BEGIN
parameter_types[icount+i]=dustem_parameter_description2type(fpd[i],string_name=string_name)
pos=strposmulti(string_name,'_',ccount)
IF ccount NE 0 THEN BEGIN
plugin_name=plugin_start_str+strmid(string_name,0,pos[ccount-1])
ENDIF ELSE BEGIN
plugin_name='UNKNOWN'
ENDELSE
plugin_names[icount+i]=plugin_name
ENDFOR
ENDIF
order=sort(plugin_names)
plugin_names=plugin_names[order]
parameter_types=parameter_types[order]
un=uniq(plugin_names)
plugin_names=plugin_names[un]
parameter_types=parameter_types[un]
ind=where(parameter_types EQ 'PLUGIN',Nplugins)
one_plugin_st={name:'',spec:ptr_new(),scope:'',paramtag:ptr_new()}
IF Nplugins EQ 0 THEN BEGIN
plugin_st=replicate(one_plugin_st,1)
plugin_st[0].name='NONE'
ENDIF ELSE BEGIN
plugin_names=plugin_names[ind]
plugin_st=replicate(one_plugin_st,Nplugins)
FOR i=0L,Nplugins-1 DO BEGIN
plugin_st[i].name=plugin_names[i]
ENDFOR
ENDELSE
;==== invok each plugin to get their scopes and parameter tag names
FOR i=0L,Nplugins-1 DO BEGIN
scope=1
str='toto='+plugin_st[i].name+'(scope=scope)'
str=str[0]
toto=execute(str)
plugin_st[i].scope=scope
paramtag=1 ;otherwise, paramtag may nt be returned by plugin
str='toto='+plugin_st[i].name+'(paramtag=paramtag)'
str=str[0]
toto=execute(str)
plugin_st[i].paramtag=ptr_new(paramtag)
ENDFOR
;creates the !dustem_plugin structure
defsysv, '!dustem_plugin', ptr_new(plugin_st)
;help,(*!dustem_plugin),/str
;help,(*!dustem_plugin)[0].scope
;stop
the_end:
END