==================================================== Compiling and executing a sequential Fortran program ==================================================== Let's compile and execute the program :doc:`sommeVecVecSEQ_f90` which computes the sum of the two vectors A and B and the result is put in C. **Definition of the compiling environment**: Supposing that we want to use Cascade partition, we have to connect to one of the login nodes for this partition, for example *s92node01* (see :doc:`../../clusters_usage/login_nodes`). To use the software modules for this partition, we have to execute: .. code-block:: bash module use /applis/PSMN/debian11/Cascade/modules/all Now we can see available modules: .. code-block:: bash module avail Load a module for GNU compilers (GCC): .. code-block:: bash module load GCC/10.3.0 We can check the compiler version: .. code-block:: bash gfortran --version GNU Fortran (GCC) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. **Compilation** .. code-block:: bash gfortran -o SommeVecVecSEQ.exe SommeVecVecSEQ.f90 The binary file (executable) *SommeVecVecSEQ.f90.exe* has been generated. .. NOTE:: If you prefer to use the Intel compiler, then you have to load the *intel/2021a* module (instead of *GCC/10.3.0*) and launch the compilation with the *ifort* command (instead of *gfortran*) **Interactive execution (on login node):** .. code-block:: bash ./SommeVecVecSEQ.exe The result is displayed on the screen : .. code-block:: bash Les deux vecteurs : A = 1 2 3 4 5 6 7 8 9 10 B = 9 8 7 6 5 4 3 2 1 0 Le vecteur somme : C = 10 10 10 10 10 10 10 10 10 10 **Batch execution (by submitting to Cascade partition):** We use a submission :doc:`script_seq` to submit a job which will run the program on compute nodes. This submission script configures the environment and then run the binary (with its options, if any) on the compute node. .. code-block:: bash sbatch script.sh Submitted batch job 649 The job is waiting that asked ressources become availables and then it will be in *Running* state: .. code-block:: bash squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 649 Cascade SommeVec mylogin R 0:00 1 s92node02 As prescribed in submission script, the **standard output** is redirected to the file *SommeVecVecSEQ.649.s92node02.out* and the **standard error** is redirected to the file *SommeVecVecSEQ.649.s92node02.err* .. code-block:: bash -rw-r--r-- 1 mylogin cbp 0 25 janv. 09:21 SommeVecVecSEQ.649.s92node02.err -rw-r--r-- 1 mylogin cbp 419 25 janv. 09:21 SommeVecVecSEQ.649.s92node02.out When the job is finished, we can see the output file as following: .. code-block:: bash cat SommeVecVecSEQ.649.s92node02.out Les deux vecteurs : A = 1 2 3 4 5 6 7 8 9 10 B = 9 8 7 6 5 4 3 2 1 0 Le vecteur somme : C = 10 10 10 10 10 10 10 10 10 10