Inputs
When starting an application from the operating system command line, you can provide input arguments. In the application tree, you specify such input arguments under the Inputs node.
Command-line arguments are automatically written to the declarations you define as Selected source, in the corresponding Settings window for an Application Argument. They can be used, for example, to provide input data or configuration settings.
Command-line arguments can be used when starting applications with COMSOL Multiphysics, COMSOL Server, as well as when starting applications that have been compiled with COMSOL Compiler. In the example below, for a compiled application in Windows®, an input argument freq is given that takes a (double) value 400.
For COMSOL Multiphysics, the corresponding command would be
comsol.exe -run myapp.mph -appargnames freq -appargvalues 400
When running this command, you need to be positioned in the COMSOL Multiphysics installation directory where the executable comsol.exe is located, for example
C:\Program Files\COMSOL\COMSOL64\Multiphysics\bin\win64
Alternatively, you can copy and paste the COMSOL Multiphysics 6.4 Windows® Desktop shortcut icon (in order to keep the original shortcut), right-click the icon, and select Properties; as shown in the figure below.
You can, for example, modify the Target text field to be:
"C:\Program Files\COMSOL\COMSOL64\Multiphysics\bin\win64\comsol.exe" -run myapp.mph -appargnames freq -appargvalues 400
To provide input arguments with special characters, you need to use single quotes. The following example of a compiled application shows how to provide a file path, such as for a configuration file, as an input argument:
myapp.exe -appargnames configfile -appargvalues 'C:\\COMSOL\\my_conf.dat'
If you have multiple input arguments, they are separated by commas, for example:
myapp.exe -appargnames a,b,configfile -appargvalues 3.2,5.4,'C:\\COMSOL\\my_conf.dat'
For COMSOL Server, you can provide the arguments directly in the address field of your browser (URL); for example:
http://<host:port>/app/myapp_mph?appargnames=freq&appargvalues=400
You can also use a file declaration as an input argument. This is useful, for example, when you want to let users supply input files. For example:
comsol.exe -run file_arguments.mph -appargnames interpfile -appargvalues 'C:\data\functions\simpleinterp.txt'
This example uses an application argument interpfile, which is linked to a file declaration to read the interpolation file simpleinterp.txt when launching the application. This file is then used in an interpolation function in the application’s embedded model.
Note that in order to use units, you need to use nested quotes. For example, -appargvalues "'500[m]','500[s]'".