# Model Coupling

MADS can be coupled with any internal or external model.

The model coupling is defined in the MADS problem dictionary.

The expectation is that for a given set of model inputs, the model will produce a model output that will be provided to MADS.

The fields in the MADS problem dictionary that can be used to define the model coupling are:

• Model : execute a Julia function defined in an input Julia file. The function that should accept a parameter dictionary with all the model parameters as an input argument and should return an observation dictionary with all the model predicted observations. MADS will execute the first function defined in the file.
• MADS model : create a Julia function based on an input Julia file. The input file should contain a function that accepts as an argument the MADS problem dictionary. MADS will execute the first function defined in the file. This function should create a Julia function that will accept a parameter dictionary with all the model parameters as an input argument and will return an observation dictionary with all the model predicted observations.
• Julia model : execute an internal Julia function that accepts a parameter dictionary with all the model parameters as an input argument and will return an observation dictionary with all the model predicted observations.
• Command : execute an external UNIX command or script that will execute an external model.
• Julia command : execute a Julia script that will execute an external model. The Julia script is defined in an input Julia file. The input file should contain a function that accepts a parameter dictionary with all the model parameters as an input argument; MADS will execute the first function defined in the file. The Julia script should be capable to (1) execute the model (making a system call of an external model), (2) parse the model outputs, (3) return an observation dictionary with model predictions.

Both Command and Julia command can use different approaches to pass model parameters to the external model.

Only Command uses different approaches to get back the model outputs. The script defined under Julia command parses the model outputs using Julia.

Both Command and Julia command can use different approaches to pass model parameters to the external model.

Only Command uses different approaches to get back the model outputs.

The script defined under Julia command parses the model outputs using Julia.

The available options for writing model inputs and reading model outputs are as follows.

## Options for writing model inputs:

• Templates : template files for writing model input files as defined at http://mads.lanl.gov
• ASCIIParameters : model parameters written in a ASCII file
• JLDParameters : model parameters written in a JLD file
• YAMLParameters : model parameters written in a YAML file
• JSONParameters : model parameters written in a JSON file

## Options for reading model outputs:

• Instructions : instruction files for reading model output files as defined at http://mads.lanl.gov
• ASCIIPredictions : model predictions read from a ASCII file
• JLDPredictions : model predictions read from a JLD file
• YAMLPredictions : model predictions read from a YAML file
• JSONPredictions : model predictions read from a JSON file