From 49ae3b78f46d3c66713c19bfffe20f8cbb04645a Mon Sep 17 00:00:00 2001 From: Nancy Collins Date: Tue, 8 Feb 2022 13:45:13 -0700 Subject: [PATCH 1/5] fix formatting of NAG blocks which are commented in/out by fixsystem --- .../modules/utilities/mpi_utilities_mod.f90 | 77 +++++++++++-------- .../utilities/null_mpi_utilities_mod.f90 | 68 +++++++++------- .../mpi_utilities/tests/ftest_mpi.f90 | 7 +- 3 files changed, 90 insertions(+), 62 deletions(-) diff --git a/assimilation_code/modules/utilities/mpi_utilities_mod.f90 b/assimilation_code/modules/utilities/mpi_utilities_mod.f90 index 7710a096c4..2c4d215d65 100644 --- a/assimilation_code/modules/utilities/mpi_utilities_mod.f90 +++ b/assimilation_code/modules/utilities/mpi_utilities_mod.f90 @@ -31,11 +31,10 @@ module mpi_utilities_mod use types_mod, only : i8, r8, digits12 -use utilities_mod, only : error_handler, & - E_ERR, E_WARN, E_MSG, E_DBG, get_unit, close_file, & - set_output, set_tasknum, initialize_utilities, & - finalize_utilities, & - nmlfileunit, do_output, do_nml_file, do_nml_term, & +use utilities_mod, only : error_handler, E_ERR, E_WARN, E_MSG, & + set_output, set_tasknum, & + initialize_utilities, finalize_utilities, & + nmlfileunit, do_nml_file, do_nml_term, & find_namelist_in_file, check_namelist_read use time_manager_mod, only : time_type, get_time, set_time @@ -52,24 +51,40 @@ module mpi_utilities_mod use mpi -! the NAG compiler needs these special definitions enabled + +! We build on case-insensitive systems so we cannot reliably +! count on having the build system run the fortran preprocessor +! since the usual distinction is between bob.F90 and bob.f90 +! to decide what needs preprocessing. instead we utilize a +! script we provide called 'fixsystem' which looks for the +! special XXX_BLOCK_EDIT comment lines and comments the blocks +! in and out depending on the target compiler. + +! the NAG compiler needs these special definitions enabled. +! the #ifdef lines are only there in case someday we can use +! the fortran preprocessor. they need to stay commented out. ! !!NAG_BLOCK_EDIT START COMMENTED_OUT ! !#ifdef __NAG__ +! ! use F90_unix_proc, only : sleep, system, exit - !! block for NAG compiler - ! PURE SUBROUTINE SLEEP(SECONDS,SECLEFT) - ! INTEGER,INTENT(IN) :: SECONDS - ! INTEGER,OPTIONAL,INTENT(OUT) :: SECLEFT - ! - ! SUBROUTINE SYSTEM(STRING,STATUS,ERRNO) - ! CHARACTER*(*),INTENT(IN) :: STRING - ! INTEGER,OPTIONAL,INTENT(OUT) :: STATUS,ERRNO - ! - !!also used in exit_all outside this module - ! SUBROUTINE EXIT(STATUS) - ! INTEGER,OPTIONAL :: STATUS - !! end block +! +! !! NAG only needs the use statement above, but +! !! these are the calling sequences if you need +! !! to use these routines additional places in code. +! ! PURE SUBROUTINE SLEEP(SECONDS,SECLEFT) +! ! INTEGER,INTENT(IN) :: SECONDS +! ! INTEGER,OPTIONAL,INTENT(OUT) :: SECLEFT +! ! +! ! SUBROUTINE SYSTEM(STRING,STATUS,ERRNO) +! ! CHARACTER*(*),INTENT(IN) :: STRING +! ! INTEGER,OPTIONAL,INTENT(OUT) :: STATUS,ERRNO +! ! +! !!also used in exit_all outside this module +! ! SUBROUTINE EXIT(STATUS) +! ! INTEGER,OPTIONAL :: STATUS +! !! end block +! ! !#endif ! !!NAG_BLOCK_EDIT END COMMENTED_OUT @@ -86,18 +101,18 @@ module mpi_utilities_mod ! this directory. It is a sed script that comments in and out the interface ! block below. Please leave the BLOCK comment lines unchanged. -! !!SYSTEM_BLOCK_EDIT START COMMENTED_OUT -! !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) -! ! interface block for getting return code back from system() routine -! interface -! function system(string) -! character(len=*) :: string -! integer :: system -! end function system -! end interface -! ! end block -! !#endif -! !!SYSTEM_BLOCK_EDIT END COMMENTED_OUT + !!SYSTEM_BLOCK_EDIT START COMMENTED_IN + !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) + ! interface block for getting return code back from system() routine + interface + function system(string) + character(len=*) :: string + integer :: system + end function system + end interface + ! end block + !#endif + !!SYSTEM_BLOCK_EDIT END COMMENTED_IN ! allow global sum to be computed for integers, r4, and r8s diff --git a/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 b/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 index 56ee2ba1bd..a13fa1f417 100644 --- a/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 +++ b/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 @@ -26,25 +26,35 @@ module mpi_utilities_mod initialize_utilities, finalize_utilities use time_manager_mod, only : time_type, set_time -! the NAG compiler needs these special definitions enabled +! We build on case-insensitive systems so we cannot reliably +! count on having the build system run the fortran preprocessor +! since the usual distinction is between bob.F90 and bob.f90 +! to decide what needs preprocessing. instead we utilize a +! script we provide called 'fixsystem' which looks for the +! special XXX_BLOCK_EDIT comment lines and comments the blocks +! in and out depending on the target compiler. + +! the NAG compiler needs these special definitions enabled. +! the #ifdef lines are only there in case someday we can use +! the fortran preprocessor. they need to stay commented out. ! !!NAG_BLOCK_EDIT START COMMENTED_OUT -!#ifdef __NAG__ - !use F90_unix_proc, only : sleep, system, exit - !! block for NAG compiler - ! PURE SUBROUTINE SLEEP(SECONDS,SECLEFT) - ! INTEGER,INTENT(IN) :: SECONDS - ! INTEGER,OPTIONAL,INTENT(OUT) :: SECLEFT - ! - ! SUBROUTINE SYSTEM(STRING,STATUS,ERRNO) - ! CHARACTER*(*),INTENT(IN) :: STRING - ! INTEGER,OPTIONAL,INTENT(OUT) :: STATUS,ERRNO - ! - !!also used in exit_all outside this module - ! SUBROUTINE EXIT(STATUS) - ! INTEGER,OPTIONAL :: STATUS - !! end block -!#endif +! !#ifdef __NAG__ +! use F90_unix_proc, only : sleep, system, exit +! ! block for NAG compiler +! ! PURE SUBROUTINE SLEEP(SECONDS,SECLEFT) +! ! INTEGER,INTENT(IN) :: SECONDS +! ! INTEGER,OPTIONAL,INTENT(OUT) :: SECLEFT +! ! +! ! SUBROUTINE SYSTEM(STRING,STATUS,ERRNO) +! ! CHARACTER*(*),INTENT(IN) :: STRING +! ! INTEGER,OPTIONAL,INTENT(OUT) :: STATUS,ERRNO +! ! +! ! ! also used in exit_all outside this module +! ! SUBROUTINE EXIT(STATUS) +! ! INTEGER,OPTIONAL :: STATUS +! ! end block +! ! #endif ! !!NAG_BLOCK_EDIT END COMMENTED_OUT @@ -59,18 +69,18 @@ module mpi_utilities_mod ! this directory. It is a sed script that comments in and out the interface ! block below. Please leave the BLOCK comment lines unchanged. -! !!SYSTEM_BLOCK_EDIT START COMMENTED_OUT -! !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) -! ! interface block for getting return code back from system() routine -! interface -! function system(string) -! character(len=*) :: string -! integer :: system -! end function system -! end interface -! ! end block -! !#endif -! !!SYSTEM_BLOCK_EDIT END COMMENTED_OUT + !!SYSTEM_BLOCK_EDIT START COMMENTED_IN + !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) + ! interface block for getting return code back from system() routine + interface + function system(string) + character(len=*) :: string + integer :: system + end function system + end interface + ! end block + !#endif + !!SYSTEM_BLOCK_EDIT END COMMENTED_IN ! allow global sum to be computed for integers, r4, and r8s diff --git a/developer_tests/mpi_utilities/tests/ftest_mpi.f90 b/developer_tests/mpi_utilities/tests/ftest_mpi.f90 index 2874599822..bb4646325d 100644 --- a/developer_tests/mpi_utilities/tests/ftest_mpi.f90 +++ b/developer_tests/mpi_utilities/tests/ftest_mpi.f90 @@ -16,13 +16,15 @@ program ftest_mpi use mpi -! the NAG compiler needs these special definitions enabled +! the NAG compiler needs these special definitions enabled. ! the 'fixsystem' script in the assimilation_code/modules/utilities dir ! should fix this for you. please leave the BLOCK comment lines unchanged. ! !!NAG_BLOCK_EDIT START COMMENTED_OUT ! !#ifdef __NAG__ +! ! use F90_unix_proc, only : sleep, system, exit +! ! !! these are the calling sequences for NAG compiler ! ! PURE SUBROUTINE SLEEP(SECONDS,SECLEFT) ! ! INTEGER,INTENT(IN) :: SECONDS @@ -36,7 +38,8 @@ program ftest_mpi ! ! SUBROUTINE EXIT(STATUS) ! ! INTEGER,OPTIONAL :: STATUS ! !! end block -! !#endif +! +! !#endif ! !!NAG_BLOCK_EDIT END COMMENTED_OUT implicit none From 90e8f2a0bfa326ccbf562c151c722e5408fd4841 Mon Sep 17 00:00:00 2001 From: Nancy Collins Date: Tue, 8 Feb 2022 13:59:12 -0700 Subject: [PATCH 2/5] make the two file versions more alike. --- .../modules/utilities/mpi_utilities_mod.f90 | 2 +- .../modules/utilities/null_mpi_utilities_mod.f90 | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/assimilation_code/modules/utilities/mpi_utilities_mod.f90 b/assimilation_code/modules/utilities/mpi_utilities_mod.f90 index d04d062e45..0f90677fa9 100644 --- a/assimilation_code/modules/utilities/mpi_utilities_mod.f90 +++ b/assimilation_code/modules/utilities/mpi_utilities_mod.f90 @@ -55,7 +55,7 @@ module mpi_utilities_mod ! We build on case-insensitive systems so we cannot reliably ! count on having the build system run the fortran preprocessor -! since the usual distinction is between bob.F90 and bob.f90 +! since the usual distinction is between bob.F90 and bob.f90 ! to decide what needs preprocessing. instead we utilize a ! script we provide called 'fixsystem' which looks for the ! special XXX_BLOCK_EDIT comment lines and comments the blocks diff --git a/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 b/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 index a13fa1f417..db466cfed8 100644 --- a/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 +++ b/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 @@ -40,21 +40,26 @@ module mpi_utilities_mod ! !!NAG_BLOCK_EDIT START COMMENTED_OUT ! !#ifdef __NAG__ +! ! use F90_unix_proc, only : sleep, system, exit -! ! block for NAG compiler +! +! !! NAG only needs the use statement above, but +! !! these are the calling sequences if you need +! !! to use these routines additional places in code. ! ! PURE SUBROUTINE SLEEP(SECONDS,SECLEFT) ! ! INTEGER,INTENT(IN) :: SECONDS ! ! INTEGER,OPTIONAL,INTENT(OUT) :: SECLEFT -! ! +! ! ! ! SUBROUTINE SYSTEM(STRING,STATUS,ERRNO) ! ! CHARACTER*(*),INTENT(IN) :: STRING ! ! INTEGER,OPTIONAL,INTENT(OUT) :: STATUS,ERRNO ! ! -! ! ! also used in exit_all outside this module +! !!also used in exit_all outside this module ! ! SUBROUTINE EXIT(STATUS) ! ! INTEGER,OPTIONAL :: STATUS -! ! end block -! ! #endif +! !! end block +! +! !#endif ! !!NAG_BLOCK_EDIT END COMMENTED_OUT From c5679d833866a6f83ee08e2edad3890aac850c36 Mon Sep 17 00:00:00 2001 From: Nancy Collins Date: Tue, 8 Feb 2022 14:03:13 -0700 Subject: [PATCH 3/5] leave the defaults so that the code is right for building with gfortran --- .../modules/utilities/mpi_utilities_mod.f90 | 24 +++++++++---------- .../utilities/null_mpi_utilities_mod.f90 | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/assimilation_code/modules/utilities/mpi_utilities_mod.f90 b/assimilation_code/modules/utilities/mpi_utilities_mod.f90 index 0f90677fa9..90797018e8 100644 --- a/assimilation_code/modules/utilities/mpi_utilities_mod.f90 +++ b/assimilation_code/modules/utilities/mpi_utilities_mod.f90 @@ -102,18 +102,18 @@ module mpi_utilities_mod ! this directory. It is a sed script that comments in and out the interface ! block below. Please leave the BLOCK comment lines unchanged. - !!SYSTEM_BLOCK_EDIT START COMMENTED_IN - !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) - ! interface block for getting return code back from system() routine - interface - function system(string) - character(len=*) :: string - integer :: system - end function system - end interface - ! end block - !#endif - !!SYSTEM_BLOCK_EDIT END COMMENTED_IN +! !!SYSTEM_BLOCK_EDIT START COMMENTED_OUT +! !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) +! ! interface block for getting return code back from system() routine +! interface +! function system(string) +! character(len=*) :: string +! integer :: system +! end function system +! end interface +! ! end block +! !#endif +! !!SYSTEM_BLOCK_EDIT END COMMENTED_OUT ! allow global sum to be computed for integers, r4, and r8s diff --git a/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 b/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 index db466cfed8..c4cdbfd5d3 100644 --- a/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 +++ b/assimilation_code/modules/utilities/null_mpi_utilities_mod.f90 @@ -74,18 +74,18 @@ module mpi_utilities_mod ! this directory. It is a sed script that comments in and out the interface ! block below. Please leave the BLOCK comment lines unchanged. - !!SYSTEM_BLOCK_EDIT START COMMENTED_IN - !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) - ! interface block for getting return code back from system() routine - interface - function system(string) - character(len=*) :: string - integer :: system - end function system - end interface - ! end block - !#endif - !!SYSTEM_BLOCK_EDIT END COMMENTED_IN +! !!SYSTEM_BLOCK_EDIT START COMMENTED_OUT +! !#if .not. defined (__GFORTRAN__) .and. .not. defined(__NAG__) +! ! interface block for getting return code back from system() routine +! interface +! function system(string) +! character(len=*) :: string +! integer :: system +! end function system +! end interface +! ! end block +! !#endif +! !!SYSTEM_BLOCK_EDIT END COMMENTED_OUT ! allow global sum to be computed for integers, r4, and r8s From 53454fd2f03a0e228c8508f9c3c84b9af9ec1eb3 Mon Sep 17 00:00:00 2001 From: Nancy Collins Date: Tue, 8 Feb 2022 14:34:52 -0700 Subject: [PATCH 4/5] NAG insists on a field width for X formatting --- assimilation_code/modules/utilities/ensemble_manager_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assimilation_code/modules/utilities/ensemble_manager_mod.f90 b/assimilation_code/modules/utilities/ensemble_manager_mod.f90 index f4a97e8c57..e9030690ee 100644 --- a/assimilation_code/modules/utilities/ensemble_manager_mod.f90 +++ b/assimilation_code/modules/utilities/ensemble_manager_mod.f90 @@ -718,7 +718,7 @@ subroutine set_up_ens_distribution(ens_handle) per_pe = ens_handle%num_vars / num_pes if (per_pe >= (huge(i)-100) ) then suggest_pes = ( ens_handle%num_vars / (huge(i)) ) * 2 - write(msgstring, '(A,I5,X,A)') & + write(msgstring, '(A,I5,1X,A)') & 'not enough MPI tasks for the model size, suggest at least ' , & suggest_pes, 'tasks' call error_handler(E_ERR, 'set_up_ens_distribution', msgstring, source) From c46c43f8b086f11c553addb5eada245c070023a1 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 11 Feb 2022 15:10:18 -0700 Subject: [PATCH 5/5] changelog and bump version for release --- CHANGELOG.rst | 4 ++++ conf.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5756765af8..1ab8496682 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,10 @@ individual files. The changes are now listed with the most recent at the top. +**February 11 2022 :: Bug-fix for nag compiler. Tag v9.13.2** + +- Bug-fix for fixsystem preprocessing for NAG compiler + **February 7 2022 :: CM1 and 3D Cartesian location_mod updates. Tag v9.13.1** *Contributed by Jon Labriola* diff --git a/conf.py b/conf.py index 337c1669a5..9a89d54442 100644 --- a/conf.py +++ b/conf.py @@ -21,7 +21,7 @@ author = 'Data Assimilation Research Section' # The full version, including alpha/beta/rc tags -release = '9.13.1' +release = '9.13.2' master_doc = 'README' # -- General configuration ---------------------------------------------------