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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/pario/dra/perfn.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
 
#if HAVE_STDIO_H
6
 
#   include <stdio.h>
7
 
#endif
8
 
#if HAVE_MATH_H
9
 
#   include <math.h>
10
 
#endif
11
 
#if HAVE_STDLIB_H
12
 
#   include <stdlib.h>
13
 
#endif
14
 
#if HAVE_STRING_H
15
 
#   include <string.h>
16
 
#endif
17
 
 
18
 
#define FNAME      "/scratch/da.try"
19
 
#define FNAME_ALT  "/tmp/da.try"
20
 
#define FNAME1     "/scratch/da1.try"
21
 
#define FNAME1_ALT "/tmp/da1.try"
22
 
#define FNAME2     "/scratch/da2.try"
23
 
#define FNAME2_ALT "/tmp/da2.try"
24
 
 
25
 
#include "dra.h"
26
 
#include "ga.h"
27
 
#include "macdecls.h"
28
 
#include "mp3.h"
29
 
 
30
 
#ifndef MAXDIM
31
 
#   define MAXDIM GA_MAX_DIM
32
 
#endif
33
 
#ifndef TRUE
34
 
#   define TRUE (Logical)1
35
 
#endif
36
 
#ifndef FALSE
37
 
#   define FALSE (Logical)0
38
 
#endif
39
 
 
40
 
/* If USER_CONFIG set to:
41
 
 *   0: Use default configuration
42
 
 *   1: Number of files is 1, number of I/O procs equals
43
 
 *      the number of nodes
44
 
 *   2: Number of files and number of I/O procs equals
45
 
 *      the number of nodes
46
 
 *   3: Number of files and number of I/O procs equals 1
47
 
 * These configurations only apply if files are not located
48
 
 * on local scratch disk. For local scratch, system defaults
49
 
 * to 1 I/O proc per node and 1 file per node. Note that
50
 
 * USER_CONFIG=1 will only work if system has parallel I/O.
51
 
 *
52
 
 * Memory and Disk Usage:
53
 
 * The aggregate memory required to run this test is approximately
54
 
 * 2*SIZE**NDIM*sizeof(double) bytes. The amount of disk space
55
 
 * required is approximately 1+2**NDIM times this amount.
56
 
 */
57
 
#define USER_CONFIG 0
58
 
#define TEST_TRANSPOSE 0
59
 
 
60
 
#define NDIM 3
61
 
#define SIZE 250
62
 
 
63
 
/*
64
 
#define NDIM 2
65
 
#define SIZE 4000
66
 
 
67
 
#define NDIM 1
68
 
#define SIZE 16000000
69
 
*/
70
 
 
71
 
#define SWITCH 0
72
 
/*#define MAXDIM 7*/
73
 
/*#define TRUE (logical)1*/
74
 
/*#define FALSE (logical)0*/
75
 
 
76
 
#define MULTFILES 0
77
 
 
78
 
#ifdef SOLARIS
79
 
#   if MULTFILES
80
 
#       define USEMULTFILES 1
81
 
#   endif
82
 
#else
83
 
#  define USEMULTFILES 0
84
 
#endif
85
 
 
86
 
#define IA 16807
87
 
#define IM 2147483647
88
 
#define AM (1.0/IM)
89
 
#define IQ 127773
90
 
#define IR 2836
91
 
#define MASK 123459876
92
 
 
93
 
 
94
 
void filename_check(char *result, const char *fname, const char *fname_alt)
95
 
{
96
 
    FILE *fd;
97
 
    strcpy(result, fname);
98
 
    if (! (fd = fopen(result, "w"))) {
99
 
        strcpy(result, fname_alt);
100
 
        if (! (fd = fopen(result, "w"))) {
101
 
            GA_Error("Could not open file", 0);
102
 
        }
103
 
    }
104
 
    fclose(fd);
105
 
}
106
 
 
107
 
 
108
 
float ran0(long *idum)
109
 
{
110
 
    long k;
111
 
    float ans;
112
 
 
113
 
    *idum ^= MASK;
114
 
    k=(*idum)/IQ;
115
 
    *idum = IA*(*idum-k*IQ)-IR*k;
116
 
    if (*idum < 0) *idum += IM;
117
 
    ans=AM*(*idum);
118
 
    *idum ^= MASK;
119
 
    return ans;
120
 
}
121
 
 
122
 
 
123
 
