Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NOAA-GFDL/FMS into read_zaxis_slice…
Browse files Browse the repository at this point in the history
…_test
  • Loading branch information
uramirez8707 committed Dec 3, 2024
2 parents 13ad4e4 + 3333fac commit 8c94e3b
Show file tree
Hide file tree
Showing 23 changed files with 240 additions and 34 deletions.
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ if(WITH_YAML)
endif()

if(USE_DEPRECATED_IO)
message( WARNING "fms_io WILL BE DEPRECATED IN A FUTURE RELEASE. PLEASE UPDATE TO USE FMS2_IO AND REMOVE "
"-DUSE_DEPRECATED_IO=on FROM YOUR OPTIONS")
list(APPEND fms_defs use_deprecated_io)
endif()

Expand Down Expand Up @@ -458,3 +460,34 @@ install(EXPORT FMSExports
NAMESPACE FMS::
FILE fms-targets.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})

# pkgconf
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/${includeDir})

set(CC ${CMAKE_C_COMPILER})
set(FC ${CMAKE_Fortran_COMPILER})
set(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
set(CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${CMAKE_BUILD_TYPE}}")
set(FCFLAGS "${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}")
set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE}}")

set(VERSION ${PROJECT_VERSION})

# TODO: If FMS depends on a library that is built as a static library, it
# should be listed here as an ldflag.
set(LIBS "")

if(NOT ${NetCDF_Fortran_LIBRARY_SHARED})
# autotools: Libs.private: -lnetcdff -lnetcdf
string(APPEND LIBS ${NetCDF_Fortran_LIBRARIES})
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FMS.pc.in
${CMAKE_CURRENT_BINARY_DIR}/FMS.pc @ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FMS.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT utilities)
2 changes: 1 addition & 1 deletion FMS.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Name: FMS
Description: The Flexible Modeling System Infrastructure Library
URL: https://www.gfdl.noaa.gov/fms
Version: @VERSION@
Libs: -L$(libdir) -lFMS
Libs: -L${libdir} -lFMS
Libs.private: @LIBS@
Cflags: -I${includedir}
Fflags: -I${includedir}
17 changes: 11 additions & 6 deletions block_control/block_control.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

module block_control_mod

use mpp_mod, only: mpp_error, NOTE, WARNING, FATAL
use mpp_mod, only: mpp_error, NOTE, WARNING, FATAL, mpp_sum, mpp_npes
use mpp_domains_mod, only: mpp_compute_extent
use fms_string_utils_mod, only: string
implicit none

