PRO dustem_run_plugins, p_dim $ ,param_descs $ ,param_values $ ,param_func $ ,run_order $ ,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 ; run_order = run order of the plugins to be run ; ; 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 IF (*!dustem_plugin)[i].run_order EQ run_order THEN BEGIN must_be_run[i]=1 ENDIF ENDFOR ;print,must_be_run ;stop ;=== 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