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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/armci/tcgmsg/ipcv4.0/pfilecopy.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
 
/* $Header: /tmp/hpctools/ga/tcgmsg/ipcv4.0/pfilecopy.c,v 1.9 2004-05-07 20:45:10 pollack Exp $ */
6
 
 
7
 
#include <stdio.h>
8
 
#ifdef SEQUENT
9
 
#include <strings.h>
10
 
#else
11
 
#include <string.h>
12
 
#endif
13
 
#include "sndrcv.h"
14
 
#include "msgtypesc.h"
15
 
 
16
 
#if defined(ULTRIX) || defined(SGI) || defined(NEXT) || defined(HPUX) || \
17
 
    defined(KSR)    || defined(DECOSF)
18
 
extern void *malloc();
19
 
#else
20
 
extern void *malloc();
21
 
#endif
22
 
 
23
 
extern void free();
24
 
 
25
 
void tcgi_pfilecopy(type, node0, filename)
26
 
     long *type, *node0;
27
 
     char *filename;
28
 
/*
29
 
  Process node0 has a file (assumed unopened) named fname.
30
 
  This file will be copied to all other processes which must
31
 
  simultaneously invoke pfilecopy. Since the processes may be
32
 
  using the same directory one probably ought to make sure
33
 
  that each process uses a different name in the call.
34
 
 
35
 
     e.g.
36
 
 
37
 
     on node 0    pfilecopy(99, 0, 'argosin')
38
 
     on node 1    pfilecopy(99, 0, 'argosin_001')
39
 
     on node 2    pfilecopy(99, 0, 'argosin_002')
40
 
*/
41
 
  
42
 
{
43
 
  char *buffer;
44
 
  FILE *file;
45
 
  long length, nread=32768, len_nread=sizeof(long);
46
 
  long typenr = (*type & 32767) | MSGINT;   /* Force user type integer */
47
 
  long typebuf =(*type & 32767) | MSGCHR;
48
 
 
49
 
  if (!(buffer = malloc((unsigned) nread)))
50
 
    Error("pfilecopy: failed to allocate the I/O buffer",nread);
51
 
 
52
 
  if (*node0 == NODEID_()) {
53
 
 
54
 
    /* I have the original file ... open and check its size */
55
 
    
56
 
    if ((file = fopen(filename,"r")) == (FILE *) NULL) {
57
 
      (void) fprintf(stderr,"me=%ld, filename = %s.\n",NODEID_(),filename);
58
 
      Error("pfilecopy: node0 failed to open original file", *node0);
59
 
    }
60
 
    
61
 
    /* Quick sanity check on the length */
62
 
 
63
 
    (void) fseek(file, 0L, (int) 2);   /* Seek to end of file */
64
 
    length = ftell(file);              /* Find the length of file */
65
 
    (void) fseek(file, 0L, (int) 0);   /* Seek to beginning of file */
66
 
    if ( (length<0) || (length>1e12) )
67
 
      Error("pfilecopy: the file length is -ve or very big", length);
68
 
 
69
 
    /* Send the file in chunks of nread bytes */
70
 
 
71
 
    while (nread) {
72
 
      nread = fread(buffer, 1, (int) nread, file);
73
 
      BRDCST_(&typenr, (char *) &nread, &len_nread, node0);
74
 
      typenr++;
75
 
      if (nread) {
76
 
        BRDCST_(&typebuf, buffer, &nread, node0);
77
 
        typebuf++;
78
 
      }
79
 
    }
80
 
  }
81
 
  else {
82
 
    
83
 
    /* Open the file for the duplicate */
84
 
 
85
 
    if ((file = fopen(filename,"w+")) == (FILE *) NULL) {
86
 
      (void) fprintf(stderr,"me=%ld, filename = %s.\n",NODEID_(),filename);
87
 
      Error("pfilecopy: failed to open duplicate file", *node0);
88
 
    }
89
 
    
90
 
    /* Receive data and write to file */
91
 
 
92
 
    while (nread) {
93
 
      BRDCST_(&typenr, (char *) &nread, &len_nread, node0);
94
 
      typenr++;
95
 
      if (nread) {
96
 
        BRDCST_(&typebuf, buffer, &nread, node0);
97
 
        typebuf++;
98
 
        if (nread != fwrite(buffer, 1, (int) nread, file))
99
 
          Error("pfilecopy: error data to duplicate file", nread);
100
 
      }
101
 
    }
102
 
  }
103
 
  
104
 
  /* Tidy up the stuff we have been using */
105
 
 
106
 
  (void) fflush(file);
107
 
  (void) fclose(file);
108
 
  (void) free(buffer);
109
 
}
110
 
 
111
 
void PFILECOPY_(type, node0, filename)
112
 
     long *type, *node0;
113
 
     char *filename;
114
 
{
115
 
    tcgi_pfilecopy(type, node0, filename);
116
 
}
117
 
 
118
 
#ifdef IPSC
119
 
#define bcopy(a, b, n) memcpy((b), (a), (n))
120
 
#endif
121
 
 
122
 
#ifdef CRAY
123
 
#include <fortran.h>
124
 
#endif
125
 
#ifdef ARDENT
126
 
struct char_desc {
127
 
  char *string;
128
 
  int len;
129
 
};
130
 
#endif
131
 
 
132
 
/* This crap because FORTRAN has no standard for passing strings */
133
 
 
134
 
#ifdef ARDENT
135
 
void PFCOPY_(type, node0, arg)
136
 
     long *type;
137
 
     long *node0;
138
 
     struct char_desc *arg;
139
 
{
140
 
  char *fname = arg->string;
141
 
  int   len = arg->len;
142
 
#endif
143
 
#ifdef CRAY
144
 
void PFCOPY_(type, node0, arg)
145
 
     long *type;
146
 
     long *node0;
147
 
     _fcd arg;
148
 
{
149
 
  char *fname = _fcdtocp(arg);
150
 
  int len = _fcdlen(arg);
151
 
#endif
152
 
#if !defined(ARDENT) && !defined(CRAY)
153
 
void PFCOPY_(type, node0, fname, len)
154
 
  long *type;
155
 
  long *node0;
156
 
  char *fname;
157
 
  int   len;
158
 
{
159
 
#endif
160
 
 
161
 
  /* Fortran wrapper around pfilecopy */
162
 
 
163
 
  char *filename;
164
 
 
165
 
#ifdef DEBUG 
166
 
  (void) printf("me=%d, type=%d, node0=%d, fname=%x, fname=%.8s, len=%d\n",
167
 
                NODEID_(), *type, *node0, fname, fname, len);
168
 
#endif 
169
 
 
170
 
  /* Strip trailing blanks off the file name */
171
 
 
172
 
  while ((len > 0) && (fname[len-1] == ' '))
173
 
    len--;
174
 
  if (len <= 0)
175
 
    Error("pfcopy_: file name length is toast", (long) len);
176
 
 
177
 
  /* Generate a NULL terminated string */
178
 
 
179
 
  filename = malloc( (unsigned) (len+1) );
180
 
  if (filename) {
181
 
    (void) bcopy(fname, filename, len);
182
 
    filename[len] = '\0';
183
 
  }
184
 
  else
185
 
    Error("PFCOPY_: failed to malloc space for filename", (long) len);
186
 
 
187
 
  /* Now call the C routine to do the work */
188
 
 
189
 
  tcgi_pfilecopy(type, node0, filename);
190
 
 
191
 
  (void) free(filename);
192
 
}
193