error.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "RCCE.h"
  17. #include <math.h>
  18. #include <stdio.h>
  19. #include "applu_share.h"
  20. #include "applu_macros.h"
  21. #include "applu_protos.h"
  22. #define u000ijk(m) u000ijk[m-1]
  23. #define errnm(m) errnm[m-1]
  24. #define dummy(m) dummy[m-1]
  25. void error() {
  26. // local variables
  27. int i, j, k, m, iglob, jglob;
  28. double tmp, u000ijk[5], dummy[5];
  29. for (m=1; m<=5; m++) {
  30. errnm(m) = 0.0;
  31. dummy(m) = 0.0;
  32. }
  33. for (k=2; k<=(nz)-1; k++)
  34. for (j=jst; j<=(jend); j++) {
  35. jglob = jpt + j;
  36. for (i=ist;i<=(iend); i++) {
  37. iglob = ipt + i;
  38. exact(iglob, jglob, k, u000ijk);
  39. for (m=1; m<=5; m++) {
  40. tmp = ( u000ijk(m) - u(m,i,j,k) );
  41. dummy(m) = dummy(m) + tmp * tmp;
  42. }
  43. }
  44. }
  45. // compute the global sum of individual contributions to dot product.
  46. RCCE_allreduce((char*)dummy, (char*)errnm, 5, RCCE_DOUBLE, RCCE_SUM, RCCE_COMM_WORLD);
  47. for (m=1; m<=5; m++) {
  48. errnm(m) = sqrt ( errnm(m) / ( (nx0-2)*(ny0-2)*(nz0-2) ) );
  49. }
  50. return;
  51. }