Skip to content

Commit

Permalink
Merge pull request #617 from thomas-robinson/diag_manager_crash
Browse files Browse the repository at this point in the history
Diag manager crash
  • Loading branch information
thomas-robinson authored Nov 6, 2020
2 parents 6a4bade + 7b1be95 commit e7e4883
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 2 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ AC_CONFIG_FILES([Makefile
docs/Makefile
test_fms/test_common.sh
test_fms/Makefile
test_fms/ufs_crash/Makefile
test_fms/diag_manager/Makefile
test_fms/data_override/Makefile
test_fms/exchange/Makefile
Expand Down
6 changes: 5 additions & 1 deletion diag_manager/diag_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,11 @@ SUBROUTINE write_axis_meta_data_fms2_io(file_unit, axes, fileob, time_ops, time_
endif

ELSE
if ( allocated(fptr%pelist) .and. .not. is_time_axis_registered) then
!> @note Check if the time variable is registered. It's possible that is_time_axis_registered is set to true if using
!! time-templated files because they aren't closed when done writing. An alternative to this set up would be to put
!! variable_exists into the if statement with an .or. so that it gets registered.
is_time_axis_registered = variable_exists(fptr,trim(axis_name),.true.)
if (allocated(fptr%pelist) .and. .not. is_time_axis_registered) then
select type (fptr)
type is (FmsNetcdfDomainFile_t)
call register_axis(fptr, trim(axis_name), unlimited )
Expand Down
2 changes: 1 addition & 1 deletion test_fms/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ACLOCAL_AMFLAGS = -I m4

# Make targets will be run in each subdirectory. Order is significant.
SUBDIRS = diag_manager data_override exchange monin_obukhov drifters \
SUBDIRS = ufs_crash diag_manager data_override exchange monin_obukhov drifters \
mosaic interpolator fms fms2_io mpp mpp_io time_interp time_manager \
horiz_interp field_manager axis_utils affinity

Expand Down
49 changes: 49 additions & 0 deletions test_fms/ufs_crash/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#***********************************************************************
#* 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 an automake file for the test_fms/diag_manager directory of the FMS
# package.
# uramirez, Ed Hartnett

# Find the needed mod and .inc files.
AM_CPPFLAGS = -I${top_srcdir}/include \
-I${top_builddir}/mpp \
-I${top_builddir}/fms \
-I${top_builddir}/axis_utils \
-I${top_builddir}/diag_manager \
-I${top_builddir}/time_manager \
-I${top_builddir}/constants \
-I${top_builddir}/platform

# Link to the FMS library.
LDADD = ${top_builddir}/libFMS/libFMS.la

# Build this test program.
check_PROGRAMS = test_diag_manager_time

# This is the source code for the test.
test_diag_manager_time_SOURCES = test_diag_manager_time.F90

# Run the test.
TESTS = test_diag_manager2.sh

# Copy over other needed files to the srcdir
EXTRA_DIST = input.nml diag_table test_diag_manager2.sh

CLEANFILES = *.nc *.out
8 changes: 8 additions & 0 deletions test_fms/ufs_crash/diag_table
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_diag_manager
2 1 1 0 0 0

#output files
"ocn%4yr%2mo%2dy%2hr", 1, "days", 1, "days", "time", 1, "days", "2 1 1 0 0 0"

#output variables
"test_diag_manager_mod", "sst", "sst", "ocn%4yr%2mo%2dy%2hr", "all", .true., "none", 2
3 changes: 3 additions & 0 deletions test_fms/ufs_crash/input.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&diag_manager_nml
use_mpp_io = .false.
/
32 changes: 32 additions & 0 deletions test_fms/ufs_crash/test_diag_manager2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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/data_override directory.

# Ed Hartnett 11/26/19

# Set common test settings.
. ../test_common.sh
cp $top_srcdir/test_fms/ufs_crash/input.nml input.nml
cp $top_srcdir/test_fms/ufs_crash/diag_table diag_table
run_test test_diag_manager_time 1
rm -f input.nml diag_table
74 changes: 74 additions & 0 deletions test_fms/ufs_crash/test_diag_manager_time.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
program test_diag_manager

use mpp_domains_mod
use diag_manager_mod
use fms_mod
use time_manager_mod, only: time_type, set_calendar_type, set_date, NOLEAP, JULIAN, operator(+), set_time, print_time

implicit none

type(time_type) :: Time
integer, dimension(2) :: layout = (/1,1/)
integer :: nlon, nlat, nz
type(domain2d) :: Domain
real, dimension(:), allocatable :: x, y, z
integer :: i, j
integer :: is, ie, js, je
real, allocatable, dimension(:,:,:) :: sst, ice
integer :: id_x, id_y, id_z, id_sst, id_ice
integer :: used

call fms_init
call set_calendar_type(JULIAN)
call diag_manager_init

nlon = 20
nlat = 20
nz = 5

call mpp_domains_set_stack_size(17280000)
call mpp_define_domains( (/1,nlon,1,nlat/), layout, Domain, name='test_diag_manager')
call mpp_define_io_domain(Domain, (/1,1/))
call mpp_get_compute_domain(Domain, is, ie, js, je)

! Set up the data
allocate(x(nlon), y(nlat), z(nz))
allocate(sst(is:ie,js:je,1:nz), ice(is:ie,js:je,1:nz))

do i=1,nlon
x(i) = i
enddo
do j=1,nlat
y(j) = j
enddo
do i=1,nz
z(i) = i
enddo

sst = 666.66
ice = 619.0

! Set up the intial time
Time = set_date(2,1,1,0,0,0)

! Register the diags
id_x = diag_axis_init('x', x, 'point_E', 'x', long_name='point_E', Domain2=Domain)
id_y = diag_axis_init('y', y, 'point_N', 'y', long_name='point_N', Domain2=Domain)
id_z = diag_axis_init('z', z, 'point_Z', 'z', long_name='point_Z')
id_sst = register_diag_field ('test_diag_manager_mod', 'sst', (/id_x,id_y,id_z/), Time, 'SST', 'K')

! Send the axis data
used = send_data(id_x, x, Time)
used = send_data(id_y, y, Time)
used = send_data(id_z, z, Time)

! Increase the time and send data
do i=1,20
Time = set_date(2,1,i,0,0,0)
if(id_sst > 0) used = send_data(id_sst, sst, Time)
enddo

call diag_manager_end(Time)
call fms_end

end program test_diag_manager

0 comments on commit e7e4883

Please sign in to comment.