dustem_run_plugins.pro
3.55 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
PRO dustem_run_plugins, p_dim ,$
param_descs,$
param_values,$
param_func,$
scopes,$
st=st,$
avoid=avoid,$
force_dustem_run=force_dustem_run,$
use_previous_fortran=use_previous_fortran, $
help=help
;+
; NAME:
; dustem_run_plugins
;
; PURPOSE:
; runs the plugins according to their scopes
; a N_ELEMENTS(PLUGINS)X N_ELEMENTS(SCOPES) matrix is created to achieve this
;
; CATEGORY:
; DustEMWrap, Distributed, Mid-Level, Plugins
;
; CALLING SEQUENCE:
; dustem_run_plugins,p_dim,param_descs,param_values,scopes,[,st][,avoid][,force_dustem_run][,/help]
;
; INPUTS:
; p_dim = parameter values
; param_descs = parameter description vector
; param_values = current parameter values
; param-func = plugin indices array
; scopes = scopes of plugins
;
; OPTIONAL INPUT PARAMETERS:
; avoid = scopes should be avoided
; force_dustem_run = Dustem should be run
; use_previous_fortran = if set, uses the output of the previous fortran run, and does not run the fortran.
;
; OUTPUTS:
; None
;
; OPTIONAL OUTPUT PARAMETERS:
; st = Dustem output structure
;
; ACCEPTED KEY-WORDS:
; help = if set, print this help
;
; COMMON BLOCKS:
; None
;
; SIDE EFFECTS:
; None
;
; RESTRICTIONS:
; The DustEM fortran code must be installed
; The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
; dustem_run_plugins, p_min, param_descs, param_values, param_func, scopes, st=st, avoid=avoid, /force_dustem_run
;
; MODIFICATION HISTORY:
; Written by IC
; Evolution details on the DustEMWrap gitlab.
; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
;-
dew_prefix='dustem_plugin_' ; we assume that this prefix is at the start of all plugin routines
;=== if no plugins, do nothing
IF (*!dustem_plugin)[0].name EQ 'NONE' THEN goto, the_end
;==== This is probably not useful
if not keyword_set(avoid) then avoid=0
if not keyword_set(force_dustem_run) then force_dustem_run=0
;print,scopes
;print,(*!dustem_plugin).scope
;LOCATING THE PLUGINS THAT SHOULD BE RUN
Nparams=n_elements(param_descs)
Nplugins=n_elements(*!dustem_plugin)
must_be_run=intarr(Nplugins)
FOR i=0L,Nplugins-1 DO BEGIN
FOR j=0L,n_elements(scopes)-1 DO BEGIN
pos=strposmulti((*!dustem_plugin)[i].scope,scopes[j],count)
IF count NE 0 THEN must_be_run[i]=1
ENDFOR
ENDFOR
;=== run plugins that need be run
FOR i=0L,Nplugins-1 DO BEGIN
IF must_be_run[i] THEN BEGIN
keys=[0L]
vals=[0.d0]
FOR j=0L,Nparams-1 DO BEGIN
parameter_type=dustem_parameter_description2type(param_descs[j],string_name=string_name,plugin_name=plugin_name,key=key)
IF parameter_type EQ 'PLUGIN' THEN BEGIN
IF plugin_name EQ (*!dustem_plugin)[i].name THEN BEGIN
ind=where(param_descs EQ 'dustem_'+string_name,count)
IF count NE 0 THEN BEGIN
keys=[keys,key]
vals=[vals,param_values[ind[0]]]
ENDIF
ENDIF
ENDIF
ENDFOR
keys=keys[1:*]
vals=vals[1:*]
str='(*!dustem_plugin)['+strtrim(i,2)+'].spec=ptr_new('+(*!dustem_plugin)[i].name+'(key=keys,val=vals)'+')'
message,'executing '+str,/info
toto=execute(str)
;stop
ENDIF
ENDFOR
the_end:
IF keyword_set(force_dustem_run) THEN BEGIN ;and idd gt 0. : remved this so that dustem is always run when the keyword is mentioned.
st = dustem_run(p_dim,use_previous_fortran=use_previous_fortran)
!dustem_current = ptr_new(st)
ENDIF
END