Skip to content

Commit

Permalink
[fortran] Continue
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Aug 12, 2024
1 parent fd85dae commit 3da80fa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions samples/f90/demo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ program main
! 'h2o2.yaml', located in the Cantera data directory
gas = importPhase('h2o2.yaml','ohmech')

gas2 = newSolution('h2o2.yaml','ohmech')

t = 1200.0 ! K
p = 101325.0 ! Pa

Expand Down
4 changes: 4 additions & 0 deletions src/fortran/cantera.f90
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ MODULE CANTERA
MODULE PROCEDURE ctthermo_gibbs_mole
END INTERFACE gibbs_mole

INTERFACE newSolution
MODULE PROCEDURE ctfunc_newSolution
END INTERFACE newSolution

INTERFACE importPhase
MODULE PROCEDURE ctfunc_importPhase
END INTERFACE importPhase
Expand Down
20 changes: 20 additions & 0 deletions src/fortran/cantera_funcs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ module cantera_funcs

contains

type(phase_t) function ctfunc_newSolution(filename, phn, trn)
implicit none
character*(*), intent(in) :: filename
character*(*), intent(in), optional :: phn
character*(*), intent(in), optional :: trn
type(phase_t) :: self
if (present(trn)) then
self%soln_id = soln_newsolution(filename, phn, trn)
else if (present(phn)) then
self%soln_id = soln_newsolution(filename, phn, 'default')
else
self%soln_id = soln_newsolution(filename, '', 'default')
end if
self%thermo_id = soln_thermo(self%soln_id)
self%kin_id = soln_kinetics(self%soln_id)
self%tran_id = soln_transport(self%soln_id)
self%err = 0
ctfunc_newSolution = self
end function ctfunc_newSolution

type(phase_t) function ctfunc_importPhase(src, id, loglevel)
implicit none
character*(*), intent(in) :: src
Expand Down
2 changes: 2 additions & 0 deletions src/fortran/cantera_thermo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module cantera_thermo
use fct

type phase_t
integer :: soln_id
integer :: thermo_id
integer :: kin_id
integer :: tran_id
Expand Down Expand Up @@ -56,6 +57,7 @@ type(phase_t) function ctthermo_newFromFile(filename, id)
self%err = 0
self%kin_id = -1
self%tran_id = -1
self%soln_id = -1
ctthermo_newFromFile = self
end function ctthermo_newFromFile

Expand Down

0 comments on commit 3da80fa

Please sign in to comment.