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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/ma/testc.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
 
#if HAVE_CONFIG_H
2
 
#   include "config.h"
3
 
#endif
4
 
 
5
 
/*
6
 
 * $Id: testc.c,v 1.5 1999-05-27 16:31:16 d3h325 Exp $
7
 
 */
8
 
 
9
 
/*
10
 
 * Test harness for portable dynamic memory allocator.
11
 
 */
12
 
 
13
 
#include "macdecls.h"
14
 
#include "string-util.h"
15
 
#if HAVE_STDIO_H
16
 
#   include <stdio.h>
17
 
#endif
18
 
#if HAVE_STDLIB_H
19
 
#   include <stdlib.h>
20
 
#endif
21
 
 
22
 
/**
23
 
 ** constants
24
 
 **/
25
 
 
26
 
#define NUM_COMMANDS    (int)(sizeof(commands) / sizeof(char *))
27
 
 
28
 
/**
29
 
 ** types
30
 
 **/
31
 
 
32
 
typedef enum
33
 
{
34
 
    C_MA_alloc_get = 0,
35
 
    C_MA_allocate_heap,
36
 
    C_MA_chop_stack,
37
 
    C_MA_free_heap,
38
 
    C_MA_get_index,
39
 
    C_MA_get_next_memhandle,
40
 
    C_MA_get_pointer,
41
 
    C_MA_init,
42
 
    C_MA_init_memhandle_iterator,
43
 
    C_MA_inquire_avail,
44
 
    C_MA_inquire_heap,
45
 
    C_MA_inquire_stack,
46
 
    C_MA_pop_stack,
47
 
    C_MA_print_stats,
48
 
    C_MA_push_get,
49
 
    C_MA_push_stack,
50
 
    C_MA_set_auto_verify,
51
 
    C_MA_set_error_print,
52
 
    C_MA_set_hard_fail,
53
 
    C_MA_sizeof,
54
 
    C_MA_sizeof_overhead,
55
 
    C_MA_summarize_allocated_blocks,
56
 
    C_MA_verify_allocator_stuff,
57
 
    C_bye,
58
 
    C_exit,
59
 
    C_help,
60
 
    C_quit,
61
 
    C_questionmark
62
 
} Command;
63
 
 
64
 
/**
65
 
 ** variables
66
 
 **/
67
 
 
68
 
static char *commands[] =
69
 
{
70
 
    "MA_alloc_get",
71
 
    "MA_allocate_heap",
72
 
    "MA_chop_stack",
73
 
    "MA_free_heap",
74
 
    "MA_get_index",
75
 
    "MA_get_next_memhandle",
76
 
    "MA_get_pointer",
77
 
    "MA_init",
78
 
    "MA_init_memhandle_iterator",
79
 
    "MA_inquire_avail",
80
 
    "MA_inquire_heap",
81
 
    "MA_inquire_stack",
82
 
    "MA_pop_stack",
83
 
    "MA_print_stats",
84
 
    "MA_push_get",
85
 
    "MA_push_stack",
86
 
    "MA_set_auto_verify",
87
 
    "MA_set_error_print",
88
 
    "MA_set_hard_fail",
89
 
    "MA_sizeof",
90
 
    "MA_sizeof_overhead",
91
 
    "MA_summarize_allocated_blocks",
92
 
    "MA_verify_allocator_stuff",
93
 
    "bye",
94
 
    "exit",
95
 
    "help",
96
 
    "quit",
97
 
    "?"
98
 
};
99
 
 
100
 
static char *help[] =
101
 
