From 44b7ee6b4b06eb6cf3b6eee2784def96c3be06bf Mon Sep 17 00:00:00 2001 From: Bennett Date: Mon, 2 Oct 2023 12:12:36 -0400 Subject: [PATCH 1/8] data_override changes --- data_override/include/data_override.inc | 24 ++++++++++++------- test_fms/data_override/Makefile.am | 2 ++ test_fms/data_override/test_data_override2.sh | 10 ++++++++ test_fms/field_manager/test_field_manager2.sh | 2 ++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index 663d2b0fcf..9bdaa7129c 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -103,11 +103,7 @@ real(FMS_DATA_OVERRIDE_KIND_) :: min_glo_lon_lnd, max_glo_lon_lnd real(FMS_DATA_OVERRIDE_KIND_) :: min_glo_lon_ice, max_glo_lon_ice integer :: num_fields = 0 !< number of fields in override_array already processed -#ifdef use_yaml type(data_type), dimension(:), allocatable :: data_table !< user-provided data table -#else -type(data_type), dimension(max_table) :: data_table !< user-provided data table -#endif type(data_type) :: default_table type(override_type), dimension(max_array) :: override_array !< to store processed fields @@ -118,8 +114,9 @@ logical :: reproduce_null_char_bug = .false. !! to reproduce the mpp_io bug where lat/lon_bnd were !! not read correctly if null characters are present in !! the netcdf file +logical :: use_yaml = .false. -namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug +namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug, use_yaml public :: DATA_OVERRIDE_INIT_IMPL_, DATA_OVERRIDE_UNSET_ATM_, DATA_OVERRIDE_UNSET_OCN_, & & DATA_OVERRIDE_UNSET_LND_, DATA_OVERRIDE_UNSET_ICE_, DATA_OVERRIDE_0D_, & @@ -166,6 +163,14 @@ if (grid_center_bug) then "that is no longer supported. Please remove this namelist variable.") endif +if (use_yaml) then + call mpp_error(NOTE, "You are using YAML.") + return +else + call mpp_error(NOTE, "You are using the legacy table.") + return +end if + atm_on = PRESENT(Atm_domain_in) ocn_on = PRESENT(Ocean_domain_in) lnd_on = PRESENT(Land_domain_in) @@ -199,10 +204,11 @@ endif #ifdef use_yaml call read_table_yaml(data_table) #else - do i = 1,max_table - data_table(i) = default_table - enddo - call read_table(data_table) + if (use_yaml) then + call mpp_error(FATAL, "compilation error, need to compile with `-Duse_yaml`") + else + allocate(data_table(max_table)) + end if #endif ! Initialize override array diff --git a/test_fms/data_override/Makefile.am b/test_fms/data_override/Makefile.am index f5c956c446..91151ffd84 100644 --- a/test_fms/data_override/Makefile.am +++ b/test_fms/data_override/Makefile.am @@ -30,6 +30,7 @@ LDADD = $(top_builddir)/libFMS/libFMS.la # Build this test program. check_PROGRAMS = \ + test_data_override_init \ test_get_grid_v1_r4 \ test_get_grid_v1_r8 \ test_data_override_r4 \ @@ -38,6 +39,7 @@ check_PROGRAMS = \ test_data_override_ongrid_r8 # This is the source code for the test. +test_data_override_init_SOURCES = test_data_override_init.F90 test_data_override_r4_SOURCES = test_data_override.F90 test_data_override_r8_SOURCES = test_data_override.F90 diff --git a/test_fms/data_override/test_data_override2.sh b/test_fms/data_override/test_data_override2.sh index 35546b41d3..dc947360ee 100755 --- a/test_fms/data_override/test_data_override2.sh +++ b/test_fms/data_override/test_data_override2.sh @@ -115,6 +115,16 @@ _EOF rm -rf INPUT *.nc # remove any leftover files to reduce size fi +data_override_init + +cat <<_EOF > data_table +"ICE", :sst_obs", "SST", "INPUT/sst_ice_clim.nc", .false., 300.0 +_EOF + +test _expect_success "data_override_init with the default table"' +mpirun -n 1 ./test_data_override_init +' + done test_done diff --git a/test_fms/field_manager/test_field_manager2.sh b/test_fms/field_manager/test_field_manager2.sh index 3388ccce93..92be7cf618 100755 --- a/test_fms/field_manager/test_field_manager2.sh +++ b/test_fms/field_manager/test_field_manager2.sh @@ -80,4 +80,6 @@ _EOF test_expect_success "field manager functional r4" 'mpirun -n 2 ./test_field_manager_r4' test_expect_success "field manager functional r8" 'mpirun -n 2 ./test_field_manager_r8' +data_override_init + test_done From 9bea5e53fc289ac22437540543e8cd7ae537821a Mon Sep 17 00:00:00 2001 From: Bennett Date: Mon, 2 Oct 2023 13:55:04 -0400 Subject: [PATCH 2/8] update to remove return statements --- data_override/include/data_override.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index 9bdaa7129c..356cc94560 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -165,10 +165,8 @@ endif if (use_yaml) then call mpp_error(NOTE, "You are using YAML.") - return else call mpp_error(NOTE, "You are using the legacy table.") - return end if atm_on = PRESENT(Atm_domain_in) From 8c8613e85e317c306d499b3e65c77928e07c2327 Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 3 Oct 2023 09:20:40 -0400 Subject: [PATCH 3/8] removed and reran without shell script changes --- data_override/include/data_override.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index 356cc94560..8811d099a2 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -206,6 +206,10 @@ end if call mpp_error(FATAL, "compilation error, need to compile with `-Duse_yaml`") else allocate(data_table(max_table)) + do i = 1, max_table + data_table(i) = default_table + enddo + call read_table(data_table) end if #endif From 4f4dcfd6daf427c4d8ada6247f4cd6f1fe5e0d64 Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 3 Oct 2023 09:25:17 -0400 Subject: [PATCH 4/8] Made changes to shell script (test_data_override2.sh) and put code below 'done' --- test_fms/data_override/test_data_override2.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test_fms/data_override/test_data_override2.sh b/test_fms/data_override/test_data_override2.sh index dc947360ee..86f33ef6c0 100755 --- a/test_fms/data_override/test_data_override2.sh +++ b/test_fms/data_override/test_data_override2.sh @@ -115,16 +115,14 @@ _EOF rm -rf INPUT *.nc # remove any leftover files to reduce size fi -data_override_init +done cat <<_EOF > data_table -"ICE", :sst_obs", "SST", "INPUT/sst_ice_clim.nc", .false., 300.0 +"ICE", "sst_obs", "SST", "INPUT/sst_ice_clim.nc", .false., 300.0 _EOF -test _expect_success "data_override_init with the default table"' -mpirun -n 1 ./test_data_override_init +test_expect_success "data_override_init with the default table"' + mpirun -n 1 ./test_data_override_init ' -done - test_done From 534535f1b4824f20188b7b8ea2cf9537842f593f Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 3 Oct 2023 13:44:57 -0400 Subject: [PATCH 5/8] finalized code and fixed make check error (not a test error) that addressed naming issues with 'use_yaml' and 'use_data_table_yaml' --- data_override/include/data_override.inc | 6 ++-- test_fms/data_override/test_data_override2.sh | 31 ++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index 8811d099a2..b1a925b23a 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -114,9 +114,9 @@ logical :: reproduce_null_char_bug = .false. !! to reproduce the mpp_io bug where lat/lon_bnd were !! not read correctly if null characters are present in !! the netcdf file -logical :: use_yaml = .false. +logical :: use_data_table_yaml = .false. -namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug, use_yaml +namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug, use_data_table_yaml public :: DATA_OVERRIDE_INIT_IMPL_, DATA_OVERRIDE_UNSET_ATM_, DATA_OVERRIDE_UNSET_OCN_, & & DATA_OVERRIDE_UNSET_LND_, DATA_OVERRIDE_UNSET_ICE_, DATA_OVERRIDE_0D_, & @@ -202,7 +202,7 @@ end if #ifdef use_yaml call read_table_yaml(data_table) #else - if (use_yaml) then + if (use_data_table_yaml) then call mpp_error(FATAL, "compilation error, need to compile with `-Duse_yaml`") else allocate(data_table(max_table)) diff --git a/test_fms/data_override/test_data_override2.sh b/test_fms/data_override/test_data_override2.sh index 86f33ef6c0..1f37446382 100755 --- a/test_fms/data_override/test_data_override2.sh +++ b/test_fms/data_override/test_data_override2.sh @@ -117,11 +117,40 @@ fi done +# data_override with the default table (not setting namelist) cat <<_EOF > data_table "ICE", "sst_obs", "SST", "INPUT/sst_ice_clim.nc", .false., 300.0 _EOF -test_expect_success "data_override_init with the default table"' +test_expect_success "data_override_init with the default table" ' + mpirun -n 1 ./test_data_override_init +' +# data_override with yaml table (setting namelist to .True.) +cat <<_EOF > input.nml +&data_override_nml +use_data_table_yaml=.true. +/ +_EOF + +cat <<_EOF > data_table.yaml +data_table: + - gridname : OCN + fieldname_code : runoff + fieldname_file : runoff + file_name : INPUT/runoff.daitren.clim.1440x1080.v20180328.nc + interpol_method : none + factor : 1.0 +_EOF + +test_expect_success "data_override_init with the yaml table" ' + mpirun -n 1 ./test_data_override_init +' +#data_override with default table (setting namelist to .True.) +cat <<_EOF > data_table +"ICE", "sst_obs", "SST", "INPUT/sst_ice_clim.nc", .true., 300.0 +_EOF + +test_expect_success "data_override_init with the default table" ' mpirun -n 1 ./test_data_override_init ' From bef0499129e6604bae83a3522a9c17ebce20e59c Mon Sep 17 00:00:00 2001 From: Bennett Chang Date: Wed, 11 Oct 2023 14:15:19 -0400 Subject: [PATCH 6/8] resolved issue regarding data_override errors when running make distcheck --- data_override/include/data_override.inc | 12 ++++++-- test_fms/data_override/test_data_override2.sh | 21 ++++++++++++-- .../data_override/test_data_override_init.F90 | 29 +++++++++++++++++++ test_fms/field_manager/test_field_manager2.sh | 2 -- 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 test_fms/data_override/test_data_override_init.F90 diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index b1a925b23a..9749dd638b 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -163,7 +163,7 @@ if (grid_center_bug) then "that is no longer supported. Please remove this namelist variable.") endif -if (use_yaml) then +if (use_data_table_yaml) then call mpp_error(NOTE, "You are using YAML.") else call mpp_error(NOTE, "You are using the legacy table.") @@ -200,7 +200,15 @@ end if default_table%interpol_method = 'bilinear' #ifdef use_yaml - call read_table_yaml(data_table) + if (use_data_table_yaml) then + call read_table_yaml(data_table) + else + allocate(data_table(max_table)) + do i = 1, max_table + data_table(i) = default_table + enddo + call read_table(data_table) + end if #else if (use_data_table_yaml) then call mpp_error(FATAL, "compilation error, need to compile with `-Duse_yaml`") diff --git a/test_fms/data_override/test_data_override2.sh b/test_fms/data_override/test_data_override2.sh index 1f37446382..15c172e4d1 100755 --- a/test_fms/data_override/test_data_override2.sh +++ b/test_fms/data_override/test_data_override2.sh @@ -142,14 +142,29 @@ data_table: factor : 1.0 _EOF -test_expect_success "data_override_init with the yaml table" ' - mpirun -n 1 ./test_data_override_init -' +#test_expect_success "data_override_init with the yaml table" ' +# mpirun -n 1 ./test_data_override_init +#' +if [ ! -z $parser_skip ]; then + test_expect_failure "data_override_init with the yaml table" ' + mpirun -n 1 ./test_data_override_init + ' +else + test_expect_success "data_override_init with the yaml table" ' + mpirun -n 1 ./test_data_override_init + ' +fi #data_override with default table (setting namelist to .True.) cat <<_EOF > data_table "ICE", "sst_obs", "SST", "INPUT/sst_ice_clim.nc", .true., 300.0 _EOF +cat <<_EOF > input.nml +&data_override_nml +use_data_table_yaml=.false. +/ +_EOF + test_expect_success "data_override_init with the default table" ' mpirun -n 1 ./test_data_override_init ' diff --git a/test_fms/data_override/test_data_override_init.F90 b/test_fms/data_override/test_data_override_init.F90 new file mode 100644 index 0000000000..dceec5aca3 --- /dev/null +++ b/test_fms/data_override/test_data_override_init.F90 @@ -0,0 +1,29 @@ +!*********************************************************************** +!* 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 . +!*********************************************************************** + +program test_data_override_init + + use fms_mod, only: fms_init, fms_end + use data_override_mod + + call fms_init() + call data_override_init + call fms_end() + +end program test_data_override_init diff --git a/test_fms/field_manager/test_field_manager2.sh b/test_fms/field_manager/test_field_manager2.sh index 92be7cf618..3388ccce93 100755 --- a/test_fms/field_manager/test_field_manager2.sh +++ b/test_fms/field_manager/test_field_manager2.sh @@ -80,6 +80,4 @@ _EOF test_expect_success "field manager functional r4" 'mpirun -n 2 ./test_field_manager_r4' test_expect_success "field manager functional r8" 'mpirun -n 2 ./test_field_manager_r8' -data_override_init - test_done From cbc99aad97df2a04e36282605a2331129115d454 Mon Sep 17 00:00:00 2001 From: Bennett Chang Date: Wed, 11 Oct 2023 14:16:46 -0400 Subject: [PATCH 7/8] removed a line that was commented out for testing purposes --- test_fms/data_override/test_data_override2.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/test_fms/data_override/test_data_override2.sh b/test_fms/data_override/test_data_override2.sh index 15c172e4d1..064b0511d4 100755 --- a/test_fms/data_override/test_data_override2.sh +++ b/test_fms/data_override/test_data_override2.sh @@ -142,9 +142,6 @@ data_table: factor : 1.0 _EOF -#test_expect_success "data_override_init with the yaml table" ' -# mpirun -n 1 ./test_data_override_init -#' if [ ! -z $parser_skip ]; then test_expect_failure "data_override_init with the yaml table" ' mpirun -n 1 ./test_data_override_init From bbf666a6bad7cf13fe558213cfe88df4f2e16ef8 Mon Sep 17 00:00:00 2001 From: Bennett Chang Date: Tue, 7 Nov 2023 11:28:54 -0500 Subject: [PATCH 8/8] fixed data_override github action operation errors --- data_override/include/data_override.inc | 7 +++---- test_fms/data_override/Makefile.am | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index 9749dd638b..6d76c0d537 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -114,7 +114,7 @@ logical :: reproduce_null_char_bug = .false. !! to reproduce the mpp_io bug where lat/lon_bnd were !! not read correctly if null characters are present in !! the netcdf file -logical :: use_data_table_yaml = .false. +logical :: use_data_table_yaml = .false. namelist /data_override_nml/ debug_data_override, grid_center_bug, reproduce_null_char_bug, use_data_table_yaml @@ -211,7 +211,7 @@ end if end if #else if (use_data_table_yaml) then - call mpp_error(FATAL, "compilation error, need to compile with `-Duse_yaml`") + call mpp_error(FATAL, "compilation error, need to compile with `-Duse_yaml`") else allocate(data_table(max_table)) do i = 1, max_table @@ -346,7 +346,6 @@ function count_ne_1(in_1, in_2, in_3) count_ne_1 = .not.(in_1.NEQV.in_2.NEQV.in_3) .OR. (in_1.AND.in_2.AND.in_3) end function count_ne_1 -#ifndef use_yaml subroutine read_table(data_table) type(data_type), dimension(max_table), intent(inout) :: data_table @@ -491,7 +490,7 @@ subroutine read_table(data_table) if(io_status/=0) call mpp_error(FATAL, 'data_override_mod: Error in closing file data_table') end subroutine read_table -#else +#ifdef use_yaml subroutine read_table_yaml(data_table) type(data_type), dimension(:), allocatable, intent(out) :: data_table diff --git a/test_fms/data_override/Makefile.am b/test_fms/data_override/Makefile.am index 91151ffd84..366c773800 100644 --- a/test_fms/data_override/Makefile.am +++ b/test_fms/data_override/Makefile.am @@ -30,7 +30,7 @@ LDADD = $(top_builddir)/libFMS/libFMS.la # Build this test program. check_PROGRAMS = \ - test_data_override_init \ + test_data_override_init \ test_get_grid_v1_r4 \ test_get_grid_v1_r8 \ test_data_override_r4 \