Skip to content

Commit

Permalink
Windows support by Alexei Yakovlev (Makefiles for Visual C++
Browse files Browse the repository at this point in the history
and fortran symbol in uppercase).
  • Loading branch information
uekstrom committed Oct 21, 2010
1 parent e1c1433 commit a000d93
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 19 deletions.
51 changes: 51 additions & 0 deletions Makefile.common_win
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#This file probably requires GNU Make, but should be easily
#convertible to regular Make format.

PATHS:=-Iinclude -Isrc -Isrc/taylor -Isrc/functionals
CFLAGS+=$(PATHS)
CXXFLAGS+=$(PATHS)

BASE_OBJ:=src/xcfun.obj src/functional.obj src/parameters.obj \
src/evaluators.obj src/fortran.obj src/potential.obj
FUN_OBJ:=$(patsubst %.cpp,%.obj,$(wildcard src/functionals/*.cpp))

lib: lib/libxcfun.lib

lib/libxcfun.lib: $(BASE_OBJ) $(FUN_OBJ) include/xcfun_autogen.h fortran/xcfun_autogen.f90
lib -OUT:$@ $(BASE_OBJ) $(FUN_OBJ)

src/parameters.obj: src/parameters.cpp src/parameters.h src/functionals/list_of_parameters.h

src/fortran.obj: src/fortran.c include/xcfun_autogen.h

geninterface: src/geninterface.cpp
$(CXX) $(CXXFLAGS) $^ -Fe$@

include/xcfun_autogen.h: geninterface src/functionals/list_of_parameters.h
./geninterface

fortran/xcfun_autogen.f90: geninterface src/functionals/list_of_parameters.h
./geninterface

funeval: test/funeval.c lib/libxcfun.lib
$(CC) $(CFLAGS) $(LIBS) $< -Fe$@ lib/libxcfun.lib

testall: test/testall.c lib/libxcfun.lib
$(CC) $(CFLAGS) $(LIBS) $< -Fe$@ lib/libxcfun.lib

example_fortran: fortran/xcfun_autogen.obj fortran/xcfun_module.obj fortran/example.obj lib/libxcfun.lib
$(FC) $(FFLAGS) $(LIBS) -o $@ $^ lib/libxcfun.lib

clean:
rm -f `find . -name '*.o' -o -name '*~'` testall funeval lib/libxcfun.lib include/xcfun_autogen.h fortran/xcfun_autogen.f90 example_fortran_

.SUFFIXES: .f90 .obj

.f90.obj:
$(FC) $(FFLAGS) -c -Fo$*.obj $*.f90

.cpp.obj:
$(CXX) $(CXXFLAGS) -c -Fo$*.obj $*.cpp

.c.obj:
$(CXX) $(CXXFLAGS) -c -Fo$*.obj $*.c
16 changes: 16 additions & 0 deletions Makefile.vc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compile time options:
# -DNDEBUG Turn off run time checks in production calculations to gain speed
# To compile without -lstdc++ needed use (g++) -fno-rtti -fno-exceptions
# -fno-threadsafe-statics. Note the last option.

# C++ compiler and flags
CXX=cl
CC=cl
CFLAGS=-Za -O2 -DNDEBUG -DFTN_UPPERCASE
CXXFLAGS=$(CFLAGS)

# Fortran compiler and flags (used for fortran/example.f90)
FC=ifort
FFLAGS=-unix -nologo -O3

include Makefile.common_win
46 changes: 28 additions & 18 deletions src/fortran.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
the final one.
*/

#ifdef FTN_UPPERCASE
#define FSYM(name)
#define FCSYM(name) name
#elif FTN_UPPERCASE_UNDERSCORE
#define FSYM(name)
#define FCSYM(name) name##_
#else
#define FSYM(name) name##_
#define FCSYM(name)
#endif

#define MAX_FORTRAN_FUNCTIONALS 5

static xc_functional fortran_functionals[MAX_FORTRAN_FUNCTIONALS] = {0};

double FSYM(xcfuve)(void)
double FSYM(xcfuve) FCSYM(XCFUVE)(void)
{
return xcfun_version();
}

int FSYM(xcnewf)(void)
int FSYM(xcnewf) FCSYM(XCNEWF)(void)
{
int i;
for (i=0;i<MAX_FORTRAN_FUNCTIONALS;i++)
Expand All @@ -33,7 +43,7 @@ int FSYM(xcnewf)(void)
return -1;
}

void FSYM(xcfree)(int *fun)
void FSYM(xcfree)FCSYM(XCFREE)(int *fun)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
xc_free_functional(fortran_functionals[*fun]);
Expand All @@ -44,7 +54,7 @@ void FSYM(xcfree)(int *fun)
Figure out the memory distance between points
from the first and second pointers.
*/
void FSYM(xceval)(int *fun, int *order,
void FSYM(xceval)FCSYM(XCEVAL)(int *fun, int *order,
int *nr_points,
double *first_density,
double *second_density,
Expand All @@ -61,43 +71,43 @@ void FSYM(xceval)(int *fun, int *order,
}


void FSYM(xcpotential)(int *fun, double *density, double *energy, double *potential)
void FSYM(xcpotential)FCSYM(XCPOTENTIAL)(int *fun, double *density, double *energy, double *potential)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
xc_potential(fortran_functionals[*fun], density, energy, potential);
}

void FSYM(xcsmod)(int *fun, int *mode)
void FSYM(xcsmod)FCSYM(XCSMOD)(int *fun, int *mode)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
xc_set_mode(fortran_functionals[*fun], *mode);
}

int FSYM(xcgett)(int *fun)
int FSYM(xcgett)FCSYM(XCGETT)(int *fun)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
return xc_get_type(fortran_functionals[*fun]);
}

int FSYM(xcmord)(int *fun)
int FSYM(xcmord)FCSYM(XCMORD)(int *fun)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
return xc_max_order(fortran_functionals[*fun]);
}

