Skip to content

Commit

Permalink
Remove references to Fortran 2018 features
Browse files Browse the repository at this point in the history
The database client interface code used assumed rank notation
introduced in Fortran 2018 to avoid needing to duplicate intefaces
for 1-7 dimensional arrays. However, MOM6 ostensibly accept only
up to Fortran 2008 features and moreover, the inclusion of this
new language feature breaks compilation by PGI.

This is overcome by changing the declaration to assumed size.
For the purposes of compatability with SmartRedis, this change is
still consistent with the implementations of the affected routines.
  • Loading branch information
ashao committed Aug 4, 2022
1 parent 7ad6c2c commit 3b3dc00
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
7 changes: 4 additions & 3 deletions config_src/external/database_comms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ code in the new implementation is part of `MOM_MEKE.F90`.

# File description

- `MOM_database_comms` contains just method signatures and elements of the
- `MOM_database_comms.F90` contains just method signatures and elements of the
control structure that are imported elsewhere within the primary MOM6
code. This includes: `dbcomms_CS_type`, `dbclient_type`, and `database_comms_init`

- `smartredis_client.F90` is a skeleton of the actual SmartRedis library
used to ensure that the interfaces to the library are maintained without
- `database_client_interface.F90` is a skeleton of the a database client library
(for now nominally based on the SmartRedis library). These are included here
so that interfaces to the library can be checked at compile-time without
requiring MOM6 users to compile in the the full library
30 changes: 15 additions & 15 deletions config_src/external/database_comms/database_client_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module database_client_interface
contains

! Public procedures
!> Puts a tensor into the database (overloaded)
!> Puts a tensor into the database for a variety of datatypes
generic :: put_tensor => put_tensor_i8, put_tensor_i16, put_tensor_i32, put_tensor_i64, &
put_tensor_float, put_tensor_double
!> Retrieve the tensor in the database into already allocated memory (overloaded)
!> Retrieve the tensor in the database into already allocated memory for a variety of datatypesm
generic :: unpack_tensor => unpack_tensor_i8, unpack_tensor_i16, unpack_tensor_i32, unpack_tensor_i64, &
unpack_tensor_float, unpack_tensor_double

Expand Down Expand Up @@ -126,7 +126,7 @@ module database_client_interface
procedure :: poll_list_length_gte
!> Repeatedly check the length of the list until it less than or equal to the given size
procedure :: poll_list_length_lte
!> Retrieve vector of datasetes from the list
!> Retrieve vector of datasets from the list
procedure :: get_datasets_from_list

! Private procedures
Expand Down Expand Up @@ -269,7 +269,7 @@ end function poll_key

!> Put a tensor whose Fortran type is the equivalent 'int8' C-type
function put_tensor_i8(self, name, data, dims) result(code)
integer(kind=int8), dimension(..), target, intent(in) :: data !< Data to be sent
integer(kind=int8), dimension(*), target, intent(in) :: data !< Data to be sent
class(dbclient_type), intent(in) :: self !< Fortran communication client
character(len=*), intent(in) :: name !< The unique name used to store in the database
integer, dimension(:), intent(in) :: dims !< The length of each dimension
Expand All @@ -280,7 +280,7 @@ end function put_tensor_i8

!> Put a tensor whose Fortran type is the equivalent 'int16' C-type
function put_tensor_i16(self, name, data, dims) result(code)
integer(kind=int16), dimension(..), target, intent(in) :: data !< Data to be sent
integer(kind=int16), dimension(*), target, intent(in) :: data !< Data to be sent
class(dbclient_type), intent(in) :: self !< Fortran communication client
character(len=*), intent(in) :: name !< The unique name used to store in the database
integer, dimension(:), intent(in) :: dims !< The length of each dimension
Expand All @@ -291,7 +291,7 @@ end function put_tensor_i16

!> Put a tensor whose Fortran type is the equivalent 'int32' C-type
function put_tensor_i32(self, name, data, dims) result(code)
integer(kind=int32), dimension(..), target, intent(in) :: data !< Data to be sent
integer(kind=int32), dimension(*), target, intent(in) :: data !< Data to be sent
class(dbclient_type), intent(in) :: self !< Fortran communication client
character(len=*), intent(in) :: name !< The unique name used to store in the database
integer, dimension(:), intent(in) :: dims !< The length of each dimension
Expand All @@ -302,7 +302,7 @@ end function put_tensor_i32

!> Put a tensor whose Fortran type is the equivalent 'int64' C-type
function put_tensor_i64(self, name, data, dims) result(code)
integer(kind=int64), dimension(..), target, intent(in) :: data !< Data to be sent
integer(kind=int64), dimension(*), target, intent(in) :: data !< Data to be sent
class(dbclient_type), intent(in) :: self !< Fortran communication client
character(len=*), intent(in) :: name !< The unique name used to store in the database
integer, dimension(:), intent(in) :: dims !< The length of each dimension
Expand All @@ -313,7 +313,7 @@ end function put_tensor_i64

