Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ce7b252
in meson.build, ignore libm dependency on win
rwxayheee Apr 18, 2025
a1497f1
replace paramdat2h.csh by python for windows compatibility
rwxayheee Apr 18, 2025
d315fdf
revise compiler flags for windows
rwxayheee Apr 18, 2025
4487f45
add missing endif
rwxayheee Apr 18, 2025
d2c7642
centralized win_compat.h patch
rwxayheee Apr 18, 2025
32ee9c8
replace openmp compile flag for msvc
rwxayheee Apr 18, 2025
84355d6
cover sys/time.h
rwxayheee Apr 18, 2025
05d5e0a
fix some unistd.h
rwxayheee Apr 18, 2025
80ccf24
fix strings.h
rwxayheee Apr 18, 2025
62e7426
include a mimic of bzero in win_compat.h
rwxayheee Apr 18, 2025
c6aebd6
small fixes
rwxayheee Apr 19, 2025
001b36f
include winsock2 after windows.h
rwxayheee Apr 19, 2025
629929f
small fixes
rwxayheee Apr 19, 2025
0362565
enforce const char when applicable
rwxayheee Apr 19, 2025
53e973b
fix strindex
rwxayheee Apr 19, 2025
c23a27c
guard winsock2 include against conflicting winsock
rwxayheee Apr 19, 2025
003ddf8
use WIN32_LEAN_AND_MEAN
rwxayheee Apr 19, 2025
31d5226
add NOMINMAX
rwxayheee Apr 19, 2025
75112c2
remove helper python file
rwxayheee Apr 19, 2025
6ca8020
rearrange include order
rwxayheee Apr 19, 2025
67d4eb8
revise and add win_compat.h to meson.build
rwxayheee Apr 19, 2025
358e9cc
fix include names
rwxayheee Apr 19, 2025
b4d1389
ignore conflicting macros if on windows
rwxayheee Apr 19, 2025
a594864
undefine macros in windows sdk
rwxayheee Apr 19, 2025
ac23f98
isolate windows.h
rwxayheee Apr 19, 2025
c0a48fe
small fixes
rwxayheee Apr 19, 2025
78ffa95
minor fix
rwxayheee Apr 19, 2025
2430746
fix VLA
rwxayheee Apr 19, 2025
2afde75
include vector
rwxayheee Apr 19, 2025
fd97086
fix mismatched types
rwxayheee Apr 19, 2025
5fa5503
small fixes; can build on mac
rwxayheee Apr 19, 2025
8ac47ca
fix printdate
rwxayheee Apr 19, 2025
d2485af
fix setup_parameter_library
rwxayheee Apr 19, 2025
5b1392f
fix read_parameter_library.h
rwxayheee Apr 19, 2025
9c176f2
add extern C to read_parameter_library.cc
rwxayheee Apr 19, 2025
4f2fb1c
optionally, allow build into self-contained .exe
rwxayheee Apr 19, 2025
fe71a97
fix option order in meson.build
rwxayheee Apr 19, 2025
311cd11
force build into self-contained .exe
rwxayheee Apr 19, 2025
6bc46a0
minimize diff
rwxayheee Apr 20, 2025
538e6d8
add mainpost1.28.cpp back, although not used
rwxayheee Apr 20, 2025
d69f2fe
change O2 to O3 for msvc
rwxayheee Apr 20, 2025
b41c486
remove files accidentally added
rwxayheee Apr 20, 2025
f3b111e
change O3 to Ox
rwxayheee Apr 20, 2025
d61cd6f
remove .DS_Store
rwxayheee Apr 20, 2025
2b78dc0
revise control flags to enforce numerical consist
rwxayheee Apr 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ad4_shared/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#define LOGETABLES 7
#define LOGNBINTE 8 // analysis.cc nonbond internal energy table
#define LOGNBINTEV 9 // analysis.cc;nbe.cc nonbond internal energy table verbose
const struct {
static const struct {
int value;
char *key;
const char *key;
} outlev_lookup[] = {
{LOGMIN, "min"},
{LOGMINCLUST, "mincluster"},
Expand Down
2 changes: 1 addition & 1 deletion ad4_shared/openfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ int openFile( const char *const filename,
const Boole mayExit,
FILE *logFile);

FILE *ad_fopen(const char *const path, const char *const mode, FILE *logFile);
FILE *ad_fopen(const char *path, const char *mode, FILE *logFile);

#endif
32 changes: 0 additions & 32 deletions ad4_shared/paramdat2h.csh

This file was deleted.

20 changes: 20 additions & 0 deletions ad4_shared/paramdat2h.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3

import sys

if len(sys.argv) != 3:
print("Usage: python paramdat2h.py AD4_parameters.dat AD4.1_bound.dat", file=sys.stderr)
sys.exit(1)

def format_param_file(filename, array_name):
print(f'const char *{array_name}[MAX_LINES] = {{')
with open(filename, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#'):
print(f'"{line}\\n", ')
print('};')

format_param_file(sys.argv[1], 'param_string_4_0')
format_param_file(sys.argv[2], 'param_string_4_1')
print('// EOF')
4 changes: 4 additions & 0 deletions ad4_shared/parse_param_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include <ctype.h>
#include "parse_param_line.h"

#ifdef _WIN32
#include "win_compat.h"
#endif

#ifdef DEBUG
extern int debug;
extern FILE *logFile; // DEBUG only
Expand Down
6 changes: 5 additions & 1 deletion ad4_shared/printdate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include <stdio.h>
#include <sys/types.h>

#ifdef _WIN32
#include "win_compat.h"
#else
#include <sys/time.h>
#endif

#ifdef HAVE_CONFIG_H
# include <config.h>
Expand All @@ -37,7 +41,7 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include "printdate.h"
// this source file is shared by AutoDock and AutoGrid

void printdate( FILE *const fp, const int flag )
void printdate(FILE *fp, int flag)
{
time_t tn; /* tn = "time_now" */
char *StringTimeDate;
Expand Down
2 changes: 1 addition & 1 deletion ad4_shared/printdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.

#include "autocomm.h"

void printdate( FILE *const fp, const int flag );
void printdate(FILE *fp, int flag);
#endif
10 changes: 7 additions & 3 deletions ad4_shared/read_parameter_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static Boole string_ends_with(const char *const a, const char *const b);

static char parameter_library[MAX_CHARS];

extern "C" {
void read_parameter_library(
FILE *logFile,
const int outlev,
Expand Down Expand Up @@ -199,9 +200,10 @@ void read_parameter_library(
} // while there is another line of parameters to read in
}

void setup_parameter_library( FILE *logFile, const int outlev,
const char *const model_text, const Unbound_Model unbound_model,
Linear_FE_Model *AD4)

void setup_parameter_library(FILE *logFile, int outlev,
const char *model_text, Unbound_Model unbound_model,
Linear_FE_Model *AD4)
{
static ParameterEntry thisParameter;
char parameter_library_line[LINE_LEN];
Expand Down Expand Up @@ -382,6 +384,8 @@ void setup_parameter_library( FILE *logFile, const int outlev,
} // while there is another line of parameters to read in
}

} // extern "C"

const char * report_parameter_library() {
return parameter_library;
}
Expand Down
49 changes: 28 additions & 21 deletions ad4_shared/read_parameter_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,35 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.

#include "autocomm.h"

#ifdef __cplusplus
extern "C" {
#endif

void read_parameter_library(
FILE *logFile,
const int outlev,
const char *const FN_parameter_library,
Linear_FE_Model *AD4
);
FILE *logFile,
int outlev,
const char *FN_parameter_library,
Linear_FE_Model *AD4
);

void setup_parameter_library(
FILE *logFile,
const int outlev,
const char * model_text,
const Unbound_Model unbound_model,
Linear_FE_Model *AD4
);

// The returned string is not supposed to be changed
const char * report_parameter_library();

void setup_distdepdiel( FILE *logFile,
const int outlev,
EnergyTables *const ptr_ad_energy_tables // Holds vdw+Hb, desolvation & dielectric lookup tables
);


FILE *logFile,
int outlev,
const char *model_text,
Unbound_Model unbound_model,
Linear_FE_Model *AD4
);

const char *report_parameter_library();

void setup_distdepdiel(
FILE *logFile,
int outlev,
EnergyTables *ptr_ad_energy_tables // Holds vdw+Hb, desolvation & dielectric lookup tables
);

#ifdef __cplusplus
}
#endif

#endif /* _READ_PARAMETER_LIBRARY */
4 changes: 4 additions & 0 deletions ad4_shared/targetfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ static const char* const ident[] = {ident[1], "@(#)$Id: targetfile.cc,v 1.1 2020
#include <stdio.h> // for fgets()
#include <ctype.h> // for isspace()
#include <string.h>
#ifdef _WIN32
#include "win_compat.h"
#else
#include <unistd.h> // for mkstemps()
#endif
#include "autocomm.h"
#include "parse_dpf_line.h"
#include "dpftoken.h"
Expand Down
4 changes: 4 additions & 0 deletions ad4_shared/threadlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
/* include stdlib.h for "free" and unistd.h for "unlink" */
/* tempnam is in <stdio.h> */
#include <stdlib.h>
#ifdef _WIN32
#include "win_compat.h"
#else
#include <unistd.h>
#endif

static char **tfilename /*[max_threads]*/;
static FILE **tfileptr /*[max_threads]*/;
Expand Down
4 changes: 4 additions & 0 deletions ad4_shared/timesys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.

*/

#ifdef _WIN32
#include "win_compat.h"
#else
#include <unistd.h>
#endif

#ifdef HAVE_CONFIG_H
# include <config.h>
Expand Down
2 changes: 1 addition & 1 deletion ad4_shared/timesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include <sys/times.h>
#else
#ifdef _WIN32
#include "mingw_sys_times.h"
#include "win_compat.h"
#else
#include <sys/times.h>
#endif
Expand Down
4 changes: 4 additions & 0 deletions ad4_shared/timesyshms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include <stdio.h>
#include <sys/types.h>

#ifdef _WIN32
#include "win_compat.h"
#else
#include <unistd.h>
#endif

#include "timesyshms.h"

Expand Down
2 changes: 1 addition & 1 deletion ad4_shared/timesyshms.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include <sys/times.h>
#else
#ifdef _WIN32
#include "mingw_sys_times.h"
#include "win_compat.h"
#else
#include <sys/times.h>
#endif
Expand Down
49 changes: 49 additions & 0 deletions ad4_shared/win_compat.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <windows.h>
#include <time.h>
#include <string.h>
#include "win_compat.h"

#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 1000
#endif

clock_t times(struct tms* buffer) {
FILETIME createTime, exitTime, kernelTime, userTime;
if (GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime)) {
ULARGE_INTEGER u, k;
k.LowPart = kernelTime.dwLowDateTime;
k.HighPart = kernelTime.dwHighDateTime;
u.LowPart = userTime.dwLowDateTime;
u.HighPart = userTime.dwHighDateTime;
buffer->tms_utime = (clock_t)(u.QuadPart / 10000 / (1000 / CLOCKS_PER_SEC));
buffer->tms_stime = (clock_t)(k.QuadPart / 10000 / (1000 / CLOCKS_PER_SEC));
buffer->tms_cutime = 0;
buffer->tms_cstime = 0;
} else {
memset(buffer, 0, sizeof(*buffer));
}
return clock();
}

int gettimeofday(struct timeval* tp, void*) {
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
unsigned __int64 t = ((unsigned __int64)ft.dwHighDateTime << 32) + ft.dwLowDateTime;
t -= 116444736000000000ULL;
tp->tv_sec = (long)(t / 10000000ULL);
tp->tv_usec = (long)((t % 10000000ULL) / 10);
return 0;
}

int gethostname(char* name, size_t len) {
DWORD dlen = static_cast<DWORD>(len);
return GetComputerNameA(name, &dlen) ? 0 : -1;
}

long sysconf(int name) {
if (name == _SC_CLK_TCK) {
return CLOCKS_PER_SEC;
} else {
return -1L;
}
}
48 changes: 48 additions & 0 deletions ad4_shared/win_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifdef _WIN32
#ifndef WIN_COMPAT_H
#define WIN_COMPAT_H

#include <io.h>
#include <direct.h>
#include <process.h>
#include <ctime>
#include <cstring>
#include <time.h>

// Portable function aliases
#define strcasecmp _stricmp
#define strdup _strdup
#define strncasecmp _strnicmp
#define getcwd _getcwd
#define chdir _chdir
#define access _access
#define unlink _unlink
#define isatty _isatty
#define fileno _fileno

#ifndef bzero
#define bzero(ptr, size) memset((ptr), 0, (size))
#endif

#ifndef HAVE_STRUCT_TMS
#define HAVE_STRUCT_TMS
struct tms {
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
};
#endif

// Declarations only – definitions go in win_compat.cc
clock_t times(struct tms* buffer);
int gettimeofday(struct timeval* tp, void*);
int gethostname(char* name, size_t len);
long sysconf(int name);

#ifndef _SC_CLK_TCK
#define _SC_CLK_TCK 3
#endif

#endif // WIN_COMPAT_H
#endif // _WIN32
2 changes: 1 addition & 1 deletion autogrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ FILE *ad_fopen(const char *path, const char *mode, FILE *logFile);
#define INFORMATION 1
#define SUGGESTION 2

void print_error( FILE *fileptr, int error_level, char *message);
void print_error( FILE *fileptr, int error_level, const char *message);

/*----------------------------------------------------------------------------*/
/* EOF. */
Expand Down
2 changes: 1 addition & 1 deletion banner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <stdio.h>
#include "autogrid.h"

void banner( char * version_num, FILE *logFile)
void banner(const char *version_num, FILE *logFile)

{

Expand Down
4 changes: 4 additions & 0 deletions gpfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
#include "autogrid.h"
#include "constants.h"

#ifdef _WIN32
#include "win_compat.h"
#endif

int gpfparser( char line[LINE_LEN] )

/******************************************************************************/
Expand Down
Loading