Skip to content

Commit

Permalink
Merge branch 'main' of github.com:noaa-gfdl/FMS into ci-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1776 authored and rem1776 committed Dec 19, 2024
2 parents f27608f + a5662f0 commit 617c55a
Show file tree
Hide file tree
Showing 84 changed files with 5,271 additions and 7,746 deletions.
18 changes: 9 additions & 9 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
* @uramirez8707 @bensonr @rem1776

# GNU autotools files
Makefile.am @uramirez8707 @rem1776
Expand All @@ -41,7 +41,7 @@ cmake @mlee03
/.github/ @rem1776

# Testing files
/test_fms/ @uramirez8707 @mlee03 @bensonr @thomas-robinson @rem1776
/test_fms/ @uramirez8707 @mlee03 @bensonr @rem1776

# Specific component directories
/affinity/ @bensonr
Expand All @@ -53,15 +53,15 @@ cmake @mlee03
#/data_override/ Currently no code owner
/test_fms/data_override/ @rem1776

/diag_manager @thomas-robinson
/test_fms/diag_manager/ @thomas-robinson
/diag_manager @uramirez8707
/test_fms/diag_manager/ @uramirez8707

/fms/ @thomas-robinson @rem1776
/test_fms/fms/ @thomas-robinson @rem1776
/fms/ @uramirez8707 @rem1776
/test_fms/fms/ @uramirez8707 @rem1776
/fms2/ @uramirez8707
/test_fms/fms2/ @uramirez8707

/libFMS/ @thomas-robinson @rem1776
/libFMS/ @uramirez8707 @rem1776