void fill_random(double *a, int isize)
124
 
{
125
 
    long *idum;
126
 
    long i, j;
127
 
 
128
 
    j = 38282;
129
 
    idum = &j;
130
 
    a[0] = (double)ran0(idum);
131
 
    for (i=0; i<(long)isize; i++) {
132
 
        a[i] = (double)(10000.0*ran0(idum));
133
 
    }
134
 
}
135
 
 
136
 
 
137
 
void test_io_dbl()
138
 
{
139
 
    int ndim = NDIM;
140
 
    double err, tt0, tt1, mbytes;
141
 
    int g_a, g_b, d_a, d_b;
142
 
#if TEST_TRANSPOSE
143
 
    int g_c, g_d, d_c;
144
 
#endif
145
 
    int i, req, loop;
146
 
    dra_size_t dlo[MAXDIM],dhi[MAXDIM];
147
 
    dra_size_t n, m;
148
 
    dra_size_t ddims[MAXDIM], reqdims[MAXDIM];
149
 
    int glo[MAXDIM],ghi[MAXDIM];
150
 
    int dims[MAXDIM];
151
 
    int me, nproc, isize, numfiles, nioprocs;
152
 
    double plus, minus;
153
 
    double *index;
154
 
    int ld[MAXDIM], chunk[MAXDIM];
155
 
#if USEMULTFILES
156
 
    int ilen;
157
 
#endif
158
 
    char filename[80], filename1[80];
159
 
 
160
 
    n = SIZE;
161
 
    m = 2*SIZE;
162
 
 
163
 
    loop  = 30;
164
 
    req = -1;
165
 
    nproc = GA_Nnodes();
166
 
    me    = GA_Nodeid();
167
 
    nioprocs = GA_Cluster_nnodes();
168
 
    numfiles = nioprocs;
169
 
 
170
 
    if (me == 0) {
171
 
        printf("Creating temporary global arrays %ld",(long)n);
172
 
        for (i=1; i<ndim; i++) {
173
 
            printf(" x %ld",(long)n);
174
 
        }
175
 
        printf("\n");
176
 
    }
177
 
    if (me == 0) fflush(stdout);
178
 
    GA_Sync();
179
 
    for (i=0; i<ndim; i++) {
180
 
        dims[i] = n;
181
 
        chunk[i] = 1;
182
 
    }
183
 
 
184
 
    g_a = NGA_Create(MT_DBL, ndim, dims, "a", chunk);
185
 
    if (!g_a) GA_Error("NGA_Create failed: a", 0);
186
 
    g_b = NGA_Create(MT_DBL, ndim, dims, "b", chunk);
187
 
    if (!g_b) GA_Error("NGA_Create failed: b", 0);
188
 
    if (me == 0) printf("done\n");
189
 
    if (me == 0) fflush(stdout);
190
 
 
191
 
    /*     initialize g_a, g_b with random values
192
 
           ... use ga_access to avoid allocating local buffers for ga_put */
193
 
 
194
 
    GA_Sync();
195
 
    NGA_Distribution(g_a, me, glo, ghi);
196
 
    NGA_Access(g_a, glo, ghi, &index, ld);
197
 
    isize = 1;
198
 
    for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
199
 
    fill_random(index, isize);
200
 
    GA_Sync();
201
 
    GA_Zero(g_b);
202
 
 
203
 
    /*.......................................................................*/
204
 
#if SWITCH
205
 
    if (me == 0) {
206
 
        printf("Creating Disk array %d",m);
207
 
        for (i=1; i<ndim; i++) {
208
 
            printf(" x %d",m);
209
 
        }
210
 
        printf("\n");
211
 
    }
212
 
    if (me == 0) fflush(stdout);
213
 
    for (i=0; i<ndim; i++) {
214
 
        ddims[i] = m;
215
 
        reqdims[i] = n;
216
 
    }
217
 
    GA_Sync();
218
 
    filename_check(filename1, FNAME1, FNAME1_ALT);
219
 
    if (NDRA_Create(MT_DBL, ndim, ddims, "B", filename1, DRA_RW,
220
 
                reqdims, &d_b) != 0) {
221
 
        GA_Error("NDRA_Create failed(d_b): ",0);
222
 
    }
223
 
 
224
 
    if (me == 0) printf("non alligned blocking write\n");
225
 
    if (me == 0) fflush(stdout);
226
 
 
227
 
    for (i=0; i<ndim; i++) {
228
 
        glo[i] = 0;
229
 
        ghi[i] = n-1;
230
 
        dlo[i] = 1;
231
 
        dhi[i] = n;
232
 
    }
233
 
    GA_Sync();
234
 
    tt0 = MP_TIMER();
235
 
    if (NDRA_Write_section(FALSE, g_a, glo, ghi,
236
 
                d_b, dlo, dhi, &req) != 0)
237
 
        GA_Error("ndra_write_section failed:",0);
238
 
 
239
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_b): ",req);
240
 
    tt1 = MP_TIMER() - tt0;
