diff --git a/mpp/include/mpp_util.inc b/mpp/include/mpp_util.inc index 0dcb5adbd..091d06c5f 100644 --- a/mpp/include/mpp_util.inc +++ b/mpp/include/mpp_util.inc @@ -136,6 +136,19 @@ end if end subroutine mpp_init_warninglog + !> @brief This function returns unit number for the warning log + !! if on the root pe, otherwise returns the etc_unit value (usually /dev/null) + function warnlog() + integer :: warnlog + if(.not. module_is_initialized) call mpp_error(FATAL, "mpp_mod: warnlog cannot be called before mpp_init") + if(root_pe .eq. pe) then + warnlog = warn_unit + else + warnlog = etc_unit + endif + return + end function warnlog + !##################################################################### subroutine mpp_set_warn_level(flag) integer, intent(in) :: flag diff --git a/mpp/mpp.F90 b/mpp/mpp.F90 index 15aaa60cb..078c99b95 100644 --- a/mpp/mpp.F90 +++ b/mpp/mpp.F90 @@ -202,7 +202,7 @@ module mpp_mod public :: mpp_init_test_read_namelist, mpp_init_test_etc_unit, mpp_init_test_requests_allocated !--- public interface from mpp_util.h ------------------------------ - public :: stdin, stdout, stderr, stdlog, lowercase, uppercase, mpp_error, mpp_error_state + public :: stdin, stdout, stderr, stdlog, warnlog, lowercase, uppercase, mpp_error, mpp_error_state public :: mpp_set_warn_level, mpp_sync, mpp_sync_self, mpp_pe public :: mpp_npes, mpp_root_pe, mpp_set_root_pe, mpp_declare_pelist public :: mpp_get_current_pelist, mpp_set_current_pelist, mpp_get_current_pelist_name diff --git a/test_fms/mpp/test_stdlog.sh b/test_fms/mpp/test_stdlog.sh index f4471e044..109f74d2c 100755 --- a/test_fms/mpp/test_stdlog.sh +++ b/test_fms/mpp/test_stdlog.sh @@ -43,6 +43,10 @@ sed -i 's/1/2/' input.nml test_expect_failure "test stdlog and stdwarn with fatal output" ' mpirun -n 2 ../test_stdlog ' +# sync the filesystem and sleep for a sec so the slower systems(CI) +# can mv and read the output from the previous test +sync +sleep 1 # move file so we don't overwrite mv warnfile.000000.out warnfile.000000.out.old sed -i 's/2/3/' input.nml