22 SUBROUTINE parse_rxn(LINE, lNoOfRxns, lName, lChemEq, lDH, lFDH)
36 CHARACTER(len=*),
INTENT(IN) :: LINE
38 INTEGER,
INTENT(INOUT) :: lNoOfRxns
40 CHARACTER(len=*),
INTENT(INOUT),
DIMENSION(DIMENSION_RXN) :: lName
42 CHARACTER(len=*),
INTENT(INOUT),
DIMENSION(DIMENSION_RXN) :: lChemEq
44 DOUBLE PRECISION,
INTENT(INOUT),
DIMENSION(DIMENSION_RXN) :: lDH
46 DOUBLE PRECISION,
INTENT(INOUT),
DIMENSION(DIMENSION_RXN, 0:DIM_M) 56 CHARACTER,
PARAMETER :: CT_BEG =
'{' 57 CHARACTER,
PARAMETER :: CT_END =
'}' 62 CHARACTER(LEN=128) :: INPUT
67 input = trim(adjustl(line))
71 bidx = index(input,ct_beg)
72 eidx = index(input,ct_end)
80 IF(eidx .GT. bidx)
THEN 85 CALL getname(input,(bidx-1), lname(idx))
87 IF(
isfracdh(input(bidx+1:eidx-1)))
THEN 88 WRITE(*, 1002)
'FracDH', trim(adjustl(input))
91 ELSEIF(
isdh(input(bidx+1:eidx-1)))
THEN 92 WRITE (*, 1002)
'DH', trim(adjustl(input))
95 ELSEIF(.NOT.
ischemeq(input(bidx+1:eidx-1)))
THEN 96 WRITE (*, 1003) trim(adjustl(input))
100 CALL getchemeq(input(bidx+1:eidx-1), lchemeq(idx))
103 WRITE(*, 1001) trim(adjustl(line))
113 CALL getname(input,(bidx-1), lname(idx))
115 IF(len_trim(adjustl(input(bidx+1:eidx-1))) .GT. 0) &
117 lchemeq(idx), ldh(idx), lfdh(idx,:))
121 WRITE(*, 1004) trim(adjustl(input))
130 WRITE(*, 1005) trim(adjustl(input))
135 ELSEIF(eidx .GT. 0)
THEN 138 ldh(idx), lfdh(idx,:))
145 ldh(idx), lfdh(idx,:))
151 1001
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
152 ' Error 1001: Mismatch of braces "{...}" in reaction ', &
153 ' construct.',//
' INPUT: ',a)
155 1002
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
156 ' Error 1002: Input format error in reaction construct.', &
157 ' Opening and',/
' closing braces were found on the same line',&
158 ' along with the',/
' keyword ',a,
'.',/
' Single line', &
159 ' constructs can only contain a chemical equation.',// &
161 ' Example 1: RXN_NAME { chem_eq = "A + B --> AB" }',// &
162 ' Example 2: RXN_NAME {',/14x,
'chem_eq = "A + B --> AB"',/14x,&
163 'DH = 2.5d4',/14x,
'fracDH(0) = 1.0',/12x,
'}')
165 1003
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
166 ' Error 1003: Input format error in reaction construct.', &
167 ' Opening and',/
' closing braces were found on the same line',&
168 ' and chem_eq was NOT found.',/
' Single line constructs can', &
169 ' only contain a chemical equation.',//
' INPUT: ',a,// &
170 ' Example 1: RXN_NAME { chem_eq = "A + B --> AB" }',// &
171 ' Example 2: RXN_NAME {',/14x,
'chem_eq = "A + B --> AB"',/14x,&
172 'DH = 2.5d4',/14x,
'fracDH(0) = 1.0',/12x,
'}')
174 1004
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
175 ' Error 1004: Data within the reaction block was identified', &
176 ' outside of a',/
' reaction construct. ',//
' INPUT: ',a)
178 1005
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
179 ' Error 1005: The start of a new reaction construct was', &
180 ' found before the',/
' closing of the previous construct.',// &
183 1000
FORMAT(/
' Please refer to the Readme file on the required input',&
184 ' format and make',/
' the necessary corrections to the data', &
185 ' file.',/1x,70(
'*')//)
207 INTEGER,
INTENT(INOUT) :: lNOR
209 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: STAT
211 IF(.NOT.
PRESENT(stat))
THEN 215 IF(stat ==
'NEW')
THEN 221 WRITE(*,*)
' Unknown status' 248 CHARACTER(len=*),
INTENT(IN) :: IN
250 CHARACTER(len=*),
INTENT(OUT) :: ChemEq
252 DOUBLE PRECISION,
INTENT(OUT) :: uDH
254 DOUBLE PRECISION,
INTENT(OUT) :: uFDH(0:
dim_m)
257 IF(len_trim(adjustl(in)) == 0)
RETURN 266 ELSEIF(
isdh(in))
THEN 271 WRITE(*, 1001) trim(adjustl(in))
278 1001
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> readConstruct',/ &
279 ' Error 1001: Unidentified keyword in reaction construct.'//, &
282 1000
FORMAT(/
' Please refer to the Readme file on the required input',&
283 ' format and make',/
' the necessary corrections to the data', &
284 ' file.',/1x,70(
'*')//)
305 CHARACTER(len=*),
INTENT(IN) :: INPUT
308 IF (index(line(1:),
"CHEM_EQ") == 0)
THEN 331 LOGICAL FUNCTION isdh(INPUT)
334 CHARACTER(len=*),
INTENT(IN) :: INPUT
337 IF (index(line(1:),
"DH") == 0)
THEN 362 CHARACTER(len=*),
INTENT(IN) :: INPUT
365 IF (index(line(1:),
"FRACDH") == 0)
THEN 387 SUBROUTINE getname(INPUT, rPOS, lNAME)
390 CHARACTER(len=*),
INTENT(IN) :: INPUT
392 INTEGER,
INTENT(IN) :: rPOS
394 CHARACTER(LEN=32) ,
INTENT(OUT) :: lNAME
404 name_len = len_trim(adjustl(input(1:rpos)))
405 IF(name_len .GT. 32)
THEN 406 WRITE(*, 1001) trim(adjustl(input))
411 ELSEIF(name_len .EQ. 0)
THEN 412 WRITE(*, 1002) trim(adjustl(input))
416 lname = trim(adjustl(input(1:rpos)))
423 1001
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> get_ChemEq',/ &
424 ' Error 1001: Reaction name too long! Reaaction names are', &
425 ' limited to 32',/
' characters.',//
' Reaction Name: ',a)
427 1002
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> get_ChemEq',/ &
428 ' Error 1002: Unable to determine reaction name.',// &
431 1000
FORMAT(/
' Please refer to the Readme file on the required input',&
432 ' format and make',/
' the necessary corrections to the data', &
433 ' file.',/1x,70(
'*')//)
451 SUBROUTINE getdh(INPUT, lDH)
454 CHARACTER(len=*),
INTENT(IN) :: INPUT
456 DOUBLE PRECISION,
INTENT(OUT) :: lDH
463 llmax = len_trim(input)
465 IF(index(input,
"DH") .EQ. 0)
THEN 466 WRITE (*, 1100) trim(adjustl(input))
471 lq = index(input(:llmax),
'=')
474 WRITE (*, 1001) trim(adjustl(input))
480 READ(input(lq+1:),*,iostat=ios) ldh
482 WRITE(*, 1002) trim(adjustl(input))
488 1001
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getDH',/ &
489 ' Error 1001: Input format error for DH.',//
' INPUT: ',a)
491 1002
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getDH',/ &
492 ' Error 1002: Unable to determine DH value from input.',/ &
493 ' Cannot convert specified value to double precision value.',/&
496 1000
FORMAT(/
' Please refer to the Readme file on the required input',&
497 ' format and make',/
' the necessary corrections to the data', &
498 ' file.',/1x,70(
'*')//)
500 1100
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
501 ' Error 1105: DH was initially located within the input line',&
502 /
' however its location cannot be determined.',&
529 CHARACTER(len=*),
INTENT(IN) :: INPUT
531 DOUBLE PRECISION,
INTENT(OUT) :: lFracDH(0:
dim_m)
534 INTEGER POS, lP, rP, lQ
541 llmax = len_trim(input)
542 pos = index(input,
"FRACDH")
545 WRITE (*, 1100) trim(adjustl(input))
550 lp = index(input(:llmax),
'(')
551 rp = index(input(:llmax),
')')
552 lq = index(input(:llmax),
'=')
554 IF(lp .EQ. rp .AND. lp .EQ.
zero)
THEN 555 WRITE(*, 1001) trim(adjustl(input))
558 ELSEIF(lp .GE. rp)
THEN 559 WRITE(*, 1002) trim(adjustl(input))
562 ELSEIF(rp .GE. lq)
THEN 563 WRITE(*, 1002) trim(adjustl(input))
568 READ(input(lp+1:rp-1),*,iostat=ios) pidx
570 WRITE(*, 1003) trim(adjustl(input))
573 ELSEIF(pidx .LT. 0 .OR. pidx .GT.
dim_m)
THEN 574 WRITE(*, 1004) trim(adjustl(input))
580 READ(input(lq+1:),*,iostat=ios) lfracdh(pidx)
582 WRITE(*, 1005)trim(adjustl(input))
589 1001
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getFracDH',/ &
590 ' Error 1001: Unable to determine phase association for', &
591 ' fracDH. When',/
' specifying heat of reaction (DH), the', &
592 ' fraction of DH assigned to',/
' each phase must be', &
593 ' given explicitly.',//
' Example: fracDH(0) = 0.25 ! 25% of',&
594 ' DH is assigned to gas phase',/
' fracDH(1) = 0.75 ',&
595 ' ! 75% of DH is assigned to solids phase 1',//
' Note:', &
596 ' fracDH(0) + fracDH(1) + ... + frachDH(M) == 1.0',// &
599 1002
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getFracDH',/ &
600 ' Error 1002: Input format error for fracDH.',// &
603 1003
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getFracDH',/ &
604 ' Error 1003: Unable to determine phase index for fracDH.',//&
607 1004
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getFracDH',/ &
608 ' Error 1004: Phase index for fracDH exceeds DIM_M!',// &
611 1005
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getFracDH',/ &
612 ' Error 1005: Unable to determine fracDH value from input.',/ &
613 ' Cannot convert specified value to double precision value.',/&
617 1000
FORMAT(/
' Please refer to the Readme file on the required input',&
618 ' format and make',/
' the necessary corrections to the data', &
619 ' file.',/1x,70(
'*')//)
621 1100
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN',/ &
622 ' Error 1105: fracDH was initially located within the', &
623 ' input line,',/
' however its location cannot be determined.',&
647 CHARACTER(len=*),
INTENT(IN) :: IN
649 CHARACTER(len=*),
INTENT(OUT) :: lChemEq
654 INTEGER POS, lPOS, rPOS, ldP, lsP, aPOS
662 pos = index(in,
"CHEM_EQ")
665 WRITE (*, 1105)
'Chem_Eq' 677 ldp = pos + index(in(pos:),
'"')
678 lsp = pos + index(in(pos:),
"'")
680 IF(ldp .GT. pos .AND. lsp .EQ. pos)
THEN 684 rpos = lpos + index(in(lpos+1:),
'"')
685 ELSEIF(ldp .EQ. pos .AND. lsp .GT. pos)
THEN 689 rpos = lpos + index(in(lpos+1:),
"'")
694 WRITE(*, 1001) trim(adjustl(in))
698 WRITE(*, 1002)
'Keyword fracDH was found inside', &
699 ' the chemical equation!', trim(adjustl(in))
701 ELSEIF(
isdh(in))
THEN 702 WRITE(*, 1002)
'Keyword DH was found inside', &
703 ' the chemical equation!', trim(adjustl(in))
706 WRITE(*, 1002)
'Unbalanced or missing parentheses',
'', &
715 IF(lpos .EQ. rpos)
THEN 719 WRITE(*, 1001) trim(adjustl(in))
722 WRITE(*, 1002)
'Unbalanced or missing parentheses',
'', &
730 apos = lpos + index(in(lpos+1:),
'&')
732 IF(apos .GT. lpos)
THEN 735 IF(apos .LE. rpos)
THEN 736 WRITE(*, 1003) trim(adjustl(in))
745 WRITE(lchemeq,
"(A,1X,A)",iostat=ios) trim(lchemeq), &
746 trim(adjustl(in(lpos:rpos-1)))
748 WRITE(*, 1004) trim(lchemeq), trim(adjustl(in))
755 1001
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getChemEq',/ &
756 ' Error 1001: Unbalanced or missing parentheses for chem_eq.',&
757 //
' INPUT: ',a,//
' Example 1: RXN_NAME { chem_eq = ', &
758 '"A + B --> AB" }',//
' Example 2: RXN_NAME {',/14x, &
759 'chem_eq = "A + B --> AB"',/14x,
'DH = 2.5d4',/14x, &
760 'fracDH(0) = 1.0',/12x,
'}')
762 1002
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getChemEq',/ &
763 ' Error 1002: Chemical equation continuation input error.', &
764 //
' > ',2a//
' INPUT: ',a)
766 1003
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getChemEq',/ &
767 ' Error 1003: Input format error for chem_eq. An amperand', &
768 ' (&)',/
' was located within the parentheses.',//
' INPUT: ',a)
770 1004
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getChemEq',/ &
771 ' Error 1004: Unable to process chemical equation input.',/ &
772 ' A possible error is variable overflow as the total length', &
773 ' is limited',/
' to 512 characters.',//
' lChemEq: ',a,// &
776 1000
FORMAT(/
' Please refer to the Readme file on the required input',&
777 ' format and make',/
' the necessary corrections to the data', &
778 ' file.',/1x,70(
'*')//)
780 1105
FORMAT(//1x,70(
'*')/
' From: PARSE_RXN --> getChemEq',/ &
781 ' Error 1105: chem_eq was initially located within the', &
782 ' input line,',/
' however its location cannot be determined.',&
logical function ischemeq(INPUT)
integer function getreactionindex(lNOR, STAT)
logical function isdh(INPUT)
subroutine getdh(INPUT, lDH)
subroutine getname(INPUT, rPOS, lNAME)
subroutine getfracdh(INPUT, lFracDH)
subroutine readconstruct(IN, ChemEq, uDH, uFDH)
logical function isfracdh(INPUT)
subroutine parse_rxn(LINE, lNoOfRxns, lName, lChemEq, lDH, lFDH)
subroutine getchemeq(IN, lChemEq)
double precision, parameter zero