-
Notifications
You must be signed in to change notification settings - Fork 143
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
Modern_diag_manager:: 0 days freq, mix_snapshot_average_fields deprecation #1500
Merged
+377
−29
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f1a35ea
implement the 0days freq capability in the modern diag manager
uramirez8707 04017b3
remove unwanted change
uramirez8707 eafee57
move and fix the logic that determines if a file has fields that are …
uramirez8707 8f4c771
Fix line count limit
uramirez8707 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Loading status checks…
implement the 0days freq capability in the modern diag manager
commit f1a35eab17a0d35cc8991e93accf8ecb302fe99c
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
!*********************************************************************** | ||
!* 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/>. | ||
!*********************************************************************** | ||
|
||
!> @brief This programs tests diag manager when the file frequency is set to 0 days | ||
program test_output_every_freq | ||
|
||
use fms_mod, only: fms_init, fms_end, string | ||
use diag_manager_mod, only: diag_axis_init, send_data, diag_send_complete, diag_manager_set_time_end, & | ||
register_diag_field, diag_manager_init, diag_manager_end | ||
use time_manager_mod, only: time_type, operator(+), JULIAN, set_time, set_calendar_type, set_date | ||
use mpp_mod, only: FATAL, mpp_error | ||
use fms2_io_mod, only: FmsNetcdfFile_t, open_file, close_file, read_data, get_dimension_size | ||
|
||
implicit none | ||
|
||
integer :: id_var0, id_var1 !< diag field ids | ||
logical :: used !< for send_data calls | ||
integer :: ntimes = 48 !< Number of time steps | ||
real :: vdata !< Buffer to store the data | ||
type(time_type) :: Time !< "Model" time | ||
type(time_type) :: Time_step !< Time step for the "simulation" | ||
integer :: i !< For do loops | ||
|
||
call fms_init | ||
call set_calendar_type(JULIAN) | ||
call diag_manager_init | ||
|
||
Time = set_date(2,1,1,0,0,0) | ||
Time_step = set_time (3600,0) !< 1 hour | ||
call diag_manager_set_time_end(set_date(2,1,3,0,0,0)) | ||
|
||
id_var0 = register_diag_field ('ocn_mod', 'var0', Time) | ||
id_var1 = register_diag_field ('ocn_mod', 'var1', Time) | ||
|
||
do i = 1, ntimes | ||
Time = Time + Time_step | ||
vdata = real(i) | ||
|
||
used = send_data(id_var0, vdata, Time) !< Sending data every hour! | ||
if (mod(i,2) .eq. 0) used = send_data(id_var1, vdata, Time) !< Sending data every two hours! | ||
|
||
call diag_send_complete(Time_step) | ||
enddo | ||
|
||
call diag_manager_end(Time) | ||
|
||
call check_output() | ||
call fms_end | ||
|
||
contains | ||
|
||
!< @brief Check the diag manager output | ||
subroutine check_output() | ||
type(FmsNetcdfFile_t) :: fileobj !< Fms2io fileobj | ||
integer :: var_size !< Size of the variable reading | ||
real, allocatable :: var_data(:) !< Buffer to read variable data to | ||
integer :: j !< For looping | ||
|
||
if (.not. open_file(fileobj, "test_0days.nc", "read")) & | ||
call mpp_error(FATAL, "Error opening file:test_0days.nc to read") | ||
|
||
call get_dimension_size(fileobj, "time", var_size) | ||
if (var_size .ne. 48) call mpp_error(FATAL, "The dimension of time in the file:test_0days is not the "//& | ||
"correct size!") | ||
allocate(var_data(var_size)) | ||
var_data = -999.99 | ||
|
||
call read_data(fileobj, "var0", var_data) | ||
do j = 1, var_size | ||
if (var_data(j) .ne. real(j)) call mpp_error(FATAL, "The variable data for var1 at time level:"//& | ||
string(j)//" is not the correct value!") | ||
enddo | ||
|
||
call close_file(fileobj) | ||
end subroutine check_output | ||
end program test_output_every_freq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/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/>. | ||
#*********************************************************************** | ||
|
||
# Copyright (c) 2019-2020 Ed Hartnett, Seth Underwood | ||
|
||
# Set common test settings. | ||
. ../test-lib.sh | ||
|
||
if [ -z "${skipflag}" ]; then | ||
# create and enter directory for in/output files | ||
output_dir | ||
|
||
cat <<_EOF > diag_table.yaml | ||
title: test_diag_manager_01 | ||
base_date: 2 1 1 0 0 0 | ||
diag_files: | ||
- file_name: test_0days | ||
time_units: days | ||
unlimdim: time | ||
freq: 0 days | ||
varlist: | ||
- module: ocn_mod | ||
var_name: var0 | ||
reduction: none | ||
kind: r4 | ||
_EOF | ||
|
||
my_test_count=1 | ||
printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 0 \n/" | cat > input.nml | ||
test_expect_success "Running diag_manager with 0 days frequency (test $my_test_count)" ' | ||
mpirun -n 1 ../test_output_every_freq | ||
' | ||
|
||
cat <<_EOF > diag_table.yaml | ||
title: test_diag_manager_01 | ||
base_date: 2 1 1 0 0 0 | ||
diag_files: | ||
- file_name: test_0days | ||
time_units: days | ||
unlimdim: time | ||
freq: 0 days | ||
varlist: | ||
- module: ocn_mod | ||
var_name: var0 | ||
reduction: none | ||
kind: r4 | ||
- module: ocn_mod | ||
var_name: var1 | ||
reduction: none | ||
kind: r4 | ||
_EOF | ||
|
||
my_test_count=`expr $my_test_count + 1` | ||
test_expect_failure "Running diag_manager with 0 days frequency and variable are calling send data at different frequencies (test $my_test_count)" ' | ||
mpirun -n 1 ../test_output_every_freq | ||
' | ||
|
||
cat <<_EOF > diag_table.yaml | ||
title: test_diag_manager_01 | ||
base_date: 2 1 1 0 0 0 | ||
diag_files: | ||
- file_name: test_0days | ||
time_units: days | ||
unlimdim: time | ||
freq: 0 days | ||
varlist: | ||
- module: ocn_mod | ||
var_name: var0 | ||
reduction: average | ||
kind: r4 | ||
_EOF | ||
|
||
my_test_count=`expr $my_test_count + 1` | ||
test_expect_failure "Running diag_manager with 0 days frequency but using average reduction method (test $my_test_count)" ' | ||
mpirun -n 1 ../test_output_every_freq | ||
' | ||
|
||
cat <<_EOF > diag_table.yaml | ||
title: test_diag_manager_01 | ||
base_date: 2 1 1 0 0 0 | ||
diag_files: | ||
- file_name: test_0days | ||
time_units: days | ||
unlimdim: time | ||
freq: -1 days | ||
varlist: | ||
- module: ocn_mod | ||
var_name: var0 | ||
reduction: average | ||
kind: r4 | ||
_EOF | ||
|
||
my_test_count=`expr $my_test_count + 1` | ||
test_expect_failure "Running diag_manager with -1 days frequency but using average reduction method (test $my_test_count)" ' | ||
mpirun -n 1 ../test_output_every_freq | ||
' | ||
fi | ||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ahhh a double negative