.. _subroutines-compile:

*************************
Compilation and Execution
*************************

Running a code with user subroutines is a two-step process. First, an executable version of Sierra/SM that recognizes the user subroutines must be created. This executable must then be used for a Sierra/SM analysis with an input file that incorporates the proper user subroutine command lines.

How the above two steps are carried out is site- and installation-specific, but an example demonstrating this process on various systems at Sandia using SIERRA---a general code framework and code management system at Sandia---command lines is provided.

For the first step, you will need the user subroutine, in a FORTRAN file, and a Sierra/SM input file that makes use of the user subroutine. You will use a system command line of the general form shown below.

.. code-block:: sh

   sierra --make adagio -i <string>input_file_name

Suppose that you have a subdirectory in your area called ``test`` and you wish to incorporate a user subroutine called ``blast_load``. The actual user subroutine will be in a file called ``blast_load.F``, and the associated input file will be called ``blast_load_1.i``. Both of these files will be in the directory ``test``. In the input file, you will have the following command line in the SIERRA scope:

.. code-block:: sierrainput

   USER SUBROUTINE FILE = blast_load.F

You will also have some subset of the command lines described in the previous section in your Sierra/SM input file. The specific form of the system command line to execute the first step of the user subroutine process is shown below.

.. code-block:: sh

   sierra --make adagio -i blast_load_1.i

The above command will create a local version of Sierra/SM in a local directory named ``UserSubsProject``. The system command line to run the local version of Presto is shown below.

.. code-block:: sh

   sierra ./UserSubsProject/bin/adagio -i <string>input_file_name

The specific form of the system command line you will execute in the subdirectory test is shown below.

.. code-block:: sh

   sierra ./UserSubsProject/bin/adagio -i blast_load_1.i

The second command line runs Sierra/SM using ``blast_load_1.i`` as an input file and uses the user subroutines in the process. Again, all of this is a site-specific example. You must determine how Sierra/SM is set up at your installation to determine what system command lines are necessary to build Sierra/SM with user subroutines and then use this version of Sierra/SM.
