Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/macos-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is part of MOM6, the Modular Ocean Model version 6.
# See the LICENSE file for licensing information.
# SPDX-License-Identifier: Apache-2.

name: 'install-macos-prerequisites'

description: 'Install prerequisites for Mac OS compilation'

runs:
using: 'composite'

steps:
- name: Install macOS packages
shell: bash
run: |
echo "::group::Install packages"
brew reinstall gcc
brew install automake
brew install netcdf
brew install netcdf-fortran
brew install openmpi
brew install libyaml
echo "::endgroup::"
33 changes: 33 additions & 0 deletions .github/workflows/github_cmake_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CMake build and unit tests on MacOS

on:
push:
branches:
- main

jobs:
build:
runs-on: macOS-latest
strategy:
matrix:
libyaml-flag: [ "", -DWITH_YAML=on ]
build-type: [ "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_BUILD_TYPE=Debug" ]
env:
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.libyaml-flag }}"
EXCLUDE_TESTS: "test_mpp_nesting|test_mpp_clock_begin_end_id|test_time_*"
CC: gcc-15
FC: gfortran
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/macos-setup/
- name: Generate makefiles with CMake
run: |
mkdir build
cd build
brew shellenv
cmake $CMAKE_FLAGS ..
- name: Build the library
run: |
brew shellenv
make -j -C build

9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ foreach(kind ${kinds})
target_link_libraries(${libTgt}_c PRIVATE OpenMP::OpenMP_C)
endif()

if(YAML_FOUND)
target_link_libraries(${libTgt}_c PRIVATE PkgConfig::YAML)
endif()

# Fortran
add_library(${libTgt}_f OBJECT ${fms_fortran_src_files})

Expand Down Expand Up @@ -459,6 +463,10 @@ if(NOT kinds)
target_link_libraries(${libTgt}_c PRIVATE OpenMP::OpenMP_C)
endif()

if(YAML_FOUND)
target_link_libraries(${libTgt}_c PRIVATE PkgConfig::YAML)
endif()

# Fortran
add_library(${libTgt}_f OBJECT ${fms_fortran_src_files})

Expand Down Expand Up @@ -717,6 +725,7 @@ if(UNIT_TESTS)
test_fms/fms/test_fms.F90
test_fms/interpolator/test_interpolator.F90
test_fms/mpp/test_clock_init.F90
test_fms/mpp/test_corner_mosaic.F90
test_fms/mpp/test_domains_simple.F90
test_fms/mpp/test_domains_utility_mod.F90
test_fms/mpp/test_global_arrays.F90
Expand Down
1 change: 0 additions & 1 deletion diag_manager/diag_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ MODULE diag_output_mod
use mpp_domains_mod, only: mpp_get_UG_io_domain
use mpp_domains_mod, only: mpp_get_UG_domain_npes
use mpp_domains_mod, only: mpp_get_UG_domain_pelist
use mpp_mod, only: mpp_gather
use mpp_mod, only: uppercase,lowercase
use fms2_io_mod

