How can I stop the solver gracefully from user Fortran in a steady state run?


Create an 'stp' file in the run directory from user Fortran. A complete working
example is provided, which demonstrates this method. See attached zip archive
file and description below.


FILES SUPPLIED

README This file
run.ccl CCL file for use with the -ccl option
solvercontrol.def Definition file
usr_stp_solver.F User Fortran source code


DESCRIPTION

This example demonstrates how to stop a steady state run of the solver from
user Fortran. In this case the criteria used to stop the solver is when a
variable falls within a specified range. In principle however, any criteria
could be used, the main purpose of the example being to demonstrate how to stop
the solver.

A steady state iteration is actually time step with one coefficient loop. It
should be possible to stop the solver using a similar method as for a transient
simulation, but unfortunately at time of writing, the 'End of Time Step'
location isn't called for steady state simulations.

Therefore, a different approach must be adopted to stop steady state cases,
which is to create a file called 'stp' in the run directory. This is basically
all the solver manager does when stopping a run. Firstly, the next free Fortran
unit is obtained using GET_FORTRAN_UNIT. A file called 'stp' then opened
(creating the file) and closed.

A working example is provided, which also writes a diagnostic message to the
output file when the solver is stopped.

The method outlined stops the solver 'gracefully'. It is sometimes necessary to
stop the solver immediately (e.g. in case of an error), in which case the
routine CFXSTP should be called.


RUNNING THE EXAMPLE

- Open a command prompt/shell. If running on a Windows based machine, obtain
this from the CFX-5 launcher using 'Tools > Command Line'.


- Use the cfx5mkext command to create a shared library from the user Fortran
source code supplied with this example.

cfx5mkext -name scontrol usr_stp_solver.F


-Run the simulation using the CFX-5 solver. The command is:

cfx5solve -def solvercontrol.def -ccl run.ccl


Note that in this example, the library path is set to .. which is adequate
for a simple example run sequentially. For real cases, particularly when
running in parallel, it is strongly recommended to use an absolute path.

Note also that a similar example is available showing how to stop a transient
simulation, which requires a simpler procedure.





Show Form
No comments yet. Be the first to add a comment!