[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:56:13 UTC 2009
The following commit has been merged in the upstream branch:
commit 7fd4ce5b827fda260297171c5955ca3066edecf4
Author: Stephane Popinet <popinet at users.sf.net>
Date: Mon Feb 23 20:13:58 2009 +1100
Automatic type checking for wavewatch C/Fortran linking
darcs-hash:20090223091358-d4795-cad43fa6487bcd6bd3db6d00288f39038c3610c5.gz
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 2f1ada1..22c81dd 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -87,9 +87,10 @@ libstokes3D_la_CFLAGS = $(AM_CFLAGS)
libstokes2D_la_SOURCES = stokes.c CW263.f
libstokes2D_la_CFLAGS = $(AM_CFLAGS) -DFTT_2D=1
-libwavewatch2D_la_SOURCES = wavewatch.c wavewatch.h
+libwavewatch2D_la_SOURCES = wavewatch.c
libwavewatch2D_la_LIBADD = -Lwavewatch -lwavewatch -L/usr/lib/gcc/i486-linux-gnu/4.2 -lgfortran
libwavewatch2D_la_CFLAGS = $(AM_CFLAGS) -DFTT_2D=1
+libwavewatch2D_la_DEPENDENCIES = wavewatch/libwavewatch.a
xyz2rsurface_SOURCES = xyz2rsurface.c rsurface.c rsurface.h
xyz2rsurface_LDADD = -LRStarTree -lcSmRST
diff --git a/modules/wavewatch/Makefile.am b/modules/wavewatch/Makefile.am
index da03ed0..9660e4f 100644
--- a/modules/wavewatch/Makefile.am
+++ b/modules/wavewatch/Makefile.am
@@ -5,13 +5,27 @@ WAVEWATCH = libwavewatch.a
endif
noinst_LIBRARIES = $(WAVEWATCH)
+noinst_PROGRAMS = checktypes
-EXTRA_DIST = gfsad3 gfsw3initmd.ftn wavewatch.h ww3_grid.inp
+EXTRA_DIST = gfsad3 gfsw3initmd.ftn wavewatch.h fchecktypes.ftn
-libwavewatch.a: gfsw3initmd.o
+BUILT_SOURCES = cfortrantypes.h
+
+checktypes_SOURCES = cchecktypes.c
+checktypes_LDADD = fchecktypes.o
+
+libwavewatch_a_SOURCES = cfortrantypes.h
+
+libwavewatch.a: gfsw3initmd.o cfortrantypes.h
rm -f libwavewatch.a
- ar cr libwavewatch.a `grep WWATCH3_DIR $(HOME)/.wwatch3.env | awk '{print $$2 "/obj/w3*.o"}'` gfsw3initmd.o
- ranlib libwavewatch.a
+ $(AR) cru libwavewatch.a `grep WWATCH3_DIR $(HOME)/.wwatch3.env | awk '{print $$2 "/obj/w3*.o"}'` gfsw3initmd.o
+ $(RANLIB) libwavewatch.a
gfsw3initmd.o: gfsw3initmd.ftn
sh gfsad3 gfsw3initmd.ftn
+
+fchecktypes.o: fchecktypes.ftn
+ sh gfsad3 fchecktypes.ftn
+
+cfortrantypes.h: checktypes
+ ./checktypes > cfortrantypes.h
diff --git a/modules/wavewatch/cchecktypes.c b/modules/wavewatch/cchecktypes.c
new file mode 100644
index 0000000..642f3ab
--- /dev/null
+++ b/modules/wavewatch/cchecktypes.c
@@ -0,0 +1,45 @@
+/* Simple checks for compatibility of C and Fortran types */
+
+#include <stdio.h>
+
+extern void check_int_ (void * a, void * b, void * c);
+extern void check_float_ (void * a, void * b, void * c);
+
+int main (int argc, char * argv[])
+{
+ int ia, ib, ic;
+ long long lc, la, lb;
+ float fa, fb, fc;
+ double dc, da, db;
+
+ printf ("/* Automatically generated using 'checktypes' */\n");
+ ia = -123; ib = 875;
+ check_int_ (&ia, &ib, &ic);
+ if (ic == ia*ib)
+ printf ("typedef int INTEGER;\n");
+ else {
+ la = -123; lb = 875;
+ check_int_ (&la, &lb, &lc);
+ if (lc != la*lb) {
+ fprintf (stderr, "checktypes: could not find compatible C and Fortran integers\n");
+ return 1;
+ }
+ printf ("typedef long long INTEGER;\n");
+ }
+
+ fa = -123.; fb = 875.;
+ check_float_ (&fa, &fb, &fc);
+ if (fc == fa*fb)
+ printf ("typedef float REAL;\n");
+ else {
+ da = -123.; db = 875.;
+ check_float_ (&da, &db, &dc);
+ if (dc != da*db) {
+ fprintf (stderr, "checktypes: could not find compatible C and Fortran floats\n");
+ return 1;
+ }
+ printf ("typedef double REAL;\n");
+ }
+
+ return 0;
+}
diff --git a/modules/wavewatch/fchecktypes.ftn b/modules/wavewatch/fchecktypes.ftn
new file mode 100644
index 0000000..674f097
--- /dev/null
+++ b/modules/wavewatch/fchecktypes.ftn
@@ -0,0 +1,9 @@
+! Simple checks for compatibility of C and Fortran types
+SUBROUTINE CHECK_INT ( A, B, C )
+ INTEGER A, B, C
+ C = A*B
+END SUBROUTINE CHECK_INT
+SUBROUTINE CHECK_FLOAT ( A, B, C )
+ REAL A, B, C
+ C = A*B
+END SUBROUTINE CHECK_FLOAT
diff --git a/modules/wavewatch/wavewatch.h b/modules/wavewatch/wavewatch.h
index b4acbec..eac5e62 100644
--- a/modules/wavewatch/wavewatch.h
+++ b/modules/wavewatch/wavewatch.h
@@ -1,8 +1,4 @@
-/*
- * These types must match the lengths of wavewatch's REAL and INTEGER types
- */
-typedef double REAL;
-typedef long long INTEGER;
+#include "cfortrantypes.h"
/**
* Initialisation of wavewatch
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list