[1130] | 1 | ! |
---|
| 2 | ! $Id: $ |
---|
| 3 | ! |
---|
| 4 | module planetwide_mod |
---|
| 5 | ! module which contains functions to obtain max/min/... values over the |
---|
| 6 | ! entire globe (trivial in serial mode, but not in parallel) |
---|
| 7 | |
---|
| 8 | use mod_phys_lmdz_para, only : is_master, gather, bcast |
---|
| 9 | |
---|
| 10 | implicit none |
---|
| 11 | |
---|
| 12 | interface planetwide_maxval ! maxval() , over the entire planet |
---|
| 13 | module procedure planetwide_maxval_i1, planetwide_maxval_i2, & |
---|
| 14 | planetwide_maxval_r1, planetwide_maxval_r2 |
---|
| 15 | end interface |
---|
| 16 | |
---|
| 17 | interface planetwide_minval ! minval() , over the entire planet |
---|
| 18 | module procedure planetwide_minval_i1, planetwide_minval_i2, & |
---|
| 19 | planetwide_minval_r1, planetwide_minval_r2 |
---|
| 20 | end interface |
---|
| 21 | |
---|
| 22 | contains |
---|
| 23 | |
---|
| 24 | subroutine planetwide_maxval_i1(values,values_max) |
---|
| 25 | use dimphy, only: klon |
---|
| 26 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 27 | implicit none |
---|
| 28 | integer,intent(in) :: values(:) ! local grid (klon) |
---|
| 29 | integer,intent(out) :: values_max |
---|
| 30 | #ifdef CPP_PARA |
---|
| 31 | integer :: values_glo(klon_glo) ! global grid |
---|
| 32 | |
---|
| 33 | ! gather field on master: |
---|
| 34 | call gather(values,values_glo) |
---|
| 35 | ! extract maximum value |
---|
| 36 | if (is_master) then |
---|
| 37 | values_max=maxval(values_glo) |
---|
| 38 | endif |
---|
| 39 | ! broadcast information to all cores |
---|
| 40 | call bcast(values_max) |
---|
| 41 | #else |
---|
| 42 | values_max=maxval(values) |
---|
| 43 | #endif |
---|
| 44 | end subroutine planetwide_maxval_i1 |
---|
| 45 | |
---|
| 46 | subroutine planetwide_maxval_i2(values,values_max) |
---|
| 47 | use dimphy, only: klon, klev |
---|
| 48 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 49 | implicit none |
---|
| 50 | integer,intent(in) :: values(:,:) ! local grid (klon,klev) |
---|
| 51 | integer,intent(out) :: values_max |
---|
| 52 | #ifdef CPP_PARA |
---|
| 53 | integer :: values_glo(klon_glo,klev) ! global grid |
---|
| 54 | |
---|
| 55 | ! gather field on master: |
---|
| 56 | call gather(values,values_glo) |
---|
| 57 | ! extract maximum value |
---|
| 58 | if (is_master) then |
---|
| 59 | values_max=maxval(values_glo) |
---|
| 60 | endif |
---|
| 61 | ! broadcast information to all cores |
---|
| 62 | call bcast(values_max) |
---|
| 63 | #else |
---|
| 64 | values_max=maxval(values) |
---|
| 65 | #endif |
---|
| 66 | end subroutine planetwide_maxval_i2 |
---|
| 67 | |
---|
| 68 | subroutine planetwide_maxval_r1(values,values_max) |
---|
| 69 | use dimphy, only: klon |
---|
| 70 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 71 | implicit none |
---|
| 72 | real,intent(in) :: values(:) ! local grid (klon) |
---|
| 73 | real,intent(out) :: values_max |
---|
| 74 | #ifdef CPP_PARA |
---|
| 75 | real :: values_glo(klon_glo) ! global grid |
---|
| 76 | |
---|
| 77 | ! gather field on master: |
---|
| 78 | call gather(values,values_glo) |
---|
| 79 | ! extract maximum value |
---|
| 80 | if (is_master) then |
---|
| 81 | values_max=maxval(values_glo) |
---|
| 82 | endif |
---|
| 83 | ! broadcast information to all cores |
---|
| 84 | call bcast(values_max) |
---|
| 85 | #else |
---|
| 86 | values_max=maxval(values) |
---|
| 87 | #endif |
---|
| 88 | end subroutine planetwide_maxval_r1 |
---|
| 89 | |
---|
| 90 | subroutine planetwide_maxval_r2(values,values_max) |
---|
| 91 | use dimphy, only: klon, klev |
---|
| 92 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 93 | implicit none |
---|
| 94 | real,intent(in) :: values(:,:) ! local grid (klon,klev) |
---|
| 95 | real,intent(out) :: values_max |
---|
| 96 | #ifdef CPP_PARA |
---|
| 97 | real :: values_glo(klon_glo,klev) ! global grid |
---|
| 98 | |
---|
| 99 | ! gather field on master: |
---|
| 100 | call gather(values,values_glo) |
---|
| 101 | ! extract maximum value |
---|
| 102 | if (is_master) then |
---|
| 103 | values_max=maxval(values_glo) |
---|
| 104 | endif |
---|
| 105 | ! broadcast information to all cores |
---|
| 106 | call bcast(values_max) |
---|
| 107 | #else |
---|
| 108 | values_max=maxval(values) |
---|
| 109 | #endif |
---|
| 110 | end subroutine planetwide_maxval_r2 |
---|
| 111 | |
---|
| 112 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 113 | |
---|
| 114 | subroutine planetwide_minval_i1(values,values_max) |
---|
| 115 | use dimphy, only: klon |
---|
| 116 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 117 | implicit none |
---|
| 118 | integer,intent(in) :: values(:) ! local grid (klon) |
---|
| 119 | integer,intent(out) :: values_max |
---|
| 120 | #ifdef CPP_PARA |
---|
| 121 | integer :: values_glo(klon_glo) ! global grid |
---|
| 122 | |
---|
| 123 | ! gather field on master: |
---|
| 124 | call gather(values,values_glo) |
---|
| 125 | ! extract maximum value |
---|
| 126 | if (is_master) then |
---|
| 127 | values_max=minval(values_glo) |
---|
| 128 | endif |
---|
| 129 | ! broadcast information to all cores |
---|
| 130 | call bcast(values_max) |
---|
| 131 | #else |
---|
| 132 | values_max=minval(values) |
---|
| 133 | #endif |
---|
| 134 | end subroutine planetwide_minval_i1 |
---|
| 135 | |
---|
| 136 | subroutine planetwide_minval_i2(values,values_max) |
---|
| 137 | use dimphy, only: klon, klev |
---|
| 138 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 139 | implicit none |
---|
| 140 | integer,intent(in) :: values(:,:) ! local grid (klon,klev) |
---|
| 141 | integer,intent(out) :: values_max |
---|
| 142 | #ifdef CPP_PARA |
---|
| 143 | integer :: values_glo(klon_glo,klev) ! global grid |
---|
| 144 | |
---|
| 145 | ! gather field on master: |
---|
| 146 | call gather(values,values_glo) |
---|
| 147 | ! extract maximum value |
---|
| 148 | if (is_master) then |
---|
| 149 | values_max=minval(values_glo) |
---|
| 150 | endif |
---|
| 151 | ! broadcast information to all cores |
---|
| 152 | call bcast(values_max) |
---|
| 153 | #else |
---|
| 154 | values_max=minval(values) |
---|
| 155 | #endif |
---|
| 156 | end subroutine planetwide_minval_i2 |
---|
| 157 | |
---|
| 158 | subroutine planetwide_minval_r1(values,values_max) |
---|
| 159 | use dimphy, only: klon |
---|
| 160 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 161 | implicit none |
---|
| 162 | real,intent(in) :: values(:) ! local grid (klon) |
---|
| 163 | real,intent(out) :: values_max |
---|
| 164 | #ifdef CPP_PARA |
---|
| 165 | real :: values_glo(klon_glo) ! global grid |
---|
| 166 | |
---|
| 167 | ! gather field on master: |
---|
| 168 | call gather(values,values_glo) |
---|
| 169 | ! extract maximum value |
---|
| 170 | if (is_master) then |
---|
| 171 | values_max=minval(values_glo) |
---|
| 172 | endif |
---|
| 173 | ! broadcast information to all cores |
---|
| 174 | call bcast(values_max) |
---|
| 175 | #else |
---|
| 176 | values_max=minval(values) |
---|
| 177 | #endif |
---|
| 178 | end subroutine planetwide_minval_r1 |
---|
| 179 | |
---|
| 180 | subroutine planetwide_minval_r2(values,values_max) |
---|
| 181 | use dimphy, only: klon, klev |
---|
| 182 | use mod_grid_phy_lmdz, only : klon_glo |
---|
| 183 | implicit none |
---|
| 184 | real,intent(in) :: values(:,:) ! local grid (klon,klev) |
---|
| 185 | real,intent(out) :: values_max |
---|
| 186 | #ifdef CPP_PARA |
---|
| 187 | real :: values_glo(klon_glo,klev) ! global grid |
---|
| 188 | |
---|
| 189 | ! gather field on master: |
---|
| 190 | call gather(values,values_glo) |
---|
| 191 | ! extract maximum value |
---|
| 192 | if (is_master) then |
---|
| 193 | values_max=minval(values_glo) |
---|
| 194 | endif |
---|
| 195 | ! broadcast information to all cores |
---|
| 196 | call bcast(values_max) |
---|
| 197 | #else |
---|
| 198 | values_max=minval(values) |
---|
| 199 | #endif |
---|
| 200 | end subroutine planetwide_minval_r2 |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | end module planetwide_mod |
---|