diff --git a/cad/tochnog/Makefile b/cad/tochnog/Makefile index 217becaff5e9..6180902e1a61 100644 --- a/cad/tochnog/Makefile +++ b/cad/tochnog/Makefile @@ -1,88 +1,80 @@ PORTNAME= tochnog PORTVERSION= 20140100 -PORTREVISION= 14 +PORTREVISION= 15 CATEGORIES= cad MASTER_SITES= SF/${PORTNAME}/Tochnog%20Latest%20January%202014 DISTFILES= Sources${EXTRACT_SUFX} gid${EXTRACT_SUFX} \ tools${EXTRACT_SUFX} test${EXTRACT_SUFX} DIST_SUBDIR= ${DISTNAME} MAINTAINER= ports@FreeBSD.org COMMENT= Free explicit/implicit Finite Element Program WWW= https://tochnog.sourceforge.net/ LICENSE= GPLv2 -BUILD_DEPENDS= ${LOCALBASE}/lib/libf2c.a:lang/f2c +LIB_DEPENDS= libf2c.so:lang/f2c -OPTIONS_DEFINE= ATLAS EXAMPLES -ATLAS_DESC= Use ATLAS instead of BLAS/LAPACK +USES= blaslapack:openblas fortran zip dos2unix +DOS2UNIX_FILES= time.cc time.h tnlapack.h tnsuplu.h + +OPTIONS_DEFINE= EXAMPLES WRKSRC= ${WRKDIR}/Sources/Tochnog-Latest-jan-2014 MAKEFILE= makefile -USES= fortran zip dos2unix -DOS2UNIX_FILES= time.cc time.h tnlapack.h tnsuplu.h # You can set GIDDIR to share/gid to install the scripts to be used # with the cad/linux-gid port, otherwise they can be linked to the data # directory to avoid polluting the port space. GIDDIR?= share/${PORTNAME} PLIST_SUB+= GIDDIR=${GIDDIR} GID_PTYPES= ${PREFIX}/${GIDDIR}/problemtypes -.include - -.if ${PORT_OPTIONS:MATLAS} -LIB_DEPENDS+= libatlas.so:math/atlas -BLAS_LIBS= -lf77blas -.else -LIB_DEPENDS+= libblas.so:math/blas \ - liblapack.so:math/lapack -BLAS_LIBS= -llapack -lblas -.endif - ALL_TARGET= freebsd_old LIB_DEPENDS+= libsuperlu.so:math/superlu SUPERLU= superlu +.include + .if ${OPSYS} == FreeBSD -CPPFLAGS+= -Dregister= +CPPFLAGS+= -Dregister= .endif post-extract: .for sup in gid tools test ${MV} ${WRKDIR}/${sup} ${WRKDIR}/Sources/ .endfor pre-configure: .for hd in pthread.h ${MV} ${WRKSRC}/${hd} ${WRKSRC}/${hd}.orig .endfor ${REINPLACE_CMD} -e 's,%%LOCALBASE%%,${LOCALBASE},g ; \ s,%%SUPERLU%%,${SUPERLU},g ; \ - s,%%BLAS_LIBS%%,-L${LOCALBASE}/lib ${BLAS_LIBS},g' \ + s,%%BLAS_LIBS%%,-L${LOCALBASE}/lib ${BLASLIB},g' \ ${WRKSRC}/makefile ${REINPLACE_CMD} -e 's,SUPERLU_USE 0,SUPERLU_USE 1,' \ ${WRKSRC}/tnsuplu.h post-build: (cd ${WRKDIR}/Sources/tools && ${CXX} ${CXXFLAGS} -o aba2tn aba2tn.cc) do-install: ${INSTALL_PROGRAM} ${WRKSRC}/tochnog ${STAGEDIR}${PREFIX}/bin ${INSTALL_PROGRAM} ${WRKDIR}/Sources/tools/aba2tn ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${WRKDIR}/Sources/tools/*.awk ${STAGEDIR}${PREFIX}/bin ${MKDIR} ${STAGEDIR}${GID_PTYPES}/tochnog.gid ${INSTALL_DATA} ${WRKDIR}/Sources/gid/tochnog.gid/tochnog.cnd \ ${STAGEDIR}${GID_PTYPES}/tochnog.gid ${INSTALL_DATA} ${WRKDIR}/Sources/gid/tochnog.gid/tochnog.mat \ ${STAGEDIR}${GID_PTYPES}/tochnog.gid ${INSTALL_SCRIPT} ${WRKDIR}/Sources/gid/tochnog.gid/tochnog.ba* \ ${STAGEDIR}${GID_PTYPES}/tochnog.gid + do-install-EXAMPLES-on: ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${RM} ${WRKDIR}/Sources/test/*.orig ${INSTALL_DATA} ${WRKDIR}/Sources/test/* ${STAGEDIR}${EXAMPLESDIR} .include diff --git a/cad/tochnog/files/patch-makefile b/cad/tochnog/files/patch-makefile index 1fc76d36e2c7..b144547bb6d4 100644 --- a/cad/tochnog/files/patch-makefile +++ b/cad/tochnog/files/patch-makefile @@ -1,106 +1,107 @@ ---- makefile.orig 2014-01-05 15:35:37.000000000 +0100 -+++ makefile 2014-03-09 22:07:32.000000000 +0100 +--- makefile.orig 2014-01-05 14:35:37 UTC ++++ makefile @@ -5,7 +5,8 @@ #*********** fortran 2 c ******************* # Set F2C (for unix -lf2c and for MS windows if using Visual C++ to f2c.lib) -F2C= -lf2c +F2C= -lf2c -L%%LOCALBASE%%/lib -+F2C_INCLUDE= -I%%LOCALBASE%%/include ++F2C_INCLUDE= # -I%%LOCALBASE%%/include # *********** hypoplasticity **************** # For hypoplasticity: # install f2c on your computer (also see F2C above) -@@ -30,11 +31,11 @@ +@@ -30,11 +31,11 @@ VCPP= SYS_FILE=sysother BCPP=-P VCPP= -COMPILER_C=bcc32 -COMPILER_CPP=bcc32 -COMPILER_FLAGS= -c -O2 -w- +COMPILER_C=$(CC) +COMPILER_CPP=$(CXX) +COMPILER_FLAGS=$(CFLAGS) -c OBJ=obj -LINK_FLAGS_BEFORE= -l$(F2C) +LINK_FLAGS_BEFORE= -l$(F2C) -L%%LOCALBASE%%/lib LINK_FLAGS_AFTER= # *********** SUPERLU library ******************* -@@ -49,6 +50,9 @@ +@@ -49,6 +50,9 @@ LINK_FLAGS_AFTER= # SUPERLU_INCLUDE=-I/Users/fdolorenzo/Downloads/petsc-3.4.2/arch-darwin-c-debug/include # 3. For SuperLU_MT be sure to compile a multi threaded version # of Tochnog (sparc_parallel, alpha_parallel, linux, etc. +SUPERLU=%%LOCALBASE%% +SUPERLU_LIB=$(SUPERLU)/lib/lib%%SUPERLU%%.so %%BLAS_LIBS%% +SUPERLU_INCLUDE=-I$(SUPERLU)/include/%%SUPERLU%% # *********** PetSc library ******************* # Do NOT link together with the SUPERLU library -@@ -80,7 +84,7 @@ +@@ -80,7 +84,7 @@ ALL_LIB= $(LAPACK_LIB) $(BLAS_LIB) $(F2C) -lm $(PETS ALL_LIB= $(LAPACK_LIB) $(BLAS_LIB) $(F2C) -lm $(PETSC_LIB) $(SUPERLU_LIB) # *********** default platform ******************* -default: darwin-intel +default: freebsd_old # single and multi-processor windows; borland c++ compiler # set SYS_FILE above to syswin32 for multi-processor -@@ -130,17 +134,22 @@ +@@ -130,18 +134,23 @@ darwin-intel: "LINK_FLAGS_AFTER=-g -v -dynamic -undefined dynamic_lookup $(ALL_LIB) $(PROFILE) -dynamic -lpthread -o tochnog" # single processor linux; gnu gcc compiler -linux_old: - make tochnog \ +freebsd_old: + ${MAKE} tochnog \ "SYS_FILE=sysother" \ "OBJ=o" \ - "BCPP=" \ - "VCPP=" \ - "COMPILER_C=gcc" \ - "COMPILER_CPP=g++-4.2" \ - "COMPILER_FLAGS= -ansi -c -O2 -Wall $(PROFILE) $(ALL_INCLUDE)" \ + "COMPILER_FLAGS= -c ${CFLAGS} ${CPPFLAGS} $(ALL_INCLUDE)" \ "LINK_FLAGS_BEFORE=" \ - "LINK_FLAGS_AFTER= $(PROFILE) $(ALL_LIB) -static -lm -o tochnog" + "LINK_FLAGS_AFTER= $(PROFILE) $(ALL_LIB) ${LDFLAGS} -pthread -lm -o tochnog" -+ + +# Multithreaded FreeBSD +freebsd_parallel: + ${MAKE} tochnog \ + "SYS_FILE=sysposix" \ + "OBJ=o" \ + "COMPILER_FLAGS= -c ${CFLAGS} ${CPPFLAGS} -D_REENTRANT $(ALL_INCLUDE)" \ + "LINK_FLAGS_BEFORE=" \ + "LINK_FLAGS_AFTER= $(PROFILE) $(ALL_LIB) ${LDFLAGS} -lpthread -lm -o tochnog" - ++ # multi processor linux; gnu gcc compiler linux: -@@ -289,7 +298,7 @@ + make tochnog \ +@@ -289,7 +298,7 @@ tochnog: adjust.$(OBJ) area.$(OBJ) \ renumber.$(OBJ) repeat.$(OBJ) restart.$(OBJ) \ slide.$(OBJ) \ so.$(OBJ) so_bicg.$(OBJ) \ - split.$(OBJ) \ + so_suplu.$(OBJ) split.$(OBJ) \ spring.$(OBJ) stress.$(OBJ) \ $(SYS_FILE).$(OBJ) tendon.$(OBJ) time.$(OBJ) tn.$(OBJ) \ top.$(OBJ) truss.$(OBJ) \ -@@ -401,7 +410,7 @@ +@@ -401,7 +410,7 @@ $(HYPO_OBJ): $(HYPO_SRC) $(COMPILER_CPP) $(COMPILER_FLAGS) $(BCPP) $(VCPP)hyperela.$(SRC_CPP) $(HYPO_OBJ): $(HYPO_SRC) - $(COMPILER_C) $(COMPILER_FLAGS) $(HYPO_SRC) + $(COMPILER_C) $(COMPILER_FLAGS) $(HYPO_SRC) $(F2C_INCLUDE) hypoplas.$(OBJ): hypoplas.$(SRC_CPP) tochnog.h $(COMPILER_CPP) $(COMPILER_FLAGS) $(BCPP) $(VCPP)hypoplas.$(SRC_CPP) -@@ -565,6 +574,9 @@ +@@ -564,6 +573,9 @@ so_bicg.$(OBJ): so_bicg.$(SRC_CPP) tochnog.h + #so_petsc.$(OBJ): so_petsc.$(SRC_C) tochnog.h # $(COMPILER_C) $(COMPILER_FLAGS) so_petsc.$(SRC_C) - ++ +so_suplu.$(OBJ): so_suplu.$(SRC_C) tochnog.h + $(COMPILER_C) $(COMPILER_FLAGS) so_suplu.$(SRC_C) -+ + split.$(OBJ): split.$(SRC_CPP) tochnog.h $(COMPILER_CPP) $(COMPILER_FLAGS) $(BCPP) $(VCPP)split.$(SRC_CPP) - diff --git a/cad/tochnog/files/patch-sysposix.cc b/cad/tochnog/files/patch-sysposix.cc index 50bbc73408da..201ecba952f0 100644 --- a/cad/tochnog/files/patch-sysposix.cc +++ b/cad/tochnog/files/patch-sysposix.cc @@ -1,33 +1,33 @@ ---- sysposix.cc.orig +--- sysposix.cc.orig 2004-02-25 20:46:52 UTC +++ sysposix.cc @@ -20,20 +20,20 @@ #include "tochnog.h" #include "pthread.h" -pthread_mutex_t mutex; +pthread_mutex_t mtx; long int inext=0; pthread_t threads[MTHREAD]; void parallel_sys_initialize( void ) { - pthread_mutex_init( &mutex, NULL ); + pthread_mutex_init( &mtx, NULL ); } void parallel_sys_lock( void ) { - pthread_mutex_lock( &mutex ); + pthread_mutex_lock( &mtx ); } void parallel_sys_next_of_loop( long int next_of_loop[], long int max_loop, -@@ -96,5 +96,5 @@ +@@ -96,5 +96,5 @@ void parallel_sys_unlock( void ) void parallel_sys_unlock( void ) { - pthread_mutex_unlock( &mutex ); + pthread_mutex_unlock( &mtx ); } diff --git a/cad/tochnog/files/patch-tn.cc b/cad/tochnog/files/patch-tn.cc index 197f3bb9acfa..23b5e692c74b 100644 --- a/cad/tochnog/files/patch-tn.cc +++ b/cad/tochnog/files/patch-tn.cc @@ -1,175 +1,174 @@ ---- tn.cc.orig 2013-08-16 01:47:35.000000000 +0200 -+++ tn.cc 2014-03-09 17:57:23.000000000 +0100 +--- tn.cc.orig 2013-08-15 23:47:35 UTC ++++ tn.cc @@ -33,6 +33,40 @@ int PetscFinalize(void); #endif +#include "getopt.h" + +bool enable_gid; +bool enable_test; + +struct option long_options [] = +{ + {"version", no_argument, NULL, 'v'}, + {"help", no_argument, NULL, 'h'}, + {"gid", no_argument, NULL, 'G'}, + {"test", no_argument, NULL, 't'}, // Not yet implemented + {NULL, 0, 0, 0} +}; + +int usage () +{ + cout << "Usage: tochnog [options]\n" + "or: tochnog [options] file.dat\n" + "or: tochnog [options] file.dat > file.out\n\n" + "options: --version print the version of the tochnog program\n" + " --help print a short options overview and exit\n" + " --gid generate the files necessary for GID interaction\n" + " --test notify if target_item/_value could be meet\n" + " (not very usefull now)\n"; + return 1; +} + +int version () +{ + cout << TOCHNOG_VERSION << '\n'; + return 1; +} + + int main( int argc, char* argv[] ) { -@@ -40,37 +74,107 @@ +@@ -40,37 +74,107 @@ int main( int argc, char* argv[] ) Time CPU; CPU.firsttime=CPU.taketime(); - long int i=0, l=0, any_point=0; + extern char *optarg; + extern int optind, opterr, optopt; -+ + + int opt_index, option, error_count = 0; + bool print_usage = false, print_version = false; + + size_t i=0, l=0, s_len=0, any_point=0; - ++ // initialise static variables initialize(); // test arguments + while ((option = getopt_long (argc, argv, "hvGt", long_options, &opt_index)) + != EOF) + { + switch (option) + { + // Options without argument + + case 'h': // print a short help message and exit + print_usage = true; + break; + case 'v': // print the version string and exit + print_version = true; + break; + case 'G': // use the *flavia* for interaction with gid + enable_gid = true; + break; + case 't': // use the *flavia* for interaction with gid + enable_test = true; + break; + // Options with 1 argument + default: + cerr << "tochnog: unrecognized option " << optarg << '\n'; + error_count++; + } + } + + if (error_count > 0) + { + cerr << "Try tochnog --help for more information"; + exit(TN_EXIT_STATUS); + } + + if (print_usage) + { + usage(); + } + if (print_version || print_usage) + { + version(); + exit(TN_EXIT_STATUS); + } + + // No comand argument + + if (argc == optind) + { + strncpy( data_file, "tn.dat", 6 ); + } + + // 1 command line argument, should be input file name + + else if (argc == optind + 1) + { + s_len = strlen (argv[optind]); + strncpy(data_file, argv[optind], s_len); + + // Check if input file name containes already ".dat" suffix + + if (strncmp(&data_file[s_len - 4], ".dat", 4) != 0) + { + + // to preserve compatibility + + if (strncmp(&data_file[s_len - 4], ".dbs", 4) != 0) + { + strncpy(data_file_base, data_file, s_len); + strncpy(&data_file[s_len], ".dat", 4); + } + else + { + strncpy(data_file_base, data_file, s_len - 4); + } + } + else + { + // to preserve compatibility + + strncpy(data_file_base, data_file, s_len - 4); + } + } + else + { + usage(); + exit(TN_EXIT_STATUS); + } + #if MPI_USE strcpy( data_file, "tn.dat" ); -#else - if ( argc==1 ) strcpy( data_file, "tn.dat" ); - else if ( argc==2 ) strcpy( data_file, argv[1] ); - else { - pri( "Usage: tochnog" ); - pri( "or: tochnog file.dat" ); - pri( "or: tochnog file.dat > file.out" ); - exit(TN_EXIT_STATUS); - } --#endif + #endif - - // append .dat to input file name - l = strlen( data_file ); - strcpy( data_file_base, "" ); - for ( i=0; i 1 ERROR___ just pick one diff --git a/cad/tochnog/files/patch-tochnog.h b/cad/tochnog/files/patch-tochnog.h index aafa9a787cfe..53299c52bd48 100644 --- a/cad/tochnog/files/patch-tochnog.h +++ b/cad/tochnog/files/patch-tochnog.h @@ -1,11 +1,19 @@ ---- tochnog.h.orig 2013-10-12 05:33:16.000000000 +0200 -+++ tochnog.h 2014-03-09 18:16:04.000000000 +0100 -@@ -58,6 +58,8 @@ +--- tochnog.h.orig 2013-10-12 03:33:16 UTC ++++ tochnog.h +@@ -37,7 +37,6 @@ + #include "tnhypo.h" + #include "matrix.h" + #include "time.h" +-#include "f2c.h" + + using namespace std; + +@@ -57,6 +56,8 @@ enum { + VERSION_EXTRUDE, // mesh for extrude MVERSION // maximum number of versions, this must be the last item }; - -+#define TOCHNOG_VERSION "Latest-jan-2014" + ++#define TOCHNOG_VERSION "Latest-jan-2014" + // constants #define MCHAR 100 // maximum length of names - #define MDIM 3 // maximum number of space dimensions