{
102
 
    "MA_alloc_get(datatype, nelem, name, memhandle, index)",
103
 
    "MA_allocate_heap(datatype, nelem, name, memhandle)",
104
 
    "MA_chop_stack(memhandle)",
105
 
    "MA_free_heap(memhandle)",
106
 
    "MA_get_index(memhandle, index)",
107
 
    "MA_get_next_memhandle(ithandle, memhandle)",
108
 
    "MA_get_pointer(memhandle, pointer)",
109
 
    "MA_init(datatype, nominal_stack, nominal_heap)",
110
 
    "MA_init_memhandle_iterator(ithandle)",
111
 
    "MA_inquire_avail(datatype)",
112
 
    "MA_inquire_heap(datatype)",
113
 
    "MA_inquire_stack(datatype)",
114
 
    "MA_pop_stack(memhandle)",
115
 
    "MA_print_stats()",
116
 
    "MA_push_get(datatype, nelem, name, memhandle, index)",
117
 
    "MA_push_stack(datatype, nelem, name, memhandle)",
118
 
    "MA_set_auto_verify(value)",
119
 
    "MA_set_error_print(value)",
120
 
    "MA_set_hard_fail(value)",
121
 
    "MA_sizeof(datatype1, nelem1, datatype2)",
122
 
    "MA_sizeof_overhead(datatype)",
123
 
    "MA_summarize_allocated_blocks()",
124
 
    "MA_verify_allocator_stuff()",
125
 
    "bye",
126
 
    "exit",
127
 
    "help",
128
 
    "quit",
129
 
    "?"
130
 
};
131
 
 
132
 
/**
133
 
 ** public routines
134
 
 **/
135
 
 
136
 
/* ------------------------------------------------------------------------- */
137
 
/*
138
 
 * Interactive interface to MA routines.
139
 
 */
140
 
/* ------------------------------------------------------------------------- */
141
 
 
142
 
int main(argc, argv)
143
 
    int        argc;
144
 
    char    *argv[];
145
 
