0a1
> C
8,18d8
< !
< ! SIMPLIFIED NOTATION:
< ! nr = numre
< ! ns = numstoi
< ! nf = nself
< ! idr = idrestoi
< ! idp = idpdstoi
< ! idf = idselfreac
< ! cfr = restoicf
< ! cfp = pdstoicf
< ! HAVE NOT YET FIGURED OUT HOW TO ELIMINATE ALL DO-LOOPS !
20c10
<       SUBROUTINE iter3_tracer 
---
>       SUBROUTINE iter3dyn 
22,26c12,17
<      2    numsp, nr, ns, idr, idp, nf,idf,
<      3    cfr,cfp,
<      3    rk, sum, gdt,
<      4    rem, rdep, rex, rdil,
<      5    c, xfr, xfl, trr, trl)
---
>      2    numsp, numre, numstoi, idrestoi, idpdstoi, nself,idselfreac,
>      3    restoicf,pdstoicf,
>      3    RK, SUM, GDT,
>      4    REM, RDEP, REX, RDIL,
>      2  nsat,mxsat,idasat,numaou,maxt,idaou,cnv,
>      5    C, XFR, XFL)
32,38c23,29
<       INTEGER numsp, nr
<       INTEGER ns(maxre,2)
<       INTEGER idr(maxre,mxleft)
<       INTEGER idp(maxre,mxright)
<       INTEGER nf,idf(mself,2)
<       REAL    cfr(maxre,mxleft)
<       REAL    cfp(maxre,mxright)
---
>       INTEGER numsp, numre
>       INTEGER numstoi(maxre,2)
>       INTEGER idrestoi(maxre,mxleft)
>       INTEGER idpdstoi(maxre,mxright)
>       INTEGER nself,idselfreac(mself,2)
>       REAL    restoicf(maxre,mxleft)
>       REAL    pdstoicf(maxre,mxright)
43d33
<       REAL    TRL(maxsp),TRR(maxsp)
45,46c35,43
<       REAL    rem(maxsp),rdep(maxsp)
<       REAL    rex(maxsp),rdil
---
>       REAL    REM(maxsp),RDEP(maxsp)
>       REAL    REX(maxsp),RDIL
> 
>       INTEGER nsat,mxsat
>       INTEGER idasat(mxsat)
>       INTEGER numaou
>       INTEGER maxt
>       INTEGER idaou(maxt)
>       REAL    cnv
51,52c48
< ! new variables (for do-loop elimination)
<       INTEGER    idarr(mxleft)
---
>       REAL    ctotaer
54a51,54
>       DO i=1,numsp
>         xfr(i)=0.
>         xfl(i)=0.
>       ENDDO
56,60c56,58
<       xfr(1:numsp)=0.
<       xfl(1:numsp)=0.
<       
<       trr(1:numsp)=0.
<       trl(1:numsp)=0.
---
>       DO i=1,numsp
>         IF (c(i).lt.1.0E-18) c(i)=1.0E-18
>       ENDDO 
62,64c60,62
<       rate(1:nr)=rk
<       !WHERE (c.lt.1.0E-13) c=1.0E-13
<       WHERE (c.lt.1.0E-30) c=1.0E-30
---
>       DO i=1,numre
>         rate(i)=rk(i)
>       ENDDO
66d63
< *************************************************************
68,75c65,68
< * except for the species given in idf where it is 2.
< * Do self reaction calculation first: mathematically identical to 
< * original code which required splitting the 1,nr loop.
< 
<       DO i=1,nf
<         ire=idf(i,1)
<         j  =idf(i,2)
<         rate(ire)=rate(ire)*c(idr(ire,j))
---
> * except for the species given in idselfreac where it is 2.
>       DO ire=1,numre
>         DO i=1,numstoi(ire,1)
>           rate(ire)=rate(ire)*c(idrestoi(ire,i))
77,85d69
< 
< *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
< !=====loop over 1,nr
< 
<       DO ire=1,nr
< 
< !ORIG (cannot simplify)!
<         DO i=1,ns(ire,1)
<          rate(ire)=rate(ire)*c(idr(ire,i))
88c72,88
< !!      ENDDO  ! <== not needed: entering 1,nr loop only once
---
>       DO i=1,nself
>         ire=idselfreac(i,1)
>         j=idselfreac(i,2)
>         rate(ire)=rate(ire)*c(idrestoi(ire,j))
>       ENDDO
> 
> ! compute the rate constant for aerosol -> gas
> c      ctotaer = cnv
> c      DO i = 1,nsat
> c        ctotaer=ctotaer+c(idasat(i))
> c      ENDDO
> c      IF (ctotaer.LT.1E5) ctotaer=1E5
> c
> c      DO i=1,numaou
> c        ire=idaou(i)
> c        rate(ire)=rate(ire)/ctotaer ! aer conc is compute INSIDE 
> c      ENDDO
90d89
< *************************************************************
92,110c91,96
< * for the loss term, stoi. coef. is 1, except for the species 
< * given in idf where it is 2.
< !      DO ire=1,nr ! <== not needed: entering 1,nr loop only once
< 
< !ORIG!
< !        DO i=1,ns(ire,1)
< !          xfl(idr(ire,i))=xfl(idr(ire,i)) + rate(ire)
< !        ENDDO
< 
< !JMLT! NUMERICALLY IDENTICAL TO ORIGINAL, ABOVE
<         i=ns(ire,1)
<         idarr(1:i)=idr(ire,1:i)
<         xfl(idarr(1:i)) = xfl(idarr(1:i))
<      &                  + rate(ire)
< 
< !ORIG (cannot simplify)!
<         DO i=1,ns(ire,2)
<           xfr(idp(ire,i))=xfr(idp(ire,i))+
<      &                         cfp(ire,i)*rate(ire)
---
> * for the loss term, stoi. coef. is 1, expect for the species 
> * given in idselfreac where it is 2.
>       DO ire=1,numre
>         DO i=1,numstoi(ire,2)
>           xfr(idpdstoi(ire,i))=xfr(idpdstoi(ire,i))+
>      &                         pdstoicf(ire,i)*rate(ire)
113,116c99,100
< ! calculate production / loss due to organic reactions ONLY (for PAM)
<         IF(ire.GE.65)THEN
<           DO i=1,ns(ire,1)
<             trl(idr(ire,i))=trl(idr(ire,i))+rate(ire)
---
>         DO i=1,numstoi(ire,1)
>           xfl(idrestoi(ire,i))=xfl(idrestoi(ire,i)) + rate(ire)
118,123d101
<           DO i=1,ns(ire,2)
<             trr(idp(ire,i))=trr(idp(ire,i))+
<      &                           cfp(ire,i)*rate(ire)
<           ENDDO
<         ENDIF
< 
125d102
< !=====end loop over 1,nr
127d103
< *************************************************************
129,132c105,108
<       DO i=1,nf
<         ire=idf(i,1)
<         j  =idf(i,2)
<         xfl(idr(ire,j))=xfl(idr(ire,j)) + rate(ire)
---
>       DO i=1,nself
>         ire=idselfreac(i,1)
>         j=idselfreac(i,2)
>         xfl(idrestoi(ire,j))=xfl(idrestoi(ire,j)) + rate(ire)
135d110
< *************************************************************
137,138c112,114
<       xfl = xfl / c
<       trl = trl / c
---
>       DO i=1,numsp
>         xfl(i)=xfl(i)/c(i)
>       ENDDO
140d115
< *************************************************************
142c117,119
<       xfl = xfl + rdep + rdil
---
>       DO i=1,numsp
>          xfl(i)=xfl(i) + rdep(i) + rdil
>       ENDDO
144d120
< *************************************************************
146c122,124
<       xfr = xfr + rem + rex
---
>       DO i=1,numsp
>          xfr(i)=xfr(i) + rem(i) + rex(i)
>       ENDDO
148d125
< *************************************************************
150c127,129
<       c=AMAX1(0., (sum+gdt*xfr)/(1.+gdt*xfl) )
---
>       DO i=1,numsp
>         c(i)=AMAX1(0., (sum(i)+gdt*xfr(i))/(1.+gdt*xfl(i)) )
>       ENDDO
152d130
< *************************************************************
