Contents

hide

5.4 A plugin for external programs

With dinverext plugin, it is possible to run an external command to compute the misfit value. This is probably the slowest option but the most convenient. Exchange of information is done through temporary files. The parameterization is built inside the graphical user interface or loaded from an XML file (e.g. produced by an external software).

Once the parameterization is defined (menu 'File/Load parameterization' or 'Tools/Parameters'), the command to run is set with menu 'Tools/Misfit command':

Information about misfit command (TODO: snapshot of widget)
Working directory: ~/case_1
Command: /usr/bin/matlab
Arguments: -nodisplay -nodesktop -nosplash
Standard input: ~/yourscript.m

'yourscript' must read file 'parameters' which contains all variable parameters in column (one by line). On output, the misfit value must be passed in file 'misfit' (just one value on the first line). If 'misfit' does not exist or is empty when returning from script, the forward computation is assumed to have failed. These two files are created in Working Directory specified in dinver user interface.

Bash script example
#!/bin/bash
# Calculate Root Mean Square of parameters relative to [ 5, 5, 5, ...]

cat parameters | awk '
BEGIN {misfit = 0;n=0}
{
  diff = 5-$0
  misfit += diff*diff
  n++
}
END { print sqrt(misfit)/n }
' > misfit              # save result to misfit file

This script can be found in 'dinverext/share', file 'rms5'