If I'm running C++ code on a cluster, is it possible to use the value of OMP_NUM_THREADS in my program? For example, suppose I have two .cpp files main.cpp and func.cpp, where func.cpp is written in parallel using OpenMP. I want to be able to define the number of threads once (in the script below) and not have to define it again in func.cpp.
#!/bin/bash
#PBS -S /bin/bash
#PBS -l walltime=00:10:00
#PBS -l select=1:ncpus=4:mem=2gb
#PBS -q QName
#PBS -N Name
#PBS -o Results/output.txt
#PBS -e Results/error.txt
#PBS -m abe -M email@address
module purge
module load intel-compiler/11.1.073
export OMP_NUM_THREADS=4
cd $WORKDIR
./myprog