|
| 1 | +!*********************************************************************** |
| 2 | +!* GNU Lesser General Public License |
| 3 | +!* |
| 4 | +!* This file is part of the GFDL Flexible Modeling System (FMS). |
| 5 | +!* |
| 6 | +!* FMS is free software: you can redistribute it and/or modify it under |
| 7 | +!* the terms of the GNU Lesser General Public License as published by |
| 8 | +!* the Free Software Foundation, either version 3 of the License, or (at |
| 9 | +!* your option) any later version. |
| 10 | +!* |
| 11 | +!* FMS is distributed in the hope that it will be useful, but WITHOUT |
| 12 | +!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | +!* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | +!* for more details. |
| 15 | +!* |
| 16 | +!* You should have received a copy of the GNU Lesser General Public |
| 17 | +!* License along with FMS. If not, see <http://www.gnu.org/licenses/>. |
| 18 | +!*********************************************************************** |
| 19 | + |
| 20 | +program test_block_control |
| 21 | + use fms_mod, only: fms_init, fms_end |
| 22 | + use mpp_domains_mod, only: domain2d, mpp_define_domains, mpp_get_compute_domain |
| 23 | + use block_control_mod, only: block_control_type, define_blocks |
| 24 | + use mpp_mod, only: mpp_pe, mpp_root_pe, mpp_error, FATAL |
| 25 | + use fms_string_utils_mod, only: string |
| 26 | + |
| 27 | + implicit none |
| 28 | + |
| 29 | + integer, parameter :: nx=96 !< Size of the x grid |
| 30 | + integer, parameter :: ny=96 !< Size of the y grid |
| 31 | + type(domain2d) :: Domain !< 2D domain |
| 32 | + integer :: layout(2) = (/2, 3/) !< Layout of the domain |
| 33 | + type(block_control_type) :: my_block !< Block control type |
| 34 | + integer :: isc, iec, jsc, jec !< Starting and ending index for the commute domain |
| 35 | + integer :: expected_startingy !< Expected starting y index for the current block |
| 36 | + integer :: expected_endingy !< Expected ending y index for the current block |
| 37 | + integer :: ncy(3) !< Size of the y for each block |
| 38 | + logical :: message !< Set to .True., to output the warning message |
| 39 | + integer :: i !< For do loops |
| 40 | + |
| 41 | + call fms_init() |
| 42 | + message = .True. !< Needs to be .true. so that the error message can be printed |
| 43 | + call mpp_define_domains( (/1,nx,1,ny/), layout, Domain) |
| 44 | + call mpp_get_compute_domain(Domain, isc, iec, jsc, jec) |
| 45 | + call define_blocks ('testing_model', my_block, isc, iec, jsc, jec, kpts=0, & |
| 46 | + nx_block=1, ny_block=3, message=message) |
| 47 | + |
| 48 | + !< Message will be set to .false. if the blocks are not uniform |
| 49 | + if (message) & |
| 50 | + call mpp_error(FATAL, "test_block_control::define_blocks did not output the warning message"//& |
| 51 | + " about uneven blocks") |
| 52 | + |
| 53 | + !Expected size of each block for every PE |
| 54 | + ncy = (/11, 10, 11/) |
| 55 | + expected_endingy = jsc-1 |
| 56 | + do i = 1, 3 |
| 57 | + ! Check the starting and ending "x" indices for each block |
| 58 | + if (my_block%ibs(i) .ne. isc .or. my_block%ibe(i) .ne. iec) & |
| 59 | + call mpp_error(FATAL, "The starting and ending 'x' index for the "//string(i)//" block is not expected value!") |
| 60 | + |
| 61 | + ! Check the starting and ending "y" indices for each block |
| 62 | + expected_startingy = expected_endingy + 1 |
| 63 | + expected_endingy = expected_startingy + ncy(i) - 1 |
| 64 | + if (my_block%jbs(i) .ne. expected_startingy .or. my_block%jbe(i) .ne. expected_endingy) & |
| 65 | + call mpp_error(FATAL, "The starting and ending 'y' index for the "//string(i)//" block is not expected value!") |
| 66 | + enddo |
| 67 | + |
| 68 | + call fms_end() |
| 69 | +end program |
0 commit comments