From 2902a7cc5576cc3e5fdab96a14ff8ea3ee7b8ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=BCtt?= Date: Thu, 11 Jun 2020 11:38:35 +0200 Subject: [PATCH] Make sopt/popt aliases for ssmp/psmp with OMP_NUM_THREADS=1 --- Makefile | 11 ++++++++++- src/start/cp2k.F | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d82e6eceb7..c74b9dbfc0 100644 --- a/Makefile +++ b/Makefile @@ -126,9 +126,18 @@ $(EXE_NAMES) all toolversions extversions extclean libcp2k cp2k_shell exts $(EXT # stage 2: Store the version target in $(ONEVERSION), # Call make recursively with $(ORIG_TARGET) as target. -$(VERSION) : +$(filter-out sopt, popt, $(VERSION)) : @+$(MAKE) --no-print-directory -f $(MAKEFILE) $(ORIG_TARGET) ORIG_TARGET="" VERSION="" ONEVERSION=$@ +sopt: + @+echo "Version sopt is now an alias for ssmp with OMP_NUM_THREADS=1." + @+$(MAKE) --no-print-directory -f $(MAKEFILE) $(ORIG_TARGET) ORIG_TARGET="" VERSION="" ONEVERSION="ssmp" + cd $(EXEDIR); ln -sf cp2k.ssmp cp2k.sopt +popt: + @+echo "Version popt is now an alias for psmp with OMP_NUM_THREADS=1." + @+$(MAKE) --no-print-directory -f $(MAKEFILE) $(ORIG_TARGET) ORIG_TARGET="" VERSION="" ONEVERSION="psmp" + cd $(EXEDIR); ln -sf cp2k.psmp cp2k.popt + else # stage 3: Include arch-file, create dirs, and run makedep.py for given $(ONEVERSION). diff --git a/src/start/cp2k.F b/src/start/cp2k.F index e0e9d3bba1..39539cd472 100644 --- a/src/start/cp2k.F +++ b/src/start/cp2k.F @@ -39,6 +39,7 @@ ! ************************************************************************************************** PROGRAM cp2k + USE OMP_LIB, ONLY: omp_set_num_threads USE cp2k_info, ONLY: compile_revision,& cp2k_flags,& cp2k_version,& @@ -98,7 +99,7 @@ PROGRAM cp2k ALLOCATE (initial_variables(2, 1:0)) ! get command and strip path - CALL GET_COMMAND(command, status=ierr) + CALL GET_COMMAND_ARGUMENT(0, command, status=ierr) CPASSERT(ierr == 0) l = LEN_TRIM(command) DO i = l, 1, -1 @@ -116,6 +117,12 @@ PROGRAM cp2k command_line_error = .TRUE. END IF + ! check if binary was invoked as sopt or popt alias + l = LEN_TRIM(command) + IF (command(l - 4:l) == ".sopt" .OR. command(l - 4:l) == ".popt") THEN + CALL omp_set_num_threads(1) + ENDIF + i_arg = 0 arg_loop: DO WHILE (i_arg < COMMAND_ARGUMENT_COUNT()) i_arg = i_arg + 1