-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds test for mpp_init_logfile #510
Changes from 1 commit
c50d06d
6990279
aecd519
b6af028
8e5c139
9d251f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,9 @@ module mpp_mod | |
public :: read_ascii_file, read_input_nml, mpp_clock_begin, mpp_clock_end | ||
public :: get_ascii_file_num_lines | ||
public :: mpp_record_time_start, mpp_record_time_end | ||
!! TODO: | ||
public :: mpp_init_logfile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you still working on this? Are you making a private routine public? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping to not make it public. Is there a better way to get access to mpp_init_logfile from the unit test app. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may remain a problem (with both pros and cons) see the issue below concerning mpp_init_test_logfile_init There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for bringing up the issue in the meeting. Fortunately for this test is a non-issue now. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its removed now! |
||
|
||
!--- public interface from mpp_comm.h ------------------------------ | ||
public :: mpp_chksum, mpp_max, mpp_min, mpp_sum, mpp_transmit, mpp_send, mpp_recv | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
!*********************************************************************** | ||
!* GNU Lesser General Public License | ||
!* | ||
!* This file is part of the GFDL Flexible Modeling System (FMS). | ||
!* | ||
!* FMS is free software: you can redistribute it and/or modify it under | ||
!* the terms of the GNU Lesser General Public License as published by | ||
!* the Free Software Foundation, either version 3 of the License, or (at | ||
!* your option) any later version. | ||
!* | ||
!* FMS is distributed in the hope that it will be useful, but WITHOUT | ||
!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
!* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
!* for more details. | ||
!* | ||
!* You should have received a copy of the GNU Lesser General Public | ||
!* License along with FMS. If not, see <http://www.gnu.org/licenses/>. | ||
!*********************************************************************** | ||
|
||
!> @file | ||
!! @brief Tests the mpp_init_logfile interface | ||
!! @author Miguel Zuniga | ||
!! @email gfdl.climate.model.info@noaa.gov | ||
|
||
program test_mpp_init_logfile | ||
#include <fms_platform.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use platforms_mod instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thats what I get for copy and pasting. I dont even use it. |
||
|
||
use mpp_mod, only : mpp_init, mpp_init_logfile | ||
use mpp_mod, only : mpp_init_test_logfile_init | ||
|
||
IMPLICIT NONE | ||
|
||
integer :: my_mpp_init_level | ||
integer :: err_no | ||
|
||
!Initialize mpp but have mpp_init() exit before log files are initalized. | ||
my_mpp_init_level = mpp_init_test_logfile_init - 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you subtracting 1? Isn't there a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was subtracting one so that initialization stops before calling init_logfile. But given the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure and am requesting input. If the init level is set to "mpp_init_test_logfile_init". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its changed so it not subtracting now. Corresponding changed in the shell script were made. Mpp_init_logfile was removed from public (i.e. put back to original form). |
||
call mpp_init( test_level = my_mpp_init_level ) | ||
|
||
call mpp_init_logfile() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is anything actually tested, or is this routine just called? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of the test work is actually done is done by the shell command calling this the fortran test program. The shell program creates file and checks the effects of the called app. Like many I/o routines, mpp_init_logfile() is merely a side_effect routine. So what the shell comman does is test that it makes it side effects correctly and also that it doesn't make additional side effects that it could potentially make. This means, checking the files that it should replace, and checking for the lack of existence of files that it should not make but that whose names are iterated over in the do loop of the routine. If you look at the shell command that calls it, you should be able to see that it returns a '1' when those conditions are not satisfied. (PS I checked that the CI summary shows "FAILED" is the shell command returns 1, and success if it returns 0.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the comments in both the Fortran test program and the corresponding shell script. It better explains what they are doing together. |
||
!! With the unifinished initialization, mpp_exit() is causing crash. Use MPI_FINALIZE: | ||
call MPI_FINALIZE(err_no) | ||
|
||
end program test_mpp_init_logfile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/sh | ||
|
||
#*********************************************************************** | ||
# GNU Lesser General Public License | ||
# | ||
# This file is part of the GFDL Flexible Modeling System (FMS). | ||
# | ||
# FMS is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or (at | ||
# your option) any later version. | ||
# | ||
# FMS is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with FMS. If not, see <http://www.gnu.org/licenses/>. | ||
#*********************************************************************** | ||
|
||
# This is part of the GFDL FMS package. This is a shell script to | ||
# execute tests in the test_fms/mpp directory. | ||
|
||
# Set common test settings. | ||
. ../test_common.sh | ||
|
||
skip_test="no" | ||
|
||
echo "Calling test_mp_init_logfile" | ||
|
||
# Get the number of available CPUs on the system | ||
if [ $(command -v nproc) ] | ||
then | ||
# Looks like a linux system | ||
nProc=$(nproc) | ||
elif [ $(command -v sysctl) ] | ||
then | ||
# Looks like a Mac OS X system | ||
nProc=$(sysctl -n hw.physicalcpu) | ||
else | ||
nProc=-1 | ||
fi | ||
|
||
# Do we need to oversubscribe | ||
if [ ${nProc} -lt 0 ] | ||
then | ||
# Couldn't get the number of CPUs, skip the test. | ||
skip_test="skip" | ||
elif [ $nProc -lt 4 ] | ||
then | ||
# Need to oversubscribe the MPI | ||
run_test test_mpp_init_logfile 4 $skip_test "true" | ||
fi | ||
|
||
fprefix="logfile.00000" | ||
file0="${fprefix}""0.out" | ||
file1="${fprefix}""1.out" | ||
file2="${fprefix}""2.out" | ||
file3="${fprefix}""3.out" | ||
|
||
#Create two log files, each with some content. | ||
#echo "test_log_line" > logfile.000000.out | ||
#echo "test_log_line" > logfile.000002.out | ||
echo "test_log_line" > ${file0} | ||
echo "test_log_line" > ${file2} | ||
#Make sure other possible log files are not in the system. | ||
if test -f ${file1}; then | ||
rm ${file1} | ||
fi | ||
if test -f ${file3}; then | ||
rm ${file3} | ||
fi | ||
|
||
#Have mpp re-initialize the two log files created above: | ||
run_test test_mpp_init_logfile 4 $skip_test | ||
|
||
#Make sure the two "old" ones have been replaced and the | ||
#two possible new ones are not present. | ||
#TODO test number | ||
if [ $(wc -l < ${file0}) -ge 1 ] || [ $(wc -l < ${file2}) -ge 1 ] || | ||
[ -f ${file1} ] || [ -f ${file3} ] | ||
then | ||
echo "ERROR: Test ? was unsuccessful." | ||
exit 1 | ||
else | ||
echo "Test ? has passed" | ||
exit 0 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any added documentation should be in doxygen format. Please reformat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have reformatted now!