241
 
    GA_Dgop(&tt1,1,"+");
242
 
    tt1 = tt1/((double)nproc);
243
 
    mbytes = 1.e-6*(double)(pow(n,ndim)*sizeof(double));
244
 
    if (me == 0) {
245
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
246
 
                mbytes,tt1,mbytes/tt1);
247
 
    }
248
 
 
249
 
    if (DRA_Close(d_b) != 0) GA_Error("DRA_Close failed(d_b): ",d_b);
250
 
    tt1 = MP_TIMER() - tt0;
251
 
    GA_Dgop(&tt1,1,"+");
252
 
    tt1 = tt1/((double)nproc);
253
 
    if (me == 0) {
254
 
        printf("Time including DRA_Close\n");
255
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
256
 
                mbytes,tt1,mbytes/tt1);
257
 
    }
258
 
 
259
 
    if (me == 0) printf("\n");
260
 
    if (me == 0) printf("disk array closed\n");
261
 
    if (me == 0) fflush(stdout);
262
 
 
263
 
    GA_Sync();
264
 
    if (me == 0) {
265
 
        printf("Creating Disk array %d",n);
266
 
        for (i=1; i<ndim; i++) {
267
 
            printf(" x %d",n);
268
 
        }
269
 
        printf("\n");
270
 
    }
271
 
    for (i=0; i<ndim; i++) {
272
 
        ddims[i] = n;
273
 
        reqdims[i] = n;
274
 
    }
275
 
    filename_check(filename, FNAME, FNAME_ALT);
276
 
    if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
277
 
                reqdims, &d_a) != 0)
278
 
    {
279
 
        GA_Error("NDRA_Create failed(d_a): ",0);
280
 
    }
281
 
    if (me == 0) printf("alligned blocking write\n");
282
 
    fflush(stdout);
283
 
    tt0 = MP_TIMER();
284
 
    if (NDRA_Write(g_a, d_a, &req) != 0) GA_Error("NDRA_Write failed(d_a):",0);
285
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
286
 
    tt1 = MP_TIMER() - tt0;
287
 
    GA_Dgop(&tt1,1,"+");
288
 
    tt1 = tt1/((double)nproc);
289
 
    mbytes = 1.e-6 * (double)(pow(n,ndim)*sizeof(double));
290
 
    if (me == 0) {
291
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
292
 
                mbytes,tt1,mbytes/tt1);
293
 
    }
294
 
 
295
 
    if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
296
 
    tt1 = MP_TIMER() - tt0;
297
 
    GA_Dgop(&tt1,1,"+");
298
 
    tt1 = tt1/((double)nproc);
299
 
    if (me == 0) {
300
 
        printf("Time including DRA_Close\n");
301
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
302
 
                mbytes,tt1,mbytes/tt1);
303
 
    }
304
 
 
305
 
    if (me == 0) printf("\n");
306
 
    if (me == 0) printf("disk array closed\n");
307
 
    if (me == 0) fflush(stdout);
308
 
#else /* SWITCH */
309
 
    if (me == 0) {
310
 
        printf("Creating Disk array %ld",(long)n);
311
 
        for (i=1; i<ndim; i++) {
312
 
            printf(" x %ld",(long)n);
313
 
        }
314
 
        printf("\n");
315
 
    }
316
 
    if (me == 0) fflush(stdout);
317
 
    for (i=0; i<ndim; i++) {
318
 
        ddims[i] = n;
319
 
        reqdims[i] = n;
320
 
    }
321
 
    GA_Sync();
322
 
    filename_check(filename, FNAME, FNAME_ALT);
323
 
    if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
324
 
                reqdims, &d_a) != 0) {
325
 
        GA_Error("NDRA_Create failed(d_a): ",0);
326
 
    }
