PRO dustem_activate_plugins,p_min,st=st,help=help,use_previous_fortran=use_previous_fortran ;+ ; NAME: ; dustem_activate_plugins ; ; PURPOSE: ; activates the plugins invoked by the parameter description vector (pd) and the fixed parameter description vector (fpd) ; ; CATEGORY: ; DustEMWrapp, Distributed, Mid-Level, Plugins ; ; CALLING SEQUENCE: ; dustem_activate_plugins,p_min[,st][,/help] ; ; INPUTS: ; p_min = dustem parameter values normalized to initial parameter values ; ; OPTIONAL INPUT PARAMETERS: ; ; OUTPUTS: ; None ; ; OPTIONAL OUTPUT PARAMETERS: ; st = Dustem output structure, with contribution from pluggins taken into account ; ; ACCEPTED KEY-WORDS: ; use_previous_fortran = if set, uses the output of the previous fortran run, and does not run the fortran. ; 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_activate_plugins, p_min ,st=st ; ; MODIFICATION HISTORY: ; Written by IC ; 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_activate_plugins' goto,the_end output=0. ENDIF p_dim = p_min * (*(*!dustem_fit).param_init_values) ;This is to account for fixed parameters ;caution: this assumes there are variable parameters, could not always be the case ... IF isa((*!dustem_fit).fixed_param_descs) THEN BEGIN ;concatenating the parameter vectors param_descs = [(*(*!dustem_fit).param_descs),(*(*!dustem_fit).fixed_param_descs)] param_values = [p_dim,(*(*!dustem_fit).fixed_param_init_values)] param_values = param_values[sort(param_descs)] ;should we put it back to the way it was? param_descs = param_descs[sort(param_descs)] ;Taking care of the param_func vector (not sure if this is of any use anymore) dustem_set_func_ind, param_descs, param_values ; this sets (*(*!dustem_fit).param_func) param_func = (*(*!dustem_fit).param_func) dustem_set_func_ind, (*(*!dustem_fit).param_descs), p_dim ;setting the pointers back to their original valyes ENDIF ELSE BEGIN param_descs = (*(*!dustem_fit).param_descs) param_values = p_dim param_func = (*(*!dustem_fit).param_func) ENDELSE ;stop ;Run the plugins, according to their scopes ;normal (additive) plugins come first as they can be used by other plugins ;The ISRF plugin is next - we can always change its scope however we please to. DustEm runs here. This is with the /force_dustem_run keyword. ;The plugins that use the DustEM output come next - we can always change their 'common' scope ;IF /avoid is used the specified scopes are avoided. They're considered when /avoid is missing. ;using '**' so not to write the entire scope ;=== This runs plugins with scopes including STELLAR, REPLACE and ISRF ;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD','REPLACE'], avoid=1,use_previous_fortran=use_previous_fortran dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD_SED'], avoid=1,use_previous_fortran=use_previous_fortran ;=== The line below makes fawlty go Segmentation fault. st is undefined at that stage ;=== it would run fine if avoid was set to 1 ;IC: I think the segmentation fault comes from the fact that the user wants to use models that have the /pol keyword in the GRAIN.DAT file without being in polarization mode. ;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['STELLAR','ISRF'] ,force_dustem_run=1,st=st,use_previous_fortran=use_previous_fortran ;dustem output is available at this step. dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD_ISRF','REPLACE_ISRF'] ,force_dustem_run=1,st=st,use_previous_fortran=use_previous_fortran ;dustem output is available at this step. ;added this small condition to ensure that dustem is run ;(if no ISRF plugin is used) ; if ~isa(st) then begin ; st=dustem_run(p_dim) ; !dustem_current=ptr_new(st) ; endif ;THE ABOVE CONDITION IS UNNECESSARY SINCE DUSTEM IS CALLED ABOVE WHETHER PLUGINS ARE RUN OR NOT. ;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['REPLACE'],use_previous_fortran=use_previous_fortran dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['REPLACE_SED'],use_previous_fortran=use_previous_fortran the_end: END