INCLUDE "ChemPlugin.f90" PROGRAM ExtendTitration Use ChemPluginModule IMPLICIT NONE TYPE(ChemPlugin) :: cp INTEGER :: error REAL(8) :: deltat, pH(1), Xi(1) WRITE(*,fmt=('("ChemPlugin example -- extending a pH titration")')) WRITE(*,fmt=('("")')) cp = ChemPlugin("stdout") ! Configure and initialize the instance error = cp%Config("Ca++ = 1 mmol/kg; Na+ = 1 mmol/kg") error = cp%Config("Cl- = 3 mmol/kg; HCO3- = 2 mmol/kg; pH = 4") error = cp%Config("react 3 mmol/kg NaOH; delxi = 0.1") error = cp%Initialize(1.0d0, "hour") error = cp%Report(Xi, "Xi") error = cp%Report(pH, "pH") WRITE(*,fmt=('(" Xi = ", F4.2, " pH = ", F4.2)')) Xi, pH ! First Time marching loop DO WHILE(.True.) deltat = cp%ReportTimeStep() IF (cp%AdvanceTimeStep(deltat) /= 0) THEN EXIT END IF IF (cp%AdvanceChemical() /= 0) then EXIT END IF error = cp%Report(Xi, "Xi") error = cp%Report(pH, "pH") WRITE(*,fmt=('(" Xi = ", F4.2, " pH = ", F4.2)')) Xi, pH END DO ! Reconfigure and extend run WRITE(*,fmt=('("")')) WRITE(*,*) "Extending run to Xi = 2" error = cp%Config("remove reactant NaOH") error = cp%Config("react 3 mmol/kg HCl") error = cp%ExtendRun(1.0d0, "hour") ! First Time marching loop DO WHILE(.True.) deltat = cp%ReportTimeStep() IF (cp%AdvanceTimeStep(deltat) /= 0) THEN EXIT END IF IF (cp%AdvanceChemical() /= 0) then EXIT END IF error = cp%Report(Xi, "Xi") error = cp%Report(pH, "pH") WRITE(*,fmt=('(" Xi = ", F4.2, " pH = ", F4.2)')) Xi, pH END DO END PROGRAM ExtendTitration