/mpp/ @thomas-robinson @bensonr
/test_fms/mpp/ @thomas-robinson @bensonr @rem1776
/mpp/ @uramirez8707 @bensonr
/test_fms/mpp/ @uramirez8707 @bensonr @rem1776
58 changes: 45 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ list(APPEND fms_fortran_src_files
memutils/memutils.F90
monin_obukhov/monin_obukhov_inter.F90
monin_obukhov/monin_obukhov.F90
mosaic/gradient.F90
mosaic/grid.F90
mosaic/mosaic.F90
grid_utils/gradient.F90
mosaic2/grid2.F90
mosaic2/mosaic2.F90
mpp/mpp.F90
Expand Down Expand Up @@ -205,11 +203,10 @@ list(APPEND fms_fortran_src_files
list(APPEND fms_c_src_files
affinity/affinity.c
fms/fms_stacksize.c
mosaic/create_xgrid.c
mosaic/gradient_c2l.c
mosaic/interp.c
mosaic/mosaic_util.c
mosaic/read_mosaic.c
grid_utils/gradient_c2l.c
grid_utils/grid_utils.c
grid_utils/tree_utils.c
horiz_interp/include/horiz_interp_conserve_xgrid.c
mpp/mpp_memuse.c
parser/yaml_parser_binding.c
parser/yaml_output_functions.c
Expand Down Expand Up @@ -257,6 +254,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 @@ -298,7 +297,8 @@ foreach(kind ${kinds})
# C
add_library(${libTgt}_c OBJECT ${fms_c_src_files})

target_include_directories(${libTgt}_c PRIVATE include)
target_include_directories(${libTgt}_c PRIVATE include
grid_utils)
target_compile_definitions(${libTgt}_c PRIVATE "${fms_defs}")

target_link_libraries(${libTgt}_c PRIVATE NetCDF::NetCDF_C
Expand Down Expand Up @@ -386,6 +386,7 @@ foreach(kind ${kinds})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/monin_obukhov/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/sat_vapor_pres/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/field_manager/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/grid_utils>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/horiz_interp/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mosaic2/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/string_utils/include>
Expand Down Expand Up @@ -429,13 +430,13 @@ endforeach()
install(
TARGETS ${LIB_TARGETS}
EXPORT FMSExports
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

### Package config
include(CMakePackageConfigHelpers)
set(CONFIG_INSTALL_DESTINATION lib/cmake/fms)
set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fms)

export(EXPORT FMSExports
NAMESPACE FMS::
Expand All @@ -458,3 +459,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}
3 changes: 1 addition & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SUBDIRS = \
parser \
string_utils \
affinity \
mosaic \
grid_utils \
time_manager \
axis_utils \
diag_manager \
Expand Down Expand Up @@ -147,4 +147,3 @@ install-data-hook:
@echo '| please see our page: https://www.github.com/NOAA-GFDL/FMS |'
@echo '+-------------------------------------------------------------+'
@echo ''

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
7 changes: 6 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ AC_CONFIG_FILES([
tridiagonal/Makefile
tracer_manager/Makefile
topography/Makefile
mosaic/Makefile
grid_utils/Makefile
mosaic2/Makefile
monin_obukhov/Makefile
memutils/Makefile
Expand Down 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
5 changes: 5 additions & 0 deletions data_override/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [Converting legacy data_table to data_table.yaml](README.MD#3-converting-legacy-data_table-to-data_tableyaml)
- [Examples](README.MD#4-examples)
- [External Weight File Structure](README.MD#5-external-weight-file-structure)
- [Ensemble and Nest Support](README.MD#6-ensemble-and-nest-support)

#### 1. YAML Data Table format:
Each entry in the data_table has the following key values:
Expand Down Expand Up @@ -200,3 +201,7 @@ variables:
- weight(:,:,2) -> (i,j+1)
- weight(:,:,3) -> (i+1,j)
- weight(:,:,4) -> (i+1,j+1)

#### 6. Ensemble and Nest Support

It may be desired to have each member of an ensemble use a different forcing file. In other to support this, FMS allows for each ensemble member to have its own data_table.yaml. For example, for a run with 2 ensemble members, fms will search for data_table_ens_01.yaml and data_table_ens_02.yaml. However, if both the data_table.yaml and the data_table_ens_* files are present, the code will crash as only 1 option is allowed. Similary, each nest can have its own data_table (data_table_nest_01.yaml), but in this case FMS will not crash if both data_table_nest_01.yaml and data_table.yaml are present. The main grid will use the data_table.yaml and the first nest will use the data_table_nest_01.yaml file.
15 changes: 12 additions & 3 deletions data_override/include/data_override.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
! modules. These modules are not intended to be used directly - they should be
! used through the data_override_mod API. See data_override.F90 for details.

use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN
use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN, FMS_FILE_LEN
use yaml_parser_mod
use constants_mod, only: DEG_TO_RAD
use mpp_mod, only : mpp_error, FATAL, WARNING, NOTE, stdout, stdlog, mpp_max
Expand All @@ -45,7 +45,7 @@ use mpp_domains_mod, only : domainUG, mpp_pass_SG_to_UG, mpp_get_UG_SG_domain, N
use time_manager_mod, only: time_type, OPERATOR(>), OPERATOR(<)
use fms2_io_mod, only : FmsNetcdfFile_t, open_file, close_file, &
read_data, fms2_io_init, variable_exists, &
get_mosaic_tile_file, file_exists
get_mosaic_tile_file, file_exists, get_instance_filename
use get_grid_version_mod, only: get_grid_version_1, get_grid_version_2
use fms_string_utils_mod, only: string

Expand Down Expand Up @@ -591,9 +591,18 @@ subroutine read_table_yaml(data_table)
integer :: nentries, mentries
integer :: i
character(len=50) :: buffer
character(len=FMS_FILE_LEN) :: filename !< Name of the expected data_table.yaml
integer :: file_id
file_id = open_and_parse_file("data_table.yaml")
! If doing and ensemble or nest run add the filename appendix (ens_XX or nest_XX) to the filename
call get_instance_filename("data_table.yaml", filename)
if (index(trim(filename), "ens_") .ne. 0) then
if (file_exists(filename) .and. file_exists("data_table.yaml")) &
call mpp_error(FATAL, "Both data_table.yaml and "//trim(filename)//" exists, pick one!")
endif
file_id = open_and_parse_file(trim(filename))
if (file_id==999) then
nentries = 0
else
Expand Down
44 changes: 27 additions & 17 deletions diag_integral/diag_integral.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module diag_integral_mod
fms_init, &
mpp_pe, mpp_root_pe,&
FATAL, write_version_number, &
stdlog
stdlog, string
use fms2_io_mod, only: file_exists
use constants_mod, only: radius, constants_init
use mpp_mod, only: mpp_sum, mpp_init
Expand Down Expand Up @@ -195,7 +195,6 @@ module diag_integral_mod
!-------------------------------------------------------------------------------
character(len=160) :: format_text !< format statement for header
character(len=160) :: format_data !< format statement for data output
logical :: do_format_data = .true. !< a data format needs to be generated ?
integer :: nd !< number of characters in data format statement
integer :: nt !< number of characters in text format statement

Expand Down Expand Up @@ -711,6 +710,8 @@ subroutine write_field_averages (Time)
integer :: nn, ninc, nst, nend, fields_to_print
integer :: i, kount
integer(i8_kind) :: icount
character(len=128) :: xtime_str
logical :: use_exp_format

!-------------------------------------------------------------------------------
! each header and data format may be different and must be generated
Expand Down Expand Up @@ -764,6 +765,12 @@ subroutine write_field_averages (Time)
!-------------------------------------------------------------------------------
xtime = get_axis_time (Time-Time_init_save, time_units)

!-------------------------------------------------------------------------------
! check if the time value is too long for decimal output
!-------------------------------------------------------------------------------
xtime_str = trim(string(xtime))
use_exp_format = len_trim(xtime_str(1:INDEX(xtime_str, "."))) .ge. 9

!-------------------------------------------------------------------------------
! generate the new header and data formats.
!-------------------------------------------------------------------------------
Expand All @@ -774,7 +781,7 @@ subroutine write_field_averages (Time)
nst = 1 + (nn-1)*fields_per_print_line
nend = MIN (nn*fields_per_print_line, num_field)
if (print_header) call format_text_init (nst, nend)
call format_data_init (nst, nend)
call format_data_init (nst, nend, use_exp_format)
if (diag_unit /= 0) then
write (diag_unit,format_data(1:nd)) &
xtime, (field_avg(i),i=nst,nend)
Expand Down Expand Up @@ -890,18 +897,22 @@ end subroutine format_text_init
!! <b> Parameters: </b>
!!
!! @code{.f90}
!! integer, intent(in), optional :: nst_in, nend_in
!! integer, intent(in) :: nst_in, nend_in
!! @endcode
!!
!! @param [in] <nst_in, nend_in> starting/ending integral index which will be
!! included in this format statement
!! @param [in] <use_exp_format> if true, uses exponent notation for the first format code
!! to avoid overflow with larger time values
!!
subroutine format_data_init (nst_in, nend_in)
subroutine format_data_init (nst_in, nend_in, use_exp_format)

integer, intent(in), optional :: nst_in !< starting/ending integral index which will be
integer, intent(in) :: nst_in !< starting/ending integral index which will be
!! included in this format statement
integer, intent(in), optional :: nend_in !< starting/ending integral index which will be
integer, intent(in) :: nend_in !< starting/ending integral index which will be
!! included in this format statement
logical, intent(in) :: use_exp_format !< if true, uses exponent notation for the first format code
!! to avoid overflow with larger time values

!-------------------------------------------------------------------------------
! local variables:
Expand All @@ -917,28 +928,27 @@ subroutine format_data_init (nst_in, nend_in)
! integrals. this section is 9 characters long.
!-------------------------------------------------------------------------------
nd = 9
format_data(1:nd) = '(1x,f10.2'
if( use_exp_format ) then
format_data(1:nd) = '(1x,e10.2'
else
format_data(1:nd) = '(1x,f10.2'
endif

!-------------------------------------------------------------------------------
! define the indices of the integrals that are to be written by this
! format statement.
!-------------------------------------------------------------------------------
if ( present (nst_in) ) then
nst = nst_in
nend = nend_in
else
nst = 1
nend = num_field
endif
nst = nst_in
nend = nend_in

!-------------------------------------------------------------------------------
! complete the data format. use the format defined for the
! particular integral in setting up the format statement.
!-------------------------------------------------------------------------------
do i=nst,nend
nc = len_trim(field_format(i))
format_data(nd+1:nd+nc+5) = ',1x,' // field_format(i)(1:nc)
nd = nd+nc+5
format_data(nd+1:nd+nc+4) = ',1x,' // field_format(i)(1:nc)
nd = nd+nc+4
end do

!-------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 617c55a

Please sign in to comment.