Skip to content

Commit

Permalink
Major version change:
Browse files Browse the repository at this point in the history
1) Large rewrite of program, focussing on splitting into functions
2) Fixed cmake lists
3) Fixed readme
4) Added check file format python function and format_example from ansys docs
5) Updated patch utility... can use any python version now
  • Loading branch information
Rod-Persky committed Oct 21, 2016
1 parent 188fd95 commit 7be7f16
Show file tree
Hide file tree
Showing 11 changed files with 1,377 additions and 734 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/
fortran/*.for
mixtures/*.MIX
fluids/*.FLD
fluids/*.PPF
fluids/HMX.BNC
fortran/MANUAL.TXT
119 changes: 76 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,98 @@
cmake_minimum_required(VERSION 2.8)
project(REFPROP Fortran)

SET (USE_OPENMP ON CACHE BOOL "Use OpenMP")
SET (CMAKE_BUILD_TYPE "RELEASE" CACHE INTERNAL "Set test build")

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
IF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
MESSAGE(FATAL_ERROR "Fortran compiler does not support F90")
ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
cmake_minimum_required(VERSION 3.3)
SET(CMAKE_BUILD_TYPE Debug)

INCLUDE(${CMAKE_MODULE_PATH}/SetFortranFlags.cmake)
INCLUDE(${CMAKE_MODULE_PATH}/SetParallelizationLibrary.cmake)
find_package(PythonLibs 3 REQUIRED)
find_package(PythonInterp)
project(RGPTableGen Fortran)


# running on windows and refprop is installed? then copy what we need
if (WIN32)
# Set locations to store output
set(REFPROP_FLUID_FOLDER "${CMAKE_BINARY_DIR}")
set(REFPROP_DLL_FILE "${CMAKE_BINARY_DIR}")

# Refprop (new version) is a 64 bit binary
find_path(REFPROP_BASE_PATH "REFPRP64.dll" "c:/program files/REFPROP" "c:/program files (x86)/REFPROP")
if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()

if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()

if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()


if (USE_OPENMP)
message(STATUS "REFPROP: Each REFPROP instance may use up to ${OMP_NUM_PROCS} threads with OpenMP")
# Build Environment
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

if (NOT REFPROP_FLAGS_ADDED)
set(REFPROP_FLAGS_ADDED "true" CACHE INTERNAL "Has refprop flags been added?")

if(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
MESSAGE(FATAL_ERROR "Fortran compiler does not support F90")
else()
SET (CMAKE_BUILD_TYPE "DEBUG" CACHE INTERNAL "Set test build")
INCLUDE("${CMAKE_MODULE_PATH}/SetFortranFlags.cmake")
INCLUDE("${CMAKE_MODULE_PATH}/SetCompileFlag.cmake")
endif()

SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "-fpic")
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "-ffast-math")
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "-fno-common")
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "-ffloat-store")
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "-fall-intrinsics")

message(STATUS "${CMAKE_Fortran_FLAGS_RELEASE}")
endif()

# Copy fluid folder to output directory
if (REFPROP_BASE_PATH)
message(STATUS "REFPROP: REFPROP found at ${REFPROP_BASE_PATH}, copying/using existing fluid/fortran files")
else()
set(REFPROP_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Code Path")
endif()

# Remove non required files
message("${REFPROP_BASE_PATH}")
# Options
SET (USE_OPENMP OFF CACHE BOOL "Use OpenMP")

find_package(PythonInterp REQUIRED)

#####################
# CONFIGURE REFPROP #
#####################

set(REFPROP_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Refprop code location")

# Set locations to store output
set(REFPROP_FLUID_FOLDER "${CMAKE_BINARY_DIR}")
set(REFPROP_DLL_FILE "${CMAKE_BINARY_DIR}")


# Copy REFPROP fluid files
message(STATUS "REFPROP: REFPROP fluids found at ${REFPROP_BASE_PATH}, copying fluid files")
file(COPY "${REFPROP_BASE_PATH}/fluids" DESTINATION "${CMAKE_BINARY_DIR}")
message(STATUS "REFPROP: Fluid files copied")

# Get fortran sources
FILE(GLOB refprop_files "${REFPROP_BASE_PATH}/fortran/*.FOR")

# Remove non-required items
LIST(REMOVE_ITEM refprop_files
"${REFPROP_BASE_PATH}/fortran/COMMONS.FOR"
"${REFPROP_BASE_PATH}/fortran/COMTRN.FOR"
"${REFPROP_BASE_PATH}/fortran/COMMONS.FOR" # include file
"${REFPROP_BASE_PATH}/fortran/COMTRN.FOR" # include file
"${REFPROP_BASE_PATH}/fortran/UTILITY.FOR"
)
execute_process(COMMAND ${PYTHON_EXECUTABLE} "patchUtility.py" "${REFPROP_BASE_PATH}/fortran/UTILITY.FOR" "${CMAKE_CURRENT_SOURCE_DIR}/UTILITY.FOR")
LIST(APPEND refprop_files "${CMAKE_CURRENT_SOURCE_DIR}/UTILITY.FOR")
message("${refprop_files}")

# Make a copy of files (which are to be patched)
message(STATUS "REFPROP: Patching fortran files")
file(COPY "${REFPROP_BASE_PATH}/fortran/COMMONS.FOR" DESTINATION "${CMAKE_BINARY_DIR}/fortran")
file(COPY "${REFPROP_BASE_PATH}/fortran/COMTRN.FOR" DESTINATION "${CMAKE_BINARY_DIR}/fortran")
file(RENAME "${CMAKE_BINARY_DIR}/fortran/COMMONS.FOR" "${CMAKE_BINARY_DIR}/fortran/commons.for")
file(RENAME "${CMAKE_BINARY_DIR}/fortran/COMTRN.FOR" "${CMAKE_BINARY_DIR}/fortran/comtrn.for")

# Add some nice flags
if(UNIX OR MINGW)
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" Fortran "${CMAKE_Fortran_FLAGS} -ffast-math -fno-common -ffloat-store" FORCE)
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patchUtility.py"
"${REFPROP_BASE_PATH}/fortran/UTILITY.FOR"
"${CMAKE_BINARY_DIR}/UTILITY.FOR")

LIST(APPEND refprop_files "${CMAKE_BINARY_DIR}/UTILITY.FOR")

# Set include directory
include_directories("${CMAKE_BINARY_DIR}/fortran")

# Setup build
include_directories("${REFPROP_BASE_PATH}/fortran")

# Use common core method
add_library(REFPROPObjects OBJECT ${refprop_files})
add_library(REFPRP64 SHARED $<TARGET_OBJECTS:REFPROPObjects>)
add_executable(RGPTableGen $<TARGET_OBJECTS:REFPROPObjects> "${CMAKE_CURRENT_SOURCE_DIR}/RGPgenerator.F90")
add_executable(RGPTableGen $<TARGET_OBJECTS:REFPROPObjects> "${CMAKE_CURRENT_SOURCE_DIR}/RGP.for")

target_compile_options(RGPTableGen PRIVATE -std=f2008 -ffree-form)
66 changes: 52 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,58 @@ RGP Generator

This program was developed to generate custom step size RGP files using the NIST fluid properties.

Included Files
--------------
fluids(folder) - Includes REFPROP fluids needed for generating the rgp file
Source Code(folder) - Includes the source code for the program (within RGPgenerator.F90, the rest are REFPROP subroutines, and RGP_Generator.prj is the simple fortran project file)
CFX Solver Guide.pdf - ANSYS CFX Documentation which was useful when formatting the RGP gen output file (See section 12.6)
RGP_Generator64.exe - 64 Bit version of the program
RGP_Generator32.exe - 32 Bit version of the program
README.txt

How to use
-----------
1) Open either the 32 or 64 bit version of RGP_Generator.exe
2) Follow the steps to generate the output file
3) Upload the RGP file to ANSYS CFX
How to Use
----

RGP File gen is a simple program generating complex files for use with the CFX fluid dynamics package.
Once the program is built (see below about how to build) you may run the program on the command line
and answer the questions with regard to your current project. Be advised that the temperature and pressure
ranges that you enter must cover both the total and static states expected in the whole flow field else
you will end up with range clipping (as will be seen in the CFX log file).

New in this version is the ability to put the answers to the questions in the program arguments. Please be
aware that the order matters, and the order is the same as the normal question asking order. You will see
the output however printed in the terminal so you will be made aware of any errors.

How to Build
=====

* Bad news: Refprop is licenced by NIST, and should not be distributed.
* Good news: We have everything sorted for you!

RGP Generator is simple to build, your computer may even have everything required
already installed. Please use the following steps to get setup. Be aware if you have
linux, that you would have to had REFPROP installed on windows to get the code and fluid
files.

1) Copy all fluids from your REFPROP install path (c:/program files/refprop) to the fluids folder
2) Copy all the fortran files to the fortran directory
3) Follow the steps below based on your OS

How to Build (Windows)
-----
1) Install mingw with fortran, if this is forign then watch the video available [here](https://www.youtube.com/watch?v=oVfAU1ziOjg
2) Install cmake from [here](https://cmake.org/download/)
3) Make a folder called build in the current directory
4) Run cmake GUI
* Set `where is the source code located` to the folder with RGP.for
* Set `where to build the binaries` to the build folder you made
* Press configure and select `MingGW Makefiles` in `Specify the generator for this project`
* Press generate
5) Open a new command window and ensure the current directory is the build folder
6) Run `mingw32-make` which should be located in the bin directory of where you installed mingw32

How to Build (Linux)
-------

Linux is much nicer!

1) Install fortran (`apt-get install gfortran` or `pacman -S gfortran`) based on your system
2) Install cmake (again using apt or pacman)
3) Navigate to the source folder and make a build directory
4) In the build directory run cmake ..
5) Run make


Licence
=======
Expand Down
Loading

0 comments on commit 7be7f16

Please sign in to comment.