Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed precision: fms_mod #1147

Merged
merged 16 commits into from
Mar 29, 2023
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,12 @@ foreach(kind ${kinds})

target_include_directories(${libTgt}_f PRIVATE include
fms
fms/include
fms2_io/include
string_utils/include
mpp/include
constants)
constants
test_fms/fms/include)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if test_fms is needed for CMake yet. @rem1776, is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's correct we don't have cmake set up to run the tests so we don't need to compile them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed from CMakeLists.txt in 1a1f887.

target_compile_definitions(${libTgt}_f PRIVATE "${fms_defs}")
target_compile_definitions(${libTgt}_f PRIVATE "${${kind}_defs}")

Expand Down Expand Up @@ -324,8 +327,11 @@ foreach(kind ${kinds})
target_include_directories(${libTgt} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fms>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fms/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fms2_io/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mpp/include>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/string_utils/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mpp/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test_fms/fms/include>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 1a1f887.


target_include_directories(${libTgt} INTERFACE
$<BUILD_INTERFACE:${moduleDir}>
Expand Down
5 changes: 4 additions & 1 deletion fms/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# 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)/fms/include
AM_FCFLAGS = $(FC_MODINC). $(FC_MODOUT)$(MODDIR)

# Build these uninstalled convenience libraries.
Expand All @@ -32,6 +32,9 @@ noinst_LTLIBRARIES = libfms.la
# Each convenience library depends on its source.
libfms_la_SOURCES = \
fms.F90 \
include/fms.inc \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these also needed for fms_mod.$(FC_MODEXT)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include/fms_r4.fh \
include/fms_r8.fh \
fms_io.F90 \
fms_io_unstructured_field_exist.inc \
fms_io_unstructured_get_file_name.inc \
Expand Down
53 changes: 8 additions & 45 deletions fms/fms.F90
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ module fms_mod
use memutils_mod, only: print_memuse_stats, memutils_init
use grid2_mod, only: grid_init, grid_end
use fms_string_utils_mod, only: fms_c2f_string, fms_cstring2cpointer, string
use platform_mod, only: r4_kind, r8_kind

use, intrinsic :: iso_c_binding

Expand Down Expand Up @@ -214,6 +215,10 @@ module fms_mod
! public mpp-io interfaces
public :: do_cf_compliance

interface monotonic_array
module procedure :: monotonic_array_r4, monotonic_array_r8
end interface monotonic_array

!Balaji
!this is published by fms and applied to any initialized clocks
!of course you can go and set the flag to SYNC or DETAILED by hand
Expand Down Expand Up @@ -720,51 +725,6 @@ function string_array_index ( string, string_array, index ) result (found)

end function string_array_index

!#######################################################################

!> @brief Determines if a real input array has monotonically increasing or
!! decreasing values.
!! @return If the input array of real values either increases or decreases monotonically then true
!! is returned, otherwise false is returned.
function monotonic_array ( array, direction )
real, intent(in) :: array(:) !< An array of real values. If the size(array) < 2 this function
!! assumes the array is not monotonic, no fatal error will occur.
integer, intent(out), optional :: direction !< If the input array is:
!! >> monotonic (small to large) then direction = +1.
!! >> monotonic (large to small) then direction = -1.
!! >> not monotonic then direction = 0.
logical :: monotonic_array !< If the input array of real values either increases or decreases monotonically
!! then TRUE is returned, otherwise FALSE is returned.
integer :: i

! initialize
monotonic_array = .false.
if (present(direction)) direction = 0

! array too short
if ( size(array(:)) < 2 ) return

! ascending
if ( array(1) < array(size(array(:))) ) then
do i = 2, size(array(:))
if (array(i-1) < array(i)) cycle
return
enddo
monotonic_array = .true.
if (present(direction)) direction = +1

! descending
else
do i = 2, size(array(:))
if (array(i-1) > array(i)) cycle
return
enddo
monotonic_array = .true.
if (present(direction)) direction = -1
endif

end function monotonic_array

!#######################################################################
!> @brief Prints to the log file (or a specified unit) the version id string and
!! tag name.
Expand Down Expand Up @@ -794,6 +754,9 @@ subroutine write_version_number (version, tag, unit)

end subroutine write_version_number

#include "fms_r4.fh"
#include "fms_r8.fh"

end module fms_mod
! <INFO>
! <BUG>
Expand Down
Loading