From: Dawid Jagiela Date: Thu, 19 Jul 2012 23:47:47 +0000 (+0200) Subject: cinfo.f generation and macro for unres MD X-Git-Tag: v.3.3.0~209^2~25^2~8^2~1^2~1 X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=commitdiff_plain;h=fe975a07b424518c030d064f010016607f8ab6e2;p=unres.git cinfo.f generation and macro for unres MD --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5180752..4ecd514 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,64 @@ set(UNRES_MAJOR 3) set(UNRES_MINOR 1) set(UNRES_PATCH 0) set(UNRES_VERSION ${UNRES_MAJOR}.${UNRES_MINOR}.${UNRES_PATCH}) - + #====================================== -# CTest stuff +# MACROS #====================================== +# Get system date +MACRO (TODAY RESULT) + IF (WIN32) + EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}}) + ELSEIF(UNIX) + EXECUTE_PROCESS(COMMAND "date" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(...) (...) (.+) (..:..:..) (.+) (....).*" "\\1 \\2 \\3 \\4 \\5 \\6" ${RESULT} ${${RESULT}}) + ELSE (WIN32) + MESSAGE(SEND_ERROR "date not implemented") + SET(${RESULT} 000000) + ENDIF (WIN32) +ENDMACRO (TODAY) + +# foramt variables used in cinfo.f +MACRO (CINFO_FORMAT FN VN VD) +# 50 znakowi +# 73 w całej linii +# write(iout,*)'INSTALL_DIR = /users/software/mpich-1.2.7p1_int...' + string(LENGTH "${VN}" VNLEN) + string(LENGTH "${VD}" VDLEN) + set(STR "${VN} ${VD}") + string(LENGTH "${STR}" SUMA) + math(EXPR STRLEN 50-${VNLEN}) +# message("lancuch=${STRLEN}") +# Fit in one line? +# No. + if(SUMA GREATER 50) + string(SUBSTRING "${STR}" 0 50 STR_OUT) +# message(" write(iout,*)'${VAR} = ${STR_OUT}'") + file(APPEND ${FN} " write(iout,*)'${STR_OUT}'\n") + math(EXPR STRLEN ${SUMA}-50) + string(SUBSTRING "${STR}" 50 ${STRLEN} STR) + string(LENGTH "${STR}" STRLEN) + while(STRLEN GREATER 48) +# message("Przycinam lancuch") + string(SUBSTRING "${STR}" 0 48 STR_OUT) + file(APPEND ${FN} " write(iout,*)' ${STR_OUT}'\n") + math(EXPR STRLEN ${STRLEN}-49) + string(SUBSTRING "${STR}" 49 ${STRLEN} STR) + string(LENGTH "${STR}" STRLEN) + endwhile(STRLEN GREATER 48) + file(APPEND ${FN} " write(iout,*)' ${STR}'\n") +# MESSAGE("DLUGOSC = ${VNLEN}; DLUGOSCD = ${VDLEN}; SUMA=${SUMA}; ${VAR} = ${${VAR}} " ) +# Yes + else(SUMA GREATER 50) + file(APPEND ${FN} " write(iout,*)'${STR}'\n") + endif(SUMA GREATER 50) +ENDMACRO (CINFO_FORMAT) +#====================================== +# CTest stuff +#======================================A + include(CTest) enable_testing() diff --git a/source/unres/src_CSA/CMakeLists.txt b/source/unres/src_CSA/CMakeLists.txt index c9be577..8ee5798 100644 --- a/source/unres/src_CSA/CMakeLists.txt +++ b/source/unres/src_CSA/CMakeLists.txt @@ -15,7 +15,6 @@ set(UNRES_CSA_SRC0 cartprint.f chainbuild.F checkder_p.F - cinfo.f contact.f convert.f cored.f @@ -188,25 +187,34 @@ set_property(SOURCE ${UNRES_CSA_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} set(UNRES_BIN "unresCSA_${Fortran_COMPILER_NAME}_${UNRES_CSA_FF}.exe") #========================================= -# cinfo.f stupid workaround for cmake -# - shame on me ]:) +# cinfo.f workaround for CMake #========================================= -set_property(SOURCE compinfo.c PROPERTY CMAKE_C_FLAGS "-c" ) -add_executable(compinfo-csa compinfo.c) -set_target_properties(compinfo-csa PROPERTIES OUTPUT_NAME compinfo) - -set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cinfo.f ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/COMMON.IOUNITS ${CMAKE_CURRENT_BINARY_DIR}/COMMON.IOUNITS - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compinfo | true - DEPENDS compinfo-csa ) -set_property(SOURCE ${UNRES_CINFO_DIR}/cinfo.f PROPERTY COMPILE_FLAGS ${FFLAGS0} ) +# get current time +TODAY(DATE) +# generate cinfo.f +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f +"C CMake generated file + subroutine cinfo + include 'COMMON.IOUNITS' + write(iout,*)'++++ Compile info ++++' + write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}' + write(iout,*)'Compiled ${DATE}' + write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}' + write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}' + write(iout,*)'OS release: ${CMAKE_SYSTEM}' + write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}' + write(iout,*)'CSA Force field: ${UNRES_CSA_FF}' + write(iout,*)'++++ End of compile info ++++' + return + end +") +# set include path +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}" ) #========================================= # Set full unres CSA sources #========================================= -set(UNRES_CSA_SRCS ${UNRES_CSA_SRC0} ${UNRES_CSA_SRC3} ${UNRES_CINFO_DIR}/cinfo.f ) +set(UNRES_CSA_SRCS ${UNRES_CSA_SRC0} ${UNRES_CSA_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f ) #========================================= # Build the binary diff --git a/source/unres/src_MD-M/CMakeLists.txt b/source/unres/src_MD-M/CMakeLists.txt index 8307560..4251303 100644 --- a/source/unres/src_MD-M/CMakeLists.txt +++ b/source/unres/src_MD-M/CMakeLists.txt @@ -272,25 +272,34 @@ else(UNRES_WITH_MPI) endif(UNRES_WITH_MPI) #========================================= -# cinfo.f stupid workaround for cmake -# - shame on me ]:) +# cinfo.f workaround for cmake #========================================= -set_property(SOURCE compinfo.c PROPERTY CMAKE_C_FLAGS "-c" ) -add_executable(compinfo-mdm compinfo.c) -set_target_properties(compinfo-mdm PROPERTIES OUTPUT_NAME compinfo) - -set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cinfo.f ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/COMMON.IOUNITS ${CMAKE_CURRENT_BINARY_DIR}/COMMON.IOUNITS - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compinfo | true - DEPENDS compinfo-mdm ) -set_property(SOURCE ${UNRES_CINFO_DIR}/cinfo.f PROPERTY COMPILE_FLAGS ${FFLAGS0} ) +# get the current date +TODAY(DATE) +# generate cinfo.f +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f +"C CMake generated file + subroutine cinfo + include 'COMMON.IOUNITS' + write(iout,*)'++++ Compile info ++++' + write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}' + write(iout,*)'Compiled ${DATE}' + write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}' + write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}' + write(iout,*)'OS release: ${CMAKE_SYSTEM}' + write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}' + write(iout,*)'MD Force field: ${UNRES_MD_FF}' + write(iout,*)'++++ End of compile info ++++' + return + end +") +# add include path +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}") #========================================= # Set full unres MD-M sources #========================================= -set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${UNRES_CINFO_DIR}/cinfo.f proc_proc.c ) +set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c ) #========================================= # Build the binary diff --git a/source/unres/src_MD/CMakeLists.txt b/source/unres/src_MD/CMakeLists.txt index 533247f..c56c706 100644 --- a/source/unres/src_MD/CMakeLists.txt +++ b/source/unres/src_MD/CMakeLists.txt @@ -232,25 +232,44 @@ else(UNRES_WITH_MPI) endif(UNRES_WITH_MPI) #========================================= -# cinfo.f stupid workaround for cmake -# - shame on me ]:) +# cinfo.f workaround for cmake #========================================= -set_property(SOURCE compinfo.c PROPERTY CMAKE_C_FLAGS "-c" ) -add_executable(compinfo-md compinfo.c) -set_target_properties(compinfo-md PROPERTIES OUTPUT_NAME compinfo) - -set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cinfo.f ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/COMMON.IOUNITS ${CMAKE_CURRENT_BINARY_DIR}/COMMON.IOUNITS - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compinfo | true - DEPENDS compinfo-md ) -set_property(SOURCE ${UNRES_CINFO_DIR}/cinfo.f PROPERTY COMPILE_FLAGS ${FFLAGS0} ) +# get the current date +TODAY(DATE) +# generate cinfo.f + +set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f") +FILE(WRITE ${CINFO} +"C CMake generated file + subroutine cinfo + include 'COMMON.IOUNITS' + write(iout,*)'++++ Compile info ++++' + write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}' +") + +CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" ) +CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" ) +CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" ) +CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" ) +CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" ) +CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" ) +CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}") + +FILE(APPEND ${CINFO} +" write(iout,*)'++++ End of compile info ++++' + return + end ") + +#FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f +# CINFO_FORMAT(CPPFLAGS) +#) +# add include path +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}") #========================================= # Set full unres MD sources #========================================= -set(UNRES_MD_SRCS ${UNRES_MD_SRC0} ${UNRES_MD_SRC3} ${UNRES_CINFO_DIR}/cinfo.f ) +set(UNRES_MD_SRCS ${UNRES_MD_SRC0} ${UNRES_MD_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f ) #========================================= diff --git a/source/unres/src_MIN/CMakeLists.txt b/source/unres/src_MIN/CMakeLists.txt index c57587a..a6c2db0 100644 --- a/source/unres/src_MIN/CMakeLists.txt +++ b/source/unres/src_MIN/CMakeLists.txt @@ -160,12 +160,35 @@ set_property(SOURCE ${UNRES_MIN_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} #======================================== set(UNRES_BIN "unres_min_${Fortran_COMPILER_NAME}.exe") -#set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) +#======================================== +# cinfo.f workaround for Cmake +#======================================== +# get the current date +TODAY(DATE) +# generate cinfo.f +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f +"C CMake generated file + subroutine cinfo + include 'COMMON.IOUNITS' + write(iout,*)'++++ Compile info ++++' + write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}' + write(iout,*)'Compiled ${DATE}' + write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}' + write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}' + write(iout,*)'OS release: ${CMAKE_SYSTEM}' + write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}' + write(iout,*)'Version MINI energy and minimization only' + write(iout,*)'++++ End of compile info ++++' + return + end +") +# add include path +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}") #========================================= # Set full unres MIN sources #========================================= -set(UNRES_MIN_SRCS ${UNRES_MIN_SRC0} ${UNRES_MIN_SRC1} ${UNRES_MIN_SRC2} ${UNRES_MIN_SRC3} cinfo.f ) +set(UNRES_MIN_SRCS ${UNRES_MIN_SRC0} ${UNRES_MIN_SRC1} ${UNRES_MIN_SRC2} ${UNRES_MIN_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f ) #========================================= # Build the binary diff --git a/source/wham/src-M/CMakeLists.txt b/source/wham/src-M/CMakeLists.txt index 184194c..0fcc200 100644 --- a/source/wham/src-M/CMakeLists.txt +++ b/source/wham/src-M/CMakeLists.txt @@ -163,25 +163,34 @@ set_property(SOURCE ${UNRES_WHAM_M_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLA set(UNRES_WHAM_M_BIN "wham_${Fortran_COMPILER_NAME}.exe") #========================================= -# cinfo.f stupid workaround for cmake -# - shame on me ]:) +# cinfo.f workaround for CMake #========================================= -set_property(SOURCE compinfo.c PROPERTY CMAKE_C_FLAGS "-c" ) -add_executable(compinfo-wham-m compinfo.c) -set_target_properties(compinfo-wham-m PROPERTIES OUTPUT_NAME compinfo) - -set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cinfo.f ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/COMMON.IOUNITS ${CMAKE_CURRENT_BINARY_DIR}/COMMON.IOUNITS - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compinfo | true - DEPENDS compinfo-wham-m ) -set_property(SOURCE ${UNRES_CINFO_DIR}/cinfo.f PROPERTY COMPILE_FLAGS ${FFLAGS0} ) +# get date +TODAY(DATE) +# getenerate cinfo.f +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f +"C CMake generated file + subroutine cinfo + include 'COMMON.IOUNITS' + write(iout,*)'++++ Compile info ++++' + write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}' + write(iout,*)'Compiled ${DATE}' + write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}' + write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}' + write(iout,*)'OS release: ${CMAKE_SYSTEM}' + write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}' + write(iout,*)'Force field: ${UNRES_MD_FF}' + write(iout,*)'++++ End of compile info ++++' + return + end +") +# set include paths +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}" ) #========================================= # Set full unres CSA sources #========================================= -set(UNRES_WHAM_M_SRCS ${UNRES_WHAM_M_SRC0} ${UNRES_CINFO_DIR}/cinfo.f proc_proc.c) +set(UNRES_WHAM_M_SRCS ${UNRES_WHAM_M_SRC0} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c) #========================================= # Build the binary diff --git a/source/wham/src/CMakeLists.txt b/source/wham/src/CMakeLists.txt index 0de3d71..c929a44 100644 --- a/source/wham/src/CMakeLists.txt +++ b/source/wham/src/CMakeLists.txt @@ -159,25 +159,34 @@ set_property(SOURCE ${UNRES_WHAM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS set(UNRES_WHAM_BIN "wham_${Fortran_COMPILER_NAME}.exe") #========================================= -# cinfo.f stupid workaround for cmake -# - shame on me ]:) +# cinfo.f workaround for CMake #========================================= -set_property(SOURCE compinfo.c PROPERTY CMAKE_C_FLAGS "-c" ) -add_executable(compinfo-wham compinfo.c) -set_target_properties(compinfo-wham PROPERTIES OUTPUT_NAME compinfo) - -set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cinfo.f ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/COMMON.IOUNITS ${CMAKE_CURRENT_BINARY_DIR}/COMMON.IOUNITS - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compinfo | true - DEPENDS compinfo-wham ) -set_property(SOURCE ${UNRES_CINFO_DIR}/cinfo.f PROPERTY COMPILE_FLAGS ${FFLAGS0} ) +# get current date +TODAY(DATE) +# generate cinfo.f +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f +"C CMake generated file + subroutine cinfo + include 'COMMON.IOUNITS' + write(iout,*)'++++ Compile info ++++' + write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}' + write(iout,*)'Compiled ${DATE}' + write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}' + write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}' + write(iout,*)'OS release: ${CMAKE_SYSTEM}' + write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}' + write(iout,*)'MD Force field: ${UNRES_MD_FF}' + write(iout,*)'++++ End of compile info ++++' + return + end +") +# set include path +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}" ) #========================================= # Set full unres CSA sources #========================================= -set(UNRES_WHAM_SRCS ${UNRES_WHAM_SRC0} ${UNRES_CINFO_DIR}/cinfo.f proc_proc.c) +set(UNRES_WHAM_SRCS ${UNRES_WHAM_SRC0} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c) #========================================= # Build the binary