{
146
 
    char        s[81];  /* string buffer */
147
 
    int         c;      /* index of command */
148
 
    int         ii1;    /* in int buffer */
149
 
    int         ii2;    /* in int buffer */
150
 
    int         ii3;    /* in int buffer */
151
 
    Integer     oi1;    /* out int buffer */
152
 
    MA_AccessIndex oi2; /* out int buffer */
153
 
    Pointer     op;     /* out Pointer buffer */
154
 
    int         value;  /* return value buffer */
155
 
 
156
 
    while (1)
157
 
    {
158
 
        printf("testc> ");
159
 
 
160
 
        if (scanf("%80s", s) != 1)
161
 
        {
162
 
            printf("*** Input read failed; exiting.\n");
163
 
            exit(1);
164
 
        }
165
 
 
166
 
        c = str_match(s, commands, NUM_COMMANDS);
167
 
        if (c == SM_MANY)
168
 
        {
169
 
            printf("*** '%s' is ambiguous\n", s);
170
 
            continue;
171
 
        }
172
 
        else if (c == SM_NONE)
173
 
        {
174
 
            printf("*** Unrecognized command '%s'\n", s);
175
 
            continue;
176
 
        }
177
 
 
178
 
        switch ((Command)c)
179
 
        {
180
 
            case C_MA_alloc_get:
181
 
                if (scanf("%d %d %80s", &ii1, &ii2, s) != 3)
182
 
                    printf("*** Input read failed for %s\n", commands[c]);
183
 
                else
184
 
                {
185
 
                    value = MA_alloc_get(ii1, ii2, s, &oi1, &oi2);
186
 
                    printf("%s=%d memhandle=%ld index=%ld\n",
187
 
                        commands[c], value, (long)oi1, (long)oi2);
188
 
                }
189
 
                break;
190
 
            case C_MA_allocate_heap:
191
 
                if (scanf("%d %d %80s", &ii1, &ii2, s) != 3)
192
 
                    printf("*** Input read failed for %s\n", commands[c]);
193
 
                else
194
 
                {
195
 
                    value = MA_allocate_heap(ii1, ii2, s, &oi1);
196
 
                    printf("%s=%d memhandle=%ld\n",
197
 
                            commands[c], value, (long)oi1);
198
 
                }
199
 
                break;
200
 
            case C_MA_chop_stack:
201
 
                if (scanf("%d", &ii1) != 1)
202
 
                    printf("*** Input read failed for %s\n", commands[c]);
203
 
                else
204
 
                {
205
 
                    value = MA_chop_stack(ii1);
206
 
                    printf("%s=%d\n", commands[c], value);
207
 
                }
208
 
                break;
209
 
            case C_MA_free_heap:
210
 
                if (scanf("%d", &ii1) != 1)
211
 
                    printf("*** Input read failed for %s\n", commands[c]);
212
 
                else
213
 
                {
214
 
                    value = MA_free_heap(ii1);
215
 
                    printf("%s=%d\n", commands[c], value);
216
 
                }
217
 
                break;
218
 
            case C_MA_get_index:
219
 
                if (scanf("%d", &ii1) != 1)
220
 
                    printf("*** Input read failed for %s\n", commands[c]);
221
 
                else
222
 
                {
223
 
                    value = MA_get_index(ii1, &oi2);
224
 
                    printf("%s=%d index=%ld\n", commands[c], value, (long)oi2);
225
 
                }
226
 
                break;
227
 
            case C_MA_get_next_memhandle:
228
 
                if (scanf("%d", &ii1) != 1)
229
 
                    printf("*** Input read failed for %s\n", commands[c]);
230
 
                else
231
 
                {
232
 
                    Integer tmp = ii1;
233
 
                    value = MA_get_next_memhandle(&tmp, &oi1);
234
 
                    printf("%s=%d ithandle=%ld memhandle=%ld\n",
235
 
                        commands[c], value, (long)tmp, (long)oi1);
236
 
                }
237
 
                break;
238
 
            case C_MA_get_pointer:
239
 
                if (scanf("%d", &ii1) != 1)
240
 
                    printf("*** Input read failed for %s\n", commands[c]);
241
 
                else
242
 
                {
243
 
                    value = MA_get_pointer(ii1, &op);
244
 
                    printf("%s=%d pointer=%lu\n", commands[c], value,
245
 
                        (unsigned long)op);
246
 
                }
247
 
                break;
248
 
            case C_MA_init:
249
 
                if (scanf("%d %d %d", &ii1, &ii2, &ii3) != 3)
250
 
                    printf("*** Input read failed for %s\n", commands[c]);
251
 
                else
252
 
                {
253
 
                    value = MA_init(ii1, ii2, ii3);
254
 
                    printf("%s=%d\n", commands[c], value);
255
 
                }
256
 
                break;
257
 
            case C_MA_init_memhandle_iterator:
258
 
                value = MA_init_memhandle_iterator(&oi1);
259
 
                printf("%s=%d ithandle=%ld\n", commands[c], value, (long)oi1);
260
 
                break;
261
 
            case C_MA_inquire_avail:
262
 
                if (scanf("%d", &ii1) != 1)
263
 
                    printf("*** Input read failed for %s\n", commands[c]);
264
 
                else
265
 
                {
266
 
                    oi1 = MA_inquire_avail(ii1);
267
 
                    printf("%s=%ld\n", commands[c], (long)oi1);
268
 
                }
269
 
                break;
270
 
            case C_MA_inquire_heap:
271
 
                if (scanf("%d", &ii1) != 1)
272
 
                    printf("*** Input read failed for %s\n", commands[c]);
273
 
                else
274
 
                {
275
 
                    oi1 = MA_inquire_heap(ii1);
276
 
                    printf("%s=%ld\n", commands[c], (long)oi1);
277
 
                }
278
 
                break;
279
 
            case C_MA_inquire_stack:
280
 
                if (scanf("%d", &ii1) != 1)
281
 
                    printf("*** Input read failed for %s\n", commands[c]);
282
 
                else
283
 
                {
284
 
                    oi1 = MA_inquire_stack(ii1);
285
 
                    printf("%s=%ld\n", commands[c], (long)oi1);
286
 
                }
287
 
                break;
288
 
            case C_MA_pop_stack:
289
 
                if (scanf("%d", &ii1) != 1)
290
 
                    printf("*** Input read failed for %s\n", commands[c]);
291
 
                else
292
 
                {
293
 
                    value = MA_pop_stack(ii1);
294
 
                    printf("%s=%d\n", commands[c], value);
295
 
                }
296
 
                break;
297
 
            case C_MA_print_stats:
298
 
                MA_print_stats(1);
299
 
                break;
300
 
            case C_MA_push_get:
301
 
                if (scanf("%d %d %80s", &ii1, &ii2, s) != 3)
302
 
                    printf("*** Input read failed for %s\n", commands[c]);
303
 
                else
304
 
                {
305
 
                    value = MA_push_get(ii1, ii2, s, &oi1, &oi2);
306
 
                    printf("%s=%d memhandle=%ld index=%ld\n",
307
 
                        commands[c], value, (long)oi1, (long)oi2);
308
 
                }
309
 
                break;
310
 
            case C_MA_push_stack: 
311
 
                if (scanf("%d %d %80s", &ii1, &ii2, s) != 3)
312
 
                    printf("*** Input read failed for %s\n", commands[c]);
313
 
                else
314
 
                {
315
 
                    value = MA_push_stack(ii1, ii2, s, &oi1);
316
 
                    printf("%s=%d memhandle=%ld\n",
317
 
                            commands[c], value, (long)oi1);
318
 
                }
319
 
                break;
320
 
            case C_MA_set_auto_verify:
321
 
                if (scanf("%d", &ii1) != 1)
322
 
                    printf("*** Input read failed for %s\n", commands[c]);
323
 
                else
324
 
                {
325
 
                    value = MA_set_auto_verify(ii1);
326
 
                    printf("%s=%d\n", commands[c], value);
327
 
                }
328
 
                break;
329
 
            case C_MA_set_error_print:
330
 
                if (scanf("%d", &ii1) != 1)
331
 
                    printf("*** Input read failed for %s\n", commands[c]);
332
 
                else
333
 
                {
334
 
                    value = MA_set_error_print(ii1);
335
 
                    printf("%s=%d\n", commands[c], value);
336
 
                }
337
 
                break;
338
 
            case C_MA_set_hard_fail:
339
 
                if (scanf("%d", &ii1) != 1)
340
 
                    printf("*** Input read failed for %s\n", commands[c]);
341
 
                else
342
 
                {
343
 
                    value = MA_set_hard_fail(ii1);
344
 
                    printf("%s=%d\n", commands[c], value);
345
 
                }
346
 
                break;
347
 
            case C_MA_sizeof:
348
 
                if (scanf("%d %d %d", &ii1, &ii2, &ii3) != 3)
349
 
                    printf("*** Input read failed for %s\n", commands[c]);
350
 
                else
351
 
                {
352
 
                    oi1 = MA_sizeof(ii1, ii2, ii3);
353
 
                    printf("%s=%ld\n", commands[c], (long)oi1);
354
 
                }
355
 
                break;
356
 
            case C_MA_sizeof_overhead:
357
 
                if (scanf("%d", &ii1) != 1)
358
 
                    printf("*** Input read failed for %s\n", commands[c]);
359
 
                else
360
 
                {
361
 
                    oi1 = MA_sizeof_overhead(ii1);
362
 
                    printf("%s=%ld\n", commands[c], (long)oi1);
363
 
                }
364
 
                break;
365
 
            case C_MA_summarize_allocated_blocks:
366
 
                MA_summarize_allocated_blocks();
367
 
                break;
368
 
            case C_MA_verify_allocator_stuff:
369
 
                value = MA_verify_allocator_stuff();
370
 
                printf("%s=%d\n", commands[c], value);
371
 
                break;
372
 
            case C_bye:
373
 
                /* fall through */
374
 
            case C_exit:
375
 
                /* fall through */
376
 
            case C_quit:
377
 
                exit(0);
378
 
            case C_help:
379
 
                /* fall through */
380
 
            case C_questionmark:
381
 
                for (ii1 = 0; ii1 < NUM_COMMANDS; ii1++)
382
 
                    printf(" %s\n", help[ii1]);
383
 
                break;
384
 
            default:
385
 
                printf("*** Unrecognized case '%d' in switch\n", c);
386
 
        }
387
 
    }
388
 
 
389
 
    return 0;
390
 
}