Expand Down
14 changes: 11 additions & 3 deletions diag_manager/fms_diag_axis_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,13 @@ subroutine write_axis_data(this, fms2io_fileobj, parent_axis)
if (present(parent_axis)) then
select type(parent_axis)
type is (fmsDiagFullAxis_type)
call write_data(fms2io_fileobj, this%subaxis_name, parent_axis%axis_data(i:j))
! Added this select type so the the data is indexed correctly
select type (vardata => parent_axis%axis_data)
type is (real(kind=r8_kind))
call write_data(fms2io_fileobj, this%subaxis_name, vardata(i:j))
type is (real(kind=r4_kind))
call write_data(fms2io_fileobj, this%subaxis_name, vardata(i:j))
end select
end select
endif
type is (fmsDiagDiurnalAxis_type)
Expand Down Expand Up @@ -881,8 +887,10 @@ subroutine fill_subaxis(this, starting_index, ending_index, axis_id, parent_id,
if (present(nz_subaxis)) nsubaxis = nz_subaxis

this%axis_id = axis_id
this%starting_index = starting_index
this%ending_index = ending_index

! The min and max were added here to support axis that are both increasing and decreasing
this%starting_index = min(starting_index, ending_index)
this%ending_index = max(starting_index, ending_index)
this%parent_axis_id = parent_id
write(nsubaxis_char, '(i2.2)') nsubaxis
this%subaxis_name = trim(parent_axis_name)//"_sub"//nsubaxis_char
Expand Down
32 changes: 29 additions & 3 deletions fms2_io/include/compressed_write.inc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ subroutine compressed_write_1d(fileobj, variable_name, cdata, unlim_dim_level, &
call error("unsupported variable type: "//trim(append_error_msg))
end select
else
select type(cdata)
select type(cdata)
type is (integer(kind=i4_kind))
allocate(buf_i4_kind(1))
type is (integer(kind=i8_kind))
Expand All @@ -148,7 +148,7 @@ subroutine compressed_write_1d(fileobj, variable_name, cdata, unlim_dim_level, &
allocate(buf_r8_kind(1))
class default
call error("unsupported variable type: "//trim(append_error_msg))
end select
end select
endif

!Gather the data onto the I/O root and write it out.
Expand Down Expand Up @@ -253,6 +253,19 @@ subroutine compressed_write_2d(fileobj, variable_name, cdata, unlim_dim_level, &
class default
call error("unsupported variable type: "//trim(append_error_msg))
end select
else
select type(cdata)
type is (integer(kind=i4_kind))
allocate(buf_i4_kind(1, 1))
type is (integer(kind=i8_kind))
allocate(buf_i8_kind(1, 1))
type is (real(kind=r4_kind))
allocate(buf_r4_kind(1, 1))
type is (real(kind=r8_kind))
allocate(buf_r8_kind(1, 1))
class default
call error("unsupported variable type: "//trim(append_error_msg))
end select
endif

c(:) = 1
Expand Down Expand Up @@ -376,7 +389,20 @@ subroutine compressed_write_3d(fileobj, variable_name, cdata, unlim_dim_level, &
call allocate_array(buf_r8_kind, e)
class default
call error("unsupported variable type: "//trim(append_error_msg))
end select
end select
else
select type(cdata)
type is (integer(kind=i4_kind))
allocate(buf_i4_kind(1, 1, 1))
type is (integer(kind=i8_kind))
allocate(buf_i8_kind(1, 1, 1))
type is (real(kind=r4_kind))
allocate(buf_r4_kind(1, 1, 1))
type is (real(kind=r8_kind))
allocate(buf_r8_kind(1, 1, 1))
class default
call error("unsupported variable type: "//trim(append_error_msg))
end select
endif

c(:) = 1
Expand Down
53 changes: 25 additions & 28 deletions fms2_io/include/domain_read.inc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ subroutine domain_read_2d(fileobj, variable_name, vdata, unlim_dim_level, &
integer :: xgsize !< Size of global x io domain
integer :: ygbegin !< Starting y index of global io domain
integer :: ygsize !< Size of global y io domain
integer :: dim_order(2) !< Order of the dimensions
type(domain2d), pointer :: io_domain !< pointer to the io_domain

!< The global data is only allocated by the io root PEs
Expand Down Expand Up @@ -164,14 +165,6 @@ subroutine domain_read_2d(fileobj, variable_name, vdata, unlim_dim_level, &
return
endif

if (xdim_index .ne. 1 .or. ydim_index .ne. 2) then
! This is a KLUDGE
! mpp_scatter assumes that the variable is (x,y), if that is not the case it remaps the data
! to a 4D array and calls domain_read_4d which does not use mpp_scatter yet
vdata_dummy(1:size(vdata,1),1:size(vdata,2), 1:1, 1:1) => vdata(:,:)
call domain_read_4d(fileobj, variable_name, vdata_dummy, unlim_dim_level)
return
endif
io_domain => mpp_get_io_domain(fileobj%domain)
c(:) = 1
e(:) = shape(vdata)
Expand Down Expand Up @@ -240,29 +233,32 @@ subroutine domain_read_2d(fileobj, variable_name, vdata, unlim_dim_level, &
e(xdim_index) = xc_size
e(ydim_index) = yc_size

dim_order(xdim_index) = 1
dim_order(ydim_index) = 2

select type(vdata)
type is (integer(kind=i4_kind))
call allocate_array(buf_i4_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
buf_i4_kind_pe, buf_i4_kind, fileobj%is_root)
buf_i4_kind_pe, buf_i4_kind, dim_order, fileobj%is_root)
call put_array_section(buf_i4_kind_pe, vdata, c, e)
deallocate(buf_i4_kind_pe)
type is (integer(kind=i8_kind))
call allocate_array(buf_i8_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
buf_i8_kind_pe, buf_i8_kind, fileobj%is_root)
buf_i8_kind_pe, buf_i8_kind, dim_order, fileobj%is_root)
call put_array_section(buf_i8_kind_pe, vdata, c, e)
deallocate(buf_i8_kind_pe)
type is (real(kind=r4_kind))
call allocate_array(buf_r4_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
buf_r4_kind_pe, buf_r4_kind, fileobj%is_root)
buf_r4_kind_pe, buf_r4_kind, dim_order, fileobj%is_root)
call put_array_section(buf_r4_kind_pe, vdata, c, e)
deallocate(buf_r4_kind_pe)
type is (real(kind=r8_kind))
call allocate_array(buf_r8_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
buf_r8_kind_pe, buf_r8_kind, fileobj%is_root)
buf_r8_kind_pe, buf_r8_kind, dim_order, fileobj%is_root)
call put_array_section(buf_r8_kind_pe, vdata, c, e)
deallocate(buf_r8_kind_pe)
class default
Expand Down Expand Up @@ -304,6 +300,7 @@ subroutine domain_read_3d(fileobj, variable_name, vdata, unlim_dim_level, &

integer :: xdim_index !< The index of the variable that is the x dimension
integer :: ydim_index !< The index of the variable that is the y dimension
integer :: zdim_index !< The index of the variable that is the z dimension
integer :: xpos !< The position of the x axis
integer :: ypos !< The position of the y axis
integer :: i !< For do loops
Expand All @@ -320,6 +317,7 @@ subroutine domain_read_3d(fileobj, variable_name, vdata, unlim_dim_level, &
integer :: xgsize !< Size of global x io domain
integer :: ygbegin !< Starting y index of global io domain
integer :: ygsize !< Size of global y io domain
integer :: dim_order(3) !< Order of the dimensions
type(domain2d), pointer :: io_domain !< pointer to the io_domain

!< The global data is only allocated by the io root PEs
Expand Down Expand Up @@ -365,14 +363,6 @@ subroutine domain_read_3d(fileobj, variable_name, vdata, unlim_dim_level, &
return
endif

if (xdim_index .ne. 1 .or. ydim_index .ne. 2) then
! This is a KLUDGE
! mpp_scatter assumes that the variable is (x,y), if that is not the case it remaps the data
! to a 4D array and calls domain_read_4d which does not use mpp_scatter yet
vdata_dummy(1:size(vdata,1),1:size(vdata,2), 1:size(vdata,3), 1:1) => vdata(:,:,:)
call domain_read_4d(fileobj, variable_name, vdata_dummy, unlim_dim_level)
return
endif
io_domain => mpp_get_io_domain(fileobj%domain)
c(:) = 1
if (present(corner)) c = corner
Expand Down Expand Up @@ -444,29 +434,36 @@ subroutine domain_read_3d(fileobj, variable_name, vdata, unlim_dim_level, &
e(xdim_index) = xc_size
e(ydim_index) = yc_size

! Calculate the index of the z dimension
zdim_index = 6 - xdim_index - ydim_index

dim_order(xdim_index) = 1
dim_order(ydim_index) = 2
dim_order(zdim_index) = 3

select type(vdata)
type is (integer(kind=i4_kind))
call allocate_array(buf_i4_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
buf_i4_kind_pe, buf_i4_kind, fileobj%is_root)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(zdim_index), &
fileobj%pelist, buf_i4_kind_pe, buf_i4_kind, dim_order, fileobj%is_root)
call put_array_section(buf_i4_kind_pe, vdata, c, e)
deallocate(buf_i4_kind_pe)
type is (integer(kind=i8_kind))
call allocate_array(buf_i8_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
buf_i8_kind_pe, buf_i8_kind, fileobj%is_root)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(zdim_index), &
fileobj%pelist, buf_i8_kind_pe, buf_i8_kind, dim_order, fileobj%is_root)
call put_array_section(buf_i8_kind_pe, vdata, c, e)
deallocate(buf_i8_kind_pe)
type is (real(kind=r4_kind))
call allocate_array(buf_r4_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
buf_r4_kind_pe, buf_r4_kind, fileobj%is_root)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(zdim_index), &
fileobj%pelist, buf_r4_kind_pe, buf_r4_kind, dim_order, fileobj%is_root)
call put_array_section(buf_r4_kind_pe, vdata, c, e)
deallocate(buf_r4_kind_pe)
type is (real(kind=r8_kind))
call allocate_array(buf_r8_kind_pe, e)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
buf_r8_kind_pe, buf_r8_kind, fileobj%is_root)
call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(zdim_index), &
fileobj%pelist, buf_r8_kind_pe, buf_r8_kind, dim_order, fileobj%is_root)
call put_array_section(buf_r8_kind_pe, vdata, c, e)
deallocate(buf_r8_kind_pe)
class default
Expand Down
Loading
Loading