327
 
    if (me == 0) printf("alligned blocking write\n");
328
 
    fflush(stdout);
329
 
    tt0 = MP_TIMER();
330
 
    if (NDRA_Write(g_a, d_a, &req) != 0) GA_Error("NDRA_Write failed(d_a):",0);
331
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
332
 
    tt1 = MP_TIMER() - tt0;
333
 
    GA_Dgop(&tt1,1,"+");
334
 
    tt1 = tt1/((double)nproc);
335
 
    mbytes = 1.e-6 * (double)(pow(n,ndim)*sizeof(double));
336
 
    if (me == 0) {
337
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
338
 
                mbytes,tt1,mbytes/tt1);
339
 
    }
340
 
 
341
 
    if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
342
 
    tt1 = MP_TIMER() - tt0;
343
 
    GA_Dgop(&tt1,1,"+");
344
 
    tt1 = tt1/((double)nproc);
345
 
    if (me == 0) {
346
 
        printf("Time including DRA_Close\n");
347
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
348
 
                mbytes,tt1,mbytes/tt1);
349
 
    }
350
 
 
351
 
    if (me == 0) printf("\n");
352
 
    if (me == 0) printf("disk array closed\n");
353
 
    if (me == 0) fflush(stdout);
354
 
    /*.......................................................................*/
355
 
 
356
 
    if (me == 0) {
357
 
        printf("Creating Disk array %ld",(long)m);
358
 
        for (i=1; i<ndim; i++) {
359
 
            printf(" x %ld",(long)m);
360
 
        }
361
 
        printf("\n");
362
 
    }
363
 
    for (i=0; i<ndim; i++) {
364
 
        ddims[i] = m;
365
 
        reqdims[i] = n;
366
 
    }
367
 
    filename_check(filename1, FNAME1, FNAME1_ALT);
368
 
    if (NDRA_Create(MT_DBL, ndim, ddims, "B", filename1, DRA_RW,
369
 
                reqdims, &d_b) != 0) {
370
 
        GA_Error("NDRA_Create failed(d_b): ",0);
371
 
    }
372
 
 
373
 
    if (me == 0) printf("non alligned blocking write\n");
374
 
    if (me == 0) fflush(stdout);
375
 
 
376
 
    for (i=0; i<ndim; i++) {
377
 
        glo[i] = 0;
378
 
        ghi[i] = n-1;
379
 
        dlo[i] = 1;
380
 
        dhi[i] = n;
381
 
    }
382
 
    tt0 = MP_TIMER();
383
 
    if (NDRA_Write_section(FALSE, g_a, glo, ghi,
384
 
                d_b, dlo, dhi, &req) != 0)
385
 
        GA_Error("ndra_write_section failed:",0);
386
 
 
387
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_b): ",req);
388
 
    tt1 = MP_TIMER() - tt0;
389
 
    GA_Dgop(&tt1,1,"+");
390
 
    tt1 = tt1/((double)nproc);
391
 
    mbytes = 1.e-6*(double)(pow(n,ndim)*sizeof(double));
392
 
    if (me == 0) {
393
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
394
 
                mbytes,tt1,mbytes/tt1);
395
 
    }
396
 
 
397
 
    if (DRA_Close(d_b) != 0) GA_Error("DRA_Close failed(d_b): ",d_b);
398
 
    tt1 = MP_TIMER() - tt0;
399
 
    GA_Dgop(&tt1,1,"+");
400
 
    tt1 = tt1/((double)nproc);
401
 
    if (me == 0) {
402
 
        printf("Time including DRA_Close\n");
403
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
404
 
                mbytes,tt1,mbytes/tt1);
405
 
    }
406
 
 
407
 
    if (me == 0) printf("\n");
408
 
    if (me == 0) printf("disk array closed\n");
409
 
    if (me == 0) fflush(stdout);
410
 
#endif /* SWITCH */
411
 
    /*.......................................................................*/
412
 
 
413
 
#if SWITCH
414
 
    if (me == 0) printf("\n");
415
 
    if (me == 0) printf("opening disk array\n");
416
 
    if (DRA_Open(filename1, DRA_R, &d_b) != 0) GA_Error("DRA_Open failed",0);
417
 
    if (me == 0) printf("non alligned blocking read\n");
