subroutine test_AllReduce_sum !Test with Integer arguments !=========================== !------------------------------------------------------------------------ !EX_UTest write(failMsg, *) "Did not return ESMF_SUCCESS" write(name, *) "VM All Reduce ESMF_REDUCE_SUM Test" call ESMF_VMAllReduce(vm, sendData=array1, recvData=array3, count=nsize, & reduceflag=ESMF_REDUCE_SUM, rc=rc) call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE) !------------------------------------------------------------------------ !EX_UTest isum=0 do j=1,npets end do do i=1,nsize array3_soln(i) = sum( array2(i,:) ) print *, localPet,'array3(',i,')=',array3(i), & 'array3_soln(',i,')=',array3_soln(i) isum=isum + abs( array3(i) - array3_soln(i) ) end do write(failMsg, *) "Returned wrong results" write(name, *) "Verify All Reduce ESMF_REDUCE_SUM Results Test" call ESMF_Test((isum.eq.0), name, failMsg, result, ESMF_SRCLINE) !Test with ESMF_KIND_R8 arguments !================================= !------------------------------------------------------------------------ !EX_UTest write(failMsg, *) "Did not return ESMF_SUCCESS" write(name, *) "VM All Reduce ESMF_REDUCE_SUM Test" call ESMF_VMAllReduce(vm, sendData=farray1, recvData=farray3, & count=nsize, reduceflag=ESMF_REDUCE_SUM, rc=rc) call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE) !------------------------------------------------------------------------ !EX_UTest fsum=0. do i=1,nsize farray3_soln(i) = sum( farray2(i,:) ) print *, localPet,'farray3(',i,')=',farray3(i), & 'farray3_soln(',i,')=',farray3_soln(i) fsum=fsum + real(abs( farray3(i) - farray3_soln(i) )) end do write(failMsg, *) "Returned wrong results" write(name, *) "Verify All Reduce ESMF_REDUCE_SUM Results Test" call ESMF_Test((fsum.eq.0), name, failMsg, result, ESMF_SRCLINE) !Test with ESMF_KIND_R4 arguments !================================= !------------------------------------------------------------------------ !EX_UTest write(failMsg, *) "Did not return ESMF_SUCCESS" write(name, *) "VM All Reduce ESMF_REDUCE_SUM Test" call ESMF_VMAllReduce(vm, sendData=f4array1, recvData=f4array3, & count=nsize, reduceflag=ESMF_REDUCE_SUM, rc=rc) call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE) !------------------------------------------------------------------------ !EX_UTest fsum=0. do i=1,nsize f4array3_soln(i) = sum( f4array2(i,:) ) print *, localPet,'f4array3(',i,')=',f4array3(i), & 'f4array3_soln(',i,')=',f4array3_soln(i) fsum=fsum + abs( f4array3(i) - f4array3_soln(i) ) end do write(failMsg, *) "Returned wrong results" write(name, *) "Verify All Reduce ESMF_REDUCE_SUM Results Test" call ESMF_Test((fsum.eq.0.), name, failMsg, result, ESMF_SRCLINE) end subroutine test_AllReduce_sum