-
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
modern diag manager: correctly adds the associated_files attribute #1451
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c289ea4
Fix the associated_files attribute and add a test
uramirez8707 9f03e22
remove the tabs
uramirez8707 ac4f33f
Ignore files that don't have any fields, to produce old behavior
uramirez8707 e2e1b58
Ignore files without variables
uramirez8707 a57a01d
Remove the limit to the number of subaxis
uramirez8707 d314da4
forgot to make MAX_SUBAXES public
uramirez8707 efbb9f0
Set up the current model time correctly, modify test to test multiple…
uramirez8707 6a8118c
Forgot a -Duse_yaml
uramirez8707 8738f23
init write_on_this_pe to false
uramirez8707 fb85ff5
Revert "init write_on_this_pe to false"
uramirez8707 3dac627
Run the diurnal test till the fourth month
uramirez8707 4469d24
minor documentation update
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
Fix the associated_files attribute and add a test
- Loading branch information
commit c289ea42fe6511556be18bfc98b2a73bc3208f39
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
!*********************************************************************** | ||
!* 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 program tests the diag_manager with fields with cell measures (area, volume) | ||
program test_cell_measures | ||
use fms_mod, only: fms_init, fms_end | ||
use diag_manager_mod, only: diag_axis_init, register_static_field, diag_send_complete, send_data | ||
use diag_manager_mod, only : register_diag_field | ||
use diag_manager_mod, only: diag_manager_init, diag_manager_end, diag_manager_set_time_end | ||
use time_manager_mod, only: time_type, set_calendar_type, set_date, JULIAN, set_time, OPERATOR(+) | ||
use mpp_mod, only: mpp_error, FATAL | ||
use fms2_io_mod | ||
use platform_mod, only: r4_kind | ||
|
||
implicit none | ||
|
||
type(time_type) :: Time !< Time of the simulation | ||
type(time_type) :: Time_step !< Time_step of the simulation | ||
integer :: i !< For looping | ||
integer :: id_axis1 !< Id of axis1 | ||
integer :: naxis1 !< Size of axis1 | ||
real(kind=r4_kind), allocatable :: axis1_data(:) !< Data for axis1 | ||
integer :: id_var1 !< Id of var1 | ||
real(kind=r4_kind), allocatable :: var1_data(:) !< Data for "var1" | ||
real(kind=r4_kind), allocatable :: area_data(:) !< Data for the "area" | ||
integer :: id_area !< Id of the "area" field | ||
logical :: used !< Used for send_data call | ||
|
||
naxis1 = 10 | ||
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) | ||
call diag_manager_set_time_end(set_date(2,1,2,0,0,0)) | ||
|
||
allocate(axis1_data(naxis1)) | ||
allocate(var1_data(naxis1)) | ||
allocate(area_data(naxis1)) | ||
do i = 1, naxis1 | ||
axis1_data = real(i, kind=r4_kind) | ||
area_data = real(i/100, kind=r4_kind) | ||
var1_data = real(i*10, kind=r4_kind) | ||
enddo | ||
|
||
id_axis1 = diag_axis_init('axis1', axis1_data, 'axis1', 'x') | ||
id_area = register_static_field ('fun_mod', 'area', (/id_axis1/)) | ||
id_var1 = register_diag_field ('fun_mod', 'var1', (/id_axis1/), init_time=Time, area=id_area) | ||
|
||
used = send_data(id_area, area_data) | ||
|
||
do i = 1, 6 | ||
Time = Time + Time_step | ||
call diag_send_complete(Time_step) | ||
used = send_data(id_var1, var1_data, Time) | ||
enddo | ||
call diag_manager_end(Time) | ||
|
||
call check_output() | ||
call fms_end() | ||
|
||
contains | ||
subroutine check_output() | ||
type(FmsNetcdfFile_t) :: fileobj !< FMS2io fileobj | ||
character(len=256) :: buffer !< Buffer to read stuff into | ||
|
||
! Check that the static_file.nc was created and it contains the area attribute | ||
if (.not. open_file(fileobj, "static_file.nc", "read")) & | ||
call mpp_error(FATAL, "static_file.nc was not created by the diag manager!") | ||
if (.not. variable_exists(fileobj, "area")) & | ||
call mpp_error(FATAL, "area is not in static_file.nc") | ||
call close_file(fileobj) | ||
|
||
! Check that file1.nc exists, that it contains the associated files attribute and it is correct, | ||
! that the var1 exists and it contains the cell_measures attributes | ||
if (.not. open_file(fileobj, "file1.nc", "read")) & | ||
call mpp_error(FATAL, "file1.nc was not created by the diag manager!") | ||
|
||
call get_global_attribute(fileobj, "associated_files", buffer) | ||
if (trim(buffer) .ne. "area: static_file.nc") & | ||
call mpp_error(FATAL, "The associated_files global attribute is not the expected result! "//trim(buffer)) | ||
|
||
call get_variable_attribute(fileobj, "var1", "cell_measures", buffer) | ||
if (trim(buffer) .ne. "area: area") & | ||
call mpp_error(FATAL, "The cell_measures attribute is not the expected result! "//trim(buffer)) | ||
call close_file(fileobj) | ||
end subroutine check_output | ||
end program |
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,64 @@ | ||
#!/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/>. | ||
#*********************************************************************** | ||
|
||
# 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 | ||
base_date: 2 1 1 0 0 0 | ||
|
||
diag_files: | ||
- file_name: static_file | ||
freq: -1 | ||
time_units: hours | ||
unlimdim: time | ||
varlist: | ||
- module: fun_mod | ||
var_name: area | ||
reduction: none | ||
kind: r4 | ||
# Here file 1 does not have the "area" variable so the associated files attribute is expected | ||
- file_name: file1 | ||
freq: 6 hours | ||
time_units: hours | ||
unlimdim: time | ||
varlist: | ||
- module: fun_mod | ||
var_name: var1 | ||
reduction: average | ||
kind: r4 | ||
_EOF | ||
|
||
# remove any existing files that would result in false passes during checks | ||
rm -f *.nc | ||
|
||
my_test_count=1 | ||
printf "&diag_manager_nml \n use_modern_diag=.true. \n/" | cat > input.nml | ||
test_expect_success "Running diag_manager with fields with cell measures (area, volume) (test $my_test_count)" ' | ||
mpirun -n 1 ../test_cell_measures | ||
' | ||
fi | ||
test_done |
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.
documentation