From 721dc68facdb6a3bb1e6bd43c6dbcf3174df80ec Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Thu, 3 Sep 2015 22:40:38 -0600 Subject: [PATCH] Fix CAS parsing for REFPROP strings --- .../REFPROP/REFPROPMixtureBackend.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp index fa37fbe7..387fd810 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp @@ -341,17 +341,22 @@ std::string REFPROPMixtureBackend::fluid_param_string(const std::string &ParamNa // c hnam--component name [character*12] // c hn80--component name--long form [character*80] // c hcasn--CAS (Chemical Abstracts Service) number [character*12] - long icomp = 1L; - char hnam[13], hn80[81], hcasn[13]; - NAMEdll(&icomp, hnam, hn80, hcasn, 12, 80, 12); - std::string casn = hcasn; - strstrip(casn); - return casn; + std::vector CASvec; + for (long icomp = 1L; icomp <= fluid_names.size(); ++icomp){ + char hnam[13], hn80[81], hcasn[13]; + NAMEdll(&icomp, hnam, hn80, hcasn, 12, 80, 12); + hcasn[12]='\0'; + std::string casn = hcasn; + strstrip(casn); + CASvec.push_back(casn); + } + return strjoin(CASvec, "&"); } else if (ParamName == "name"){ long icomp = 1L; char hnam[13], hn80[81], hcasn[13]; NAMEdll(&icomp, hnam, hn80, hcasn, 12, 80, 12); + hnam[12] = '\0'; std::string name = hnam; strstrip(name); return name; @@ -360,6 +365,7 @@ std::string REFPROPMixtureBackend::fluid_param_string(const std::string &ParamNa long icomp = 1L; char hnam[13], hn80[81], hcasn[13]; NAMEdll(&icomp, hnam, hn80, hcasn, 12, 80, 12); + hn80[80] = '\0'; std::string n80 = hn80; strstrip(n80); return n80; @@ -372,6 +378,7 @@ long REFPROPMixtureBackend::match_CAS(const std::string &CAS){ for (long icomp = 1L; icomp <= static_cast(fluid_names.size()); ++icomp){ char hnam[13], hn80[81], hcasn[13]; NAMEdll(&icomp, hnam, hn80, hcasn, 12, 80, 12); + hcasn[12] = '\0'; std::string casn = hcasn; strstrip(casn); if (casn == CAS){