Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallic2 committed Nov 9, 2023
2 parents 02b33c6 + b0dbc30 commit 9f94158
Show file tree
Hide file tree
Showing 67 changed files with 5,742 additions and 4,428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github_autotools_gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
conf-flag: [ --disable-openmp, --enable-mixed-mode, --disable-setting-flags, --with-mpi=no]
conf-flag: [ --disable-openmp, --disable-setting-flags, --with-mpi=no, --disable-r8-defaults]
input-flag: [--with-yaml, --enable-test-input=/home/unit_tests_input]
exclude:
- conf-flag: --with-mpi=no
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/github_coupler_gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ jobs:
coupler-build:
runs-on: ubuntu-latest
container:
image: ryanmulhall/hpc-me.ubuntu-minimal:coupler
image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:12.3.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
env:
CC: mpicc
FC: mpif90
CPPFLAGS: '-I/usr/include -Duse_LARGEFILE -DMAXFIELDMETHODS_=500'
FCFLAGS: '-fcray-pointer -fdefault-double-8 -fdefault-real-8 -Waliasing -ffree-line-length-none -fno-range-check -I/usr/include'
LDFLAGS: '-L/usr/lib'
VERBOSE: 1
CPPFLAGS: '-I/opt/view/include'
FFLAGS: '-fallow-argument-mismatch' # mkmf uses FFLAGS instead of FC
LDFLAGS: '-L/opt/view/lib'
steps:
- name: Checkout FMS
uses: actions/checkout@v2
Expand Down
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
10 changes: 7 additions & 3 deletions 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 Expand Up @@ -321,9 +321,11 @@ foreach(kind ${kinds})
field_manager/include
time_interp/include
tracer_manager/include
tridiagonal/include
interpolator/include
coupler/include
data_override/include)
data_override/include
amip_interp/include)

target_compile_definitions(${libTgt}_f PRIVATE "${fms_defs}")
target_compile_definitions(${libTgt}_f PRIVATE "${${kind}_defs}")
Expand Down Expand Up @@ -378,7 +380,9 @@ foreach(kind ${kinds})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/interpolator/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/coupler/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mosaic2/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/data_override/include>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/data_override/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tridiagonal/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/amip_interp/include>)

