@@ -29,9 +29,12 @@ program test_multiple_zbounds
2929 type (time_type) :: Time_step ! < Time_step of the simulation
3030 integer :: id_z1 ! < Axis id for the z dimension
3131 integer :: id_z2 ! < Axis id for the z dimension
32+ integer :: id_z_reverse ! < Axis id for the z dimension (decreasing)
3233 integer :: id_var1 ! < var id for the first variable
3334 integer :: id_var2 ! < var_id for the second variable
35+ integer :: id_var3 ! < var_id for the third variable
3436 real , allocatable :: z(:) ! < z axis data
37+ real , allocatable :: z_reverse(:) ! < z axis data (decreasing)
3538 integer :: nz ! < Size of the z dimension
3639 integer :: i
3740 logical :: used ! < Dummy argument to send_data
@@ -42,25 +45,28 @@ program test_multiple_zbounds
4245
4346 nz = 10
4447 allocate (z(nz))
48+ allocate (z_reverse(nz))
4549 do i= 1 , nz
4650 z(i) = i
51+ z_reverse(i) = nz - i + 1
4752 enddo
4853
4954 Time = set_date(2 ,1 ,1 ,0 ,0 ,0 )
5055 Time_step = set_time (3600 ,0 )
5156
5257 id_z1 = diag_axis_init(' zaxis1' , z, ' z' , ' z' , long_name= ' Z1' )
5358 id_z2 = diag_axis_init(' zaxis2' , z, ' z' , ' z' , long_name= ' Z2' )
59+ id_z_reverse = diag_axis_init(' zaxis3' , z_reverse, ' z_reverse' , ' z' , long_name= ' Z3' )
5460 id_var1 = register_diag_field (' atmos' , ' ua_1' , (/ id_z1/ ), Time)
5561 id_var2 = register_diag_field (' atmos' , ' ua_2' , (/ id_z2/ ), Time)
62+ id_var3 = register_diag_field (' atmos' , ' ua_3' , (/ id_z_reverse/ ), Time)
5663
5764 call diag_manager_set_time_end(set_date(2 ,1 ,2 ,0 ,0 ,0 ))
5865 do i = 1 , 24
5966 Time = Time + Time_step
60- z = real (i)
6167 used = send_data(id_var1, z, Time)
6268 used = send_data(id_var2, z, Time)
63-
69+ used = send_data(id_var3, z, Time)
6470 call diag_send_complete(Time_step)
6571 end do
6672
@@ -77,15 +83,25 @@ subroutine check_output()
7783 integer :: SUB1_SIZE = 3
7884 integer :: SUB2_SIZE = 1
7985 character (len= 20 ) :: EXPECTED_DIM_NAMES(2 )
86+ real :: EXPECTED_ZSUBAXIS_1(3 )
87+ real :: EXPECTED_ZSUBAXIS_2(1 )
88+ real :: EXPECTED_ZSUBAXIS_3(3 )
8089
8190 EXPECTED_DIM_NAMES(2 ) = " time"
8291 if (.not. open_file(fileobj, " test_multiple_zbounds.nc" , " read" )) then
8392 call mpp_error(FATAL, " Unable to open the expected output file: test_var_masks.nc" )
8493 endif
8594
8695 call check_dimension(fileobj, " time" , EXPECTED_NTIMES)
87- call check_dimension(fileobj, " zaxis1_sub01" , SUB1_SIZE)
88- call check_dimension(fileobj, " zaxis2_sub02" , SUB2_SIZE)
96+
97+ EXPECTED_ZSUBAXIS_1 = (/ 3 ., 4 ., 5 ./ )
98+ call check_dimension(fileobj, " zaxis1_sub01" , SUB1_SIZE, EXPECTED_ZSUBAXIS_1)
99+
100+ EXPECTED_ZSUBAXIS_2 = (/ 1 ./ )
101+ call check_dimension(fileobj, " zaxis2_sub02" , SUB2_SIZE, EXPECTED_ZSUBAXIS_2)
102+
103+ EXPECTED_ZSUBAXIS_3 = (/ 5 ., 4 ., 3 ./ )
104+ call check_dimension(fileobj, " zaxis3_sub03" , SUB1_SIZE, EXPECTED_ZSUBAXIS_3)
89105
90106 EXPECTED_DIM_NAMES(1 ) = " zaxis1_sub01"
91107 call check_variable(fileobj, " ua_1" , EXPECTED_DIM_NAMES)
@@ -114,17 +130,40 @@ subroutine check_variable(fileobj, variable_name, expected_dimnames)
114130
115131 end subroutine check_variable
116132
117- subroutine check_dimension (fileobj , dimension_name , expected_size )
133+ ! > @brief Check dimension data
134+ subroutine check_data (err_msg , actual_data , expected_data )
135+ character (len=* ), intent (in ) :: err_msg ! < Error message to append
136+ real , intent (in ) :: actual_data(:) ! < Dimension data from file
137+ real , intent (in ) :: expected_data(:) ! < Expected data
138+
139+ integer :: i
140+
141+ do i = 1 , size (actual_data)
142+ if (actual_data(i) .ne. expected_data(i)) &
143+ call mpp_error(FATAL, " The data is not expected for " // trim (err_msg))
144+ enddo
145+ end subroutine check_data
146+
147+ subroutine check_dimension (fileobj , dimension_name , expected_size , expected_data )
118148 type (FmsNetcdfFile_t), intent (in ) :: fileobj
119149 character (len=* ), intent (in ) :: dimension_name
120150 integer , intent (in ) :: expected_size
151+ real , optional , intent (in ) :: expected_data(:)
121152
122153 integer :: dim_size
154+ real , allocatable :: z_data(:)
123155
124156 call get_dimension_size(fileobj, dimension_name, dim_size)
125157 if (dim_size .ne. expected_size) then
126158 call mpp_error(FATAL, trim (dimension_name)// " is not the expected size!" )
127159 endif
128160
161+ if (present (expected_data)) then
162+ allocate (z_data(dim_size))
163+ call read_data(fileobj, dimension_name, z_data)
164+ call check_data(dimension_name, z_data, expected_data)
165+ endif
166+
167+
129168 end subroutine
130169end program test_multiple_zbounds
0 commit comments