[Pw_forum] stack.c in Mac OS X/Intel
Cesar R.S. da Silva
cesards at msi.umn.edu
Tue Mar 4 06:51:36 CET 2008
Problem: Mac OS X does not allow regular users to set stack limits above
certain maximum. Therefore, the esprsso-distribution clib/stack.c fails.
Solution: I patched stack.c to work around this problem. This is the code:
**************************************************************************
/*
Copyright (C) 2007 Quantum-Espresso group
This file is distributed under the terms of the
GNU General Public License. See the file `License'
in the root directory of the present distribution,
or http://www.gnu.org/copyleft/gpl.txt .
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include "c_defs.h"
void F77_FUNC(remove_stack_limit,REMOVE_STACK_LIMIT) (void) {
struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY };
if ( setrlimit(RLIMIT_STACK, &rlim) == -1 ) {
printf("Cannot set stack size to infinity!");
/* exit(1); */
if ( getrlimit(RLIMIT_STACK, &rlim) == 0 ) {
printf(" Trying to set stack size to the maximum");
printf(" Current Stack limits : %12i %12i
\n",rlim.rlim_cur,rlim.rlim_max);
rlim.rlim_cur = rlim.rlim_max;
if ( setrlimit(RLIMIT_STACK, &rlim) == 0 ) {
getrlimit(RLIMIT_STACK, &rlim);
printf(" SUCCESS! Stack size set to %12i \n",rlim.rlim_cur);
} else {
printf(" Failed! Cannot set stack size to new value");
perror(" Failed! Cannot set stack size to new value");
}
}
}
}
**************************************************************************
----------------------------------------------------
Cesar R.S. da Silva, PhD.
Minnesota Supercomputing Institute,
University of Minnesota.
Phone: (612)-624-7425 e-mail: cesards at msi.umn.edu
----------------------------------------------------
More information about the users
mailing list