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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/armci/src/common/spawn.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
/* OS specific server process/thread creation and destruction  
 
6
 * JN/03.25.2000
 
7
 */
 
8
#if HAVE_STDIO_H
 
9
#   include <stdio.h>
 
10
#endif
 
11
#if HAVE_ERRNO_H
 
12
#   include <errno.h>
 
13
#endif
 
14
#include "armcip.h"
 
15
 
 
16
#ifdef WIN32
 
17
/************************** Windows threads **************************/
 
18
#if HAVE_WINDOWS_H
 
19
#   include <windows.h>
 
20
#endif
 
21
#if HAVE_PROCESS_H
 
22
#   include <process.h>
 
23
#endif
 
24
 
 
25
thread_id_t armci_serv_tid;
 
26
unsigned long armci_serv_handle;
 
27
#ifndef NO_STDLIBC
 
28
#define NEWTHREAD CreateThread
 
29
#else
 
30
#define NEWTHREAD _beginthreadex 
 
31
#endif
 
32
 
 
33
unsigned __stdcall armci_wrap_func(void *arg)
 
34
{
 
35
void (*func)(void*);
 
36
     func = arg;
 
37
 
 
38
     /* boost the server thread priority be better responsiveness */
 
39
     (void)SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST);
 
40
 
 
41
     func(NULL);
 
42
 
 
43
     return (unsigned)0;
 
44
}
 
45
 
 
46
 
 
47
void armci_create_server_thread ( void* (* func)(void*) )
 
48
{
 
49
     /* as we need to use std C rt library we cannot use CreateThread */
 
50
     armci_serv_handle = NEWTHREAD(NULL, 0, armci_wrap_func, (void*)func, 
 
51
                                         0, &armci_serv_tid);
 
52
     if(!armci_serv_handle) 
 
53
         armci_die("armci_create_server_thread: create failed",0);
 
54
 
 
55
 
 
56
 
 
57
}
 
58
 
 
59
void armci_terminate_server_thread()
 
60
{
 
61
/*int rc;*/
 
62
/*    TerminateThread(armci_serv_handle,&rc);*/
 
63
}
 
64
 
 
65
/****************************** PTHREADS *****************************/
 
66
#elif defined(PTHREADS)
 
67
#include <pthread.h>
 
68
 
 
69
thread_id_t armci_serv_tid;
 
70
 
 
71
void armci_create_server_thread ( void* (* func)(void*) )
 
72
{
 
73
pthread_attr_t attr;
 
74
int rc;
 
75
 
 
76
    if(pthread_attr_init(&attr))
 
77
       armci_die("armci_create_server_thread: attr init failed",0);
 
78
 
 
79
#if defined(AIX) || defined(SOLARIS)
 
80
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
 
81
#endif
 
82
 
 
83
    rc = pthread_create(&armci_serv_tid, &attr, func, NULL);
 
84
    if(rc) armci_die("armci_create_server_thread: create failed",errno);
 
85
 
 
86
    pthread_attr_destroy(&attr);
 
87
}
 
88
 
 
89
 
 
90
void armci_terminate_server_thread()
 
91
{
 
92
  if(pthread_join(armci_serv_tid,NULL))
 
93
     armci_die("armci_terminate_server_thread: failed",0);
 
94
}
 
95
 
 
96
 
 
97
#else
 
98
/**************************** Unix processes ******************************/
 
99
 
 
100
#if HAVE_UNISTD_H
 
101
#   include <unistd.h>
 
102
#endif
 
103
#if HAVE_SYS_TYPES_H
 
104
#   include <sys/types.h>
 
105
#endif
 
106
#if HAVE_SYS_WAIT_H
 
107
#   include <sys/wait.h>
 
108
#endif
 
109
 
 
110
pid_t server_pid= (pid_t)0;
 
111
 
 
112
 
 
113
void armci_create_server_process ( void* (* func)(void*) )
 
114
{
 
115
pid_t pid;     
 
116
 
 
117
     if ( (pid = fork() ) < 0)
 
118
        armci_die("fork failed", (int)pid);
 
119
 
 
120
     else if(pid == 0){
 
121
 
 
122
        armci_me = SOFFSET - armci_me; /* server id derived from parent id */
 
123
 
 
124
        func(NULL);
 
125
 
 
126
     } else server_pid = pid;
 
127
}
 
128
 
 
129
 
 
130
void armci_wait_server_process()
 
131
{
 
132
     int stat;
 
133
     pid_t rc;
 
134
 
 
135
     if(!server_pid) return;
 
136
     rc = wait (&stat);
 
137
     if (rc != server_pid){
 
138
         perror("ARMCI master: wait for child process (server) failed:");
 
139
     }
 
140
     server_pid = (pid_t)0;
 
141
}
 
142
 
 
143
#endif