int FSYM(xcinle)(int *fun)
int FSYM(xcinle)FCSYM(XCINLE)(int *fun)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
return xc_input_length(fortran_functionals[*fun]);
}

int FSYM(xcoule)(int *fun, int *order)
int FSYM(xcoule)FCSYM(XCOULE)(int *fun, int *order)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
return xc_output_length(fortran_functionals[*fun],*order);
}

int FSYM(xcdind)(int *fun, const int *derivative)
int FSYM(xcdind)FCSYM(XCDIND)(int *fun, const int *derivative)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
return xc_derivative_index(fortran_functionals[*fun],derivative);
Expand Down Expand Up @@ -127,12 +137,12 @@ static char *ints2str(int ints[])
}
#endif

void FSYM(xcspla)(int *text, int *len)
void FSYM(xcspla)FCSYM(XCSPLA)(int *text, int *len)
{
str2ints(text,*len,xcfun_splash());
}

void FSYM(xcsnam)(int *dst, int *dstlen, int *n)
void FSYM(xcsnam)FCSYM(XCSNAM)(int *dst, int *dstlen, int *n)
{
const char *s;
s= xc_name(*n-1);
Expand All @@ -142,32 +152,32 @@ void FSYM(xcsnam)(int *dst, int *dstlen, int *n)
dst[0] = 0;
}

void FSYM(xcssho)(int *dst, int *dstlen, int *n)
void FSYM(xcssho)FCSYM(XCSSHO)(int *dst, int *dstlen, int *n)
{
const char *s;
s = xc_short_description(*n-1);
str2ints(dst,*dstlen,s);
}

void FSYM(xcslon)(int *dst, int *dstlen, int *n)
void FSYM(xcslon)FCSYM(XCSLON)(int *dst, int *dstlen, int *n)
{
const char *s;
s = xc_long_description(*n-1);
str2ints(dst,*dstlen,s);
}

int FSYM(xcisfu)(int *n)
int FSYM(xcisfu)FCSYM(XCISFU)(int *n)
{
return xc_is_functional(*n-1);
}

void FSYM(xcsets)(int *fun, int *n, double *value)
void FSYM(xcsets)FCSYM(XCSETS)(int *fun, int *n, double *value)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
xc_set_param(fortran_functionals[*fun],*n-1,*value);
}

double FSYM(xcgets)(int *fun, int *n)
double FSYM(xcgets)FCSYM(XCGETS)(int *fun, int *n)
{
assert(*fun >= 0 && *fun < MAX_FORTRAN_FUNCTIONALS);
return xc_get_param(fortran_functionals[*fun],*n-1);
Expand Down
2 changes: 1 addition & 1 deletion test/testall.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

int main(void)
{
int i = 0;
printf("%s",xcfun_splash());
printf("XCFun version: %g\n",xcfun_version());
int i = 0;
printf("\nAvailable functionals and settings:\n");
for (i=0;i<XC_NR_PARAMS;i++)
{
Expand Down

0 comments on commit a000d93

Please sign in to comment.