-
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
Conversation
mpp/include/mpp_util.inc
Outdated
! <FUNCTION NAME="mpp_init_logfile"> | ||
! <OVERVIEW> | ||
! Initialize the logfile. | ||
! </OVERVIEW> | ||
! <DESCRIPTION> | ||
! This function re-initializes the log files of the PEs. Re-initialization | ||
! means replacing if it already exists. It does not make new files if they don't | ||
! already exist. Only log files with names of format "<header>.pe_number.out", | ||
! where pe_number is the digit integer represeting the PE number, such as 000000 for the | ||
! root PE, 000001 for the next PE, etch. The <header> is the config file name prefix - | ||
! a module global normally set elsewhere, and frequetly is the integer simulation | ||
! timedate (e.g. 19480101). | ||
! </DESCRIPTION> | ||
! </FUNCTION> | ||
|
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!
!! @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 comment
The 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 comment
The 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.
mpp/mpp.F90
Outdated
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think its removed now!
mpp/mpp.F90
Outdated
!! TODO: | ||
public :: mpp_init_logfile |
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.
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 comment
The 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 comment
The 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 comment
The 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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you subtracting 1? Isn't there a mpp_init_test
level that you can directly use?
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 was subtracting one so that initialization stops before calling init_logfile. But given the
challenge of keeping init_logfile private, and upon inspection of the mpp_init routine, it occurs to me that I can solve both issues just by not subtracting one and not calling init_log_file.
Thanks.
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 am not sure and am requesting input. If the init level is set to "mpp_init_test_logfile_init".
then mpp_init() actually does more work AFTER calling mpp_initlogfile: it writes to the logifle. So technically, to test the interface, one should isolate the interface to whatever extent possible, not after what it creates is used by another function.
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.
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).
my_mpp_init_level = mpp_init_test_logfile_init - 1 | ||
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 comment
The 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 comment
The 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 comment
The 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.
…e comments as suggested by merge reviewers.
… test_mpp_initlog
…nit. This also caused changes to the made in the shell script and mpp.F90 (mpp_init_logfile function was removed from the public interface, i.e. back to original setting).
test included in #800 |
Description
This PR creates a unit test for the mpp interface mpp_init_logfile()
Fixes # (issue)
How Has This Been Tested?
On both the skylake server with intel compiler, and a home computer with gcc compiler,
libFMS and the unit test applications were compiled. The unite tests for subdirectory FMS/est_fms/mpp were run via "make check" from the command line. Additionally, the unit test brought in with this PR was made made to run as expected under various conditions and the side effects on the files were verified to be as expected.
Note and warning: Interface mpp_init_logfile() did not have any documentation. I made an interpretation on how its expected to run and commented the interface to contain that documentation. In order to test from an external program, I made the interface public. Let me know if this is an issue.
Checklist:
make distcheck
passes