@@ -1376,6 +1376,67 @@ def test_intel_toolchain(self):
13761376 for var in ['CFLAGS' , 'CXXFLAGS' , 'FCFLAGS' , 'FFLAGS' , 'F90FLAGS' ]:
13771377 self .assertTrue ('-openmp' in tc .get_variable (var ))
13781378
1379+ # with compiler-only toolchain the $MPI* variables are not defined
1380+ mpi_vars = ('MPICC' , 'MPICXX' , 'MPIF77' , 'MPIF90' , 'MPIFC' )
1381+
1382+ # make sure environment variables are undefined before preparing build environment
1383+ for var in mpi_vars :
1384+ if os .getenv (var ):
1385+ del os .environ [var ]
1386+
1387+ tc = self .get_toolchain ('intel-compilers' , version = '2021.4.0' )
1388+ tc .set_options ({})
1389+ tc .prepare ()
1390+
1391+ self .assertEqual (os .getenv ('CC' ), 'icc' )
1392+ self .assertEqual (os .getenv ('CXX' ), 'icpc' )
1393+ self .assertEqual (os .getenv ('F77' ), 'ifort' )
1394+ self .assertEqual (os .getenv ('F90' ), 'ifort' )
1395+ self .assertEqual (os .getenv ('FC' ), 'ifort' )
1396+
1397+ for var in mpi_vars :
1398+ self .assertEqual (os .getenv (var ), None )
1399+
1400+ def test_intel_toolchain_oneapi (self ):
1401+ """Test for opt-in to oneAPI with intel toolchain"""
1402+
1403+ # for recent versions of intel toolchain, we can opt in to using the new oneAPI compilers
1404+ self .setup_sandbox_for_intel_fftw (self .test_prefix , imklver = '2021.4.0' )
1405+ self .modtool .prepend_module_path (self .test_prefix )
1406+ tc = self .get_toolchain ('intel' , version = '2021b' )
1407+ tc .set_options ({})
1408+ tc .prepare ()
1409+
1410+ # default remains classic compilers for now
1411+ self .assertEqual (os .getenv ('CC' ), 'icc' )
1412+ self .assertEqual (os .getenv ('CXX' ), 'icpc' )
1413+ self .assertEqual (os .getenv ('F77' ), 'ifort' )
1414+ self .assertEqual (os .getenv ('F90' ), 'ifort' )
1415+ self .assertEqual (os .getenv ('FC' ), 'ifort' )
1416+
1417+ self .assertEqual (os .getenv ('MPICC' ), 'mpiicc' )
1418+ self .assertEqual (os .getenv ('MPICXX' ), 'mpiicpc' )
1419+ self .assertEqual (os .getenv ('MPIF77' ), 'mpiifort' )
1420+ self .assertEqual (os .getenv ('MPIF90' ), 'mpiifort' )
1421+ self .assertEqual (os .getenv ('MPIFC' ), 'mpiifort' )
1422+
1423+ self .modtool .purge ()
1424+ tc = self .get_toolchain ('intel' , version = '2021b' )
1425+ tc .set_options ({'oneapi' : True })
1426+ tc .prepare ()
1427+
1428+ self .assertEqual (os .getenv ('CC' ), 'icx' )
1429+ self .assertEqual (os .getenv ('CXX' ), 'icpx' )
1430+ self .assertEqual (os .getenv ('F77' ), 'ifx' )
1431+ self .assertEqual (os .getenv ('F90' ), 'ifx' )
1432+ self .assertEqual (os .getenv ('FC' ), 'ifx' )
1433+
1434+ self .assertEqual (os .getenv ('MPICC' ), 'mpiicc' )
1435+ self .assertEqual (os .getenv ('MPICXX' ), 'mpiicpc' )
1436+ self .assertEqual (os .getenv ('MPIF77' ), 'mpiifort' )
1437+ self .assertEqual (os .getenv ('MPIF90' ), 'mpiifort' )
1438+ self .assertEqual (os .getenv ('MPIFC' ), 'mpiifort' )
1439+
13791440 def test_toolchain_verification (self ):
13801441 """Test verification of toolchain definition."""
13811442 tc = self .get_toolchain ('foss' , version = '2018a' )
0 commit comments