From 0a364ca46c3947fcc9510e202a46719954fa2416 Mon Sep 17 00:00:00 2001 From: "T.Tian" Date: Thu, 18 Jan 2024 14:05:15 +0800 Subject: [PATCH] add missing initialization part --- src/include/isddft.h | 2 +- src/initialization.c | 13 +++++++++++++ src/socket/driver.c | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/include/isddft.h b/src/include/isddft.h index 8675c832..bfdc4e3b 100644 --- a/src/include/isddft.h +++ b/src/include/isddft.h @@ -1001,7 +1001,7 @@ typedef struct _SPARC_OBJ{ int socket_port; // socket host int socket_inet; // boolean value to indicate whether to use inet socket int socket_fd; // socket file descriptor; This should be initialized to -1 - int socket_max_niter; // max number of iterations + int socket_max_niter; // max number of iterations. Default is 10000 #endif }SPARC_OBJ; diff --git a/src/initialization.c b/src/initialization.c index b6b22c71..55794fa0 100644 --- a/src/initialization.c +++ b/src/initialization.c @@ -830,6 +830,19 @@ void set_defaults(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC) { /* Default parameter for cyclix */ pSPARC_Input->twist = 0.0; + + /* Default socket options */ +#ifdef USE_SOCKET + // Defaults for pSPARC_Input, if not initialized by the cmdline + if (pSPARC_Input->SocketFlag != 1) + { + pSPARC_Input->SocketFlag = 0; // socket off + strncpy(pSPARC_Input->socket_host, "localhost", sizeof(pSPARC_Input->socket_host)); + pSPARC_Input->socket_port = -1; // socket port + pSPARC_Input->socket_inet = 0; // 0: -> default unix socket, 1: -> inet socket + } + pSPARC_Input->socket_max_niter = 10000; // Set to a very large number +#endif } diff --git a/src/socket/driver.c b/src/socket/driver.c index 6f08e0a6..15a4cdb8 100644 --- a/src/socket/driver.c +++ b/src/socket/driver.c @@ -772,6 +772,10 @@ void main_Socket(SPARC_OBJ *pSPARC) status = -1; // -1: not initialized init = 1; hasdata = 0; +#ifdef DEBUG + if (rank == 0) + printf("Status: socket_max_niter %d\n", pSPARC->socket_max_niter); +#endif // DEBUG // TODO: option to specify N_MAXSTEPS (or directly taken from MD / relax?) while (pSPARC->SocketSCFCount <= pSPARC->socket_max_niter) {