mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Merge branch 'master' into eigenPolynomials
Conflicts: externals/eigen include/MatrixMath.h include/PolyMath.h src/Backends/Helmholtz/Fluids/Incompressible.cpp src/Backends/Helmholtz/Fluids/Incompressible.h src/PolyMath.cpp
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
||||
[submodule "externals/Catch"]
|
||||
path = externals/Catch
|
||||
url = https://github.com/philsquared/Catch
|
||||
[submodule "externals/eigen"]
|
||||
path = externals/eigen
|
||||
[submodule "externals/Eigen"]
|
||||
path = externals/Eigen
|
||||
url = https://github.com/RLovelett/eigen.git
|
||||
|
||||
@@ -61,11 +61,8 @@ option (COOLPROP_TESTING
|
||||
file(GLOB_RECURSE APP_SOURCES "src/*.cpp")
|
||||
file(GLOB_RECURSE APP_HEADERS "include/*.h" "src/*.h") # "externals/*.hpp")
|
||||
list(REMOVE_ITEM APP_SOURCES "${CMAKE_SOURCE_DIR}/src/Tests/Tests.cpp")
|
||||
## You can exclude this file as well, in case you want to run your own tests
|
||||
#list(REMOVE_ITEM APP_SOURCES "${CMAKE_SOURCE_DIR}/src/Tests/test_main.cpp")
|
||||
|
||||
|
||||
set (APP_INCLUDE_DIRS "externals/eigen")
|
||||
set (APP_INCLUDE_DIRS "externals/Eigen")
|
||||
foreach (_headerFile ${APP_HEADERS})
|
||||
get_filename_component(_dir ${_headerFile} PATH)
|
||||
list (APPEND APP_INCLUDE_DIRS ${_dir})
|
||||
@@ -108,6 +105,7 @@ add_custom_target(generate_headers
|
||||
if (COOLPROP_STATIC_LIBRARY)
|
||||
add_library(${app_name} STATIC ${APP_SOURCES})
|
||||
add_dependencies (${app_name} generate_headers)
|
||||
set_target_properties (${app_name} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -DCOOLPROP_LIB -DCONVENTION=__cdecl")
|
||||
endif()
|
||||
|
||||
##### COOLPROP SHARED LIBRARY ######
|
||||
@@ -315,10 +313,11 @@ if (COOLPROP_TESTING)
|
||||
add_executable (testRunner.exe ${APP_SOURCES})
|
||||
add_dependencies (testRunner.exe generate_headers)
|
||||
set_target_properties (testRunner.exe PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -DENABLE_CATCH")
|
||||
set_source_files_properties(src/PolyMath.cpp PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -DCATCH_CONFIG_MAIN")
|
||||
if(UNIX)
|
||||
target_link_libraries (testRunner.exe ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
add_test(ProcedureTests testRunner.exe)
|
||||
add_test(ProceedureTests testRunner.exe)
|
||||
|
||||
# C++ Documentation Test
|
||||
add_executable (docuTest.exe "Web/examples/C++/Example.cpp")
|
||||
|
||||
@@ -224,7 +224,7 @@ def getlim(key,dicts,fac=1):
|
||||
# Here starts the real script
|
||||
#########################################################################
|
||||
|
||||
fluid = 'R245fa'
|
||||
fluid = 'water'
|
||||
CP.enable_TTSE_LUT(fluid)
|
||||
|
||||
PRINT = False
|
||||
@@ -241,7 +241,7 @@ else:
|
||||
|
||||
Tmin = CP.PropsSI('Tmin' ,'T',0,'P',0,fluid) + 5.0
|
||||
Tcri = CP.PropsSI('Tcrit','T',0,'P',0,fluid)
|
||||
#Tmax = CP.PropsSI('Tcrit','T',0,'P',0,fluid) * 2.0
|
||||
Tmax = CP.PropsSI('Tcrit','T',0,'P',0,fluid) * 2.0
|
||||
|
||||
## Get phase boundary
|
||||
T_TP = np.linspace(Tmin, Tcri-0.5, 0.5*points)
|
||||
@@ -275,12 +275,8 @@ Hmax = H_L + (H_V-H_L)*2.0
|
||||
Pmin = np.min([P_L,P_V])
|
||||
Pmax = CP.PropsSI('pcrit','T',0,'P',0,fluid) * 2.0 # should be p_reduce
|
||||
|
||||
Tmin = CP.PropsSI('T','H',Hmin,'P',Pmax,fluid)
|
||||
Tmax = CP.PropsSI('T','H',Hmax,'P',Pmin,fluid)
|
||||
|
||||
Dmin = CP.PropsSI('D','H',Hmax,'P',Pmin,fluid)
|
||||
Dmax = CP.PropsSI('D','H',Hmin,'P',Pmax,fluid)
|
||||
|
||||
Dmin = CP.PropsSI('D','H',Hmin,'P',Pmax,fluid)
|
||||
Dmax = CP.PropsSI('D','H',Hmax,'P',Pmin,fluid)
|
||||
|
||||
|
||||
|
||||
@@ -330,6 +326,7 @@ Tdata = fill_Z(X,Y)
|
||||
HPSdict = {'H': X, 'P': Y, 'S': Z, 'V': logVdata, 'T': Tdata, 'H_TP': X_TP, 'P_TP': Y_TP, 'S_TP': Z_TP}
|
||||
|
||||
|
||||
|
||||
#########################################################################
|
||||
# Start with the next diagram, vTp
|
||||
#########################################################################
|
||||
@@ -341,10 +338,10 @@ Z_TP = logP_TP
|
||||
|
||||
#Xmin = np.log10(1.0/Dmax)
|
||||
#Xmax = np.log10(1.0/Dmin)
|
||||
Xmin = np.min(logVdata)
|
||||
Xmax = np.max(logVdata)
|
||||
Ymin = np.min(Tdata)
|
||||
Ymax = np.max(Tdata)
|
||||
Xmin = np.min(X_TP)
|
||||
Xmax = np.max(X_TP)
|
||||
Ymin = np.min(Y_TP)
|
||||
Ymax = Tmax
|
||||
|
||||
X = np.linspace(Xmin, Xmax, points) # Volume
|
||||
Y = np.linspace(Ymin, Ymax, points) # Temperature
|
||||
|
||||
@@ -10,6 +10,10 @@ import os
|
||||
import sys
|
||||
import json
|
||||
import hashlib
|
||||
import struct
|
||||
import glob
|
||||
|
||||
json_options = {'indent' : 2, 'sort_keys' : True}
|
||||
|
||||
def get_hash(data):
|
||||
return hashlib.sha224(data).hexdigest()
|
||||
@@ -23,6 +27,70 @@ if os.path.exists(hashes_fname):
|
||||
else:
|
||||
hashes = dict()
|
||||
|
||||
# 0: Input file path relative to dev folder
|
||||
# 1: Output file path relative to include folder
|
||||
# 2: Name of variable
|
||||
values = [
|
||||
('all_fluids.json','all_fluids_JSON.h','all_fluids_JSON'),
|
||||
('all_incompressibles.json','all_incompressibles_JSON.h','all_incompressibles_JSON'),
|
||||
('mixtures/mixture_excess_term.json', 'mixture_excess_term_JSON.h', 'mixture_excess_term_JSON'),
|
||||
('mixtures/mixture_reducing_parameters.json', 'mixture_reducing_parameters_JSON.h', 'mixture_reducing_parameters_JSON')
|
||||
]
|
||||
|
||||
def TO_CPP(root_dir, hashes):
|
||||
def to_chunks(l, n):
|
||||
if n<1:
|
||||
n=1
|
||||
return [l[i:i+n] for i in range(0, len(l), n)]
|
||||
|
||||
# Normalise path name
|
||||
root_dir = os.path.normpath(root_dir)
|
||||
|
||||
# First we package up the JSON files
|
||||
combine_json(root_dir)
|
||||
|
||||
for infile,outfile,variable in values:
|
||||
|
||||
json = open(os.path.join(root_dir,'dev',infile),'r').read()
|
||||
|
||||
# convert each character to hex and add a terminating NULL character to end the
|
||||
# string, join into a comma separated string
|
||||
if sys.version_info[0] == 2:
|
||||
h = [hex(struct.unpack("b",b)[0]) for b in json] + ['0x00']
|
||||
else:
|
||||
# Encode as ASCII characters
|
||||
json = json.encode('ascii')
|
||||
h = [str(hex(b)) for b in json] + [str('0x00')]
|
||||
|
||||
# Break up the file into lines of 16 hex characters
|
||||
chunks = to_chunks(h, 16)
|
||||
|
||||
# Put the lines back together again
|
||||
# The chunks are joined together with commas, and then EOL are used to join the rest
|
||||
hex_string = ',\n'.join([', '.join(chunk) for chunk in chunks])
|
||||
|
||||
# Check if hash is up to date based on using variable as key
|
||||
if variable not in hashes or (variable in hashes and hashes[variable] != get_hash(hex_string)):
|
||||
|
||||
# Generate the output string
|
||||
output = '// File generated by the script dev/JSON_to_CPP.py on '+ str(datetime.now()) + '\n\n'
|
||||
output += '// JSON file encoded in binary form\n'
|
||||
output += 'const unsigned char '+variable+'_binary[] = {\n' + hex_string + '\n};'+'\n\n'
|
||||
output += '// Combined into a single std::string \n'
|
||||
output += 'std::string {v:s}({v:s}_binary, {v:s}_binary + sizeof({v:s}_binary)/sizeof({v:s}_binary[0]));'.format(v = variable)
|
||||
|
||||
# Write it to file
|
||||
f = open(os.path.join(root_dir,'include',outfile), 'w')
|
||||
f.write(output)
|
||||
f.close()
|
||||
|
||||
# Store the hash of the data that was written to file (not including the header)
|
||||
hashes[variable] = get_hash(hex_string)
|
||||
|
||||
print(os.path.join(root_dir,'include',outfile)+ ' written to file')
|
||||
else:
|
||||
print(outfile + ' is up to date')
|
||||
|
||||
def version_to_file(root_dir):
|
||||
|
||||
# Get the version from the version.txt file
|
||||
@@ -30,7 +98,6 @@ def version_to_file(root_dir):
|
||||
|
||||
# Get the hash of the version
|
||||
if 'version' not in hashes or ('version' in hashes and hashes['version'] != get_hash(version)):
|
||||
print('*** Generating cpversion.h ***')
|
||||
hashes['version'] = get_hash(version)
|
||||
|
||||
# Format the string to be written
|
||||
@@ -46,6 +113,9 @@ def version_to_file(root_dir):
|
||||
f = open(file_name,'w')
|
||||
f.write(string_for_file)
|
||||
f.close()
|
||||
|
||||
print(os.path.join(include_dir,'cpversion.h') + ' written to file')
|
||||
|
||||
else:
|
||||
print('cpversion.h is up to date')
|
||||
|
||||
@@ -72,11 +142,15 @@ def gitrev_to_file(root_dir):
|
||||
include_dir = os.path.join(root_dir,'include')
|
||||
|
||||
if p.returncode != 0:
|
||||
print('tried to update git revision, but it failed for some reason (building from zip file?)')
|
||||
gitrev = '???'
|
||||
print('tried to get git revision from git, but could not (building from zip file?)')
|
||||
gitrevision_path = os.path.join(root_dir, 'dev', 'gitrevision.txt')
|
||||
if os.path.exists(gitrevision_path):
|
||||
gitrev = open(gitrevision_path, 'r').read().strip()
|
||||
else:
|
||||
print('tried to get git revision from '+gitrevision_path+', but could not')
|
||||
gitrev = '???'
|
||||
else:
|
||||
gitrev = stdout.strip()
|
||||
print('git revision is', gitrev)
|
||||
|
||||
try:
|
||||
is_hash = gitrev.find(' ') == -1 # python 2.x
|
||||
@@ -86,6 +160,8 @@ def gitrev_to_file(root_dir):
|
||||
if not is_hash:
|
||||
raise ValueError('No hash returned from call to git, got '+rev+' instead')
|
||||
|
||||
print('git revision is', gitrev)
|
||||
|
||||
if 'gitrevision' not in hashes or ('gitrevision' in hashes and hashes['gitrevision'] != get_hash(gitrev)):
|
||||
print('*** Generating gitrevision.h ***')
|
||||
gitstring = '//Generated by the generate_headers.py script on {t:s}\n\nstd::string gitrevision = \"{rev:s}\";'.format(t = str(datetime.now()), rev = gitrev)
|
||||
@@ -95,11 +171,54 @@ def gitrev_to_file(root_dir):
|
||||
f.close()
|
||||
|
||||
hashes['gitrevision'] = get_hash(gitrev)
|
||||
print(os.path.join(include_dir,'gitrevision.h') + ' written to file')
|
||||
else:
|
||||
print('gitrevision.h is up to date')
|
||||
|
||||
except (subprocess.CalledProcessError,OSError):
|
||||
pass
|
||||
|
||||
def combine_json(root_dir):
|
||||
|
||||
master = []
|
||||
|
||||
for file in glob.glob(os.path.join(root_dir,'dev','fluids','*.json')):
|
||||
|
||||
path, file_name = os.path.split(file)
|
||||
fluid_name = file_name.split('.')[0]
|
||||
|
||||
# Load the fluid file
|
||||
fluid = json.load(open(file, 'r'))
|
||||
|
||||
master += [fluid]
|
||||
|
||||
fp = open(os.path.join(root_dir,'dev','all_fluids_verbose.json'),'w')
|
||||
fp.write(json.dumps(master, **json_options))
|
||||
fp.close()
|
||||
|
||||
fp = open(os.path.join(root_dir,'dev','all_fluids.json'),'w')
|
||||
fp.write(json.dumps(master))
|
||||
fp.close()
|
||||
|
||||
master = []
|
||||
|
||||
for file in glob.glob(os.path.join(root_dir,'dev','IncompressibleLiquids','*.json')):
|
||||
|
||||
path, file_name = os.path.split(file)
|
||||
fluid_name = file_name.split('.')[0]
|
||||
|
||||
# Load the fluid file
|
||||
fluid = json.load(open(file, 'r'))
|
||||
|
||||
master += [fluid]
|
||||
|
||||
fp = open(os.path.join(root_dir,'dev','all_incompressibles_verbose.json'),'w')
|
||||
fp.write(json.dumps(master, **json_options))
|
||||
fp.close()
|
||||
|
||||
fp = open(os.path.join(root_dir,'dev','all_incompressibles.json'),'w')
|
||||
fp.write(json.dumps(master))
|
||||
fp.close()
|
||||
|
||||
if __name__=='__main__':
|
||||
|
||||
@@ -109,8 +228,7 @@ if __name__=='__main__':
|
||||
version_to_file(root_dir = repo_root_path)
|
||||
gitrev_to_file(root_dir = repo_root_path)
|
||||
|
||||
import JSON_to_CPP
|
||||
JSON_to_CPP.TO_CPP(root_dir = repo_root_path, hashes = hashes)
|
||||
TO_CPP(root_dir = repo_root_path, hashes = hashes)
|
||||
|
||||
# Write the hashes to a hashes JSON file
|
||||
if hashes:
|
||||
|
||||
2
externals/Catch
vendored
2
externals/Catch
vendored
Submodule externals/Catch updated: 4e044ed4b1...44aa45cc4f
1
externals/Eigen
vendored
Submodule
1
externals/Eigen
vendored
Submodule
Submodule externals/Eigen added at 42856d5e1d
1
externals/eigen
vendored
1
externals/eigen
vendored
Submodule externals/eigen deleted from 24d4064d26
@@ -32,7 +32,7 @@
|
||||
# undef EXPORT_CODE
|
||||
# define EXPORT_CODE extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
// Functions with the call type like
|
||||
// EXPORT_CODE void CONVENTION AFunction(double, double);
|
||||
// will be exported to the DLL
|
||||
@@ -41,33 +41,33 @@
|
||||
####################################################################################
|
||||
Overloads for DLL wrapping puposes
|
||||
|
||||
These functions take strings which are 0-terminated. These functions pass directly to
|
||||
These functions take strings which are 0-terminated. These functions pass directly to
|
||||
equivalently named functions in CoolProp.h that take std::string
|
||||
####################################################################################
|
||||
*/
|
||||
|
||||
/**
|
||||
\overload
|
||||
\overload
|
||||
\sa Props1SI(std::string, std::string)
|
||||
*/
|
||||
EXPORT_CODE double CONVENTION Props1SI(const char *FluidName, const char* Output);
|
||||
/**
|
||||
\overload
|
||||
\overload
|
||||
\sa PropsSI(std::string, std::string, double, std::string, double, std::string)
|
||||
*/
|
||||
EXPORT_CODE double CONVENTION PropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Ref);
|
||||
/**
|
||||
\overload
|
||||
\overload
|
||||
\sa Props(std::string, std::string, double, std::string, double, std::string)
|
||||
*/
|
||||
EXPORT_CODE double CONVENTION PropsS(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Ref);
|
||||
/**
|
||||
\overload
|
||||
\overload
|
||||
\sa Props(std::string, std::string, double, std::string, double, std::string)
|
||||
*/
|
||||
EXPORT_CODE double CONVENTION Props(const char *Output, const char Name1, double Prop1, const char Name2, double Prop2, const char *Ref);
|
||||
/**
|
||||
\overload
|
||||
\overload
|
||||
\sa Props1(std::string, std::string)
|
||||
*/
|
||||
EXPORT_CODE double CONVENTION Props1(const char *FluidName, const char *Output);
|
||||
@@ -76,8 +76,8 @@
|
||||
\sa IsFluidType(std::string, std::string)
|
||||
*/
|
||||
EXPORT_CODE int CONVENTION IsFluidType(const char *Ref, const char *Type);
|
||||
|
||||
// When using SWIG, it is extremely difficult to deal with char* for output strings, so just use
|
||||
|
||||
// When using SWIG, it is extremely difficult to deal with char* for output strings, so just use
|
||||
// the std::string version since SWIG can handle std::string just fine
|
||||
#if defined(SWIG)
|
||||
std::string get_global_param_string(std::string ParamName);
|
||||
@@ -101,7 +101,7 @@
|
||||
####################################################################################
|
||||
Implemented functions
|
||||
|
||||
These functions take inputs that are compatible with DLL passing and are
|
||||
These functions take inputs that are compatible with DLL passing and are
|
||||
implemented in CoolPropDLL.cpp
|
||||
####################################################################################
|
||||
*/
|
||||
@@ -110,9 +110,9 @@
|
||||
\brief FORTRAN 77 style wrapper of the PropsSI function
|
||||
\sa PropsSI(std::string, std::string, double, std::string, double, std::string)
|
||||
*/
|
||||
EXPORT_CODE void CONVENTION F77PropsSI(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char * Ref, double *output);
|
||||
EXPORT_CODE void CONVENTION propssi_(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char * Ref, double *output);
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
EXPORT_CODE double CONVENTION PropsSIZ(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *FluidName, const double *z, int n);
|
||||
|
||||
@@ -120,12 +120,12 @@
|
||||
// from get_param_index('D') for instance and the Fluid index from get_Fluid_index('Air') for instance
|
||||
EXPORT_CODE double CONVENTION IPropsSI(long iOutput, long iName1, double Prop1, long iName2, double Prop2, long iFluid);
|
||||
EXPORT_CODE double CONVENTION IProps(long iOutput, long iName1, double Prop1, long iName2, double Prop2, long iFluid);
|
||||
|
||||
|
||||
/// Convert from degrees Fahrenheit to Kelvin (useful primarily for testing)
|
||||
EXPORT_CODE double CONVENTION F2K(double T_F);
|
||||
/// Convert from Kelvin to degrees Fahrenheit (useful primarily for testing)
|
||||
EXPORT_CODE double CONVENTION K2F(double T_K);
|
||||
|
||||
|
||||
EXPORT_CODE long CONVENTION get_param_index(const char *param);
|
||||
EXPORT_CODE long CONVENTION redirect_stdout(const char *file);
|
||||
|
||||
@@ -144,14 +144,14 @@
|
||||
// Humid Air Properties
|
||||
// ---------------------------------
|
||||
|
||||
|
||||
|
||||
EXPORT_CODE double CONVENTION HAPropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Name3, double Prop3);
|
||||
|
||||
/**
|
||||
/**
|
||||
\brief FORTRAN 77 style wrapper of the HAPropsSI function
|
||||
*/
|
||||
EXPORT_CODE void CONVENTION F77HAPropsSI(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char *Name3, double *Prop3, double *output);
|
||||
EXPORT_CODE void CONVENTION hapropssi_(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char *Name3, double *Prop3, double *output);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
#define COOLPROP_OK 1
|
||||
#endif
|
||||
|
||||
#ifdef HUGE_VAL
|
||||
# define _HUGE HUGE_VAL
|
||||
#if defined(HUGE_VAL) && !defined(_HUGE)
|
||||
# define _HUGE HUGE_VAL
|
||||
#else
|
||||
// GCC Version of huge value macro
|
||||
#ifdef HUGE
|
||||
# define _HUGE HUGE
|
||||
#endif
|
||||
// GCC Version of huge value macro
|
||||
#if defined(HUGE) && !defined(_HUGE)
|
||||
# define _HUGE HUGE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Microsoft version of math.h doesn't include acosh or asinh, so we just define them here.
|
||||
// It was included from Visual Studio 2013
|
||||
// It was included from Visual Studio 2013
|
||||
#if _MSC_VER < 1800
|
||||
static double acosh(double x)
|
||||
{
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__powerpc__)
|
||||
// PPC version of math.h doesn't include acosh or asinh, so we just define them here
|
||||
static double acosh(double x)
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__powerpc__)
|
||||
#undef min
|
||||
#undef max
|
||||
@@ -87,13 +87,14 @@
|
||||
#define DEPRECATED(func) func
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <locale>
|
||||
#include <fstream>
|
||||
#include <cerrno>
|
||||
#include <numeric>
|
||||
|
||||
/// The following code for the trim functions was taken from http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
|
||||
// trim from start
|
||||
@@ -119,7 +120,7 @@
|
||||
std::string format(const char* fmt, ...);
|
||||
// Missing string split - like in Python
|
||||
std::vector<std::string> strsplit(std::string s, char del);
|
||||
|
||||
|
||||
inline std::string upper(const std::string str_)
|
||||
{
|
||||
std::string str = str_;
|
||||
@@ -128,13 +129,13 @@
|
||||
}
|
||||
|
||||
std::string strjoin(std::vector<std::string> strings, std::string delim);
|
||||
|
||||
|
||||
void MatInv_2(double A[2][2] , double B[2][2]);
|
||||
|
||||
double root_sum_square(std::vector<double> x);
|
||||
double interp1d(std::vector<double> *x, std::vector<double> *y, double x0);
|
||||
double powInt(double x, int y);
|
||||
|
||||
|
||||
template<class T> T LinearInterp(T x0, T x1, T y0, T y1, T x)
|
||||
{
|
||||
return (y1-y0)/(x1-x0)*(x-x0)+y0;
|
||||
@@ -143,12 +144,12 @@
|
||||
{
|
||||
return LinearInterp(x[i0],x[i1],y[i0],y[i1],val);
|
||||
};
|
||||
|
||||
|
||||
template<class T> T QuadInterp(T x0, T x1, T x2, T f0, T f1, T f2, T x)
|
||||
{
|
||||
/* Quadratic interpolation.
|
||||
Based on method from Kreyszig,
|
||||
Advanced Engineering Mathematics, 9th Edition
|
||||
/* Quadratic interpolation.
|
||||
Based on method from Kreyszig,
|
||||
Advanced Engineering Mathematics, 9th Edition
|
||||
*/
|
||||
T L0, L1, L2;
|
||||
L0=((x-x1)*(x-x2))/((x0-x1)*(x0-x2));
|
||||
@@ -160,7 +161,7 @@
|
||||
{
|
||||
return QuadInterp(x[i0],x[i1],x[i2],y[i0],y[i1],y[i2],val);
|
||||
};
|
||||
|
||||
|
||||
template<class T> T CubicInterp( T x0, T x1, T x2, T x3, T f0, T f1, T f2, T f3, T x)
|
||||
{
|
||||
/*
|
||||
@@ -190,7 +191,7 @@
|
||||
};
|
||||
|
||||
void solve_cubic(double a, double b, double c, double d, int &N, double &x0, double &x1, double &x2);
|
||||
|
||||
|
||||
inline double min3(double x1, double x2, double x3){return std::min(std::min(x1, x2), x3);};
|
||||
inline double max3(double x1, double x2, double x3){return std::max(std::max(x1, x2), x3);};
|
||||
|
||||
@@ -250,6 +251,16 @@
|
||||
return check_abs(A,B,1e5*DBL_EPSILON);
|
||||
};
|
||||
|
||||
template<class T> void normalize_vector(std::vector<T> &x)
|
||||
{
|
||||
// Sum up all the elements in the vector
|
||||
T sumx = std::accumulate( x.begin(), x.end(), static_cast<T>(0) );
|
||||
// Normalize the components by dividing each by the sum
|
||||
for (std::size_t i = 0; i < x.size(); ++i){
|
||||
x[i] /= sumx;
|
||||
}
|
||||
};
|
||||
|
||||
#define CATCH_ALL_ERRORS_RETURN_HUGE(x) try{ \
|
||||
x \
|
||||
} \
|
||||
@@ -259,6 +270,6 @@
|
||||
} \
|
||||
catch(...){ \
|
||||
return _HUGE; \
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,7 @@ EXPORT_CODE double CONVENTION Props(const char *Output, char Name1, double Prop1
|
||||
// Convert inputs to SI
|
||||
Prop1 = convert_from_kSI_to_SI(iName1, Prop1);
|
||||
Prop2 = convert_from_kSI_to_SI(iName2, Prop2);
|
||||
|
||||
|
||||
// Call the SI function
|
||||
double val = PropsSI(Output, sName1.c_str(), Prop1, sName2.c_str(), Prop2, Ref);
|
||||
|
||||
@@ -135,16 +135,16 @@ EXPORT_CODE double CONVENTION PropsSIZ(const char *Output, const char *Name1, do
|
||||
std::string _Output = Output, _Name1 = Name1, _Name2 = Name2, _FluidName = FluidName;
|
||||
return CoolProp::PropsSI(_Output, _Name1, Prop1, _Name2, Prop2, _FluidName, std::vector<double>(z, z+n));
|
||||
}
|
||||
EXPORT_CODE void CONVENTION F77PropsSI(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char * FluidName, double *output)
|
||||
EXPORT_CODE void CONVENTION propssi_(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char * FluidName, double *output)
|
||||
{
|
||||
std::string _Output = Output, _Name1 = Name1, _Name2 = Name2, _FluidName = FluidName;
|
||||
*output = CoolProp::PropsSI(_Output, _Name1, *Prop1, _Name2, *Prop2, _FluidName);
|
||||
}
|
||||
|
||||
EXPORT_CODE double CONVENTION K2F(double T){
|
||||
return T * 9 / 5 - 459.67;
|
||||
EXPORT_CODE double CONVENTION K2F(double T){
|
||||
return T * 9 / 5 - 459.67;
|
||||
}
|
||||
EXPORT_CODE double CONVENTION F2K(double T_F){
|
||||
EXPORT_CODE double CONVENTION F2K(double T_F){
|
||||
return (T_F + 459.67) * 5 / 9;
|
||||
}
|
||||
EXPORT_CODE int CONVENTION get_debug_level(){
|
||||
@@ -174,7 +174,7 @@ EXPORT_CODE double CONVENTION HAPropsSI(const char *Output, const char *Name1, d
|
||||
{
|
||||
return HumidAir::HAPropsSI(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3);
|
||||
}
|
||||
EXPORT_CODE void CONVENTION F77HAPropsSI(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char * Name3, double * Prop3, double *output)
|
||||
EXPORT_CODE void CONVENTION hapropssi_(const char *Output, const char *Name1, double *Prop1, const char *Name2, double *Prop2, const char * Name3, double * Prop3, double *output)
|
||||
{
|
||||
*output = HumidAir::HAPropsSI(Output, Name1, *Prop1, Name2, *Prop2, Name3, *Prop3);
|
||||
}
|
||||
|
||||
@@ -12,181 +12,389 @@
|
||||
|
||||
namespace CoolProp{
|
||||
|
||||
|
||||
}; /* namespace CoolProp */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef ENABLE_CATCH
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include "catch.hpp"
|
||||
|
||||
TEST_CASE("Internal consistency checks and example use cases for MatrixMath.h","[MatrixMath]")
|
||||
{
|
||||
bool PRINT = false;
|
||||
|
||||
/// Test case for "SylthermXLT" by "Dow Chemicals"
|
||||
std::vector<double> cHeat;
|
||||
cHeat.clear();
|
||||
cHeat.push_back(+1.1562261074E+03);
|
||||
cHeat.push_back(+2.0994549103E+00);
|
||||
cHeat.push_back(+7.7175381057E-07);
|
||||
cHeat.push_back(-3.7008444051E-20);
|
||||
|
||||
std::vector<std::vector<double> > cHeat2D;
|
||||
cHeat2D.push_back(cHeat);
|
||||
cHeat2D.push_back(cHeat);
|
||||
|
||||
SECTION("Pretty printing tests") {
|
||||
|
||||
Eigen::MatrixXd matrix = Eigen::MatrixXd::Random(4,1);
|
||||
std::string tmpStr;
|
||||
if (PRINT) std::cout << std::endl;
|
||||
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::vec_to_string(cHeat[0]) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::vec_to_string(cHeat) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::vec_to_string(cHeat2D) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::mat_to_string(CoolProp::vec_to_eigen(cHeat[0])) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::mat_to_string(CoolProp::vec_to_eigen(cHeat, 1)) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::mat_to_string(CoolProp::vec_to_eigen(cHeat, 2)) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
CHECK_NOTHROW( tmpStr = CoolProp::mat_to_string(CoolProp::vec_to_eigen(cHeat2D)) );
|
||||
if (PRINT) std::cout << tmpStr << std::endl;
|
||||
}
|
||||
|
||||
SECTION("Matrix modifications") {
|
||||
Eigen::MatrixXd matrix = CoolProp::vec_to_eigen(cHeat2D);
|
||||
|
||||
std::string tmpStr;
|
||||
std::vector<std::vector<double> > vec2D;
|
||||
if (PRINT) std::cout << std::endl;
|
||||
|
||||
CHECK_NOTHROW( CoolProp::removeColumn(matrix,1) );
|
||||
if (PRINT) std::cout << CoolProp::mat_to_string(matrix) << std::endl;
|
||||
|
||||
CHECK_NOTHROW( CoolProp::removeRow(matrix,1) );
|
||||
if (PRINT) std::cout << CoolProp::mat_to_string(matrix) << std::endl;
|
||||
|
||||
CHECK_THROWS( CoolProp::removeColumn(matrix,10) );
|
||||
CHECK_THROWS( CoolProp::removeRow(matrix,10) );
|
||||
}
|
||||
|
||||
SECTION("std::vector to Eigen::Matrix and back") {
|
||||
std::vector<std::vector<double> > vec2D(cHeat2D);
|
||||
Eigen::MatrixXd matrix = CoolProp::vec_to_eigen(vec2D);
|
||||
for (size_t i = 0; i < matrix.cols(); ++i) {
|
||||
for (size_t j = 0; j < matrix.rows(); ++j) {
|
||||
CHECK( fabs(matrix(j,i)-vec2D[j][i]) <= 1e-10 );
|
||||
}
|
||||
}
|
||||
vec2D = CoolProp::eigen_to_vec(matrix);
|
||||
for (size_t i = 0; i < matrix.cols(); ++i) {
|
||||
for (size_t j = 0; j < matrix.rows(); ++j) {
|
||||
CHECK( fabs(matrix(j,i)-vec2D[j][i]) <= 1e-10 );
|
||||
}
|
||||
}
|
||||
std::vector<double> vec1D(cHeat);
|
||||
matrix = CoolProp::vec_to_eigen(vec1D);
|
||||
for (size_t i = 0; i < matrix.cols(); ++i) {
|
||||
for (size_t j = 0; j < matrix.rows(); ++j) {
|
||||
CHECK( fabs(matrix(j,i)-vec1D[j]) <= 1e-10 );
|
||||
}
|
||||
}
|
||||
vec1D = CoolProp::eigen_to_vec1D(matrix);
|
||||
for (size_t i = 0; i < matrix.cols(); ++i) {
|
||||
for (size_t j = 0; j < matrix.rows(); ++j) {
|
||||
CHECK( fabs(matrix(j,i)-vec1D[j]) <= 1e-10 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* ENABLE_CATCH */
|
||||
|
||||
|
||||
//#include <unsupported/Eigen/Polynomials>
|
||||
//#include <iostream>
|
||||
////using namespace Eigen;
|
||||
////using namespace std;
|
||||
//
|
||||
//#include <vector>
|
||||
//#include <string>
|
||||
//#include <MatrixMath.h>
|
||||
//
|
||||
//int main()
|
||||
///*
|
||||
//Owe a debt of gratitude to http://sole.ooz.ie/en - very clear treatment of GJ
|
||||
//*/
|
||||
//template<typename T> void swap_rows(std::vector<std::vector<T> > *A, size_t row1, size_t row2)
|
||||
//{
|
||||
//Eigen::Vector4d roots = Eigen::Vector4d::Random();
|
||||
//std::cout << "Roots: " << roots.transpose() << std::endl;
|
||||
//Eigen::Matrix<double,5,1> polynomial;
|
||||
//Eigen::roots_to_monicPolynomial( roots, polynomial );
|
||||
//std::cout << "Polynomial: ";
|
||||
//for( int i=0; i<4; ++i ){ std::cout << polynomial[i] << ".x^" << i << "+ "; }
|
||||
//std::cout << polynomial[4] << ".x^4" << std::endl;
|
||||
//Eigen::Vector4d evaluation;
|
||||
//for( int i=0; i<4; ++i ){
|
||||
//evaluation[i] = Eigen::poly_eval( polynomial, roots[i] ); }
|
||||
//std::cout << "Evaluation of the polynomial at the roots: " << evaluation.transpose() << std::endl;
|
||||
//std::cout << std::endl;
|
||||
// for (size_t col = 0; col < (*A)[0].size(); col++){
|
||||
// std::swap((*A)[row1][col],(*A)[row2][col]);
|
||||
// }
|
||||
//}
|
||||
//template<typename T> void subtract_row_multiple(std::vector<std::vector<T> > *A, size_t row, T multiple, size_t pivot_row)
|
||||
//{
|
||||
// for (size_t col = 0; col < (*A)[0].size(); col++){
|
||||
// (*A)[row][col] -= multiple*(*A)[pivot_row][col];
|
||||
// }
|
||||
//}
|
||||
//template<typename T> void divide_row_by(std::vector<std::vector<T> > *A, size_t row, T value)
|
||||
//{
|
||||
// for (size_t col = 0; col < (*A)[0].size(); col++){
|
||||
// (*A)[row][col] /= value;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//template<typename T> size_t get_pivot_row(std::vector<std::vector<T> > *A, size_t col)
|
||||
//{
|
||||
// int index = col;
|
||||
// T max = 0, val;
|
||||
//
|
||||
// for (size_t row = col; row < (*A).size(); row++)
|
||||
// {
|
||||
// val = (*A)[row][col];
|
||||
// if (fabs(val) > max)
|
||||
// {
|
||||
// max = fabs(val);
|
||||
// index = row;
|
||||
// }
|
||||
// }
|
||||
// return index;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//template<typename T> std::vector<std::vector<T> > linsolve_Gauss_Jordan(std::vector<std::vector<T> > const& A, std::vector<std::vector<T> > const& B) {
|
||||
// std::vector<std::vector<T> > AB;
|
||||
// std::vector<std::vector<T> > X;
|
||||
// size_t pivot_row;
|
||||
// T pivot_element;
|
||||
//
|
||||
// size_t NrowA = num_rows(A);
|
||||
// size_t NrowB = num_rows(B);
|
||||
// size_t NcolA = num_cols(A);
|
||||
// size_t NcolB = num_cols(B);
|
||||
//
|
||||
// if (NrowA!=NrowB) throw ValueError(format("You have to provide matrices with the same number of rows: %d is not %d. ",NrowA,NrowB));
|
||||
//
|
||||
// AB.resize(NrowA, std::vector<T>(NcolA+NcolB, 0));
|
||||
// X.resize(NrowA, std::vector<T>(NcolB, 0));
|
||||
//
|
||||
// // Build the augmented matrix
|
||||
// for (size_t row = 0; row < NrowA; row++){
|
||||
// for (size_t col = 0; col < NcolA; col++){
|
||||
// AB[row][col] = A[row][col];
|
||||
// }
|
||||
// for (size_t col = NcolA; col < NcolA+NcolB; col++){
|
||||
// AB[row][col] = B[row][col-NcolA];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (size_t col = 0; col < NcolA; col++){
|
||||
// // Find the pivot value
|
||||
// pivot_row = get_pivot_row(&AB, col);
|
||||
//
|
||||
// if (fabs(AB[pivot_row][col]) < 10*DBL_EPSILON){ throw ValueError(format("Zero occurred in row %d, the matrix is singular. ",pivot_row));}
|
||||
//
|
||||
// if (pivot_row>=col){
|
||||
// // Swap pivot row and current row
|
||||
// swap_rows(&AB, col, pivot_row);
|
||||
// }
|
||||
// // Get the pivot element
|
||||
// pivot_element = AB[col][col];
|
||||
// // Divide the pivot row by the pivot element
|
||||
// divide_row_by(&AB,col,pivot_element);
|
||||
//
|
||||
// if (col < NrowA-1)
|
||||
// {
|
||||
// // All the rest of the rows, subtract the value of the [r][c] combination
|
||||
// for (size_t row = col + 1; row < NrowA; row++)
|
||||
// {
|
||||
// subtract_row_multiple(&AB,row,AB[row][col],col);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int col = NcolA - 1; col > 0; col--)
|
||||
// {
|
||||
// for (int row = col - 1; row >=0; row--)
|
||||
// {
|
||||
// subtract_row_multiple(&AB,row,AB[row][col],col);
|
||||
// }
|
||||
// }
|
||||
// // Set the output value
|
||||
// for (size_t row = 0; row < NrowA; row++){
|
||||
// for (size_t col = 0; col < NcolB; col++){
|
||||
// X[row][col] = AB[row][NcolA+col];
|
||||
// }
|
||||
// }
|
||||
// return X;
|
||||
//}
|
||||
//
|
||||
//
|
||||
////std::vector<std::vector<double> > linsolve_Gauss_Jordan_reimpl(std::vector<std::vector<double> > const& A, std::vector<std::vector<double> > const& B) {
|
||||
//// std::vector<std::vector<double> > AB;
|
||||
//// std::vector<std::vector<double> > X;
|
||||
//// size_t pivot_row;
|
||||
//// double pivot_element;
|
||||
//// double tmp_element;
|
||||
////
|
||||
////Eigen::MatrixXd coeffs = Eigen::MatrixXd::Random(5,1);
|
||||
////Eigen::MatrixXd input = Eigen::MatrixXd::Random(2,1)*1e0;
|
||||
//Eigen::Vector4d coeffs = Eigen::Vector4d::Random()*1e2;
|
||||
//double input = 1.9e0;
|
||||
//std::cout << "Coeffs: " << std::endl << coeffs.transpose() << std::endl;
|
||||
//double eval = Eigen::poly_eval( coeffs, input);
|
||||
//std::cout << "Evaluation of the polynomial at " << input << std::endl;
|
||||
//std::cout << eval << std::endl;
|
||||
//// size_t NrowA = num_rows(A);
|
||||
//// size_t NrowB = num_rows(B);
|
||||
//// size_t NcolA = num_cols(A);
|
||||
//// size_t NcolB = num_cols(B);
|
||||
////
|
||||
//// if (NrowA!=NrowB) throw ValueError(format("You have to provide matrices with the same number of rows: %d is not %d. ",NrowA,NrowB));
|
||||
////
|
||||
//// AB.resize(NrowA, std::vector<double>(NcolA+NcolB, 0));
|
||||
//// X.resize(NrowA, std::vector<double>(NcolB, 0));
|
||||
////
|
||||
//// // Build the augmented matrix
|
||||
//// for (size_t row = 0; row < NrowA; row++){
|
||||
//// for (size_t col = 0; col < NcolA; col++){
|
||||
//// AB[row][col] = A[row][col];
|
||||
//// }
|
||||
//// for (size_t col = NcolA; col < NcolA+NcolB; col++){
|
||||
//// AB[row][col] = B[row][col-NcolA];
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// for (size_t col = 0; col < NcolA; col++){
|
||||
//// // Find the pivot row
|
||||
//// pivot_row = 0;
|
||||
//// pivot_element = 0.0;
|
||||
//// for (size_t row = col; row < NrowA; row++){
|
||||
//// tmp_element = fabs(AB[row][col]);
|
||||
//// if (tmp_element>pivot_element) {
|
||||
//// pivot_element = tmp_element;
|
||||
//// pivot_row = row;
|
||||
//// }
|
||||
//// }
|
||||
//// // Check for errors
|
||||
//// if (AB[pivot_row][col]<1./_HUGE) throw ValueError(format("Zero occurred in row %d, the matrix is singular. ",pivot_row));
|
||||
//// // Swap the rows
|
||||
//// if (pivot_row>col) {
|
||||
//// for (size_t colInt = 0; colInt < NcolA; colInt++){
|
||||
//// std::swap(AB[pivot_row][colInt],AB[pivot_row][colInt]);
|
||||
//// }
|
||||
//// }
|
||||
//// // Process the entries below current element
|
||||
//// for (size_t row = col; row < NrowA; row++){
|
||||
//// // Entries to the right of current element (until end of A)
|
||||
//// for (size_t colInt = col+1; colInt < NcolA; colInt++){
|
||||
//// // All entries in augmented matrix
|
||||
//// for (size_t colFull = col; colFull < NcolA+NcolB; colFull++){
|
||||
//// AB[colInt][colFull] -= AB[col][colFull] * AB[colInt][col] / AB[col][col];
|
||||
//// }
|
||||
//// AB[colInt][col] = 0.0;
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// return AB;
|
||||
////}
|
||||
//
|
||||
//double vec0 = 0.1;
|
||||
//std::vector<double> vec1(2,0.44);
|
||||
//std::vector< std::vector<double> > vec2;
|
||||
//vec2.push_back(std::vector<double>(2,0.2));
|
||||
//vec2.push_back(std::vector<double>(2,0.3));
|
||||
//
|
||||
//std::cout << CoolProp::vec_to_string(vec0) << std::endl;
|
||||
//std::cout << CoolProp::vec_to_string(vec1) << std::endl;
|
||||
//std::cout << CoolProp::vec_to_string(vec2) << std::endl;
|
||||
//
|
||||
//Eigen::Matrix<double,2,2> mat;
|
||||
//mat.setConstant(2,2,0.25);
|
||||
//std::vector< std::vector<double> > vec;
|
||||
//
|
||||
//CoolProp::convert(mat, vec);
|
||||
//std::cout << CoolProp::vec_to_string(vec) << std::endl;
|
||||
//
|
||||
////Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> mat;
|
||||
////mat.resize(6,2);
|
||||
//
|
||||
//Eigen::Matrix<double,2,2> mat2;
|
||||
//CoolProp::convert(vec2, mat2);
|
||||
//CoolProp::convert(mat2, vec);
|
||||
//std::cout << CoolProp::vec_to_string(vec) << std::endl;
|
||||
//template<class T> std::vector<std::vector<T> > linsolve(std::vector<std::vector<T> > const& A, std::vector<std::vector<T> > const& B){
|
||||
// return linsolve_Gauss_Jordan(A, B);
|
||||
//}
|
||||
//
|
||||
//Eigen::Matrix<double,2,1> mat1;
|
||||
//CoolProp::convert(vec1, mat1);
|
||||
//std::vector<double> vec3;
|
||||
//CoolProp::convert(mat1, vec);
|
||||
//std::cout << CoolProp::vec_to_string(vec) << std::endl;
|
||||
//template<class T> std::vector<T> linsolve(std::vector<std::vector<T> > const& A, std::vector<T> const& b){
|
||||
// std::vector<std::vector<T> > B;
|
||||
// for (size_t i = 0; i < b.size(); i++){
|
||||
// B.push_back(std::vector<T>(1,b[i]));
|
||||
// }
|
||||
// B = linsolve(A, B);
|
||||
// B[0].resize(B.size(),0.0);
|
||||
// for (size_t i = 1; i < B.size(); i++){
|
||||
// B[0][i] = B[i][0];
|
||||
// }
|
||||
// return B[0];
|
||||
//}
|
||||
//
|
||||
////std::vector< std::vector<double> > vec(vec2);
|
||||
////CoolProp::convert(mat,vec);
|
||||
//
|
||||
////std::cout << CoolProp::vec_to_string() << std::endl;
|
||||
///// Some shortcuts and regularly needed operations
|
||||
//template<class T> std::size_t num_rows (std::vector<std::vector<T> > const& in){ return in.size(); }
|
||||
//template<class T> std::size_t num_cols (std::vector<std::vector<T> > const& in){
|
||||
// if (num_rows(in)>0) {
|
||||
// if (is_squared(in)) {
|
||||
// return in[0].size();
|
||||
// } else {
|
||||
// return max_cols(in);
|
||||
// }
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
//template<class T> std::size_t max_cols (std::vector<std::vector<T> > const& in){
|
||||
// std::size_t cols = 0;
|
||||
// std::size_t col = 0;
|
||||
// for (std::size_t i = 0; i < in.size(); i++) {
|
||||
// col = in[i].size();
|
||||
// if (cols<col) {cols = col;}
|
||||
// }
|
||||
// return cols;
|
||||
//}
|
||||
//template<class T> std::vector<T> get_row(std::vector< std::vector<T> > const& in, size_t row) { return in[row]; }
|
||||
//template<class T> std::vector<T> get_col(std::vector< std::vector<T> > const& in, size_t col) {
|
||||
// std::size_t sizeX = in.size();
|
||||
// if (sizeX<1) throw ValueError(format("You have to provide values, a vector length of %d is not valid. ",sizeX));
|
||||
// size_t sizeY = in[0].size();
|
||||
// if (sizeY<1) throw ValueError(format("You have to provide values, a vector length of %d is not valid. ",sizeY));
|
||||
// std::vector<T> out;
|
||||
// for (std::size_t i = 0; i < sizeX; i++) {
|
||||
// sizeY = in[i].size();
|
||||
// if (sizeY-1<col) throw ValueError(format("Your matrix does not have enough entries in row %d, last index %d is less than %d. ",i,sizeY-1,col));
|
||||
// out.push_back(in[i][col]);
|
||||
// }
|
||||
// return out;
|
||||
//}
|
||||
//template<class T> bool is_squared(std::vector<std::vector<T> > const& in){
|
||||
// std::size_t cols = max_cols(in);
|
||||
// if (cols!=num_rows(in)) { return false;}
|
||||
// else {
|
||||
// for (std::size_t i = 0; i < in.size(); i++) {
|
||||
// if (cols!=in[i].size()) {return false; }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
//template<class T> std::vector<std::vector<T> > make_squared(std::vector<std::vector<T> > const& in){
|
||||
// std::size_t cols = max_cols(in);
|
||||
// std::size_t rows = num_rows(in);
|
||||
// std::size_t maxVal = 0;
|
||||
// std::vector<std::vector<T> > out;
|
||||
// std::vector<T> tmp;
|
||||
//
|
||||
////Eigen::Matrix2d mat2 = CoolProp::convert(vec2);
|
||||
// if (cols>rows) {maxVal = cols; }
|
||||
// else {maxVal = rows; }
|
||||
// out.clear();
|
||||
// for (std::size_t i = 0; i < in.size(); i++) {
|
||||
// tmp.clear();
|
||||
// for (std::size_t j = 0; j < in[i].size(); j++) {
|
||||
// tmp.push_back(in[i][j]);
|
||||
// }
|
||||
// while (maxVal>tmp.size()) {
|
||||
// tmp.push_back(0.0);
|
||||
// }
|
||||
// out.push_back(tmp);
|
||||
// }
|
||||
// // Check rows
|
||||
// tmp.clear();
|
||||
// tmp.resize(maxVal,0.0);
|
||||
// while (maxVal>out.size()) {
|
||||
// out.push_back(tmp);
|
||||
// }
|
||||
// return out;
|
||||
//}
|
||||
//
|
||||
////Eigen::MatrixXd mat2(10,10);
|
||||
////CoolProp::convert(vec2, mat2);
|
||||
//
|
||||
////std::cout << CoolProp::vec_to_string(CoolProp::convert(mat2)) << std::endl;
|
||||
//template<class T> T multiply( std::vector<T> const& a, std::vector<T> const& b){
|
||||
// return dot_product(a,b);
|
||||
//
|
||||
//}
|
||||
//template<class T> std::vector<T> multiply(std::vector<std::vector<T> > const& A, std::vector<T> const& b){
|
||||
// std::vector<std::vector<T> > B;
|
||||
// for (size_t i = 0; i < b.size(); i++){
|
||||
// B.push_back(std::vector<T>(1,b[i]));
|
||||
// }
|
||||
// B = multiply(A, B);
|
||||
// B[0].resize(B.size(),0.0);
|
||||
// for (size_t i = 1; i < B.size(); i++){
|
||||
// B[0][i] = B[i][0];
|
||||
// }
|
||||
// return B[0];
|
||||
//}
|
||||
//
|
||||
//template<class T> std::vector<std::vector<T> > multiply(std::vector<std::vector<T> > const& A, std::vector<std::vector<T> > const& B){
|
||||
// if (num_cols(A) != num_rows(B)){
|
||||
// throw ValueError(format("You have to provide matrices with the same columns and rows: %d is not equal to %d. ",num_cols(A),num_rows(B)));
|
||||
// }
|
||||
// size_t rows = num_rows(A);
|
||||
// size_t cols = num_cols(B);
|
||||
// T tmp;
|
||||
// std::vector<std::vector<T> > outVec;
|
||||
// std::vector<T> tmpVec;
|
||||
// outVec.clear();
|
||||
// for (size_t i = 0; i < rows; i++){
|
||||
// tmpVec.clear();
|
||||
// for (size_t j = 0; j < cols; j++){
|
||||
// tmp = 0.0;
|
||||
// for (size_t k = 0; k < num_cols(A); k++){
|
||||
// tmp += A[i][k] * B[k][j];
|
||||
// }
|
||||
// tmpVec.push_back(tmp);
|
||||
// }
|
||||
// outVec.push_back(tmpVec);
|
||||
// }
|
||||
// return outVec;
|
||||
//}
|
||||
//
|
||||
//template<class T> T dot_product(std::vector<T> const& a, std::vector<T> const& b){
|
||||
// if (a.size()==b.size()){
|
||||
// return std::inner_product(a.begin(), a.end(), b.begin(), 0.0);
|
||||
// }
|
||||
// throw ValueError(format("You have to provide vectors with the same length: %d is not equal to %d. ",a.size(),b.size()));
|
||||
//}
|
||||
//
|
||||
//template<class T> std::vector<T> cross_product(std::vector<T> const& a, std::vector<T> const& b){
|
||||
// throw NotImplementedError("The cross product function has not been implemented, yet");
|
||||
//}
|
||||
//
|
||||
//template<class T> std::vector< std::vector<T> > transpose(std::vector<std::vector<T> > const& in){
|
||||
// size_t sizeX = in.size();
|
||||
// if (sizeX<1) throw ValueError(format("You have to provide values, a vector length of %d is not a valid. ",sizeX));
|
||||
// size_t sizeY = in[0].size();
|
||||
// size_t sizeYOld = sizeY;
|
||||
// if (sizeY<1) throw ValueError(format("You have to provide values, a vector length of %d is not a valid. ",sizeY));
|
||||
// std::vector< std::vector<T> > out(sizeY,std::vector<T>(sizeX));
|
||||
// for (size_t i = 0; i < sizeX; ++i){
|
||||
// sizeY = in[i].size();
|
||||
// if (sizeY!=sizeYOld) throw ValueError(format("You have to provide a rectangular matrix: %d is not equal to %d. ",sizeY,sizeYOld));
|
||||
// for (size_t j = 0; j < sizeY; ++j){
|
||||
// out[j][i] = in[i][j];
|
||||
// }
|
||||
// }
|
||||
// return out;
|
||||
//}
|
||||
//
|
||||
//template<class T> std::vector< std::vector<T> > invert(std::vector<std::vector<T> > const& in){
|
||||
// if (!is_squared(in)) throw ValueError(format("Only square matrices can be inverted: %d is not equal to %d. ",num_rows(in),num_cols(in)));
|
||||
// std::vector<std::vector<T> > identity;
|
||||
// // Build the identity matrix
|
||||
// size_t dim = num_rows(in);
|
||||
// identity.resize(dim, std::vector<T>(dim, 0));
|
||||
// for (size_t row = 0; row < dim; row++){
|
||||
// identity[row][row] = 1.0;
|
||||
// }
|
||||
// return linsolve(in,identity);
|
||||
//}
|
||||
//
|
||||
//template<class T> std::string vec_to_string( T const& a){
|
||||
// std::stringstream out;
|
||||
// out << format("[ %7.3f ]",a);
|
||||
// return out.str();
|
||||
//}
|
||||
//
|
||||
//template<class T> std::string vec_to_string( std::vector<T> const& a) {
|
||||
// return vec_to_string(a,"%7.3g");
|
||||
//}
|
||||
//template<class T> std::string vec_to_string( std::vector<T> const& a, const char *fmt) {
|
||||
// if (a.size()<1) {
|
||||
// return std::string("");
|
||||
// } else {
|
||||
// std::stringstream out;
|
||||
// out << format("[ ");
|
||||
// out << format(fmt,a[0]);
|
||||
// for (size_t j = 1; j < a.size(); j++) {
|
||||
// out << ", ";
|
||||
// out << format(fmt,a[j]);
|
||||
// }
|
||||
// out << " ]";
|
||||
// return out.str();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//template<class T> std::string vec_to_string(std::vector<std::vector<T> > const& A) {
|
||||
// return vec_to_string(A, "%7.3g");
|
||||
//}
|
||||
//
|
||||
//template<class T> std::string vec_to_string(std::vector<std::vector<T> > const& A, const char *fmt) {
|
||||
// std::stringstream out;
|
||||
// for (size_t j = 0; j < A.size(); j++) {
|
||||
// out << vec_to_string(A[j], fmt);
|
||||
// }
|
||||
// return out.str();
|
||||
//}
|
||||
|
||||
|
||||
}; /* namespace CoolProp */
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#ifdef ENABLE_CATCH
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
|
||||
#endif /* ENABLE_CATCH */
|
||||
@@ -1,13 +1,5 @@
|
||||
@echo off
|
||||
REM Some Windows commands to compile the Fortran interface for F77
|
||||
setlocal
|
||||
set comPath=C:\MinGW32-xy\bin
|
||||
set FC=%comPath%\gfortran
|
||||
set CC=%comPath%\gcc
|
||||
REM set comPath=C:\MinGW32\bin
|
||||
REM set FC=%comPath%\g77
|
||||
REM set CC=%comPath%\gcc
|
||||
%FC% -g -c examplef.for
|
||||
%CC% -g -c coolpropIF.c
|
||||
%FC% -g -o example examplef.o coolpropIF.o -L../SharedLibrary -lCoolProp
|
||||
endlocal
|
||||
copy C:\Users\Belli\Documents\Code\coolprop-v5-new\build\32bitcdecl\Debug\Coolprop.dll .
|
||||
C:\MinGW\bin\gfortran -g -o example examplef.for -L. -lCoolProp
|
||||
example
|
||||
@@ -1,98 +0,0 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef int bool;
|
||||
#define false 0
|
||||
#define true 1
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__)
|
||||
# define CONVENTION __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#ifndef CONVENTION
|
||||
# define CONVENTION
|
||||
#endif
|
||||
|
||||
double CONVENTION Props1 (char * FluidName, char * Output);
|
||||
double CONVENTION Props (char * Output,char Name1, double Prop1, char Name2, double Prop2, char * FluidName);
|
||||
double CONVENTION PropsSI(char * Output,char Name1, double Prop1, char Name2, double Prop2, char * FluidName);
|
||||
double CONVENTION DerivTerms(char * Term, double T, double rho, char * FluidName);
|
||||
int CONVENTION set_reference_stateS(char * FluidName, char * reference_state);
|
||||
bool CONVENTION enable_TTSE_LUT(char *FluidName);
|
||||
bool CONVENTION isenabled_TTSE_LUT(char *FluidName);
|
||||
bool CONVENTION disable_TTSE_LUT(char *FluidName);
|
||||
int CONVENTION set_TTSE_mode(char *FluidName, char * Value);
|
||||
|
||||
|
||||
void CONVENTION propsmod_(char *Output, char *Name1, double *Prop1, char *Name2, double *Prop2, char *FluidName, double *resu)
|
||||
{
|
||||
/* return Props(std::string(Output), Name1, Prop1, Name2, Prop2, std::string(FluidName)); */
|
||||
*resu = Props(Output, *Name1, *Prop1, *Name2, *Prop2, FluidName);
|
||||
}
|
||||
|
||||
/* Create pointer-only functions for Fortran avoiding underscores for f77 */
|
||||
double CONVENTION props1_(char *FluidName, char *Output)
|
||||
{
|
||||
/* return Props1(std::string(FluidName), std::string(Output)); */
|
||||
return Props1(FluidName, Output);
|
||||
}
|
||||
|
||||
double CONVENTION props_(char *Output, char *Name1, double *Prop1, char *Name2, double *Prop2, char *FluidName)
|
||||
{
|
||||
/* return Props(std::string(Output), Name1, Prop1, Name2, Prop2, std::string(FluidName)); */
|
||||
return Props(Output, *Name1, *Prop1, *Name2, *Prop2, FluidName);
|
||||
}
|
||||
|
||||
double CONVENTION propssi_(char *Output, char *Name1, double *Prop1, char *Name2, double *Prop2, char *FluidName)
|
||||
{
|
||||
/* return Props(std::string(Output), Name1, Prop1, Name2, Prop2, std::string(FluidName)); */
|
||||
return PropsSI(Output, *Name1, *Prop1, *Name2, *Prop2, FluidName);
|
||||
}
|
||||
|
||||
double CONVENTION derivterms_(char *Term, double *T, double *rho, char *FluidName)
|
||||
{
|
||||
/* return DerivTerms(std::string(Term), T, rho, std::string(FluidName)); */
|
||||
return DerivTerms(Term, *T, *rho, FluidName);
|
||||
}
|
||||
|
||||
int CONVENTION setreferencestates_(char *FluidName, char *reference_state)
|
||||
{
|
||||
/* return set_reference_stateS(std::string(FluidName), std::string(reference_state)); */
|
||||
return set_reference_stateS(FluidName, reference_state);
|
||||
}
|
||||
/* int set_reference_stateS(std::string FluidName, std::string reference_state); */
|
||||
|
||||
/* Enable the TTSE */
|
||||
int CONVENTION enablettselut_(char *FluidName)
|
||||
{
|
||||
if (enable_TTSE_LUT(FluidName)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
/* bool CONVENTION enable_TTSE_LUT(char *FluidName); */
|
||||
|
||||
/* Check if TTSE is enabled */
|
||||
int CONVENTION isenabledttselut_(char *FluidName)
|
||||
{
|
||||
if (isenabled_TTSE_LUT(FluidName)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
/* bool CONVENTION isenabled_TTSE_LUT(char *FluidName); */
|
||||
|
||||
/* Disable the TTSE */
|
||||
int CONVENTION disablettselut_(char *FluidName)
|
||||
{
|
||||
if (disable_TTSE_LUT(FluidName)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
/* bool CONVENTION disable_TTSE_LUT(char *FluidName); */
|
||||
|
||||
/* Set the TTSE mode (normal or bicubic) */
|
||||
int CONVENTION setttsemode_(char *FluidName, char *Value)
|
||||
{
|
||||
return set_TTSE_mode(FluidName, Value);
|
||||
}
|
||||
/* int CONVENTION set_TTSE_mode(char *FluidName, char * Value); */
|
||||
|
||||
|
||||
|
||||
42
wrappers/Fortran/detailed_example/README.md
Normal file
42
wrappers/Fortran/detailed_example/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
FORTRAN example with module
|
||||
===========================
|
||||
|
||||
To build static library
|
||||
-----------------------
|
||||
|
||||
Start in root folder of repo
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir gccstatic
|
||||
cd gccstatic
|
||||
cmake ../.. -G "MinGW Makefiles" -DCOOLPROP_STATIC_LIBRARY=ON
|
||||
cmake --build .
|
||||
|
||||
This will generate the file libCoolProp.a which is a GCC static library that can be linked with GCC/GFORTRAN code
|
||||
|
||||
Make sure that the macro COOLPROP_LIB is defined and that the macro CONVENTION=__cdecl is set.
|
||||
|
||||
Copy this .a file into the directory with the coolprop FORTRAN example
|
||||
|
||||
To build FORTRAN example
|
||||
------------------------
|
||||
|
||||
gfortran -c -Wall cool_fortran_bind.f90
|
||||
gfortran -Wall cool_fortran_bind.f90 libCoolProp.a -o main -lstdc++
|
||||
main
|
||||
|
||||
Note!! You MUST put the static library after the cool_fortran_bind.f90 Same thing if you compile the fortran to object file, static library must always be at the end.
|
||||
|
||||
Compiling on Windows
|
||||
--------------------
|
||||
|
||||
At the moment, the most reliable mixed compilation seems to be using the mingw-provided gfortran/gcc combination from mingw-get. Theese are the versions used as of June 20, 2014::
|
||||
|
||||
>gfortran --version
|
||||
GNU Fortran (GCC) 4.8.1
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
>gcc --version
|
||||
gcc (GCC) 4.8.1
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
31
wrappers/Fortran/detailed_example/cool_fortran_bind.f90
Normal file
31
wrappers/Fortran/detailed_example/cool_fortran_bind.f90
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
program hello
|
||||
|
||||
Use cpinterface
|
||||
|
||||
implicit none
|
||||
|
||||
!Initialize the variables used in the example
|
||||
double precision T, Q
|
||||
character(LEN=32) fluid, out1, n1, n2
|
||||
double precision dens1, dens2
|
||||
|
||||
!----------------------
|
||||
!Example calculates density of saturated liquid propane at 300 K:
|
||||
!---------------------
|
||||
|
||||
T = 300 ! Temperature [K]
|
||||
Q = 0 ! Quality [-]
|
||||
|
||||
out1 = "D"//CHAR(0) ! String with of the output Property
|
||||
n1 = "T"//CHAR(0) ! String with of the input Property #1
|
||||
n2 = "Q"//CHAR(0) ! String with of the input Property #2
|
||||
fluid = "Propane"//CHAR(0) ! String with the fluid name
|
||||
|
||||
dens1 = PropsSI(out1, n1, T, n2, Q, fluid) !calling props, strings are Variables
|
||||
|
||||
dens2 = PropsSI("D"//CHAR(0), "T"//CHAR(0), T, "Q"//CHAR(0), Q, fluid) !calling props defining the strings directlly in the arguments
|
||||
|
||||
Print *, dens1, dens2
|
||||
|
||||
end program hello
|
||||
308
wrappers/Fortran/detailed_example/cpinterface.mod
Normal file
308
wrappers/Fortran/detailed_example/cpinterface.mod
Normal file
@@ -0,0 +1,308 @@
|
||||
GFORTRAN module version '10' created from cool_fortran_bind.f90
|
||||
MD5:873c9ba6821e41613acc9f5722d930de -- If you edit this, you'll get what you deserve.
|
||||
|
||||
(() () () () () () () () () () () () () () () () () () () () () () () ()
|
||||
() () ())
|
||||
|
||||
()
|
||||
|
||||
(('c_funptr' '__iso_c_binding' 2) ('c_ptr' '__iso_c_binding' 3))
|
||||
|
||||
()
|
||||
|
||||
()
|
||||
|
||||
()
|
||||
|
||||
(2 'C_funptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP IS_ISO_C) (
|
||||
DERIVED 2 0 1 1 UNKNOWN ()) 0 0 () () 0 ((4 '__c_funptr_c_address' (
|
||||
INTEGER 4 0 1 0 INTEGER ()) () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC
|
||||
UNKNOWN UNKNOWN 0 0) UNKNOWN-ACCESS ())) UNKNOWN-ACCESS () () 2 44 0)
|
||||
3 'C_ptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT UNKNOWN-PROC
|
||||
UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP IS_ISO_C) (DERIVED 3 0 1 1
|
||||
UNKNOWN ()) 0 0 () () 0 ((5 '__c_ptr_c_address' (INTEGER 4 0 1 0 INTEGER
|
||||
()) () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0)
|
||||
UNKNOWN-ACCESS ())) UNKNOWN-ACCESS () () 2 42 0)
|
||||
6 '__iso_c_binding' '__iso_c_binding' '' 1 ((MODULE UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 INTRINSIC) (UNKNOWN 0 0 0 0 UNKNOWN ())
|
||||
0 0 () () 0 () () () 2 0)
|
||||
7 'c_alert' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000007') () 0 () () ()
|
||||
2 35)
|
||||
8 'c_associated' '__iso_c_binding' '__iso_c_binding_c_associated' 1 ((
|
||||
PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL UNKNOWN 0 0 FUNCTION
|
||||
ALWAYS_EXPLICIT IS_ISO_C) (LOGICAL 4 0 0 0 LOGICAL ()) 9 0 (10 11) () 8
|
||||
() () () 2 47)
|
||||
12 'c_backspace' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000008') () 0 () () ()
|
||||
2 36)
|
||||
13 'c_bool' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
LOGICAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1') () 0 ()
|
||||
() () 2 32)
|
||||
14 'c_carriage_return' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000d') () 0 () () ()
|
||||
2 39)
|
||||
15 'c_char' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
CHARACTER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1') () 0
|
||||
() () () 2 33)
|
||||
16 'c_double' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 () ()
|
||||
() 2 25)
|
||||
17 'c_double_complex' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 ()
|
||||
() () 2 29)
|
||||
18 'c_f_pointer' '__iso_c_binding' '__iso_c_binding_c_f_pointer' 1 ((
|
||||
PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL UNKNOWN 0 0 SUBROUTINE
|
||||
ALWAYS_EXPLICIT IS_ISO_C) (UNKNOWN 0 0 0 0 UNKNOWN ()) 19 0 (20 21 22) ()
|
||||
0 () () () 2 46)
|
||||
23 'c_f_procpointer' '__iso_c_binding' '__iso_c_binding_c_f_procpointer'
|
||||
1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL UNKNOWN 0 0 SUBROUTINE
|
||||
IS_ISO_C) (UNKNOWN 0 0 0 0 UNKNOWN ()) 24 0 (25 26) () 0 () () () 2 50)
|
||||
27 'c_float' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 () ()
|
||||
() 2 24)
|
||||
28 'c_float128' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '16') () 0 () ()
|
||||
() 2 27)
|
||||
29 'c_float128_complex' '__iso_c_binding' '' 1 ((PARAMETER
|
||||
UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (
|
||||
INTEGER 4 0 1 1 COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ())
|
||||
0 '16') () 0 () () () 2 31)
|
||||
30 'c_float_complex' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 28)
|
||||
31 'c_form_feed' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000c') () 0 () () ()
|
||||
2 37)
|
||||
32 'c_funloc' '__iso_c_binding' '__iso_c_binding_c_funloc' 1 ((
|
||||
PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 EXTERNAL
|
||||
FUNCTION PURE IS_ISO_C) (DERIVED 2 0 0 0 DERIVED ()) 0 0 () () 32 () ()
|
||||
() 2 49)
|
||||
33 'c_funptr' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 FUNCTION GENERIC) (REAL 4 0 0 0 REAL ())
|
||||
0 0 () () 0 () () () 2 44)
|
||||
34 'c_horizontal_tab' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000009') () 0 () () ()
|
||||
2 40)
|
||||
35 'c_int' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 0)
|
||||
36 'c_int128_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '-2') () 0 ()
|
||||
() () 2 13)
|
||||
37 'c_int16_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '2') () 0 ()
|
||||
() () 2 10)
|
||||
38 'c_int32_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 11)
|
||||
39 'c_int64_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 ()
|
||||
() () 2 12)
|
||||
40 'c_int8_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1') () 0 ()
|
||||
() () 2 9)
|
||||
41 'c_int_fast128_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '-2') () 0 ()
|
||||
() () 2 23)
|
||||
42 'c_int_fast16_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '2') () 0 ()
|
||||
() () 2 20)
|
||||
43 'c_int_fast32_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 21)
|
||||
44 'c_int_fast64_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 ()
|
||||
() () 2 22)
|
||||
45 'c_int_fast8_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1') () 0 ()
|
||||
() () 2 19)
|
||||
46 'c_int_least128_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '-2') () 0 ()
|
||||
() () 2 18)
|
||||
47 'c_int_least16_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '2') () 0 ()
|
||||
() () 2 15)
|
||||
48 'c_int_least32_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 16)
|
||||
49 'c_int_least64_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 ()
|
||||
() () 2 17)
|
||||
50 'c_int_least8_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1') () 0 ()
|
||||
() () 2 14)
|
||||
51 'c_intmax_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 ()
|
||||
() () 2 4)
|
||||
52 'c_intptr_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 5)
|
||||
53 'c_loc' '__iso_c_binding' '__iso_c_binding_c_loc' 1 ((PROCEDURE
|
||||
UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 EXTERNAL FUNCTION PURE
|
||||
IS_ISO_C) (DERIVED 3 0 0 0 DERIVED ()) 0 0 () () 53 () () () 2 48)
|
||||
54 'c_long' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 2)
|
||||
55 'c_long_double' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '10') () 0 () ()
|
||||
() 2 26)
|
||||
56 'c_long_double_complex' '__iso_c_binding' '' 1 ((PARAMETER
|
||||
UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (
|
||||
INTEGER 4 0 1 1 COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ())
|
||||
0 '10') () 0 () () () 2 30)
|
||||
57 'c_long_long' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8') () 0 ()
|
||||
() () 2 3)
|
||||
58 'c_new_line' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000a') () 0 () () ()
|
||||
2 38)
|
||||
59 'c_null_char' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000000') () 0 () () ()
|
||||
2 34)
|
||||
60 'c_null_funptr' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP IS_ISO_C) (
|
||||
DERIVED 2 0 1 1 UNKNOWN ()) 0 0 () (STRUCTURE (DERIVED 2 0 0 0 DERIVED ())
|
||||
0 (((NULL (UNKNOWN 0 0 0 1 UNKNOWN ()) 0) ())) ()) () 0 () () () 2 45)
|
||||
61 'c_null_ptr' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP IS_ISO_C) (
|
||||
DERIVED 3 0 1 1 UNKNOWN ()) 0 0 () (STRUCTURE (DERIVED 3 0 0 0 DERIVED ())
|
||||
0 (((NULL (UNKNOWN 0 0 0 1 UNKNOWN ()) 0) ())) ()) () 0 () () () 2 43)
|
||||
62 'c_ptr' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 FUNCTION GENERIC) (REAL 4 0 0 0 REAL ())
|
||||
0 0 () () 0 () () () 2 42)
|
||||
63 'c_ptrdiff_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 6)
|
||||
64 'c_short' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '2') () 0 ()
|
||||
() () 2 1)
|
||||
65 'c_signed_char' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1') () 0 ()
|
||||
() () 2 8)
|
||||
66 'c_size_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (INTEGER 4 0 1 1
|
||||
INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4') () 0 ()
|
||||
() () 2 7)
|
||||
67 'c_sizeof' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
|
||||
UNKNOWN-PROC DECL UNKNOWN 0 0 INTRINSIC FUNCTION) (INTEGER 4 0 0 0
|
||||
INTEGER ()) 68 0 (69) () 0 () () () 2 48)
|
||||
70 'c_vertical_tab' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
|
||||
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) (CHARACTER 1 0 1
|
||||
1 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1'))) 0 0 () (
|
||||
CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000b') () 0 () () ()
|
||||
2 41)
|
||||
71 'cpinterface' 'cpinterface' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC
|
||||
UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0
|
||||
0)
|
||||
72 'propssi' 'cpinterface' 'PropsSI' 1 ((PROCEDURE UNKNOWN-INTENT
|
||||
MODULE-PROC BODY UNKNOWN 0 0 EXTERNAL FUNCTION IS_BIND_C IS_C_INTEROP) (
|
||||
REAL 8 0 1 0 REAL ()) 73 0 (74 75 76 77 78 79) () 72 () () () 0 0)
|
||||
10 'C_ptr_1' '__iso_c_binding' '' 9 ((DERIVED IN UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 VALUE DUMMY) (DERIVED 3 0 0 0 DERIVED ()) 0 0 () () 0 () ()
|
||||
() 0 0 0)
|
||||
11 'C_ptr_2' '__iso_c_binding' '' 9 ((DERIVED IN UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 OPTIONAL VALUE DUMMY) (DERIVED 3 0 0 0 DERIVED ()) 0 0 () ()
|
||||
0 () () () 0 0 0)
|
||||
20 'Cptr' '__iso_c_binding' '' 19 ((DERIVED IN UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 VALUE DUMMY) (DERIVED 3 0 0 0 DERIVED ()) 0 0 () () 0 () ()
|
||||
() 0 0 0)
|
||||
21 'fptr' '__iso_c_binding' '' 19 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC
|
||||
UNKNOWN UNKNOWN 0 0 POINTER DUMMY) (VOID 0 0 0 0 VOID ()) 0 0 () () 0 ()
|
||||
() () 0 0)
|
||||
22 'shape' '__iso_c_binding' '' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 DIMENSION OPTIONAL DUMMY) (VOID 4 0 0 0 VOID ()) 0 0 () (1 0
|
||||
ASSUMED_SHAPE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1') ()) 0 () ()
|
||||
() 0 0)
|
||||
25 'Cptr' '__iso_c_binding' '' 24 ((DERIVED IN UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 VALUE DUMMY) (DERIVED 2 0 0 0 DERIVED ()) 0 0 () () 0 () ()
|
||||
() 0 0 0)
|
||||
26 'fptr' '__iso_c_binding' '' 24 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC
|
||||
UNKNOWN UNKNOWN 0 0 DUMMY PROC_POINTER) (VOID 0 0 0 0 VOID ()) 0 0 () ()
|
||||
0 () () () 0 0)
|
||||
69 'x' '' '' 68 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
|
||||
UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
|
||||
74 'output' '' '' 73 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 DIMENSION DUMMY) (CHARACTER 1 0 1 0 CHARACTER ((CONSTANT (
|
||||
INTEGER 4 0 1 1 CHARACTER ()) 0 '1'))) 0 0 () (1 0 ASSUMED_SIZE (
|
||||
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
|
||||
75 'name1' '' '' 73 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 DIMENSION DUMMY) (CHARACTER 1 0 1 0 CHARACTER ((CONSTANT (
|
||||
INTEGER 4 0 1 1 CHARACTER ()) 0 '1'))) 0 0 () (1 0 ASSUMED_SIZE (
|
||||
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
|
||||
76 'prop1' '' '' 73 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 VALUE DUMMY) (REAL 8 0 1 0 REAL ()) 0 0 () () 0 () () () 0 0)
|
||||
77 'name2' '' '' 73 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 DIMENSION DUMMY) (CHARACTER 1 0 1 0 CHARACTER ((CONSTANT (
|
||||
INTEGER 4 0 1 1 CHARACTER ()) 0 '1'))) 0 0 () (1 0 ASSUMED_SIZE (
|
||||
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
|
||||
78 'prop2' '' '' 73 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 VALUE DUMMY) (REAL 8 0 1 0 REAL ()) 0 0 () () 0 () () () 0 0)
|
||||
79 'fluidname' '' '' 73 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN 0 0 DIMENSION DUMMY) (CHARACTER 1 0 1 0 CHARACTER ((CONSTANT (
|
||||
INTEGER 4 0 1 1 CHARACTER ()) 0 '1'))) 0 0 () (1 0 ASSUMED_SIZE (
|
||||
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
|
||||
)
|
||||
|
||||
('C_funptr' 0 2 'C_ptr' 0 3 '__iso_c_binding' 0 6 'c_alert' 0 7
|
||||
'c_associated' 0 8 'c_backspace' 0 12 'c_bool' 0 13 'c_carriage_return'
|
||||
0 14 'c_char' 0 15 'c_double' 0 16 'c_double_complex' 0 17 'c_f_pointer'
|
||||
0 18 'c_f_procpointer' 0 23 'c_float' 0 27 'c_float128' 0 28
|
||||
'c_float128_complex' 0 29 'c_float_complex' 0 30 'c_form_feed' 0 31
|
||||
'c_funloc' 0 32 'c_funptr' 0 33 'c_horizontal_tab' 0 34 'c_int' 0 35
|
||||
'c_int128_t' 0 36 'c_int16_t' 0 37 'c_int32_t' 0 38 'c_int64_t' 0 39
|
||||
'c_int8_t' 0 40 'c_int_fast128_t' 0 41 'c_int_fast16_t' 0 42
|
||||
'c_int_fast32_t' 0 43 'c_int_fast64_t' 0 44 'c_int_fast8_t' 0 45
|
||||
'c_int_least128_t' 0 46 'c_int_least16_t' 0 47 'c_int_least32_t' 0 48
|
||||
'c_int_least64_t' 0 49 'c_int_least8_t' 0 50 'c_intmax_t' 0 51
|
||||
'c_intptr_t' 0 52 'c_loc' 0 53 'c_long' 0 54 'c_long_double' 0 55
|
||||
'c_long_double_complex' 0 56 'c_long_long' 0 57 'c_new_line' 0 58
|
||||
'c_null_char' 0 59 'c_null_funptr' 0 60 'c_null_ptr' 0 61 'c_ptr' 0 62
|
||||
'c_ptrdiff_t' 0 63 'c_short' 0 64 'c_signed_char' 0 65 'c_size_t' 0 66
|
||||
'c_sizeof' 0 67 'c_vertical_tab' 0 70 'cpinterface' 0 71 'propssi' 0 72)
|
||||
@@ -1,8 +1,7 @@
|
||||
! Example fortran file
|
||||
!
|
||||
double precision T,Q,D,h,s
|
||||
character(LEN=32) Ref
|
||||
character(LEN=2) Output, Name1, Name2
|
||||
character(LEN=32) Ref,Output, Name1, Name2
|
||||
double precision outVal,Prop1,Prop2
|
||||
|
||||
integer inte
|
||||
@@ -17,6 +16,7 @@
|
||||
Name2 = "Q"//CHAR(0)
|
||||
Prop2 = Q
|
||||
Ref = "R134a"//CHAR(0)
|
||||
outval = 9999999
|
||||
|
||||
! Output(LEN(Output):LEN(Output)) = CHAR(0)
|
||||
! Name1(LEN(Name1):LEN(Name1)) = CHAR(0)
|
||||
@@ -24,44 +24,44 @@
|
||||
! Ref(LEN(Ref):LEN(Ref)) = CHAR(0)
|
||||
|
||||
write(*,*) "Saturation pressure for R134a: "
|
||||
outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
call propssi(Output, Name1, Prop1, Name2, Prop2, Ref, outVal)
|
||||
write(*,*) "Result was: ", outVal/1e2, " bar"
|
||||
write(*,*) "-----------------------------------------------"
|
||||
|
||||
Output = "S"//CHAR(0)
|
||||
|
||||
|
||||
|
||||
outVal = props1(Ref , "Tcrit"//CHAR(0))
|
||||
write(*,*) "Tcrit from props1 : ", outVal
|
||||
outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
write(*,*) "S from standard props : ", outVal
|
||||
outVal = 0.0
|
||||
CALL propsmod(Output, Name1, Prop1, Name2, Prop2, Ref, outVal)
|
||||
write(*,*) "S from modified props : ", outVal
|
||||
outVal = derivterms("dpdrho"//CHAR(0), Prop1, D, Ref)
|
||||
write(*,*) "dpdrho from derivterms: ", outVal
|
||||
inte = setreferencestates(Ref, "IIR"//CHAR(0))
|
||||
write(*,*) "reference to IIR : ", inte
|
||||
outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
write(*,*) "S from standard props : ", outVal
|
||||
inte = setreferencestates(Ref, "ASHRAE"//CHAR(0))
|
||||
write(*,*) "reference to ASHRAE : ", inte
|
||||
outVal = props(Output, Name1, Prop1, Name2,Prop2, Ref)
|
||||
write(*,*) "S from standard props : ", outVal
|
||||
inte = enablettselut(Ref)
|
||||
write(*,*) "enabling TTSE : ", inte
|
||||
inte = isenabledttselut(Ref)
|
||||
write(*,*) "state of TTSE : ", inte
|
||||
outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
write(*,*) "S from TTSE props : ", outVal
|
||||
inte = setttsemode(Ref , "bicubic"//CHAR(0))
|
||||
write(*,*) "TTSE mode to bicubic : ", inte
|
||||
outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
write(*,*) "S from bicubic props : ", outVal
|
||||
inte = disablettselut(Ref)
|
||||
write(*,*) "Disabling TTSE : ", inte
|
||||
outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
write(*,*) "S from standard props : ", outVal
|
||||
c
|
||||
c Output = "S"//CHAR(0)
|
||||
c
|
||||
c
|
||||
c
|
||||
c outVal = props1(Ref , "Tcrit"//CHAR(0))
|
||||
c write(*,*) "Tcrit from props1 : ", outVal
|
||||
c outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
c write(*,*) "S from standard props : ", outVal
|
||||
c outVal = 0.0
|
||||
c CALL propsmod(Output, Name1, Prop1, Name2, Prop2, Ref, outVal)
|
||||
c write(*,*) "S from modified props : ", outVal
|
||||
c outVal = derivterms("dpdrho"//CHAR(0), Prop1, D, Ref)
|
||||
c write(*,*) "dpdrho from derivterms: ", outVal
|
||||
c inte = setreferencestates(Ref, "IIR"//CHAR(0))
|
||||
c write(*,*) "reference to IIR : ", inte
|
||||
c outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
c write(*,*) "S from standard props : ", outVal
|
||||
c inte = setreferencestates(Ref, "ASHRAE"//CHAR(0))
|
||||
c write(*,*) "reference to ASHRAE : ", inte
|
||||
c outVal = props(Output, Name1, Prop1, Name2,Prop2, Ref)
|
||||
c write(*,*) "S from standard props : ", outVal
|
||||
c inte = enablettselut(Ref)
|
||||
c write(*,*) "enabling TTSE : ", inte
|
||||
c inte = isenabledttselut(Ref)
|
||||
c write(*,*) "state of TTSE : ", inte
|
||||
c outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
c write(*,*) "S from TTSE props : ", outVal
|
||||
c inte = setttsemode(Ref , "bicubic"//CHAR(0))
|
||||
c write(*,*) "TTSE mode to bicubic : ", inte
|
||||
c outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
c write(*,*) "S from bicubic props : ", outVal
|
||||
c inte = disablettselut(Ref)
|
||||
c write(*,*) "Disabling TTSE : ", inte
|
||||
c outVal = props(Output, Name1, Prop1, Name2, Prop2, Ref)
|
||||
c write(*,*) "S from standard props : ", outVal
|
||||
|
||||
end program
|
||||
|
||||
49
wrappers/Fortran/simple_example/README.md
Normal file
49
wrappers/Fortran/simple_example/README.md
Normal file
@@ -0,0 +1,49 @@
|
||||
Build and Run
|
||||
=============
|
||||
|
||||
To build this very simple example, do something like this::
|
||||
|
||||
gfortran -c fortmyfunc.f90
|
||||
gcc -c -std=c++11 myfunc.cpp
|
||||
gfortran fortmyfunc.o myfunc.o -o main -lstdc++
|
||||
main
|
||||
|
||||
The``-lstdc++`` is required to link in the c++ standard libraries
|
||||
|
||||
Running ``main`` should yield something like::
|
||||
|
||||
1
|
||||
42.000000000000000
|
||||
0.0000000000000000
|
||||
1.0000000000000000
|
||||
2.0000000000000000
|
||||
3.0000000000000000
|
||||
4.0000000000000000
|
||||
5.0000000000000000
|
||||
6.0000000000000000
|
||||
7.0000000000000000
|
||||
8.0000000000000000
|
||||
9.0000000000000000
|
||||
10.000000000000000
|
||||
11.000000000000000
|
||||
12.000000000000000
|
||||
13.000000000000000
|
||||
14.000000000000000
|
||||
15.000000000000000
|
||||
16.000000000000000
|
||||
17.000000000000000
|
||||
18.000000000000000
|
||||
19.000000000000000
|
||||
|
||||
Compiling on Windows
|
||||
====================
|
||||
|
||||
At the moment, the most reliable mixed compilation seems to be using the mingw-provided gfortran/gcc combination from mingw-get. Theese are the versions used as of June 20, 2014::
|
||||
|
||||
>gfortran --version
|
||||
GNU Fortran (GCC) 4.8.1
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
>gcc --version
|
||||
gcc (GCC) 4.8.1
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
18
wrappers/Fortran/simple_example/fortmyfunc.f90
Normal file
18
wrappers/Fortran/simple_example/fortmyfunc.f90
Normal file
@@ -0,0 +1,18 @@
|
||||
subroutine myfunc(a, b, c) bind(C, NAME="myfunc")!
|
||||
!
|
||||
use iso_c_binding!
|
||||
!
|
||||
integer(c_int), value :: a!
|
||||
real(c_double), value :: b!
|
||||
real(c_double), dimension(*) :: c!
|
||||
!
|
||||
integer :: i!
|
||||
!
|
||||
print *, a!
|
||||
print *, b!
|
||||
!
|
||||
do i=1,20!
|
||||
print*, c(i)!
|
||||
end do!
|
||||
!
|
||||
end subroutine myfunc
|
||||
11
wrappers/Fortran/simple_example/myfunc.cpp
Normal file
11
wrappers/Fortran/simple_example/myfunc.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
extern "C" void myfunc(int a, double b, double c[]);
|
||||
|
||||
int main()
|
||||
{
|
||||
double c[20];
|
||||
|
||||
for (int i=0; i<20; i++)
|
||||
c[i] = double(i);
|
||||
|
||||
myfunc(1, 42.0, c);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
# Name of the final output library (written to OUTFILE.out)
|
||||
OUTFILE = plus_one
|
||||
|
||||
# hostname or IP address of the target, if automatically transferring binary via FTP.
|
||||
# To automatically transfer via FTP, uncomment the FTP section below.
|
||||
TARGET = 0.0.0.0
|
||||
|
||||
# directory to write the output library on the target, if automatically transferring via FTP.
|
||||
TARGET_DIR = /ni-rt/system
|
||||
|
||||
# These variables control the compiler and linker flags. Change them as
|
||||
# appropriate.
|
||||
|
||||
DEBUG_MODE = 0
|
||||
|
||||
ADDED_CFLAGS =
|
||||
|
||||
ifeq ($(DEBUG_MODE),1)
|
||||
OBJ_DIR := PPC603gnu_DEBUG
|
||||
CFLAGS = -g -mlongcall
|
||||
else
|
||||
OBJ_DIR := PPC603gnu
|
||||
CFLAGS = -Os -fstrength-reduce -fno-builtin -fno-strict-aliasing -mlongcall
|
||||
endif
|
||||
|
||||
# Expects NAME.c or NAME.cpp, and produces OBJDIR/NAME.o
|
||||
SRCS = $(wildcard *.cpp)
|
||||
OBJS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRCS))
|
||||
|
||||
LINKFLAGS = $(CFLAGS)
|
||||
|
||||
# This is the name of the output shared library.
|
||||
PROJECT_TARGETS := $(OBJ_DIR)/$(OUTFILE).out
|
||||
|
||||
# If you have other VxWorks .a files to reference, list them here.
|
||||
LIBS =
|
||||
LIBPATH =
|
||||
|
||||
CPP = powerpc-wrs-vxworks-g++
|
||||
CPU = PPC603
|
||||
TOOL_FAMILY = gnu
|
||||
TOOL = gnu
|
||||
CC_ARCH_SPEC = -mcpu=603 -mstrict-align -mno-implicit-fp
|
||||
|
||||
# This basic rule compiles a .c file into a .o file. It can be adapted to
|
||||
# all other source files that gcc can compile, including assembly (.s) and
|
||||
# C++ (.cpp, .cc, .C, .cxx) files. To enable support for those extensions,
|
||||
# copy this rule and modify its extension and compile flags for the
|
||||
# required source file type.
|
||||
|
||||
# Adapted rule for .cpp files
|
||||
$(OBJ_DIR)/%.o : %.cpp
|
||||
$(CPP) $(CFLAGS) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<"
|
||||
|
||||
all : check_objectdir $(PROJECT_TARGETS)
|
||||
@echo Build of $(OUTFILE).out completed successfully.
|
||||
|
||||
# FTP the output file to the target (uncomment if desired)
|
||||
# @echo
|
||||
# @echo Transferring $(OUTFILE).out to target $(TARGET) via FTP...
|
||||
# @echo user anonymous anonymous > $(OBJ_DIR)/ftpCommands.txt
|
||||
# @echo binary >> $(OBJ_DIR)/ftpCommands.txt
|
||||
# @echo send $(OBJ_DIR)/$(OUTFILE).out $(TARGET_DIR)/$(OUTFILE).out >> $(OBJ_DIR)/ftpCommands.txt
|
||||
# @echo quit >> $(OBJ_DIR)/ftpCommands.txt
|
||||
# @ftp -n -i -s:$(OBJ_DIR)/ftpCommands.txt $(TARGET)
|
||||
|
||||
$(PROJECT_TARGETS) : $(OBJS)
|
||||
$(CPP) -mlongcall -r -nostdlib -Wl,-X -o "$@" $(OBJS) $(LIBPATH) $(LIBS) $(ADDED_LIBPATH) $(ADDED_LIBS)
|
||||
|
||||
check_objectdir :
|
||||
@if [ ! -d "$(OBJ_DIR)" ]; then\
|
||||
mkdir -p $(OBJ_DIR);\
|
||||
fi
|
||||
|
||||
clean :
|
||||
rm -f $(OBJS) $(PROJECT_TARGETS) $(wildcard $(OBJ_DIR)/*.unstripped)
|
||||
|
||||
.DUMMY: check_objectdir clean
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <tr1/memory>
|
||||
|
||||
struct Foo{
|
||||
int a;
|
||||
};
|
||||
|
||||
std::tr1::shared_ptr<Foo> p;
|
||||
|
||||
extern "C" int plus_one(int a)
|
||||
{
|
||||
p.reset(new Foo);
|
||||
return a+1;
|
||||
}
|
||||
Reference in New Issue
Block a user