From e2767cf72542685d4dfef0af6b0e1604bfa1ade2 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Thu, 5 Aug 2004 17:04:21 +0000 Subject: [PATCH] minor changes to fortran files --- Cantera/fortran/src/cantera_funcs.f90 | 2 - Cantera/fortran/src/fct.cpp | 2 - tools/templates/f90/demo.f90 | 154 +++++++++++++++----------- 3 files changed, 92 insertions(+), 66 deletions(-) diff --git a/Cantera/fortran/src/cantera_funcs.f90 b/Cantera/fortran/src/cantera_funcs.f90 index bfeb11bb2..2d2158c4a 100644 --- a/Cantera/fortran/src/cantera_funcs.f90 +++ b/Cantera/fortran/src/cantera_funcs.f90 @@ -30,10 +30,8 @@ module cantera_funcs str = ctxml_child(s, 'transport') call ctxml_getAttrib(str, 'model', model) if (present(loglevel)) then - write(*,*) 'tr 1' self%tran_id = newTransport(model, self%thermo_id, loglevel) else - write(*,*) 'tr 2' self%tran_id = newTransport(model, self%thermo_id, 0) end if diff --git a/Cantera/fortran/src/fct.cpp b/Cantera/fortran/src/fct.cpp index f864a0e8e..c04d89c93 100644 --- a/Cantera/fortran/src/fct.cpp +++ b/Cantera/fortran/src/fct.cpp @@ -604,8 +604,6 @@ extern "C" { string mstr = f2string(model, lenmodel); thermo_t* t = _fth(ith); try { - cout << int(mstr[5]) << endl; - cout << "mstr = >" << mstr << "< " << endl; Transport* tr = newTransportMgr(mstr, t, *loglevel); return Storage::storage()->addTransport(tr); } diff --git a/tools/templates/f90/demo.f90 b/tools/templates/f90/demo.f90 index d2e02f5b7..87db22d70 100644 --- a/tools/templates/f90/demo.f90 +++ b/tools/templates/f90/demo.f90 @@ -4,93 +4,123 @@ ! This program uses functions defined in demo_ftnlib.cpp to create ! an ideal gas mixture and print some its properties. ! -! For a C++ version of this program, see ../cxx/demo.cpp. +! For a C++ version of this program, type 'ctnew -cxx'. ! program main - call demo(100, 500) - -stop -end - -subroutine demo(maxsp, maxrxns) + ! use the Cantera module use cantera - implicit none - integer, intent(in) :: maxsp - integer, intent(in) :: maxrxns + implicit none + ! objects representing phases of matter have type 'phase_t' type(phase_t) gas + integer nsp, nrxns + double precision :: t, p + + write(*,*) + write(*,*) '******** Fortran 90 Test Program ********' + + + ! Read in a definition of the 'gas' phase. + ! This will take the definition with name 'ohmech' from file + ! 'h2o2.cti', located in the Cantera data directory + gas = importPhase('h2o2.cti','ohmech') + + t = 1200.0 ! K + p = 101325.0 ! Pa + + ! set the temperature, pressure, and mole fractions. + call setState_TPX(gas, t, p, 'H2:1, O2:1, AR:2') + + + nsp = nSpecies(gas) ! number of species + nrxns = nReactions(gas) ! number of reactions + + call demo(gas, nsp, nrxns) + + stop + +end program main + + +!-------------------------------------------------------- + +subroutine demo(gas, MAXSP, MAXRXNS) + + ! use the Cantera module + use cantera + + implicit none + + ! declare the arguments + type(phase_t), intent(inout) :: gas + integer, intent(in) :: MAXSP + integer, intent(in) :: MAXRXNS + double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS) double precision diff(MAXSP) + character*80 eq character*20 name double precision :: t, p, dnu, dlam integer :: i, irxns, nsp, k -write(*,*) -write(*,*) '******** Fortran 90 Test Program ********' + write(*,*) 'Initial state properties:' + write(*,10) temperature(gas), pressure(gas), density(gas), & + enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas) -gas = importPhase('h2o2.cti','ohmech') + ! compute the equilibrium state holding the specific + ! enthalpy and pressure constant + call equilibrate(gas, HP) -t = 1200.0 -p = 101325.0 - -call setState_TPX(gas, t, p, 'H2:1, O2:1, AR:2') - -write(*,*) 'Initial state properties:' -write(*,10) temperature(gas), pressure(gas), density(gas), & - enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas) - -! compute the equilibrium state holding the specifi! -! enthalpy and pressure constant -call equilibrate(gas, HP) - -write(*,*) 'Equilibrium state properties:' -write(*,10) temperature(gas), pressure(gas), density(gas), & - enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas) + write(*,*) 'Equilibrium state properties:' + write(*,10) temperature(gas), pressure(gas), density(gas), & + enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas) 10 format(//'Temperature: ',g14.5,' K'/ & - 'Pressure: ',g14.5,' Pa'/ & - 'Density: ',g14.5,' kg/m3'/ & - 'Molar Enthalpy:',g14.5,' J/kmol'/ & - 'Molar Entropy: ',g14.5,' J/kmol-K'/ & - 'Molar cp: ',g14.5,' J/kmol-K'//) + 'Pressure: ',g14.5,' Pa'/ & + 'Density: ',g14.5,' kg/m3'/ & + 'Molar Enthalpy:',g14.5,' J/kmol'/ & + 'Molar Entropy: ',g14.5,' J/kmol-K'/ & + 'Molar cp: ',g14.5,' J/kmol-K'//) -! Reaction information -irxns = nReactions(gas) + ! Reaction information + irxns = nReactions(gas) -! forward and reverse rates of progress should be equal -! in equilibrium states -call getFwdRatesOfProgress(gas, qf) -call getRevRatesOfProgress(gas, qr) + ! forward and reverse rates of progress should be equal + ! in equilibrium states + call getFwdRatesOfProgress(gas, qf) + call getRevRatesOfProgress(gas, qr) -! net rates of progress should be zero in equilibrium states -call getNetRatesOfProgress(gas, q) + ! net rates of progress should be zero in equilibrium states + call getNetRatesOfProgress(gas, q) -! for each reaction, print the equation and the rates of progress -do i = 1,irxns - call getReactionString(gas, i,eq) - write(*,20) eq,qf(i),qr(i),q(i) -20 format(a27,3e14.5,' kmol/m3/s') -end do + ! for each reaction, print the equation and the rates of progress + do i = 1,irxns + call getReactionString(gas, i,eq) + write(*,20) eq,qf(i),qr(i),q(i) +20 format(a27,3e14.5,' kmol/m3/s') + end do -! Transport properties -dnu = viscosity(gas) -dlam = thermalConductivity(gas) -call getMixDiffCoeffs(gas, diff) + ! transport properties + dnu = viscosity(gas) + dlam = thermalConductivity(gas) + call getMixDiffCoeffs(gas, diff) -write(*,30) dnu, dlam + write(*,30) dnu, dlam 30 format(//'Viscosity: ',g14.5,' Pa-s'/ & - 'Thermal conductivity: ',g14.5,' W/m/K'/) + 'Thermal conductivity: ',g14.5,' W/m/K'/) -write(*,*) 'Species Diffusion Coefficient' -nsp = nSpecies(gas) -do k = 1, nsp - call getSpeciesName(gas, k, name) - write(*,40) name, diff(k) -40 format(' ',a20,e14.5,' m2/s') -end do + write(*,*) 'Species Diffusion Coefficient' + nsp = nSpecies(gas) + do k = 1, nsp + call getSpeciesName(gas, k, name) + write(*,40) name, diff(k) +40 format(' ',a20,e14.5,' m2/s') + end do + + return -stop end subroutine demo +