public block_control_type
Expand Down Expand Up @@ -104,15 +105,19 @@ subroutine define_blocks (component, Block, isc, iec, jsc, jec, kpts, &
integer, dimension(ny_block) :: j1, j2
character(len=256) :: text
integer :: i, j, nblks, ix, ii, jj
integer :: non_uniform_blocks !< Number of non uniform blocks

if (message) then
non_uniform_blocks = 0
if ((mod(iec-isc+1,nx_block) .ne. 0) .or. (mod(jec-jsc+1,ny_block) .ne. 0)) then
write( text,'(a,a,2i4,a,2i4,a)' ) trim(component),'define_blocks: domain (',&
(iec-isc+1), (jec-jsc+1),') is not an even divisor with definition (',&
nx_block, ny_block,') - blocks will not be uniform'
call mpp_error (WARNING, trim(text))
non_uniform_blocks = 1
endif
call mpp_sum(non_uniform_blocks)
if (non_uniform_blocks > 0 ) then
call mpp_error(NOTE, string(non_uniform_blocks)//" out of "//string(mpp_npes())//" total domains "//&
"have non-uniform blocks for block size ("//string(nx_block)//","//string(ny_block)//")")
message = .false.
endif
message = .false.
endif

!--- set up blocks
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,12 @@ AC_CONFIG_FILES([
test_fms/random_numbers/Makefile
test_fms/topography/Makefile
test_fms/column_diagnostics/Makefile
test_fms/block_control/Makefile
FMS.pc
])

AC_OUTPUT()

if test $enable_deprecated_io = yes; then
AC_MSG_WARN(FMS_IO WILL BE DEPRECATED IN A FUTURE RLEASE. PLEASE UPDATE TO USE FMS2_IO AND REMOVE --enable-deprecated-io FROM YOUR CONFIGURE OPTIONS)
fi
4 changes: 2 additions & 2 deletions diag_manager/diag_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ LOGICAL FUNCTION diag_send_data(diag_field_id, field, time, is_in, js_in, ks_in,
allocate(mask_remap(1:size(mask,1), 1:size(mask,2), 1:size(mask,3), 1))
mask_remap(:,:,:,1) = mask
endif
diag_send_data = fms_diag_object%fms_diag_accept_data(diag_field_id, field_remap, mask_remap, rmask_remap, &
call fms_diag_object%fms_diag_accept_data(diag_field_id, field_remap, mask_remap, rmask_remap, &
time, is_in, js_in, ks_in, ie_in, je_in, ke_in, weight, &
err_msg)
deallocate (field_remap)
Expand Down Expand Up @@ -3518,7 +3518,7 @@ LOGICAL FUNCTION send_data_4d(diag_field_id, field, time, is_in, js_in, ks_in, &
if (present(mask)) mask_local = mask
if (present(rmask)) rmask_local = rmask

send_data_4d = fms_diag_object%fms_diag_accept_data(diag_field_id, field, mask_local, rmask_local, &
call fms_diag_object%fms_diag_accept_data(diag_field_id, field, mask_local, rmask_local, &
time, is_in, js_in, ks_in, ie_in, je_in, ke_in, weight, &
err_msg)

Expand Down
14 changes: 5 additions & 9 deletions diag_manager/fms_diag_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ integer function fms_register_diag_field_obj &
integer, allocatable :: file_ids(:) !< The file IDs for this variable
integer :: i !< For do loops
integer, allocatable :: diag_field_indices(:) !< indices where the field was found in the yaml
class(diagDomain_t), pointer :: null_diag_domain => NULL() !< Workaround for a Cray bug which will be fixed in CCE 19
#endif
#ifndef use_yaml
fms_register_diag_field_obj = DIAG_FIELD_NOT_FOUND
Expand Down Expand Up @@ -267,7 +268,7 @@ integer function fms_register_diag_field_obj &
call fileptr%add_field_and_yaml_id(fieldptr%get_id(), diag_field_indices(i))
call fileptr%add_buffer_id(fieldptr%buffer_ids(i))
if(fieldptr%get_type_of_domain() .eq. NO_DOMAIN) then
call fileptr%set_file_domain(NULL(), fieldptr%get_type_of_domain())
call fileptr%set_file_domain(null_diag_domain, fieldptr%get_type_of_domain())
else
call fileptr%set_file_domain(fieldptr%get_domain(), fieldptr%get_type_of_domain())
endif
Expand All @@ -284,7 +285,7 @@ integer function fms_register_diag_field_obj &
call fileptr%add_buffer_id(fieldptr%buffer_ids(i))
call fileptr%init_diurnal_axis(this%diag_axis, this%registered_axis, diag_field_indices(i))
if(fieldptr%get_type_of_domain() .eq. NO_DOMAIN) then
call fileptr%set_file_domain(NULL(), fieldptr%get_type_of_domain())
call fileptr%set_file_domain(null_diag_domain, fieldptr%get_type_of_domain())
else
call fileptr%set_file_domain(fieldptr%get_domain(), fieldptr%get_type_of_domain())
endif
Expand Down Expand Up @@ -536,7 +537,7 @@ end function fms_diag_axis_init
!! multithreaded case.
!! \note If some of the diag manager is offloaded in the future, then it should be treated similarly
!! to the multi-threaded option for processing later
logical function fms_diag_accept_data (this, diag_field_id, field_data, mask, rmask, &
subroutine fms_diag_accept_data (this, diag_field_id, field_data, mask, rmask, &
time, is_in, js_in, ks_in, &
ie_in, je_in, ke_in, weight, err_msg)
class(fmsDiagObject_type),TARGET, INTENT(inout) :: this !< Diaj_obj to fill
Expand Down Expand Up @@ -680,8 +681,6 @@ logical function fms_diag_accept_data (this, diag_field_id, field_data, mask, rm
!$omp end critical
call this%FMS_diag_fields(diag_field_id)%set_data_buffer(field_data, oor_mask, field_weight, &
is, js, ks, ie, je, ke)
fms_diag_accept_data = .TRUE.
return
else

!< At this point if we are no longer in an openmp region or running with 1 thread
Expand Down Expand Up @@ -709,13 +708,10 @@ logical function fms_diag_accept_data (this, diag_field_id, field_data, mask, rm
if(.not. this%FMS_diag_fields(diag_field_id)%has_mask_allocated()) &
call this%FMS_diag_fields(diag_field_id)%allocate_mask(oor_mask)
call this%FMS_diag_fields(diag_field_id)%set_mask(oor_mask, field_info)
return
end if main_if
!> Return false if nothing is done
fms_diag_accept_data = .FALSE.
return
#endif
end function fms_diag_accept_data
end subroutine fms_diag_accept_data

!< @brief Do the math for all the buffers
subroutine do_buffer_math(this)
Expand Down
10 changes: 10 additions & 0 deletions fms/fms_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,11 @@ subroutine fms_io_init()
call mpp_error(FATAL,'=>fms_io_init: Error reading input nml file')
endif

call mpp_error(NOTE, "fms_io_init: fms_io WILL BE DEPRECATED IN A FUTURE RELEASE! "//&
"PLEASE REMOVE -Duse_deprecated_io FROM YOUR COMPILE FLAGS "// &
"AND MOVE TO FMS2_IO. CONTACT YOUR MODEL LIASISON IF YOU NEED "// &
"ASSISTANCE")

! take namelist options if present
! read_data_bug is no longer supported.
if (read_data_bug) then
Expand Down Expand Up @@ -802,6 +807,11 @@ subroutine fms_io_exit()

if( .NOT.module_is_initialized )return !make sure it's only called once per PE

call mpp_error(NOTE, "fms_io_exit: fms_io WILL BE DEPRECATED IN A FUTURE RELEASE! "//&
"PLEASE REMOVE -Duse_deprecated_io FROM YOUR COMPILE FLAGS "// &
"AND MOVE TO FMS2_IO. CONTACT YOUR MODEL LIASISON IF YOU NEED "// &
"ASSISTANCE")

do i=1,max_axis_size
axisdata(i) = i
enddo
Expand Down
2 changes: 1 addition & 1 deletion test_fms/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ACLOCAL_AMFLAGS = -I m4
SUBDIRS = astronomy coupler diag_manager data_override exchange monin_obukhov drifters \
mosaic2 interpolator fms mpp mpp_io time_interp time_manager horiz_interp topography \
field_manager axis_utils affinity fms2_io parser string_utils sat_vapor_pres tracer_manager \
random_numbers diag_integral column_diagnostics tridiagonal
random_numbers diag_integral column_diagnostics tridiagonal block_control

# testing utility scripts to distribute
EXTRA_DIST = test-lib.sh.in intel_coverage.sh.in tap-driver.sh
47 changes: 47 additions & 0 deletions test_fms/block_control/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#***********************************************************************
#* 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/block_control directory of the
# FMS package.

# Find the fms and mpp mod files.
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(MODDIR)

# Link to the FMS library.
LDADD = $(top_builddir)/libFMS/libFMS.la

# Build this test program.
check_PROGRAMS = \
test_block_control

# This is the source code for the test.
test_block_control_SOURCES = test_block_control.F90

# Run the test program.
TESTS = test_block_control.sh

# Copy over other needed files to the srcdir
EXTRA_DIST = test_block_control.sh

TEST_EXTENSIONS = .sh
SH_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(abs_top_srcdir)/test_fms/tap-driver.sh

# Clean up
CLEANFILES = input.nml *.out* *.dpi *.spi *.dyn *.spl
69 changes: 69 additions & 0 deletions test_fms/block_control/test_block_control.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
!***********************************************************************
!* 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/>.
!***********************************************************************

program test_block_control
use fms_mod, only: fms_init, fms_end
use mpp_domains_mod, only: domain2d, mpp_define_domains, mpp_get_compute_domain
use block_control_mod, only: block_control_type, define_blocks
use mpp_mod, only: mpp_pe, mpp_root_pe, mpp_error, FATAL
use fms_string_utils_mod, only: string

implicit none

integer, parameter :: nx=96 !< Size of the x grid
integer, parameter :: ny=96 !< Size of the y grid
type(domain2d) :: Domain !< 2D domain
integer :: layout(2) = (/2, 3/) !< Layout of the domain
type(block_control_type) :: my_block !< Block control type
integer :: isc, iec, jsc, jec !< Starting and ending index for the commute domain
integer :: expected_startingy !< Expected starting y index for the current block
integer :: expected_endingy !< Expected ending y index for the current block
integer :: ncy(3) !< Size of the y for each block
logical :: message !< Set to .True., to output the warning message
integer :: i !< For do loops

call fms_init()
message = .True. !< Needs to be .true. so that the error message can be printed
call mpp_define_domains( (/1,nx,1,ny/), layout, Domain)
call mpp_get_compute_domain(Domain, isc, iec, jsc, jec)
call define_blocks ('testing_model', my_block, isc, iec, jsc, jec, kpts=0, &
nx_block=1, ny_block=3, message=message)

!< Message will be set to .false. if the blocks are not uniform
if (message) &
call mpp_error(FATAL, "test_block_control::define_blocks did not output the warning message"//&
" about uneven blocks")

!Expected size of each block for every PE
ncy = (/11, 10, 11/)
expected_endingy = jsc-1
do i = 1, 3
! Check the starting and ending "x" indices for each block
if (my_block%ibs(i) .ne. isc .or. my_block%ibe(i) .ne. iec) &
call mpp_error(FATAL, "The starting and ending 'x' index for the "//string(i)//" block is not expected value!")

! Check the starting and ending "y" indices for each block
expected_startingy = expected_endingy + 1
expected_endingy = expected_startingy + ncy(i) - 1
if (my_block%jbs(i) .ne. expected_startingy .or. my_block%jbe(i) .ne. expected_endingy) &
call mpp_error(FATAL, "The starting and ending 'y' index for the "//string(i)//" block is not expected value!")
enddo

call fms_end()
end program
38 changes: 38 additions & 0 deletions test_fms/block_control/test_block_control.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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/block_control directory.

# Set common test settings.
. ../test-lib.sh

# Prepare the directory to run the tests.
cat <<EOF > input.nml
EOF

# Run the test.

test_expect_success "Test block_control" '
mpirun -n 6 ./test_block_control
'

test_done
4 changes: 2 additions & 2 deletions test_fms/diag_manager/test_diag_manager2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ diag_files:
kind: r4
- module: atm_mod
var_name: var7
reduction: average
reduction: none
kind: r4
- file_name: file4
freq: 6 hours
Expand Down Expand Up @@ -1050,7 +1050,7 @@ diag_files:
dimensions: time grid_index
- module: atm_mod
var_name: var7
reduction: average
reduction: none
kind: r4
output_name:
long_name:
Expand Down
Loading

0 comments on commit 8c94e3b

Please sign in to comment.