subdomain.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Copyright 2010 Intel Corporation
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include <stdio.h>
  17. #include "applu_share.h"
  18. void subdomain() {
  19. int mm, errorcode=99;
  20. //c x dimension
  21. mm = nx0%xdim;
  22. if (row <= mm) {
  23. nx = nx0/xdim + 1;
  24. ipt = (row-1)*nx;
  25. }
  26. else {
  27. nx = nx0/xdim;
  28. ipt = (row-1)*nx + mm;
  29. }
  30. //c y dimension
  31. mm = ny0%ydim;
  32. if (col <= mm) {
  33. ny = ny0/ydim + 1;
  34. jpt = (col-1)*ny;
  35. }
  36. else {
  37. ny = ny0/ydim;
  38. jpt = (col-1)*ny + mm;
  39. }
  40. //c z dimension
  41. nz = nz0;
  42. //c---------------------------------------------------------------------
  43. //c check the sub-domain size
  44. //c---------------------------------------------------------------------
  45. if ( (nx < 4) || (ny < 4) || (nz < 4) ) {
  46. printf(" SUBDOMAIN SIZE IS TOO SMALL - \n");
  47. printf(" ADJUST PROBLEM SIZE OR NUMBER OF PROCESSORS\n");
  48. printf(" SO THAT NX, NY AND NZ ARE GREATER THAN OR EQUAL\n");
  49. printf(" TO 4. THEY ARE CURRENTLY: %3d %3d %3d\n", nx, ny, nz);
  50. }
  51. if ( (nx > isiz1) || (ny > isiz2) || (nz > isiz3) ) {
  52. printf(" SUBDOMAIN SIZE IS TOO LARGE - \n");
  53. printf(" ADJUST PROBLEM SIZE OR NUMBER OF PROCESSORS\n");
  54. printf(" SO THAT NX, NY AND NZ ARE LESS THAN OR EQUAL TO \n");
  55. printf(" ISIZ1, ISIZ2 AND ISIZ3 RESPECTIVELY. THEY ARE\n");
  56. printf(" CURRENTLY: %3d %3d %3d\n", nx, ny, nz);
  57. }
  58. //c---------------------------------------------------------------------
  59. //c set up the start and end in i and j extents for all processors
  60. //c---------------------------------------------------------------------
  61. ist = 1;
  62. iend = nx;
  63. if (north == -1) ist = 2;
  64. if (south == -1) iend = nx - 1;
  65. jst = 1;
  66. jend = ny;
  67. if (west == -1) jst = 2;
  68. if (east == -1) jend = ny - 1;
  69. return;
  70. }