!> Put a tensor whose Fortran type is the equivalent 'float' C-type
function put_tensor_float(self, name, data, dims) result(code)
real(kind=real32), dimension(..), target, intent(in) :: data !< Data to be sent
real(kind=real32), dimension(*), target, intent(in) :: data !< Data to be sent
class(dbclient_type), intent(in) :: self !< Fortran communication client
character(len=*), intent(in) :: name !< The unique name used to store in the database
integer, dimension(:), intent(in) :: dims !< The length of each dimension
Expand All @@ -324,7 +324,7 @@ end function put_tensor_float

!> Put a tensor whose Fortran type is the equivalent 'double' C-type
function put_tensor_double(self, name, data, dims) result(code)
real(kind=real64), dimension(..), target, intent(in) :: data !< Data to be sent
real(kind=real64), dimension(*), target, intent(in) :: data !< Data to be sent
class(dbclient_type), intent(in) :: self !< Fortran communication client
character(len=*), intent(in) :: name !< The unique name used to store in the database
integer, dimension(:), intent(in) :: dims !< The length of each dimension
Expand All @@ -335,7 +335,7 @@ end function put_tensor_double

!> Put a tensor whose Fortran type is the equivalent 'int8' C-type
function unpack_tensor_i8(self, name, result, dims) result(code)
integer(kind=int8), dimension(..), target, intent(out) :: result !< Data to be sent
integer(kind=int8), dimension(*), target, intent(out) :: result !< Data to be sent
class(dbclient_type), intent(in) :: self !< Pointer to the initialized client
character(len=*), intent(in) :: name !< The name to use to place the tensor
integer, dimension(:), intent(in) :: dims !< Length along each dimension of the tensor
Expand All @@ -346,7 +346,7 @@ end function unpack_tensor_i8

!> Put a tensor whose Fortran type is the equivalent 'int16' C-type
function unpack_tensor_i16(self, name, result, dims) result(code)
integer(kind=int16), dimension(..), target, intent(out) :: result !< Data to be sent
integer(kind=int16), dimension(*), target, intent(out) :: result !< Data to be sent
class(dbclient_type), intent(in) :: self !< Pointer to the initialized client
character(len=*), intent(in) :: name !< The name to use to place the tensor
integer, dimension(:), intent(in) :: dims !< Length along each dimension of the tensor
Expand All @@ -357,7 +357,7 @@ end function unpack_tensor_i16

!> Put a tensor whose Fortran type is the equivalent 'int32' C-type
function unpack_tensor_i32(self, name, result, dims) result(code)
integer(kind=int32), dimension(..), target, intent(out) :: result !< Data to be sent
integer(kind=int32), dimension(*), target, intent(out) :: result !< Data to be sent
class(dbclient_type), intent(in) :: self !< Pointer to the initialized client
character(len=*), intent(in) :: name !< The name to use to place the tensor
integer, dimension(:), intent(in) :: dims !< Length along each dimension of the tensor
Expand All @@ -368,7 +368,7 @@ end function unpack_tensor_i32

!> Put a tensor whose Fortran type is the equivalent 'int64' C-type
function unpack_tensor_i64(self, name, result, dims) result(code)
integer(kind=int64), dimension(..), target, intent(out) :: result !< Data to be sent
integer(kind=int64), dimension(*), target, intent(out) :: result !< Data to be sent
class(dbclient_type), intent(in) :: self !< Pointer to the initialized client
character(len=*), intent(in) :: name !< The name to use to place the tensor
integer, dimension(:), intent(in) :: dims !< Length along each dimension of the tensor
Expand All @@ -379,7 +379,7 @@ end function unpack_tensor_i64

!> Put a tensor whose Fortran type is the equivalent 'float' C-type
function unpack_tensor_float(self, name, result, dims) result(code)
real(kind=real32), dimension(..), target, intent(out) :: result !< Data to be sent
real(kind=real32), dimension(*), target, intent(out) :: result !< Data to be sent
class(dbclient_type), intent(in) :: self !< Pointer to the initialized client
character(len=*), intent(in) :: name !< The name to use to place the tensor
integer, dimension(:), intent(in) :: dims !< Length along each dimension of the tensor
Expand All @@ -390,7 +390,7 @@ end function unpack_tensor_float

!> Put a tensor whose Fortran type is the equivalent 'double' C-type
function unpack_tensor_double(self, name, result, dims) result(code)
real(kind=real64), dimension(..), target, intent(out) :: result !< Data to be sent
real(kind=real64), dimension(*), target, intent(out) :: result !< Data to be sent
class(dbclient_type), intent(in) :: self !< Pointer to the initialized client
character(len=*), intent(in) :: name !< The name to use to place the tensor
integer, dimension(:), intent(in) :: dims !< Length along each dimension of the tensor
Expand Down

0 comments on commit 3b3dc00

Please sign in to comment.