Skip to content

Commit

Permalink
MAINT: Updated formatting to be consistent with Cantera standards.
Browse files Browse the repository at this point in the history
Addressed points raised in the review on pull request. Added calls
to new routines in the sample F90 program and cleaned up a few of
the routine interfaces to remove deprecated/unused info.
  • Loading branch information
Tim Gallagher committed Dec 27, 2021
1 parent 62c49bf commit dc6b7f2
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 120 deletions.
27 changes: 11 additions & 16 deletions include/cantera/base/NoExitLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@
#include <string>
#include "cantera/base/logger.h"

using namespace std;

static std::string ss = "print \"\"\" ";

namespace Cantera {
/// Logger that doesn't exit when an error is thrown.
/// @ingroup textlogs
class NoExitLogger : public Logger {
public:
NoExitLogger() {}
virtual ~NoExitLogger() {}

/// Logger that doesn't exit when an error is thrown.
/// @ingroup textlogs
class NoExitLogger : public Logger {
public:
NoExitLogger() {}
virtual ~NoExitLogger() {}

virtual void error(const std::string& msg)
{
std::cerr << msg << std::endl;
}
};
virtual void error(const std::string& msg)
{
std::cerr << msg << std::endl;
}
};
}
#endif
13 changes: 13 additions & 0 deletions samples/f90/demo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ subroutine demo(gas, MAXSP, MAXRXNS)

double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS)
double precision diff(MAXSP)
double precision molar_cp(MAXSP), molar_h(MAXSP), g_rt(MAXSP)

character*80 eq
character*20 name
Expand Down Expand Up @@ -119,6 +120,18 @@ subroutine demo(gas, MAXSP, MAXRXNS)
40 format(' ',a20,e14.5,' m2/s')
end do

! Thermodynamic properties
CALL getPartialMolarCp(gas, molar_cp)
CALL getPartialMolarEnthalpies(gas, molar_h)
CALL getGibbs_RT(gas, g_rt)

write(*,*) 'Species molar cp, molar enthalpy, normalized Gibbs free energy'
do k = 1, nsp
call getSpeciesName(gas, k, name)
write(*,50) name, molar_cp(k), molar_h(k), g_rt(k)
50 format(' ',a20,g14.5,' J/kmol-K',g14.5,' J/kmol',g14.5,'-')
end do

return

end subroutine demo
4 changes: 0 additions & 4 deletions src/fortran/cantera.f90
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,6 @@ MODULE CANTERA
MODULE PROCEDURE ctthermo_setMassFractionsByName
END INTERFACE setMassFractionsByName

INTERFACE setMassFractions_NoNorm
MODULE PROCEDURE ctthermo_setMassFractions_NoNorm
END INTERFACE setMassFractions_NoNorm

INTERFACE setMoleFractions
MODULE PROCEDURE ctthermo_setMoleFractions
END INTERFACE setMoleFractions
Expand Down
5 changes: 2 additions & 3 deletions src/fortran/cantera_funcs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ subroutine ctfunc_getCanteraError(buf)
ierr = ctgetCanteraError(buf)
end subroutine ctfunc_getCanteraError

subroutine ctfunc_turnOffExitOnError(self)
subroutine ctfunc_turnOffExitOnError()
implicit none
type(phase_t), intent(inout) :: self
self%err = ctturnOffExitOnError(self%thermo_id)
call ctturnOffExitOnError()
end subroutine ctfunc_turnOffExitOnError

subroutine ctfunc_addCanteraDirectory(self, buf)
Expand Down
9 changes: 1 addition & 8 deletions src/fortran/cantera_thermo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,6 @@ subroutine ctthermo_setMassFractionsByName(self, y)
self%err = phase_setmassfractionsbyname(self%thermo_id, y)
end subroutine ctthermo_setmassfractionsbyname

subroutine ctthermo_setMassFractions_NoNorm(self, x)
implicit none
type(phase_t), intent(inout) :: self
double precision, intent(in) :: x(self%nsp)
self%err = phase_setMassFractions(self%thermo_id, x, 0)
end subroutine ctthermo_setMassFractions_NoNorm

subroutine ctthermo_getAtomicWeights(self, atw)
implicit none
type(phase_t), intent(inout) :: self
Expand Down Expand Up @@ -556,7 +549,7 @@ subroutine ctthermo_getGibbs_RT(self, grt)
implicit none
type(phase_t), intent(inout) :: self
double precision, intent(out) :: grt(self%nsp)
self%err = th_getpartialmolarenthalpies(self%thermo_id, grt)
self%err = th_getgibbs_rt(self%thermo_id, grt)
end subroutine ctthermo_getGibbs_RT

subroutine ctthermo_getEntropies_R(self, s_r)
Expand Down
Loading

0 comments on commit dc6b7f2

Please sign in to comment.