Skip to content

Commit

Permalink
Merge branch 'nag-workflow' into 'develop'
Browse files Browse the repository at this point in the history
Add support for the NAG Fortran compiler v6.2

See merge request mhm/mhm!32
  • Loading branch information
MuellerSeb committed Apr 24, 2020
2 parents 3792d3f + eaeede3 commit bc17636
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 6 deletions.
69 changes: 69 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ show-env-vars:
script:
- echo -e "${SEP}\n${S00}$(date)\n${SEP}\n${S01}\n${S02}\n${S03}\n${S04}\n${SEP}\n${S05}${GIT_CLONE_PATH}\n${S06}\n${SEP}"

cmake-nag62:
stage: cmake
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME
script:
- source moduleLoadScripts/eve.nag62
- source CI-scripts/compile
- source CI-scripts/compile_debug
artifacts:
paths:
- mhm
- mhm_debug

cmake-gcc73:
stage: cmake
variables:
Expand Down Expand Up @@ -116,6 +129,27 @@ cmake-intel18MPI:
- mhm_mpi
- mhm_mpi_debug

valgrind-nag62:
when: always
stage: valgrind
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME
needs:
- job: cmake-nag62
artifacts: true
script:
- source moduleLoadScripts/eve.nag62
- module load Anaconda3
- source activate /global/apps/mhm_checks/mhm_env
- valgrind --version
- valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ./mhm_debug
# execute mem-use check
- valgrind --tool=massif --stacks=yes --time-unit=i --massif-out-file=massif.out.0 ./mhm_debug
- ms_print massif.out.0
artifacts:
paths:
- massif.out.0

valgrind-gcc73:
when: always
stage: valgrind
Expand Down Expand Up @@ -179,6 +213,41 @@ valgrind-intel18:
paths:
- massif.out.0

check-nag62:
when: always
stage: test
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME
needs:
- job: cmake-nag62
artifacts: true
script:
- source moduleLoadScripts/eve.nag62
- source CI-scripts/pre_check
- python -u run_mhm_checks.py -l logs -e ../mhm
artifacts:
when: always
paths:
- check/logs/

check-nag62DEBUG:
when: always
stage: test
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME
needs:
- job: cmake-nag62
artifacts: true
script:
- source moduleLoadScripts/eve.nag62
- source CI-scripts/pre_check
# skip cases with optimization due to overflow in the random-number-generator (NAG uses -ieee=stop in DEBUG)
- python -u run_mhm_checks.py -l logs -e ../mhm_debug -s case_03 case_06 case_07 case_08 case_11
artifacts:
when: always
paths:
- check/logs/

check-gcc73:
when: always
stage: test
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ function(cpp_definitions defName defCMakeName value cacheString)
endif()
endfunction()

# add pre-processor -fpp for NAG
CHECK_Fortran_COMPILER_FLAG("-fpp" FPP_FLAG)
# if the flag exists, we add it to the compilation flags
if (FPP_FLAG)
set(ADDITIONAL_GCC_FLAGS "-fpp")
endif()

# Add definitions. These should later be set via the cache line file and only
# have a default value here. These part only concerns user build definitions like MRM2MHM
#add_definitions(-DMRM2MHM=.true.)
Expand Down Expand Up @@ -131,6 +138,11 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -warn all -g -debug -traceback -fp-stack-check -O0 -debug -check all")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -O3 -qoverride-limits")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -colour -unsharedf95 -ideclient")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -g -nan -O0 -C=all -strict95 -ieee=stop")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -O4 -ieee=full")
endif()
message(STATUS "the following debug flags will be used: ${CMAKE_Fortran_FLAGS_DEBUG}")
# Usually that works fine, except, one is on a module system and tries to execute the executable
# in the end without having the modules loaded. A workaround is provided using the variable
Expand Down
4 changes: 3 additions & 1 deletion check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A summary for all cases is given at the end.

## Usage

python run_mhm_checks.py [-h] [-e EXE [EXE ...]] [-v] [-l LOG_PATH] [-m MPI_NOP] [-t OPENMP_THREADS]
python run_mhm_checks.py [-h] [-e EXE [EXE ...]] [-v] [-l LOG_PATH] [-m MPI_NOP] [-t OPENMP_THREADS] [-s [SKIP [SKIP ...]]]

Run the mhm check cases with a given mhm executable.

Expand All @@ -26,6 +26,8 @@ Run the mhm check cases with a given mhm executable.
-t OPENMP_THREADS, --threads OPENMP_THREADS
Number of threads for openMP. No mpi allowed!
(default: 0)
-s [SKIP [SKIP ...]], --skip [SKIP [SKIP ...]]
skip cases (case_01 case_03 ..) (default: [])

## Examples
Run mhm from parent directory in verbosity mode with mpi on 4 processes:
Expand Down
25 changes: 20 additions & 5 deletions check/run_mhm_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
MHM_EXE = ["../mhm"]
# case 5 and 7 don't work with MPI. case 4 has a bug working with ifort+debug
SKIP_CASES_MPI = ["case_04", "case_05", "case_07"]
SKIP = []


# ARGUMENT PARSER #############################################################
Expand Down Expand Up @@ -144,13 +145,23 @@ def parse_args():
dest="openmp_threads",
help="Number of threads for openMP. No mpi allowed! (default: 0)",
)
parser.add_argument(
"-s",
"--skip",
action="store",
nargs="*",
default=SKIP,
dest="skip",
help="skip cases (case_01 case_03 ..) (default: {})".format(SKIP),
)
args = parser.parse_args()
return (
args.exe,
args.verbose,
args.log_path,
args.mpi_nop,
args.openmp_threads,
args.skip,
)


Expand Down Expand Up @@ -448,9 +459,10 @@ def run_model(
child.expect(pexpect.EOF)
if sys.platform != "win32":
child.close()
# close the output stream
exitstatus = child.exitstatus
else:
exitstatus = child.wait()
out.close()
exitstatus = child.exitstatus
exit_ok = exitstatus == 0
# check the last 4 lines of the log-file for "mHM: Finished!"
with open(log) as log_f:
Expand All @@ -471,7 +483,7 @@ def run_model(

if __name__ == "__main__":
# get args
exe_list, print_log, log_path, mpi_nop, openmp_threads = parse_args()
exe_list, print_log, log_path, mpi_nop, openmp_threads, skip = parse_args()
# checking path
cases_path = os.path.dirname(os.path.realpath(__file__))
# get all cases folders (in the cases_path)
Expand All @@ -483,6 +495,9 @@ def run_model(
final_result = True
final_exe_results = {}
exe_case_results = {}
# skip some cases for mpi
if int(mpi_nop) > 0:
skip += SKIP_CASES_MPI
# iterate of all mhm exe-s given
for exe in exe_list:
# dict for checking results
Expand All @@ -505,8 +520,8 @@ def run_model(
for case in cases:
# base name of the case
case_base = os.path.basename(case)
# skip some cases for mpi
if int(mpi_nop) > 0 and case_base in SKIP_CASES_MPI:
# skip some cases
if case_base in skip:
print(sep_text("skip case: " + case_base, sep_n=60, tab_n=1))
continue
print(sep_text("checking case: " + case_base, sep_n=60, tab_n=1))
Expand Down
6 changes: 6 additions & 0 deletions moduleLoadScripts/eve.nag62
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module purge
module load NAGfor
module load netcdf-fortran
module load CMake
export FC=nagfor
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH":/usr/lib64"

0 comments on commit bc17636

Please sign in to comment.