From c347de37ecdee686a61de7dc8a50b7fcd2f28f12 Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Thu, 15 Oct 2020 16:40:57 -0600 Subject: [PATCH 1/4] Add 'nag' build target in the top-level Makefile The 'nag' target is intended to be used with the NAG Fortran compiler and GNU C/C++ compilers. At present, however, no MPAS cores will compile with NAG due to errors in shared MPAS code. --- Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Makefile b/Makefile index baceb05cb7..da36ad0966 100644 --- a/Makefile +++ b/Makefile @@ -396,6 +396,31 @@ bluegene: "OPENMP = $(OPENMP)" \ "CPPFLAGS = $(MODEL_FORMULATION) -D_MPI" ) +nag: + ( $(MAKE) all \ + "FC_PARALLEL = mpifort" \ + "CC_PARALLEL = mpicc" \ + "CXX_PARALLEL = mpic++" \ + "FC_SERIAL = nagfor" \ + "CC_SERIAL = gcc" \ + "CXX_SERIAL = g++" \ + "FFLAGS_PROMOTION = -r8" \ + "FFLAGS_OPT = -free -mismatch -O3 -convert=big_ieee" \ + "CFLAGS_OPT = -O3" \ + "CXXFLAGS_OPT = -O3" \ + "LDFLAGS_OPT = -O3" \ + "FFLAGS_DEBUG = -free -mismatch -O0 -g -C -convert=big_ieee" \ + "CFLAGS_DEBUG = -O0 -g -Wall -pedantic" \ + "CXXFLAGS_DEBUG = -O0 -g -Wall -pedantic" \ + "LDFLAGS_DEBUG = -O0 -g -C" \ + "FFLAGS_OMP = -qsmp=omp" \ + "CFLAGS_OMP = -qsmp=omp" \ + "CORE = $(CORE)" \ + "DEBUG = $(DEBUG)" \ + "USE_PAPI = $(USE_PAPI)" \ + "OPENMP = $(OPENMP)" \ + "CPPFLAGS = $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE -DNAG_COMPILER" ) + CPPINCLUDES = FCINCLUDES = LIBS = From ee62ace85f9b44a86dfde94556f3a139b997025b Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Thu, 15 Oct 2020 16:44:17 -0600 Subject: [PATCH 2/4] Remove FFLAGS from definition of FC provided to esmf_time build The src/external/Makefile defined FC as "$(FC) $(FFLAGS)" when invoking a sub-make in the esmf_time_f90 directory. However, the Makefile in esmf_time_f90 explicitly adds FFLAGS to compilation commands, leading to a duplication of flags. The NAG compiler fails with the following: Option warning: -free option specified twice, continuing Option error: -convert= option specified twice This issue is resolved by defining FC as simply "$(FC)" when invoking the sub-make for the esmf_time target in src/external/Makefile. --- src/external/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external/Makefile b/src/external/Makefile index 4409d9c704..afb7533445 100644 --- a/src/external/Makefile +++ b/src/external/Makefile @@ -3,7 +3,7 @@ all: esmf_time ezxml-lib esmf_time: - ( cd esmf_time_f90; $(MAKE) FC="$(FC) $(FFLAGS)" CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS) -DHIDE_MPI" GEN_F90=$(GEN_F90) ) + ( cd esmf_time_f90; $(MAKE) FC="$(FC)" FFLAGS="$(FFLAGS)" CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS) -DHIDE_MPI" GEN_F90=$(GEN_F90) ) ezxml-lib: ( cd ezxml; $(MAKE) ) From 2b6e9d5e0481a9d89fd36b2144e5a05fb3d77838 Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Thu, 15 Oct 2020 16:57:24 -0600 Subject: [PATCH 3/4] Correct order of argument declarations in mpas_spline_interpolation The NAG compiler generates the following error when compiling the mpas_spline_interpolation module: NAG Fortran Compiler Release 7.0(Yurakucho) Build 7005 Error: mpas_spline_interpolation.F, line 118: Implicit type for N detected at N@) Error: mpas_spline_interpolation.F, line 123: Implicit type for NOUT detected at NOUT@) Error: mpas_spline_interpolation.F, line 127: Symbol N has already been implicitly typed detected at N@, Error: mpas_spline_interpolation.F, line 128: Symbol NOUT has already been implicitly typed detected at NOUT@ Error: mpas_spline_interpolation.F, line 362: Implicit type for N detected at N@) Error: mpas_spline_interpolation.F, line 366: Implicit type for NOUT detected at NOUT@) Error: mpas_spline_interpolation.F, line 370: Symbol N has already been implicitly typed detected at N@, Error: mpas_spline_interpolation.F, line 371: Symbol NOUT has already been implicitly typed detected at NOUT@ These errors are eliminated by moving the declaration of the dummy arguments N and NOUT above the declarations of the other dummy arguments that use them. --- src/operators/mpas_spline_interpolation.F | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/operators/mpas_spline_interpolation.F b/src/operators/mpas_spline_interpolation.F index f7fa682842..6d0d2ffa02 100644 --- a/src/operators/mpas_spline_interpolation.F +++ b/src/operators/mpas_spline_interpolation.F @@ -115,6 +115,10 @@ subroutine mpas_interpolate_cubic_spline( &!{{{ ! INPUT PARAMETERS: + integer, intent(in) :: & + n, &!< Input: number of nodes, input grid + nOut !< Input: number of nodes, output grid + real (kind=RKIND), dimension(n), intent(in) :: & x, &!< Input: node location, input grid y, &!< Input: interpolation variable, input grid @@ -123,10 +127,6 @@ subroutine mpas_interpolate_cubic_spline( &!{{{ real (kind=RKIND), dimension(nOut), intent(in) :: & xOut !< Input: node location, output grid - integer, intent(in) :: & - n, &!< Input: number of nodes, input grid - nOut !< Input: number of nodes, output grid - ! OUTPUT PARAMETERS: real (kind=RKIND), dimension(nOut), intent(out) :: & @@ -359,6 +359,10 @@ subroutine mpas_interpolate_linear( &!{{{ ! !INPUT PARAMETERS: + integer, intent(in) :: & + N, &!< Input: number of nodes, input grid + NOut !< Input: number of nodes, output grid + real (kind=RKIND), dimension(n), intent(in) :: & x, &!< Input: node location, input grid y !< Input: interpolation variable, input grid @@ -366,10 +370,6 @@ subroutine mpas_interpolate_linear( &!{{{ real (kind=RKIND), dimension(nOut), intent(in) :: & xOut !< Input: node location, output grid - integer, intent(in) :: & - N, &!< Input: number of nodes, input grid - NOut !< Input: number of nodes, output grid - ! !OUTPUT PARAMETERS: real (kind=RKIND), dimension(nOut), intent(out) :: & From b43584c42a2cca4b80faf2091e8c07b97ecfa1c2 Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Thu, 15 Oct 2020 19:27:10 -0600 Subject: [PATCH 4/4] For NAG only, don't rewind the namelist file before reading each namelist group When MPAS is built with the NAG compiler, reads of namelist groups after the first return a non-zero error code, which then causes MPAS to raise a critical error. For example, with the 'test' core, the following critical message is generated: Reading namelist from file namelist.test CRITICAL ERROR: Error while reading namelist record io. This commit modifies the gen_inc.c code so that in the generated namelist_defines.inc Fortran code the REWIND statement is commented-out if the code is being built with the NAG compiler. For example, the code to read the 'io' group in the 'test' core now looks like the following: if (dminfo % my_proc_id == IO_NODE) then ! Rewinding before each read leads to errors when the code is built with ! the NAG Fortran compiler. If building with NAG, be kind and don't rewind. #ifndef NAG_COMPILER rewind(unitNumber) #endif read(unitNumber, io, iostat=ierr) end if call mpas_dmpar_bcast_int(dminfo, ierr) --- src/tools/registry/gen_inc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tools/registry/gen_inc.c b/src/tools/registry/gen_inc.c index 90074576e5..c906e50aaa 100644 --- a/src/tools/registry/gen_inc.c +++ b/src/tools/registry/gen_inc.c @@ -645,7 +645,11 @@ int parse_namelist_records_from_registry(ezxml_t registry)/*{{{*/ } fortprintf(fd, " if (dminfo %% my_proc_id == IO_NODE) then\n"); + fortprintf(fd, "! Rewinding before each read leads to errors when the code is built with\n"); + fortprintf(fd, "! the NAG Fortran compiler. If building with NAG, be kind and don't rewind.\n"); + fortprintf(fd, "#ifndef NAG_COMPILER\n"); fortprintf(fd, " rewind(unitNumber)\n"); + fortprintf(fd, "#endif\n"); fortprintf(fd, " read(unitNumber, %s, iostat=ierr)\n", nmlrecname); fortprintf(fd, " end if\n");