Blame view

src/idl/dustem_init_plugins.pro 3.1 KB
5816c74c   Annie Hughes   made fpd a keyword
1
PRO dustem_init_plugins,pd,fpd=fpd,help=help
392ede91   Jean-Philippe Bernard   included an help ...
2
3
4
5
6
7
8
9
10

;+
; NAME:
;    dustem_init_plugins
; PURPOSE:
;    initializes variable !dustem_plugin
; CATEGORY:
;    DustEMWrap
; CALLING SEQUENCE:
90047618   Annie Hughes   made fpd a keyword
11
;    dustem_init_plugins,pd,[fpd=fpd,help=help]
392ede91   Jean-Philippe Bernard   included an help ...
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
; 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
e7938fa3   Ilyes Choubani   Corrected02: Impl...
42

e7938fa3   Ilyes Choubani   Corrected02: Impl...
43

7f2b2149   Jean-Philippe Bernard   a Ilyes
44
plugin_names=['']
5eebdedb   Jean-Philippe Bernard   changed plugin st...
45
;plugind_detect_string='dustem_plugin'
83b3ddee   Jean-Philippe Bernard   modified with Ily...
46
Nplugins=0L
5eebdedb   Jean-Philippe Bernard   changed plugin st...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
7f2b2149   Jean-Philippe Bernard   a Ilyes
68
ENDFOR
5eebdedb   Jean-Philippe Bernard   changed plugin st...
69
icount=i
3c479f24   Ilyes Choubani   Allowing to fix p...
70
IF KEYWORD_SET(fpd) THEN BEGIN
5eebdedb   Jean-Philippe Bernard   changed plugin st...
71
72
73
74
75
76
77
78
79
    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
3c479f24   Ilyes Choubani   Allowing to fix p...
80
81
    ENDFOR
ENDIF
607060e5   Ilyes Choubani   test version
82

5eebdedb   Jean-Philippe Bernard   changed plugin st...
83
84
85
86
87
88
89
90
91
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()}
759a527d   Ilyes Choubani   general update
92

83b3ddee   Jean-Philippe Bernard   modified with Ily...
93
IF Nplugins EQ 0 THEN BEGIN
5eebdedb   Jean-Philippe Bernard   changed plugin st...
94
95
    plugin_st=replicate(one_plugin_st,1)
    plugin_st[0].name='NONE'
83b3ddee   Jean-Philippe Bernard   modified with Ily...
96
ENDIF ELSE BEGIN
5eebdedb   Jean-Philippe Bernard   changed plugin st...
97
98
99
100
101
    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
83b3ddee   Jean-Philippe Bernard   modified with Ily...
102
103
ENDELSE

5eebdedb   Jean-Philippe Bernard   changed plugin st...
104
105
106
107
108
109
110
111
112
113
114
115
;==== invok each plugin to get their scopes and parameter tag names
FOR i=0L,Nplugins-1 DO BEGIN
    str='toto='+plugin_st[i].name+'(scope=scope)'
    str=str[0]       
    toto=execute(str)
    plugin_st[i].scope=scope

    str='toto='+plugin_st[i].name+'(paramtag=paramtag)'
    str=str[0]       
    toto=execute(str)
    plugin_st[i].paramtag=ptr_new(paramtag)
ENDFOR
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
116

5eebdedb   Jean-Philippe Bernard   changed plugin st...
117
118
;creates the !dustem_plugin structure
defsysv, '!dustem_plugin', ptr_new(plugin_st)
e7938fa3   Ilyes Choubani   Corrected02: Impl...
119

5eebdedb   Jean-Philippe Bernard   changed plugin st...
120
121
122
;help,(*!dustem_plugin),/str
;help,(*!dustem_plugin)[0].scope
;stop
e7938fa3   Ilyes Choubani   Corrected02: Impl...
123

392ede91   Jean-Philippe Bernard   included an help ...
124
the_end:
e7938fa3   Ilyes Choubani   Corrected02: Impl...
125

392ede91   Jean-Philippe Bernard   included an help ...
126
END