# Basic examples of MOPAC usage

This directory contains several examples of MOPAC calculations.

MOPAC is most commonly used as a command-line program with input and output files.
Here are several examples of input files for the most commonly used MOPAC features applied to water:

 - `example_scf.mop`: self-consistent field (SCF) calculation
 - `example_relax.mop`: molecular geometry relaxation
 - `example_vibe.mop`: vibrational calculation on a relaxed geometry
 - `example_cosmo.mop`: SCF calculation with COSMO implicit solvation model

These example input files are interoperable with the `.xyz` file format by adding or removing the MOPAC keyword line at the top.
Each of these examples can be run using the syntax:
```
 /path/to/mopac/executable example_name.mop
```
If the MOPAC executable is in your path, then `/path/to/mopac/executable` is simply `mopac`.
These examples generate a main output file named `example_name.out` and an archival output file named `example_name.arc`.
A reference copy of the main output files with the name `example_name.mop_output` is provided for comparison.

## C API example

These same example calculations are performed using the C API to MOPAC in the C program `example.c`.
This example includes the MOPAC API header file `mopac.h` located in `/include` and must be linked with the MOPAC shared library
(i.e. libmopac.so on Linux, libmopac.dylib on Mac, mopac.dll on Windows).
An example build statement with the `gcc` compiler and the MOPAC shared library located at `../lib` is:
```
gcc example.c -I../include -L../lib -lmopac -o c_executable
```
Additional linking options such as `-Wl,-rpath=../lib` may be necessary if the MOPAC shared library is not in your path.
`example.c_output` is a reference copy of the standard output generated by this example.

## Fortran API example

The Fortran API to MOPAC requires an extra wrapper that must be compiled alongside the calling program.
The Fortran program `example.F90` is the Fortran equivalent to `example.c`, which must be compiled and linked with
`mopac_wrapper.F90` and `mopac_wrapper_internal.F90` located in `/include` along with the MOPAC shared library.
An example build statement with the `gfortran` compiler and the MOPAC shared library located at `../lib` is:
```
gfortran example.F90 ../include/mopac_wrapper.F90 ../include/mopac_wrapper_internal.F90 -I../include -L../lib -lmopac -o fortran_executable
```
Additional linking options such as `-Wl,-rpath=../lib` may be necessary if the MOPAC shared library is not in your path.
`example.F90_output` is a reference copy of the standard output generated by this example.

## Further information

MOPAC's features and command-line functionality are primarily determined by keywords at the top of the input file.
Online [guides](https://openmopac.github.io/guides/) provide instructions on how to use the most
popular MOPAC keywords and features, and the online [manual](https://openmopac.github.io/Manual/) has a more detailed and
comprehensive description of MOPAC's keywords and features. Further information about the API is available in the
[API guide](https://openmopac.github.io/guides/api/).