418
 
    if (me == 0) fflush(stdout);
419
 
    tt0 = MP_TIMER();
420
 
    if (NDRA_Read_section(FALSE, g_b, glo, ghi, d_b, dlo, dhi, &req) != 0)
421
 
        GA_Error("NDRA_Read_section failed:",0);
422
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
423
 
    tt1 = MP_TIMER() - tt0;
424
 
    GA_Dgop(&tt1,1,"+");
425
 
    tt1 = tt1/((double)nproc);
426
 
    if (me == 0) {
427
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
428
 
                mbytes,tt1,mbytes/tt1);
429
 
    }
430
 
    plus = 1.0;
431
 
    minus = -1.0;
432
 
    GA_Add(&plus, g_a, &minus, g_b, g_b);
433
 
    err = GA_Ddot(g_b, g_b);
434
 
    if (err != 0) {
435
 
        if (me == 0) printf("BTW, we have error = %f\n",err);
436
 
    } else {
437
 
        if (me == 0) printf("OK\n");
438
 
    }
439
 
    if (DRA_Delete(d_b) != 0) GA_Error("DRA_Delete failed",0);
440
 
    /*.......................................................................*/
441
 
    if (me == 0) printf("\n");
442
 
    if (me == 0) printf("opening disk array\n");
443
 
    if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
444
 
    if (me == 0) printf("alligned blocking read\n");
445
 
    if (me == 0) fflush(stdout);
446
 
    tt0 = MP_TIMER();
447
 
    if (NDRA_Read(g_b, d_a, &req) != 0) GA_Error("NDRA_Read failed:",0);
448
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
449
 
    tt1 = MP_TIMER() - tt0;
450
 
    GA_Dgop(&tt1,1,"+");
451
 
    tt1 = tt1/((double)nproc);
452
 
    if (me == 0) {
453
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
454
 
                mbytes,tt1,mbytes/tt1);
455
 
    }
456
 
    GA_Add(&plus, g_a, &minus, g_b, g_b);
457
 
    err = GA_Ddot(g_b, g_b);
458
 
    if (err != 0) {
459
 
        if (me == 0) printf("BTW, we have error = %f\n",err);
460
 
    } else {
461
 
        if (me == 0) printf("OK\n");
462
 
    }
463
 
    if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
464
 
#else /* SWITCH */
465
 
    if (me == 0) printf("\n");
466
 
    if (me == 0) printf("opening disk array\n");
467
 
    if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
468
 
    if (me == 0) printf("alligned blocking read\n");
469
 
    if (me == 0) fflush(stdout);
470
 
    tt0 = MP_TIMER();
471
 
    if (NDRA_Read(g_b, d_a, &req) != 0) GA_Error("NDRA_Read failed:",0);
472
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
473
 
    tt1 = MP_TIMER() - tt0;
474
 
    GA_Dgop(&tt1,1,"+");
475
 
    tt1 = tt1/((double)nproc);
476
 
    if (me == 0) {
477
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
478
 
                mbytes,tt1,mbytes/tt1);
479
 
    }
480
 
    plus = 1.0;
481
 
    minus = -1.0;
482
 
    GA_Add(&plus, g_a, &minus, g_b, g_b);
483
 
    err = GA_Ddot(g_b, g_b);
484
 
    if (err != 0) {
485
 
        if (me == 0) printf("BTW, we have error = %f\n",err);
486
 
    } else {
487
 
        if (me == 0) printf("OK\n");
488
 
    }
489
 
    if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
490
 
    /*.......................................................................*/
491
 
 
492
 
    if (me == 0) printf("\n");
493
 
    if (me == 0) printf("opening disk array\n");
494
 
    if (DRA_Open(filename1, DRA_R, &d_b) != 0) GA_Error("DRA_Open failed",0);
495
 
    if (me == 0) printf("non alligned blocking read\n");
496
 
    if (me == 0) fflush(stdout);
497
 
    tt0 = MP_TIMER();
498
 
    if (NDRA_Read_section(FALSE, g_b, glo, ghi, d_b, dlo, dhi, &req) != 0)
499
 
        GA_Error("NDRA_Read_section failed:",0);
500
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
501
 
    tt1 = MP_TIMER() - tt0;
502
 
    GA_Dgop(&tt1,1,"+");
503
 
    tt1 = tt1/((double)nproc);
