~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_fill.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
    void *alpha;
 
13
    int buffer[100];
 
14
    int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
 
15
    int result=0, error_index=-1, error_proc=-1;
 
16
    int ival = 6;
 
17
    long lval = 7;
 
18
    long long llval = 8;
 
19
    float fval = 9;
 
20
    double dval = 10;
 
21
    SingleComplex cval = {11,12};
 
22
    DoubleComplex zval = {13,14};
 
23
 
 
24
    mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
 
25
    result_a = Mock_Create(type, ndim, dims, "mock", NULL);
 
26
 
 
27
    g_a = create_function[dist_idx](type, ndim, dims);
 
28
 
 
29
    mock_data(mock_a, g_a);
 
30
 
 
31
    mock_to_global(mock_a, g_a);
 
32
 
 
33
    switch (type) {
 
34
        case C_INT:      alpha = &ival; break;
 
35
        case C_LONG:     alpha = &lval; break;
 
36
        case C_LONGLONG: alpha = &llval; break;
 
37
        case C_FLOAT:    alpha = &fval; break;
 
38
        case C_DBL:      alpha = &dval; break;
 
39
        case C_SCPL:     alpha = &cval; break;
 
40
        case C_DCPL:     alpha = &zval; break;
 
41
    }
 
42
 
 
43
    Mock_Fill(mock_a, alpha);
 
44
 
 
45
    GA_Fill(g_a, alpha);
 
46
 
 
47
    global_to_mock(g_a, result_a);
 
48
 
 
49
    result = neq_mock(mock_a, result_a, &error_index);
 
50
    if (0 != result) {
 
51
        error_proc = GA_Nodeid();
 
52
    }
 
53
 
 
54
    GA_Igop(&result, 1, "+");
 
55
    GA_Igop(&error_proc, 1, "max");
 
56
 
 
57
    if (error_proc != GA_Nodeid()) {
 
58
        error_index = 0;
 
59
    }
 
60
 
 
61
    GA_Igop(&error_index, 1, "+");
 
62
    if (0 != result) {
 
63
        if (error_proc == GA_Nodeid()) {
 
64
            printf("ERROR: local result failed to compare to global result\n");
 
65
            printf("\terror_proc=%d\n", error_proc);
 
66
            printf("\terror_index=%d\n", error_index);
 
67
            printf("***LOCAL RESULT***\n");
 
68
            Mock_Print(mock_a);
 
69
            printf("***GLOBAL RESULT***\n");
 
70
            Mock_Print(result_a);
 
71
            printf("\tprinting array distribution\n");
 
72
        }
 
73
        GA_Sync();
 
74
        GA_Print(g_a);
 
75
        GA_Print_distribution(g_a);
 
76
        return 1;
 
77
    }
 
78
 
 
79
 
 
80
    Mock_Destroy(mock_a);
 
81
    Mock_Destroy(result_a);
 
82
    GA_Destroy(g_a);
 
83
 
 
84
    return 0;
 
85
}
 
86
 
 
87
int main(int argc, char **argv)
 
88
{
 
89
    TEST_SETUP;
 
90
 
 
91
    int shape_idx=0, type_idx=0, dist_idx=0;
 
92
    int return_code=0;
 
93
 
 
94
    for (shape_idx=0; shape_idx < NUM_SHAPES; ++shape_idx) {
 
95
        for (type_idx=0; type_idx < NUM_TYPES; ++type_idx) {
 
96
            for (dist_idx=0; dist_idx < NUM_DISTS; ++dist_idx) {
 
97
                if (0 == GA_Nodeid()) {
 
98
                    printf("%s\t%s\t%s\n",
 
99
                            SHAPE_NAMES[shape_idx],
 
100
                            TYPE_NAMES[type_idx],
 
101
                            DIST_NAMES[dist_idx]
 
102
                            );
 
103
                }
 
104
                GA_Sync();
 
105
                return_code = test(shape_idx, type_idx, dist_idx);
 
106
                if (0 != return_code) {
 
107
                    break;
 
108
                }
 
109
            }
 
110
            if (0 != return_code) {
 
111
                break;
 
112
            }
 
113
        }
 
114
        if (0 != return_code) {
 
115
            break;
 
116
        }
 
117
    }
 
118
 
 
119
    TEST_TEARDOWN;
 
120
    return return_code;
 
121
}