target_include_directories(${libTgt} INTERFACE
$<BUILD_INTERFACE:${moduleDir}>
Expand Down
179 changes: 163 additions & 16 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

* Use Fortran 95 standard or newer
* Two space indentation
* Use `KIND` parameters from intrinsic fortran modules such as iso_fortran_env
or iso_c_binding to ensure portability
* Use `KIND` parameters from platform_mod
* Never use implicit variables (i.e., always specify `IMPLICIT NONE`)
* Lines must be <= 120 characters long (including comments)
* logical, compound logical, and relational if statements may be one line,
Expand All @@ -43,7 +42,7 @@
* Inline doxygen descriptions for all member variables.

## Functions
* If a function has a result variable, it should be declared on its own line,
* If a function has a result variable, it should be declared on its own line,
and the variable should not be declared with a specific intent.
* Inline doxygen descriptions for all arguments, except the result variable.
* Doxygen description on the line(s) before the function definition. This must
Expand All @@ -60,9 +59,37 @@
all shared and private variables.
* All critical sections must have a unique name.

## Precision
* Precision of all real arguments are explicitly defined as `real(kind=r4_kind)`,
`real(kind=r8_kind)`, or as any other precision parameters defined in platform_mod.
* The precision of real numerical values should be consistent with the precision
of the associated variable. For example, if the variable `a` has been declared
as r8_kind, then `a=1.4_r8_kind` is acceptable. The following, a=1.4 and a=(1.4,kind=r8_kind),
are not acceptable since the numerical value of 1.4 will be represented in the default precision
set by the compiler.
* The precision of integers do not need to be explicitly defined and can be determined at compile time.
* If the precision of integers are explicitly defined, they are defined with the precision parameters,
_e.g._ i4_kind, i8_kind, found in platform_mod.

## Macros
* All letters in the macro names are capitalized
* All macro names end with an underscore "_"
* All precision related macro names start with the letters "FMS"
* Macro names should be unique to each module. For example,
`FMS_AU_KIND_` is used in axis_utils_mod.
`FMS_HI_KIND_` is used in horiz_interp_mod

## .fh and .inc files
* The .fh header files contain macro definitions.
* If the .fh files contain mainly precision related macro definitions, the files
should be named with `_r4.fh` and `_r8.fh` extensions in the include subdirectory found
in the module directory. These .fh files are `#include`-ed at the end of the .F90 module files.
* For precision related .inc files, the .inc files contain the procedure definitions and are
`#include`-ed at the end of both *_r4.fh and *_f8.fh files. These .inc files are located in the
same include subdirectory as the .fh files. See below for details.
## Fortran Example

```Fortran
```Fortran ./example.F90 file
!***********************************************************************
!* GNU Lesser General Public License
Expand All @@ -89,45 +116,165 @@
!! @email [email protected]
module example_mod
use, intrinsic :: iso_fortran_env, only: INT32, REAL32
use platform_mod, only r4_kind, r8_kind, i4_kind, i8_kind
use util_mod, only: util_func1
implicit none
private
public :: sub1
public :: func1
public :: ex_subroutine
interface ex_subroutine !< generic interface block. When the user
module procedure ex_subroutine_r4 !! calls ex_subroutine, the compiler checks
module procedure ex_subroutine_r8 !! the input arguments and invokes either
end interface ex_subroutine !! ex_subroutine_r4 or ex_subroutine_r8
!! ex_subroutine_r4/8 are generated by the preprocessor
!! which requires example_r4.fh, example_r8.fh, and
!! example.inc files
!> @brief Doxygen description of type.
type,public :: CustomType
private
integer(kind=INT32) :: a_var !< Inline doxygen description.
real(kind=REAL32),dimension(:),allocatable :: b_arr !< long description
!! continued on
!! multiple lines.
integer(kind=i4_kind) :: a_var !< Inline doxygen description.
real(kind=r8_kind),dimension(:),allocatable :: b_arr !< long description
!! continued on
!! multiple lines.
endtype CustomType
contains
!> @brief Doxygen description.
subroutine sub1(arg1, &
& arg2, &
subroutine sub1(arg1, arg2, &
& arg3)
real(kind=REAL32),intent(in) :: arg1 !< Inline doxygen description.
integer(kind=INT32),intent(inout) :: arg2 !< Inline doxygen description.
real(kind=r4_kind),intent(in) :: arg1 !< Inline doxygen description.
integer(kind=i8_kind),intent(inout) :: arg2 !< Inline doxygen description.
character(len=*),intent(inout) :: arg3 !< Long inline doxygen
!! description.
arg1=2.456_r4_kind
end subroutine sub1
!> @brief Doxygen description
!! @return Function return value.
function func1(arg1, arg2) result(res)
integer(kind=INT32),intent(in) :: arg1 !< Inline doxygen description
integer(kind=INT32),intent(in) :: arg2 !< Inline doxygen description
integer(kind=INT32) :: res
integer(kind=i4_kind),intent(in) :: arg1 !< Inline doxygen description
integer(kind=i4_kind),intent(in) :: arg2 !< Inline doxygen description
integer(kind=r8_kind) :: res
res=real(arg1,r8_kind) * 3.14_r8_kind
end function func1
#include "example_r4.fh" !< These two header file contains the macro definition
#include "example_r8.fh" !! and an "#include example.inc" where the procedure
!! is defined. See below.
end module example_mod
```
```Fortran ./include/example_r4.fh file
!***********************************************************************
!* 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/>.
!***********************************************************************
!> @file
!! @brief Example _r4.fh file containing macro definitions
!! @author <developer>
!! @email [email protected]
#undef FMS_EX_KIND_
#define FMS_EX_KIND_ r4_kind
#undef EX_SUBROUTINE_
#define EX_SUBROUTINE_ ex_subroutine_r4
#include "example.inc" !< example.inc file contains the procedure definition
```
```Fortran ./include/example_r8.fh file
!***********************************************************************
!* 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/>.
!***********************************************************************
!> @file
!! @brief Example file _r8.fh file containing macro definitions
!! @author <developer>
!! @email [email protected]
#undef FMS_EX_KIND_
#define FMS_EX_KIND_ r8_kind
#undef EX_SUBROUTINE_
#define EX_SUBROUTINE_ ex_subroutine_r8
#include "example.inc" !< example.inc file contains the procedure definition
```
``` Fortran ./include/example.inc file
!***********************************************************************
!* 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/>.
!***********************************************************************
!> @file
!! @brief Example .inc file containing subroutine definitions/declarations
!! @author <developer>
!! @email [email protected]
!> The macro EX_SUBROUTINE_ gets replaced by the preprocessor
!! as ex_subroutine_r4 (as defined in the example_r4.fh file) and
!! as ex_subroutine r8 (as defined in the example_r8.fh file)
subroutine EX_SUBROUTINE_(arg1, arg2, arg3)
real(FMS_EX_KIND_), intent(in) :: arg2 !< FMS_EX_KIND_ gets replaced by the preprocessor
real(FMS_EX_KIND_), intent(out) :: arg1 !< FMS_EX_KIND_ gets replaced by the preprocessor
integer(i4_kind) :: arg3
integer, parameter :: lkind=FMS_EX_KIND_ !< kind parameter local to the subroutine
arg1 = arg2 / 4.0_lkind !< GCC does not like 4.0_FMS_EX_KIND_. Thus, the
!! parameter lkind is declared and used.
end subroutine EX_SUBROUTINE_
```

## C/C++

Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ endif
# Make targets will be run in each subdirectory. Order is significant.
SUBDIRS = \
platform \
tridiagonal \
mpp \
tridiagonal \
constants \
constants4 \
memutils \
Expand Down
8 changes: 6 additions & 2 deletions amip_interp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@
# Ed Hartnett 2/22/19

# Include .h and .mod files.
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/amip_interp/include
AM_FCFLAGS = $(FC_MODINC). $(FC_MODOUT)$(MODDIR)

# Build this uninstalled convenience library.
noinst_LTLIBRARIES = libamip_interp.la

# The convenience library depends on its source.
libamip_interp_la_SOURCES = amip_interp.F90
libamip_interp_la_SOURCES = \
amip_interp.F90 \
include/amip_interp.inc \
include/amip_interp_r4.fh \
include/amip_interp_r8.fh

BUILT_SOURCES = amip_interp_mod.$(FC_MODEXT)
nodist_include_HEADERS = amip_interp_mod.$(FC_MODEXT)
Expand Down
Loading

0 comments on commit 9f94158

Please sign in to comment.