504
 
    if (me == 0) {
505
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
506
 
                mbytes,tt1,mbytes/tt1);
507
 
    }
508
 
    GA_Add(&plus, g_a, &minus, g_b, g_b);
509
 
    err = GA_Ddot(g_b, g_b);
510
 
    if (err != 0) {
511
 
        if (me == 0) printf("BTW, we have error = %f\n",err);
512
 
    } else {
513
 
        if (me == 0) printf("OK\n");
514
 
    }
515
 
    if (DRA_Delete(d_b) != 0) GA_Error("DRA_Delete failed",0);
516
 
#endif /* SWITCH */
517
 
    /*.......................................................................*/
518
 
    GA_Destroy(g_a);
519
 
    GA_Destroy(g_b);
520
 
    /*.......................................................................*/
521
 
#if TEST_TRANSPOSE
522
 
    /* Test transpose function for DRAs */
523
 
    dims[0] = n;
524
 
    for (i=1; i<ndim; i++) dims[i] = n/2;
525
 
    for (i=0; i<ndim; i++) chunk[i] = 1;
526
 
    if (me == 0) printf("Creating asymmetric arrays to test transpose\n\n");
527
 
    g_c = NGA_Create(MT_DBL, ndim, dims, "c", chunk);
528
 
    if (!g_c) GA_Error("NGA_Create failed: c", 0);
529
 
    g_d = NGA_Create(MT_DBL, ndim, dims, "d", chunk);
530
 
    if (!g_d) GA_Error("NGA_Create failed: d", 0);
531
 
    if (me == 0) printf("done\n");
532
 
    if (me == 0) fflush(stdout);
533
 
 
534
 
    /*     initialize g_a, g_b with random values
535
 
           ... use ga_access to avoid allocating local buffers for ga_put */
536
 
 
537
 
    GA_Sync();
538
 
    NGA_Distribution(g_c, me, glo, ghi);
539
 
    NGA_Access(g_c, glo, ghi, &index, ld);
540
 
    isize = 1;
541
 
    for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
542
 
    fill_random(index, isize);
543
 
    GA_Sync();
544
 
    GA_Zero(g_c);
545
 
    GA_Copy(g_c,g_d);
546
 
 
547
 
    for (i=0; i<ndim; i++) {
548
 
        ddims[i] = m;
549
 
        reqdims[i] = n;
550
 
    }
551
 
    filename_check(filename2, FNAME2, FNAME2_ALT);
552
 
    if (me == 0) printf("Creating DRA for transpose test\n");
553
 
    if (NDRA_Create(MT_DBL, ndim, ddims, "C", filename2, DRA_RW,
554
 
                reqdims, &d_c) != 0) {
555
 
        GA_Error("NDRA_Create failed(d_c): ",0);
556
 
    }
557
 
    if (me == 0) printf("done\n");
558
 
    if (me == 0) fflush(stdout);
559
 
    GA_Sync();
560
 
    for (i=0; i<ndim-1; i++) {
561
 
        dlo[i] = 1;
562
 
        dhi[i] = n/2;
563
 
    }
564
 
    dlo[ndim-1] = 1;
565
 
    dhi[ndim-1] = n;
566
 
    glo[0] = 0;
567
 
    ghi[0] = n-1;
568
 
    for (i=1; i<ndim; i++) {
569
 
        glo[i] = 0;
570
 
        ghi[i] = n/2-1;
571
 
    }
572
 
    if (me == 0) printf("non-aligned blocking write with transpose\n");
573
 
    tt0 = MP_TIMER();
574
 
    if (NDRA_Write_section(TRUE,g_c,glo,ghi,d_c,dlo,dhi,&req) != 0)
575
 
        GA_Error("NDRA_Write_section (transpose) failed: ",0);
576
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
577
 
    isize = 1;
578
 
    for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
579
 
    mbytes = 1.e-6 * (double)(isize*sizeof(double));
580
 
    tt1 = MP_TIMER() - tt0;
581
 
    GA_Dgop(&tt1,1,"+");
582
 
    tt1 = tt1/((double)nproc);
583
 
    if (me == 0) {
584
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
585
 
                mbytes,tt1,mbytes/tt1);
586
 
    }
587
 
    if (DRA_Close(d_c) != 0) GA_Error("DRA_Close failed(d_c): ",d_c);
588
 
    if (me == 0) printf("\n");
