~ubuntu-branches/ubuntu/utopic/nwchem/utopic

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/pario/elio/stat.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
 
/* $Id: stat.c,v 1.20.10.3 2007-08-30 18:19:44 manoj Exp $ */
6
 
 
7
 
#include "eliop.h"
8
 
#include "chemio.h"
9
 
 
10
 
#if defined(CRAY) && defined(__crayx1)
11
 
#undef CRAY
12
 
#endif
13
 
 
14
 
#define DEBUG_ 0
15
 
 
16
 
 
17
 
/**
18
 
 * determines directory path for a given file
19
 
 */
20
 
int elio_dirname(const char *fname, char *dirname, int len)
21
 
{
22
 
    size_t flen = strlen(fname);
23
 
    
24
 
    if(len<=((int)flen)) 
25
 
    ELIO_ERROR(LONGFAIL,flen);
26
 
    
27
 
#ifdef WIN32
28
 
    while(fname[flen] != '/' && fname[flen] != '\\' && flen >0 ) flen--;
29
 
#else
30
 
    while(fname[flen] != '/' && flen >0 ) flen--;
31
 
#endif
32
 
 
33
 
    if(flen==0)strcpy(dirname,".");
34
 
    else {strncpy(dirname, fname, flen); dirname[flen]=(char)0;}
35
 
    
36
 
    return(ELIO_OK);
37
 
}
38
 
 
39
 
 
40
 
#ifdef WIN32
41
 
#include <direct.h>
42
 
#include <stdlib.h>
43
 
 
44
 
/**
45
 
 * determine drive name given the file path name
46
 
 */ 
47
 
char* elio_drivename(const char* fname)
48
 
{
49
 
 
50
 
         static char path[_MAX_PATH];
51
 
         static char drive[_MAX_DRIVE];
52
 
         
53
 
         if( _fullpath(path,fname,_MAX_PATH) == NULL) return NULL;
54
 
         _splitpath(path, drive, NULL, NULL, NULL);
55
 
         return(drive);
56
 
}
57
 
 
58
 
 
59
 
void  get_avail_space(int dev, avail_t *avail, int* bsize)
60
 
{
61
 
      static char drive[4]="A:\\";
62
 
      int sectors, cfree, ctotal;
63
 
      drive[0]= dev + 'A';
64
 
 
65
 
      GetDiskFreeSpace(drive, &sectors, bsize, &cfree, &ctotal);
66
 
      *avail = sectors*(avail_t)cfree;
67
 
}
68
 
 
69
 
#endif /* WIN32 */
70
 
         
71
 
         
72
 
/**
73
 
 * Stat a file (or path) to determine it's filesystem info
74
 
 */
75
 
int  elio_stat(char *fname, stat_t *statinfo)
76
 
{
77
 
    struct  stat      ufs_stat;
78
 
    int bsize;
79
 
    
80
 
    struct  STATVFS   ufs_statfs;
81
 
    
82
 
    PABLO_start(PABLO_elio_stat); 
83
 
    
84
 
    if(stat(fname, &ufs_stat) != 0)
85
 
        ELIO_ERROR(STATFAIL, 1);
86
 
 
87
 
#   if defined(PIOFS)
88
 
/*        fprintf(stderr,"filesystem %d\n",ufs_stat.st_vfstype);*/
89
 
        /* according to /etc/vfs, "9" means piofs */
90
 
        if(ufs_stat.st_vfstype == 9) statinfo->fs = ELIO_PIOFS;
91
 
        else
92
 
#   endif
93
 
 
94
 
    statinfo->fs = ELIO_UFS;
95
 
    
96
 
    /* only regular or directory files are OK */
97
 
    if(!S_ISREG(ufs_stat.st_mode) && !S_ISDIR(ufs_stat.st_mode))
98
 
        ELIO_ERROR(TYPEFAIL, 1);
99
 
    
100
 
#   if defined(CRAY) || defined(NEC)
101
 
    if(statfs(fname, &ufs_statfs, sizeof(ufs_statfs), 0) != 0)
102
 
#   elif defined (CATAMOUNT)
103
 
        statinfo->avail =2*1024*1024*128; 
104
 
        return(ELIO_OK);
105
 
#   else
106
 
        if(STATVFS(fname, &ufs_statfs) != 0)
107
 
#   endif
108
 
           ELIO_ERROR(STATFAIL,1);
109
 
    
110
 
#   if defined(WIN32)
111
 
 
112
 
       get_avail_space(ufs_statfs.st_dev, &(statinfo->avail), &bsize);
113
 
      
114
 
#   else
115
 
      /* get number of available blocks */
116
 
#     if defined(CRAY) || defined(NEC)
117
 
          /* f_bfree == f_bavail -- naming changes */
118
 
 
119
 
#        ifdef CRAY
120
 
          if(ufs_statfs.f_secnfree != 0) /* check for secondary partition */
121
 
             statinfo->avail = (avail_t) ufs_statfs.f_secnfree;
122
 
          else
123
 
#        endif
124
 
             statinfo->avail = (avail_t) ufs_statfs.f_bfree;
125
 
#     else
126
 
          statinfo->avail = (avail_t) ufs_statfs.f_bavail;
127
 
#     endif
128
 
 
129
 
#     ifdef NO_F_FRSIZE
130
 
         /*       on some older systems it was f_bsize */
131
 
         bsize = (int) ufs_statfs.f_bsize; 
132
 
#     else
133
 
         /* get block size, fail if bszie is still 0 */
134
 
         bsize = (int) ufs_statfs.f_frsize;
135
 
         if(bsize==0)bsize =(int) ufs_statfs.f_bsize; 
136
 
         if(bsize==0) ELIO_ERROR(STATFAIL, 1);
137
 
 
138
 
         if(DEBUG_)
139
 
           printf("stat: f_frsize=%d f_bsize=%d bsize=%d free blocks=%ld\n",
140
 
            (int) ufs_statfs.f_frsize,(int) ufs_statfs.f_bsize, bsize,
141
 
            statinfo->avail );
142
 
#     endif
143
 
#   endif
144
 
    
145
 
    /* translate number of available blocks into kilobytes */
146
 
    switch (bsize) {
147
 
    case 512:  statinfo->avail /=2; break;
148
 
    case 1024: break;
149
 
    case 2048: statinfo->avail *=2; break;
150
 
    case 4096: statinfo->avail *=4; break;
151
 
    case 8192: statinfo->avail *=8; break;
152
 
    case 16384: statinfo->avail *=16; break;
153
 
    case 32768: statinfo->avail *=32; break;
154
 
    default:   { 
155
 
        double avail;
156
 
        double factor = ((double)bsize)/1024.0;
157
 
        avail = factor * (double)statinfo->avail;
158
 
        statinfo->avail = (avail_t) avail;
159
 
               }
160
 
    }
161
 
    
162
 
    PABLO_end(PABLO_elio_stat);
163
 
    return(ELIO_OK);
164
 
}