Skip to content

5.2 Running Multiwfn in silent mode

Note

If you can read Chinese, please read Sections 1 and 2 of my blog article “Detailed introduction to the command line running and batch running methods of Multiwfn” (http://sobereva.com/612) instead, in which more detailed information about running Multiwfn via command-line is introduced and many illustrative scripts are given and carefully explained.

Multiwfn aims for ease of use, so it is designed as an interactive program. Nevertheless, Multiwfn can also run in silent mode (command-line mode), so that you do not need to press any button during running. Here I will introduce how to do it.

For Windows users

For example, you want to obtain the graph in example 4.4.1 silently, you need to write an input stream file first, the content is (red texts are comments):

4   ← Main function 4
1   ← Real space function 1
1   ← Color-filled map
   ← Space line, corresponding to press ENTER button once (use default grid setting)
2   ← XZ plane
0   ← Y=0
0   ← Option 0: save graph to current directory

I suppose that the inputstream file is named as 4.4.1.txt, I have already provided this file in “examples” directory. Now change “isilent” parameter in settings.ini from 0 to 1 (or add "-silent" argument in command line), this makes Multiwfn forbid displaying any graph or GUI automatically during running, otherwise you have to close the window by clicking mouse button. Then enter command-line environment of Windows (click “Start”-“run” and type “cmd”) and run:

Multiwfn HCN.wfn < 4.4.1.txt > medinfo.txt

Here I assume that Multiwfn.exe, 4.4.1.txt and HCN.wfn are in current directory. After a few seconds, you will find that image file has appeared in current directory. From medinfo.txt you can find all intermediate information outputted by Multiwfn.

What does the content in the input stream file mean? The answer is: the texts in each line of the input stream file are just what you need to input in interactive mode. It is very easy to write a new input stream file by following the prompts on screen in interactive mode. The symbols “<” and “>” are redirection operators, they respectively tell Multiwfn that the content in 4.4.1.txt is input stream, while the output stream should be stored to medinfo.txt. This redirection mechanism is not provided by Multiwfn but provided by operation system. Notice that the name of input file is not given in input stream file, because it appears as an argument.

You may have noted that when the task is finished, some errors like below appear:

forrtl: severe (24): end-of-file during read, unit -4, file CONIN$
Image              PC        Routine            Line        Source
Multiwfn.exe       00588F1A  Unknown               Unknown  Unknown
Multiwfn.exe       00586438  Unknown               Unknown  Unknown
Multiwfn.exe       00530B3A  Unknown               Unknown  Unknown
......

Actually they are not errors, and hence you can safely ignore them. However, if you really want to exit Multiwfn gracefully to avoid printing the "errors", you should properly write the input stream file so that command q is inputted in the main function menu at the final step.

Another example, assume that you want to save detail compositions of orbitals 1 to 3 of COCl2.fch, just create an input stream file orbana_1_3.in with the following content:

8  ← Orbital composition analysis
1  ← Mulliken method
1  ← Orbital 1
2  ← Orbital 2
3  ← Orbital 3

Then run the command: Multiwfn COCl2.fch < orbana_1_3.in > orbana_1_3.txt.

Notice that if you are using PowerShell in Windows environment, since the "<" redirection operator is unsupported, you should use "Get-Content" command and pipeline feature instead. For example, above command should be written as (assume that Multiwfn.exe is in current folder): Get-Content orbana_1_3.in | ./Multiwfn.exe COCl2.fch > orbana_1_3.txt

For Linux / MacOS users

If you are a Linux or MacOS user, you can not only run Multiwfn silently as introduced above, but also make use of "echo" command to avoid explicitly writing an input stream file. The last example can be equivalently realized by running this command:

echo -e "8\n1\n1\n2\n3" | Multiwfn COCl2.fch > orbana_1_3.txt

Each \n means pressing ENTER button once.

If you prefer to use shell script, you can also add below lines into your shell script file:

Multiwfn COCl2.fch > orbana_1_3.txt << EOF
8
1
1
2
3
EOF