~ubuntu-branches/ubuntu/trusty/nwchem/trusty-proposed

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/global/testing/unit-tests/ga_add_constant.c~

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Daniel Leidert, Andreas Tille, Michael Banck
  • Date: 2013-07-04 12:14:55 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130704121455-5tvsx2qabor3nrui
Tags: 6.3-1
* New upstream release.
* Fixes anisotropic properties (Closes: #696361).
* New features include:
  + Multi-reference coupled cluster (MRCC) approaches
  + Hybrid DFT calculations with short-range HF 
  + New density-functionals including Minnesota (M08, M11) and HSE hybrid
    functionals
  + X-ray absorption spectroscopy (XAS) with TDDFT
  + Analytical gradients for the COSMO solvation model
  + Transition densities from TDDFT 
  + DFT+U and Electron-Transfer (ET) methods for plane wave calculations
  + Exploitation of space group symmetry in plane wave geometry optimizations
  + Local density of states (LDOS) collective variable added to Metadynamics
  + Various new XC functionals added for plane wave calculations, including
    hybrid and range-corrected ones
  + Electric field gradients with relativistic corrections 
  + Nudged Elastic Band optimization method
  + Updated basis sets and ECPs 

[ Daniel Leidert ]
* debian/watch: Fixed.

[ Andreas Tille ]
* debian/upstream: References

[ Michael Banck ]
* debian/upstream (Name): New field.
* debian/patches/02_makefile_flags.patch: Refreshed.
* debian/patches/06_statfs_kfreebsd.patch: Likewise.
* debian/patches/07_ga_target_force_linux.patch: Likewise.
* debian/patches/05_avoid_inline_assembler.patch: Removed, no longer needed.
* debian/patches/09_backported_6.1.1_fixes.patch: Likewise.
* debian/control (Build-Depends): Added gfortran-4.7 and gcc-4.7.
* debian/patches/10_force_gcc-4.7.patch: New patch, explicitly sets
  gfortran-4.7 and gcc-4.7, fixes test suite hang with gcc-4.8 (Closes:
  #701328, #713262).
* debian/testsuite: Added tests for COSMO analytical gradients and MRCC.
* debian/rules (MRCC_METHODS): New variable, required to enable MRCC methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "ga.h"
 
2
#include "mock.h"
 
3
#include "ga_unit.h"
 
4
 
 
5
static int test(int shape_idx, int type_idx, int dist_idx)
 
6
{
 
7
    int type = TYPES[type_idx];
 
8
    int *dims = SHAPES[shape_idx];
 
9
    int ndim = SHAPES_NDIM[shape_idx];
 
10
    mock_ga_t *mock_a, *result_a;
 
11
    int g_a;
 
12
    int buffer[100];
 
13
    int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
 
14
    int result=0, error_index=-1, error_proc=-1;
 
15
 
 
16
    /* create the local array and result array */
 
17
    mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
 
18
    result_a = Mock_Create(type, ndim, dims, "mock", NULL);
 
19
 
 
20
    /* create the global array */
 
21
    g_a = create_function[dist_idx](type, ndim, dims);
 
22
 
 
23
    /* create meaningful data for local array */
 
24
    mock_data(mock_a, g_a);
 
25
 
 
26
    /* init global array with same data as local array */
 
27
    mock_to_global(mock_a, g_a);
 
28
 
 
29
    /* call the local routine */
 
30
    Mock_Abs_value(mock_a);
 
31
 
 
32
    /* call the global routine */
 
33
    GA_Abs_value(g_a);
 
34
 
 
35
    /* get the results from the global array */
 
36
    global_to_mock(g_a, result_a);
 
37
 
 
38
    /* compare the results */
 
39
    result = neq_mock(mock_a, result_a, &error_index);
 
40
    if (0 != result) {
 
41
        error_proc = GA_Nodeid();
 
42
    }
 
43
    /* make sure all procs get same result so they can die gracefully */
 
44
    GA_Igop(&result, 1, "+");
 
45
    /* if error occured, find the highest failing node ID */
 
46
    GA_Igop(&error_proc, 1, "max");
 
47
    /* clear the error index for all but the highest failing node ID */
 
48
    if (error_proc != GA_Nodeid()) {
 
49
        error_index = 0;
 
50
    }
 
51
    /* make sure all procs get the error index on the highest failing node ID */
 
52
    GA_Igop(&error_index, 1, "+");
 
53
    if (0 != result) {
 
54
        if (error_proc == GA_Nodeid()) {
 
55
            printf("ERROR: local result failed to compare to global result\n");
 
56
            printf("\terror_proc=%d\n", error_proc);
 
57
            printf("\terror_index=%d\n", error_index);
 
58
            printf("***LOCAL RESULT***\n");
 
59
            Mock_Print(mock_a);
 
60
            printf("***GLOBAL RESULT***\n");
 
61
            Mock_Print(result_a);
 
62
            printf("\tprinting array distribution\n");
 
63
        }
 
64
        GA_Sync();
 
65
        GA_Print(g_a);
 
66
        GA_Print_distribution(g_a);
 
67
        return 1;
 
68
    }
 
69
 
 
70
    /* clean up */
 
71
    Mock_Destroy(mock_a);
 
72
    Mock_Destroy(result_a);
 
73
    GA_Destroy(g_a);
 
74
 
 
75
    return 0;
 
76
}
 
77
 
 
78
int main(int argc, char **argv)
 
79
{
 
80
    TEST_SETUP;
 
81
 
 
82
    int shape_idx=0, type_idx=0, dist_idx=0;
 
83
    int return_code=0;
 
84
 
 
85
    for (shape_idx=0; shape_idx < NUM_SHAPES; ++shape_idx) {
 
86
        for (type_idx=0; type_idx < NUM_TYPES; ++type_idx) {
 
87
            for (dist_idx=0; dist_idx < NUM_DISTS; ++dist_idx) {
 
88
                if (0 == GA_Nodeid()) {
 
89
                    printf("%s\t%s\t%s\n",
 
90
                            SHAPE_NAMES[shape_idx],
 
91
                            TYPE_NAMES[type_idx],
 
92
                            DIST_NAMES[dist_idx]
 
93
                            );
 
94
                }
 
95
                GA_Sync();
 
96
                return_code = test(shape_idx, type_idx, dist_idx);
 
97
                if (0 != return_code) {
 
98
                    break;
 
99
                }
 
100
            }
 
101
            if (0 != return_code) {
 
102
                break;
 
103
            }
 
104
        }
 
105
        if (0 != return_code) {
 
106
            break;
 
107
        }
 
108
    }
 
109
 
 
110
    TEST_TEARDOWN;
 
111
    return return_code;
 
112
}