589
 
    if (me == 0) printf("disk array closed\n");
590
 
    if (me == 0) fflush(stdout);
591
 
 
592
 
    if (me == 0) printf("\n");
593
 
    if (me == 0) printf("opening disk array\n");
594
 
    if (DRA_Open(filename2, DRA_R, &d_c) != 0) GA_Error("DRA_Open failed",0);
595
 
 
596
 
    GA_Zero(g_c);
597
 
    if (me == 0) printf("non-aligned blocking read with transpose\n");
598
 
    tt0 = MP_TIMER();
599
 
    if (NDRA_Read_section(TRUE,g_c,glo,ghi,d_c,dlo,dhi,&req) != 0)
600
 
        GA_Error("NDRA_Read_section (transpose) failed: ",0);
601
 
    if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
602
 
    tt1 = MP_TIMER() - tt0;
603
 
    GA_Dgop(&tt1,1,"+");
604
 
    tt1 = tt1/((double)nproc);
605
 
    if (me == 0) {
606
 
        printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
607
 
                mbytes,tt1,mbytes/tt1);
608
 
    }
609
 
    GA_Add(&plus, g_c, &minus, g_d, g_d);
610
 
    err = GA_Ddot(g_d, g_d);
611
 
    if (err != 0) {
612
 
        if (me == 0) printf("BTW, we have error = %f\n",err);
613
 
    } else {
614
 
        if (me == 0) printf("OK\n");
615
 
    }
616
 
    if (DRA_Delete(d_c) != 0) GA_Error("DRA_Delete failed",0);
617
 
    /*.......................................................................*/
618
 
    GA_Destroy(g_c);
619
 
    GA_Destroy(g_d);
620
 
#endif /* TEST_TRANSPOSE */
621
 
}
622
 
 
623
 
 
624
 
int main(int argc, char **argv)
625
 
{
626
 
    int status, me;
627
 
    int max_arrays = 10;
628
 
    double max_sz = 1e8, max_disk = 1e10, max_mem = 1e6;
629
 
    int numfiles, numioprocs;
630
 
#if defined(IBM)
631
 
    int stack = 9000000, heap = 4000000;
632
 
#else
633
 
    int stack = 12000000, heap = 8000000;
634
 
#endif
635
 
 
636
 
    MP_INIT(argc,argv);
637
 
    GA_Initialize();
638
 
    if (!GA_Uses_ma()) {
639
 
        if (GA_Nodeid() == 0) printf("GA not using MA\n");
640
 
        stack = 100000;
641
 
        heap = 2*sizeof(double)*pow(SIZE,NDIM)/GA_Nnodes()+10000000;
642
 
    }
643
 
 
644
 
    me = GA_Nodeid();
645
 
    if (MA_init(MT_F_DBL, stack, heap) ) {
646
 
        if (DRA_Init(max_arrays, max_sz, max_disk, max_mem) != 0)
647
 
            GA_Error("DRA_Init failed: ",0);
648
 
        if (USER_CONFIG == 0) {
649
 
            numfiles = -1;
650
 
            numioprocs = -1;
651
 
        } else if (USER_CONFIG == 1) {
652
 
            numfiles = 1;
653
 
            numioprocs = GA_Cluster_nnodes();
654
 
        } else if (USER_CONFIG == 2) {
655
 
            numfiles = GA_Cluster_nnodes();
656
 
            numioprocs = GA_Cluster_nnodes();
657
 
        } else {
658
 
            numfiles = 1;
659
 
            numioprocs = 1;
660
 
        }
661
 
        if (me==0) {
662
 
            printf("Disk resident arrays configured as:\n");
663
 
            printf("    Number of files: %d\n",numfiles);
664
 
            printf("    Number of I/O processors: %d\n",numioprocs);
665
 
        }
666
 
        DRA_Set_default_config(numfiles,numioprocs);
667
 
        if (me == 0) printf("\n");
668
 
        if (me == 0) printf("TESTING PERFORMANCE OF DISK ARRAYS\n");
669
 
        if (me == 0) printf("\n");
670
 
        test_io_dbl();
671
 
        status = DRA_Terminate();
672
 
        GA_Terminate();
673
 
    } else {
674
 
        printf("MA_init failed\n");
675
 
    }
676
 
    if(me == 0) printf("all done ...\n");
677
 
    MP_FINALIZE();
678
 
    return 0;
679
 
}