.. _sec-restart_terminate: ************************************************** Restart and terminate PHITS calculations ************************************************** .. _sec-restart: Restart PHITS calculations ================================================== If tally results of PHITS calculations are not statistically significant enough, PHITS is able to read the previous tally results and resume the calculations (restart calculation mode). In the **[parameters]** section, restart calculation mode can be activated by setting **istdev < 0**, and the statistics of the restart calculation will be counted together with the previous tally results. It is allowed to add new tally sections for the input file with the restart calculation, even if there is no past tally result. Please refer to the description of **istdev** in the **[parameters]** section. The procedure of restart calculation is described as follows: #. Check whether or not the file specified by **resfile** in each tally section exists. The default file name of the **resfile** is that given by **file** parameter. #. If there is no **resfile** for a tally, it is regarded as new. If no **resfile** can be found for any tally, a new calculation is begun with **istdev=|istdev|**. #. If **resfile** exists, PHITS reads information from the file on the standard deviation mode **istdev**, total weight **resc2**, total history number **resc3**, history number per batch **maxcas**, the next random seed **rijklst**, and the results and relative errors of the past calculation. #. The tally parameters given in the current and past PHITS input files are then checked for consistency. If they are not consistent with each other, PHITS stops the calculation and outputs an error message. It should be noted that not all tally parameters are checked for consistency in this process. #. (In batch standard deviation mode only) The consistency of **istdev** and **maxcas** among the **resfiles** is checked. If they are consistent, the restart calculation is performed using these values. If an inconsistency is found, the calculation is stopped. #. The initial random seed is changed to the value of **rijklst** obtained from the first **resfiles**. If **rijklst** differs by **resfile**, a warning message is output. #. Upon finishing the restart calculation, the tally results are output to the file specified by **file=**. If **resfile** is not specified, the past tally results are overwritten. Important notice: I. All past tally results should be calculated in the same standard deviation mode: i.e., **istdev** should be the same in all **resfile**. II. The **maxcas** written in the input file is not used in the restart calculation in batch standard deviation mode. III. Except for those given in the tally sections, the consistencies of input parameters are not checked by the PHITS program. If they are inconsistent with the previous setting, the tally results might be incorrect even if no error messages show up. Terminate the PHITS code ================================================== Once PHITS is executed, it creates a ``batch.out`` [#]_ file following every batch that contains elapse information. In parallel calculation, ``batch.out`` also contains each processor element (PE) status. The occurrence of a PE abort can be determined by examining ``batch.out``. The first line of ``batch.out`` is written as follows: .. code-block:: text 10 <--- number of remaining batches Here, the value on the left is the number of remaining batches at the moment. The remaining batches can be reduced by editing the value and saving ``batch.out``. For example, when the value is changed to 3, the PHITS execution will be terminated after the calculation of three batches is finished. Changing the value to 0 terminates the code execution right after the calculation of that batch is completed. This function can be useful in the way explained below. The parameter **itall** can be used together with ``batch.out``. If **itall=0(default)** or **itall=1** is set in the **[parameters]** section, PHITS will update the calculation results (tally output) at the end of each batch. With **itall=1**, the image (``*.eps``) files will also be updated. In parallel computing mode, the results are updated every batch :math:`\times` (PE - 1). Using these functions enables terminating PHITS calculations at any time with the latest results updated. From ver. 2.86, the file name of ``batch.out`` can be modified by setting **file(22)** in the **[parameters]** section. Changing the name of each input file enables multiple executions of PHITS in a common directory. Note that this function is not available if **[t-dchain]** is set in the input files, because the same file name, ``n.flux``, is used. The value of **rijk** written in the ``batch.out`` file is the initial random number of the current batch. Thus, for example, in cases of unsuccessful termination of PHITS, it is possible to reproduce the calculation of the specified batch using the value of **rijk**. .. [#] Until ver. 2.85, the name of this file had been named ``batch.now.``