Skip to content

Commit

Permalink
Merge branch 'main' into keyword_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
abrooks1085 authored Nov 13, 2023
2 parents c433e92 + 302e3cb commit c2e03cd
Show file tree
Hide file tree
Showing 17 changed files with 300 additions and 169 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@ and this project uses `yyyy.rr[.pp]`, where `yyyy` is the year a patch is releas
`rr` is a sequential release number (starting from `01`), and an optional two-digit
sequential patch number (starting from `01`).

## [2023.03] - 2023-10-27
### Known Issues
- GCC 9 and below as well as GCC 11.1.0 are unsupported due to compilation issues. See prior releases for more details.
- `NO_QUAD_PRECISION` macro is no longer set by FMS, the `ENABLE_QUAD_PRECISION` macro has replaced prior usage of `NO_QUAD_PRECISION`. `-DENABLE_QUAD_PRECISION` should be set if quad precision is to be used, otherwise FMS will not use quad precision reals where applicable.

### Added
- UNIT_TESTS: New unit tests have been created or and existing ones expanded on for any modules utilizing mixed precision support.

### Changed
- MIXED PRECISION: Most subroutines and functions in FMS have been updated to simultaneously accept both 4 byte and 8 byte reals as arguments. This deprecates the `--enable-mixed-mode` option, which enabled similar functionality but was limited to certain directories and was not enabled by default. To facilitate easier testing of these code changes, the CMake precision options for default real size were left in (along with an equivalent `--disable-r8-default` flag for autotools). The resulting libraries will support mixed-precision real kinds regardless of default real size. It should also be noted that many routines that accept real arguments have been moved to include files along with headers in order to be compiled with both kinds. Most module level variables were explicitly declared as r8_kind for these updates.
- Some type/module changes were made to facilitate mixed precision support. They are **intended** to have minimal impact to other codebases:
- COUPLER_TYPES: In coupler_types.F90, `coupler_nd_field_type` and `coupler_nd_values_type` have been renamed to indicate real kind value: `coupler_nd_real4/8_field_type` and `coupler_nd_real4/8_values_type`. The `bc` field within `coupler_nd_bc_type` was modified to use r8_kind within the value and field types, and an additional field added `bc_r4` to use r4_kind values.
- TRIDIAGONAL: Module state between r4 and r8 calls are distinct (ie. subsequent calls will only be affected by calls of the same precision). This behaviour can be changed via the `save_both_kinds` optional argument to `tri_invert`.
- CODE_STYLE: has been updated to reflect the formatting used for the mixed precision support updates.

### Fixed
- DIAG_MANAGER: Tile number (ie. tileX) will now be added to filenames for sub-regional diagnostics.
- MPP: Bug affecting non-intel compilers coming from uninitialized pointer in the `nest_domain_type`
- MPP: Bug fix for unallocated field causing seg faults in `mpp_check_field`
- FMS2_IO: Fixed segfault occuring from use of cray pointer remapping along with mpp_scatter/gather
- TEST_FMS: Added various fixes for different compilers within test programs for fms2_io, mpp, diag_manager, parser, and sat_vapor_pres.
- INTERPOLATOR: Deallocates fields in the type that were previously left out in `interpolator_end`

### Removed
- CPP MACROS:
- `no_4byte_reals` was removed and will not set any additional macros if used. `no_8byte_integers` is still functional.
- `NO_QUAD_PRECISION` was removed. It was conditionally set if ENABLE_QUAD_PRECISION was undefined. ENABLE_QUAD_PRECISION should be used in model components instead (logic is flipped)
- `use_netCDF` was set by autotools previously but wasn't consistently used in the code. FMS should always be compiled with netcdf installed so this was removed with the exception of its use in deprecated IO modules.
- DRIFTERS: The drifters subdirectory has been deprecated. It will only be compiled if using the `-Duse_drifters` CPP flag.

### Tag Commit Hashes
- 2023.03-beta1 06b94a7f574e7794684b8584391744ded68e2989
- 2023.03-alpha3 b25a7c52a27dfd52edc10bc0ebe12776af0f03df
- 2023.03-alpha2 9983ce308e62e9f7215b04c227cebd30fd75e784
- 2023.03-alpha1 a46bd94fd8dd1f6f021501e29179003ff28180ec

## [2023.02] - 2023-07-27
### Known Issues
- GCC 11.1.0 is unsupported due to compilation issues with select type. The issue is resolved in later GCC releases.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set(CMAKE_Fortran_FLAGS_DEBUG)

