Originally Posted by sonu kumar
1) what is an environment variable ?
It is one of the ways to pass information from a process to a child process.
It is most often used to pass information from a shell (a terminal session or a script) to programs run from that shell.
Environment variables intended to be passed from a shell to a program are most often defined in advance in some initialization script such as .bashrc, and passed to every program run from the shell. Those that care about that environment variable use it, and those that don't ignore it.
But you can also define environment variable as part of the command for invoking a specific program, so those environment variables are defined for just that one run of that program.
Environment variables are often used to pass directory paths, but they can be used to pass many other kinds of information as well.
3) why and how to set it e.g after the insatallation of a intel compiler?
You should look in the documentation of the Intel compiler to see what environment variables it expects (I forget and anyway you might be using a different version of the Intel compiler than I use).
Then you need to think about how the Intel compiler will be used on your system.
Environment variables might be used to tell makefiles to use Intel instead of GCC and how to use it. They might be used to tell the Intel compiler which version of GCC to be compatible with and where to find that GCC's header files and/or other options to use as defaults when compiling.
We never make any version or configuration the Intel compiler the default compiler on any of our systems. The rare uses that we make of a default compiler are GCC. So we don't put any environment variables for Intel in .bashrc scripts or similar generic places associated with having installed a version of Intel.
Each of our software build processes specifies a specific tool set and there are a lot of environment variables associated with that tool set. The system we use instead of makefiles has a rather complex set of methods for causing all those environment variables to be defined at the point the compiler is run.
If you want to have multiple compilers (such as GCC and Intel) available, you probably want some kind of script that can be run to set all the environment variables you would want for building with the Intel compiler for a specific target type.