[102] | 1 | SUBROUTINE surface_coupler |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
[258] | 4 | ! Current revisions: |
---|
[102] | 5 | ! ----------------- |
---|
[881] | 6 | ! |
---|
[102] | 7 | ! |
---|
| 8 | ! Former revisions: |
---|
| 9 | ! ------------------ |
---|
| 10 | ! $Id: surface_coupler.f90 881 2012-04-13 06:36:58Z maronga $ |
---|
| 11 | ! |
---|
[881] | 12 | ! 880 2012-04-13 06:28:59Z raasch |
---|
| 13 | ! Bugfix: preprocessor statements for parallel execution added |
---|
| 14 | ! |
---|
[710] | 15 | ! 709 2011-03-30 09:31:40Z raasch |
---|
| 16 | ! formatting adjustments |
---|
| 17 | ! |
---|
[668] | 18 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
[709] | 19 | ! Additional case for nonequivalent processor and grid topopolgy in ocean and |
---|
| 20 | ! atmosphere added (coupling_topology = 1). |
---|
[668] | 21 | ! Added exchange of u and v from Ocean to Atmosphere |
---|
| 22 | ! |
---|
[392] | 23 | ! 291 2009-04-16 12:07:26Z raasch |
---|
| 24 | ! Coupling with independent precursor runs. |
---|
| 25 | ! Output of messages replaced by message handling routine. |
---|
| 26 | ! |
---|
[226] | 27 | ! 206 2008-10-13 14:59:11Z raasch |
---|
| 28 | ! Implementation of a MPI-1 Coupling: replaced myid with target_id, |
---|
| 29 | ! deleted __mpi2 directives |
---|
| 30 | ! |
---|
[110] | 31 | ! 109 2007-08-28 15:26:47Z letzel |
---|
[102] | 32 | ! Initial revision |
---|
| 33 | ! |
---|
| 34 | ! Description: |
---|
| 35 | ! ------------ |
---|
| 36 | ! Data exchange at the interface between coupled models |
---|
| 37 | !------------------------------------------------------------------------------! |
---|
| 38 | |
---|
| 39 | USE arrays_3d |
---|
| 40 | USE control_parameters |
---|
| 41 | USE cpulog |
---|
| 42 | USE grid_variables |
---|
| 43 | USE indices |
---|
| 44 | USE interfaces |
---|
| 45 | USE pegrid |
---|
| 46 | |
---|
| 47 | IMPLICIT NONE |
---|
| 48 | |
---|
[108] | 49 | INTEGER :: i, j, k |
---|
[102] | 50 | |
---|
[291] | 51 | REAL :: time_since_reference_point_rem |
---|
[667] | 52 | REAL :: total_2d(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
[102] | 53 | |
---|
[206] | 54 | #if defined( __parallel ) |
---|
[102] | 55 | |
---|
[667] | 56 | CALL cpu_log( log_point(39), 'surface_coupler', 'start' ) |
---|
[102] | 57 | |
---|
[667] | 58 | |
---|
| 59 | |
---|
[102] | 60 | ! |
---|
[108] | 61 | !-- In case of model termination initiated by the remote model |
---|
| 62 | !-- (terminate_coupled_remote > 0), initiate termination of the local model. |
---|
| 63 | !-- The rest of the coupler must then be skipped because it would cause an MPI |
---|
| 64 | !-- intercomminucation hang. |
---|
| 65 | !-- If necessary, the coupler will be called at the beginning of the next |
---|
| 66 | !-- restart run. |
---|
[667] | 67 | |
---|
| 68 | IF ( coupling_topology == 0 ) THEN |
---|
[709] | 69 | CALL MPI_SENDRECV( terminate_coupled, 1, MPI_INTEGER, target_id, & |
---|
| 70 | 0, & |
---|
| 71 | terminate_coupled_remote, 1, MPI_INTEGER, target_id, & |
---|
[667] | 72 | 0, comm_inter, status, ierr ) |
---|
| 73 | ELSE |
---|
| 74 | IF ( myid == 0) THEN |
---|
| 75 | CALL MPI_SENDRECV( terminate_coupled, 1, MPI_INTEGER, & |
---|
| 76 | target_id, 0, & |
---|
| 77 | terminate_coupled_remote, 1, MPI_INTEGER, & |
---|
| 78 | target_id, 0, & |
---|
| 79 | comm_inter, status, ierr ) |
---|
| 80 | ENDIF |
---|
[709] | 81 | CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_INTEGER, 0, comm2d, & |
---|
| 82 | ierr ) |
---|
[667] | 83 | |
---|
| 84 | ALLOCATE( total_2d_a(-nbgp:ny_a+nbgp,-nbgp:nx_a+nbgp), & |
---|
| 85 | total_2d_o(-nbgp:ny_o+nbgp,-nbgp:nx_o+nbgp) ) |
---|
| 86 | |
---|
| 87 | ENDIF |
---|
| 88 | |
---|
[108] | 89 | IF ( terminate_coupled_remote > 0 ) THEN |
---|
[274] | 90 | WRITE( message_string, * ) 'remote model "', & |
---|
| 91 | TRIM( coupling_mode_remote ), & |
---|
| 92 | '" terminated', & |
---|
| 93 | '&with terminate_coupled_remote = ', & |
---|
| 94 | terminate_coupled_remote, & |
---|
| 95 | '&local model "', TRIM( coupling_mode ), & |
---|
| 96 | '" has', & |
---|
| 97 | '&terminate_coupled = ', & |
---|
[667] | 98 | terminate_coupled |
---|
[258] | 99 | CALL message( 'surface_coupler', 'PA0310', 1, 2, 0, 6, 0 ) |
---|
[108] | 100 | RETURN |
---|
| 101 | ENDIF |
---|
[667] | 102 | |
---|
[291] | 103 | |
---|
[108] | 104 | ! |
---|
| 105 | !-- Exchange the current simulated time between the models, |
---|
[667] | 106 | !-- currently just for total_2ding |
---|
[709] | 107 | IF ( coupling_topology == 0 ) THEN |
---|
| 108 | |
---|
| 109 | CALL MPI_SEND( time_since_reference_point, 1, MPI_REAL, target_id, 11, & |
---|
| 110 | comm_inter, ierr ) |
---|
| 111 | CALL MPI_RECV( time_since_reference_point_rem, 1, MPI_REAL, target_id, & |
---|
| 112 | 11, comm_inter, status, ierr ) |
---|
[667] | 113 | ELSE |
---|
[709] | 114 | |
---|
[667] | 115 | IF ( myid == 0 ) THEN |
---|
[709] | 116 | |
---|
| 117 | CALL MPI_SEND( time_since_reference_point, 1, MPI_REAL, target_id, & |
---|
| 118 | 11, comm_inter, ierr ) |
---|
| 119 | CALL MPI_RECV( time_since_reference_point_rem, 1, MPI_REAL, & |
---|
[667] | 120 | target_id, 11, comm_inter, status, ierr ) |
---|
[709] | 121 | |
---|
[667] | 122 | ENDIF |
---|
[709] | 123 | |
---|
| 124 | CALL MPI_BCAST( time_since_reference_point_rem, 1, MPI_REAL, 0, comm2d, & |
---|
| 125 | ierr ) |
---|
| 126 | |
---|
[667] | 127 | ENDIF |
---|
[102] | 128 | |
---|
| 129 | ! |
---|
| 130 | !-- Exchange the interface data |
---|
| 131 | IF ( coupling_mode == 'atmosphere_to_ocean' ) THEN |
---|
[667] | 132 | |
---|
| 133 | ! |
---|
[709] | 134 | !-- Horizontal grid size and number of processors is equal in ocean and |
---|
| 135 | !-- atmosphere |
---|
| 136 | IF ( coupling_topology == 0 ) THEN |
---|
[102] | 137 | |
---|
| 138 | ! |
---|
[709] | 139 | !-- Send heat flux at bottom surface to the ocean |
---|
| 140 | CALL MPI_SEND( shf(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 12, & |
---|
| 141 | comm_inter, ierr ) |
---|
[102] | 142 | ! |
---|
[709] | 143 | !-- Send humidity flux at bottom surface to the ocean |
---|
[667] | 144 | IF ( humidity ) THEN |
---|
[709] | 145 | CALL MPI_SEND( qsws(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 13, & |
---|
| 146 | comm_inter, ierr ) |
---|
[667] | 147 | ENDIF |
---|
| 148 | ! |
---|
[709] | 149 | !-- Receive temperature at the bottom surface from the ocean |
---|
| 150 | CALL MPI_RECV( pt(0,nysg,nxlg), 1, type_xy, target_id, 14, & |
---|
| 151 | comm_inter, status, ierr ) |
---|
[108] | 152 | ! |
---|
[709] | 153 | !-- Send the momentum flux (u) at bottom surface to the ocean |
---|
| 154 | CALL MPI_SEND( usws(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 15, & |
---|
| 155 | comm_inter, ierr ) |
---|
[102] | 156 | ! |
---|
[709] | 157 | !-- Send the momentum flux (v) at bottom surface to the ocean |
---|
| 158 | CALL MPI_SEND( vsws(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 16, & |
---|
| 159 | comm_inter, ierr ) |
---|
[102] | 160 | ! |
---|
[709] | 161 | !-- Receive u at the bottom surface from the ocean |
---|
| 162 | CALL MPI_RECV( u(0,nysg,nxlg), 1, type_xy, target_id, 17, & |
---|
| 163 | comm_inter, status, ierr ) |
---|
[667] | 164 | ! |
---|
[709] | 165 | !-- Receive v at the bottom surface from the ocean |
---|
| 166 | CALL MPI_RECV( v(0,nysg,nxlg), 1, type_xy, target_id, 18, & |
---|
| 167 | comm_inter, status, ierr ) |
---|
[667] | 168 | ! |
---|
| 169 | !-- Horizontal grid size or number of processors differs between |
---|
| 170 | !-- ocean and atmosphere |
---|
| 171 | ELSE |
---|
| 172 | |
---|
| 173 | ! |
---|
[709] | 174 | !-- Send heat flux at bottom surface to the ocean |
---|
[667] | 175 | total_2d_a = 0.0 |
---|
[709] | 176 | total_2d = 0.0 |
---|
[667] | 177 | total_2d(nys:nyn,nxl:nxr) = shf(nys:nyn,nxl:nxr) |
---|
[709] | 178 | |
---|
| 179 | CALL MPI_REDUCE( total_2d, total_2d_a, ngp_a, MPI_REAL, MPI_SUM, 0, & |
---|
| 180 | comm2d, ierr ) |
---|
| 181 | CALL interpolate_to_ocean( 12 ) |
---|
[667] | 182 | ! |
---|
[709] | 183 | !-- Send humidity flux at bottom surface to the ocean |
---|
| 184 | IF ( humidity ) THEN |
---|
[667] | 185 | total_2d_a = 0.0 |
---|
[709] | 186 | total_2d = 0.0 |
---|
[667] | 187 | total_2d(nys:nyn,nxl:nxr) = qsws(nys:nyn,nxl:nxr) |
---|
[709] | 188 | |
---|
| 189 | CALL MPI_REDUCE( total_2d, total_2d_a, ngp_a, MPI_REAL, MPI_SUM, & |
---|
| 190 | 0, comm2d, ierr ) |
---|
| 191 | CALL interpolate_to_ocean( 13 ) |
---|
[667] | 192 | ENDIF |
---|
| 193 | ! |
---|
[709] | 194 | !-- Receive temperature at the bottom surface from the ocean |
---|
| 195 | IF ( myid == 0 ) THEN |
---|
[667] | 196 | CALL MPI_RECV( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, & |
---|
| 197 | target_id, 14, comm_inter, status, ierr ) |
---|
| 198 | ENDIF |
---|
| 199 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 200 | CALL MPI_BCAST( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, 0, comm2d, & |
---|
| 201 | ierr ) |
---|
[667] | 202 | pt(0,nysg:nyng,nxlg:nxrg) = total_2d_a(nysg:nyng,nxlg:nxrg) |
---|
| 203 | ! |
---|
[709] | 204 | !-- Send momentum flux (u) at bottom surface to the ocean |
---|
[667] | 205 | total_2d_a = 0.0 |
---|
[709] | 206 | total_2d = 0.0 |
---|
[667] | 207 | total_2d(nys:nyn,nxl:nxr) = usws(nys:nyn,nxl:nxr) |
---|
[709] | 208 | CALL MPI_REDUCE( total_2d, total_2d_a, ngp_a, MPI_REAL, MPI_SUM, 0, & |
---|
| 209 | comm2d, ierr ) |
---|
| 210 | CALL interpolate_to_ocean( 15 ) |
---|
[667] | 211 | ! |
---|
[709] | 212 | !-- Send momentum flux (v) at bottom surface to the ocean |
---|
[667] | 213 | total_2d_a = 0.0 |
---|
[709] | 214 | total_2d = 0.0 |
---|
[667] | 215 | total_2d(nys:nyn,nxl:nxr) = vsws(nys:nyn,nxl:nxr) |
---|
[709] | 216 | CALL MPI_REDUCE( total_2d, total_2d_a, ngp_a, MPI_REAL, MPI_SUM, 0, & |
---|
| 217 | comm2d, ierr ) |
---|
| 218 | CALL interpolate_to_ocean( 16 ) |
---|
[667] | 219 | ! |
---|
[709] | 220 | !-- Receive u at the bottom surface from the ocean |
---|
| 221 | IF ( myid == 0 ) THEN |
---|
[667] | 222 | CALL MPI_RECV( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, & |
---|
[709] | 223 | target_id, 17, comm_inter, status, ierr ) |
---|
[667] | 224 | ENDIF |
---|
| 225 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 226 | CALL MPI_BCAST( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, 0, comm2d, & |
---|
| 227 | ierr ) |
---|
[667] | 228 | u(0,nysg:nyng,nxlg:nxrg) = total_2d_a(nysg:nyng,nxlg:nxrg) |
---|
| 229 | ! |
---|
[709] | 230 | !-- Receive v at the bottom surface from the ocean |
---|
| 231 | IF ( myid == 0 ) THEN |
---|
[667] | 232 | CALL MPI_RECV( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, & |
---|
[709] | 233 | target_id, 18, comm_inter, status, ierr ) |
---|
[667] | 234 | ENDIF |
---|
| 235 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 236 | CALL MPI_BCAST( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, 0, comm2d, & |
---|
| 237 | ierr ) |
---|
[667] | 238 | v(0,nysg:nyng,nxlg:nxrg) = total_2d_a(nysg:nyng,nxlg:nxrg) |
---|
| 239 | |
---|
| 240 | ENDIF |
---|
| 241 | |
---|
[102] | 242 | ELSEIF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
| 243 | |
---|
| 244 | ! |
---|
[667] | 245 | !-- Horizontal grid size and number of processors is equal |
---|
| 246 | !-- in ocean and atmosphere |
---|
| 247 | IF ( coupling_topology == 0 ) THEN |
---|
| 248 | ! |
---|
[709] | 249 | !-- Receive heat flux at the sea surface (top) from the atmosphere |
---|
| 250 | CALL MPI_RECV( tswst(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 12, & |
---|
| 251 | comm_inter, status, ierr ) |
---|
[102] | 252 | ! |
---|
[709] | 253 | !-- Receive humidity flux from the atmosphere (bottom) |
---|
[667] | 254 | !-- and add it to the heat flux at the sea surface (top)... |
---|
| 255 | IF ( humidity_remote ) THEN |
---|
| 256 | CALL MPI_RECV( qswst_remote(nysg,nxlg), ngp_xy, MPI_REAL, & |
---|
| 257 | target_id, 13, comm_inter, status, ierr ) |
---|
| 258 | ENDIF |
---|
| 259 | ! |
---|
| 260 | !-- Send sea surface temperature to the atmosphere model |
---|
[709] | 261 | CALL MPI_SEND( pt(nzt,nysg,nxlg), 1, type_xy, target_id, 14, & |
---|
| 262 | comm_inter, ierr ) |
---|
[667] | 263 | ! |
---|
| 264 | !-- Receive momentum flux (u) at the sea surface (top) from the atmosphere |
---|
[709] | 265 | CALL MPI_RECV( uswst(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 15, & |
---|
| 266 | comm_inter, status, ierr ) |
---|
[667] | 267 | ! |
---|
| 268 | !-- Receive momentum flux (v) at the sea surface (top) from the atmosphere |
---|
[709] | 269 | CALL MPI_RECV( vswst(nysg,nxlg), ngp_xy, MPI_REAL, target_id, 16, & |
---|
| 270 | comm_inter, status, ierr ) |
---|
[667] | 271 | ! |
---|
[709] | 272 | !-- Send u to the atmosphere |
---|
| 273 | CALL MPI_SEND( u(nzt,nysg,nxlg), 1, type_xy, target_id, 17, & |
---|
| 274 | comm_inter, ierr ) |
---|
[667] | 275 | ! |
---|
[709] | 276 | !-- Send v to the atmosphere |
---|
| 277 | CALL MPI_SEND( v(nzt,nysg,nxlg), 1, type_xy, target_id, 18, & |
---|
| 278 | comm_inter, ierr ) |
---|
| 279 | ! |
---|
[667] | 280 | !-- Horizontal gridsize or number of processors differs between |
---|
| 281 | !-- ocean and atmosphere |
---|
| 282 | ELSE |
---|
| 283 | ! |
---|
[709] | 284 | !-- Receive heat flux at the sea surface (top) from the atmosphere |
---|
| 285 | IF ( myid == 0 ) THEN |
---|
[667] | 286 | CALL MPI_RECV( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, & |
---|
[709] | 287 | target_id, 12, comm_inter, status, ierr ) |
---|
[667] | 288 | ENDIF |
---|
| 289 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 290 | CALL MPI_BCAST( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, 0, comm2d, & |
---|
| 291 | ierr ) |
---|
[667] | 292 | tswst(nysg:nyng,nxlg:nxrg) = total_2d_o(nysg:nyng,nxlg:nxrg) |
---|
| 293 | ! |
---|
[709] | 294 | !-- Receive humidity flux at the sea surface (top) from the atmosphere |
---|
| 295 | IF ( humidity_remote ) THEN |
---|
| 296 | IF ( myid == 0 ) THEN |
---|
[667] | 297 | CALL MPI_RECV( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, & |
---|
[709] | 298 | target_id, 13, comm_inter, status, ierr ) |
---|
[667] | 299 | ENDIF |
---|
| 300 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 301 | CALL MPI_BCAST( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, 0, & |
---|
| 302 | comm2d, ierr) |
---|
[667] | 303 | qswst_remote(nysg:nyng,nxlg:nxrg) = total_2d_o(nysg:nyng,nxlg:nxrg) |
---|
| 304 | ENDIF |
---|
| 305 | ! |
---|
| 306 | !-- Send surface temperature to atmosphere |
---|
| 307 | total_2d_o = 0.0 |
---|
[709] | 308 | total_2d = 0.0 |
---|
[667] | 309 | total_2d(nys:nyn,nxl:nxr) = pt(nzt,nys:nyn,nxl:nxr) |
---|
| 310 | |
---|
[709] | 311 | CALL MPI_REDUCE( total_2d, total_2d_o, ngp_o, MPI_REAL, MPI_SUM, 0, & |
---|
| 312 | comm2d, ierr) |
---|
| 313 | CALL interpolate_to_atmos( 14 ) |
---|
[667] | 314 | ! |
---|
[709] | 315 | !-- Receive momentum flux (u) at the sea surface (top) from the atmosphere |
---|
| 316 | IF ( myid == 0 ) THEN |
---|
[667] | 317 | CALL MPI_RECV( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, & |
---|
[709] | 318 | target_id, 15, comm_inter, status, ierr ) |
---|
[667] | 319 | ENDIF |
---|
| 320 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 321 | CALL MPI_BCAST( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, & |
---|
[709] | 322 | 0, comm2d, ierr ) |
---|
[667] | 323 | uswst(nysg:nyng,nxlg:nxrg) = total_2d_o(nysg:nyng,nxlg:nxrg) |
---|
| 324 | ! |
---|
[709] | 325 | !-- Receive momentum flux (v) at the sea surface (top) from the atmosphere |
---|
| 326 | IF ( myid == 0 ) THEN |
---|
[667] | 327 | CALL MPI_RECV( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, & |
---|
[709] | 328 | target_id, 16, comm_inter, status, ierr ) |
---|
[667] | 329 | ENDIF |
---|
| 330 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 331 | CALL MPI_BCAST( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, 0, comm2d, & |
---|
| 332 | ierr ) |
---|
[667] | 333 | vswst(nysg:nyng,nxlg:nxrg) = total_2d_o(nysg:nyng,nxlg:nxrg) |
---|
| 334 | ! |
---|
| 335 | !-- Send u to atmosphere |
---|
| 336 | total_2d_o = 0.0 |
---|
[709] | 337 | total_2d = 0.0 |
---|
[667] | 338 | total_2d(nys:nyn,nxl:nxr) = u(nzt,nys:nyn,nxl:nxr) |
---|
[709] | 339 | CALL MPI_REDUCE( total_2d, total_2d_o, ngp_o, MPI_REAL, MPI_SUM, 0, & |
---|
| 340 | comm2d, ierr ) |
---|
| 341 | CALL interpolate_to_atmos( 17 ) |
---|
[667] | 342 | ! |
---|
| 343 | !-- Send v to atmosphere |
---|
| 344 | total_2d_o = 0.0 |
---|
[709] | 345 | total_2d = 0.0 |
---|
[667] | 346 | total_2d(nys:nyn,nxl:nxr) = v(nzt,nys:nyn,nxl:nxr) |
---|
[709] | 347 | CALL MPI_REDUCE( total_2d, total_2d_o, ngp_o, MPI_REAL, MPI_SUM, 0, & |
---|
| 348 | comm2d, ierr ) |
---|
| 349 | CALL interpolate_to_atmos( 18 ) |
---|
[667] | 350 | |
---|
| 351 | ENDIF |
---|
| 352 | |
---|
| 353 | ! |
---|
| 354 | !-- Conversions of fluxes received from atmosphere |
---|
| 355 | IF ( humidity_remote ) THEN |
---|
[108] | 356 | ! |
---|
[709] | 357 | !-- Here tswst is still the sum of atmospheric bottom heat fluxes, |
---|
| 358 | !-- * latent heat of vaporization in m2/s2, or 540 cal/g, or 40.65 kJ/mol |
---|
| 359 | !-- /(rho_atm(=1.0)*c_p) |
---|
| 360 | tswst = tswst + qswst_remote * 2.2626108E6 / 1005.0 |
---|
| 361 | ! |
---|
[667] | 362 | !-- ...and convert it to a salinity flux at the sea surface (top) |
---|
[108] | 363 | !-- following Steinhorn (1991), JPO 21, pp. 1681-1683: |
---|
| 364 | !-- S'w' = -S * evaporation / ( rho_water * ( 1 - S ) ) |
---|
| 365 | saswst = -1.0 * sa(nzt,:,:) * qswst_remote / & |
---|
[667] | 366 | ( rho(nzt,:,:) * ( 1.0 - sa(nzt,:,:) ) ) |
---|
[108] | 367 | ENDIF |
---|
| 368 | |
---|
| 369 | ! |
---|
[102] | 370 | !-- Adjust the kinematic heat flux with respect to ocean density |
---|
| 371 | !-- (constants are the specific heat capacities for air and water) |
---|
[667] | 372 | !-- now tswst is the ocean top heat flux |
---|
[108] | 373 | tswst = tswst / rho(nzt,:,:) * 1005.0 / 4218.0 |
---|
[102] | 374 | |
---|
| 375 | ! |
---|
[667] | 376 | !-- Adjust the momentum fluxes with respect to ocean density |
---|
| 377 | uswst = uswst / rho(nzt,:,:) |
---|
| 378 | vswst = vswst / rho(nzt,:,:) |
---|
[102] | 379 | |
---|
[667] | 380 | ENDIF |
---|
| 381 | |
---|
[709] | 382 | IF ( coupling_topology == 1 ) THEN |
---|
[667] | 383 | DEALLOCATE( total_2d_o, total_2d_a ) |
---|
| 384 | ENDIF |
---|
| 385 | |
---|
| 386 | CALL cpu_log( log_point(39), 'surface_coupler', 'stop' ) |
---|
| 387 | |
---|
| 388 | #endif |
---|
| 389 | |
---|
| 390 | END SUBROUTINE surface_coupler |
---|
| 391 | |
---|
| 392 | |
---|
| 393 | |
---|
[709] | 394 | SUBROUTINE interpolate_to_atmos( tag ) |
---|
[667] | 395 | |
---|
[880] | 396 | #if defined( __parallel ) |
---|
| 397 | |
---|
[667] | 398 | USE arrays_3d |
---|
| 399 | USE control_parameters |
---|
| 400 | USE grid_variables |
---|
| 401 | USE indices |
---|
| 402 | USE pegrid |
---|
| 403 | |
---|
| 404 | IMPLICIT NONE |
---|
| 405 | |
---|
| 406 | INTEGER :: dnx, dnx2, dny, dny2, i, ii, j, jj |
---|
| 407 | INTEGER, intent(in) :: tag |
---|
| 408 | |
---|
| 409 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 410 | |
---|
[709] | 411 | IF ( myid == 0 ) THEN |
---|
| 412 | ! |
---|
| 413 | !-- Cyclic boundary conditions for the total 2D-grid |
---|
[667] | 414 | total_2d_o(-nbgp:-1,:) = total_2d_o(ny+1-nbgp:ny,:) |
---|
| 415 | total_2d_o(:,-nbgp:-1) = total_2d_o(:,nx+1-nbgp:nx) |
---|
| 416 | |
---|
| 417 | total_2d_o(ny+1:ny+nbgp,:) = total_2d_o(0:nbgp-1,:) |
---|
| 418 | total_2d_o(:,nx+1:nx+nbgp) = total_2d_o(:,0:nbgp-1) |
---|
| 419 | |
---|
[102] | 420 | ! |
---|
[667] | 421 | !-- Number of gridpoints of the fine grid within one mesh of the coarse grid |
---|
| 422 | dnx = (nx_o+1) / (nx_a+1) |
---|
| 423 | dny = (ny_o+1) / (ny_a+1) |
---|
[102] | 424 | |
---|
| 425 | ! |
---|
[709] | 426 | !-- Distance for interpolation around coarse grid points within the fine |
---|
| 427 | !-- grid (note: 2*dnx2 must not be equal with dnx) |
---|
[667] | 428 | dnx2 = 2 * ( dnx / 2 ) |
---|
| 429 | dny2 = 2 * ( dny / 2 ) |
---|
[102] | 430 | |
---|
[667] | 431 | total_2d_a = 0.0 |
---|
[102] | 432 | ! |
---|
[667] | 433 | !-- Interpolation from ocean-grid-layer to atmosphere-grid-layer |
---|
| 434 | DO j = 0, ny_a |
---|
| 435 | DO i = 0, nx_a |
---|
| 436 | DO jj = 0, dny2 |
---|
| 437 | DO ii = 0, dnx2 |
---|
| 438 | total_2d_a(j,i) = total_2d_a(j,i) & |
---|
| 439 | + total_2d_o(j*dny+jj,i*dnx+ii) |
---|
| 440 | ENDDO |
---|
| 441 | ENDDO |
---|
| 442 | total_2d_a(j,i) = total_2d_a(j,i) / ( ( dnx2 + 1 ) * ( dny2 + 1 ) ) |
---|
| 443 | ENDDO |
---|
| 444 | ENDDO |
---|
| 445 | ! |
---|
[709] | 446 | !-- Cyclic boundary conditions for atmosphere grid |
---|
[667] | 447 | total_2d_a(-nbgp:-1,:) = total_2d_a(ny_a+1-nbgp:ny_a,:) |
---|
| 448 | total_2d_a(:,-nbgp:-1) = total_2d_a(:,nx_a+1-nbgp:nx_a) |
---|
| 449 | |
---|
| 450 | total_2d_a(ny_a+1:ny_a+nbgp,:) = total_2d_a(0:nbgp-1,:) |
---|
| 451 | total_2d_a(:,nx_a+1:nx_a+nbgp) = total_2d_a(:,0:nbgp-1) |
---|
| 452 | ! |
---|
| 453 | !-- Transfer of the atmosphere-grid-layer to the atmosphere |
---|
[709] | 454 | CALL MPI_SEND( total_2d_a(-nbgp,-nbgp), ngp_a, MPI_REAL, target_id, & |
---|
| 455 | tag, comm_inter, ierr ) |
---|
[102] | 456 | |
---|
| 457 | ENDIF |
---|
| 458 | |
---|
[667] | 459 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
[102] | 460 | |
---|
[880] | 461 | #endif |
---|
| 462 | |
---|
[667] | 463 | END SUBROUTINE interpolate_to_atmos |
---|
[102] | 464 | |
---|
[667] | 465 | |
---|
[709] | 466 | SUBROUTINE interpolate_to_ocean( tag ) |
---|
[667] | 467 | |
---|
[880] | 468 | #if defined( __parallel ) |
---|
| 469 | |
---|
[667] | 470 | USE arrays_3d |
---|
| 471 | USE control_parameters |
---|
| 472 | USE grid_variables |
---|
| 473 | USE indices |
---|
| 474 | USE pegrid |
---|
| 475 | |
---|
| 476 | IMPLICIT NONE |
---|
| 477 | |
---|
| 478 | INTEGER :: dnx, dny, i, ii, j, jj |
---|
| 479 | INTEGER, intent(in) :: tag |
---|
[709] | 480 | REAL :: fl, fr, myl, myr |
---|
[667] | 481 | |
---|
[709] | 482 | |
---|
[667] | 483 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 484 | |
---|
[709] | 485 | IF ( myid == 0 ) THEN |
---|
[667] | 486 | |
---|
| 487 | ! |
---|
[709] | 488 | !-- Number of gridpoints of the fine grid within one mesh of the coarse grid |
---|
[667] | 489 | dnx = ( nx_o + 1 ) / ( nx_a + 1 ) |
---|
| 490 | dny = ( ny_o + 1 ) / ( ny_a + 1 ) |
---|
| 491 | |
---|
| 492 | ! |
---|
[709] | 493 | !-- Cyclic boundary conditions for atmosphere grid |
---|
[667] | 494 | total_2d_a(-nbgp:-1,:) = total_2d_a(ny+1-nbgp:ny,:) |
---|
| 495 | total_2d_a(:,-nbgp:-1) = total_2d_a(:,nx+1-nbgp:nx) |
---|
| 496 | |
---|
| 497 | total_2d_a(ny+1:ny+nbgp,:) = total_2d_a(0:nbgp-1,:) |
---|
| 498 | total_2d_a(:,nx+1:nx+nbgp) = total_2d_a(:,0:nbgp-1) |
---|
| 499 | ! |
---|
[709] | 500 | !-- Bilinear Interpolation from atmosphere grid-layer to ocean grid-layer |
---|
[667] | 501 | DO j = 0, ny |
---|
| 502 | DO i = 0, nx |
---|
| 503 | myl = ( total_2d_a(j+1,i) - total_2d_a(j,i) ) / dny |
---|
| 504 | myr = ( total_2d_a(j+1,i+1) - total_2d_a(j,i+1) ) / dny |
---|
| 505 | DO jj = 0, dny-1 |
---|
[709] | 506 | fl = myl*jj + total_2d_a(j,i) |
---|
| 507 | fr = myr*jj + total_2d_a(j,i+1) |
---|
[667] | 508 | DO ii = 0, dnx-1 |
---|
| 509 | total_2d_o(j*dny+jj,i*dnx+ii) = ( fr - fl ) / dnx * ii + fl |
---|
| 510 | ENDDO |
---|
| 511 | ENDDO |
---|
| 512 | ENDDO |
---|
| 513 | ENDDO |
---|
| 514 | ! |
---|
[709] | 515 | !-- Cyclic boundary conditions for ocean grid |
---|
[667] | 516 | total_2d_o(-nbgp:-1,:) = total_2d_o(ny_o+1-nbgp:ny_o,:) |
---|
| 517 | total_2d_o(:,-nbgp:-1) = total_2d_o(:,nx_o+1-nbgp:nx_o) |
---|
| 518 | |
---|
| 519 | total_2d_o(ny_o+1:ny_o+nbgp,:) = total_2d_o(0:nbgp-1,:) |
---|
| 520 | total_2d_o(:,nx_o+1:nx_o+nbgp) = total_2d_o(:,0:nbgp-1) |
---|
| 521 | |
---|
| 522 | CALL MPI_SEND( total_2d_o(-nbgp,-nbgp), ngp_o, MPI_REAL, & |
---|
| 523 | target_id, tag, comm_inter, ierr ) |
---|
| 524 | |
---|
| 525 | ENDIF |
---|
| 526 | |
---|
| 527 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 528 | |
---|
[880] | 529 | #endif |
---|
| 530 | |
---|
[667] | 531 | END SUBROUTINE interpolate_to_ocean |
---|