# Define the CMake project
project(FMS
VERSION 2023.02.0
VERSION 2023.03.0
DESCRIPTION "GFDL FMS Library"
HOMEPAGE_URL "https://www.gfdl.noaa.gov/fms"
LANGUAGES C Fortran)
Expand Down
32 changes: 15 additions & 17 deletions axis_utils/include/axis_utils2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@
end subroutine TRANLON_
function FRAC_INDEX_(value, array)
function FRAC_INDEX_(rval, array)
integer :: ia, i, ii, iunit
real(kind=FMS_AU_KIND_) :: value !< arbitrary data...same units as elements in "array"
real(kind=FMS_AU_KIND_) :: rval !< arbitrary data...same units as elements in "array"
real(kind=FMS_AU_KIND_) :: FRAC_INDEX_
real(kind=FMS_AU_KIND_), dimension(:) :: array !< array of data points (must be monotonically increasing)
logical :: keep_going
Expand All @@ -232,7 +232,7 @@
if (array(i) < array(i-1)) then
iunit = stdout()
write (iunit,*) '=> Error: "frac_index" array must be monotonically' &
& // 'increasing when searching for nearest value to ', value
& // 'increasing when searching for nearest value to ', rval
write (iunit,*) ' array(i) < array(i-1) for i=',i
write (iunit,*) ' array(i) for i=1..ia follows:'
do ii = 1, ia
Expand All @@ -242,17 +242,15 @@
endif
enddo
if (value < array(1) .or. value > array(ia)) then
! if (value < array(1)) frac_index = 1.
! if (value > array(ia)) frac_index = float(ia)
if (rval < array(1) .or. rval > array(ia)) then
FRAC_INDEX_ = -1.0_lkind
else
i = 1
keep_going = .true.
do while (i <= ia .and. keep_going)
i = i+1
if (value <= array(i)) then
FRAC_INDEX_ = real((i-1), lkind) + (value-array(i-1)) / (array(i) - array(i-1))
if (rval <= array(i)) then
FRAC_INDEX_ = real((i-1), lkind) + (rval-array(i-1)) / (array(i) - array(i-1))
keep_going = .false.
endif
enddo
Expand All @@ -266,7 +264,7 @@
!!
!! inputs:
!!
!! value = arbitrary data...same units as elements in "array"
!! rval = arbitrary data...same units as elements in "array"
!! array = array of data points (must be monotonically increasing)
!! ia = dimension of "array"
!!
Expand Down Expand Up @@ -298,12 +296,12 @@
function NEAREST_INDEX_(value, array)
function NEAREST_INDEX_(rval, array)
integer :: NEAREST_INDEX_
integer :: ia !< dimension of "array"
integer :: i, ii, iunit
real(kind=FMS_AU_KIND_) :: value !< arbitrary data...same units as elements in "array"
real(kind=FMS_AU_KIND_) :: rval !< arbitrary data...same units as elements in "array"
real(kind=FMS_AU_KIND_), dimension(:) :: array !< array of data points (must be monotonically increasing)
logical :: keep_going
Expand All @@ -313,7 +311,7 @@
if (array(i) < array(i-1)) then
iunit = stdout()
write (iunit,*) '=> Error: "nearest_index" array must be monotonically increasing' &
& // 'when searching for nearest value to ', value
& // 'when searching for nearest value to ', rval
write (iunit,*) ' array(i) < array(i-1) for i=',i
write (iunit,*) ' array(i) for i=1..ia follows:'
do ii = 1, ia
Expand All @@ -323,17 +321,17 @@
endif
enddo
if (value < array(1) .or. value > array(ia)) then
if (value < array(1)) NEAREST_INDEX_ = 1
if (value > array(ia)) NEAREST_INDEX_ = ia
if (rval < array(1) .or. rval > array(ia)) then
if (rval < array(1)) NEAREST_INDEX_ = 1
if (rval > array(ia)) NEAREST_INDEX_ = ia
else
i = 1
keep_going = .true.
do while (i <= ia .and. keep_going)
i = i+1
if (value <= array(i)) then
if (rval <= array(i)) then
NEAREST_INDEX_ = i
if (array(i)-value > value-array(i-1)) NEAREST_INDEX_ = i-1
if (array(i)-rval > rval-array(i-1)) NEAREST_INDEX_ = i-1
keep_going = .false.
endif
enddo
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AC_PREREQ([2.69])

# Initialize with name, version, and support email address.
AC_INIT([GFDL FMS Library],
[2023.02.00-dev],
[2023.03.00-dev],
[[email protected]],
[FMS],
[https://www.github.com/NOAA-GFDL/FMS])
Expand Down
39 changes: 27 additions & 12 deletions data_override/include/data_override.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_data_table_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_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_, &
Expand Down Expand Up @@ -166,6 +163,12 @@ if (grid_center_bug) then
"that is no longer supported. Please remove this namelist variable.")
endif

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.")
end if

atm_on = PRESENT(Atm_domain_in)
ocn_on = PRESENT(Ocean_domain_in)
lnd_on = PRESENT(Land_domain_in)
Expand Down Expand Up @@ -197,12 +200,25 @@ endif
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
do i = 1,max_table
data_table(i) = default_table
enddo
call read_table(data_table)
if (use_data_table_yaml) then
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

! Initialize override array
Expand Down Expand Up @@ -330,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

Expand Down Expand Up @@ -475,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
Expand Down
Loading

0 comments on commit c2e03cd

Please sign in to comment.