I'm working on installzation of oneapi in my pc with CentOS 7 system. After installed the components of oneapi, I want to setup the environment of oneapi by sourcing (in the terminal) the setvars.sh file
source /opt/intel/oneapi/setvars.sh intel64
the terminal echoes multiple lines of output as it should
:: initializing oneAPI environment ...
BASH version = 4.2.46(2)-release
:: dev-utilities -- latest
:: tbb -- latest
:: compiler -- latest
:: dpl -- latest
:: mkl -- latest
:: vtune -- latest
:: dpcpp-ct -- latest
:: mpi -- latest
:: clck -- latest
:: inspector -- latest
:: itac -- latest
:: oneAPI environment initialized ::
then I can find the location of the compilers like ifort through
which ifort
then it gives
/opt/intel/oneapi/compiler/2021.1-beta10/linux/bin/intel64/ifort
Here is my question,
instead of sourcing setvars.sh directly in the terminal, if I use a sh file like
#!/bin/bash
source /opt/intel/oneapi/setvars.sh intel64
and run the sh file with
bash hello_world.sh
then the outputs still arise as above which I believe can demonstrate that the source command in the sh file had been successfully executed. However, , this time, the environment variables are not probably setted, as which ifort
command gives
/usr/bin/which: no ifort in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/wuchen/.local/bin:/home/wuchen/bin)
I noticed this post Difference between sh and bash and changed the command in the sh file to
. /opt/intel/oneapi/setvars.sh intel64
But still it doesn't work. I wonder if my problem is due to the setvars.sh itself.