Skip to content

Commit

Permalink
add function to get warnlog unit number and try to fix ci fails
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1776 authored and rem1776 committed Jun 11, 2024
1 parent 1198935 commit 9217283
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions mpp/include/mpp_util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mpp/mpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test_fms/mpp/test_stdlog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9217283

Please sign in to comment.