model_error

A single model that raises/returns an error.

C Version

Model Code:

1int main(int argc, char *argv[]) {
2  // Return a non-zero value to indicate an error
3  return -1;
4}
5

Model YAML:

 1---
 2
 3model:
 4  name: model_error_c
 5  driver: GCCModelDriver
 6  args: ./src/model_error.c  # compile the C code with necessary libraries
 7
 8  inputs:
 9    - name: inFile
10      driver: FileInputDriver
11      args: ./Input/input.txt
12    - name: model_errorQueueIn
13      driver: InputDriver
14      args: model_errorQueue
15  
16  outputs:
17    - name: model_errorQueueOut
18      driver: OutputDriver
19      args: model_errorQueue
20    - name: outFile
21      driver: FileOutputDriver
22      args: output_model_error.txt
23      in_temp: True

C++ Version

Model Code:

 1#include <YggInterface.hpp>
 2
 3int main(int argc, char *argv[]) {
 4  // This must be set to prevent dialog box on windows for unhandled exception
 5#ifdef _WIN32
 6  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
 7  _set_abort_behavior(0,_WRITE_ABORT_MSG);
 8#endif
 9  // Throw an error or return a non-zero value to indicate an error
10  throw "Test error";
11  return -1;
12}

Model YAML:

 1---
 2
 3model:
 4  name: model_error_cpp
 5  driver: GCCModelDriver
 6  args: ./src/model_error.cpp
 7
 8  inputs:
 9    - name: inFile
10      driver: FileInputDriver
11      args: ./Input/input.txt
12    - name: model_errorQueueIn    
13      driver: InputDriver
14      args: model_errorQueue
15
16  outputs:
17    - name: model_errorQueueOut
18      driver: OutputDriver
19      args: model_errorQueue
20    - name: outFile
21      driver: FileOutputDriver
22      args: output_model_error.txt
23      in_temp: True

Fortran Version

Model Code:

1program main
2  stop 1
3end program main

Model YAML:

 1---
 2
 3model:
 4  name: model_error_fortran
 5  driver: FortranModelDriver
 6  args: ./src/model_error.f90  # Runs the fortran script using default fortran compiler
 7
 8  inputs:
 9    - name: inFile
10      driver: FileInputDriver
11      args: ./Input/input.txt
12    - name: model_errorQueueIn    
13      driver: InputDriver
14      args: model_errorQueue
15
16  outputs:
17    - name: model_errorQueueOut    
18      driver: OutputDriver
19      args: model_errorQueue
20    - name: outFile
21      driver: FileOutputDriver
22      args: output_model_error.txt
23      in_temp: True

Matlab Version

Model Code:

1% Raise an error or return non-zero value
2error('Test error');

Model YAML:

 1---
 2
 3model:
 4  name: model_error_matlab
 5  driver: MatlabModelDriver
 6  args: ./src/model_error.m  # Runs the matlab script using Matlab engine
 7
 8  inputs:
 9    - name: inFile
10      driver: FileInputDriver
11      args: ./Input/input.txt
12    - name: model_errorQueueIn    
13      driver: InputDriver
14      args: model_errorQueue
15
16  outputs:
17    - name: model_errorQueueOut    
18      driver: OutputDriver
19      args: model_errorQueue
20    - name: outFile
21      driver: FileOutputDriver
22      args: output_model_error.txt
23      in_temp: True

Python Version

Model Code:

1
2def runerror():
3    # Raise exception or return non-zero value to indicate an error
4    raise Exception("Test error")
5
6    
7if __name__ == '__main__':
8    runerror()

Model YAML:

 1---
 2
 3model:
 4  name: model_error_python
 5  driver: PythonModelDriver
 6  args: ./src/model_error.py  # Runs the python script using default python
 7
 8  inputs:
 9    - name: inFile
10      driver: FileInputDriver
11      args: ./Input/input.txt
12    - name: model_errorQueueIn    
13      driver: InputDriver
14      args: model_errorQueue
15
16  outputs:
17    - name: model_errorQueueOut    
18      driver: OutputDriver
19      args: model_errorQueue
20    - name: outFile
21      driver: FileOutputDriver
22      args: output_model_error.txt
23      in_temp: True

R Version

Model Code:

1stop("Test error")

Model YAML:

 1---
 2
 3model:
 4  name: model_error_R
 5  driver: RModelDriver
 6  args: ./src/model_error.R  # Runs the R script using default R
 7
 8  inputs:
 9    - name: inFile
10      driver: FileInputDriver
11      args: ./Input/input.txt
12    - name: model_errorQueueIn    
13      driver: InputDriver
14      args: model_errorQueue
15
16  outputs:
17    - name: model_errorQueueOut    
18      driver: OutputDriver
19      args: model_errorQueue
20    - name: outFile
21      driver: FileOutputDriver
22      args: output_model_error.txt
23      in_temp: True