================================== Executing Calculations ================================== This section explains how to run calculations on the supercomputing system. It is assumed that :doc:`/getting_started/login_to_system` has already been completed. MASAMUNE-II employs a job management mechanism using the `PBS Professional `_ job scheduler. Users write the calculations they wish to perform in a job script and submit it to a queue corresponding to the required computing resources. Jobs submitted by each user are allocated computing resources and executed according to the execution priority determined by the job scheduler. The execution priority of a job is determined based on the amount of reserved computing resources and past resource usage of each user, in order to ensure that jobs are executed as fairly and efficiently as possible among users. For details, please refer to :doc:`/job/job_exe_order`. Overview ======== To run a calculation, the following steps are usually performed: 1. Compile the calculation program source code 2. Create a job script to run the program 3. Submit the job using the ``qsub`` command .. note:: Many materials science calculation applications are pre-installed on MASAMUNE-II, so you can use them without compiling code yourself. You can check job script examples on each application's page in :doc:`/app/app_list`. Job Script ---------- Jobs are written in shell script format as follows: .. code-block:: none #!/bin/sh #PBS -l select=1:ncpus=1:mem=4gb #PBS -q queue_name #PBS -N job_name (Specify program to execute, etc. below) The lines starting with "#PBS" in lines 2–4 of the script reserve computing resources, specify the queue, and set the job name. For details, please refer to :doc:`/job/command/exe_job` and related pages. Procedure for Running a Sample Program ====================================== Here, we explain the procedure for compiling a C language Hello World program and running it as a job. Creating and Compiling the Source Code -------------------------------------- First, create a file named ``hello.c`` with the following content: .. code-block:: none #include int main(void) { printf("Hello world!\n"); return 0; } Next, compile the program using a compiler to generate the executable file ``hello``. Here we will use the GNU compiler (gcc). .. code-block:: none $ gcc hello.c -o hello .. note:: In addition to the GNU compiler, MASAMUNE-II has the Intel compiler, NVIDIA HPC compiler, and CUDA toolkit installed. For how to use them, please refer to :doc:`/compiler_lib/compiler_lib`. Creating the Job Script ----------------------- Next, create a job script to submit the compiled program to the queue. Create a file named ``hello.sh`` with the following content. This script submits a job named "hello" to the queue ``CP_001`` and executes the ``hello`` program created above. .. code-block:: none #!/bin/sh #PBS -l select=1:ncpus=1:mem=4gb #PBS -q CP_001 #PBS -N hello # Move to the directory where the job was submitted cd ${PBS_O_WORKDIR} # Redirect standard output to result.out and standard error to result.err ./hello > result.out 2> result.err For details on the script format, please refer to :doc:`/job/command/script` and related pages. Submitting the Job ------------------ Once the script is created, submit the job using the ``qsub`` command as follows: When the job submission is successful, the Job ID (in this case, ``123456.cmspbs1``) is displayed. .. code-block:: none $ qsub hello.sh 123456.cmspbs1 You can check the status of the job using the ``statj`` command. .. code-block:: none $ statj sdb: Req'd Req'd Elap Job ID Username Queue Jobname SessID NDS TSK Memory Time S Time --------------- -------- -------- ---------- ------ --- --- ------ ----- - ----- 123456.cmspbs1 sc-user CP_001 hello -- 1 1 4gb 24:00 Q -- The meaning of each item is as follows: .. list-table:: :widths: 30 70 :header-rows: 1 * - Item - Meaning * - Job ID - ID assigned to the job * - Username - User name * - Queue - Name of the queue to which the job was submitted * - Jobname - Job name * - SessID - Session ID * - NDS - Number of allocated nodes * - TSK - Number of CPU cores * - Req'd Memory - Maximum available memory limit * - Req'd Time - Maximum execution time limit * - S - Job status |br| Q: Queued (Waiting) |br| R: Running |br| E: Exiting |br| H: Held * - Elap Time - Elapsed time since the job started running .. |br| raw:: html
When the job finishes, the following files will be saved in the current directory: .. code-block:: none result.out result.err hello.o123456 hello.e123456 Files named ``hello.o123456`` and ``hello.e123456`` record the contents of standard output and standard error, respectively. In this example, these files should be empty because they are redirected to ``result.out`` and ``result.err`` respectively. .. attention:: When running a program that outputs large amounts of calculation results to standard output or standard error, be sure to redirect the output to a file. Unredirected output is stored in the PBS temporary file storage area, which may cause storage space exhaustion and adversely affect other users' job executions. Therefore, if this precaution is not observed, the job may be forcibly terminated. Let's check the output results. If you can see the output like below, the program has run successfully.: .. code-block:: none $ cat result.out Hello world! If the output is incorrect or if no output is produced, please check whether an error message is output to the standard error output. .. code-block:: none $ cat result.err This concludes the explanation of how to execute calculations on MASAMUNE-II. For more detailed instructions, please refer to the following references: References ---------- * :doc:`/job/exe_job` * :doc:`/compiler_lib/compiler_lib` * :doc:`/app/how_to_use_app`