From d32804592e05ec117c1495a5e318b2670d2c4575 Mon Sep 17 00:00:00 2001 From: Ryan Mulhall <35538242+rem1776@users.noreply.github.com> Date: Thu, 11 Apr 2024 08:46:20 -0400 Subject: [PATCH 1/5] CI: mom6 tests on PR's (#1440) --- .github/workflows/github_mom_gnu.yml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/github_mom_gnu.yml diff --git a/.github/workflows/github_mom_gnu.yml b/.github/workflows/github_mom_gnu.yml new file mode 100644 index 000000000..36735b725 --- /dev/null +++ b/.github/workflows/github_mom_gnu.yml @@ -0,0 +1,32 @@ +name: Run MOM6 test suite + +# runs on PR's or when manually triggered +on: [workflow_dispatch, pull_request] + +# cancel running jobs if theres a newer push +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + container: + image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:13.2.0 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.github_token }} + steps: + - name: Checkout MOM6 repository + uses: actions/checkout@v4 + with: + repository: 'NOAA-GFDL/MOM6' + submodules: recursive + - name: Checkout FMS into MOM build + uses: actions/checkout@v4 + with: + path: .testing/deps/fms/src + - name: Build FMS and MOM test suite + run: make -C .testing -j + - name: Run MOM tests + run: make -C .testing -j test From 9b05ea106b736be6ab9f47844a944c1027f08084 Mon Sep 17 00:00:00 2001 From: Tom Robinson <33458882+thomas-robinson@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:26:48 -0400 Subject: [PATCH 2/5] chore: updates to codeowners (#1488) --- .github/CODEOWNERS | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ff4da7503..4421b7285 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -25,7 +25,7 @@ # These owners will be the default owners for all the files in the # repository. Unless a later match is found, these owners # will be requested for a review when a PR is opened. -* @thomas-robinson @bensonr @rem1776 @scitech777 +* @thomas-robinson @bensonr @rem1776 # GNU autotools files Makefile.am @uramirez8707 @rem1776 @@ -34,15 +34,13 @@ Makefile.am @uramirez8707 @rem1776 *.m4 @uramirez8707 @rem1776 # cmake files -CM* @mlee03 @ngs333 -cmake @mlee03 @ngs333 +CM* @mlee03 +cmake @mlee03 # Files specific to GitHub or GitLab -/.github/ @GFDL-Eric @rem1776 -/.gitlab/ @GFDL-Eric @rem1776 +/.github/ @rem1776 # Testing files -/.gitlab-ci.yml @uramirez8707 @mlee03 @bensonr @thomas-robinson @rem1776 /test_fms/ @uramirez8707 @mlee03 @bensonr @thomas-robinson @rem1776 # Specific component directories @@ -52,18 +50,16 @@ cmake @mlee03 @ngs333 /block_control/ @bensonr /test_fms/block_control/ @bensonr @rem1776 -/data_override/ @GFDL-Eric -/test_fms/data_override/ @GFDL-Eric @rem1776 +#/data_override/ Currently no code owner +/test_fms/data_override/ @rem1776 -/diag_manager @thomas-robinson @ngs333 -/test_fms/diag_manager/ @thomas-robinson @ngs333 - -/fv3gfs/ @bensonr +/diag_manager @thomas-robinson +/test_fms/diag_manager/ @thomas-robinson /fms/ @thomas-robinson @rem1776 /test_fms/fms/ @thomas-robinson @rem1776 -/fms2/ @uramirez8707 @GFDL-Eric -/test_fms/fms2/ @uramirez8707 @GFDL-Eric +/fms2/ @uramirez8707 +/test_fms/fms2/ @uramirez8707 /libFMS/ @thomas-robinson @rem1776 From cb0c48a5194ff2119c93a0e7d71c5d84e8d637aa Mon Sep 17 00:00:00 2001 From: uramirez8707 <49168881+uramirez8707@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:54:54 -0400 Subject: [PATCH 3/5] fix: data_override failures with scalars and add test case (#1489) --- data_override/include/data_override.inc | 18 +++-- test_fms/data_override/Makefile.am | 6 +- .../test_data_override2_scalar.sh | 71 ++++++++++++++++++ .../test_data_override_ongrid.F90 | 75 +++++++++++++++++++ 4 files changed, 161 insertions(+), 9 deletions(-) create mode 100755 test_fms/data_override/test_data_override2_scalar.sh diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index cfec9ef64..a7385677d 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -69,9 +69,9 @@ type data_type logical :: multifile = .false. character(len=512) :: prev_file_name !< name of netCDF data file for previous segment character(len=512) :: next_file_name !< name of netCDF data file for next segment - type(time_type), dimension(:), pointer :: time_records => NULL() - type(time_type), dimension(:), pointer :: time_prev_records => NULL() - type(time_type), dimension(:), pointer :: time_next_records => NULL() + type(time_type), dimension(:), allocatable :: time_records + type(time_type), dimension(:), allocatable :: time_prev_records + type(time_type), dimension(:), allocatable :: time_next_records end type data_type !> Private type for holding various data fields for performing data overrides @@ -900,13 +900,17 @@ subroutine DATA_OVERRIDE_0D_(gridname,fieldname_code,data_out,time,override,data !10 do time interp to get data in compute_domain - first_record = data_table(index1)%time_records(1) - last_record = data_table(index1)%time_records(dims(4)) - ! if using consecutive files, allow to perform time interpolation between the last record of previous ! file and first record of current file OR between the last record of current file and first record of ! next file hence "bridging" over files. if_multi2: if (multifile) then + dims = get_external_field_size(id_time) + if (.not. allocated(data_table(index1)%time_records)) allocate(data_table(index1)%time_records(dims(4))) + call get_time_axis(id_time,data_table(index1)%time_records) + + first_record = data_table(index1)%time_records(1) + last_record = data_table(index1)%time_records(dims(4)) + if_time2: if (time. +#*********************************************************************** +# +# Copyright (c) 2019-2021 Ed Hartnett, Uriel Ramirez, Seth Underwood + +# Set common test settings. +. ../test-lib.sh + +output_dir +rm -rf data_table data_table.yaml input.nml input_base.nml + +if [ ! -z $parser_skip ]; then + cat <<_EOF > input.nml +&data_override_nml +use_data_table_yaml=.False. +/ +&test_data_override_ongrid_nml + test_case = 3 +/ +_EOF + printf '"OCN", "co2", "co2", "./INPUT/scalar.nc", "none" , 1.0' | cat > data_table +else +cat <<_EOF > input.nml +&data_override_nml +use_data_table_yaml=.True. +/ +&test_data_override_ongrid_nml + test_case = 3 +/ +_EOF +cat <<_EOF > data_table.yaml +data_table: + - gridname : OCN + fieldname_code : co2 + fieldname_file : co2 + file_name : INPUT/scalar.nc + interpol_method : none + factor : 1.0 +_EOF +fi + +[ ! -d "INPUT" ] && mkdir -p "INPUT" +for KIND in r4 r8 +do +rm -rf INPUT/* +test_expect_success "data_override scalar field (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} +' + +done +rm -rf INPUT *.nc # remove any leftover files to reduce size + +test_done \ No newline at end of file diff --git a/test_fms/data_override/test_data_override_ongrid.F90 b/test_fms/data_override/test_data_override_ongrid.F90 index ac97f03a1..4345bb9f8 100644 --- a/test_fms/data_override/test_data_override_ongrid.F90 +++ b/test_fms/data_override/test_data_override_ongrid.F90 @@ -50,6 +50,7 @@ program test_data_override_ongrid integer :: io_status integer, parameter :: ongrid = 1 integer, parameter :: bilinear = 2 +integer, parameter :: scalar = 3 integer :: test_case = ongrid namelist / test_data_override_ongrid_nml / nhalox, nhaloy, test_case @@ -83,6 +84,8 @@ program test_data_override_ongrid call generate_ongrid_input_file () case (bilinear) call generate_bilinear_input_file () +case (scalar) + call generate_scalar_input_file () end select call mpp_sync() @@ -96,6 +99,8 @@ program test_data_override_ongrid call ongrid_test() case (bilinear) call bilinear_test() +case (scalar) + call scalar_test() end select call mpp_exit @@ -437,4 +442,74 @@ subroutine bilinear_test() enddo deallocate(runoff_decreasing, runoff_increasing) end subroutine bilinear_test + +!> @brief Generates the input for the bilinear data_override test_case +subroutine generate_scalar_input_file() + if (mpp_pe() .eq. mpp_root_pe()) then + call create_grid_spec_file () + call create_ocean_mosaic_file() + call create_ocean_hgrid_file() + call create_scalar_data_file() + endif + call mpp_sync() +end subroutine generate_scalar_input_file + +subroutine create_scalar_data_file() + type(FmsNetcdfFile_t) :: fileobj + character(len=10) :: dimnames(1) + real(lkind), allocatable, dimension(:) :: co2_in + real(lkind), allocatable, dimension(:) :: time_data + integer :: i + + allocate(co2_in(10)) + allocate(time_data(10)) + do i = 1, 10 + co2_in(i) = real(i, lkind) + enddo + time_data = (/1., 2., 3., 5., 6., 7., 8., 9., 10., 11./) + + dimnames(1) = 'time' + + if (open_file(fileobj, 'INPUT/scalar.nc', 'overwrite')) then + call register_axis(fileobj, "time", unlimited) + call register_field(fileobj, "time", "float", (/"time"/)) + call register_variable_attribute(fileobj, "time", "cartesian_axis", "T", str_len=1) + call register_variable_attribute(fileobj, "time", "calendar", "noleap", str_len=6) + call register_variable_attribute(fileobj, "time", "units", "days since 0001-01-01 00:00:00", str_len=30) + + call register_field(fileobj, "co2", "float", dimnames) + call write_data(fileobj, "co2", co2_in) + call write_data(fileobj, "time", time_data) + call close_file(fileobj) + else + call mpp_error(FATAL, "Error opening the file: 'INPUT/scalar.nc' to write") + endif + deallocate(co2_in) +end subroutine create_scalar_data_file + +subroutine scalar_test() + real(lkind) :: expected_result !< Expected result from data_override + type(time_type) :: Time !< Time + real(lkind) :: co2 !< Data to be written + + co2 = 999._lkind + !< Run it when time=3 + Time = set_date(1,1,4,0,0,0) + call data_override('OCN','co2',co2, Time) + !< Because you are getting the data when time=3, and this is an "ongrid" case, the expected result is just + !! equal to the data at time=3, which is 3. + expected_result = 3._lkind + if (co2 .ne. expected_result) call mpp_error(FATAL, "co2 was not overriden to the correct value!") + + !< Run it when time=4 + co2 = 999._lkind + Time = set_date(1,1,5,0,0,0) + call data_override('OCN','co2',co2, Time) + !< You are getting the data when time=4, the data at time=3 is 3. and at time=5 is 4., so the expected result + !! is the average of the 2 (because this is is an "ongrid" case and there is no horizontal interpolation). + expected_result = (3._lkind + 4._lkind) / 2._lkind + if (co2 .ne. expected_result) call mpp_error(FATAL, "co2 was not overriden to the correct value!") + +end subroutine scalar_test + end program test_data_override_ongrid From 4c832f9299dc48977015bf6a3a27c4443a6e98e2 Mon Sep 17 00:00:00 2001 From: Ryan Mulhall Date: Tue, 23 Apr 2024 13:38:18 -0400 Subject: [PATCH 4/5] change netcdf call to create instead of open --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cd6449372..30e94759f 100644 --- a/configure.ac +++ b/configure.ac @@ -265,7 +265,7 @@ AC_MSG_CHECKING([if HDF5 version causes floating point exceptions with set flags AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ use netcdf integer i, j - j = nf90_open("test.nc", NC_WRITE, i) + j = nf90_create("test.nc", NC_WRITE, i) ]])], [hdf5_fpe_bug=no], [hdf5_fpe_bug=yes]) AC_MSG_RESULT([$hdf5_fpe_bug]) if test $hdf5_fpe_bug = yes; then From b973f20b3d877022eb50e409c72e1f3dd3111175 Mon Sep 17 00:00:00 2001 From: rem1776 Date: Wed, 24 Apr 2024 13:47:15 -0400 Subject: [PATCH 5/5] fix leftover file and sneak in a distcheck fix --- Makefile.am | 4 ++-- test_fms/monin_obukhov/test_monin_obukhov2.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22fb68f97..f9a8211f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -125,10 +125,10 @@ check-code-coverage: check .PHONY: check-code-coverage clean-local: - -rm -rf .mods coverage-data coverage-report + -rm -rf .mods coverage-data coverage-report test.nc else clean-local: - -rm -rf .mods + -rm -rf .mods test.nc endif install-data-hook: diff --git a/test_fms/monin_obukhov/test_monin_obukhov2.sh b/test_fms/monin_obukhov/test_monin_obukhov2.sh index 72a5f9b3f..c125164c9 100755 --- a/test_fms/monin_obukhov/test_monin_obukhov2.sh +++ b/test_fms/monin_obukhov/test_monin_obukhov2.sh @@ -35,7 +35,7 @@ for p in r4 r8 do cp ${top_srcdir}/test_fms/monin_obukhov/input.${p}.nml input.nml test_expect_success "test monin_obukhov_mod (${p})" "mpirun -n 1 ./test_monin_obukhov_${p}" - rm input.nml + rm -f input.nml done test_done