Skip to content
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

Closed
wants to merge 6 commits into from
Closed

Adds test for mpp_init_logfile #510

wants to merge 6 commits into from

Conversation

ngs333
Copy link
Contributor

@ngs333 ngs333 commented Jul 10, 2020

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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@colingladueNOAA colingladueNOAA self-assigned this Jul 11, 2020
@colingladueNOAA colingladueNOAA added development enhancement Issue/PR for a modification that increases performance, improves syntax, or adds functionality. labels Jul 11, 2020
Comment on lines 152 to 166
! <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>

Copy link
Member

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

Copy link
Contributor Author

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>
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this whitespace

Copy link
Contributor Author

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
Comment on lines 233 to 234
!! TODO:
public :: mpp_init_logfile
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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()
Copy link
Member

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?

Copy link
Contributor Author

@ngs333 ngs333 Jul 15, 2020

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.)

Copy link
Contributor Author

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.

…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).
Base automatically changed from master to main March 8, 2021 16:41
@rem1776
Copy link
Contributor

rem1776 commented Aug 13, 2021

test included in #800

@rem1776 rem1776 closed this Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development enhancement Issue/PR for a modification that increases performance, improves syntax, or adds functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants