206
PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared for the United States Environmental Protection Agency under Contracts AGRDW89939464-01 and AGRDW89939645-01 Joint Global Change Research Institute, College Park, MD Pacific Northwest National Laboratory Operated by Battelle for the US Department of Energy DISCLAIMER This report was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency thereof, nor Battelle Memorial Institute, nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof. PACIFIC NORTHWEST NATIONAL LABORATORY operated by BATTELLE for the UNITED STATES DEPARTMENT OF ENERGY under Contract DE-AC05-76RL01830 Printed in the United States of America Available to DOE and DOE contractors from the Office of Scientific and Technical Information, P.O. Box 62, Oak Ridge, TN 37831-0062; ph: (865) 576-8401 fax: (865) 576-5728 email: [email protected] Available to the public from the National Technical Information Service, U.S. Department of Commerce, 5285 Port Royal Rd., Springfield, VA 22161 ph: (800) 553-6847 fax: (703) 605-6900 email: [email protected] online ordering: http://www.ntis.gov/ordering.htm

SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

PNNL-15037-1

SGM Model Code I

Joint Global Change Research Institute Model Group

Antoinette L. Brenkert (editor)

January 28, 2005

Prepared for the United States Environmental Protection Agency under Contracts AGRDW89939464-01 and AGRDW89939645-01

Joint Global Change Research Institute, College Park, MD

Pacific Northwest National Laboratory Operated by Battelle for the US Department of Energy

DISCLAIMER

This report was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency

thereof, nor Battelle Memorial Institute, nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does

not necessarily constitute or imply its endorsement, recommendation, or favoring by

the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not

necessarily state or reflect those of the United States Government or any agency thereof.

PACIFIC NORTHWEST NATIONAL LABORATORY operated by BATTELLE for the

UNITED STATES DEPARTMENT OF ENERGY under Contract DE-AC05-76RL01830

Printed in the United States of America Available to DOE and DOE contractors from the

Office of Scientific and Technical Information, P.O. Box 62, Oak Ridge, TN 37831-0062;

ph: (865) 576-8401 fax: (865) 576-5728

email: [email protected] Available to the public from the National Technical Information Service, U.S. Department of Commerce, 5285 Port Royal Rd., Springfield, VA 22161

ph: (800) 553-6847 fax: (703) 605-6900

email: [email protected] online ordering: http://www.ntis.gov/ordering.htm

Page 2: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

2

Table of Contents Figure 1 A Basic Flowchart of the SGM ........................................................ 205 SGM Model Code I................................................................................ 1 Table of Contents............................................................................... 2 C COMMON BLOCKS......................................................................... 4 C COMMON BLOCKS........................................................................ 12 SUBROUTINE ACCOUNT............................................................................. 13 SUBROUTINE BANNER.............................................................................. 16 SUBROUTINE BRNT................................................................................ 17 REAL*8 FUNCTION EXCESSD(PriceMrkItr)........................................................... 18 REAL*8 FUNCTION ZBRENT(func,x1,x2,tol)......................................................... 20 SUBROUTINE CESCALC............................................................................. 21 SUBROUTINE CARBONPRICE......................................................................... 28 REAL*8 FUNCTION CARBTRADE(IDUM)................................................................ 30 SUBROUTINE IVID(pct,psct,idx,lstr,ustr)........................................................ 32 SUBROUTINE DBOUT............................................................................... 32 SUBROUTINE DEMK................................................................................ 44 SUBROUTINE DEMOG............................................................................... 54 SUBROUTINE EBAL................................................................................ 56 SUBROUTINE EXPPROFIT........................................................................... 58 SUBROUTINE FIXC................................................................................ 61 SUBROUTINE GETCFEE............................................................................. 62 SUBROUTINE GHG................................................................................. 66 SUBROUTINE GHGEMIS............................................................................. 67 SUBROUTINE GOVT................................................................................ 72 SUBROUTINE GPCM................................................................................ 75 SUBROUTINE HHOLD............................................................................... 76 SUBROUTINE IMPEX............................................................................... 79 SUBROUTINE IMPEXold............................................................................ 81 SUBROUTINE INVST............................................................................... 82 PROGRAM SGM.................................................................................... 84 SUBROUTINE MODEL1.............................................................................. 87 SUBROUTINE MODEL2.............................................................................. 89 SUBROUTINE NEWINVNEW........................................................................... 91 SUBROUTINE NEWINVold.......................................................................... 107 SUBROUTINE OPERATENEW......................................................................... 113 SUBROUTINE OPERATEOLD......................................................................... 117 SUBROUTINE OUTEXCEL........................................................................... 123 SUBROUTINE POSTINI............................................................................ 141 SUBROUTINE POSTPER............................................................................ 146 SUBROUTINE PPS................................................................................ 155 SUBROUTINE SGMCTRL............................................................................ 160 SUBROUTINE SGMDATA............................................................................ 161 SUBROUTINE NEXTFIELD(FIELDMRK,INDIC).......................................................... 185 SUBROUTINE PARSECOM(CH)....................................................................... 185 SUBROUTINE NEXTTABLE(TABLEMRK,INDIC).......................................................... 185 SUBROUTINE NEXTSCEN(SCENMRK,INDIC)............................................................ 186 SUBROUTINE INTERP(N,ISTART,IY,X,Y)............................................................ 186 C SGM FUNCTION LIBRARY..................................................................... 188 FUNCTION FIFGE(A,B,I,J)....................................................................... 188 FUNCTION SUMINTRP(FL1,FL2).................................................................... 188 FUNCTION TECHINTERP(m0,ml,mm,x0,xl,itype)..................................................... 189 SUBROUTINE SOLUTN............................................................................. 189 SUBROUTINE GAUSSJ(a,n,np,b,m,mp).............................................................. 198 SUBROUTINE SOLVE.............................................................................. 199 SUBROUTINE TECH............................................................................... 201 JGCRI’s Software User Acknowledgement......................................................... 206

Page 3: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

3

Introduction This is a first release of the Second Generation Model code. It includes the Fortran source codes to operate the SGM. The initial conceptual work for the Second Generation Model began in 1990, with implementation starting in 1991. Since then many sponsors and staff have contributed to the model development. Prominent among the sponsors have been the US EPA, presently through the Economic Analysis Branch of the Climate Change Division, Office of Atmospheric Programs, the Integrated Assessment Program within the Office of Science, US Department of Energy, and the Electric Power Research Institute, Climate Change Program. SGM’s documentation (PNNL-14256), overview document (PNNL-14916) and users guide (PNNL-15019-1) are available from http://www.globalchange.umd.edu/?models&page=sgm.

Note that GAUSSJ and ZBRENT are Numerical Recipes routines used in the SGM AN INDEPENDENT LICENCE NEEDS TO BE OBTAINED BY EVERY USER FROM NUMERICAL RECIPES BEFORE THE MODEL CAN BE COMPILED SEE http://www.nr.com/com/storefront.html See SUBROUTINE gaussj(a,n,np,b,m,mp) RETURN END And FUNCTION zbrent(func,x1,x2,tol) RETURN END C (C) Copr. 1986-92 Numerical Recipes Software

Page 4: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

4

CODE C********************************************************************** C C COMMON BLOCKS C C********************************************************************** C LEGAL NOTICE C This computer software was prepared by Battelle Memorial Institute, C hereinafter the Contractor, under Contract No. DE-AC05-76RL0 1830 C with the Department of Energy (DOE). C NEITHER THE GOVERNMENT NOR THE CONTRACTOR MAKES ANY WARRANTY, C EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF C THIS SOFTWARE. C This notice including this sentence must appear on any copies C of this computer software. C C EXPORT CONTROL C User agrees that the Software will not be shipped, transferred or C exported into any country or used in any manner prohibited by the C United States Export Administration Act or any other applicable C export laws, restrictions or regulations C (collectively the "Export Laws"). C Export of the Software may require some form of license or other C authority from the U.S. Government, and failure to obtain such C export control license may result in criminal liability under C U.S. laws. C C In addition, if the Software is identified as export controlled C items under the Export Laws, User represents and warrants that User C is not a citizen, or otherwise located within, an embargoed nation C (including without limitation Iran, Iraq, Syria, Sudan, Libya, Cuba, C North Korea, and Serbia) and that User is not otherwise prohibited C under the Export Laws from receiving the Software. C C All rights to use the Software are granted on condition that such C rights are forfeited if User fails to comply with the terms of C this Agreement. C C User agrees to identify, defend and hold harmless BATTELLE, C its officers, agents and employees from all liability involving C the violation of such Export Laws, either directly or indirectly, C by User. C*********************************************************************** REAL*8 KA_STORE,KA_TEMP COMMON/STORE/ & KA_STORE(NISSP,NISP,0:NMP), ! Capital stocks summed over vintages & KA_TEMP(0:NMP), ! Temporary array & PROFITS_STORE(NIOP,NISSP,0:NMP), ! Profits summed over vintages & COSTK_STORE(NIOP,NISSP,0:NMP), ! Cost of capital for new vintage & IOVAL_STORE(NISP,NINP,0:NMP) ! Values in input-output table C**********************************************************************

C COMMON BLOCKS C C********************************************************************** C VERSION 1. 1/30/05 C Common blocks for sgm version 1.0 C IMPLICIT DOUBLE PRECISION (A-H,O-Z) REAL*8 K,KA,KAPRIOR,KC,KCPRIOR,KAFLOW,KAFLOWT,KDEM,KWORK REAL*8 ED,EDVIN,SSQED,P,PI,PE,PERETRO,PIE,Z,LEON Real*8 PROFRATE CHARACTER*3 TECHINT PARAMETER( & NINP = 27, ! Maximum number of inputs & NISSP = 16, ! Maximum number of sub sectors & NIOP = 22, ! Maximum number of production sectors

Page 5: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

5

& NMP = 23) ! Maximum number of periods PARAMETER( & IVIN1P = -13, ! oldest vintage for retrofits & NMPP4 = NMP + 4, ! NMP plus 4(used for expectations) & NLP=13, ! Number of regions & NISP = 27, ! Number of inputs NIOP + 2 + 3 factors of prod & NDEFP = 57, ! Maximum number of prod. sectors and subsectors & NDEFSP = 67) ! Maximum number of all sectors and subsectors PARAMETER( & IVIN0P = -3, ! Oldest initial vintage allowed in model & NRFP = 1, ! Number of retrofit technologies & NMRKP = 350, ! Maximum number of markets & MXITRP = 30) ! Maximum number of iterations in sol algor PARAMETER( & NGSP = 11, ! Maximum number of gases in emissions & NSRCP = 40, ! Maximum number of sources in emissions & NAGEP = 21) ! Maximum number of age groups in demographics COMMON/GPCM1/ ! Variables for Generalized Production and Cost Module--I & A(0:NINP,0:NDEFP,IVIN0P:NMP,0:NLP), ! Prod. Func. Parms & ACST(0:NINP,NDEFP,IVIN0P:NMP,NLP), ! Dual of PF Parms(cost) & ADJ(NINP,NDEFSP,NLP,0:NMPP4), ! Multiplicative adj factor for prices & ADJZ(NINP,NDEFSP,NLP), ! Terminal value for ADJ & ACCINV(NLP), ! Investment equation parameter & C(0:NINP,NRFP,NDEFP,IVIN0P:NMP,NLP), ! Retrofit parameters & COST(NINP,NDEFSP,IVIN0P:NMP,NLP), ! Cost of inputs & CrbPriceRcyPct(3), ! percent allocation of carbon price ! 1 to govt, 2 to hhold, 3 to ind & DEFLATOR(NLP), ! Deflator for reporting GNP, etc, & DEXPPROF(NISSP,NIOP,NLP,-1:NMP), ! Expected profits for multi-period investments & DRSCE(NIOP,NISSP,NLP), ! Fos. Fuel Resources & RESC(NIOP,NISSP,0:NLP,0:NMP), ! Fos. Fuel Resources by Period & ROUT(NIOP,NISSP,NLP,0:NMP), ! output by subsector & VOUT(NIOP,NISSP,NLP,0:NMP), ! value of output by subsector & RESV(NIOP,NISSP,NLP,0:NMP), ! Reserves by grade & TOTPRD(NINP,0:NLP,0:NMP), ! total production by industry & DRSCTMP(NIOP,NISSP,NLP), ! Temp for Fos. fuel Resources & DRSVE(NIOP,NISSP,IVIN0P:NMP,NLP), ! Fos. Fuel Reserves & DRSVTMP(NIOP,NISSP,IVIN0P:NMP,NLP), ! Temp for Fos. Fuel Reserves & ED(NINP,NISP,NLP,0:NMP), ! Excess demand by subsector & EDVIN(NINP,NDEFSP,IVIN0P:NMP,NLP), ! Excess demand by vintage & EQDEP(NIOP,NISSP,NLP), ! production from depletable resources & EQDEPPRE(NIOP,NISSP,NLP), ! production in previous period from depl resources & EXCHRATE(NLP), ! Exchange rate into US currency & EXIMPORT(0:NINP,0:NLP,0:NMPP4), ! Transportation cost multiplier & EXOINVST(NIOP,NLP,0:NMP), ! exogenous investment demand & EXPPROF(NISSP,NIOP,NLP,-1:NMP), ! Expected Profits & K(NIOP,NLP,IVIN0P:NMP), ! Capital stocks by sector & SVEXPPROF(NISSP,NIOP,NLP,-1:NMP), ! Expected Profits & PROFRATE(NIOP,NISSP,NLP,-3:NMP,IVIN0P:NMP) ! Profit Rate COMMON/GPCM2/ ! Variables for Generalized Production and Cost Module--II & KAPRIOR(NISSP,NIOP,IVIN0P:NMP,NLP), ! Prior capital stock by vintage & KA(NISSP,NIOP,IVIN0P:NMP,NLP), ! Capital stock by vintage & KAFLOW(NISSP,NIOP,IVIN0P:NMP,NLP), ! Investment & KAFLOWT(NISSP,NIOP,IVIN0P:NMP,NLP), ! Tempory Investment & KWORK(NLP,0:NMP), ! capital per worker & KC(NRFP,NDEFP,IVIN0P:NMP,NLP), ! Capital stock by retrofits & KCPRIOR(NRFP,NDEFP,IVIN0P:NMP,NLP), ! Prior capital stock for retrofits & KDEM(NISSP,NIOP,IVIN0P:NMP,NLP), ! Investment by subsector & P(NINP,NLP,0:NMPP4), ! World Price & PE(NIOP,NISSP,NLP), ! Expected price received & PERETRO(NINP,NDEFP,IVIN1P:NMP,NLP), ! Expected price for retrofits & PRCV(NINP,NLP,0:NMPP4), ! Price received by producers & PI(NINP,NDEFSP,NLP,IVIN0P:NMP,2), ! Price paid & PIE(NINP,NISSP,NIOP,NLP), ! Expected price paid & PRCONVRT(0:NINP,NLP), ! Price to physical units conversion & PROF(NIOP,NLP), ! Profits by industry & TPROF(NLP,0:NMP), ! Total profits by region and period & PROFITS(NIOP,NISSP,IVIN0P:NMP,NLP), ! Profits by vintage and subsector & PRDVIN(NIOP,NISSP,IVIN0P:NMP,NLP), ! Production by vintage & PRDVNPRE(NIOP,NISSP,IVIN0P:NMP,NLP), ! Previous period production by vintage & ASAVE(0:NINP,0:NDEFP,IVIN0P:NMP,0:NLP), ! Prod. Func. Parms & PEELEC(NIOP,NISSP,NLP), ! Expected price received for elec subsectors & PRCVELEC(NISSP,NLP,0:NMPP4), ! price received for elec subsectors & svRIOTOT(NDEFSP,NLP) ! saved col total used for new elec price

Page 6: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

6

COMMON/GPCM3/ ! Variables for Generalized Production and Cost Module--III & RGNP(0:NLP,0:NMP), ! GNP at base year prices & GNPRP(NLP,0:NMP), ! GNP growth rate from exogenous projection & MGNP(NLP), ! Switch for GNP growth rate matching & IOFF, ! Switch to write outexcel in last period & RGNPW(NLP,0:NMP), ! GNP per worker at base year prices & RCONS(0:NLP,0:NMP), ! Consumption at base year prices & RINVST(0:NLP,0:NMP), ! Investment at base year prices & RGOVT(0:NLP,0:NMP), ! Government at base year prices & RTRD(0:NLP,0:NMP), ! Trade at base year prices & RHOINV(NIOP,NLP), ! logit parm for sector investments & RINV(NLP), ! Profit elasticity parm & RPROFIT(NIOP,NLP), ! invest elas excess profit rate parms & SALES(2,NISP,NLP,0:NMP), ! industry output and total sales & SCLINV(NLP), ! investment scale parameter & SCLPROFT(NIOP,NLP), ! scale parm excess profit rate & SDEXPRF(NIOP,NLP,-1:NMP), ! sector expected profit rate & SHARE(NIOP,NISSP), ! share of subsector in Sector Inv & TADJZ(NINP,NDEFSP,NLP), ! time to reach final ADJ value & TAZ(0:NDEFP,0:NLP), ! time to reach final tech. & TECHSOLM(0:NISSP,0:NIOP, & 0:NLP,0:NMP), ! Tech change used to get AZs & TECHNN(9,NDEFP,NLP,0:NMP), ! Non-neutral technical change parameters & TMPKAF(NIOP,NLP), ! Previous period investment & TMPKA1(NIOP,NLP), ! Previous period capital & TMPKA2(NIOP,NLP), ! period -2 capital & TR(NINP,NLP,0:NMPP4), ! Initial transport costs & TRADE(0:1,0:NINP,0:NLP,0:NMP), ! trade(imports > 0) & CAPTRD(NLP,0:NMP), ! Stores inital capital flow for permit trade calc & TRZ(NINP,NLP), ! Final transport costs & TTRZ(NINP,NLP), ! time to final transport costs & TXADD(NINP,NDEFSP,NLP,0:NMPP4), ! Additive taxes & TXIBT(NINP,NLP,0:NMPP4), ! IBT tax rates & EXIBT(NLP,0:NMP), ! Array to collect excess IBT taxes & TXPRO(NINP,NDEFSP,NLP,0:NMPP4), ! Proportional investment & VKRATIO(NIOP,NLP), ! Ratio of vintage inv -1 & -2 & X(10), ! not used & Z(NIOP,NISSP), ! intermediate value in expected profit & RIBT(NDEFSP,NLP), ! indirect business tax & RIOVAL(NINP,NDEFSP,NLP), ! io values for calibration & EMPLOY(0:NLP,0:NMP), ! employed population & HHAEEI(10,NLP,0:NMP), ! Household AEEI by fuel & GVAEEI(10,NLP,0:NMP), ! Government AEEI by fuel & ICRBTXOPT, ! carbon price recycling options & IN, ! Index for inputs & IO, ! Index for industry & IREP, ! Number of market solutions & IRF, ! index for retrofits & IS, ! Index for sector(io + TIGC) & ISCNO, ! Scenario number & ISOPT, ! Solution option & ISS, ! Index for subsector & ISSGROUP(NIOP,NISSP,NLP) ! subsector for new technology COMMON/GPCM4/ ! Variables for Generalized Production and Cost Module--IV & EXONUC(0:NMP,NLP), ! Exogenous investment in nuclear power & EXOHYDRO(0:NMP,NLP), ! Exogenous investment in hdyro power & SHAREINV(NIOP,NLP), ! Base-year investment share vector & CAPSHR(NIOP,NIOP,NLP), ! Base-year investment share matrix & CAPMAT(NIOP,NIOP,NLP), ! Base-year investment matrix for private sector & CAPMATG(NIOP,NIOP,NLP), ! Base-year investment matrix for government (SGM-Japan only) & SHARE16G(NIOP), ! Shares of row 16 in CAPMATG (SGM-Japan only) & CAPR16G(NIOP), ! Ratio of capital to row 16 (SGM-Japan only) & GSUPK(NIOP,0:NLP), ! Government-supplied capital (SGM-Japan only) & IVIN, ! Index for vintage & L, ! Index for region & IMPOLD(NLP), ! Indicator to run old IMPEX & LINVEST(NLP), ! Indicator for type of investment equation & M, ! Index for period & MFOR, ! Index for year within period & MKTLINK(NINP,NLP), ! Links markets across regions & MYRETRO(NRFP,NISSP,NIOP,NLP), ! Indicates required retrofits & NEM, ! Number of emissions & NETE, ! Number of the everything else(numeraire) sector & NIO, ! Number of IO(producing) sectors & NIN, ! Number of inputs to production function & NIS, ! Numnber of sectors & NISS(0:NISP,0:NLP), ! Number of subsectors & NL, ! Number of regions

Page 7: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

7

& NM, ! Number of periods & NP, ! Lifetime of technology & NTECHCHAR(1:6,0:NDEFP, & 0:NLP,IVIN0P:NMP), ! Characteristics of technologies & NOPT(NISSP,NIOP,NLP), ! Price expection formation option & NRF(NISSP,NIOP,IVIN0P:NMP,NLP), ! Number of retrofits & NRSCHAR(2,NIOP,NLP), ! Flag for depletable resource & NSTEP, ! Number of years in a period & NVIN0, ! Earliest vintage in model & NELEC, ! Number of electricity sector & JNUC, ! Number of nuclear power subsector & JHYDRO, ! Number of hydro power subsector & TECHINT ! Type of interpolation in tech(EXP or LIN) COMMON/DEMOG1/ ! Variables for demographic module & FCLM(NAGEP,NLP,0:NMP), ! Initial Fertility Rates & FCLZ(NAGEP,NLP), ! Terminal Fertility rates & FXCLM(NAGEP,NLP), ! M / TFCLZ(intermediate calculation) & GCLM(NAGEP,NLP), ! Male birth fraction & POPGCLM(2,NAGEP,NLP,0:NMP), ! Population by gender age reg and per & POPGCM(2,NAGEP,0:NMP), ! Population by gender age and period & POPGLM(2,NLP,0:NMP), ! Population by gender region and per & POPGM(2,0:NMP), ! Population by gender and period & POPLM(0:NLP,0:NMP), ! Population by region and period & POPM(0:NMP), ! Population by period & SVGCLM(2,NAGEP,NLP,0:NMP), ! initial death rates & SVGCLZ(2,NAGEP,NLP), ! terminal death rates & SVXGCLM(2,NAGEP,NLP), ! M / TSVGCLZ(Intermediate calc) & TSVGCLZ(2,NAGEP,NLP), ! time-to-terminal death rates & TFCLZ(NAGEP,NLP), ! time-to-terminal fertility rates & TXMIGZ(NLP), ! time-to-terminal net migration rate & XMIG(2,NAGEP,NLP,0:NMP), ! Initial migration rate & XMIGZ(2,NAGEP,NLP), ! Terminal migration rate & XXMIG(2,NAGEP,NLP), ! M / TXMIGZ(Intermediate calculation) & YNGOLD(NLP,0:NMP), ! Fraction below 15 or over 65 & MAXLIFE, ! Unreferenced & NAGE, ! Number of age groups & POPTYPE(NLP) ! Rate or absolute population data CHARACTER*4 POPTYPE COMMON/SOL/ & CONV, ! Dynamic convergence criteria & MRKED(NMRKP), ! Excess demand by market & MRKLED(NMRKP,NLP), ! Excess demand by market and region & MRKPRD(NMRKP), ! Production by market & PR(NMRKP), ! Price vector used in DIAG and SSQPLOT & DELP(MXITRP), ! Price Change within market solution & EXD(NMRKP,MXITRP), ! Excess demand withing market solution & PRICE(NMRKP,MXITRP), ! Price within market solution & PROD(NMRKP,MXITRP), ! production within market solution & SOLCONV, ! Solution convergence(relative to supply) & regsol(nlp), ! regional solution criterion & SSQED, ! Sum of squared excess demands & SUMED, ! Sum of excess demands & SCREEN, ! Switch to activate writing to screen & IBR, ! Solution flag in BRNT & IDEF(NIOP,NISSP,NLP), ! Prod Sector-Subsector identifier & IDEFS(NISP,NISSP,NLP), ! All Sector-Subsector identifier & IPFIX(NMRKP,0:NLP,0:NMP), ! Flag for fixed price(not solved for) & ISECDF(NINP,NLP), ! model sector to market mapping & ISOL, ! Number of Unsolved Markets & ITR, ! iteration counter within market sol & ixvectcnt, ! counter for xvector evaluations & MODL, ! Number of model evaluations & MRK, ! Market index & MRKDEF(0:NMRKP,20), ! Market definition(inverse for ISECDF & MSOL, ! indicator of solution failure in SOLUTN & NMRK, ! Number of Markets & NNEWT, ! Size of matrix in Solutn & NR, ! Number of regions in a market & READINPRICE ! Use read in price data(YES) or previous period price ! as initial value for sol. algor. CHARACTER*3 READINPRICE LOGICAL IPFIX REAL*8 MRKPRD,MRKLED REAL*8 MRKED,PR,PT,XIT,XI,U REAL*8 LB,NHH,KTOT,HHINC,LFIX COMMON/FNLDMD/ ! Variables in final demand sectors

Page 8: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

8

& CRBTREXO(NLP,0:NMP), ! net exogenous carbon trading (value) & TRADECARB(NLP,0:NMP), ! computed net carbon trading income & CITR(NLP,0:NMP), ! corporate income tax rate & CONS(0:NLP,0:NMP), ! consumption expenditures & CRBPRICETOT(NLP,0:NMP), ! Total carbon price revenues & DIO(NINP,NLP,0:NMP), ! Total IO demand & E(0:2,0:NINP,0:NLP,0:NMP), ! consumer demand function coefs & EMPR(NLP,0:NMP), ! fraction of working age employed & EXIM(0:NLP,0:NMP), ! Net exports & G(0:4,NLP,0:NMP), ! govt transfer coefs & GC(0:NINP,0:NISSP,0:NLP,0:NMP), ! Fixed weights for Government expends & GE(NISSP,NLP,0:NMP), ! Government expenditure by sub sector & GF(0:NISSP,0:NLP,0:NMP), ! government preference function parms & GNP(0:NLP,-3:NMP), ! Gross national product & GOVDEF(NLP,0:NMP), ! Government deficit & GOVDEFT(NLP,0:NMP), ! temporary government deficit & GOVMT(0:NLP,0:NMP), ! total government expenditures & GOVTR(NLP,0:NMP), ! government transfers & HHINC(10,NLP), ! household income & KTOT(0:NLP,0:NMP), ! total investment(annual rate) & LB(0:2,0:2,0:NLP,0:NMP), ! labor market coefficients & LFIX(NLP,0:NMP), ! fixed labor market fraction path & NHH(NLP,0:NMP), ! Number of households & PERCAP(NLP,0:NMP), ! Per capita income & PGC(NISSP), ! government subsector prices & PINC(NLP), ! Personal income & PITR(NLP,0:NMP), ! Personal income tax rate & R(0:2,NLP,0:NMP), ! land supply coefs & RE(0:1,0:NIOP,0:NLP,0:NMP), ! retained earnings parameters & RETE(NIOP,NLP), ! retained earnings & S(0:2,NLP,0:NMP), ! household savings parameters & SAVING(NLP,0:NMP), ! household savings (does not include RE) & SSTR(NLP,0:NMP), ! social security tax rates & SUBSID(NINP,NLP), ! Subsidy by Sector & SUBSIDY(NLP,0:NMP), ! Total Subsidy & TAX(5,NISP,NLP), ! Tax income by sector and type & SUBSIDGOV(NLP), ! government Subsidy by region & TAXGOV(5,NLP), ! govt tax payments (income) & TAXCHH(NLP), ! estimated household carbon price & TAXCINV(NLP), ! estimated investment carbon price & TCON(NINP,NLP,0:NMP), ! Consumption & TLA(0:NLP,0:NMP), ! Total Land Area & TOTTAX(NLP), ! Total tax receipts & TRD(NINP,NLP,0:NMP), ! Trade--unreferenced & TRETE(NLP), ! Total retained earnings & TRNP(NINP,NLP), ! transportation costs & WAGE(4,0:NLP,-2:NMP), ! Work age population, at work, & gnp/worker & WHSL(NINP,NLP), ! distribution and markup factors & XITCR(NISP), ! Investment tax credit rate & XITC(NISP,NLP), ! Investment tax credit by sector & XITCTOT(NLP), ! Total Investment Tax Credit & IWDGMRK(0:NIOP,0:NISSP,0:NLP,0:NMP), !Signals direct investment wedge & WEDGE(0:NIOP,0:NISSP,0:NLP,0:NMP) !Direct investment wedge COMMON/NAMES/ ! Names of variables & NRGINP(NINP), ! Mapping to energy sectors (for tech change) & NNRGINP, ! Number of energy sectors & INBLOCK(NINP), ! Input groups (for tech change) & JCAPITAL,JLABOR,JENERGY,JMATRL,JLAND, & JENDOIL,JENDGAS,JENDCOAL,JENDELEC, ! Sector (or input) group names & NINPCAT, ! Number of input categories & JHHOIL,JHHGAS,JHHCOAL,JHHELEC, ! Sector (or input) group names & NINAEEI ! Number of input categories COMMON/EMISS/ ! greenhouse gas emissions variables & CARBONLIM(0:NLP,0:NMP), ! limit for carbon emissions & CARBDATA(0:3,0:NLP,0:NMP), ! data for setting carbon limit & CARBPRICEP(6,NLP), ! data on carbon price & CARBVAR(NLP,0:NMP), ! Entries for variable carbon fee or target & CarbPriceAdj(0:Ninp,NLP), ! Used to apply carbon price to subset of fuels & EM(NSRCP,0:NLP,0:NMP), ! greenhouse gas emissions by source & EMACTY(NSRCP,NLP), ! Activity levels for greenhouse gas sources & EMC(NSRCP,10,NLP), ! emission per unit of activity & EMCADJ(NSRCP,NLP,0:NMP), ! adjustment over time on emissions coef & EMTOT(0:NLP,0:NMP), ! emissions to be controlled in carbon equivalent & CARBF(0:NIOP,NLP), ! carbon price($/TC) to rate conversion & CPRICER(NINP+10,NDEFSP,NLP,0:NMP), ! carbon price($/TC) to rate conversion & RedCfee(NINP+10,NDEFSP,NLP,0:NMP), ! Cfees that are not leveled & CFBSTOP(0:NMP), ! Value (1985$) for carbon-free backstop & CO2TOTG(NLP,0:NMP), ! Stores pre-backstop emissions & GWP(NGSP,NLP,0:NMP), ! Global Warming Potentials adj by carbon wght

Page 9: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

9

& EMCLABEL(NSRCP,NLP), ! label for the emissions & NGAS, ! Number of greenhouse gases & NSOURCE(0:NLP) ! Number of sources of GHG's CHARACTER*40 EMCLABEL INTEGER CARBPRICEP COMMON/EMTECH/ ! emissions mitigation technologies & EMT(NSRCP,0:10,6,NLP), ! & JEMT(NSRCP,9,NLP), ! array of integer toggles & EMTJPR(NSRCP,NLP), ! 1990 price of joint product/ton em & EMTINTRP(NSRCP,6,NLP,0:NMP), ! contains the final redux val & EMTACNT(NSRCP,6,NLP,0:NMP), ! accounting & emtexpprof(NSRCP,15), ! marginal profit by level & JEMTSIMP(NSRCP,NLP), ! number of levels in cost curve & EMTSIMP(NSRCP,13,2,NLP) ! cost curve: 1 is charge, 2 is redux (13 mc levels) COMMON/EPA/ ! EPA modifications variables & A0AF(NLP,0:NMP), ! A0 multiplicative adjustment factor & A0SAVE(NISSP,NIOP, & IVIN0P:NMP,NLP) ! Stores initial value for A0. C ************************************************************************** C This section is included in SGMDATA.for in the NEXTSCEN subroutine. C Be sure to make changes to this block in both this file and SGMDATA.for. COMMON/FILES/ ! Information on input and output files & CASENAME, ! Case name & OUT1FILE, ! Main SGM output file & ENBLFILE, ! Energy Balance output file & ENEMFILE, ! Energy/Emissions output file & IVRSFILE, ! Inv./Resources output file & SECNAME(NISP,NLP), ! Name of Sector & TECHNAME(NISP,NISSP,NLP) ! Name of technology CHARACTER*72 CASENAME,CASENOTE CHARACTER*72 OUT1FILE,ENBLFILE,ENEMFILE,IVRSFILE, & PLCYFILE,FILES CHARACTER*40 TECHNAME,SECNAME C *************************************************************************** COMMON/POLICY/ & RESGRZ(NIOP,NISSP,NLP), ! terminal growth rates in depletable resources & TRESGRZ(NIOP,NISSP,NLP), ! time-to-terminal growth rates in depletable resources & RESGRO(NIOP,NISSP,NLP,0:NMP), ! initial growth rates in depletable resources & DRSCE0(NIOP,NISSP,NLP), ! Initial depletable resources & ITCPD ! Initial period for investment tax credit COMMON/CTRL/ & INFILES, ! & FILES(30), ! & CASENOTE, ! & IUNIT ! COMMON/RON1/ & RONPIV(NIOP,NISSP,IVIN0P:NMP,NLP), & PPDELEC(NINP,NLP,0:NMPP4), ! Price paid & RHOST(NDEFP,NLP), ! Rho for short-term elasticities & EXOELEC(NLP,NISSP,0:NMP), ! Exogenous investment in electricity subsectors & JELFIX(NLP,NISSP,0:NMP), ! Switch to fix investment in electricity subsectors & JFIXINV(NIOP,NISSP,NLP,0:NMP), ! Switch for fixed investment by subsector & FIXINV(NIOP,NISSP,NLP,0:NMP), ! Fixed investment by subsector & TESTK(NIOP,NLP), ! Initial guess for sector investment & QPROJ(NLP,0:NMP), ! Multiplier for projecting output & LEON(0:NINP,NDEFP,IVIN0P:NMP,NLP), ! Leontief technical coefficients & SIGMA1(NDEFP,NLP), ! Long-run (envelope) sigma & SIGMA2(NDEFP,NLP), ! Short-run sigma & CRESERV(IVIN0P:NMP,NIOP) ! Cumulative reserves REAL*8 LevCost,Kcost,issDEXPPROF REAL*8 IOstore,IOrowsum,IOpct,IOemis,IOemisCO2,IOsubsum COMMON/AAF1/ & TAC(NSRCP,0:NLP,0:NMP), ! NonCO2 exog. total abatement cost by source & EMCBASE(NSRCP,NLP,2), ! 1-Stores base emissons in Tg 2-gas & EMTARGET(NLP,0:NMP), ! Stores emissions target for carbon price tuning & LevCost(NLP,16,0:NMP), ! levelized cost per kilowatt hour & RHOINVsub(NLP), ! subsubsector share exponent & SHAREstore(2,0:NMP,16), ! store investment shares: 1-endogenous share, 2-total share & SHAREpkbs1(2,0:NMP,2), ! peak-base level share peak (oil and gas)

Page 10: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

10

& SHAREpkbs2(3,0:NMP,2), ! peak-base level share base (PC, NGCC, IGCC) & SHAREccs1(2,0:NMP,2), ! ccs level share PC (PC, PCcd) & SHAREccs2(2,0:NMP,2), ! ccs level share NGCC (NGCC, NGCCcd) & SHAREccs3(2,0:NMP,2), ! ccs level share IGCC (IGCC, IGCCcd) & SHAREfrnh1(2,0:NMP,2), ! fossil renewable nuclear hydro level share fossil (peak, base) & SHAREfrnh2(6,0:NMP,2), ! fossil renewable nuclear hydro level share renewables (,,,,,) & SHAREelec(4,0:NMP,2), ! elec level share (fossil renewable nuclear hydro) & DEXPPRccs(3,NLP,-1:NMP), ! expected profit for a ccs subnest & DEXPPRpkbs(2,NLP,-1:NMP), ! expected profit for a peak base subnest & DEXPPRfrnh(4,NLP,-1:NMP), ! expected profit for a fossil renewable nuclear hydro subnest & RHOINVccs(NLP), ! logit parm for ccs nest & RHOINVpkbs(NLP), ! logit parm for peak base nest & RHOINVfsl(NLP), ! logit parm for fossil nest & RHOINVrnw(NLP), ! logit parm for fossil renewable nest & TMPEXPccs(3), ! summed subnest expected profits which when summed > tmpexp0 & TMPEXP2ccs(3), ! summed subnest expected profits which when summed > tmpexp0 & TMPEXPpkbs(2), ! summed subnest expected profits which when summed > tmpexp0 & TMPEXP2pkbs(2), ! summed subnest expected profits which when summed > tmpexp0 & TMPEXPfrnh(4), ! summed subnest expected profits which when summed > tmpexp0 & TMPEXP2frnh(4), ! summed subnest expected profits which when summed > tmpexp0 & Zold(NIOP,NISSP), ! intermediate value in lev cost & Kcost(NISSP,NLP), ! cost of capital & Yfixfac(NIOP,NISSP,NLP), ! Y from CES math & OUTPUT(NIOP,NISSP,NLP), ! output = (Y/Z)^(1/rho) & BETAin(NISSP,NLP), ! Beta parameter for calibrating lowest level subsector investment shares when using levelized cost & BetaB(3,NLP), ! Beta parameter for calibrating Base (ngcc, igcc, pc) level investment shares when using levelized cost & BetaF(2,NLP), ! Beta parameter for calibrating Fossil (peak v. base) level investment shares when using levelized cost & BetaE(4,NLP), ! Beta parameter for calibrating Elec (fossil, renewable, nuclear, hydro) level investment shares when using levelized cost & IOstore(NINP,NDEFSP), ! Store vintaged summed IO table & IOrowsum(NINP,NLP), ! Row sum of IO table & IOsubsum(NINP,nLP), ! subsector sum of IO table & PriEnergyC(9,NLP,0:NMP), ! Row sum of IO table for oil coal and gas prd & PriEnergyCelec(9,NLP,0:NMP), ! sum of elec subsectors use of oil coal and gas prd & IOpct(NINP,NDEFSP), ! % of output used by a sector & IOemis(3,NDEFSP,0:NMP,3), ! CO2 emissions by fuel attributed to end use sectors & IOemisCO2(NIOP,0:NMP,NLP), ! CO2 emissions attributed to end use sectors & ISUBexp(NLP), ! switch for subsubsector share exponent & IProfitOption(NLP), ! switch for different expected profit calculations & issDELAY(NLP,NISSP), ! delay option for availabilty of elec subsector techs & issDEXPPROF(NISSP,NLP,-1:NMP) ! expected profit for subsectors when using levelized cost sharing COMMON/ENERGY/ ! Calculate energy balance data & BAL1(NINP,NISP,NLP,0:NMP), ! & BAL2(NINP,NISP,NLP,0:NMP), ! & EPRD(NIOP,NLP,0:NMP), ! & EDEM(NIOP,NLP,0:NMP), ! & ETRADE(NIOP,NLP,0:NMP), ! & BASEGENG(NISSP,NLP), ! Base year electricity generation by fuel (GWh) & ELECGEN(NISSP,NLP,0:NMP), ! Electricity generation (EJ) & ELECPRD(NISSP,NLP,IVIN0P:NMP), ! & ELECFAC(NIOP,NISSP,NLP), ! Conversion from currency to electricity & CO2(NSRCP,0:NLP,0:NMP), ! & TOTCO2(0:NLP,0:NMP), ! & PRI(20,0:NLP,0:NMP), ! note hardwired 20 for primary energy calculation & TOTPRI(0:NLP,0:NMP), ! & PRCONVRTiss(NIOP,NISSP,NLP), ! this is the same as elecfac & PELECCONV(NISSP,NLP) C C ** DATABASE VARIABLE INDEXING ** INTEGER vl, rvl, dbaridx CHARACTER*15 ctstr, sctstr CHARACTER*100 DBNAME COMMON/dbidx/ & vl(99,99,99), ! variable lookup & rvl(3000), ! reverse var lookup & ctstr(99), ! category string & sctstr(99,99), ! subcategory string & vindatasave(2,NIOP,NISSP,IVIN0P:NMP,NLP,0:NMP), !vintage data store FROM 2 TO ! & dbaridx, ! counter for db varid & DBNAME ! name of the database C COMMON/switch/iswitch ! electricity switch (0 for old method; 1 for electricty C fees only)

Page 11: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

11

COMMON/CCS/sqccs COMMON/VEST/LINVST C Carbon prices and offsets through biofuel, agsoil, affor, OR total COMMON/seqswitch/iseqsw(0:NLP) ! sequestration_McCarl's offset switch ! (0 for no offsets; 1 for offsets) Real*8 EmSeq,EmSeqP, ! carbon offset accounting & EmSave,EmSqPSav, & prevEm,prevPr C COMMON/EmSq/ ! McCarl's input & EmSeq(0:NLP,0:401,4), ! emission sequestration that can be offset for that price & EmSeqP(0:NLP,0:401) ! emission sequestration price COMMON/EmPSave/ ! carbon offset accounting & EmSave(0:NLP,0:NMP), ! variable to save emissions that can be offset & EmSqPSav(0:NLP,0:NMP), ! carbon price of the offset emissions & prevEm(0:NLP,0:NMP), ! emissions that can be offset from previous time step & prevPr(0:NLP,0:NMP) ! carbon price of emissions that can be previously offset C for nesting REAL*8 DEXPPR,SHARE2,SHARE1,TMPEXP,KAFL COMMON/DEX/ & DEXPPR(NISSP,NIOP,NLP,-1:NMP), ! expected profit for a electrity subnest & SHARE2(NIOP,NISSP), ! corrected subshare nests for exogenous demand for investment & SHARE1(NIOP,NISSP), ! shares for each subnest & TMPEXP(NISSP), ! summed subnest expected profits which when summed > tmpexp0 & ISUB(NLP) ! nesting switch for electricity technologies ! Debug variables. These are large character vectors that contain debugging information. ! Write to them as you would to a file. They are reinitialized at the start of each ! period. In the event the model fails to solve, the arrays are written to Sgmlog.csv ! providing a starting point for the debugging process. There is one array for the ! solution subroutines and another for the model subrountes COMMON/dbug/ ! debugging common block & Message, ! character array to store Solution debugging info & Messnew, ! buffer to use in write statements & Imesscnt, ! counter for Message (increment by one for each line & modmess, ! character array to store Model debugging info & Imodmescnt, ! counter for model messages & modllimit , ! gives number of model evaluations needed to turn on ! debug output & MessageOut ! if true,forces debug output even if SGM 'solves'. Character*100 message(50000), Modmess(500000) Character*100 messnew Integer Imesscnt, Imodmescnt Logical Messageout

Page 12: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

12

C**********************************************************************

C COMMON BLOCKS C C********************************************************************** REAL*8 KA_STORE,KA_TEMP COMMON/STORE/ & KA_STORE(NISSP,NISP,0:NMP), ! Capital stocks summed over vintages & KA_TEMP(0:NMP), ! Temporary array & PROFITS_STORE(NIOP,NISSP,0:NMP), ! Profits summed over vintages & COSTK_STORE(NIOP,NISSP,0:NMP), ! Cost of capital for new vintage & IOVAL_STORE(NISP,NINP,0:NMP) ! Values in input-output table

Page 13: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

13

C***********************************************************************

SUBROUTINE ACCOUNT C This subroutine computes the information necessary to run the GOVT C and the HHOLD subroutines. C In addition, it keeps track of net receipts from international C carbon trading to Carb Price revenue C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' C Initialize arrays TRETE(L) = 0. DO IK = 1,10 HHINC(IK,L) = 0.0 END DO PINC(L) = 0. XITCTOT(L)=0. C calculate total carbon price receipts, first place estimated household and C government receipts into the array TAX(5,NIS-1,L) = TAXGOV(5,L) !gov carbon price TAX(5,NIS,L) = TAXCHH(L) !household carbon price TAX(5,NIS-2,L) = TAXCINV(L) !carbon price on investments DO IS = 1,NIS CRBPRICETOT(L,M) = CRBPRICETOT(L,M) + TAX(5,IS,L) END DO C Compute international carbon trading revenue IDUMMY=1 !Doesn't do anything, just needed for the function call TRADECARB(L,M) = CARBTRADE(IDUMMY) C take the hh, govt, invst tax receipts out of the trade estimate since C they were not included when ghgemiss ran for the tradecarb call IF (IPFIX(NIN-3,L,M) .EQ. .FALSE.) THEN TRADECARB(L,M) = TRADECARB(L,M) - TAXGOV(5,L) TRADECARB(L,M) = TRADECARB(L,M) - TAXCHH(L) TRADECARB(L,M) = TRADECARB(L,M) - TAXCINV(L) END IF CRBPRICETOT(L,M) = CRBPRICETOT(L,M) + TRADECARB(L,M) C CRBPRICETOT has the net revenue to the government (tax receipts net payments C to buy permits from other countries -or- plus receipts from permit sales) C . first compute corporate taxes, retained earnings, and dividends. C . . Compute sector investment tax credit. DO IO = 1,NIO XITCRATE = FIFGE(XITCR(IO),0,M,ITCPD) DO ISS = 1,NISS(IO,L) XITC(IO,L) = XITC(IO,L) + XITCRATE * KDEM(ISS,IO,M,L) END DO TEMP = RE(0,IO,L,M) * (1. - EXP(RE(1,IO,L,M) * P(NIN,L,M))) TAX(3,IO,L) = TAX(3,IO,L) + CITR(L,M) * PROF(IO,L) - XITC(IO,L) HHINC(1,L) = HHINC(1,L) + (PROF(IO,L)*(1. - CITR(L,M)) & + XITC(IO,L)) * (1. - TEMP) RETE(IO,L) = (PROF(IO,L)*(1. - CITR(L,M)) + XITC(IO,L)) * TEMP TRETE(L) = TRETE(L) + RETE(IO,L) XITCTOT(L) = XITCTOT(L) + XITC(IO,L) END DO C Recycle carbon price to producing sectors option: C 60% of domestic carbon price revenues and of C revenue from trade go to Industry Allocate_Carbprice: Select case (icrbtxopt) Case (0:3,5) !no action required

Page 14: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

14

Case (4) ! 60% of domestic carbon price and permit revenues to ind trete(l)=trete(l) + 0.6 * CRBPRICETOT(L,M) trete(l)=trete(l) + 0.6 * EXIBT(L,M) Case (6) ! CrbPriceRcyPct(3) of carbprice and permits goes to industry trete(l)=trete(l) + CrbPriceRcyPct(3) * CRBPRICETOT(L,M) trete(l)=trete(l) + CrbPriceRcyPct(3) * EXIBT(L,M) End select Allocate_Carbprice C . Compute employment offer at current wage rate ED(NIN-1,NIS,L,M) = 0. DO NG = 1,2 IF(LFIX(L,M).EQ.0) THEN ED(NIN-1,NIS,L,M) = ED(NIN-1,NIS,L,M) - WAGE(NG,L,M) & * LB(0,NG,L,M) * (1 - EXP((P(NIN-1,L,M) & / PI(NETE,IDEFS(NIS,1,L),L,M,1)) * LB(1,NG,L,M))) ELSE ED(NIN-1,NIS,L,M) = ED(NIN-1,NIS,L,M) - WAGE(NG,L,M) * & LFIX(L,M) END IF END DO SALES(1,NIN-1,L,M) = -ED(NIN-1,NIS,L,M) C . Labor income estimates based on labor supply HHINC(2,L) = HHINC(2,L) + (1. - SSTR(L,M)) * & (- ED(NIN-1,NIS,L,M)) * P(NIN-1,L,M) TAX(2,NIS,L) = TAX(2,NIS,L) + SSTR(L,M) * (- ED(NIN-1,NIS,L,M)) & * P(NIN-1,L,M) HHINC(5,L) = TAX(2,NIS,L) C . Compute number of households assuming there is a C . stable number of people per household. NHH(L,M) = POPLM(L,M) / LB(2,1,L,M) C . Compute land supply[Version 0.0 has only 1 type of land] ED(NIN-2,NIS,L,M) = - TLA(L,M) * R(0,L,M) & * (1. - EXP((P(NIN-2,L,M) & / PI(NETE,IDEFS(NIS,1,L),L,M,1)) * R(1,L,M))) SALES(1,NIN-2,L,M) = - ED(NIN-2,NIS,L,M) C . Compute land rent component of personal income. Based on Land Supply. C . Version 0.0 has one land type HHINC(3,L) = HHINC(3,L) + (- ED(NIN-2,NIS,L,M)) * P(NIN-2,L,M) C . Remove household land demand from household land supply ED(NIN-2,NIS,L,M) = ED(NIN-2,NIS,L,M) + NHH(L,M) * R(2,L,M) C . Personal income computation complete (government transfer untaxed) PINC(L) = HHINC(1,L) + HHINC(2,L) + HHINC(3,L) PERCAP(L,M) = PINC(L) / POPLM(L,M) EMPR(L,M) = (-ED(NIN-1,NIS,L,M)) & / (WAGE(1,L,M) + WAGE(2,L,M)) TAX(3,NIS,L) = TAX(3,NIS,L) + PINC(L) * PITR(L,M) HHINC(4,L) = TAX(3,NIS,L) PINC(L) = (1. - PITR(L,M)) * PINC(L) C . Add government transfers to PINC. Base on average per capita C . income, percent of population in young and old age groups, and C . fraction of population working. Government transfers assumed to C . be untaxed. GOVTR(L,M) = PI(NETE,IDEFS(NIS,1,L),L,M,1) & * (G(4,L,M) + POPLM(L,M) * G(0,L,M) & * PERCAP(L,M) ** G(1,L,M) & * EMPR(L,M) ** G(2,L,M)

Page 15: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

15

& * YNGOLD(L,M) ** G(3,L,M)) HHINC(6,L) = GOVTR(L,M) PINC(L) = PINC(L) + GOVTR(L,M) C . . Collect IBT taxes. DO IO = 1,NIO TAX(4,IO,L) = TXIBT(IO,L,M) * SALES(2,IO,L,M) END DO C Determine amount of ibt tax collected above base year C tax rates. EXIBT(L,M) = 0.0 DO IO=1,NIO EXIBT(L,M) = EXIBT(L,M) + SALES(2,IO,L,M) * & (TXIBT(IO,L,M) - TXIBT(IO,L,0)) END DO RETURN END

Page 16: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

16

C******************************************************************************

SUBROUTINE BANNER C THIS SUBROUTINE PRINTS A TITLE PAGE FOR THE PROGRAM WHICH IS C DISPLAYED BOTH WHILE DATA IS BEING READ IN AND WHILE THE C PROGRAM IS RUNNING. C C***********************************************************************

LOGICAL exists CHARACTER*50 LNote, LText CHARACTER*2800 LTXT(38) LNOTE = '..\exec\Legal Notice.txt'

LText = '..\exec\Legal_Text.csv' INQUIRE(FILE = LText, EXIST = exists) IF (exists) THEN Return ELSE Pause OPEN (991, FILE = LNOTE) Do i=1,37 Read (991,"(A72)") LTXT(i) Write (*,"(A72)") LTXT(i) enddo Write(*,*) Write(*,*)"ONE MAY ONLY LEGALLY PROCEED AFTER READING THE ABOVE & LICENSE AGREEMENT" Write(*,*) Write (*,*) " to CONFIRM AGREEMENT hit return" Write(*,*) Pause WRITE (*,*) OPEN (992, FILE = LText, ACCESS = 'APPEND') Write (992,*) "AGREEMENT HAS BEEN READ" Write (*,*) Pause Close (991) Close (992) END IF WRITE(*,'(1X,10X,''THE PROGRAM IS RUNNING''/)') RETURN END

Page 17: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

17

C**********************************************************************

SUBROUTINE BRNT C This subroutine computes the equilibrium price once bracketing values C for the price have been found. It relies on the Numerical Recipes C function zbrent C The zbrent function requires the following arguments C func, an external function, here: FUNCTION ExcessD C 'ExcessD' takes as an input the price in the market 'MRK' at C iteration 'ITR' and returns the excess demand 'EXD' in C the market 'MRK' at iteration 'ITR'. C x1, here: PRICE(MRK,ITR) C x2, here: PRICE(MRK,ITR-1) C tol, here: CNV * (PRICE(MRK,ITR) + PRICE(MRK,ITR-1)) / 2 C where PRICE(MRK,ITR+1) = zbrent(ExcessD,x1,x2,tol) C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' REAL*8 cnv,tol,AA,BB,CC,FAA,FBB,FCC,DD,EE,TOL1,EPS,PP,QQ, & RR,XM,SS PARAMETER (CNV = .000001, SMALL = .01) EXTERNAL ExcessD logical ifprint ifprint = .false. INN = MRKDEF(MRK,2) x1 = PRICE(MRK,ITR) x2 = PRICE(MRK,ITR-1) tol = CNV * (PRICE(MRK,ITR) + PRICE(MRK,ITR-1)) / 2 PRICE(MRK,ITR+1) = zbrent(ExcessD,x1,x2,tol) ITR = ITR + 1 EXD(MRK,ITR) = ExcessD(PRICE(MRK,ITR)) PROD(MRK,ITR) = MRKPRD(MRK) RETURN END

Page 18: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

18

C***********************************************************************

REAL*8 FUNCTION EXCESSD(PriceMrkItr) C The function'ExcessD' is passed by the BRNT subroutine to C call the zbrent function from NUMERICAL RECIPES. 'ExcessD' takes as C an input the price in the market 'MRK' at iteration 'ITR' and C returns the excess demand 'EXD' in the market 'MRK' at iteration 'ITR'. C***********************************************************************C INCLUDE 'COMMON.BLK' REAL*8 PriceMrkItr PRICE(MRK,ITR) = PriceMrkItr INN = MRKDEF(MRK,2) NR = MRKDEF(MRK,3) DO LL = 1,NR L = MRKDEF(MRK,3+LL) P(INN,L,M) = PRICE(MRK,ITR) END DO C . Now call model to get new excess demand CALL MODEL1 PROD(MRK,ITR) = MRKPRD(MRK) EXD(MRK,ITR) = MRKED(MRK) ExcessD = EXD(MRK,ITR) RETURN END C***********************************************************************

Page 19: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

19

Page 20: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

20

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C ZBRENT is a Numerical Recipes Function used here C C Using Brent’s method, find the root of a function func known to lie between x1 and x2. C The root, returned as zbrent, will be refined until its accuracy is tol. C Parameters: Maximum allowed number of iterations, and machine floating-point precision. C The zbrent function requires the following arguments C func, an external function, here: FUNCTION ExcessD C 'ExcessD' takes as an input the price in the market 'MRK' at C iteration 'ITR' and returns the excess demand 'EXD' in C the market 'MRK' at iteration 'ITR'. C x1, here: PRICE(MRK,ITR) C x2, here: PRICE(MRK,ITR-1) C tol, here: CNV * (PRICE(MRK,ITR) + PRICE(MRK,ITR-1)) / 2 C where PRICE(MRK,ITR+1) = zbrent(ExcessD,x1,x2,tol) C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C AN INDEPENDENT LICENCE NEEDS TO BE OBTAINED BY EVERY USER FROM NUMERICAL RECIPES C BEFORE USING Function XBRENT IN COMPILING THIS MODEL C SEE http://www.nr.com/com/storefront.html CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

REAL*8 FUNCTION ZBRENT(func,x1,x2,tol) END C (C) Copr. 1986-92 Numerical Recipes Software *********************************************************************************

Page 21: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

21

C**********************************************************************

SUBROUTINE CESCALC C C Subroutine to calculate CES coefficients using the input-output table, C vintaged capital data and elasticity of substitution data. C Also calculates CES coefficients for new technologies. C This subroutine enables the model to run without any calibration C precedure. Note: if introduction time, NTECHCHAR(5,...), is not base C year, then considered future technology and not included in base year C IO table. C C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' REAL*8 TOTAL, ! temporary total & DELTA, ! IO difference & RHO, ! rho & SIG, ! 1/(1-rho) & MU, ! rho/(1-rho) & PO(NIOP,NISSP,NLP), ! price received & RIOTOT(NDEFSP,NLP), ! total IO production & RINTOT(NINP,NLP), ! total IN demand & TEMP, ! temporary value & ALPHA, ! temporary value & ERROR ! error INTEGER*4 NVINI, ! temporary initial vintage & NVINF, ! temporary finial vintage & IVINT, ! temporary vintage & IRHO, ! index for rho & ICT, ! index for counting & ISST, ! temporary subsector index & ISSP, ! temporary subsector index & IP ! temporary index C . Calculate prices paid for base year(M=0). C . Prices paid for all inputs not including land, C . labor and capital are 1 in the base year. M = 0 DO IN = 1, NIO+1 P(IN,L,M) = 1.0 END DO C . Calculate total demand for each input. C . Do only for base year IO values as specified by ntechchar. DO IN = 1, NIN RINTOT(IN,L) = 0.0 DO IS = 1, NIS DO ISS = 1,NISS(IS,L) IF (IS .LE. NIO .AND. & NTECHCHAR(5,IDEF(IS,ISS,L),L,M).EQ.0) THEN RINTOT(IN,L) = RINTOT(IN,L) & + RIOVAL(IN,IDEFS(IS,ISS,L),L) ELSE IF (IS. GT. NIO) THEN RINTOT(IN,L) = RINTOT(IN,L) & + RIOVAL(IN,IDEFS(IS,ISS,L),L) END IF END DO END DO END DO C . Calculate prices paid for land, which is the total $ demand C . for land divided by the amount of land in use. P(NIN-2,L,M) = RINTOT(NIN-2,L)/ED(NIN-2,NIS,L,M) IF(P(NIN-2,L,M) .LT. 0.00001) THEN P(NIN-2,L,M) = 1.0 END IF C . Calculate prices paid for labor, which is the total $ demand C . for labor divided by the number employed.

Page 22: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

22

P(NIN-1,L,M) = RINTOT(NIN-1,L) / ED(NIN-1,NIS,L,M) C . Calculate total output for all subsectors. DO IS = 1, NIS DO ISS = 1, NISS(IS,L) RIOTOT(IDEFS(IS,ISS,L),L) = 0.0 DO IN = 1, NIN RIOTOT(IDEFS(IS,ISS,L),L) = & RIOTOT(IDEFS(IS,ISS,L),L) & + RIOVAL(IN,IDEFS(IS,ISS,L),L) END DO IF (IS. LE. NIO) & RIOTOT(IDEFS(IS,ISS,L),L) = & RIOTOT(IDEFS(IS,ISS,L),L) & + RIBT(IDEFS(IS,ISS,L),L) SVRIOTOT(IDEFS(IS,ISS,L),L)=RIOTOT(IDEFS(IS,ISS,L),L) END DO END DO C . Check balance of input-output table for the first ten C . inputs against the production. DO IN = 1, NIO TOTAL = 0.0 DO ISS = 1,NISS(IN,L) IF (NTECHCHAR(5,IDEF(IN,ISS,L),L,M).EQ.0) & TOTAL = TOTAL & + RIOTOT(IDEFS(IN,ISS,L),L) END DO IF (TOTAL.NE.0.0) THEN DELTA = ABS(RINTOT(IN,L)-TOTAL)/TOTAL IF (DELTA.GT.0.01) THEN WRITE(6,*)'IO not balanced to 1% for Region ',L,' Input ',IN WRITE(6,*)'IO balance off by ',DELTA END IF END IF END DO C . Calculation of CES coefficients. DO IO = 1, NIO DO ISS = 1, NISS(IO,L) IVIN = NTECHCHAR(5,IDEF(IO,ISS,L),L,M) C . Calculate price received for product IF (RIOTOT(IDEFS(IO,ISS,L),L).NE.0.0) & PO(IO,ISS,L) = (RIOTOT(IDEFS(IO,ISS,L),L) & - RIBT(IDEFS(IO,ISS,L),L))/ & RIOTOT(IDEFS(IO,ISS,L),L) RHO = A(NIN+1,IDEF(IO,ISS,L),IVIN,L) MU = RHO/(1-RHO) C . Calculate x(i) DO IN = 1, NIN-1 A(IN,IDEF(IO,ISS,L),IVIN,L) = & RIOVAL(IN,IDEFS(IO,ISS,L),L)/P(IN,L,M) END DO C . Calculate alpha(i);remember alpha(2) = 1 C . temp is x(2) TOTAL = 0.0 TEMP = A(2,IDEF(IO,ISS,L),IVIN,L) DO IN = 1, NIN-1 IF(RIOVAL(IN,IDEFS(IO,ISS,L),L).EQ.0.0) THEN A(IN,IDEF(IO,ISS,L),IVIN,L) = 0.0 ELSE TOTAL = TOTAL + & A(IN,IDEF(IO,ISS,L),IVIN,L)/ & TEMP*P(IN,L,M) A(IN,IDEF(IO,ISS,L),IVIN,L) = & (A(IN,IDEF(IO,ISS,L),IVIN,L)/ & TEMP)**(RHO/MU)* & P(IN,L,M)/P(2,L,M) END IF END DO C . Calculate A(0) coefficient;A(0) does not depend C . on capital stock but total output. IF (RIOTOT(IDEFS(IO,ISS,L),L).EQ.0.0) THEN A(0,IDEF(IO,ISS,L),IVIN,L) = 1.0 A(NIN+1,IDEF(IO,ISS,L),IVIN,L) = -1.0

Page 23: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

23

Z(IO,ISS) = 0.0 ELSE A(0,IDEF(IO,ISS,L),IVIN,L) = & (PO(IO,ISS,L)/P(2,L,M))** & (-1.0/RHO)* & RIOTOT(IDEFS(IO,ISS,L),L)**(-1.0/MU)* & TEMP**(1.0/MU) Z(IO,ISS) = 1 - & (A(0,IDEF(IO,ISS,L),IVIN,L)* & PO(IO,ISS,L))** MU * TOTAL END IF C . Sum all vintage capital stocks while checking C . lifetime and delayed investments. TOTAL = 0.0 NVINI = -3 IF (NTECHCHAR(1,IDEF(IO,ISS,L),L,M).LT.4) & NVINI = -3+4-NTECHCHAR(1,IDEF(IO,ISS,L),L,M) NVINF = NTECHCHAR(5,IDEF(IO,ISS,L),L,M) & - NTECHCHAR(2,IDEF(IO,ISS,L),L,M) DO IVINT = NVINI, NVINF TOTAL = TOTAL + & KAPRIOR(ISS,IO,IVINT,L) END DO C . Calculate A(k) coefficient;A(k) depends on C . capital stock and total output. IF (RIOTOT(IDEFS(IO,ISS,L),L).EQ.0.0 .OR. & TOTAL.EQ.0.0) THEN A(NIN,IDEF(IO,ISS,L),IVIN,L) = 0.0 ELSE A(NIN,IDEF(IO,ISS,L),IVIN,L) = & (RIOTOT(IDEFS(IO,ISS,L),L)/ & A(0,IDEF(IO,ISS,L),IVIN,L)/ & TOTAL)**RHO*Z(IO,ISS) END IF C . Reset capital stock to zero for new technologies C . and grades that do not exist in base year, but C . . . required capital stock for calculation of coefficients. IF (NTECHCHAR(5,IDEF(IO,ISS,L),L,M).NE.0) THEN DO IVINT = NVIN0, NVINF KAPRIOR(ISS,IO,IVINT,L) = 0.0 END DO END IF C introduce delays in investing in electricity technologies IF (io .eq. 8 .and. issDELAY(L,ISS) .gt. 0) THEN DO IVINT = NVIN0, NVINF KAPRIOR(ISS,IO,IVINT,L) = 0.0 END DO END IF C . Set capital stock to zero if lifetime has expired. C . This is normally fixed in the input data set. IF (NTECHCHAR(1,IDEF(IO,ISS,L),L,M).LT.4) THEN DO IVINT = NVIN0,-NTECHCHAR(1,IDEF(IO,ISS,L),L,M) KAPRIOR(ISS,IO,IVINT,L) = 0.0 END DO END IF C . Normalize all A coefficients TOTAL = 0.0 DO IN = 1, NIN TOTAL = TOTAL + & A(IN,IDEF(IO,ISS,L),IVIN,L) END DO IF (TOTAL.NE.0.0) THEN DO IN = 1, NIN A(IN,IDEF(IO,ISS,L),IVIN,L) = & A(IN,IDEF(IO,ISS,L),IVIN,L)/ & TOTAL*100.0 END DO A(0,IDEF(IO,ISS,L),IVIN,L) = & A(0,IDEF(IO,ISS,L),IVIN,L)*

Page 24: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

24

& (TOTAL/100.0)**(1.0/RHO) END IF C . Set previous vintage coefficients equal C . to the base year coefficients. For new technologies C . report coefficients for introduction period. IF (NTECHCHAR(5,IDEF(IO,ISS,L),L,M).EQ.0) THEN IF (NTECHCHAR(1,IDEF(IO,ISS,L),L,M).LT.4) & THEN NVINI = -3+4-NTECHCHAR(1,IDEF(IO,ISS,L),L,M) ELSE NVINI = -3 END IF ELSE NVINI = NVINF END IF NVINF = NTECHCHAR(5,IDEF(IO,ISS,L),L,M) DO IVINT = NVINI, NVINF-1 DO IN = 0, NIN+1 A(IN,IDEF(IO,ISS,L),IVINT,L) = & A(IN,IDEF(IO,ISS,L),IVIN,L) END DO END DO END DO !end of iss loop END DO !end of io loop C . Calculate total population in 1985 for use in C . calibration. POPLM(L,0) = 0.0 DO NA = 1, NAGE DO NG = 1,2 POPLM(L,0) = POPLM(L,0)+POPGCLM(NG,NA,L,0) END DO END DO C . Calculation of PRCONVRTs, which is a conversion factor C . from currency to energy. Total currency output C . divided by quantity of energy production. Amount of C . energy produced (for the appropriate sectors) are read C . in as data. PRCONVRTs for non-energy sectors are set C . to 1. C PRCONVRTs for carbon market set to 1 for trade in Model PRCONVRT(NIN-3,L)=1.0 C . Calculation of GC, the relative inputs of government C . demand. DO ISS = 1, NISS(NIS-1,L) DO IN = 1, NIN GC(IN,ISS,L,0)=RIOVAL(IN,IDEFS(NIS-1,ISS,L),L) & / RIOTOT(IDEFS(NIS-1,ISS,L),L) & / P(IN,L,0) DO M = 0, NM GC(IN,ISS,L,M) = GC(IN,ISS,L,0) END DO END DO END DO C . Calculation of GF, government preference function. C . Read-in RHO for government and calculate the rest C . of GF. The GF parameters are calculated using the C . Gauss-Seidel method. IRHO = NISS(NIS-1,L)+1 RHO = GF(IRHO,L,0) SIG = 1.0/(1.0-RHO) GOVMT(L,0) = 0.0 DO ISS = 1, NISS(NIS-1,L) GF(ISS,L,0) = 1.0 ! initial approximation GOVMT(L,0) = GOVMT(L,0) + & RIOTOT(IDEFS(NIS-1,ISS,L),L) END DO IF (NISS(NIS-1,L).GT.1) THEN ERROR = 1.0 ICT = 0 DO WHILE(ERROR.GT.0.0001 .OR. ICT.LT.20) TOTAL = 0.0

Page 25: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

25

DO ISS = 1, NISS(NIS-1,L) IP = 0 ISSP = 0 TEMP = 0.0 ISSP = ISS DO IREP = 1, NISS(NIS-1,L)-1 ISST = ISSP + 1 IF(ISST.GT.NISS(NIS-1,L)) THEN ISST = 1 + IP IP = IP + 1 END IF TEMP = TEMP + GF(ISST,L,0)**SIG ISSP = ISSP + 1 END DO ALPHA = RIOTOT(IDEFS(NIS-1,ISS,L),L) & / GOVMT(L,0) GF(ISS,L,0) = (ALPHA/(1-ALPHA) & * TEMP)**(1.0/SIG) TOTAL = TOTAL + GF(ISS,L,0)**SIG END DO ERROR = 0.0 DO ISS = 1, NISS(NIS-1,L) GE(ISS,L,0) = GOVMT(L,0)*GF(ISS,L,0)**SIG & / TOTAL ERROR = ERROR & + ABS(RIOTOT(IDEFS(NIS-1,ISS,L),L) & - GE(ISS,L,0)) & / RIOTOT(IDEFS(NIS-1,ISS,L),L) END DO ICT = ICT + 1 END DO ! do while loop END IF DO ISS = 1, NISS(NIS-1,L) DO M = 0, NM GF(ISS,L,M) = GF(ISS,L,0) END DO END DO C . Calculation of Labor Supply Function parameters. DO NG = 1,2 IF(LFIX(L,0).EQ.0) THEN LB(1,NG,L,0) = LOG(1.0 - ED(NIN-1,NIS,L,0) & /((WAGE(1,L,0)+WAGE(2,L,0))*LB(0,NG,L,0))) & /P(NIN-1,L,0) ELSE LB(1,NG,L,0) = ED(NIN-1,NIS,L,0) / & (WAGE(1,L,0) + WAGE(2,L,0)) END IF END DO LB(2,1,L,0) = POPLM(L,0)/NHH(L,0) ! people per household LB(2,2,L,0) = RIOVAL(NIN-1,IDEFS(NIS,1,L),L) & /(ED(NIN-1,NIS,L,0)*P(NIN-1,L,0)) DO NG = 1,2 DO M = 0, NM LB(1,NG,L,M) = LB(1,NG,L,0) LB(2,NG,L,M) = LB(2,NG,L,0) END DO END DO C . Calculation of Land Supply Function coefficients. C . R(0) maximum useable land; read-in data. R(1,L,0) = LOG(1.0 - (ED(NIN-2,NIS,L,0)/TLA(L,0)/R(0,L,0))) & /P(NIN-2,L,0) R(2,l,0) = RIOVAL(NIN-2,IDEFS(NIS,1,L),L) & /(NHH(L,0)*P(NIN-2,L,0)) DO M = 0, NM R(0,L,M) = R(0,L,0) R(1,L,M) = R(1,L,0) R(2,L,M) = R(2,L,0) END DO C . Calculation of Retained Earnings parameter. C . RE(0) maximum retained earnings; read-in data. C . TRETE total retained earnings is read-in for calibration.

Page 26: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

26

DO IO = 1, NIO RE(1,IO,L,0) = LOG(1.0 - TRETE(L)/(RINTOT(NIN,L) & * RE(0,IO,L,0) * (1.0-CITR(L,0)))) & / P(NIN,L,0) DO M = 0, NM RE(0,IO,L,M) = RE(0,IO,L,0) RE(1,IO,L,M) = RE(1,IO,L,0) END DO END DO C . Calculation of Personal Income. HHINC(1,L) = 0.0 PINC(L) = 0.0 C . Retained earnings income DO IO = 1,NIO TEMP = RE(0,IO,L,0)*(1.0 - EXP(RE(1,IO,L,0) * P(NIN,L,0))) TOTAL = 0.0 DO ISS = 1, NISS(IO,L) IF (NTECHCHAR(5,IDEF(IO,ISS,L),L,0).EQ.0) & TOTAL = TOTAL + RIOVAL(NIN,IDEFS(IO,ISS,L),L) END DO HHINC(1,L) = HHINC(1,L) + (TOTAL & * (1.0 - CITR(L,0)) & + XITC(IO,L)) * (1.0 - TEMP) END DO C . Labor income. HHINC(2,L) = (1.0 - SSTR(L,0)) * & ED(NIN-1,NIS,L,0) * P(NIN-1,L,0) C . Land rent income. HHINC(3,L) = ED(NIN-2,NIS,L,0) * P(NIN-2,L,0) PINC(L) = HHINC(1,L) + HHINC(2,L) + HHINC(3,L) C . Subtract income tax from personal income. PINC(L) = (1.0 - PITR(L,0)) * PINC(L) C . Calculate government transfer to household. Simplify the C . government transfer so that it is a function of population C . and the G(0) parameter only. G(4) is set to zero. The actual C . govt transfer for 1985 is a data read-in. G(0,L,0) = GOVTR(L,0)/POPLM(L,0) G(1,L,0) = 0.0 G(2,L,0) = 0.0 G(3,L,0) = 0.0 G(4,L,0) = 0.0 DO M = 0, NM G(0,L,M) = G(0,L,0) G(1,L,M) = G(1,L,0) G(2,L,M) = G(2,L,0) G(3,L,M) = G(3,L,0) G(4,L,M) = G(4,L,0) END DO M = 0 GOVTR(L,M) = G(4,L,M) + POPLM(L,M) * G(0,L,M) PINC(L) = PINC(L) + GOVTR(L,M) C . Calculation of the Savings function parameters. C . ED(NIN,NIS,L,M) is household savings and is a negative C . value in HHOLD.F, but positive here for calibration. S(1,L,0) = 1.0 S(2,L,0) = LOG(1.0 - ED(NIN,NIS,L,0)/(PINC(L)*S(0,L,0))) & / P(NIN,L,0) DO M = 0, NM S(0,L,M) = S(0,L,0) S(1,L,M) = S(1,L,0) S(2,L,M) = S(2,L,0) END DO C . Calculation of the Household Demand Function Scaler. C . ED(NIN,NIS,L,M) is household savings and is a negative C . value in HHOLD.F, but positive here for calibration.

Page 27: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

27

PINC(L) = PINC(L) - ED(NIN,NIS,L,0) DO ISS = 1, NISS(NIS,L) DO IN = 1, NIO E(0,IN,L,0) = RIOVAL(IN,IDEFS(NIS,ISS,L),L) & /(PINC(L)**E(1,IN,L,0) & *P(IN,L,0)**E(2,IN,L,0)) DO M = 0, NM E(0,IN,L,M) = E(0,IN,L,0) END DO END DO END DO M = 0 P(NIN-3,L,M) = 0.0 RETURN END

Page 28: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

28

C***********************************************************************

SUBROUTINE CARBONPRICE C Set carbon limit or permit price depending on CARBPRICEP options C . CARBPRICEP(1,L) = 0 no carbon price C . CARBPRICEP(1,L) = 1 some kind of carbon price C . CARBPRICEP(2,L) = 0 fixed carbon price C . CARBPRICEP(2,L) = 1 carbon price set to reach emissions goal(variable tax) C . CARBPRICEP(3,L) = 0 only CO2 emissions used to compute limit C . CARBPRICEP(3,L) = 1 all Carbon emissions used to compute limit C . CARBPRICEP(4,L) = 0 external carbon emissions limit C . CARBPRICEP(4,L) = 1 internal carbon emissions limit C . CARBPRICEP(5,L) = reference period for carbon emissions limit(eg 1 = 1990) C . CARBPRICEP(6,L) = initial period for carbon price to apply(must be after reference C . period. C . CARBDATA(1,L,M) = Tax rate for fixed tax(must be entered for each period). C . CARBDATA(2,L,M) = Emissions limit for external limit C . CARBDATA(3,L,M) = Fraction of reference period for emissions limit C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' IF (CARBPRICEP(1,L).EQ.0 .OR. M.LT.CARBPRICEP(6,L)) THEN !if no C prices IPFIX(NIN-3,L,M) = .TRUE. CARBONLIM(L,M) = 0.0 C For mixed trading cases, set carbon limit for Non-Annex I regions P(NIN-3,L,M) = 0.0 !0 for the prices when they are computed in getcfee RETURN END IF C if a sequestration offset is used we need C to get the allowable increase in emissions through the offset lookup table if (iseqsw(l) .eq. 1) then if (P(NIN-3,L,M) .gt.400.d0) then !avoid getting beyond the highest Cprice EmSave(l,m) = Emseq(L,401,4) + 0.001 EmSqPSav(l,m) = EmSeqP(L,401) else DO IP = 2,400 !start with the non-zero Cprice if (P(NIN-3,L,M) .lt. EmSeqP(L,IP) & .and.P(NIN-3,L,M) .ge. EmSeqP(L,IP-1)) then & EmSave(L,M) = (P(NIN-3,L,M)-EmSeqP(L,IP-1)) & / (EmSeqP(L,IP)-EmSeqP(L,IP-1)) & * (EmSeq(L,IP,4)-EmSeq(L,IP-1,4)) & + EmSeq(L,IP-1,4) iip = ip EmSav = EmSave(L,M) EmSqPSav(l,m) = P(NIN-3,L,M) Cycle end if END DO End if End if IF (CARBPRICEP(1,L) .EQ. 1) THEN !if we are using carbon prices IF (CARBPRICEP(2,L) .EQ. 0) THEN C . Fixed carbon price option IPFIX(NIN-3,L,M) = .TRUE. P(NIN-3,L,M) = CARBDATA(1,L,M) !fix price at the one that was read CARBONLIM(L,M) = 0.0 ELSE C . Variable carbon price options IPFIX(NIN-3,L,M) = .FALSE. !allow model to solve for carbon price IF (P(NIN-3,L,M) .LE. 0.0) THEN C . Get a positive value for P so solve won't fail P(NIN-3,L,M) = 0.1 END IF IF (CARBPRICEP(4,L) .EQ. 0) THEN

Page 29: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

29

C . User supplied limit if (iseqsw(l) .eq. 1) then CARBONLIM(L,M) = CARBDATA(2,L,M) + EmSave(l,m) else ! Iseqsw = 0 branch CARBONLIM(L,M) = CARBDATA(2,L,M) end if ELSE C . Endogenous emissions limit IREF = CARBPRICEP(5,L) if (iseqsw(l).eq.1) then CARBONLIM(L,M) = EMTOT(L,IREF) * CARBDATA(3,L,M) & + EmSave(l,m) ! else ! Iseqsw = 0 branch CARBONLIM(L,M) = EMTOT(L,IREF) * CARBDATA(3,L,M) end if END IF END IF END IF RETURN END

Page 30: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

30

C***********************************************************************

REAL*8 FUNCTION CARBTRADE(IDUM) C C Function to return the net carbon trading revenues. C C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' c If you are not in a carbon trading market, set trade to C exogenous trade (which is zero if not read in) and return IF(MKTLINK(NIN-3,L).EQ.0 .OR. M.EQ.0) THEN CARBTRADE=CRBTREXO(L,M) RETURN END IF CALL GHGEMIS !get emissions C Get net trading revenue: permit price * (limit - emissions) CARBTRADE = P(NIN-3,L,M)*EXCHRATE(L)* & (CARBONLIM(L,M) - EMTOT(L,M)) RETURN END

Page 31: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

31

Page 32: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

32

C***********************************************************************

SUBROUTINE IVID(pct,psct,idx,lstr,ustr) C Sub called once for each variable to be written, assigns it a varid C and an index for the array to hold all output and writes it to the master table C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' INTEGER varid, pct, psct, idx CHARACTER*(*) lstr, ustr 200 FORMAT(I6,4(1h,,A)) c assign a 6 digit varid to the item varid = pct*10000+psct*100+idx IF (vl(pct,psct,idx).ne.0) THEN WRITE(6,*) 'PCT ', PCT,'PSCT ', PSCT,'IDX ',IDX PAUSE 'Duplicate VarID:' END IF c print the varid table entry for the item WRITE(108,200) varid, ctstr(pct), sctstr(pct,psct), &lstr, ustr c assign the varid to the next available array index dbaridx = dbaridx + 1 vl(pct,psct,idx) = dbaridx rvl(dbaridx) = varid RETURN END C***********************************************************************

SUBROUTINE DBOUT C main database output subroutine C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' INCLUDE 'DB_DATA.BLK' Parameter (nmdbase = 12) ! set data base to run to 2050 at most REAL*8 DEMAND(NIN,NIS,0:NMdbase), DBAR(3000,0:NMdbase), & DBARG(3000,0:NMdbase),Zero(0:nmdbase) REAL*8 TMPOUT(0:NMdbase) !temp storage for a vector of values by period REAL*8 TMPOUT2(0:NMdbase) !temp storage for a vector of values by period REAL*8 TMPEMISS(0:NMdbase) !temp storage for a vector of values by period INTEGER RunID, vidx, ct, sct, LORDER(NL) LOGICAL vp, exists !vp is if to print out a varid file CHARACTER*50 dboutfile, dbinfofile, varinfo INTEGER(2) tmpday, tmpmonth, tmpyear INTEGER(2) tmphour, tmpminute, tmpsecond, tmphund CHARACTER*40 INNAME(NIN), ISNAME(NIS), GASLBL(NGSP) CHARACTER*2 INTTOCHAR(0:10) REAL*8 TempSum INTTOCHAR = (/'0','1','2','3','4','5','6','7','8','9','10'/) GASLBL = (/'CO2','CH4','N2O','HFC-23','PFC','SF6', & 'HFCs',' ',' ',' ',' '/) !gas labels Zero = 0 c determine RunID CALL GETDAT(tmpyear, tmpmonth, tmpday) CALL GETTIM(tmphour, tmpminute, tmpsecond, tmphund) RunID = tmpsecond + 100 * tmpminute + 10000 * tmphour + & 1000000 * tmpday + 100000000 * tmpmonth c hardcoded path and file names for database output files

Page 33: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

33

dboutfile = '..\outputs\dbout.csv' dbinfofile = '..\outputs\dbruninfo.csv' varinfo = '..\outputs\dbvarinfo.csv' c See if we are appending or starting a new db buffer INQUIRE(FILE = dboutfile, EXIST = exists) IF (exists) THEN OPEN (110, FILE = dboutfile, ACCESS = 'APPEND') ELSE OPEN (110, FILE = dboutfile) WRITE(110,92) (1990 + MM * 5, MM=0,NMdbase) !write field names END IF 92 FORMAT('RunID,','Region,','VarID',13(',y',I4)) c ** Write to the run information database ** INQUIRE(FILE = dbinfofile, EXIST = exists) IF (exists) THEN OPEN (109, FILE = dbinfofile, ACCESS = 'APPEND') ELSE OPEN (109, FILE = dbinfofile) WRITE(109,91) !91 just has the field names for the first line END IF WRITE(109,90) RunID,CASENAME,CASENOTE,FILES(1:INFILES) CLOSE (109) c ** Close the run information database ** 91 FORMAT('RunID',1H,,'RunLabel',1H,,'RunComments',1H,,'Field4',1H,, &'Field5',1H,, &'Field6',1H,,'Field7',1H,,'Field8',1H,,'Field9',1H,,'Field10',1H,, &'Field11',1H,,'Field12',1H,, &'Field13',1H,,'Field14',1H,,'Field15',1H,,'Field16',1H,,'Field17', &1H,,'Field18',1H,, &'Field19',1H,,'Field20',1H,,'Field21',1H,,'Field22',1H,,'Field23', &1H,,'Field24',1H,, &'Field25',1H,,'Field26',1H,,'Field27',1H,,'Field28',1H,,'Field29', &1H,,'Field30',1H,, &'Field31',1H,,'Field32',1H,,'Field33') 90 FORMAT(1I10,1H,,1A20,1H,,1A100,30(1H,,1A50)) 100 FORMAT(I10,',',I4,',',1I6,13(',',F20.5)) c INITIALIZATION DBARG = 0.0 !initialize global totals vl = 0 rvl = 0 dbaridx = 0 c reorder the regions so the US can go first (establishing the master c list of variable id's) LORDER = MRKDEF(0,4:3+NL) !the "standard" region order determined by mkt 0 DO II = 1, NL IF (LORDER(II).EQ.11) THEN !swap the US and the first region ITMP = LORDER(1) LORDER(II) = ITMP LORDER(1) = 11 EXIT END IF END DO DO 850 II=1,NL !REGION DO LOOP L = LORDER(II) c ------------------------------------------------------------------------------------ c Begin database output format code regional loop c ------------------------------------------------------------------------------------ DBAR = 0.0 !initialize DBAR c Here's the usual code block to get the physical demand table c this also appears in ebal, ghg, and outexcel in similar forms DO IN = 1, NIN DO IS = 1, NIS DEMAND(IN,IS,:) = ED(IN,IS,L,0:NM) IF (IN .LE. NIO .AND. IN .EQ. IS) THEN DEMAND(IN,IS,:) = DEMAND(IN,IS,:) + SALES(1,IS,L,0:NM) END IF IF (IN .LE. NIO) THEN DEMAND(IN,IS,:) = DEMAND(IN,IS,:) * PRCONVRT(IN,L) END IF

Page 34: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

34

END DO END DO c conversion to different phys units on electric - prconvrt issues... TMPOUT = TOTPRD(8,L,0:NM) / SUM(ELECGEN(1:NISS(8,L),L,0:NM),DIM=1) DO IS = 1, NIS DEMAND(8,IS,:) = DEMAND(8,IS,:)/TMPOUT END DO c NOTE *** production numbers etc. no longer match DEMAND... c this fix is mostly for c the reporting of electricity consumption so it matches the old sgmgen... c set up complete arrays of input and sector names for making labels later INNAME(1:NIN) = (/SECNAME(1:NIO,L),'Carb','Land','Labor', & 'Capital'/) ISNAME(1:NIS) = (/SECNAME(1:NIO,L),'Carb','Trade', & 'Invest','Govt','Household'/) vp = .FALSE. IF (L.EQ.11.OR.NL.EQ.1) vp = .TRUE. IF(vp) THEN OPEN (108, FILE = varinfo) WRITE(108,300) END IF 300 FORMAT('VarID,','Cat,','SubCat,','VarLabel,','VarUnits') c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 10 ctstr(ct) = 'Emissions' sct = 01 ! by driver, CE weight sctstr(ct,sct) = 'All CE' DO I = 1, NSOURCE(L) IF(vp)CALL ivid(ct,sct,I,EMCLABEL(I,L),'MMTCE') DBAR(vl(ct,sct,I),:) = EM(I,L,0:NM) END DO sct = 02 ! by driver, gas weight sctstr(ct,sct) = 'All GasWght' DO I = 1, NSOURCE(L) IF(vp)CALL ivid(ct,sct,I,EMCLABEL(I,L),'Tg Gas') DBAR(vl(ct,sct,I),:) = EM(I,L,0:NM)/GWP(EMC(I,3,L),L,0:NM) END DO sct = 11 ! by gas, CE weight sctstr(ct,sct) = 'ByGas CE' DO I = 1, NGAS TMPOUT = 0 DO IX = 1, NSOURCE(L) IF (EMC(IX,3,L) .EQ. I) THEN TMPOUT = TMPOUT + EM(IX,L,0:NM) END IF END DO IF(vp)CALL ivid(ct,sct,I,GASLBL(I),'MMTCE') DBAR(vl(ct,sct,I),:) = TMPOUT END DO sct = 12 ! by gas, CE weight sctstr(ct,sct) = 'ByGas GasWght' DO I = 1, NGAS TMPOUT = 0 DO IX = 1, NSOURCE(L) IF (EMC(IX,3,L) .EQ. I) THEN TMPOUT = TMPOUT + EM(IX,L,0:NM)/GWP(I,L,0:NM) END IF END DO IF(vp)CALL ivid(ct,sct,I,GASLBL(I),'MMTCE') DBAR(vl(ct,sct,I),:) = TMPOUT END DO sct = 50 !totals sctstr(ct,sct) = 'Totals' IF(vp)CALL ivid(ct,sct,1,'ModelEms','MMTCE')

Page 35: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

35

IF(vp)CALL ivid(ct,sct,2,'ContrldEms','MMTCE') IF(vp)CALL ivid(ct,sct,3,'ModEms-Seq','MMTCE') DBAR(vl(ct,sct,1),:) = SUM(EM(:,L,0:NM),DIM=1) DBAR(vl(ct,sct,2),:) = EMTOT(L,0:NM) DBAR(vl(ct,sct,3),:) = SUM(EM(:,L,0:NM),DIM=1)-1.D0*EmSave(L,0:NM) sct = 51 !Total GHG CE Emissions Targets sctstr(ct,sct) = 'Targets' IF(vp)CALL ivid(ct,sct,1,'Emiss. Targ.','MMTCE') DBAR(vl(ct,sct,1),:) = EMTARGET(L,0:NM) sct = 52 !miss distance sctstr(ct,sct) = 'Miss Dist' TMPOUT = 0 TMPOUT2 = 0 TMPEMISS= SUM(EM(:,L,0:NM),DIM=1)-1.D0*EmSave(L,0:NM) IF (CARBPRICEP(1,L) .EQ. 1) THEN ! add emissions to target if carbon policy exists TMPOUT(CARBPRICEP(6,L):NM) = & TMPOUT(CARBPRICEP(6,L):NM) & + TMPEMISS(CARBPRICEP(6,L):NM) TMPOUT2(CARBPRICEP(6,L):NM) = & TMPOUT2(CARBPRICEP(6,L):NM) & + EMTARGET(L,CARBPRICEP(6,L):NM) END IF IF(vp)CALL ivid(ct,sct,1,'Targ. Miss','MMTCE') DBAR(vl(ct,sct,1),:) = TMPOUT - TMPOUT2 sct = 61 ! by sector, CE weight sctstr(ct,sct) = 'All CE' DO I = 1, NIO TMPOUT = 0 DO IX = 1, NSOURCE(L) IF (EMC(IX,4,L) .EQ. I) THEN TMPOUT = TMPOUT + EM(IX,L,0:NM) END IF END DO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'MMTCE') DBAR(vl(ct,sct,I),:) = TMPOUT END DO sct = 62 ! by sector, CO2 only sctstr(ct,sct) = 'CO2 CE' DO I = 1, NIO TMPOUT = 0 DO IX = 1, NSOURCE(L) IF (EMC(IX,4,L) .EQ. I .AND. EMC(IX,3,L).EQ.1) THEN TMPOUT = TMPOUT + EM(IX,L,0:NM) END IF END DO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'MMTCE') DBAR(vl(ct,sct,I),:) = TMPOUT END DO sct = 63 ! by sector, NonCO2 CE sctstr(ct,sct) = 'NonCO2 CE' DO I = 1, NIO TMPOUT = 0 DO IX = 1, NSOURCE(L) IF (EMC(IX,4,L) .EQ. I .AND. EMC(IX,3,L).GT.1) THEN TMPOUT = TMPOUT + EM(IX,L,0:NM) END IF END DO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'MMTCE') DBAR(vl(ct,sct,I),:) = TMPOUT END DO sct = 64 ! by end use sector, CO2 sctstr(ct,sct) = 'CO2enduse' DO I = 1, NIOP IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'MMTCE') DBAR(vl(ct,sct,I),:) = IOemisCO2(I,0:NM,L) END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Page 36: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

36

ct = 70 ctstr(ct) = 'NonCO2 TAC' sct = 01 ! by driver, 90$ sctstr(ct,sct) = 'driver ' DO I = 1, NSOURCE(L) IF(vp)CALL ivid(ct,sct,I,EMCLABEL(I,L),'90$') DBAR(vl(ct,sct,I),:) = TAC(I,L,0:NM) END DO sct = 11 ! by gas, 90$ sctstr(ct,sct) = 'ByGas ' DO I = 1, NGAS TMPOUT = 0 DO IX = 1, NSOURCE(L) IF (EMC(IX,3,L) .EQ. I) THEN TMPOUT = TMPOUT + TAC(IX,L,0:NM) END IF END DO IF(vp)CALL ivid(ct,sct,I,GASLBL(I),'90$') DBAR(vl(ct,sct,I),:) = TMPOUT END DO sct = 50 !totals sctstr(ct,sct) = 'Totals' IF(vp)CALL ivid(ct,sct,1,'NonCO2Ems','90$') DBAR(vl(ct,sct,1),:) = SUM(TAC(:,L,0:NM),DIM=1) c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 80 ctstr(ct) = 'Targets' sct = 01 !Total GHG CE Emissions Targets sctstr(ct,sct) = 'Target' IF(vp)CALL ivid(ct,sct,1,'CE Emissions','MMMTCE') DBAR(vl(ct,sct,1),:) = EMTARGET(L,0:NM) c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 11 ctstr(ct) = 'MitiTechs' c first write all the possible labels, for multiregion runs this c uses the US em driver set as the master list sctstr(ct,01) = 'JointPr' sctstr(ct,02) = 'Invst' sctstr(ct,03) = 'O&M1' sctstr(ct,04) = 'O&M2' sctstr(ct,05) = 'O&M3' sctstr(ct,06) = 'O&M4' sctstr(ct,10) = 'PctMit' sctstr(ct,11) = 'CarbCap' IF(vp) THEN DO IX = 1, NSOURCE(L) IF (EMT(IX,1,1,L) .LE. 0.0 .AND. JEMTSIMP(IX,L) .EQ. 0) CYCLE CALL ivid(ct,01,IX,EMCLABEL(IX,L),'90 $') CALL ivid(ct,02,IX,EMCLABEL(IX,L),'90 $') CALL ivid(ct,03,IX,EMCLABEL(IX,L),'90 $') CALL ivid(ct,04,IX,EMCLABEL(IX,L),'90 $') CALL ivid(ct,05,IX,EMCLABEL(IX,L),'90 $') CALL ivid(ct,06,IX,EMCLABEL(IX,L),'90 $') CALL ivid(ct,10,IX,EMCLABEL(IX,L),'%Rdx') CALL ivid(ct,11,IX,EMCLABEL(IX,L),'TgGas') END DO END IF DO IX = 1, NSOURCE(L) IF (EMT(IX,1,1,L) .LE. 0.0 .AND. JEMTSIMP(IX,L) .EQ. 0) CYCLE DBAR(vl(ct,01,IX),:) = EMTACNT(IX,1,L,0:NM) DBAR(vl(ct,02,IX),:) = EMTACNT(IX,2,L,0:NM) DBAR(vl(ct,03,IX),:) = EMTACNT(IX,3,L,0:NM) DBAR(vl(ct,04,IX),:) = EMTACNT(IX,4,L,0:NM) DBAR(vl(ct,05,IX),:) = EMTACNT(IX,5,L,0:NM) DBAR(vl(ct,06,IX),:) = EMTACNT(IX,6,L,0:NM) DBAR(vl(ct,10,IX),:) = EMTINTRP(IX,1,L,0:NM) DBAR(vl(ct,11,IX),:) =(EM(IX,L,0:NM)/(1.0-EMTINTRP(IX,1,L,0:NM))

Page 37: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

37

& -EM(IX,L,0:NM)) / GWP(EMC(IX,3,L),L,0:NM) END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 20 ctstr(ct) = 'Production' sct = 01 ! phys/local sctstr(ct,sct) = 'Sector' DO I = 1,NIO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'Phys/local') DBAR(vl(ct,sct,I),:) = TOTPRD(I,L,0:NM) END DO sct = 02 ! 90 $ sctstr(ct,sct) = 'Sector' DO I = 1,NIO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'90 $') DBAR(vl(ct,sct,I),:) = SALES(1,I,L,0:NM) / EXCHRATE(L) END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 21 ctstr(ct) = 'Consumption' sct = 01 ! phys/local sctstr(ct,sct) = 'Sector' DO I = 1,NIO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'Phys/local') DBAR(vl(ct,sct,I),:) = EDEM(I,L,0:NM) END DO sct = 02 ! 90 $ sctstr(ct,sct) = 'Sector' DO I = 1,NIO IF(vp)CALL ivid(ct,sct,I,SECNAME(I,L),'90 $') DBAR(vl(ct,sct,I),:) =(EDEM(I,L,0:NM)/PRCONVRT(I,L))/EXCHRATE(L) END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 22 ctstr(ct) = 'Investment' sct = 01 ! phys/local sctstr(ct,sct) = 'Sector' DO IS = 1, NIO DO ISS = 1, NISS(IS,L) IF(vp)CALL ivid(ct,sct,IDEFS(IS,ISS,L),TECHNAME(IS,ISS,L), & 'Phys/local') DBAR(vl(ct,sct,IDEFS(IS,ISS,L)),:) = KDEM(ISS,IS,0:NM,L) END DO END DO sct = 02 ! 90 $ sctstr(ct,sct) = 'Sector' DO IS = 1, NIO DO ISS = 1, NISS(IS,L) IF(vp)CALL ivid(ct,sct,IDEFS(IS,ISS,L),TECHNAME(IS,ISS,L), & '90 $') DBAR(vl(ct,sct,IDEFS(IS,ISS,L)),:) = KDEM(ISS,IS,0:NM,L) & / EXCHRATE(L) END DO END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 23 ctstr(ct) = 'Capital Stock' sct = 01 ! 90 $ sctstr(ct,sct) = 'Sector' DO IS = 1, NIO DO ISS = 1, NISS(IS,L) IF(vp)CALL ivid(ct,sct,IDEFS(IS,ISS,L),TECHNAME(IS,ISS,L), & '90 $')

Page 38: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

38

DBAR(vl(ct,sct,IDEFS(IS,ISS,L)),:) = KA_STORE(ISS,IS,0:12) END DO END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 24 ctstr(ct) = 'Cost of Capital' sct = 01 ! 90 $ sctstr(ct,sct) = 'Sector' DO IS = 1, NIO DO ISS = 1, NISS(IS,L) IF(vp)CALL ivid(ct,sct,IDEFS(IS,ISS,L),TECHNAME(IS,ISS,L), & 'ratio') DBAR(vl(ct,sct,IDEFS(IS,ISS,L)),:) = COSTK_STORE(IS,ISS,0:12) END DO END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 25 ctstr(ct) = 'Profits' sct = 01 ! 90 $ sctstr(ct,sct) = 'Sector' DO IS = 1, NIO DO ISS = 1, NISS(IS,L) IF(vp)CALL ivid(ct,sct,IDEFS(IS,ISS,L),TECHNAME(IS,ISS,L), & 'values') DBAR(vl(ct,sct,IDEFS(IS,ISS,L)),:) =PROFITS_STORE(IS,ISS,0:12) END DO END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 26 ctstr(ct) = 'Prices' sct = 01 sctstr(ct,sct) = 'Input' DO I = 1, NIN IF(vp)CALL ivid(ct,sct,I,INNAME(I),'market') DBAR(vl(ct,sct,I),:) = P(I,L,0:NM) END DO sct = 02 !pricepaid by electricity sector sctstr(ct,sct) = 'PrPd Elec' DO I = 1, NIO IF(vp)CALL ivid(ct,sct,I,INNAME(I),'paid') DBAR(vl(ct,sct,I),:) = PPDELEC(I,L,0:NM) END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 30 ctstr(ct) = 'GNP Comp' C Don't use a deflator if one has not been read in for region IF(DEFLATOR(L).LT.0.0001) DEFLATOR(L)=1.0 sct = 01 !nominal, local curr sctstr(ct,sct) = 'Nom Local' IF(vp)CALL ivid(ct,sct,1,'Cons','Nom local') IF(vp)CALL ivid(ct,sct,2,'Invest','Nom local') IF(vp)CALL ivid(ct,sct,3,'Govt Exp','Nom local') IF(vp)CALL ivid(ct,sct,4,'Exports','Nom local') IF(vp)CALL ivid(ct,sct,5,'GNP','Nom local') IF(vp)CALL ivid(ct,sct,6,'GNP/worker','Nom local') IF(vp)CALL ivid(ct,sct,7,'GNP/pop','Nom local') DBAR(vl(ct,sct,1),:) = CONS(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,2),:) = KTOT(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,3),:) = GOVMT(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,4),:) = EXIM(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,5),:) = (CONS(L,0:NM)+KTOT(L,0:NM)+GOVMT(L,0:NM) & +EXIM(L,0:NM))*DEFLATOR(L) DBAR(vl(ct,sct,6),:) = WAGE(4,L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,7),:) = DBAR(vl(ct,sct,5),:)/POPLM(L,0:NM) sct = 02 !nominal, 90$

Page 39: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

39

sctstr(ct,sct) = 'Nom 90$' IF(vp)CALL ivid(ct,sct,1,'Cons','90 $') IF(vp)CALL ivid(ct,sct,2,'Invest','90 $') IF(vp)CALL ivid(ct,sct,3,'Govt Exp','90 $') IF(vp)CALL ivid(ct,sct,4,'Exports','90 $') IF(vp)CALL ivid(ct,sct,5,'GNP','90 $') IF(vp)CALL ivid(ct,sct,6,'GNP/worker','90 $') IF(vp)CALL ivid(ct,sct,7,'GNP/pop','90 $') DBAR(vl(ct,sct,1),:) = CONS(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,2),:) = KTOT(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,3),:) = GOVMT(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,4),:) = EXIM(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,5),:) = (CONS(L,0:NM)+KTOT(L,0:NM)+GOVMT(L,0:NM) & +EXIM(L,0:NM))*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,6),:) = WAGE(4,L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,7),:) = DBAR(vl(ct,sct,5),:)/POPLM(L,0:NM) & /EXCHRATE(L) sct = 05 !real, local curr sctstr(ct,sct) = 'Real Local' c ** Note that some of the following variables are modified in outexcel IF(vp)CALL ivid(ct,sct,1,'Cons','Nom local') IF(vp)CALL ivid(ct,sct,2,'Invest','Nom local') IF(vp)CALL ivid(ct,sct,3,'Govt Exp','Nom local') IF(vp)CALL ivid(ct,sct,4,'Exports','Nom local') IF(vp)CALL ivid(ct,sct,5,'GNP','Nom local') IF(vp)CALL ivid(ct,sct,6,'GNP/worker','Nom local') IF(vp)CALL ivid(ct,sct,7,'GNP/pop','Nom local') DBAR(vl(ct,sct,1),:) = RCONS(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,2),:) = RINVST(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,3),:) = RGOVT(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,4),:) = RTRD(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,5),:) = (RCONS(L,0:NM)+RINVST(L,0:NM)+RGOVT(L,0:NM) & +RTRD(L,0:NM))*DEFLATOR(L) DBAR(vl(ct,sct,6),:) = RGNPW(L,0:NM)*DEFLATOR(L) DBAR(vl(ct,sct,7),:) = DBAR(vl(ct,sct,5),:)/POPLM(L,0:NM) sct = 06 !real, 90$ sctstr(ct,sct) = 'Real 90$' c ** Note that some of the following variables are modified in outexcel IF(vp)CALL ivid(ct,sct,1,'Cons','Real 90$') IF(vp)CALL ivid(ct,sct,2,'Invest','Real 90$') IF(vp)CALL ivid(ct,sct,3,'Govt Exp','Real 90$') IF(vp)CALL ivid(ct,sct,4,'Exports','Real 90$') IF(vp)CALL ivid(ct,sct,5,'GNP','Real 90$') IF(vp)CALL ivid(ct,sct,6,'GNP/worker','Real 90$') IF(vp)CALL ivid(ct,sct,7,'GNP/pop','Real 90$') DBAR(vl(ct,sct,1),:) = RCONS(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,2),:) = RINVST(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,3),:) = RGOVT(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,4),:) = RTRD(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,5),:) = (RCONS(L,0:NM)+RINVST(L,0:NM) & +RGOVT(L,0:NM) & +RTRD(L,0:NM))*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,6),:) = RGNPW(L,0:NM)*DEFLATOR(L)/EXCHRATE(L) DBAR(vl(ct,sct,7),:) = DBAR(vl(ct,sct,5),:)/POPLM(L,0:NM) & /EXCHRATE(L) c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 35 ctstr(ct) = 'EnergyDetail' sct = 01 !summed fossil and refined fossil energy use by sector sctstr(ct,sct) = 'Fossil En' DO IS = 1, NIS IF(vp)CALL ivid(ct,sct,IS,ISNAME(IS),'EJ') TMPOUT= SUM(DEMAND(3:7,IS,:),DIM=1)+SUM(DEMAND(9:10,IS,:),DIM=1) c don't count input of raw pri. fuel to the refining sectors IF (IS .EQ. 6) TMPOUT = TMPOUT - DEMAND(5,6,0:NM) IF (IS .EQ. 9) TMPOUT = TMPOUT - DEMAND(3,9,0:NM) IF (IS .EQ. 10) TMPOUT = TMPOUT - DEMAND(4,10,0:NM) DBAR(vl(ct,sct,IS),:) = TMPOUT END DO sct = 10 !elec gen sctstr(ct,sct) = 'Elec Gen'

Page 40: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

40

DO ISS = 1, NISS(8,L) IF(vp)CALL ivid(ct,sct,ISS,TECHNAME(8,ISS,L),'EJ') DBAR(vl(ct,sct,ISS),:) = ELECGEN(ISS,L,0:NM) END DO IF(vp)CALL ivid(ct,sct,99,'Total','EJ') DBAR(vl(ct,sct,99),:) = SUM(ELECGEN(1:NISS(8,L),L,0:NM),DIM=1) c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 40 ctstr(ct) = 'Misc' sct = 10 !demog sctstr(ct,sct) = 'Demog' IF(vp)CALL ivid(ct,sct,1,'Population','1000s') IF(vp)CALL ivid(ct,sct,2,'W. Age M','1000s') IF(vp)CALL ivid(ct,sct,3,'W. Age F','1000s') IF(vp)CALL ivid(ct,sct,4,'W. Age Tot','1000s') IF(vp)CALL ivid(ct,sct,5,'Employ','1000s') DBAR(vl(ct,sct,1),:) = POPLM(L,0:NM) DBAR(vl(ct,sct,2),:) = WAGE(1,L,0:NM) DBAR(vl(ct,sct,3),:) = WAGE(2,L,0:NM) DBAR(vl(ct,sct,4),:) = WAGE(1,L,0:NM)+WAGE(2,L,0:NM) DBAR(vl(ct,sct,5),:) = EMPLOY(L,0:NM) sct = 20 !cpricemisc ctstr(ct) = 'Cpolicy' sctstr(ct,20) = 'CPrices etc' IF(vp)CALL ivid(ct,sct,1,'PermP','90 $') IF(vp)CALL ivid(ct,sct,2,'PermP','local') IF(vp)CALL ivid(ct,sct,3,'Target with sequestration','MMTCE') IF(vp)CALL ivid(ct,sct,4,'Trade','MMTCE') IF(vp)CALL ivid(ct,sct,5,'Actual emissions','MMTCE') IF(vp)CALL ivid(ct,sct,6,'Emission Seq' ,'MMTCE') IF(vp)CALL ivid(ct,sct,7,'Em-Targeted' ,'MMTCE') IF(vp)CALL ivid(ct,sct,8,'McCarl Cprice' ,'90 $') !convert to 2005$s w/ gdp deflator IF(vp)CALL ivid(ct,sct,9,'PermP','2005 $') DBAR(vl(ct,sct,1),:) = P(NIN-3,L,0:NM) DBAR(vl(ct,sct,2),:) = P(NIN-3,L,0:NM)*EXCHRATE(L) !bc tax kept in $ DBAR(vl(ct,sct,3),:) = CARBONLIM(L,0:NM) !carbon limit DBAR(vl(ct,sct,4),:) = TRADE(1,NIN-3,L,0:NM) DBAR(vl(ct,sct,5),:) = EMTOT(L,0:NM) DBAR(vl(ct,sct,6),:) = -1.D0*EmSave(L,0:NM) DBAR(vl(ct,sct,7),:) = EMTOT(L,0:NM)-1.D0*EmSave(L,0:NM) DBAR(vl(ct,sct,8),:) = EmSqPSav(L,0:NM) !convert to 2005$s w/ gdp deflator DBAR(vl(ct,sct,9),:) = P(NIN-3,L,0:NM) / 0.75 sct = 22 !cpricemisc sctstr(ct,22) = 'CPolicy Revenue' IF(vp)CALL ivid(ct,sct,1,'NetPermRev:CRBTXTOT','local') IF(vp)CALL ivid(ct,sct,2,'SummedTax(5,1:27)','local') IF(vp)CALL ivid(ct,sct,3,'Rev if 0.97 for oil','local') IF(vp)CALL ivid(ct,sct,4,'InvestC','local') IF(vp)CALL ivid(ct,sct,5,'GovtC','local') IF(vp)CALL ivid(ct,sct,6,'HHoldC','local') IF(vp)CALL ivid(ct,sct,7,'TradeCarb','local') DBAR(vl(ct,sct,1),:) = CRBPRICETOT(L,0:NM) !carbon price revenue DBAR(vl(ct,sct,3),:) = P(NIN-3,L,0:NM) * EMTOT(L,0:NM) DBAR(vl(ct,sct,7),:) = tradecarb(l,0:NM) c * * * * * * * * * * * * * * * * * * * * * * * * * * * sct = 30 !cpricemisc sctstr(ct,30) = 'Cprices' DO I=1,22 IF(vp)CALL ivid(ct,sct,I, & 'PriceC_'//INNAME(I),'SupplySect') DBAR(vl(ct,sct,I),:) = CPRICER(I,IDEFS(NIS,1,L),L,0:M) END DO sct = 40 !straight from the outexcel table "capital stock..." sctstr(ct,sct) = 'CapStock' IF(vp)CALL ivid(ct,sct,1,'Capital','local')

Page 41: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

41

IF(vp)CALL ivid(ct,sct,2,'Cap/1000wkrs','local') IF(vp)CALL ivid(ct,sct,3,'Saving','local') IF(vp)CALL ivid(ct,sct,4,'RE','local') IF(vp)CALL ivid(ct,sct,5,'Saving + RE','local') IF(vp)CALL ivid(ct,sct,6,'Gov Def','local') IF(vp)CALL ivid(ct,sct,7,'Profits','local') DBAR(vl(ct,sct,1),:) = (KWORK(L,0:NM)*EMPLOY(L,0:NM)) DBAR(vl(ct,sct,2),:) = KWORK(L,0:NM) DBAR(vl(ct,sct,3),:) = SAVING(L,0:NM) DBAR(vl(ct,sct,4),:) = -ED(NIN,NIS,L,0:NM)-SAVING(L,0:NM) DBAR(vl(ct,sct,5),:) = -ED(NIN,NIS,L,0:NM) DBAR(vl(ct,sct,6),:) = GOVDEFT(L,0:NM) DBAR(vl(ct,sct,7),:) = TPROF(L,0:NM) c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 50 ctstr(ct) = 'IO Quantities' DO IS = 1, NIS sctstr(ct,IS) = ISNAME(IS) !sectors as subcat labels END DO DO IS = 1, NIS c Store quantities of variable inputs. DO IN = 1, NIN-1 IF(vp)CALL ivid(ct,IS,IN,(ADJUSTR(INNAME(IN))//' In'), & 'Phys/local') DBAR(vl(ct,IS,IN),:) = DEMAND(IN,IS,:)/PRCONVRT(IN,L) END DO c Store capital stock. IN = NIN IF(vp)CALL ivid(ct,IS,IN,(ADJUSTR(INNAME(IN))//' In'), & 'Phys/local') C Sum over subsectors KA_TEMP = 0.0d0 DO ISS=1,NISS(IS,L) KA_TEMP(0:NM) = KA_TEMP(0:NM) + KA_STORE(ISS,IS,0:NM) END DO DBAR(vl(ct,IS,IN),:) = KA_TEMP(0:NM) END DO C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ct = 51 ctstr(ct) = 'IO Values' DO IS = 1, NIS sctstr(ct,IS) = ISNAME(IS) !sectors as subcat labels END DO DO IS = 1, NIS DO IN = 1, NIN IF(vp)CALL ivid(ct,IS,IN,(ADJUSTR(INNAME(IN))//' In'), & 'values') DBAR(vl(ct,IS,IN),:) = IOVAL_STORE(IS,IN,0:NM) END DO END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c varid = pct*10000+psct*100+idx IS = 8 ! <<-- SET sector for detailed reporting here ct = 60 ! ct is the first two digits of the variable ID in the database ! use a different ct index for each sector you get detail from ctstr(ct) = ISNAME(IS) C *** OUTPUT BY SUBSECTOR AND VINTAGE*** DO ISS = 1, NISS(IS,L) !loop over all the subsectors sct = 38 + ISS sctstr(ct,sct) = 'Prd '//TECHNAME(IS,ISS,L) !label the subcat DO IVIN = 0, -1*NVIN0 IF(vp)CALL ivid(ct,sct,IVIN+1, & ('vin -'//INTTOCHAR(IVIN)),'Local') DO MM = 0, NM !this loop rearranges the data into compact form DBAR(vl(ct,sct,IVIN+1),MM) = vindatasave(1,IS,ISS,MM-IVIN,L,MM) END DO END DO END DO

Page 42: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

42

C *** PROFIT RATES BY SUBSECTOR AND VINTAGE *** ct = 62 ! ct is the first two digits of the variable ID in the database C ! use a different ct index for each sector you get detail from DO ISS = 1, NISS(IS,L) !loop over all the subsectors sct = 38 + ISS sctstr(ct,sct) = 'Prft '//TECHNAME(IS,ISS,L) !label the subcat DO IVIN = 0, -1*NVIN0 IF(vp)CALL ivid(ct,sct,IVIN+1, & ('vin -'//INTTOCHAR(IVIN)),'Pct') DO MM = 0, NM !this loop rearranges the data into compact form DBAR(vl(ct,sct,IVIN+1),MM)=vindatasave(2,IS,ISS,MM-IVIN,L,MM) & / vindatasave(1,IS,ISS,MM-IVIN,L,MM) END DO END DO END DO c *** EXPECTED PROFIT (OF NEW VINTAGE) BY SUBSECTOR ct = 64 ! ct is the first two digits of the variable ID in the database ! use a different ct index for each sector you get detail from DO ISS = 1, NISS(IS,L) !loop over all the subsectors sct = 20 + ISS sctstr(ct,sct) = 'ExpPrft'//TECHNAME(IS,ISS,L) !label the subcat IF(vp)CALL ivid(ct,sct,ISS,TECHNAME(IS,ISS,L),'Pct') DBAR(vl(ct,sct,ISS),:) = DEXPPROF(ISS,IS,L,0:NM) END DO c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c Now write the contents of DBAR to the file if (nm .eq. nmdbase) then DO I = 1, UBOUND(DBAR,DIM=1) IF (rvl(I).EQ.0) EXIT WRITE(110,100) RunID, L, rvl(I), DBAR(I,:) END DO else DO I = 1, UBOUND(DBAR,DIM=1) IF (rvl(I).EQ.0) EXIT WRITE(110,100) RunID, L, rvl(I), DBAR(I,0:NM), & Zero(NM+1:NMDBASE) END DO end if c * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * c sum global totals c first adjust the iotable by exchange rates so we can get a global io table DO IN = 1, NIO IF (IN .GE. 3 .AND. IN .LE. 10) CYCLE !energy units DO IS = 1, NIS DBAR(vl(50,IS,IN),:) = DBAR(vl(50,IS,IN),:) / EXCHRATE(L) END DO END DO DBARG = DBARG + DBAR !sum the whole array C ********** 850 CONTINUE !END REGION DO LOOP c GLOBAL OUTPUT -------------------------------------- c first delete all the things that can't be summed or fixed DO I = 1, UBOUND(DBAR,DIM=1) IF(rvl(I).ge.110100.and.rvl(I).lt.110200) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.200100.and.rvl(I).lt.200200) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.210100.and.rvl(I).lt.210200) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.220100.and.rvl(I).lt.220200) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.250000.and.rvl(I).lt.260000) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.300100.and.rvl(I).lt.300200) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.300500.and.rvl(I).lt.300600) DBARG(I,:)=-11111.11111 ! IF(rvl(I).ge.402000.and.rvl(I).lt.402100) DBARG(I,:)=-11111.11111 ! END DO c now fix anything that remains to be done for global items c --------------------------------------------------------- c gnp/cap and gnp/worker DBARG(vl(30,02,06),:) = -11111.11111 !kill gnp/worker DBARG(vl(30,02,07),:) =DBARG(vl(30,02,05),:)/DBARG(vl(40,10,01),:) DBARG(vl(40,30,02),:) = -11111.11111 !kill cap/worker c ---------------------------------------------------- c write global output (DBARG) to region '0' IF (NL.GT.1) THEN

Page 43: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

43

if (nm.eq.nmdbase) then DO I = 1,UBOUND(DBARG,DIM=1) IF (rvl(I).EQ.0) EXIT IF (DBARG(I,2).NE.-11111.11111) THEN WRITE(110,100) RunID, 0, rvl(I), DBARG(I,:) END IF END DO else DO I = 1,UBOUND(DBARG,DIM=1) IF (rvl(I).EQ.0) EXIT IF (DBARG(I,2).NE.-11111.11111) THEN WRITE(110,100) RunID, 0, rvl(I), DBARG(I,0:NM), & Zero(nm+1:nmdbase) END IF END DO END IF END IF C-----END GLOBAL OUTPUT c ************************************************************************************** c call the c++ program to move the data to the database... c the program takes the following parameters from the command line: c c datamover.exe [database] [datatable] [source csv file] [replace] c c the last argument is optional, if you specify "replace" the table is overwritten c the source csv file will be deleted by the c program c MAKE SURE ALL THE CSV's are CLOSED (access requires exclusive read) CLOSE(110) CLOSE(108) c * * * * * * * ! idum=SYSTEMQQ("datamover.exe """//DBNAME//""" dbmain "//DBOUTFILE) ! idum=SYSTEMQQ("datamover.exe """//DBNAME//""" dbrunlabels "// ! & DBINFOFILE) ! idum=SYSTEMQQ("datamover.exe """//DBNAME//""" dbvarlabels " ! & //VARINFO//" replace") idum = SYSTEMQQ("datamover.exe "//DBNAME//" dbmain "//DBOUTFILE) idum = SYSTEMQQ("datamover.exe "//DBNAME//" dbrunlabels & "//DBINFOFILE) idum = SYSTEMQQ("datamover.exe "//DBNAME//" dbvarlabels & "//VARINFO//" replace") RETURN END

Page 44: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

44

C *********************************************************************

SUBROUTINE DEMK C Subroutine to compute demands for new capital when gross C output is known in advance. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' C Local variables REAL*8 Q(NIOP,NLP,0:NMP),QOLD(NIOP,NLP,0:NMP),SSPRD(NIOP,NISSP), 1 QNEW(NIOP,NLP,0:NMP),COSTK(NIOP,NISSP,-3:NMP,NLP), 3 CAPQ(NIOP,NISSP,NLP,-3:NMP), 4 CAPQSS(NISSP),TESTKSS(NISSP), 5 ExpProfRate(NISSP),ShareInvSS(NISSP) C Store gross output in Q array. Later, this will come directly C from the solution mechanism. DO IO=1,NIO IF(M .EQ. 0) THEN Q(IO,L,M) = SALES(1,IO,L,M) ELSE Q(IO,L,M) = SALES(1,IO,L,M-1)*QPROJ(L,M) END IF END DO C Operate old vintages. DO IO=1,NIO DO IVIN=-3,M-1 CALL OPERATEOLD END DO END DO C Sum output across old vintages and subsectors. DO IO=1,NIO QOLD(IO,L,M) = 0.0 DO ISS = 1,NISS(IO,L) SSPRD(IO,ISS) = 0.0 DO IVIN=-3,M-1 SSPRD(IO,ISS) = SSPRD(IO,ISS) + PRDVIN(IO,ISS,IVIN,L) QOLD(IO,L,M) = QOLD(IO,L,M) + PRDVIN(IO,ISS,IVIN,L) END DO END DO END DO C Calculate output needed from new vintages. QNEW = Q - QOLD C ====================================================================== C Calculate profit per unit of capital and capital-output ratios by C subsector. Loop over sectors and subsectors. DO IO=1,NIO DO ISS=1,NISS(IO,L) IVIN=M IF(A(NIN,IDEF(IO,ISS,L),IVIN,L) .GT. 0.0) THEN C Code to calculate profit rate, borrowed from EXPROF.FOR C May need some additional checks for sectors that are not operating. Z(IO,ISS) = 0.0 NRHO=NIN+1 DO IN=1,NIN-1 Z(IO,ISS) = Z(IO,ISS) + ACST(IN,IDEF(IO,ISS,L),IVIN,L) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) & ** ACST(NRHO,IDEF(IO,ISS,L),IVIN,L) END DO Z(IO,ISS) = 1.0 - Z(IO,ISS) * (A(0,IDEF(IO,ISS,L),IVIN,L)

Page 45: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

45

& * PRCV(IO,L,M)) ** (-ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) IF (Z(IO,ISS) .LE. 0.0) THEN PROFRATE(IO,ISS,L,M,ivin) = 0.0 ELSE PROFRATE(IO,ISS,L,M,ivin) = A(0,IDEF(IO,ISS,L),IVIN,L) & * PRCV(IO,L,M) & * Z(IO,ISS) ** (1 / ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) & * A(NIN,IDEF(IO,ISS,L),IVIN,L) & ** (1.0 / A(NRHO,IDEF(IO,ISS,L),IVIN,L)) END IF C Calculate profit rate for Leontief technologies. CAPQ1 = LEON(0,IDEF(IO,ISS,L),IVIN,L) * & LEON(NIN,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ1 VALQ = QCAP * PRCV(IO,L,M) VALIN = 0.0D0 DO IN=1,NIN-1 VALIN = VALIN + QCAP * LEON(0,IDEF(IO,ISS,L),IVIN,L) * 1 LEON(IN,IDEF(IO,ISS,L),IVIN,L) * 2 PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) END DO RPR = VALQ - VALIN C Overwrite if Leontief technology. IF(SIGMA1(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN PROFRATE(IO,ISS,L,M,ivin) = MAX(0.0D0,RPR) END IF ! end code for Leontief technology. C DIAGNOSTIC R1 = PROFRATE(IO,ISS,L,M,ivin) C ---------------------------------------------------------------------- C Calculate capital-output ratio for CES technology. IF(PROFRATE(IO,ISS,L,M,ivin) .LE. 0.0000) THEN CAPQ1 = 0.0D0 ELSE A0 = A(0,IDEF(IO,ISS,L),IVIN,L) AI = A(NIN,IDEF(IO,ISS,L),IVIN,L) RHO = A(NIN+1,IDEF(IO,ISS,L),IVIN,L) PSUBI = PROFRATE(IO,ISS,L,M,ivin) PSUBJ = PRCV(IO,L,M) EXPA0 = RHO/(1.0D0 - RHO) EXPAI = 1.0D0/(1.0D0 - RHO) EXPP = EXPAI CAPQ1 = A0**EXPA0 * AI**EXPAI * (PSUBJ/PSUBI)**EXPP CAPQ(IO,ISS,L,M) = CAPQ1 END IF ! end of code for CES technology. C Check for Leontief technology and overwrite CAPQ. IF(SIGMA1(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN CAPQ2 = LEON(0,IDEF(IO,ISS,L),IVIN,L) * 1 LEON(NIN,IDEF(IO,ISS,L),IVIN,L) CAPQ(IO,ISS,L,M) = CAPQ2 END IF ! end of code for Leontief technology. END IF ! end check on alpha-zero END DO ! end subsector loop END DO ! end sector loop

Page 46: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

46

C End of code to collect profit rate and capital-output C information by subsector. C ====================================================================== C Back out amount of capital needed to produce QNEW. IVIN = M DO IO=1,NIO C Calculations are really simple with one subsector. IF(NISS(IO,L) .EQ. 1) THEN ISS = 1 TESTK(IO,L) = CAPQ(IO,ISS,L,M) * QNEW(IO,L,M) ELSE ! number of subsectors is greater than 1 C Set up calculations for the amount of output produced by fixed C investment. This includes 2 times the previous period's investment C (because of capital interpolation formula), plus 3 times any fixed C investment for the current period. RQALL = 0.0D0 RFIXINV1 = 0.0D0 RFIXINV2 = 0.0D0 DO ISS = 1,NISS(IO,L) IF(CAPQ(IO,ISS,L,M) .GT. 0.0) THEN QCAP = 1.0D0 / CAPQ(IO,ISS,L,M) ELSE QCAP = 0.0D0 END IF C Get previous investment by subsector. RFIXINV1 = RFIXINV1 + KAFLOW(ISS,IO,M-1,L) RQ1 = KAFLOW(ISS,IO,M-1,L) * QCAP * 2.0D0 C Get fixed investment by electricity subsectors. RQ2 = 0.0D0 IF(IO .EQ. NELEC) THEN RFIXINV2 = RFIXINV2 + EXOELEC(L,ISS,M) RQ2 = EXOELEC(L,ISS,M) * QCAP * 3.0D0 END IF RQALL = RQALL + RQ1 + RQ2 END DO ! end subsector loop for output by fixed investment RGAP = QNEW(IO,L,M) - RQALL DO ISS = 1,NISS(IO,L) C Present value calculation for converting profit rate to C expected profit rate. The first PV assignment below mimics Excel's C PV calculation when payments are made at the beginning of period. RATE1 = PI(NIN,IDEFS(IO,ISS,L),L,IVIN,1) X1 = 1.0D0/(1.0D0 + RATE1) NYEARS = NSTEP * NTECHCHAR(1,IDEF(IO,ISS,L),L,IVIN) PV = (1.0D0 - X1**NYEARS)*(1.0D0/(1.0D0 - X1)) C The second PV assignment creates a one-half-period delay. PV = PV * X1**0.5D0 C Store intermediate calculations by subsector CAPQSS(ISS) = CAPQ(IO,ISS,L,M) ExpProfRate(ISS) = PROFRATE(IO,ISS,L,M,ivin) * PV END DO ! end subsector loop C Create subsector investment share. RLAMDA = RHOINV(IO,L) c Determine what subnesting is used in elec sector

Page 47: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

47

IF (IO .EQ. NELEC .and. ISUB(L) .GE. 1) THEN c Calculate investment shares for variable subsectors. c This is done as in the Newinvnew subroutine. c First calculate Levelized Cost (code borrowed from Newinvnew subroutine) DO ISS = 1,NISS(IO,L) !iss loop for lowest level nests !this loop to sum the alphas for each subsector checks if a subsesctor is !active and turns it off if not to avoid problems in the sol'n algorithm temp=0 DO IN=1,NIN-1 temp = temp + A(IN,IDEF(IO,ISS,L),IVIN,L) END DO if (temp .eq. 0) then BETAin(iss,l) = 0.0 else LevCost(L,ISS,M)= 0.0 RHO = A(NIN+1,IDEF(IO,ISS,L),IVIN,L) DO IN=1,NIN-1 LevCost(L,ISS,M) = LevCost(L,ISS,M) & + A(IN,IDEF(IO,ISS,L),IVIN,L) ** (1/(1-RHO)) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) ** (RHO/(RHO-1)) END DO LevCost(L,ISS,M) = LevCost(L,ISS,M) & + A(NIN,IDEF(IO,ISS,L),IVIN,L) ** (1/(1-RHO)) & * Kcost(ISS,L) ** (RHO/(RHO-1)) LevCost(L,ISS,M)= LevCost(L,ISS,M) ** ((RHO-1)/RHO) LevCost(L,ISS,M)= LevCost(L,ISS,M) & / (ELECFAC(IO,ISS,L)*1000/3.6) end if END DO c c Now calculate investment shares (code from Newinvnew subroutine) c IXccs = 3 !set # of subsectors for carbon capture and storage level IXpkbs = 2 !set # of subsectors for peak base level IXfrnh = 4 !set # of subsectors for fossil renewable nuclear hydro TMPEXP0 = 0.0 !set vars to zero DO INS = 1,IXccs TMPEXPccs(INS) = 0.d0 TMPEXP2ccs(INS)= 0.d0 END DO DO INS = 1,IXpkbs TMPEXPpkbs(INS) = 0.d0 TMPEXP2pkbs(INS)= 0.d0 END DO DO INS = 1,IXfrnh TMPEXPfrnh(INS) = 0.d0 TMPEXP2frnh(INS)= 0.d0 END DO if(Iprofitoption(L) .eq. 2) then !Use levelized cost approach: exemption file dependent if (RHOINVccs(L).gt.0) then RHOINVfsl(L) = -RHOINVfsl(L) !logit sharing exponent for fossil nest RHOINVrnw(L) = -RHOINVrnw(L) !logit sharing exponent for renewables nest RHOINVpkbs(L) = -RHOINVpkbs(L) !logit sharing exponent for peak base level nest RHOINVccs(L) = -RHOINVccs(L) !logit sharing exponent for knife edge !carbon capture and sequestration level nests RHOINV(IO,L) = -RHOINV(IO,L) ! alternative for oveall subnest shares end if !Else Use expected profit approach and use expected profit directly from Exprof2k else !Use expected profit approach do iss=1,niss(io,l) BETAin(iss,l) = 1.0 !Betain parameters for lowest level subnests end do do ins=1,IXccs BetaB(ins,l) = 1.0 !BetaB parameters for base subnetst (ngcc, igcc, pc)

Page 48: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

48

end do do ins=1,IXpkbs BetaF(ins,l) = 1.0 !BetaF parameters for fossil subnetst (peak v. base) end do do ins=1,IXfrnh BetaE(ins,l) = 1.0 !BetaE parameters for elec subnest (fossil, renewable, nuclear, hydro) end do end if ! 1 (expected profit approach) or 2 (levelized cost approach) c ISS loop to set lowest level nests -------------- DO ISS = 1,NISS(IO,L) !iss loop for lowest level nests if(Iprofitoption(L) .eq. 2) then !Use levelized cost approach if (LevCost(L,ISS,M).gt.0) then !substitute levelized costs for expected profit rates DEXPPROF(ISS,IO,L,M) = LevCost(L,ISS,M) else DEXPPROF(ISS,IO,L,M) = 10000 end if end if !Iprofitoption(L) .eq. 2 ! Account for delays REQUIRED HERE FOR LEVELIZED COST OPTION ! - FOR EXPECTED PROFIT the Expectedprofit SUBROUTINE ACCOUNTs FOR IT ! SPECIFICS FOR SUBNESTING DELAYS ARE IN SUBNESTING EXEMPTION FILE ! THESE WILL OVERRIDE DEFAULT DELAYS IN MAIN INPUT FILE if(M .lt. issDELAY(L,ISS)) then DEXPPROF(ISS,IO,L,M) = 0.d0 issDEXPPROF(ISS,L,M) = 0.d0 if(Iprofitoption(L) .eq. 2) then !Use levelized cost approach DEXPPROF(ISS,IO,L,M) = 100000 end if end if ! Begin nesting code IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN !Peak - oil and gas TMPEXPpkbs(1) = TMPEXPpkbs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVpkbs(L) TMPEXP2pkbs(1)= TMPEXP2pkbs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVpkbs(L)+1) END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN TMPEXPccs(1) = TMPEXPccs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L) TMPEXP2ccs(1)= TMPEXP2ccs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVccs(L)+1) END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN TMPEXPccs(2) = TMPEXPccs(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L) TMPEXP2ccs(2) = TMPEXP2ccs(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVccs(L)+1) END IF !CCS nest: IGCC (IGCC, IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN TMPEXPccs(3) = TMPEXPccs(3) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M)

Page 49: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

49

& ** RHOINVccs(L) TMPEXP2ccs(3) = TMPEXP2ccs(3) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVccs(L)+1) END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN TMPEXPfrnh(2) = TMPEXPfrnh(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVrnw(L) TMPEXP2frnh(2) = TMPEXP2frnh(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVrnw(L)+1) END IF !Fossil Renewables Nuclear Hydro nest: Nuclear IF (ISS.EQ.4) THEN TMPEXPfrnh(3) = TMPEXPfrnh(3) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVfsl(L) DEXPPRfrnh(ISS,L,M) = DEXPPROF(ISS,IO,L,M) END IF !Fossil Renewables Nuclear Hydro nest: Hydro IF (ISS.EQ.5) THEN TMPEXPfrnh(4) = TMPEXPfrnh(4) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVrnw(L) DEXPPRfrnh(ISS,L,M) = DEXPPROF(ISS,IO,L,M) END IF END IF !NRSCHAR(1,IO,L) .EQ. 0 .OR. DRSCTMP(IO,ISS,L) .GT. 0.0 END IF !JELFIX(L,ISS,M) .NE. 1 END DO !end ISS loop C ISS loop to set lowest level nests -------------- C expected profits for lowest level nests------------- C expected profit for peak (oil and gas) IF (TMPEXPpkbs(1) .GT. 0) THEN DEXPPRpkbs(1,L,M) = TMPEXP2pkbs(1) / TMPEXPpkbs(1) ENDIF !expected profit for PC (coal and PCcd) IF (TMPEXPccs(1) .GT. 0) THEN DEXPPRccs(1,L,M) = TMPEXP2ccs(1) / TMPEXPccs(1) END IF !expected profit for NGCC (NGCC and NGCCcd) IF (TMPEXPccs(2) .GT. 0) THEN DEXPPRccs(2,L,M) = TMPEXP2ccs(2) / TMPEXPccs(2) END IF !expected profit for IGCC (IGCC and IGCCcd) IF (TMPEXPccs(3) .GT. 0) THEN DEXPPRccs(3,L,M) = TMPEXP2ccs(3) / TMPEXPccs(3) END IF !expected profit for renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (TMPEXPfrnh(2) .GT. 0) THEN DEXPPRfrnh(2,L,M) = TMPEXP2frnh(2) / TMPEXPfrnh(2) END IF C end expected profits for lowest level nests---------- C INS loops for next level up nests------------------- !Peak-Base nest: base (PC, NGCC and IGCC) DO INS = 1,IXccs TMPEXPpkbs(2) = TMPEXPpkbs(2) + BetaB(INS,L) & * DEXPPRccs(INS,L,M) & ** RHOINVpkbs(L)

Page 50: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

50

TMPEXP2pkbs(2)= TMPEXP2pkbs(2) + BetaB(INS,L) & * DEXPPRccs(INS,L,M) & ** (RHOINVpkbs(L)+1) END DO c end INS loops for next level up nests------------------- c expected profits for next level up nests-------------- !expected profit for base (PC, NGCC and IGCC) IF (TMPEXPpkbs(2) .GT. 0.0) THEN DEXPPRpkbs(2,L,M) = TMPEXP2pkbs(2) / TMPEXPpkbs(2) END IF c end expected profits for next level up nests---------- c INS loops for next level up nests------------------- !Fossil Renewables Nuclear Hydro nest: Fossil (Peak and Base) DO INS = 1,IXpkbs TMPEXPfrnh(1) = TMPEXPfrnh(1) + BetaF(INS,L) & * DEXPPRpkbs(INS,L,M) & ** RHOINVfsl(L) TMPEXP2frnh(1)= TMPEXP2frnh(1) + BetaF(INS,L) & * DEXPPRpkbs(INS,L,M) & ** (RHOINVfsl(L)+1) END DO c end INS loops for next level up nests------------------- c expected profits for next level up nests-------------- !expected profit for fossil (peak and base) IF (TMPEXPfrnh(1) .GT. 0.0) THEN DEXPPRfrnh(1,L,M) = TMPEXP2frnh(1) / TMPEXPfrnh(1) END IF c end expected profits for next level up nests---------- c INS loops for sector level TMPEXPs------------------- DO INS = 1,IXfrnh !ins loop for TMPEXP2 & 3 ! JELFIX(L,ISS,M)=1 fix for lev cost if (DEXPPRfrnh(INS,L,M) .gt. 0) then TMPEXP0 = TMPEXP0 + BetaE(INS,L) & * DEXPPRfrnh(INS,L,M) ** RHOINV(IO,L) end if END DO !INS loop c end INS loops for sector level TMPEXPs---------------- c now calculate lowest sub sub sector shares------------- DO ISS=1,NISS(IO,L) !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN if (iss.eq.1) ins=1 if (iss.eq.2) ins=2 IF (TMPEXPpkbs(1) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREpkbs1(INS,M,1) = (BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVpkbs(L))/TMPEXPpkbs(1) END IF END IF END IF END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN if (iss.eq.3) ins=1 if (iss.eq.16) ins=2 IF (TMPEXPccs(1) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREccs1(INS,M,1) = (BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L))/TMPEXPccs(1) END IF END IF END IF END IF

Page 51: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

51

!CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN if (iss.eq.12) ins=1 if (iss.eq.14) ins=2 IF (TMPEXPccs(2) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREccs2(INS,M,1) = (BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L))/TMPEXPccs(2) END IF END IF END IF END IF !CCS nest: IGCC (IGCC and IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN if (iss.eq.13) ins=1 if (iss.eq.15) ins=2 IF (TMPEXPccs(3) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREccs3(INS,M,1) = (BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L))/TMPEXPccs(3) END IF END IF END IF END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN if (iss.eq.6) ins=1 if (iss.eq.7) ins=2 if (iss.eq.8) ins=3 if (iss.eq.9) ins=4 if (iss.eq.10) ins=5 if (iss.eq.11) ins=6 IF (TMPEXPfrnh(2) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREfrnh2(INS,M,1) = (BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVrnw(L))/TMPEXPfrnh(2) END IF END IF END IF END IF END DO !INS loop c End calculate lowest sub sub sector shares------------- c Now calculate next level up subsector shares------------- !Peak-Base nest: base (PC, NGCC and IGCC) DO INS=1,IXccs SHAREpkbs2(INS,M,1) = (BetaB(INS,L) * DEXPPRccs(INS,L,M) & ** RHOINVpkbs(L)) / TMPEXPpkbs(2) END DO !Fossil Renewables Nuclear Hydro nest: Fossil (Peak and Base) DO INS=1,IXpkbs SHAREfrnh1(INS,M,1) = (BetaF(INS,L) *DEXPPRpkbs(INS,L,M) & ** RHOINVfsl(L)) / TMPEXPfrnh(1) END DO !Elec nest: (Fossil Renewables Nuclear Hydro) DO INS=1,IXfrnh if (DEXPPRfrnh(INS,L,M) .gt. 0 .and. TMPEXP0 .gt. 0) then

Page 52: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

52

SHAREelec(INS,M,1) = (BetaE(INS,L) *DEXPPRfrnh(INS,L,M) & ** RHOINV(IO,L)) / TMPEXP0 else SHAREelec(INS,M,1) = 0.0 end if END DO c end calculate upper level subsector shares------------- c now calculate lowest sub sub sector shares as share of total--------- DO ISS=1,NISS(IO,L) !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN if (iss.eq.1) ins=1 if (iss.eq.2) ins=2 SHARE(IO,ISS) = SHAREpkbs1(INS,M,1) & *SHAREfrnh1(1,M,1) & *SHAREelec(1,M,1) END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN if (iss.eq.3) ins=1 if (iss.eq.16) ins=2 SHARE(IO,ISS) = SHAREccs1(INS,M,1) & *SHAREpkbs2(1,M,1) & *SHAREfrnh1(2,M,1) & *SHAREelec(1,M,1) END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN if (iss.eq.12) ins=1 if (iss.eq.14) ins=2 SHARE(IO,ISS) = SHAREccs2(INS,M,1) & *SHAREpkbs2(2,M,1) & *SHAREfrnh1(2,M,1) & *SHAREelec(1,M,1) END IF !CCS nest: IGCC (IGCC and IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN if (iss.eq.13) ins=1 if (iss.eq.15) ins=2 SHARE(IO,ISS) = SHAREccs3(INS,M,1) & *SHAREpkbs2(3,M,1) & *SHAREfrnh1(2,M,1) & *SHAREelec(1,M,1) END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN if (iss.eq.6) ins=1 if (iss.eq.7) ins=2 if (iss.eq.8) ins=3 if (iss.eq.9) ins=4 if (iss.eq.10) ins=5 if (iss.eq.11) ins=6 SHARE(IO,ISS) = SHAREfrnh2(INS,M,1) & *SHAREelec(2,M,1) END IF !Elec nest: Nuclear IF (ISS.EQ.4) THEN SHARE(IO,ISS) = SHAREelec(3,M,1) END IF !Elec nest: Hydro IF (ISS.EQ.5) THEN SHARE(IO,ISS) = SHAREelec(4,M,1) END IF END DO ! ISS loop DO ISS=1,NISS(IO,L)

Page 53: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

53

ShareInvSS(ISS) = SHARE(IO,ISS) END DO ! end subsector loop c c End - calculate investment shares (code from Newinvnew subroutine) c ELSE ! ISUB = 0 or not electricity sector c Calculate investment shares for variable subsectors. c This is done by setting expected profit rate to zero for c the fixed electricity subsectors. DO ISS=1,NISS(IO,L) IF(JELFIX(L,ISS,M) .EQ. 1 .AND. IO .EQ. NELEC) THEN ExpProfRate(ISS) = 0.0D0 END IF ! end test for electricity sector END DO ! end subsector loop DENOM = 0.0D0 DO ISS=1,NISS(IO,L) IF(JELFIX(L,ISS,M) .EQ. 1) ExpProfRate(ISS) = 0.0D0 DENOM = DENOM + ExpProfRate(ISS)**RLAMDA END DO ! end subsector loop DO ISS=1,NISS(IO,L) IF(DENOM .GT. 0.0D0) THEN ShareInvSS(ISS) = ExpProfRate(ISS)**RLAMDA / DENOM ELSE ShareInvSS(ISS) = 0.0D0 END IF END DO ! end subsector loop END IF ! end lev cost / exp prof if then else C Calculate sector-level output-capital ratio. QCAP = 0.0D0 DO ISS=1,NISS(IO,L) IF(CAPQSS(ISS) .GT. 0.0D0) THEN QCAP = QCAP + ShareInvSS(ISS) * 1.0D0 / CAPQSS(ISS) END IF END DO ! end subsector loop IF(QCAP .GT. 0.0D0) THEN CAPQ1 = 1.0D0 / QCAP ELSE CAPQ1 = 0.0D0 END IF C Multiply to get demand for capital. TESTK(IO,L) = CAPQ1 * QNEW(IO,L,M) TESTK1 = CAPQ1 * RGAP + RFIXINV1 * 2.0D0 + RFIXINV2 * 3.0D0 TESTK2 = CAPQ1 * RGAP / 3.0D0 TESTK(IO,L) = TESTK1 C Calculate demand for capital by subsector. SUMTEST1 = 0.0D0 END IF ! end test for number of subsectors END DO ! end sector loop RTEST3 = 1.0D0 RETURN END

Page 54: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

54

C*********************************************************************

SUBROUTINE DEMOG C This module provides information regarding age and gender of regional C populations. regional populations are divided into age groups based C on the time step of the model. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' CHARACTER*4 RATE,POPS RATE = 'RATE' POPS = 'POPS' C . If first period and initial population values are used, then C . go to totals calculation at end of subroutine IF(M.EQ.0 .OR. POPTYPE(L) .EQ. POPS) GO TO 100 nage=16 C . Compute fertility rates DO NA=1,NAGE IF ((NSTEP * M) .LT. TFCLZ(NA,L)) THEN FXCLM(NA,L) = (NSTEP * M) / TFCLZ(NA,L) ELSE FXCLM(NA,L) = 1.0 END IF FCLM(NA,L,M) = FCLM(NA,L,0) * (1.0 - FXCLM(NA,L)) & + FCLZ(NA,L) * FXCLM(NA,L) C . Convert annual fertility rates to 5-year rates per female FCLM(NA,L,M) = 5.0 * FCLM(NA,L,M) / 1000.0 END DO C . Compute survival rates C . Begin by computing period specific death rate by sex--SVGCLM DO NG = 1,2 DO NA = 1,NAGE IF ((NSTEP*M) .LT. TSVGCLZ(NG,NA,L)) THEN SVXGCLM(NG,NA,L) = (NSTEP * M) / TSVGCLZ(NG,NA,L) ELSE SVXGCLM(NG,NA,L)=1.0 END IF SVGCLM(NG,NA,L,M) = SVGCLM(NG,NA,L,0) & * (1.0 - SVXGCLM(NG,NA,L)) & + SVGCLZ(NG,NA,L) * SVXGCLM(NG,NA,L) C . Convert annual death rates to 5-year survival probabilities SVGCLM(NG,NA,L,M) = (1.0 - SVGCLM(NG,NA,L,M) / 1000.0) ** 5 END DO END DO C . Compute net migration rates DO NG=1,2 DO NA=1,NAGE IF ((NSTEP*M) .LT. TXMIGZ(L)) THEN XXMIG(NG,NA,L) = (NSTEP * M) / TXMIGZ(L) ELSE XXMIG(NG,NA,L)=1.0 END IF XMIG(NG,NA,L,M) = XMIG(NG,NA,L,0) * (1.0 - XXMIG(NG,NA,L)) & + XMIGZ(NG,NA,L) * XXMIG(NG,NA,L) C . . . Convert annual net migration rate to 5-year rate per thousand XMIG(NG,NA,L,M) = 5.0 * XMIG(NG,NA,L,M) / 1000.0 END DO END DO C . Compute new births by gender BIRTHM=0

Page 55: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

55

BIRTHF=0 DO NA = 2,NAGE BIRTHM = BIRTHM + FCLM(NA,L,M) * POPGCLM(2,NA,L,M-1) & * GCLM(NA,L) BIRTHF = BIRTHF + FCLM(NA,L,M) * POPGCLM(2,NA,L,M-1) & * (1.0-GCLM(NA,L)) END DO POPGCLM(1,1,L,M) = BIRTHM POPGCLM(2,1,L,M) = BIRTHF C . Compute new population figures (in 1000S) by gender, age, and region DO NG=1,2 DO NA=2,NAGE - 1 POPGCLM(NG,NA,L,M) = POPGCLM(NG,NA-1,L,M-1) * & (SVGCLM(NG,NA-1,L,M) + XMIG(NG,NA-1,L,M)) END DO POPGCLM(NG,NAGE,L,M) = & POPGCLM(NG,NAGE-1,L,M-1) * (SVGCLM(NG,NAGE-1,L,M) & + XMIG(NG,NAGE-1,L,M)) & + POPGCLM(NG,NAGE,L,M-1) * (SVGCLM(NG,NAGE,L,M) & + XMIG(NG,NAGE,L,M)) END DO 100 CONTINUE C . Get population age 15 to 65 for labor supply computations. DO NG = 1,2 WAGE(NG,L,M) = 0. DO NA = 4,13 WAGE(NG,L,M) = WAGE(NG,L,M) + POPGCLM(NG,NA,L,M) END DO END DO C . Compute regional gender, regional, and world population totals POPLM(L,M) = 0. DO NG=1,2 POPGLM(NG,L,M) = 0. DO NA=1,NAGE POPGLM(NG,L,M) = POPGLM(NG,L,M) + POPGCLM(NG,NA,L,M) END DO POPLM(L,M) = POPLM(L,M) + POPGLM(NG,L,M) END DO C . Compute fraction of population less than 15 and over 65. YNGOLD(L,M) = 1.- (WAGE(1,L,M) + WAGE(2,L,M)) / POPLM(L,M) RETURN END

Page 56: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

56

C**********************************************************************

SUBROUTINE EBAL C Subroutine to compute energy balances for each time period C and CO2 emissions from energy combustion. C The subroutine writes out data from the ED and SALES arrays to C reconstruct energy balances at the end of each time period. C Electricity generation output written to standard out-gen file C********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' DO LL = 1,NL L = MRKDEF(0,3+LL) DO IN=1,NIN DO IS=1,NIS BAL1(IN,IS,L,M) = ED(IN,IS,L,M) END DO END DO DO IN=1,NIO BAL1(IN,IN,L,M) = BAL1(IN,IN,L,M) + SALES(1,IN,L,M) EPRD(IN,L,M) = PRCONVRT(IN,L) * SALES(1,IN,L,M) END DO DO IN=1,NIO EDEM(IN,L,M) = 0.0 DO IS=1,NIS BAL2(IN,IS,L,M) = BAL1(IN,IS,L,M)*PRCONVRT(IN,L) EDEM(IN,L,M) = EDEM(IN,L,M) + BAL2(IN,IS,L,M) END DO END DO DO IN=1,NIO EDEM(IN,L,M) = EDEM(IN,L,M) - BAL2(IN,NIS-3,L,M) ETRADE(IN,L,M) = EPRD(IN,L,M) - EDEM(IN,L,M) END DO C Calculate emissions for ONLY oil, gas and coal CO2(3,L,M) = (EDEM(3,L,M) - ETRADE(9,L,M)) * EMC(1,1,L) CO2(4,L,M) = (EDEM(4,L,M) - ETRADE(10,L,M)) * EMC(2,1,L) CO2(5,L,M) = (EDEM(5,L,M) - ETRADE(6,L,M)) * EMC(3,1,L) PRI(1,L,M) = (EDEM(3,L,M) - ETRADE(9,L,M)) PRI(2,L,M) = (EDEM(4,L,M) - ETRADE(10,L,M)) PRI(3,L,M) = EDEM(5,L,M) -ETRADE(6,L,M) ! Coal products TOTCO2(L,M) = CO2(3,L,M) + CO2(4,L,M) + CO2(5,L,M) C Get electricity output by subsector in currency. c The subsector order differs in the old sgm input files and the c new versions which include renewables. The if statement below c discerns which is being used based on the subnesting option switch c ISUB. If the new input files are being used with the old flat c subnesting option (i.e. ISUB = 0) then this will not capture the c proper order of bio, nuc, and hydro, and the primary energy c calculations may be off. The primary energy calculations need to c be revisited to properly include renewables and advanced fossil c technologies. if (isub(L) .eq. 0) then !subsector order in old input files NELEC = 8 JBIO = 4 JNUC = 5 JHYDRO = 6 else !subsector order in new input files NELEC = 8 JBIO = 6 JNUC = 4 JHYDRO = 5

Page 57: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

57

end if DO ISS = 1,NISS(NELEC,L) ELECPRD(ISS,L,M) = 0.0 DO IVIN=-3,M ELECPRD(ISS,L,M) = ELECPRD(ISS,L,M) & + PRDVIN(NELEC,ISS,IVIN,L) END DO END DO C Calculate currency-to-energy factors for the electricity C generation subsectors using base year generation from C energy balance tables divided by base-year generation in currency IF (M .EQ. 0) THEN C Sum up value of base year generation in currency from IO table DO ISS=1,NISS(NELEC,L) TOTGENSS = 0.0 DO IN=1,NIN TOTGENSS = TOTGENSS + RIOVAL(IN,IDEFS(NELEC,ISS,L),L) END DO TOTGENSS = TOTGENSS + RIBT(IDEFS(NELEC,ISS,L),L) C Calculate currency-to-energy factors for subsectors 1 thru 6 IF (TOTGENSS.EQ.0) THEN ELECFAC(NELEC,ISS,L)=0 ELSE C Convert PJ to EJ with this formula ELECFAC(NELEC,ISS,L)=(BASEGENG(ISS,L)/1000.0) & /(TOTGENSS) END IF END DO C Assign sector-level prconvrt to remaining subsectors END IF C Calculate electricity generation by fuel C Use sector level prconvrt for those subsectors not included C in energy balance table DO ISS=1,NISS(NELEC,L) ELECGEN(ISS,L,M)=ELECPRD(ISS,L,M)* & ELECFAC(NELEC,ISS,L) END DO ENUC = ELECGEN(JNUC,L,M) EHYDRO = ELECGEN(JHYDRO,L,M) C Note that primary energy for nuclear and hydro is C weighted at 3 times the amount of electrical C energy produced. PRI(JBIO,L,M) = 0.0 PRI(JNUC,L,M) = ENUC * 3.0 PRI(JHYDRO,L,M) = EHYDRO * 3.0 PRI(12,L,M) = ELECGEN(12,L,M) !NGCC PRI(13,L,M) = ELECGEN(13,L,M) !Coal IGCC PRI(14,L,M) = ELECGEN(14,L,M) !NGCCcd PRI(15,L,M) = ELECGEN(15,L,M) !COAL IGCCcd PRI(16,L,M) = ELECGEN(16,L,M) !PCcd C oil, gas, coal for FF primary energy TOTPRI(L,M) = PRI(1,L,M) + PRI(2,L,M) + PRI(3,L,M) + PRI(12,L,M) & + PRI(13,L,M) + PRI(14,L,M) + PRI(15,L,M) & + PRI(16,L,M) 1001 FORMAT(15(F15.3,',')) 1002 FORMAT(5(F14.3,',')) END DO !End region loop RETURN END

Page 58: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

58

C**********************************************************************

SUBROUTINE EXPPROFIT C C EXPPROFIT is a subroutine that uses expected future prices to C produce unit costs for individual subsectors of a sector. C********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' logical print print = .false. C Initialize Z to zero. Z(IO,ISS)= 0.0 C New switch for returning 0 EXPPROF for technologies not yet C available. Replaced by ISSdelay IF(M.LT.NTECHCHAR(5,IDEF(IO,ISS,L),L,0)) THEN EXPPROF(ISS,IO,L,M) = 0.0 Z(IO,ISS) = 0.0 RETURN END IF IF (io .eq. 8 .and. M .lt. issDELAY(L,ISS)) THEN EXPPROF(ISS,IO,L,M) = 0.0 Z(IO,ISS) = 0.0 RETURN END IF C Also check if subsector is no longer available for investment IF(M.GE.NTECHCHAR(6,IDEF(IO,ISS,L),L,0)) THEN EXPPROF(ISS,IO,L,M) = 0.0 RETURN END IF C Also return 0 if alpha0 is set to zero (avoids errors in expprof code below) IF(A(0,IDEF(IO,ISS,L),IVIN,L).LE.0.0) THEN EXPPROF(ISS,IO,L,M) = 0.0 RETURN END IF C Also return 0 if alphaK is set to zero (avoids errors in expprof code below) IF(A(NIN,IDEF(IO,ISS,L),IVIN,L).LE.0.0) THEN EXPPROF(ISS,IO,L,M) = 0.0 RETURN END IF C . . For depletable or constrained resources, set expected profit C . . rate to zero if that resource has been exhausted. ICHAR=1 IF (NRSCHAR(ICHAR,IO,L) .GE. 1) THEN IF (DRSCE(IO,ISS,L) .LE. 0.0) THEN EXPPROF(ISS,IO,L,M) = 0.0 RETURN END IF END IF C . Use the dual cost function to compute the expected future profit C . rate. Begin by computing Z(IO,ISS) Z(IO,ISS)= 0.0 NRHO=NIN+1 DO IN=1,NIN-1 C if (pie(in,iss,io,l) .eq. 0) goto 100 Z(IO,ISS) = Z(IO,ISS) + ACST(IN,IDEF(IO,ISS,L),IVIN,L) & * PIE(IN,ISS,IO,L) ** ACST(NRHO,IDEF(IO,ISS,L),IVIN,L) END DO if (pe(io,iss,l) .eq. 0) goto 200 if (IO.eq.8) then !correct expected profit for elec subsectors if (IProfitOption(L).gt.0) then !correct expected profit for elec subsectors !keep old Z for factor demands in lev cost calc Zold(IO,ISS) = 1.0 - Z(IO,ISS) *

Page 59: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

59

& (A(0,IDEF(IO,ISS,L),IVIN,L) & * PE(IO,ISS,L)) ** (-ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) Z(IO,ISS) = 1.0 - Z(IO,ISS) * (A(0,IDEF(IO,ISS,L),IVIN,L) & * PEELEC(IO,ISS,L)) ** (-ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) RHO = A(NIN+1,IDEF(IO,ISS,L),IVIN,L) !code borrowed from ebal to find elec fac in first period IF (M .EQ. 0) THEN C Sum up value of base year generation in currency from IO table TOTGENSS = 0.0 DO IN=1,NIN TOTGENSS = TOTGENSS + RIOVAL(IN,IDEFS(IO,ISS,L),L) END DO TOTGENSS = TOTGENSS + RIBT(IDEFS(IO,ISS,L),L) C Calculate currency-to-energy factors for subsectors 1 thru 6 IF (TOTGENSS.EQ.0) THEN ELECFAC(IO,ISS,L)=0 ELSE !baseyear PRCONVRTs calculated by subsector ELECFAC(IO,ISS,L)=(BASEGENG(ISS,L)/1000.0) & /(TOTGENSS) END IF END IF ELSE Z(IO,ISS) = 1.0 - Z(IO,ISS) * (A(0,IDEF(IO,ISS,L),IVIN,L) & * PE(IO,ISS,L)) ** (-ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) END IF !IProfitOption(L).gt.0 ELSE Z(IO,ISS) = 1.0 - Z(IO,ISS) * (A(0,IDEF(IO,ISS,L),IVIN,L) & * PE(IO,ISS,L)) ** (-ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) END IF !IO.eq.8 C . Compute expected profit per unit new investment for subsector, ISS. 200 IF (Z(IO,ISS) .LE. 0.0) THEN EXPPROF(ISS,IO,L,M) = 0.0 ELSE IF (IO.eq.8 .and. IProfitOption(L).gt.0) THEN !baseyear PRCONVRTs calculated by subsector EXPPROF(ISS,IO,L,M) =A(0,IDEF(IO,ISS,L),IVIN,L) & *PEELEC(IO,ISS,L) & / PI(NETE,IDEFS(IO,ISS,L),L,M,1) & * Z(IO,ISS) ** (1 / ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) & * A(NIN,IDEF(IO,ISS,L),IVIN,L) & ** (1.0 / A(NRHO,IDEF(IO,ISS,L),IVIN,L)) ELSE EXPPROF(ISS,IO,L,M) =A(0,IDEF(IO,ISS,L),IVIN,L)* & PE(IO,ISS,L) / PI(NETE,IDEFS(IO,ISS,L),L,M,1) & * Z(IO,ISS) ** (1 / ACST(NRHO,IDEF(IO,ISS,L),IVIN,L)) & * A(NIN,IDEF(IO,ISS,L),IVIN,L) & ** (1.0 / A(NRHO,IDEF(IO,ISS,L),IVIN,L)) END IF !IProfitOption(L).gt.0 END IF C . . Adjust expected profit for any investment tax credit XITCRATE = FIFGE(XITCR(IO),0.0,M,ITCPD) EXPPROF(ISS,IO,L,M) = EXPPROF(ISS,IO,L,M) / (1.0 - XITCRATE) C +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Code for fixed-coefficient technologies C If new capital has a sigma less than 0.05, then this expected C profit rate will be substituted. CAPQ = LEON(NIN,IDEF(IO,ISS,L),IVIN,L) / & LEON(0,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ VALQ = QCAP * PE(IO,ISS,L) VALIN = 0.0D0 DO IN=1,NIN-1 VALIN = VALIN + QCAP / LEON(0,IDEF(IO,ISS,L),IVIN,L) * 1 LEON(IN,IDEF(IO,ISS,L),IVIN,L) * PIE(IN,ISS,IO,L) END DO REP = VALQ - VALIN IF(SIGMA1(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN EXPPROF(ISS,IO,L,M) = MAX(0.0D0,REP) END IF

Page 60: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

60

C End code for Leontief technologies. C +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ RETURN END

Page 61: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

61

C**********************************************************************

SUBROUTINE FIXC C Subroutine to calculate technical coefficients for Leontief technologies C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' DO IO=1,NIO DO ISS=1,NISS(IO,L) C Calculate total amount of beginning capital stock. BEGK = 0.0D0 DO IVIN = -3,0 BEGK = BEGK + KAPRIOR(ISS,IO,IVIN,L) END DO C These calculations are for base-year vintage only. IVIN = 0 C Set the "alpha-zero" parameter to 1.0 LEON(0,IDEF(IO,ISS,L),IVIN,L) = 1.0D0 C If there is no beginning capital stock, then set all technical C coefficients to zero. IF(BEGK .LT. 1.0D0) THEN DO IN=1,NIN LEON(IN,IDEF(IO,ISS,L),IVIN,L) = 0.0D0 END DO ELSE C Calculate output quantity. PSUBJ = PRCV(IO,L,M) VSUBJ = 0.0D0 DO IN =1,NIN VSUBJ = VSUBJ + RIOVAL(IN,IDEFS(IO,ISS,L),L) END DO QSUBJ = VSUBJ/PSUBJ C Calculate input-output coefficients for all inputs except C capital. DO IN=1,NIN-1 PSUBI = PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) VSUBI = RIOVAL(IN,IDEFS(IO,ISS,L),L) IF(PSUBI .GT. 0.0D0) THEN QSUBI = VSUBI/PSUBI ELSE QSUBI = 0.0D0 END IF LEON(IN,IDEF(IO,ISS,L),IVIN,L) = QSUBI/QSUBJ END DO C Calculate capital-output coefficient. C COSTK = RIOVAL(NIN,IDEFS(IO,ISS,L),L)/BEGK LEON(NIN,IDEF(IO,ISS,L),IVIN,L) = BEGK/QSUBJ END IF DO IVIN = -3,-1 DO IN=0,NIN+1 LEON(IN,IDEF(IO,ISS,L),IVIN,L) = & LEON(IN,IDEF(IO,ISS,L),0,L) END DO END DO END DO ! end of ISS loop END DO ! end of IO loop RETURN END

Page 62: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

62

C***********************************************************************

SUBROUTINE GETCFEE C Calculates the carbon fee on each sector based on the GHG C emissions from that sector. Also deals with emissions C mitigating technologies C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' REAL*8 NPV(6), emtcosts(10) !, emtexpprof(NSOURCE,10) C Scale the emissions coefficient over time with EMCADJ IF (M .GT. 0) THEN !fails for period 0 since GHGEMIS hasn't yet run DO IX = 1,NSOURCE(L) EMC(IX,10,L) = (1.0+EMCADJ(IX,L,M)) * EMC(IX,1,L) END DO END IF C this section of code applies if a simple marginal cost curve has been C read in for a particular driver DO IX = 1, NSOURCE(L) IF (CARBPRICEP(1,L) .EQ. 0) CYCLE ! skip if no carbon policy for region IF (CARBPRICEP(3,L) .EQ. 0) CYCLE ! skip if CO2 only is targeted IF (EMC(IX,5,L) .NE. 0) CYCLE ! skip if NonCO2 GHG's not priced (-2) C ! or if not a GHG (-1) or if CO2 (1) IF (JEMTSIMP(IX,L).EQ.0) CYCLE IF (EMT(IX,1,1,L) .GT. 0) THEN ! *** TRAP ERROR OF DOING BOTH WAYS ** PAUSE 'ERROR IN COST CURVES - BOTH SIMPLE AND DETAILED VSNS USED' CYCLE END IF Cprice = P(NIN-3,L,M) !set temp fee to the carbon price IF (Cprice.LE.0.0 .OR. M.LE.2) CYCLE ! cost curves set to apply in 2005 DO ILEV = JEMTSIMP(IX,L), 1, -1 !start at the highest fee IF (Cprice.GE.EMTSIMP(IX,ILEV,1,L)) THEN !interpolate IF (ILEV.EQ.JEMTSIMP(IX,L)) THEN !if redux is maxed out EMTINTRP(IX,1,L,M) = EMTSIMP(IX,ILEV,2,L) ELSE !interpolate EMTINTRP(IX,1,L,M) = ((cprice-EMTSIMP(IX,ILEV,1,L)) / & (EMTSIMP(IX,ILEV+1,1,L)-EMTSIMP(IX,ILEV,1,L))) * & (EMTSIMP(IX,ILEV+1,2,L)-EMTSIMP(IX,ILEV,2,L)) + & EMTSIMP(IX,ILEV,2,L) END IF EXIT END IF END DO !end loop over levels ! reduce EMC (this will carry into the fee and price computations below) EMC(IX,10,L) = EMC(IX,10,L) - EMTINTRP(IX,1,L,M) * EMC(IX,10,L) END DO C now compute exogenous total abatement cost for non co2 gasses DO IX = 1, NSOURCE(L) TAC(IX,L,M) = 0 IF (CARBPRICEP(1,L) .EQ. 0) CYCLE ! skip if no carbon policy for region IF (EMC(IX,5,L) .NE. 0) CYCLE ! skip if NonCO2 GHG's not priced (-2) C ! or if not a GHG (-1) or if CO2 (1) IF (CARBPRICEP(3,L) .EQ. 0) CYCLE ! skip if CO2 only is targeted IF (JEMTSIMP(IX,L).EQ.0) CYCLE IF (EMT(IX,1,1,L) .GT. 0) THEN ! *** TRAP ERROR OF DOING BOTH WAYS ** PAUSE 'ERROR IN COST CURVES - BOTH SIMPLE AND DETAILED VSNS USED' CYCLE END IF Cprice = P(NIN-3,L,M) !set temp fee to the carbon price TAC(IX,L,M) = 0 IF (Cprice.LE.0.0 .OR. M.LE.2) CYCLE ! cost curves set to apply in 2005 DO ILEV = 2, JEMTSIMP(IX,L) !start at the lowest nonzero carbon fee IF (cprice.GE.EMTSIMP(IX,ILEV,1,L)) THEN !add exog tc TAC(IX,L,M) = TAC(IX,L,M) & +0.5 & *(EMTSIMP(IX,ILEV,1,L) - EMTSIMP(IX,ILEV-1,1,L)) & *(EMTSIMP(IX,ILEV,2,L) - EMTSIMP(IX,ILEV-1,2,L)) & * EM(IX,L,M)/(1-EMTINTRP(IX,1,L,M)) & + EMTSIMP(IX,ILEV-1,1,L) & *(EMTSIMP(IX,ILEV,2,L) - EMTSIMP(IX,ILEV-1,2,L))

Page 63: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

63

& * EM(IX,L,M)/(1-EMTINTRP(IX,1,L,M)) ELSE !add interpolated bit TAC(IX,L,M) = TAC(IX,L,M) & +0.5 & *(Cprice - EMTSIMP(IX,ILEV-1,1,L)) & *(EMTINTRP(IX,1,L,M) - EMTSIMP(IX,ILEV-1,2,L)) & * EM(IX,L,M)/(1-EMTINTRP(IX,1,L,M)) & + EMTSIMP(IX,ILEV-1,1,L) & *(EMTINTRP(IX,1,L,M) - EMTSIMP(IX,ILEV-1,2,L)) & * EM(IX,L,M)/(1-EMTINTRP(IX,1,L,M)) EXIT END IF END DO !end loop over levels END DO C END CODE FOR SIMPLE REDUCTIONS C BEGIN code for investing in mitigation technologies C JEMT(IX,1,L) = Number of levels of control available C JEMT(IX,2,L) = Available without fee? 1 = true C JEMT(IX,3..6,L) = Inputs used for O&M C JEMT(IX,7,L) = input to put joint product in C JEMT(IX,8,L) = Model price to relate joint product to (sector) C JEMT(IX,9,L) = subsector (haven't tried on multi subsectors yet) C EMTJPR(IX,L) = real 1990$ price per ton emissions C EMT(IX,JLEV,1,L) = percent reduction C EMT(IX,JLEV,2,L) = capital 90$/90$ of prod C EMT(IX,JLEV,3..6,L) = oandm 90$ of input/90$ of prod DO IX = 1, NSOURCE(L) IF (M.GT.3 .AND. EMT(IX,1,1,L) .GT. 0) THEN !if EMT exists Tempfee = P(NIN-3,L,M) !set temp fee to the carbon price ! conditions in which no fee is applied to the emissions driver: IF (Tempfee .EQ. 0.0 .OR. & (CARBPRICEP(3,L) .EQ. 0 .AND. EMC(IX,5,L) .EQ. 0)) THEN ! skip if tech doesn't run without a fee IF (JEMT(IX,2,L).NE.1) CYCLE Tempfee = 0.0 !set tempfee to 0 !(even if there is a carbon price it doesn't apply in this case) END IF C Set temporary constants ! the sector driving emissions and paying the fee SectNo = EMC(IX,4,L) !the sector/subsec to use mitigation IDN = IDEFS(SectNo,JEMT(IX,9,L),L) !the number of the gas (methane=2) GasNo = EMC(IX,3,L) !volgas is tg gas from 1 90$ VolGas = EMC(IX,10,L) * PRCONVRT(SectNo,L) ! 90$ joint product / ton of gas mitigated pr_jprod = EMTJPR(IX,L) * !the ratio of P's is the change in price of the joint product sector since !the base period. emtjpr(ix,l) is the real value per ton in 90$ as read in & (P(JEMT(IX,8,L),L,M) / P(JEMT(IX,8,L),L,0)) ! Calculate expected profit from EMT PRK = PI(NIN,IDN,L,M,1) !the price of capital for the sector ! loop to calculate actual pv multiplier (inefficient?) XNPVFACTOR = 0.0d0 DO MMSTEP = 1,NSTEP XNPVFACTOR = XNPVFACTOR + 1 / (1+PRK)**MMSTEP END DO C XNPVFACTOR = 3.5887 !factor at FIXED 20% discount rate C approximation of pv multiplier, falls between begin and end values C (this is the same approximation that is used in the pps module) C XNPVFACTOR = (1.0/(1.0+PRK))**0.5 * (1.0+(1.0/PRK)) C & * (1.0-(1.0/(1.0+PRK)) ** NSTEP) C NPV(1) is the value of stopping all emissions from 1 90 $ of production for 5 years C NPV(3..6) is the present value of 1 90 $ of inputs 3..6 for 5 years (no price expectations) NPV(1) = XNPVFACTOR * Tempfee * VolGas * & GWP(EMC(IX,3,L),L,M) + XNPVFACTOR * pr_jprod * VolGas !+ joint pr DO JI = 3,6 NPV(JI) = XNPVFACTOR * & (P(JEMT(IX,JI,L),L,M) / P(JEMT(IX,JI,L),L,0)) END DO

Page 64: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

64

!calc on the margin for all levels DO JLEV = 1,JEMT(IX,1,l) emtcosts = 0 !has npv of the marginal O&M stream DO JI = 3, 6 emtcosts(JLEV) = emtcosts(JLEV) + NPV(JI) * & (EMT(IX,JLEV,JI,L)-EMT(IX,JLEV-1,JI,L)) END DO emtexpprof(IX,JLEV) = -(EMT(IX,JLEV,2,L) - & EMT(IX,JLEV-1,2,L)) !marginal cap & - emtcosts(JLEV) !discounted oandm costs & + (NPV(1) * (EMT(IX,JLEV,1,L)-EMT(IX,JLEV-1,1,L))) !discounted revenues END DO ! now pick the last one where marginal value is positive DO JLEV = 1,JEMT(IX,1,l) IF(emtexpprof(IX,JLEV).LT.0.0)EXIT END DO EMTINTRP(IX,:,L,M) = EMT(IX,JLEV-1,:,L) ! reduce EMC (this will carry into the tax computations below) EMC(IX,10,L) = EMC(IX,10,L) - EMTINTRP(IX,1,L,M) * EMC(IX,10,L) C the investment amounts, o&m accounting, and joint product are all in INVEST END IF !end if the em driver has a emt END DO !end loop over em drivers C BEGIN PRICE COMPUTATIONS IF (P(NIN-3,L,M) .EQ. 0.0) RETURN !don't bother if there's no price C CARBF(IN,L) is carbon emissions/dollar of production to be used in calculating C CPRICER - the carbon price. It replaces OILF, COALF, and GASF DO IN = 1,NIO CARBF(IN,L) = 0.0 END DO DO IX = 1,NSOURCE(L) IF (EMC(IX,5,L) .EQ. -1) CYCLE !skip if driver is not a greenhouse gas IF (EMC(IX,5,L) .EQ. -2) CYCLE !skip if driver is not controlled IF (CARBPRICEP(3,L) .EQ. 1 .OR. EMC(IX,5,L) .EQ. 1) THEN C IF all gases are included OR include for CO2 only is set (or both) THEN ITIN = EMC(IX,4,L) !ITIN = the input to price for emissions from driver IX CARBF(ITIN,L) = CARBF(ITIN,L) + EMC(IX,10,L) * PRCONVRT(ITIN,L) & * GWP(EMC(IX,3,L),L,M) END IF END DO C calculate CPRICER - carbon price on inputs per dollar of production DO IN = 1,NIO NELEC = 8 NOIL = 1 NGASid = 2 NCOAL = 3 NNUCLEAR = 4 NHYDRO = 5 NWASTE = 6 NSOLIDS = 7 NWIND = 8 NWINDOS = 9 NSOLAR = 10 NGEO = 11 NGCC = 12 IGCC = 13 NGCCcd = 14 IGCCcd = 15 PCcd = 16 DO IO = 1,NIS DO ISS=1,NISS(IO,L) ! ! define the subsectors to have a Ccost or not IDEFSNO=IDEFS(IO,ISS,L) CPRICER(IN,IDEFSNO,L,M) = 0.D0 IF (ISS.LE.NCOAL) CPRICER(IN,IDEFSNO,L,M) = & P(NIN-3,L,M) * CARBF(IN,L) * EXCHRATE(L) IF (ISS.GE.NGCC) CPRICER(IN,IDEFSNO,L,M) = & P(NIN-3,L,M) * CARBF(IN,L) * EXCHRATE(L) ! Cfee reduction here reduces impact of Cfees ! sqccs = 0.1D0 see Ghgemis IF (ISS.GE.NGCCcd) CPRICER(IN,IDEFSNO,L,M) = & sqccs * P(NIN-3,L,M) * CARBF(IN,L) * EXCHRATE(L) ! if electricity sectors only have carbon costs IF (Iswitch.ge.1.and.IO.NE.NELEC) & CPRICER(IN,IDEFSNO,L,M)=0.d0

Page 65: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

65

END DO END DO CPRICER(IN,IDEFS(NIS,1,L),L,M)= P(NIN-3,L,M) * CARBF(IN,L) & * EXCHRATE(L) CPRICER(IN,IDEFS(NIS-1,1,L),L,M)= P(NIN-3,L,M) * CARBF(IN,L) & * EXCHRATE(L) CPRICER(IN,IDEFS(NIS-3,1,L),L,M)= P(NIN-3,L,M) * CARBF(IN,L) & * EXCHRATE(L) END DO RETURN END

Page 66: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

66

C***********************************************************************

SUBROUTINE GHG C This routine puts emissions to be controlled into the ED array C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' CALL GHGEMIS C put emissions into the ED array IF (CARBPRICEP(1,L).EQ.1) THEN DO IN = 1,NIO ED(NIN-3,IN,L,M) = 0.0 !initialize carbon demands END DO DO IX = 1,NSOURCE(L) IF (EMC(IX,5,L) .EQ. -1) CYCLE !skip if driver isnot a greenhouse gas IF (CARBPRICEP(3,L) .EQ. 1 .OR. EMC(IX,5,L) .EQ. 1) THEN ! IF all gases are included OR include for CO2 only is set (or both) THEN ED(NIN-3,EMC(IX,4,L),L,M) = ED(NIN-3,EMC(IX,4,L),L,M) & + EM(IX,L,M) END IF END DO ED(NIN-3,NIS-4,L,M) = - CARBONLIM(L,M) !-carblim is the supply of permits SALES(1,NIN-3,L,M) = CARBONLIM(L,M) END IF RETURN END

Page 67: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

67

C***********************************************************************

SUBROUTINE GHGEMIS C Compute greenhouse gas emissions from economic activity levels C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' C . Local Variables REAL*8 DEMAND(NINP,NISP,NLP,0:NMP), ! demand by input and sector & TOTDMD(NINP,NLP,0:NMP) ! Total demand by input REAL*8 EDEMAND(NINP,NISP,NLP,0:NMP), ! energy demand by input and sector that produces emissions & TOTEDMD(NINP,NLP,0:NMP) ! Total demand by input NELEC = 8 NGCCcd = 14 NCoalIGCCcd = 15 NPCcd = 16 DO IN = 1,NIO !22 ! for emissions we are interested in IN=3:10 TOTDMD(IN,L,M) = 0.D0 TOTEDMD(IN,L,M) = 0.D0 DO IS = 1,NIS ! for emissions by production sectors EDEMAND(IN,IS,L,M) = 0.D0 ENDDO ENDDO DO IS = 1,NIS ! for emissions by production sectors DO IN = 1,NIO !22 ! for emissions we are interested in IN=3:10 IF (IS.LE.NIO .AND. IN.EQ.IS) THEN DEMAND(IN,IS,L,M) = ED(IN,IS,L,M) & + SALES(1,IS,L,M) ! NOTE SALES IS BACK IN: important when going back to EDVIN ELSE DEMAND(IN,IS,L,M) = ED(IN,IS,L,M) !(E)DEMAND to be reduced if capture and disposal END IF C Check iswitch=1 IF (iswitch.ge.1) THEN ! electricity sector emissions tracked for coal, gasT&D and refined oil in electricityswitch.csv IF (IS.EQ.NELEC) THEN DO ISS=1,NISS(IS,L) DO IVIN = M-3,M IF (ISS.lt.NGCCcd) THEN ! no carbon capture and disposal IF (IS.LE.NIO .AND. IN.EQ.IS) THEN EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & (EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) + & PRDVIN(IS,ISS,IVIN,L)) ELSE ! no own use EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) END IF ! ELSE ! capture and disposal IF (ISS.ge.NGCCcd) THEN IF (IS.LE.NIO .AND. IN.EQ.IS) THEN EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & (EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) + & PRDVIN(IS,ISS,IVIN,L)) * 0.1d0 ELSE ! no own use EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) * 0.1d0 END IF END IF END IF ! end cd END DO ! IVIN END DO ! ISS ELSE ! end of sub-sectors 14 through 16 DO ISS=1,NISS(IS,L) ! need iss and ivin loops here again DO IVIN = M-3,M EDEMAND(IN,ISS,L,M) = 0.d0 END DO ! IVIN END DO ! ISS END IF ! NELEC end of if electricty sector only has emission

Page 68: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

68

ELSE ! iswitch = 0 > all sectors: end of if electricty sector only has emissions DO ISS=1,NISS(IS,L) DO IVIN = M-3,M IF (ISS.lt.NGCCcd) THEN ! no carbon capture and disposal IF (IS.LE.NIO .AND. IN.EQ.IS) THEN EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & (EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) + & PRDVIN(IS,ISS,IVIN,L)) ELSE ! no own use EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) END IF ! ELSE ! capture and disposal sqccs=0.1d0 IF (ISS.ge.NGCCcd) THEN IF (IS.LE.NIO .AND. IN.EQ.IS) THEN EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & (EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) + & PRDVIN(IS,ISS,IVIN,L)) * sqccs ELSE ! no own use EDEMAND(IN,IS,L,M) = EDEMAND(IN,IS,L,M) + & EDVIN(IN,IDEFS(IS,ISS,L),IVIN,L) * sqccs END IF END IF END IF ! end cd END DO ! IVIN END DO ! ISS END IF !iswitch C check iswitch=0 C IF (IS.EQ.NIS-3) THEN ! take care of trade TOTDMD(IN,L,M) = TOTDMD(IN,L,M) TOTEDMD(IN,L,M)= TOTEDMD(IN,L,M) ELSE TOTDMD(IN,L,M) = TOTDMD(IN,L,M) & + DEMAND(IN,IS,L,M) TOTEDMD(IN,L,M)= TOTEDMD(IN,L,M) & + EDEMAND(IN,IS,L,M) END IF ! if not trade END DO !IN END DO ! IS C Set all EMACTY(...) to the total demand in the main sector specified in EMC(_,4,L) DO IX = 1,NSOURCE(L) EMACTY(IX,L) = TOTDMD(EMC(IX,4,L),L,M) * PRCONVRT(EMC(IX,4,L),L) END DO C ! We now always need EDEMAND() that is, TOTEDMD ! because when iswitch=0 EDEMAND=DEMAND, when iswitch=1 then only electricity DO IX = 1,NSOURCE(L) EMACTY(IX,L) = TOTEDMD(EMC(IX,4,L),L,M) * PRCONVRT(EMC(IX,4,L),L) !PRCONVRT for oil, gas and coal-time independent END DO C REDUCED TOTEDMD IF carboncapture and disposal C Now hard code all the adjustments to deal with things like trade C ** OIL ** C include trade of refined oil IF (EMC(1,4,L).eq.3) then EMACTY(1,L) = 0.97 * EMACTY(1,L) - (TRADE(0,9,L,M)*PRCONVRT(9,L)) END IF C ---SNFU--- C ** GAS ** C include trade of city gas IF (EMC(2,4,L).eq.4) then EMACTY(2,L) = EMACTY(2,L) - (TRADE(0,10,L,M) * PRCONVRT(10,L)) end if C If period = 0 then scale the actual base values in EMC(_,1,L) C -this will depend on if a coefficient or base year emissions C are read in (EMC(_,2,L)) IF (M .EQ.0) THEN DO IX = 1,NSOURCE(L) IF (EMC(IX,2,L) .EQ. 1) THEN if (emacty(ix,l) .gt. 0) then !we have base year emissions EMC(IX,1,L) = EMC(IX,1,L) / EMACTY(IX,L) EMCBASE(IX,L,1) = EMC(IX,1,L) !store base year emissions in Tg EMCBASE(IX,L,2) = EMC(IX,3,L) !store gas emitted from driver else

Page 69: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

69

emc(ix,1,l) = 0 ! no emissions in sector if base year driver is zero end if END IF EMC(IX,10,L) = EMC(IX,1,L) * (1.0+EMCADJ(IX,L,M)) !the line above is in GETCFEE for M greater than 0 END DO END IF C . Calculate emissions from emissions activities and emissions C . coefficients which were read from input sheet. DO IX = 1,NSOURCE(L) EM(IX,L,M) = EMACTY(IX,L) * EMC(IX,10,L) * GWP(EMC(IX,3,L),L,M) END DO C EMTOT(L,M) Stores total _controlled_ emissions by region and period EMTOT(L,M) = 0.0 DO IX = 1,NSOURCE(L) IF (EMC(IX,5,L) .EQ. -1) CYCLE !skip if driver is not a greenhouse gas IF (CARBPRICEP(3,L) .EQ. 1 .OR. EMC(IX,5,L) .EQ. 1) THEN C IF all gases are included OR include for CO2 only is set (or both) THEN EMTOT(L,M) = EMTOT(L,M) + EM(IX,L,M) END IF END DO C Code to calculate emissions by end use sector ------ ! sum vintages of edvin to create IO table DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IN = 1,NIN IF (M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M).GT.-3) THEN NVINI = M-NTECHCHAR(3,IDEF(IO,ISS,L),L,M) ELSE NVINI = -3 END IF IOstore(IN,IDEFS(IO,ISS,L)) = 0.0 DO IVINc = NVINI,M IOstore(IN,IDEFS(IO,ISS,L)) = & IOstore(IN,IDEFS(IO,ISS,L)) & + EDVIN(IN,IDEFS(IO,ISS,L),IVINc,L) END DO END DO END DO END DO ! sum rows of IO table for Oil, Gas, and Coal Production DO IN = 3,5 IOrowsum(IN,L) = 0 DO IO=1,NIO if (IO .ne. IN) then DO ISS=1,NISS(IO,L) if (IO.eq.8 .and. ISS .ge. 14) then !account for ccs IOrowsum(IN,L) = IOrowsum(IN,L) & + sqccs*IOstore(IN,IDEFS(IO,ISS,L)) else IOrowsum(IN,L) = IOrowsum(IN,L) & +IOstore(IN,IDEFS(IO,ISS,L)) end if END DO end if END DO PriEnergyC(IN,L,M)=IOrowsum(IN,L) END DO ! calculate % of total Oil Gas and Coal used in each sector DO IN = 3,5 DO IO=1,NIO DO ISS=1,NISS(IO,L) if (IOrowsum(IN,L) .gt. 0 .and. IN .ne. IO) then if (IO.eq.8 .and. ISS .ge. 14) then IOpct(IN,IDEFS(IO,ISS,L)) = & sqccs*IOstore(IN,IDEFS(IO,ISS,L)) / IOrowsum(IN,L) else IOpct(IN,IDEFS(IO,ISS,L)) = & IOstore(IN,IDEFS(IO,ISS,L)) / IOrowsum(IN,L) end if else IOpct(IN,IDEFS(IO,ISS,L)) = 0 end if END DO END DO END DO

Page 70: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

70

! attribute total emissions from Oil Gas and Coal to end use sectors DO IN = 3,5 IX = IN-2 DO IO=1,NIO DO ISS=1,NISS(IO,L) IOemis(IX,IDEFS(IO,ISS,L),M,1) = & IOpct(IN,IDEFS(IO,ISS,L))*EM(IX,L,M) END DO END DO END DO ! sum rows of IO table for RefOil and GasT&D Production DO IN = 9,10 IOrowsum(IN,L) = 0 DO IO=1,NIO if (IO .ne. IN) then DO ISS=1,NISS(IO,L) if (IO.eq.8 .and. ISS .ge. 14) then !account for ccs IOrowsum(IN,L) = IOrowsum(IN,L) & + sqccs*IOstore(IN,IDEFS(IO,ISS,L)) else IOrowsum(IN,L) = IOrowsum(IN,L) & +IOstore(IN,IDEFS(IO,ISS,L)) end if END DO end if END DO END DO ! calculate % of total RefOil and GasT&D used in each sector DO IN = 9,10 DO IO=1,NIO DO ISS=1,NISS(IO,L) if (IOrowsum(IN,L) .gt. 0 .and. IN .ne. IO) then if (IO.eq.8 .and. ISS .ge. 14) then IOpct(IN,IDEFS(IO,ISS,L)) = & sqccs*IOstore(IN,IDEFS(IO,ISS,L)) / IOrowsum(IN,L) else IOpct(IN,IDEFS(IO,ISS,L)) = & IOstore(IN,IDEFS(IO,ISS,L)) / IOrowsum(IN,L) end if else IOpct(IN,IDEFS(IO,ISS,L)) = 0 end if END DO END DO END DO ! attribute total emissions from RefOil and GasT&D to end use sectors DO IN = 9,10 IX = IN - 8 DO IO=1,NIO DO ISS=1,NISS(IO,L) IOemis(IX,IDEFS(IO,ISS,L),M,2) = & IOpct(IN,IDEFS(IO,ISS,L)) & * IOemis(IX,IDEFS(IN,1,L),M,1) END DO END DO END DO ! combine end use emissions from above DO IX = 1,3 DO IO = 1,NIO DO ISS = 1,NISS(IO,L) IOemis(IX,IDEFS(IO,ISS,L),M,3) = & IOemis(IX,IDEFS(IO,ISS,L),M,1) & + IOemis(IX,IDEFS(IO,ISS,L),M,2) if (IO .eq. 9 .and. IX .eq. 1) then IOemis(IX,IDEFS(IO,ISS,L),M,3) = 0.0 end if if (IO .eq. 10 .and. IX .eq. 2) then IOemis(IX,IDEFS(IO,ISS,L),M,3) = 0.0 end if END DO END DO END DO ! add up end use co2 emissions DO IO = 1,NIO IOemisCO2(IO,M,L) = 0.0

Page 71: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

71

DO IX = 1,3 DO ISS = 1,NISS(IO,L) IOemisCO2(IO,M,L) = & IOemisCO2(IO,M,L) + & + IOemis(IX,IDEFS(IO,ISS,L),M,3) END DO END DO END DO C End code to calculate emissions by end use sector C Primary energy use DO IN = 3,5 IOrowsum(IN,L) = 0 DO IO=1,NIO if (IO .ne. IN) then DO ISS=1,NISS(IO,L) IOrowsum(IN,L) = IOrowsum(IN,L) & +IOstore(IN,IDEFS(IO,ISS,L)) END DO end if END DO PriEnergyC(IN,L,M)=IOrowsum(IN,L)*PRCONVRT(IN,L)*1000 END DO DO IN = 3,9 IOsubsum(IN,L) = 0 IO=8 DO ISS=1,NISS(IO,L) IOsubsum(IN,L) = IOsubsum(IN,L) & +IOstore(IN,IDEFS(IO,ISS,L)) END DO PriEnergyCelec(IN,L,M)=IOsubsum(IN,L)*PRCONVRT(IN,L)*1000 END DO C End primary energy use C **** BEGIN BACKSTOP CODE (skipped, not tested) **** C . . Implement carbon-free backstop in cases where carbon price exceeds C . . backstop value (Backstop entered in 1985 US$) C Store regional pre-backstop emissions for calculation of emissions C avoided by backstop CO2TOTG(L,M) = EMTOT(L,M) C Check to see if backstop exists IF (CFBSTOP(M).NE.0.D0) THEN C Check to see if regional fee is at backstop level IF (P(NIN-3,L,M).EQ.CFBSTOP(M)) THEN C Check to see that emissions are greater than limit IF (CO2TOTG(L,M).GE.CARBONLIM(L,M)) THEN C Set emissions equal to target level EMTOT(L,M) = CARBONLIM(L,M) C Fix price at backstop level IPFIX(NIN-3,L,M) = .TRUE. ELSE IPFIX(NIN-3,L,M) = .FALSE. P(NIN-3,L,M) = CFBSTOP(M)*0.8 END IF END IF END IF C **** END BACKSTOP CODE **** RETURN END

Page 72: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

72

C**********************************************************************

SUBROUTINE GOVT C This subroutine provides estimates for government sector demands. C Allocation across subsectors is on the basis of a CES preference C function normalized to exhaust TAX - SUBSID - GOVTR. Each subsector C purchases a fixed weight from each production sector. C C Collect Taxes from the government and include them in the government's C budget constraint C C Option added to allow percentage allocation of carbon price revenues C to general revenues, households and industry C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' logical print,print1 print = .false. print1 = .false. if(m .eq. 1 .or. m .eq. 0)print = .true. if(m .eq. 1 .or. m .eq. 0)print1 = .true. C . Compute resources left after subsidies and transfers. TOTTAX(L) = 0.0 SUBSIDY(L,M) = 0.0 DO IN = 1,NIN SUBSIDY(L,M) = SUBSIDY(L,M) + SUBSID(IN,L) END DO SUBSIDY(L,M) = SUBSIDY(L,M) + SUBSIDGOV(L) !add in estimated govt. subsidy C . Now compute total tax income; first place estimated govt taxes into the array c the TAXGOV that is used here was calculated last model evaluation TAX(1,NIS-1,L) = TAXGOV(1,L) !positive TXPRO and TXADD taxes TAX(2,NIS-1,L) = TAXGOV(2,L) !TXPRO and TXADD taxes on labor TAX(5,NIS-1,L) = TAXGOV(5,L) !carbon price DO IS = 1,NIS DO ITC = 1,5 TOTTAX(L) = TOTTAX(L) + TAX(ITC,IS,L) END DO END DO C . Note that government deficit is stated in real base year dollars. C . To keep the accounting straight this needs to be reflected in nominal C . dollars. GOVDEFT(L,M) = GOVDEFT(L,M) * PI(NETE,IDEFS(NIS-1,1,L),L,M,1) GOVMT(L,M) = TOTTAX(L) - SUBSIDY(L,M) GOVMT(L,M) = GOVMT(L,M) - GOVTR(L,M) GOVMT(L,M) = GOVMT(L,M) + GOVDEFT(L,M) C . Recycle carbon price proceeds in alternative fashion depending C . on ICRBTXOPT. ICRBTXOPT = 0 No carbon price C . . . . . . . ICRBTXOPT = 1 carbon price to general revenues C . . . . . . . ICRBTXOPT = 2 carbon price to deficit reduction. C . . . . . . . ICRBTXOPT = 3 carbon price to consumers C . . . . . . . ICRBTXOPT = 4 40% Households, 60% Industry C . . . . . . . ICRBTXOPT = 5 Domestic to consumers, permits to Deficit C ICRBTXOPT = 6 CrbPriceRcyPct (1) to govt revenues ! CrbPriceRcyPct (2) to hhold ! CrbPriceRcyPct (3) to industry C . Note that government tax revenues include carbon price at this point so C . opt = 1 requires no changes. Also note that a deficit is treated C . as a positive number so that the tax has to be subtracted. PINC is C . modified in hhold so that household income reflects the transfer C . under options 3, 4, and 5. Allocate_CarbPrice: Select Case (Icrbtxopt) Case (0:1) ! no action required

Page 73: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

73

Case (2) ! carbon price to deficit reduction. GOVMT(L,M) = GOVMT(L,M)-CRBPRICETOT(L,M) GOVDEFT(L,M) = GOVDEFT(L,M)-CRBPRICETOT(L,M) Case(3:4) ! all revenues to other sectors GOVMT(L,M) = GOVMT(L,M) - CRBPRICETOT(L,M) Case (5) ! Domestic to consumers, permits to Deficit IF (TRADECARB(L,M).GT.0.0) THEN GOVMT(L,M) = GOVMT(L,M)-CRBPRICETOT(L,M) GOVDEFT(L,M) = GOVDEFT(L,M)-TRADECARB(L,M) ELSE GOVMT(L,M) = GOVMT(L,M)-CRBPRICETOT(L,M) END IF Case (6) GOVMT(L,M) = GOVMT(L,M)-(CrbPriceRcyPct(2)+CrbPriceRcyPct(3)) & * CRBPRICETOT(L,M) End Select Allocate_CarbPrice C . Compute expenditures by subsector of government. C . First compute subsector prices using fixed weights. DO ISS = 1,NISS(NIS-1,L) PGC(ISS) = 0. DO IN = 1,NIN-1 PGC(ISS) = PGC(ISS) + GC(IN,ISS,L,M) & * PI(IN,IDEFS(NIS-1,ISS,L),L,M,1) END DO PGC(ISS) = PGC(ISS) + GC(NIN,ISS,L,M) & * PI(NETE,IDEFS(NIS-1,1,L),L,M,1) END DO C . Compute demands given total government resources GOVMT(L,M). C . First estimate term involving Lagrange multiplier and value C . of government preference function IRHO = NISS(NIS-1,L) + 1 RHO = GF(IRHO,L,M) SIG = 1. / (1.-RHO) TEMP = 0.0 DO ISS = 1,NISS(NIS-1,L) TEMP = TEMP + PGC(ISS) ** (- RHO * SIG) * GF(ISS,L,M) ** SIG END DO TEMP = GOVMT(L,M) / TEMP C . Compute total units purchased by category DO ISS = 1,NISS(NIS-1,L) GE(ISS,L,M) = TEMP * PGC(ISS) ** (- SIG) * GF(ISS,L,M) ** SIG END DO C . Allocate subsector purchases across production sectors using GC, DO IN = 1,NIN-1 ED(IN,NIS-1,L,M) = 0.0 DO ISS = 1,NISS(NIS-1,L) ED(IN,NIS-1,L,M) = ED(IN,NIS-1,L,M) & + GE(ISS,L,M) * GC(IN,ISS,L,M) END DO END DO c initialize government taxes and subsidies SUBSIDGOV(L) = 0.0 DO ITC = 1,5 TAXGOV(ITC,L) = 0.0 END DO C figure out government taxes, they are paid to itself next model evaluation DO IN = 1,NIN-1 ISS = 1 !*** Makes TXPRO and TXADD the same across govt subsectors ITC = 1 IF (IN .EQ. NIN-1) ITC = 2 IF ((TXPRO(IN,IDEFS(NIS-1,ISS,L),L,M) - 1.0) .GT. 0.0) THEN TAXGOV(ITC,L) = TAXGOV(ITC,L) + & (P(IN,L,M) + TR(IN,L,M) * EXIMPORT(IN,L,M)) & * ED(IN,NIS-1,L,M) & * (TXPRO(IN,IDEFS(NIS-1,ISS,L),L,M) - 1.0) ELSE IF ((TXPRO(IN,IDEFS(NIS-1,ISS,L),L,M) - 1.0) .LT. 0.0) & THEN

Page 74: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

74

SUBSIDGOV(L) = SUBSIDGOV(L) & - (P(IN,L,M) + EXIMPORT(IN,L,M) & * TR(IN,L,M)) & * ED(IN,NIS-1,L,M) & * (TXPRO(IN,IDEFS(NIS-1,ISS,L),L,M) - 1.0) END IF C . . Per Unit taxes IF (TXADD(IN,IDEFS(NIS-1,ISS,L),L,M) .GE. 0.0) THEN TAXGOV(ITC,L) = TAXGOV(ITC,L) + & ED(IN,NIS-1,L,M) * TXADD(IN,IDEFS(NIS-1,ISS,L),L,M) ELSE SUBSIDGOV(L) = SUBSIDGOV(L) & - ED(IN,NIS-1,L,M) & * TXADD(IN,IDEFS(NIS-1,ISS,L),L,M) END IF C ...carbon price IF (CPRICER(IN,IDEFS(NIS-1,1,L),L,M) .GT. 0.0) THEN TAXGOV(5,L) = TAXGOV(5,L) + & CPRICER(IN,IDEFS(NIS-1,1,L),L,M) * ED(IN,NIS-1,L,M) !NIS-1 END IF END DO !end loop over inputs C . Treat capital demands separately to generate both financial C . and physical demands. Note that PI(NETE...) is needed even if C . P(NETE...) is set to one as numeraire. Note that government C . saves automatically, so government capital does not, in this version, C . increase demand for savings. ED(NIN,NIS-1,L,M) = 0.0 t1 = 0.0 DO ISS = 1, NISS(NIS-1,L) t1 = t1 + ge(iss,l,m) * gc(nin,iss,l,m) * pgc(iss) ED(NIN,NIS-1,L,M) = ED(NIN,NIS-1,L,M) + t1 t2 = GE(ISS,L,M) * GC(NIN,ISS,L,M) ED(NETE,NIS-2,L,M) = ED(NETE,NIS-2,L,M) + t2 END DO C . Add government deficit to the demand for savings. ED(NIN,NIS-1,L,M) = ED(NIN,NIS-1,L,M) + GOVDEFT(L,M) C . Need code to handle government capital demands. Now they are C . simply passed straight through as investment demands. No accounting C . for previous stocks is made. RETURN END

Page 75: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

75

C**********************************************************************

SUBROUTINE GPCM C C GPCM is called for a specific market (IO), region (L), and C period (M). It computes excess demands & investment demands C for all market commodities IO=1,NIO. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' LOGICAL PRINT PRINT = .FALSE. C . Initialize all demand to zero. DO IVIN=NVIN0,M DO ISS=1,NISS(IO,L) DO IN = 1,NIN EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = 0.D0 ! Gpcm called in an IO loop END DO END DO END DO C . Operate the new capital stocks. IVIN=M CALL OPERATENEW C . Operate existing vintages. DO IVIN=NVIN0,M-1 CALL OPERATEOLD END DO RETURN END

Page 76: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

76

C**********************************************************************

SUBROUTINE HHOLD C This subroutine provides estimates for the household. Outputs C include savings, consumption, household formation, labor supply, C labor demands, land supply, and land demands C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' C . If carbon price is rebated to households, adjust after tax personal C . income at this point. Allocate_CarbPrice: Select Case (Icrbtxopt) Case (0:2) ! no action required Case (3) !all to consumers PINC(L)=PINC(L)+CRBPRICETOT(L,M) HHINC(7,L)=HHINC(7,L)+CRBPRICETOT(L,M) Case (4) !40% to consumers 60% to industry PINC(L)=PINC(L) + 0.4 * CRBPRICETOT(L,M) HHINC(7,L)=HHINC(7,L) + 0.4 * CRBPRICETOT(L,M) Case (5) !domestic to consumers, permits to deficit IF (TRADECARB(L,M).GT.0.0) THEN ! trading revenue + PINC(L) = PINC(L) + CRBPRICETOT(L,M) - TRADECARB(L,M) HHINC(7,L) = HHINC(7,L) + CRBPRICETOT(L,M) - TRADECARB(L,M) ELSE !trading loss so just use CRBPRICETOT PINC(L) = PINC(L) + CRBPRICETOT(L,M) HHINC(7,L) = HHINC(7,L) + CRBPRICETOT(L,M) END IF Case (6) ! CrbPriceRcyPct(2) goes to households PINC(L)=PINC(L) + CrbPriceRcyPct(2) * CRBPRICETOT(L,M) HHINC(7,L)=HHINC(7,L) + CrbPriceRcyPct(2) * CRBPRICETOT(L,M) END Select Allocate_CarbPrice C . First determine household savings using a simple exponential C . model. SAVING(L,M) = 0.0 ED(NIN,NIS,L,M) = - (S(0,L,M) * PINC(L) & * (1. - S(1,L,M) * EXP(S(2,L,M) & * P(NIN,L,M)))) HHINC(8,L) = -ED(NIN,NIS,L,M) SAVING(L,M) = -ED(NIN,NIS,L,M) C . Now compute consumption expenditures (note that savings is negative) PINC(L) = PINC(L) + ED(NIN,NIS,L,M) CONS(L,M) = PINC(L) C . Add corporate retained earnings to savings to get total savings C . supply. ED(NIN,NIS,L,M) = ED(NIN,NIS,L,M) - TRETE(L) SALES(1,NIN,L,M) = -ED(NIN,NIS,L,M) C . First pass through consumer demand equations. These are quantity C . equations so need to be multiplied by price to get budget constraint C . correctly applied. C . Each consumer demand category has an income elasticity given by C . E(1,...) and a price elastiticy given by e(2,...). TEMP = 0.0 ISS = 1 DO IN = 1, NIO ED(IN,NIS,L,M) = E(0,IN,L,M) * (PINC(L) & / PI(NETE,IDEFS(NIS,ISS,L),L,M,1)) ** E(1,IN,L,M) & * (PI(IN,IDEFS(NIS,ISS,L),L,M,1) & / PI(NETE,IDEFS(NIS,ISS,L),L,M,1)) ** E(2,IN,L,M) TEMP = TEMP + ED(IN,NIS,L,M) * PI(IN,IDEFS(NIS,ISS,L),L,M,1) END DO C . Remove labor and land expenditures from personal income available

Page 77: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

77

C . to purchase produced commodites(IN = 1, NIO). ISS = 1 HHINC(9,L) = PI(NIN-1,IDEFS(NIS,ISS,L),L,M,1) * LB(2,2,L,M) & * ( - ED(NIN-1,NIS,L,M)) PINC(L) = PINC(L) - HHINC(9,L) HHINC(10,L) = PI(NIN-2,IDEFS(NIS,ISS,L),L,M,1) * R(2,L,M) & * NHH(L,M) PINC(L) = PINC(L) - HHINC(10,L) C . Consumer purchases of housing should be subtracted from PINC C . also. C . Now adjust each consumption category so budget constraint is C . satisfied. Divide by sector price to get physical units. DO IN = 1,NIO ED(IN,NIS,L,M) = ED(IN,NIS,L,M) * PINC(L) / TEMP END DO C . Note that households purchase capital services from the ETE sector C . in this version of the model. C . Social security taxes are collected in ACCOUNT.FOR so that loop C . runs only over NIN-2. carbon price are counted here to provide an C estimate for the next model evaluation TAXCHH(L) = 0.0 DO IN = 1,NIN - 2 C . . Collect transportation costs for markets with imports C . . Divide by PI(NETE...) to get physical units for supply sector. TRNP(IN,L) = TRNP(IN,L) + TR(IN,L,M) * EXIMPORT(IN,L,M) & * ED(IN,NIS,L,M) & / PI(NETE,IDEFS(NIS,ISS,L),L,M,1) C . . Collect tax receipts C . . Ad valorem taxes IF ((TXPRO(IN,IDEFS(NIS,ISS,L),L,M) - 1.0) .GE. 0.0) THEN TAX(1,NIS,L) = TAX(1,NIS,L) + & (P(IN,L,M) + TR(IN,L,M) * EXIMPORT(IN,L,M)) & * ABS(ED(IN,NIS,L,M)) & * (TXPRO(IN,IDEFS(NIS,ISS,L),L,M) - 1.0) ELSE SUBSID(IN,L) = SUBSID(IN,L) & + (P(IN,L,M) + EXIMPORT(IN,L,M) * TR(IN,L,M)) & * ED(IN,NIS,L,M) & * (TXPRO(IN,IDEFS(NIS,ISS,L),L,M) - 1.0) END IF C . . Per Unit taxes IF (TXADD(IN,IDEFS(NIS,ISS,L),L,M) .GE. 0.0) THEN TAX(1,NIS,L) = TAX(1,NIS,L) + & ED(IN,NIS,L,M) * TXADD(IN,IDEFS(NIS,ISS,L),L,M) ELSE SUBSID(IN,L) = SUBSID(IN,L) - & ED(IN,NIS,L,M) * TXADD(IN,IDEFS(NIS,ISS,L),L,M) END IF C ...carbon price IF (CPRICER(IN,IDEFS(NIS,1,L),L,M) .GT. 0.0) THEN TAXCHH(L) = TAXCHH(L) + CPRICER(IN,IDEFS(NIS,1,L),L,M) & * ED(IN,NIS,L,M) END IF c the TAXGOV that is used here was caluclated last model evaluation TAX(1,NIS-1,L) = TAXGOV(1,L) !positive TXPRO and TXADD taxes TAX(2,NIS-1,L) = TAXGOV(2,L) !TXPRO and TXADD taxes on labor TAX(5,NIS-1,L) = TAXGOV(5,L) !carbon price C . . Collect adjustment factor--representing distribution and C . . markup factors. Divide by PI(NIO...) to get physical units C . . for supply sector. WHSL(IN,L) = WHSL(IN,L) + (ADJ(IN,IDEFS(NIS,ISS,L),L,M) - 1.0) & * (((P(IN,L,M) + TR(IN,L,M) * EXIMPORT(IN,L,M)) & * TXPRO(IN,IDEFS(NIS,ISS,L),L,M)) & + TXADD(IN,IDEFS(NIS,ISS,L),L,M)) & * ED(IN,NIS,L,M) / PI(NETE,IDEFS(NIS,ISS,L),L,M,1) END DO C . Remove demand for household labor from total labor supply to get C . supply available to the rest of the economy. ED(NIN-1,NIS,L,M) = ED(NIN-1,NIS,L,M) * (1. - LB(2,2,L,M)) RETURN END

Page 78: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

78

Page 79: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

79

C**********************************************************************

SUBROUTINE IMPEX C The trade sector is denoted as NIS - 3. The final demand sectors C are all denoted relative to sector NIS, so that the number of productive C sectors can be freely varied. C C This subroutine looks to the value in TRADE(0,NIN,L,M) to define C the trade surplus. It is (+) for a surplus and (-) for a deficit. C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' C Add international carbon trading revenue or expense to capital inflow/outflow C given in TRADE(0,NIN,L,M). Use CAPTRD(L,M) as intermediate so that the baseline C TRADE(0,NIN,L,M) value remains the starting point for the calculation. TRADE(0,NIN,L,M) = CAPTRD(L,M) - TRADECARB(L,M) C . Copy trade quantities into excess demand array. This is needed C . for solution mechanism to work correctly for sectors with fixed C . trade or no trade. DO IN = 1,NIN IF (MKTLINK(IN,L) .EQ. 0) THEN ED(IN,NIS-3,L,M) = TRADE(0,IN,L,M) END IF END DO C . Calculate trade for all sectors with open trade as difference C . between production and all other uses within a region. This C . is done by calculating row sums of the ED array. Trade for C . the ETE sector is calculated in the same way as any other C . sector open to trade. MKTLINK for the ETE sector must be set C . equal to 1. DO IN=1,NIO IF(MKTLINK(IN,L) .EQ. 1) THEN TRADE(1,IN,L,M) = 0.0 DO J=1,NIS TRADE(1,IN,L,M) = TRADE(1,IN,L,M) - ED(IN,J,L,M) END DO END IF END DO C Carbon market trade (when carbon price is in effect) IN=NIN-3 IF(MKTLINK(IN,L) .EQ. 1) THEN TRADE(1,IN,L,M) = 0.0 IF(M.GE.CARBPRICEP(6,L) .AND. P(IN,L,M).GT.0.0) THEN DO J=1,NIS TRADE(1,IN,L,M) = TRADE(1,IN,L,M) - ED(IN,J,L,M) END DO END IF END IF C Copy trade values into the trade sector of the ED array. DO IN=1,NIN-1 IF(MKTLINK(IN,L) .EQ. 1 .AND. IPFIX(IN,L,M)) THEN c & .and. in .ne. (nin-3)) then ED(IN,NIS-3,L,M) = TRADE(1,IN,L,M) END IF END DO C . Calculate trade balance using the TRADE array, prices, and C . taxes. This calculation does not affect model results, but C . is a diagnostic indicator to make sure that the trade surplus C . (deficit) matches exogenously given capital outflow (inflow). C For international carbon market, temporarily convert trade C to local currency (for adding to trade balance) C Convert back after next loop. TRADE(1,NIN-3,L,M) = TRADE(1,NIN-3,L,M)*EXCHRATE(L) EXIM(L,M) = 0.0 C . For imports, and exports, DO IN = 1,NIN-1 EXIM(L,M) = EXIM(L,M) + TRADE(1,IN,L,M) & *P(IN,L,M)

Page 80: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

80

END DO C Remove carbon trade from net exports EXIM(L,M) = EXIM(L,M) - TRADE(1,NIN-3,L,M) * P(NIN-3,L,M) C convert carbon trade back to TgC units TRADE(1,NIN-3,L,M) = TRADE(1,NIN-3,L,M)/EXCHRATE(L) RETURN END

Page 81: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

81

C**********************************************************************

SUBROUTINE IMPEXold C********************************************************************** C C This subroutine provides estimates for trade demands/supplies C when less than a full version of the SGM is run. The subroutine C has two modes. The first uses excess demand functions to model C the performance of the relevant external sector. These function C require a price at which there would be zero excess demand C (i.e no trade) and an elasticity. The other fixes imports(negative) C or exports at a level and lets the domestic market solve given this C supply/demand. C C The trade sector is denoted as NIS + 1. The final demand sectors C are all denoted relative to sector NIS, so that the number of productive C sectors can be freely varied. C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' C . Note that imports and exports are aggregated to the market level and C . have no subsectors or technologies. C . For capital subsector, price is one for the present. EXIM(L,M) = 0.0 DO IN = 1,NIN C . . First check to see if trade is allowed in this sector. C . . For the time being trade balance is exogenous C . . Imports should reflect PI rather than P, but PI is on a C . . subsector basis c . . NOTE THAT PI IS NOW USED BUT FOR CONSUMERS BECAUSE THE NECESSARY C . . INPUTS FOR THE TRADE SECTOR ARE NOT AVAILABLE ISS = 1 C IF (MKTLINK(IN,L) .GT. 0) THEN ED(IN,NIS-3,L,M) = TRADE(1,IN,L,M) C IF (IN .LT. NIN .and. in .ne. nete) THEN IF (IN .LT. NIN) THEN IF (TRADE(1,IN,L,M) .LT. 0.0) THEN EXIM(L,M) = EXIM(L,M) + TRADE(1,IN,L,M) & * (PI(IN,IDEFS(NIS,1,L),L,M,1) & - TXADD(IN,IDEFS(NIS,1,L),L,M) & - CPRICER(IN,IDEFS(NIS-3,1,L),L,M)) ELSE EXIM(L,M) = EXIM(L,M) + TRADE(1,IN,L,M) & * P(IN,L,M) END IF C ELSE if (in .ne. nete) then ELSE IF (IN .EQ. NIN) THEN EXIM(L,M) = EXIM(L,M) + TRADE(1,IN,L,M) & * PI(NETE,IDEFS(NIS,1,L),L,M,1) ED(IN,NIS-3,L,M) = TRADE(1,IN,L,M) & * PI(NETE,IDEFS(NIS,1,L),L,M,1) END IF END DO C . Set imports/exports of everything else so that the trade balance is C . zero. if(exim(l,m) .lt. 0.0) then ed(nete,nis-3,l,m) = ed(nete,nis-3,l,m) - exim(l,m)/p(nete,l,m) EXIM(L,M) = EXIM(L,M) + ed(nete,nis-3,l,m) * P(nete,L,M) else ed(nete,nis-3,l,m) = ed(nete,nis-3,l,m) & - exim(l,m) / PI(NETE,IDEFS(NIS,1,L),L,M,1) EXIM(L,M) = EXIM(L,M) + ed(nete,nis-3,l,m) & * PI(NETE,IDEFS(NIS,1,L),L,M,1) end if END

Page 82: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

82

C**********************************************************************

SUBROUTINE INVST C C This subroutine collects all investments and distributes them to the C relevant sectors. (In version 0.0 it all goes to the ETE sector.) C It also allocates demand for transportation TR and the markup factor C ADJ (also to ETE in version 0.0) C*********************************************************************** C . . Include Common Blocks INCLUDE 'COMMON.BLK' C . Insert capital demands into appropriate places in the capital C . market excess demand vector. C . An array has been set up to share investment out to the sectors that C . produce capital goods. ETE is no longer the sole producer of C . capital goods. c Add capital demands from mitigation technologies to KDEM DO IX = 1, NSOURCE(L) IF (M.GT.3 .AND. EMT(IX,1,1,L) .GT. 0) THEN !if EMT exists iosec = EMC(IX,4,L) ISS = JEMT(IX,9,L) prdtot = SALES(1,iosec,L,M) - TRADE(0,iosec,L,M) VolGas = EMC(IX,10,L) / (1-EMTINTRP(IX,1,L,M))*PRCONVRT(iosec,L) !tons/$ pr_jprod = EMTJPR(IX,L) * ! 90$ joint product / ton of gas mitigated & (P(JEMT(IX,8,L),L,M) / P(JEMT(IX,8,L),L,0)) c make the joint product EMTACNT(IX,1,L,M)= (prdtot*VolGas*pr_jprod) * EMTINTRP(IX,1,L,M) ED(JEMT(IX,7,L),iosec,L,M) = ED(JEMT(IX,7,L),iosec,L,M) - & EMTACNT(IX,1,L,M) c investment demands EMTACNT(IX,2,L,M) = prdtot * EMTINTRP(IX,2,L,M) !investment KDEM(ISS,iosec,M,L) = KDEM(ISS,iosec,M,L) + EMTACNT(IX,2,L,M) c account the o&m costs (add them into ED) DO J = 3,6 EMTACNT(IX,J,L,M) = prdtot * EMTINTRP(IX,J,L,M) ED(JEMT(IX,J,L),iosec,L,M) = ED(JEMT(IX,J,L),iosec,L,M) + & EMTACNT(IX,J,L,M) END DO END IF END DO KTOT(L,M) = 0. TAXCINV(L) = 0. DO IO = 1,NIO DO ISS = 1, NISS(IO,L) DO IROW=1,NIO ED(IROW,NIS-2,L,M) = ED(IROW,NIS-2,L,M) + & KDEM(ISS,IO,M,L) * CAPMAT(IROW,IO,L) ED(NIN,NIS-2,L,M) = ED(NIN,NIS-2,L,M) + & KDEM(ISS,IO,M,L) * CAPMAT(IROW,IO,L) & * PI(IROW,IDEFS(IO,ISS,L),L,M,1) KTOT(L,M) = KTOT(L,M) + & KDEM(ISS,IO,M,L) * CAPMAT(IROW,IO,L) END DO END DO END DO DO IN = 1,NIO C ..Carbon Prices - estimate for next model evaluation IF (CPRICER(IN,IDEFS(NIS-2,1,L),L,M) .GT. 0.0) THEN TAXCINV(L) = TAXCINV(L) + CPRICER(IN,IDEFS(NIS-2,1,L),L,M) & * ED(IN,NIS-2,L,M) END IF END DO C . Allocate all transportation demand as final demand to C . the ETE sector.

Page 83: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

83

DO IN = 1,NIO ED(NETE,NIS-2,L,M) = ED(NETE,NIS-2,L,M) + TRNP(IN,L) END DO C . Allocate all distribution costs(WHSL) as final demand to C . the ETE sector. DO IN = 1,NIO ED(NETE,NIS-2,L,M) = ED(NETE,NIS-2,L,M) + WHSL(IN,L) END DO C . Develop estimate of GNP in region L for period M. GNP(L,M) = KTOT(L,M) + GOVMT(L,M) + CONS(L,M) + EXIM(L,M) RETURN END

Page 84: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

84

C***********************************************************************

PROGRAM SGM C THIS IS THE MAIN PROGRAM FOR THE SECOND GENERATION GREENHOUSE GAS C EMISSIONS MODEL. C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' EXTERNAL GETTIM EXTERNAL GETDAT REAL*4 GR,ERROR INTEGER*2 IHR, IMIN, ISEC, I100TH INTEGER*2 IYR, IMON, IDAY LOGICAL exists C . Display banner CALL BANNER C . Call control statements subroutine which reads in case name, C . description, and names of input and output files. ! set debug parameters modllimit = 6870 ! when SGM won't solve this is useful to get last few evaluations ! Force output of message and modmess (the solution and model debug files) Messageout = .false. Messageout = .true. IUNIT = 5 C . Get data and parameter values C Call File control file CALL SGMCTRL DO INF=1,INFILES OPEN(IUNIT,FILE=FILES(INF)) CALL SGMDATA CLOSE (IUNIT) END DO C Open Log file, which keeps tabs on basic run times, model iterations, C and also gets the error file if the model doesn't solve for any period INQUIRE(FILE = '..\sgmlog.csv', EXIST = exists) IF (exists) THEN ! OPEN (36, FILE = '..\sgmlog.csv', ACCESS = 'APPEND') OPEN (36, File = '..\sgmlog.csv') ! always open new file for now ELSE OPEN (36, FILE = '..\sgmlog.csv') END IF C . Large SGM output file. OPEN (11, FILE = OUT1FILE) OPEN (30,FILE=ENEMFILE) !SGMGEN 2000 FORMAT(A72) C . Microsoft uses this format for the date and time call. CALL GETTIM(IHR, IMIN, ISEC, I100TH) CALL GETDAT(IYR, IMON, IDAY) C . Write out case id information so runs can be identified. WRITE(11,2000)CASENAME WRITE(36,2000)CASENAME write(36,"(2(i2.2,'/'),i4,' ',i2,':',i2.2,':',i2.2'.' i2.2)") & imon,iday,iyr,ihr,imin,isec,i100th C ************************ C . BEGIN MODEL SOLUTION

Page 85: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

85

C ************************ MRK = 1 M = 0 C . Interpolate A's, etc... C . Market number 0 contains all region numbers DO LL = 1,NL L = MRKDEF(0,3+LL) CALL CESCALC CALL PPS CALL FIXC CALL TECH END DO C *************************** C . CALCULATE BASE YEAR RESULTS C *************************** C . Develop demographic information and get information needed C . to set up carbon markets if necessary DO LL = 1,NL L = MRKDEF(0,3+LL) CALL DEMOG CALL CARBONPRICE END DO CALL MODEL1 CALL POSTINI C Activate CALL POSTPER line to write out TESTING file C (Must activate CALL POSTPER line below as well) CALL POSTPER CALL EBAL C ************************ C . BEGIN PERIOD LOOP C ************************ DO M = 1,NM MODL = 0 MSOL = 0 ISOL = 0 WRITE(6,*)' Period ********** ',M DO LL = 1,NL L = MRKDEF(0,3+LL) CALL DEMOG CALL CARBONPRICE C . Compute current period solution CALL PPS IF(LINVEST(L) .GE. 1) THEN CALL DEMK END IF END DO CALL SOLUTN C . . Update solution information vectors and prepare for next period CALL POSTINI C Activate CALL POSTPER line to write out TESTING file C (Must activate CALL POSTPER line above as well) CALL POSTPER CALL EBAL IF (MSOL .GT. 0 .OR. ISOL .GT. 0) THEN WRITE(6,1000)M,ISOL,MSOL WRITE(11,1000)M,ISOL,MSOL 1000 FORMAT(1X,'Solution Failed in Period ',2i5) go to 110 END IF END DO C ************************

Page 86: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

86

C . END OF PERIOD LOOP C ************************ 110 CONTINUE if (msol .gt. 0) nm = m-1 if (msol .gt. 0) write (0,*)'value for nm ', nm C Call Output Subroutine CALL OUTEXCEL CALL DBOUT !database output format C . Post final results CLOSE (11) CLOSE (30) C . Write Done.CSV for use in multiple run automation OPEN (32,FILE='DONE.CSV') WRITE(32,*)'DONE RUNNING WSGM' CLOSE (32) CALL GETTIM(IHR, IMIN, ISEC, I100TH) CALL GETDAT(IYR, IMON, IDAY) write(36,"(2(i2.2,'/'),i4,' ',i2,':',i2.2,':',i2.2'.' i2.2)") & iday,imon,iyr,ihr,imin,isec,i100th END

Page 87: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

87

C**********************************************************************

SUBROUTINE MODEL1 C This subroutine provides partial or complete model evaluations, C depending on the row of MRKDEF selected by MRK. C MODEL1 loops over the number of regions in the market. C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' PARAMETER (IOIL = 3, IGAS = 4, ICOAL = 5) NR = MRKDEF(MRK,3) MRKED(MRK) = 0. MRKPRD(MRK) = 0. MODL = MODL + 1 INN = MRKDEF(MRK,2) if (m.eq.0 .or. modl.eq.1) nr = mrkdef(0,3) C . . NR represents only the number of regions in the market DO LL = 1,NR C . . Market number 0 is the place holder for all region numbers. L = MRKDEF(MRK,3+LL) if (m.eq.0 .or. modl.eq.1) l = mrkdef(0,3+ll) C . . Initialize tax and other variables for region L. CRBPRICETOT(L,M) = 0.0 TOTTAX(L) = 0.0 PINC(L) = 0.0 TRETE(L) = 0.0 DO IN=1,NIN SUBSID(IN,L) = 0.0 TRNP(IN,L) = 0.0 WHSL(IN,L) = 0.0 DO IO = 1,NIS ED(IN,IO,L,M) = 0.0 DO ISS = 1, NISS(IO,L) DO IVIN = NVIN0,M COST(IN,IDEFS(IO,ISS,L),IVIN,L) = 0.0 END DO END DO END DO END DO DO IO = 1,NIO PROF(IO,L) = 0.0 XITC(IO,L) = 0.0 END DO DO IO = 1,NIS SALES(1,IO,L,M) = 0.0 SALES(2,IO,L,M) = 0.0 DO IK =1,5 TAX(IK,IO,L) = 0.0 END DO END DO C . . . Initialize resource and reserve variables for region L. DO IO = 1,NIO DO ISS = 1, NISS(IO,L) DRSCTMP(IO,ISS,L) = DRSCE(IO,ISS,L) DO IVIN = NVIN0,M-1 DRSVTMP(IO,ISS,IVIN,L) = DRSVE(IO,ISS,IVIN,L) KA(ISS,IO,IVIN,L) = KAPRIOR(ISS,IO,IVIN,L) END DO END DO END DO GOVDEFT(L,M) = GOVDEF(L,M) C . . Begin model evaluation CALL GETCFEE CALL PPS

Page 88: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

88

if (ISUB(L).eq.0) CALL NEWINVold if (ISUB(L).ne.0) CALL NEWINVnew TPROF(L,M) = 0.0 DO IO = 1,NIO CALL GPCM C . . . Calculate total profits by region and period. C . . . For diagnosis, TPROF(L,M) = TPROF(L,M) + PROF(IO,L) END DO CALL ACCOUNT CALL HHOLD IF(IMPOLD(L).EQ.1) THEN CALL IMPEXold END IF CALL GOVT CALL INVST CALL GHG IF(IMPOLD(L).EQ.0) THEN CALL IMPEX END IF END DO C . Compute demands across all markets. MRKSV = MRK SSQED = 0.0 SUMED = 0.0 DO MRK = 1,NMRK INN = MRKDEF(MRK,2) NR = MRKDEF(MRK,3) MRKED(MRK) = 0. MRKPRD(MRK) = 0. DO LL = 1,NR L = MRKDEF(MRK,3+LL) MRKLED(MRK,L) = 0. IF (INN .LE. (NIO+1)) THEN DO IS = 1,NIS MRKED(MRK)=MRKED(MRK)+ED(INN,IS,L,M)*PRCONVRT(INN,L) MRKLED(MRK,L)=MRKLED(MRK,L)+ED(INN,IS,L,M) END DO MRKPRD(MRK) = MRKPRD(MRK) + SALES(1,INN,L,M) & *PRCONVRT(INN,L) ELSE DO IS = 1,NIS MRKED(MRK)=MRKED(MRK)+ED(INN,IS,L,M)/EXCHRATE(L) MRKLED(MRK,L)=MRKLED(MRK,L)+ED(INN,IS,L,M) END DO MRKPRD(MRK) = MRKPRD(MRK) + SALES(1,INN,L,M)/EXCHRATE(L) END IF END DO T1 = P(INN,L,M) * MRKED(MRK) SSQED = SSQED + MRKED(MRK)**2 SUMED = SUMED + T1 END DO MRK = MRKSV RETURN END

Page 89: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

89

C**********************************************************************

SUBROUTINE MODEL2 C This subroutine provides partial or complete model evaluations, C depending on the row of MRKDEF selected by MRK. C MODEL2 loops over ALL the regions in the model. C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' logical print PARAMETER (IOIL = 3, IGAS = 4, ICOAL = 5) print = .false. NR = MRKDEF(MRK,3) MRKED(MRK) = 0. MRKPRD(MRK) = 0. MODL = MODL + 1 INN = MRKDEF(MRK,2) C . . NL represents all regions in the model. DO LL = 1,NL C . . Market number 0 is the place holder for all region numbers. L = MRKDEF(0,3+LL) C . . Initialize tax and other variables for region L. CRBPRICETOT(L,M) = 0.0 TOTTAX(L) = 0.0 PINC(L) = 0.0 TRETE(L) = 0.0 DO IN=1,NIN SUBSID(IN,L) = 0.0 TRNP(IN,L) = 0.0 WHSL(IN,L) = 0.0 DO IO = 1,NIS ED(IN,IO,L,M) = 0.0 DO ISS = 1, NISS(IO,L) DO IVIN = NVIN0,M COST(IN,IDEFS(IO,ISS,L),IVIN,L) = 0.0 END DO END DO END DO END DO DO IO = 1,NIO PROF(IO,L) = 0.0 XITC(IO,L) = 0.0 END DO DO IO = 1,NIS SALES(1,IO,L,M) = 0.0 SALES(2,IO,L,M) = 0.0 DO IK =1,5 TAX(IK,IO,L) = 0.0 END DO END DO C . . . Initialize resource and reserve variables for region L. DO IO = 1,NIO DO ISS = 1, NISS(IO,L) DRSCTMP(IO,ISS,L) = DRSCE(IO,ISS,L) DO IVIN = NVIN0,M-1 DRSVTMP(IO,ISS,IVIN,L) = DRSVE(IO,ISS,IVIN,L) KA(ISS,IO,IVIN,L) = KAPRIOR(ISS,IO,IVIN,L) END DO END DO END DO GOVDEFT(L,M) = GOVDEF(L,M) C . . Begin model evaluation CALL GETCFEE CALL PPS

Page 90: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

90

if (ISUB(L).eq.0) CALL NEWINVold if (ISUB(L).ne.0) CALL NEWINVnew TPROF(L,M) = 0.0 DO IO = 1,NIO CALL GPCM C . . . Calculate total profits by region and period. C . . . For diagnosis, TPROF(L,M) = TPROF(L,M) + PROF(IO,L) END DO CALL ACCOUNT CALL HHOLD IF(IMPOLD(L).EQ.1) THEN CALL IMPEXold END IF CALL GOVT CALL INVST CALL GHG IF(IMPOLD(L).EQ.0) THEN CALL IMPEX END IF END DO C . Compute demands across all markets. MRKSV = MRK SSQED = 0.0 SUMED = 0.0 DO MRK = 1,NMRK INN = MRKDEF(MRK,2) NR = MRKDEF(MRK,3) MRKED(MRK) = 0. MRKPRD(MRK) = 0. DO LL = 1,NR L = MRKDEF(MRK,3+LL) MRKLED(MRK,L) = 0. IF (INN .LE. (NIO+1)) THEN DO IS = 1,NIS MRKED(MRK)=MRKED(MRK)+ED(INN,IS,L,M)*PRCONVRT(INN,L) MRKLED(MRK,L)=MRKLED(MRK,L)+ED(INN,IS,L,M) END DO MRKPRD(MRK) = MRKPRD(MRK) + SALES(1,INN,L,M) & *PRCONVRT(INN,L) ELSE DO IS = 1,NIS MRKED(MRK)=MRKED(MRK)+ED(INN,IS,L,M)/EXCHRATE(L) MRKLED(MRK,L)=MRKLED(MRK,L)+ED(INN,IS,L,M) END DO MRKPRD(MRK) = MRKPRD(MRK) + SALES(1,INN,L,M)/EXCHRATE(L) END IF END DO T1 = P(INN,L,M) * MRKED(MRK) SSQED = SSQED + MRKED(MRK)**2 SUMED = SUMED + T1 END DO MRK = MRKSV if(print)write(10,'(i5,'' iteration number '',e12.7,'' ssqed'')') & modl,ssqed RETURN END

Page 91: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

91

C**********************************************************************

SUBROUTINE NEWINVNEW C NEWINV is a subroutine which takes expected future prices and uses C them to produce profit rates for new technology options. These C profit rates are used to compute demand for investment in new C capacity. C C Option added to base elec investment shares on levelized cost C Option added for hierarchical nesting of electrcity technologies C C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' DIMENSION BETA(NISSP),BETAN(NISSP),RESERVE(NISSP) REAL*8 KTOTAL REAL*8 DEXP1 LOGICAL PRINT, RLE, RPT PARAMETER(TINY = 1.E-10, AGGINVSS = .10, AGGINVS = .01, & SMALL = 1.0) NELEC = 8 C . Begin by computing the profit rate per unit of investment C . expenditure. Note that P(NIN,L,M) is the interest rate. IVIN = M DO 100 IO = 1,NIO !call expected profits for each sector and subsector DO ISS = 1,NISS(IO,L) ! delay loop for IO CALL EXPPROFIT !for each subsector; independent of nesting C . . . Incorporate delay factors for investments that take more than one C . . . period before coming on line; new delay factors read in input case(354) LINVST = NTECHCHAR(2,IDEF(IO,ISS,L),L,IVIN) + 1 IT = M - IVIN DENOM = 0.0 DO J = IT, LINVST-1 DENOM = DENOM + 1/((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-J-1))) END DO DENOM = DENOM * ((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-IT-1)))/FLOAT(LINVST) DEXPPROF(ISS,IO,L,M) = EXPPROF(ISS,IO,L,M)/DENOM END DO !ISS loop 100 CONTINUE ! end delay IO loop; expected profits known now C . Compute weighted average profit rate using current period subsector C . profits and previous period subsector investments as weights. KTOTAL = 0.0 AVPR = 0.0 DO 200 IO = 1,NIO do iss = 1,niss(io,l) AVPR = AVPR + DEXPPROF(ISS,IO,L,M) ** .5 KTOTAL = KTOTAL + KAFLOW(ISS,IO,M-1,L) !summed subsectors; previous period capital flow; remains independent on nesting end do ! ISS loop 200 CONTINUE ! IO loop Total, over all IOs, expected investment KTOTAL known now IF (avpr .GT. 0.0) THEN AVPR = AVPR ** 2 ELSE AVPR = 1.0 END IF C . Determine total investment in region and investment in each C . sector. C . . Applies the basic investment equation at the sector C . . level and uses the logistic equation to share sector investment to C . . the subsector levels. Investment lost in a sector due to

Page 92: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

92

C . . depletable resource limits, affects other C . . sectors by adjusting total capital and total capital available to C . . non-limited subsectors. C Assumes that exogenous nuclear and hydro investments C are stored in EXONUC and EXOHYDRO arrays. C NOTE exogenous investments in Geo & Waste DO 300 IO = 1,NIO !over all sectors C . . . Create sector level arguments for investment equation and C . . . compute the part of investment equation independent of the C . . . current period. TMPKAF(IO,L) = 0.0 DO ISS = 1,NISS(IO,L) BETA(ISS) = 1.0 TMPKAF(IO,L) = TMPKAF(IO,L) + KAFLOW(ISS,IO,IVIN-1,L) !summed over subsectors; previous vintage capital flow END DO ! ISS loop ! TMPKAP is summed over the previous subsector vintage capital flow C . . . Now compute components of investment equation. IF (TMPKAF(IO,L) .GT. SMALL) THEN BASEKAP = TMPKAF(IO,L) ELSE BASEKAP = AGGINVS * KTOTAL ! AGGINVS = 0.01 from above END IF ! income: GNP/work force population previous period tmpka1(io,l) = wage(4,l,m-1) ! income: GNP/work force population 2 periods ago tmpka2(io,l) = wage(4,l,m-2) ! current male and female working population vkratio0 = (wage(1,l,m) + wage(2,l,m)) / ! previous period male and female working population & (wage(1,l,m-1) + wage(2,l,m-1)) ! working population change over 5 yrs * income change over 5 yrs vkratio(io,l) = vkratio0 * tmpka1(io,l) / tmpka2(io,l) C . . . Use previous period sector profit rate unles it's zero, then C . . . use average profit rate for this period. C . . . set TMPEXP1 to 1.0 so that the comparison is to what the C . . . marginal dollar should earn under perfect competition. TMPEXP1 = 1.0 ! SCLINV = 1.2 = base rate in investment sheet ! ACCINV = 1 ! RINV = 1 ! A0 same for each sector and subsector A0 = SCLINV(L) * BASEKAP * vkratio0 ** ACCINV(L) & * TMPEXP1 ** (-RINV(L)) IF (M .GE. 1) THEN SELECT CASE(LINVEST(L)) !LINVEST(L) = 1 CASE(1) IF((IO .GE. 6) .AND. (IO .LE. 10)) THEN !for coke (6), electricity (8), refined oil (9), gas T&D (10) TESTINV = (TESTK(IO,L) - 2.0*BASEKAP)/3.0 IF(TESTINV .GT. (TESTK(IO,L)/10.0)) THEN A0 = TESTINV ELSE A0 = TESTK(IO,L)/10.0 END IF END IF CASE(2) !for sectors TESTINV = (TESTK(IO,L) - 2.0*BASEKAP)/3.0 IF(TESTINV .GT. (TESTK(IO,L)/10.0)) THEN A0 = TESTINV ELSE A0 = TESTK(IO,L)/10.0 END IF CASE DEFAULT END SELECT END IF ! if (M .GE. 1) C . . . Beginning of investment share loop. C . . . Compute current period expected rate of return

Page 93: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

93

icnt = 0 205 CONTINUE ! if resources limited TMPEXP0 = 0.0 TMPEXP2 = 0.0 TMPEXP3 = 0.0 IF (ISUB(L) .NE. 0) THEN ! !big if then else for seperating new subnesting !structure from old code !ISUB.ne.0 for new subnesting structure * !New subnesting only here in Newinv2k_new, !Old subnesting code is now in Newinv2k_old c c Electricity Sector Subnesting Diagram c ------------------------------------- c c electricity--------------------------- c /\ | | c / \ | | c / \ | | c / \ | | c / \ | | c fossil renewables nuclear hydro c / \ / / / \ \ \ c / \ / / / \ \ \ c / \ w b w w s g c peak base a i i i o e c /\ /|\ s o n n l o c / \ / | \ t m d d a t c oil gas / | \ e a r h c / | \ s o o e c coal ngcc igcc s n f p r c /\ /\ /\ v m c / \ / \ / \ c no ccs no ccs no ccs c c IF (IO .EQ. NELEC) THEN NOIL = 1 NGASid = 2 NCOAL = 3 NNUCLEAR = 4 NHYDRO = 5 NWASTE = 6 NSOLIDS = 7 NWIND = 8 NWINDOS = 9 NSOLAR = 10 NGEO = 11 NGCC = 12 IGCC = 13 NGCCccs = 14 IGCCccs = 15 PCccs = 16 IXccs = 3 !set # of subsectors for carbon capture and storage level IXpkbs = 2 !set # of subsectors for peak base level IXfrnh = 4 !set # of subsectors for fossil renewable nuclear hydro !set vars to zero DO INS = 1,IXccs TMPEXPccs(INS) = 0.d0 TMPEXP2ccs(INS)= 0.d0 END DO DO INS = 1,IXpkbs TMPEXPpkbs(INS) = 0.d0 TMPEXP2pkbs(INS)= 0.d0 END DO DO INS = 1,IXfrnh TMPEXPfrnh(INS) = 0.d0 TMPEXP2frnh(INS)= 0.d0 END DO c c lev cost calc(using variable factor unit cost function) c

Page 94: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

94

DO ISS = 1,NISS(IO,L) !iss loop for lowest level nests !this loop to sum the alphas for each subsector checks if a subsesctor is !active and turns it off if not to avoid problems in the sol'n algorithm temp=0 DO IN=1,NIN-1 temp = temp + A(IN,IDEF(IO,ISS,L),IVIN,L) END DO if (temp .eq. 0) then BETAin(iss,l) = 0.0 else LevCost(L,ISS,M)= 0.0 RHO = A(NIN+1,IDEF(IO,ISS,L),IVIN,L) DO IN=1,NIN-1 LevCost(L,ISS,M) = LevCost(L,ISS,M) & + A(IN,IDEF(IO,ISS,L),IVIN,L) ** (1/(1-RHO)) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) ** (RHO/(RHO-1)) END DO LevCost(L,ISS,M) = LevCost(L,ISS,M) & + A(NIN,IDEF(IO,ISS,L),IVIN,L) ** (1/(1-RHO)) & * Kcost(ISS,L) ** (RHO/(RHO-1)) LevCost(L,ISS,M)= LevCost(L,ISS,M) ** ((RHO-1)/RHO) LevCost(L,ISS,M)= LevCost(L,ISS,M) & / (ELECFAC(IO,ISS,L)*1000/3.6) end if END DO C levelized cost or expected profit setup; exemption file dependent C IProfitOption=0 Traditional SGM expected profit calculation C IProfitOption=1 Change price received in electricity subsector so it is C consistent with units used for quantities C both in ExpProf2k.for C IProfitOption=2 Use levelized cost per kWh instead of expected profits C Use levelized cost approach if(Iprofitoption(L) .eq. 2) then !Use levelized cost approach: !exemption file dependent if (RHOINVccs(L).gt.0) then RHOINVfsl(L) = -RHOINVfsl(L) !logit sharing exponent for fossil nest RHOINVrnw(L) = -RHOINVrnw(L) !logit sharing exponent for renewables nest RHOINVpkbs(L) = -RHOINVpkbs(L)!logit sharing exponent for peak base level nest RHOINVccs(L) = -RHOINVccs(L) !logit sharing exponent for knife edge !carbon capture and sequestration level nests RHOINV(IO,L) = -RHOINV(IO,L) ! alternative for oveall subnest shares end if C Else Use expected profit approach and use expected profit directly from Exprof2k else !Use expected profit approach ! and set betas to one do iss=1,niss(io,l) BETAin(iss,l) = 1.0 C Betain parameters for lowest level subnests end do do ins=1,IXccs BetaB(ins,l) = 1.0 C BetaB parameters for base subnetst (ngcc, igcc, pc) end do do ins=1,IXpkbs BetaF(ins,l) = 1.0 C BetaF parameters for fossil subnetst (peak v. base) end do do ins=1,IXfrnh BetaE(ins,l) = 1.0 C BetaE parameters for elec subnest (fossil, renewable, nuclear, hydro) end do end if ! Iprofitoption(L) .eq. 1 (expected profit approach) or ! 2 (levelized cost approach) C ISS loop to set lowest level nests -------------- DO ISS = 1,NISS(IO,L) !iss loop for lowest level nests if(Iprofitoption(L) .eq. 2) then !Use levelized cost approach issDEXPPROF(ISS,L,M) = DEXPPROF(ISS,IO,L,M) !save expected profit if (LevCost(L,ISS,M).gt.0) then

Page 95: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

95

DEXPPROF(ISS,IO,L,M) = LevCost(L,ISS,M) !substitute levelized costs for expected profit rates else DEXPPROF(ISS,IO,L,M) = 10000 end if end if !Iprofitoption(L) .eq. 2 C Account for delays REQUIRED HERE FOR LEVELIZED COST OPTION C - FOR EXPECTED PROFIT IT IS IN THAT SUBROUTINE ACCOUNTED FOR C SPECIFICS FOR SUBNESTING DELAYS IN SUBNESTING EXEMPTION FILE C THESE WILL OVERRIDE DEFAULT DELAYS IN MAIN INPUT FILE if(M .lt. issDELAY(L,ISS)) then DEXPPROF(ISS,IO,L,M) = 0.d0 issDEXPPROF(ISS,L,M) = 0.d0 if(Iprofitoption(L) .eq. 2) then !Use levelized cost approach DEXPPROF(ISS,IO,L,M) = 100000 end if end if C Begin nesting code IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN !Peak - oil and gas TMPEXPpkbs(1) = TMPEXPpkbs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVpkbs(L) TMPEXP2pkbs(1)= TMPEXP2pkbs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVpkbs(L)+1) END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN TMPEXPccs(1) = TMPEXPccs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L) TMPEXP2ccs(1)= TMPEXP2ccs(1) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVccs(L)+1) END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN TMPEXPccs(2) = TMPEXPccs(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L) TMPEXP2ccs(2) = TMPEXP2ccs(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVccs(L)+1) END IF !CCS nest: IGCC (IGCC, IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN TMPEXPccs(3) = TMPEXPccs(3) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L) TMPEXP2ccs(3) = TMPEXP2ccs(3) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVccs(L)+1) END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN TMPEXPfrnh(2) = TMPEXPfrnh(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVrnw(L)

Page 96: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

96

TMPEXP2frnh(2) = TMPEXP2frnh(2) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** (RHOINVrnw(L)+1) END IF !Fossil Renewables Nuclear Hydro nest: Nuclear IF (ISS.EQ.4) THEN TMPEXPfrnh(3) = TMPEXPfrnh(3) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVfsl(L) DEXPPRfrnh(ISS,L,M) = DEXPPROF(ISS,IO,L,M) END IF !Fossil Renewables Nuclear Hydro nest: Hydro IF (ISS.EQ.5) THEN TMPEXPfrnh(4) = TMPEXPfrnh(4) + BETAin(ISS,L) & * DEXPPROF(ISS,IO,L,M) & ** RHOINVrnw(L) DEXPPRfrnh(ISS,L,M) = DEXPPROF(ISS,IO,L,M) END IF END IF !NRSCHAR(1,IO,L) .EQ. 0 .OR. DRSCTMP(IO,ISS,L) .GT. 0.0 END IF !JELFIX(L,ISS,M) .NE. 1 END DO !end ISS loop C End ISS loop to set lowest level nests -------------- C Expected profits for lowest level nests------------- C expected profit for peak (oil and gas) IF (TMPEXPpkbs(1) .GT. 0) THEN DEXPPRpkbs(1,L,M) = TMPEXP2pkbs(1) / TMPEXPpkbs(1) ENDIF !expected profit for PC (coal and PCcd) IF (TMPEXPccs(1) .GT. 0) THEN DEXPPRccs(1,L,M) = TMPEXP2ccs(1) / TMPEXPccs(1) END IF !expected profit for NGCC (NGCC and NGCCcd) IF (TMPEXPccs(2) .GT. 0) THEN DEXPPRccs(2,L,M) = TMPEXP2ccs(2) / TMPEXPccs(2) END IF !expected profit for IGCC (IGCC and IGCCcd) IF (TMPEXPccs(3) .GT. 0) THEN DEXPPRccs(3,L,M) = TMPEXP2ccs(3) / TMPEXPccs(3) END IF !expected profit for renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (TMPEXPfrnh(2) .GT. 0) THEN DEXPPRfrnh(2,L,M) = TMPEXP2frnh(2) / TMPEXPfrnh(2) END IF c expected profits for lowest level nests---------- c INS loops for next level up nests------------------- !Peak-Base nest: base (PC, NGCC and IGCC) DO INS = 1,IXccs TMPEXPpkbs(2) = TMPEXPpkbs(2) + BetaB(INS,L) & * DEXPPRccs(INS,L,M) & ** RHOINVpkbs(L) TMPEXP2pkbs(2)= TMPEXP2pkbs(2) + BetaB(INS,L) & * DEXPPRccs(INS,L,M) & ** (RHOINVpkbs(L)+1) END DO c End INS loops for next level up nests------------------- c expected profits for next level up nests-------------- !expected profit for base (PC, NGCC and IGCC) IF (TMPEXPpkbs(2) .GT. 0.0) THEN DEXPPRpkbs(2,L,M) = TMPEXP2pkbs(2) / TMPEXPpkbs(2) END IF c End expected profits for next level up nests---------- c INS loops for next level up nests------------------- !Fossil Renewables Nuclear Hydro nest: Fossil (Peak and Base) DO INS = 1,IXpkbs TMPEXPfrnh(1) = TMPEXPfrnh(1) + BetaF(INS,L)

Page 97: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

97

& * DEXPPRpkbs(INS,L,M) & ** RHOINVfsl(L) TMPEXP2frnh(1)= TMPEXP2frnh(1) + BetaF(INS,L) & * DEXPPRpkbs(INS,L,M) & ** (RHOINVfsl(L)+1) END DO c End INS loops for next level up nests------------------- c expected profits for next level up nests-------------- !expected profit for fossil (peak and base) IF (TMPEXPfrnh(1) .GT. 0.0) THEN DEXPPRfrnh(1,L,M) = TMPEXP2frnh(1) / TMPEXPfrnh(1) END IF c End expected profits for next level up nests---------- c INS loops for sector level TMPEXPs------------------- DO INS = 1,IXfrnh !ins loop for TMPEXP2 & 3 if (DEXPPRfrnh(INS,L,M) .gt. 0) then ! JELFIX(L,ISS,M)=1 fix for lev cost TMPEXP0 = TMPEXP0 + BetaE(INS,L) & * DEXPPRfrnh(INS,L,M) ** RHOINV(IO,L) TMPEXP2 = TMPEXP2 + BetaE(INS,L) & * DEXPPRfrnh(INS,L,M) ** (RHOINV(IO,L)+1.0) TMPEXP3 = TMPEXP3 + BetaE(INS,L) & * DEXPPRfrnh(INS,L,M) ** RHOINV(IO,L) end if END DO !INS loop c End INS loops for sector level TMPEXPs---------------- c Now calculate lowest sub sub sector shares------------- DO ISS=1,NISS(IO,L) !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN if (iss.eq.1) ins=1 if (iss.eq.2) ins=2 IF (TMPEXPpkbs(1) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREpkbs1(INS,M,1) = (BETAin(ISS,L) * DEXPPROF(ISS,IO,L,M) & ** RHOINVpkbs(L)) / TMPEXPpkbs(1) END IF END IF END IF END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN if (iss.eq.3) ins=1 if (iss.eq.16) ins=2 IF (TMPEXPccs(1) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREccs1(INS,M,1) = (BETAin(ISS,L) * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L)) / TMPEXPccs(1) END IF END IF END IF END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN if (iss.eq.12) ins=1 if (iss.eq.14) ins=2 IF (TMPEXPccs(2) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREccs2(INS,M,1) = (BETAin(ISS,L) * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L)) / TMPEXPccs(2) END IF END IF

Page 98: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

98

END IF END IF !CCS nest: IGCC (IGCC and IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN if (iss.eq.13) ins=1 if (iss.eq.15) ins=2 IF (TMPEXPccs(3) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREccs3(INS,M,1) = (BETAin(ISS,L) * DEXPPROF(ISS,IO,L,M) & ** RHOINVccs(L)) / TMPEXPccs(3) END IF END IF END IF END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN if (iss.eq.6) ins=1 if (iss.eq.7) ins=2 if (iss.eq.8) ins=3 if (iss.eq.9) ins=4 if (iss.eq.10) ins=5 if (iss.eq.11) ins=6 IF (TMPEXPfrnh(2) .GT. 0.0) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHAREfrnh2(INS,M,1) = (BETAin(ISS,L) * DEXPPROF(ISS,IO,L,M) & ** RHOINVrnw(L)) / TMPEXPfrnh(2) END IF END IF END IF END IF END DO !INS loop c End calculate lowest sub sub sector shares------------- c Now calculate next level up subsector shares------------- !Peak-Base nest: base (PC, NGCC and IGCC) DO INS=1,IXccs SHAREpkbs2(INS,M,1) = (BetaB(INS,L) * DEXPPRccs(INS,L,M) & ** RHOINVpkbs(L)) / TMPEXPpkbs(2) END DO !Fossil Renewables Nuclear Hydro nest: Fossil (Peak and Base) DO INS=1,IXpkbs SHAREfrnh1(INS,M,1) = (BetaF(INS,L) * DEXPPRpkbs(INS,L,M) & ** RHOINVfsl(L)) / TMPEXPfrnh(1) END DO !Elec nest: (Fossil Renewables Nuclear Hydro) DO INS=1,IXfrnh if (DEXPPRfrnh(INS,L,M) .gt. 0 .and. TMPEXP0 .gt. 0) then SHAREelec(INS,M,1) = (BetaE(INS,L) * DEXPPRfrnh(INS,L,M) & ** RHOINV(IO,L)) / TMPEXP0 else SHAREelec(INS,M,1) = 0.0 end if END DO c End calculate upper level subsector shares------------- c Now calculate lowest sub sub sector shares as share of total--------- DO ISS=1,NISS(IO,L) !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN

Page 99: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

99

if (iss.eq.1) ins=1 if (iss.eq.2) ins=2 SHARE(IO,ISS) = SHAREpkbs1(INS,M,1) & *SHAREfrnh1(1,M,1) & *SHAREelec(1,M,1) END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN if (iss.eq.3) ins=1 if (iss.eq.16) ins=2 SHARE(IO,ISS) = SHAREccs1(INS,M,1) & *SHAREpkbs2(1,M,1) & *SHAREfrnh1(2,M,1) & *SHAREelec(1,M,1) END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN if (iss.eq.12) ins=1 if (iss.eq.14) ins=2 SHARE(IO,ISS) = SHAREccs2(INS,M,1) & *SHAREpkbs2(2,M,1) & *SHAREfrnh1(2,M,1) & *SHAREelec(1,M,1) END IF !CCS nest: IGCC (IGCC and IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN if (iss.eq.13) ins=1 if (iss.eq.15) ins=2 SHARE(IO,ISS) = SHAREccs3(INS,M,1) & *SHAREpkbs2(3,M,1) & *SHAREfrnh1(2,M,1) & *SHAREelec(1,M,1) END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN if (iss.eq.6) ins=1 if (iss.eq.7) ins=2 if (iss.eq.8) ins=3 if (iss.eq.9) ins=4 if (iss.eq.10) ins=5 if (iss.eq.11) ins=6 SHARE(IO,ISS) = SHAREfrnh2(INS,M,1) & *SHAREelec(2,M,1) END IF !Elec nest: Nuclear IF (ISS.EQ.4) THEN SHARE(IO,ISS) = SHAREelec(3,M,1) END IF !Elec nest: Hydro IF (ISS.EQ.5) THEN SHARE(IO,ISS) = SHAREelec(4,M,1) END IF END DO ! ISS loop c End calculate lowest sub sub sector shares as share of total---------- ELSE ! not elec DO ISS = 1,NISS(IO,L) ! for non-electricity sector ! RHOINV = 1 for all IOS, but RHOINV = 1.2 for electricity and = 2 for IO=11 TMPEXP0 = TMPEXP0 + BETA(ISS) !BETA(ISS)=1 defined above & * DEXPPROF(ISS,IO,L,M) ** RHOINV(IO,L) TMPEXP2 = TMPEXP2 + DEXPPROF(ISS,IO,L,M)** & (RHOINV(IO,L)+1.0) TMPEXP3 = TMPEXP3 + DEXPPROF(ISS,IO,L,M)** & RHOINV(IO,L)

Page 100: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

100

END DO !end iss loop END IF !end big elec not elec if else C Back to sector level: C . . . There are two options for determining sector-level profit rates. The C . . . first IF block uses Pythagorean aggregation derived from choosing C . . . random samples from independent Weibull distributions. The second IF C . . . block calculates a weighted average profit rate. One of the following C . . . two IF blocks should be commented out.. if (Iprofitoption(L) .eq. 2 .and. IO .EQ. NELEC) then SDEXPRF(IO,L,M) = 0 DO ISS=1,NISS(IO,L) SDEXPRF(IO,L,M) = SDEXPRF(IO,L,M) & + SHARE(IO,ISS) * issDEXPPROF(ISS,L,M) END DO else IF (TMPEXP3 .GT. 0.0) THEN SDEXPRF(IO,L,M) = TMPEXP2/TMPEXP3 ELSE SDEXPRF(IO,L,M) = 0.0 END IF end if !(Iprofitoption .eq. 2) C Sector level: IF (SDEXPRF(IO,L,M) .GT. 0.0) THEN K(IO,L,M) = A0 * (SDEXPRF(IO,L,M) ** RINV(L)) ELSE K(IO,L,M) = 0.0 END IF C Some sectors may have investment set exogenously. IF (EXOINVST(IO,L,M) .GT. 1.0) THEN K(IO,L,M) = EXOINVST(IO,L,M) !e.g. for sector level oil and for gas if ifix=T END IF C . . . Now create subsector shares. C . . . Use the Logit function to compute market investment shares C . . . for the new capacity in sector IO. TMPEXP0 has the denominator. IF(IO .NE. NELEC) THEN DO ISS = 1,NISS(IO,L) IF (TMPEXP0 .GT. 0.0) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHARE(IO,ISS) = (DEXPPROF(ISS,IO,L,M) & ** RHOINV(IO,L)) / TMPEXP0 ELSE SHARE(IO,ISS) = 0.0 END IF ELSE !if tmpexp0 le zero SHARE(IO,ISS) = 0.0 END IF KAFLOW(ISS,IO,IVIN,L) = SHARE(IO,ISS) * K(IO,L,M) END DO !end ISS loop C . . . . . Do the following only for electricity. ELSE ! if IO.eq.NELEC C if shares are fixed do correction: fixes only at first nesting level! SUMSHARE = 0.0 SUMSHARE2 = 0.0 SUMFIX = 0.0 NUMFIX = 0 DO ISS = 1,NISS(IO,L) IF (JELFIX(L,ISS,M) .EQ. 1) THEN SUMFIX = SUMFIX + EXOELEC(L,ISS,M) !iss fixed shares summed NUMFIX = NUMFIX + 1 ELSE ! sumshare is fraction that can be shared (should be 1 in this code) SUMSHARE = SUMSHARE + SHARE(IO,ISS) !iss calculated shares summed END IF END DO !ISS loop C If investment is fixed in all electricity subsectors, then sector C level investment is also fixed. IF (NISS(NELEC,L) .EQ. NUMFIX) THEN K(IO,L,M) = SUMFIX END IF

Page 101: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

101

! sumvar is that what can be shared that is not fixed SUMVAR = MAX(0.0,K(IO,L,M) - SUMFIX) K(IO,L,M) = SUMFIX + SUMVAR DO ISS = 1,NISS(NELEC,L) !correct for fixed investments IF (JELFIX(L,ISS,M) .EQ. 1) THEN KAFLOW(ISS,IO,IVIN,L) = EXOELEC(L,ISS,M) ELSE KAFLOW(ISS,IO,IVIN,L) = SHARE(IO,ISS) * SUMVAR END IF END DO !ISS loop !----------now store endogenous shares and total shares------------------------ !-------note: this is not needed for model operation, but provides useful output DO ISS=1,NISS(IO,L) SHAREstore(1,M,ISS) = SHARE(IO,ISS) !endogenous investment shares IF (JELFIX(L,ISS,M) .EQ. 1) THEN !total investment shares SHAREstore(2,M,ISS) = EXOELEC(L,ISS,M) & / (SUMFIX + SUMVAR) ELSE SHAREstore(2,M,ISS) = SHARE(IO,ISS) * SUMVAR & / (SUMFIX + SUMVAR) END IF END DO ccs1Add = 0.0 ccs2Add = 0.0 ccs3Add = 0.0 pkbs1Add = 0.0 pkbs2Add = 0.0 frnh1Add = 0.0 frnh2Add = 0.0 frnh3Add = 0.0 frnh4Add = 0.0 elecAdd = 0.0 ! for subsectors, first add up investments DO ISS=1,NISS(IO,L) !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN if (iss.eq.1) ins=1 if (iss.eq.2) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN pkbs1Add = pkbs1Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE pkbs1Add = pkbs1Add & + EXOELEC(L,ISS,M) END IF END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN if (iss.eq.3) ins=1 if (iss.eq.16) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN ccs1Add = ccs1Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE ccs1Add = ccs1Add & + EXOELEC(L,ISS,M) END IF END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN if (iss.eq.12) ins=1 if (iss.eq.14) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN ccs2Add = ccs2Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE ccs2Add = ccs2Add & + EXOELEC(L,ISS,M) END IF END IF !CCS nest: IGCC (IGCC and IGCCcd)

Page 102: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

102

IF (ISS.EQ.13 .OR. ISS.eq.15) THEN if (iss.eq.13) ins=1 if (iss.eq.15) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN ccs3Add = ccs3Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE ccs3Add = ccs3Add & + EXOELEC(L,ISS,M) END IF END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN if (iss.eq.6) ins=1 if (iss.eq.7) ins=2 if (iss.eq.8) ins=3 if (iss.eq.9) ins=4 if (iss.eq.10) ins=5 if (iss.eq.11) ins=6 IF(JELFIX(L,ISS,M) .NE. 1) THEN frnh2Add = frnh2Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE frnh2Add = frnh2Add & + EXOELEC(L,ISS,M) END IF END IF !Elec nest: Nuclear IF (ISS.EQ.4) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN frnh3Add = frnh3Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE frnh3Add = frnh3Add & + EXOELEC(L,ISS,M) END IF END IF !Elec nest: Hydro IF (ISS.EQ.5) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN frnh4Add = frnh4Add & + SHAREstore(2,M,ISS)*K(IO,L,M) ELSE frnh4Add = frnh4Add & + EXOELEC(L,ISS,M) END IF END IF END DO ! ISS loop !now calculate shares DO ISS=1,NISS(IO,L) !Peak-Base nest: Peak (oil and gas) IF (ISS.EQ.1 .OR. ISS.EQ.2) THEN if (iss.eq.1) ins=1 if (iss.eq.2) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN SHAREpkbs1(INS,M,2) = SHAREstore(2,M,ISS)*K(IO,L,M) & /pkbs1Add ELSE SHAREpkbs1(INS,M,2) = EXOELEC(L,ISS,M) / pkbs1Add END IF END IF !CCS nest: PC (coal and PCcd) IF (ISS.EQ.3 .OR. ISS.eq.16) THEN if (iss.eq.3) ins=1 if (iss.eq.16) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN SHAREccs1(INS,M,2) = SHAREstore(2,M,ISS)*K(IO,L,M) & /ccs1Add ELSE

Page 103: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

103

SHAREccs1(INS,M,2) = EXOELEC(L,ISS,M) / ccs1Add END IF END IF !CCS nest: NGCC (NGCC and NGCCcd) IF (ISS.EQ.12 .OR. ISS.eq.14) THEN if (iss.eq.12) ins=1 if (iss.eq.14) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN SHAREccs2(INS,M,2) = SHAREstore(2,M,ISS)*K(IO,L,M) & /ccs2Add ELSE SHAREccs2(INS,M,2) = EXOELEC(L,ISS,M) / ccs2Add END IF END IF !CCS nest: IGCC (IGCC and IGCCcd) IF (ISS.EQ.13 .OR. ISS.eq.15) THEN if (iss.eq.13) ins=1 if (iss.eq.15) ins=2 IF(JELFIX(L,ISS,M) .NE. 1) THEN SHAREccs3(INS,M,2) = SHAREstore(2,M,ISS)*K(IO,L,M) & /ccs3Add ELSE SHAREccs3(INS,M,2) = EXOELEC(L,ISS,M) / ccs3Add END IF END IF !Fossil Renewables Nuclear Hydro nest: renewables !(waste, bioenergy, wind, wind off shore, solar, geothermal) IF (ISS.EQ.6 .OR. & ISS.EQ.7 .OR. & ISS.EQ.8 .OR. & ISS.EQ.9 .OR. & ISS.EQ.10 .OR. & ISS.EQ.11 ) THEN if (iss.eq.6) ins=1 if (iss.eq.7) ins=2 if (iss.eq.8) ins=3 if (iss.eq.9) ins=4 if (iss.eq.10) ins=5 if (iss.eq.11) ins=6 IF(JELFIX(L,ISS,M) .NE. 1) THEN SHAREfrnh2(INS,M,2) = SHAREstore(2,M,ISS)*K(IO,L,M) & /frnh2Add ELSE SHAREfrnh2(INS,M,2) = EXOELEC(L,ISS,M) / frnh2Add END IF END IF END DO ! ISS loop C End calculate lowest sub sub sector shares------------- C Now calculate next level up subsector shares------------- !Peak-Base nest: base (PC, NGCC and IGCC) pkbs2Add = ccs1Add + ccs2Add + ccs3Add SHAREpkbs2(1,M,2) = ccs1Add/pkbs2Add SHAREpkbs2(2,M,2) = ccs2Add/pkbs2Add SHAREpkbs2(3,M,2) = ccs3Add/pkbs2Add !Fossil Renewables Nuclear Hydro nest: Fossil (Peak and Base) frnh1Add = pkbs1Add + pkbs2Add SHAREfrnh1(1,M,2) = pkbs1Add/frnh1Add SHAREfrnh1(2,M,2) = pkbs2Add/frnh1Add !Elec nest: (Fossil Renewables Nuclear Hydro) elecAdd = frnh1Add + frnh2Add + frnh3Add + frnh4Add SHAREelec(1,M,2) = frnh1Add/elecAdd SHAREelec(2,M,2) = frnh2Add/elecAdd SHAREelec(3,M,2) = frnh3Add/elecAdd SHAREelec(4,M,2) = frnh4Add/elecAdd !----------------end store shares--------------------------------------- END IF ! if IO.eq.NELEC END IF C . . . Interpolation of the 5-year total investment flow. C . . . For calibration use read in value of vintage capital.

Page 104: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

104

DO ISS = 1,NISS(IO,L) FL1 = KAFLOW(ISS,IO,IVIN-1,L) IF (M .NE. 0) THEN KA(ISS,IO,IVIN,L) = & SUMINTRP(FL1,KAFLOW(ISS,IO,IVIN,L)) ELSE KA(ISS,IO,IVIN,L) = KAPRIOR(ISS,IO,0,L) END IF END DO ! ISS loop C . . . For depletable and constrained resources, compute invested C . . . capacity using the amount produced per period based on expected C . . . prices and the nameplate lifetime of the investment. ICHAR = 1 RPT = .FALSE. RLE = .FALSE. IF (NRSCHAR(ICHAR,IO,L) .GE. 1) THEN DO ISS = 1,NISS(IO,L) BETAN(ISS) = 1.0 IRHO = NIN + 1 IF (Z(IO,ISS) .GT. 0.0) THEN IVIN = M ICHAR = 1 XNP = NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN)*NSTEP RHO = A(IRHO,IDEF(IO,ISS,L),IVIN,L) Z1 = A(NIN,IDEF(IO,ISS,L),IVIN,L) ** (1.0 / RHO) & * KA(ISS,IO,IVIN,L) Z2 = Z(IO,ISS) ** (-1.0 / RHO) EQDEP(IO,ISS,L)=(A(0,IDEF(IO,ISS,L),IVIN,L)*Z1*Z2) & * XNP ELSE EQDEP(IO,ISS,L) = 0.0 END IF C . . . . . Set installed reserves and deduct from resource base. C . . . . . Note that PRCONVRT units are expressed in physical units per C . . . . . 1.0E6 1985 dollars.!ab: according to Ron now $1990$$ RESERVE(ISS) = EQDEP(IO,ISS,L) * PRCONVRT(IO,L) IF (RESERVE(ISS).LT.0.0) RESERVE(ISS) = 0.0 C . . . . . Check if reserves associate with desired investment exceed C . . . . . available reserves. If so, scale investment and EQDEP etc. C . . . . . Added conditional statement AND to correct for divide by zero error C . . . . . when reserve is zero and drsctmp is negative. IF (RESERVE(ISS) .GT. DRSCTMP(IO,ISS,L) .AND. & DRSCTMP(IO,ISS,L) .GT. 0.0) THEN RLE = .TRUE. PCT = DRSCTMP(IO,ISS,L) / RESERVE(ISS) PCT = 1.0 BETAN(ISS) = PCT EQDEP(IO,ISS,L) = PCT * EQDEP(IO,ISS,L) KA(ISS,IO,IVIN,L) = PCT * KA(ISS,IO,IVIN,L) KAFLOW(ISS,IO,IVIN,L) = PCT * KAFLOW(ISS,IO,IVIN,L) RESERVE(ISS) = DRSCTMP(IO,ISS,L) END IF ! if RESERVE IF (DRSCTMP(IO,ISS,L) .EQ. 0.0) RESERVE(ISS) = 0.0 END DO !ISS loop for checking reserves IF (RLE) THEN DO ISS = 1,NISS(IO,L) IF (ABS((BETAN(ISS) - BETA(ISS))) .GT. .1) & RPT = .TRUE. END DO ! ISS loop END IF ! if RLE IF (RPT) THEN ICNT = ICNT + 1 DO ISS = 1,NISS(IO,L) BETA(ISS) = BETAN(ISS) END DO IF (ICNT .LE. 5) GO TO 205 END IF ! if RPT DO ISS = 1,NISS(IO,L) DRSVTMP(IO,ISS,IVIN,L) = RESERVE(ISS) DRSCTMP(IO,ISS,L) = DRSCTMP(IO,ISS,L) - RESERVE(ISS)

Page 105: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

105

END DO ! ISS loop END IF ! if NRSCHAR(ICHAR,IO,L) .GE. 1 300 CONTINUE ! IO loop C . Check profitablility of delayed investments DO 400 IO = 1,NIO DO 400 ISS=1,NISS(IO,L) C . . . Add current period's annual demand for capital. LINVST = NTECHCHAR(2,IDEF(IO,ISS,L),L,IVIN) + 1 KDEM(ISS,IO,M,L) = KAFLOW(ISS,IO,IVIN,L)/FLOAT(LINVST) C . . . For delayed investments, loop over past vintages and check C . . . profitability of continuing the investment further. IVIN = M-(LINVST-1) DO WHILE (IVIN .LE. M-1) IT = M - IVIN DENOM = 0.0 IF ((LINVST-1) .GT. IT) THEN DO J = IT, LINVST-1 DENOM = DENOM + & 1/((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-J-1))) END DO ELSE DENOM = 1. END IF DENOM = DENOM * ((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-IT-1)))/FLOAT(LINVST) C . . . . Calculate expected profit term based on current C . . . . period's prices and previous period's technology C . . . . to be used in delayed investment scale. kaf10/16/92 CALL EXPPROFIT DEXP1 = EXPPROF(ISS,IO,L,M)/DENOM C . . . . Test to see if ongoing investment is still as profitable. C . . . . If as profitable, continue investment at previous period C . . . . level. If less profitable scale the investment. IF(KAFLOW(ISS,IO,IVIN,L) .GT. 0.0) THEN IF ((DEXP1 / DEXPPROF(ISS,IO,L,M-1)) & .GE. 1.0) THEN KDEM(ISS,IO,M,L) = KDEM(ISS,IO,M,L) & + KAFLOW(ISS,IO,IVIN,L) & / FLOAT(LINVST) ELSE IF (DEXPPROF(ISS,IO,L,M-1) .GT. 0.0) THEN EXPRATIO = DEXP1 & / DEXPPROF(ISS,IO,L,M-1) ELSE EXPRATIO = DEXP1 / AVPR END IF EXPRATIO = MIN(1.0D0,EXPRATIO) C EXPRATIO = 1.0 KAFLOWT(ISS,IO,IVIN,L) = KAFLOW(ISS,IO,IVIN,L) & * EXPRATIO KA(ISS,IO,IVIN,L) = KA(ISS,IO,IVIN,L) * EXPRATIO KDEM(ISS,IO,M,L) = KDEM(ISS,IO,M,L) & + KAFLOWT(ISS,IO,IVIN,L) & / FLOAT(LINVST) C . . . . . . If disminishing investment in depletable or constrained C . . . . . . renewable investment, add committed reserves back to C . . . . . . resource base. IF (NRSCHAR(1,IO,L) .GE. 1) THEN DRSCTMP(IO,ISS,L) = DRSCTMP(IO,ISS,L) & + DRSVTMP(IO,ISS,IVIN,L) & * (1. - EXPRATIO) DRSVTMP(IO,ISS,IVIN,L) = EXPRATIO & * DRSVTMP(IO,ISS,IVIN,L) END IF END IF END IF

Page 106: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

106

IVIN = IVIN + 1 END DO !end DO WHILE vintage loop 400 CONTINUE !IO and IIS loop RETURN END

Page 107: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

107

C**********************************************************************

SUBROUTINE NEWINVold C C NEWINV is a subroutine which takes expected future prices and uses C them to produce profit rates for new technology options. These C profit rates are used to compute demand for investment in new C capacity. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' DIMENSION BETA(NISSP),BETAN(NISSP),RESERVE(NISSP) REAL*8 KTOTAL REAL*8 DEXP1 LOGICAL PRINT, RLE, RPT PARAMETER(TINY = 1.E-10, AGGINVSS = .10, AGGINVS = .01, & SMALL = 1.0) print = .false. NELEC = 8 IF (IO .EQ. NELEC) THEN C ISS ids NOIL = 1 NGASid = 2 NCOAL = 3 NNUCLEAR = 4 NHYDRO = 5 NWASTE = 6 NSOLIDS = 7 NWIND = 8 NWINDOS = 9 NSOLAR = 10 NGEO = 11 NGCC = 12 IGCC = 13 NGCCccs = 14 IGCCccs = 15 PCccs = 16 ENDIF C . Begin by computing the profit rate per unit of investment C . expenditure. C . Note that P(NIN,L,M) is the interest rate. IVIN = M DO 100 IO = 1,NIO print = .false. if(m .eq. 0) print = .true. DO ISS = 1,NISS(IO,L) CALL EXPPROFIT C . . . Incorporate delay factors for investments that take more than one C . . . period before coming on line; new delay factors read in input case(354) LINVST = NTECHCHAR(2,IDEF(IO,ISS,L),L,IVIN) + 1 IT = M - IVIN DENOM = 0.0 DO J = IT, LINVST-1 DENOM = DENOM + 1/((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-J-1))) END DO DENOM = DENOM * ((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-IT-1)))/FLOAT(LINVST) DEXPPROF(ISS,IO,L,M) = EXPPROF(ISS,IO,L,M)/DENOM END DO 100 CONTINUE C . Compute weighted average profit rate using current period subsector C . profits and previous period subsector investments as weights. KTOTAL = 0.0

Page 108: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

108

AVPR = 0.0 DO IO = 1,NIO do iss = 1,niss(io,l) AVPR = AVPR + DEXPPROF(ISS,IO,L,M) ** .5 KTOTAL = KTOTAL + KAFLOW(ISS,IO,M-1,L) end do END DO IF (avpr .GT. 0.0) THEN AVPR = AVPR ** 2 ELSE AVPR = 1.0 END IF C . Determine total investment in region and investment in each C . sector. C . . Applies the basic investment equation at the sector C . . level and uses the logistic equation to share sector investment to C . . the subsector levels. Investment lost in a sector due to C . . depletable resource limits affects other C . . sectors by adjusting total capital and total capital available to C . . non-limited subsectors. Assumes that exogenous nuclear and hydro investments C are stored in EXONUC and EXOHYDRO arrays. DO IO = 1,NIO C . . . Create sector level arguments for investment equation and C . . . compute the part of investment equation independent of the C . . . current period. TMPKAF(IO,L) = 0.0 DO ISS = 1,NISS(IO,L) BETA(ISS) = 1.0 TMPKAF(IO,L) = TMPKAF(IO,L) + KAFLOW(ISS,IO,IVIN-1,L) END DO C . . . Now compute components of investment equation. IF (TMPKAF(IO,L) .GT. SMALL) THEN BASEKAP = TMPKAF(IO,L) ELSE BASEKAP = AGGINVS * KTOTAL END IF tmpka1(io,l) = wage(4,l,m-1) tmpka2(io,l) = wage(4,l,m-2) vkratio0 = (wage(1,l,m) + wage(2,l,m)) / & (wage(1,l,m-1) + wage(2,l,m-1)) vkratio(io,l) = vkratio0 * tmpka1(io,l) / tmpka2(io,l) C . . . set TMPEXP1 to 1.0 so that the comparison is to what the C . . . marginal dollar should earn under perfect competition. TMPEXP1 = 1.0 A0 = SCLINV(L) * BASEKAP * vkratio0 ** ACCINV(L) & * TMPEXP1 ** (-RINV(L)) IF(M .GE. 1) THEN SELECT CASE(LINVEST(L)) CASE(1) IF((IO .GE. 6) .AND. (IO .LE. 10)) THEN TESTINV = (TESTK(IO,L) - 2.0*BASEKAP)/3.0 IF(TESTINV .GT. (TESTK(IO,L)/10.0)) THEN A0 = TESTINV ELSE A0 = TESTK(IO,L)/10.0 END IF END IF CASE(2) TESTINV = (TESTK(IO,L) - 2.0*BASEKAP)/3.0 IF(TESTINV .GT. (TESTK(IO,L)/10.0)) THEN A0 = TESTINV ELSE A0 = TESTK(IO,L)/10.0 END IF

Page 109: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

109

CASE DEFAULT END SELECT END IF C . . . Beginning of investment share loop. C . . . Compute current period expected rate of return icnt = 0 205 TMPEXP0 = 0.0 TMPEXP2 = 0.0 TMPEXP3 = 0.0 DO ISS = 1,NISS(IO,L) TMPEXP0 = TMPEXP0 + BETA(ISS) & * DEXPPROF(ISS,IO,L,M) ** RHOINV(IO,L) IF(IO .EQ. NELEC) THEN IF(JELFIX(L,ISS,M) .NE. 1) THEN TMPEXP2 = TMPEXP2 + DEXPPROF(ISS,IO,L,M)** & (RHOINV(IO,L)+1.0) TMPEXP3 = TMPEXP3 + DEXPPROF(ISS,IO,L,M)** & RHOINV(IO,L) END IF ELSE TMPEXP2 = TMPEXP2 + DEXPPROF(ISS,IO,L,M)** & (RHOINV(IO,L)+1.0) TMPEXP3 = TMPEXP3 + DEXPPROF(ISS,IO,L,M)** & RHOINV(IO,L) END IF END DO C . . . There are two options for determining sector-level profit rates. The C . . . first IF block uses Pythagorean aggregation derived from choosing C . . . random samples from independent Weibull distributions. The second IF C . . . block calculates a weighted average profit rate. One of the following C . . . two IF blocks should be commented out. C IF (TMPEXP0 .GT. 0.0) THEN C SDEXPRF(IO,L,M) = TMPEXP0 ** (1. / RHOINV(IO,L)) C ELSE C SDEXPRF(IO,L,M) = 0.0 C END IF IF (TMPEXP3 .GT. 0.0) THEN SDEXPRF(IO,L,M) = TMPEXP2/TMPEXP3 ELSE SDEXPRF(IO,L,M) = 0.0 END IF IF (SDEXPRF(IO,L,M) .GT. 0.0) THEN K(IO,L,M) = A0 * (SDEXPRF(IO,L,M) ** RINV(L)) ELSE K(IO,L,M) = 0.0 END IF C Some sectors may have investment set exogenously. IF(EXOINVST(IO,L,M) .GT. 1.0) THEN K(IO,L,M) = EXOINVST(IO,L,M) END IF C . . . Now create subsector shares. C . . . Use the Logit function to compute market investment shares C . . . for the new capacity in sector IO. TMPEXP0 has the denominator. DO ISS = 1,NISS(IO,L) IF (TMPEXP0 .GT. 0.0) THEN IF (NRSCHAR(1,IO,L) .EQ. 0 .OR. & DRSCTMP(IO,ISS,L) .GT. 0.0 ) THEN SHARE(IO,ISS) = (DEXPPROF(ISS,IO,L,M) & ** RHOINV(IO,L)) / TMPEXP0 ELSE SHARE(IO,ISS) = 0.0 END IF ELSE SHARE(IO,ISS) = 0.0 END IF KAFLOW(ISS,IO,IVIN,L) = SHARE(IO,ISS) * K(IO,L,M) END DO

Page 110: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

110

C . . . . . Do the following only for electricity. IF (IO .EQ. NELEC) THEN SHARE(NELEC,1) = MAX(0.001D0,SHARE(NELEC,1)) SHARE(NELEC,2) = MAX(0.001D0,SHARE(NELEC,2)) SHARE(NELEC,3) = MAX(0.001D0,SHARE(NELEC,3)) SUMSHARE = 0.0 SUMFIX = 0.0 NUMFIX = 0 DO ISS = 1,NISS(NELEC,L) IF (JELFIX(L,ISS,M) .EQ. 1) THEN SUMFIX = SUMFIX + EXOELEC(L,ISS,M) NUMFIX = NUMFIX + 1 ELSE SUMSHARE = SUMSHARE + SHARE(IO,ISS) END IF END DO C If investment is fixed in all electricity subsectors, then sector C level investment is also fixed. IF(NISS(NELEC,L) .EQ. NUMFIX) THEN K(IO,L,M) = SUMFIX END IF SUMVAR = MAX(0.0,K(IO,L,M) - SUMFIX) K(IO,L,M) = SUMFIX + SUMVAR DO ISS = 1,NISS(NELEC,L) IF (JELFIX(L,ISS,M) .EQ. 1) THEN KAFLOW(ISS,IO,IVIN,L) = EXOELEC(L,ISS,M) ELSE SHARE2(IO,ISS) = SHARE(IO,ISS)/SUMSHARE KAFLOW(ISS,IO,IVIN,L) = SHARE2(IO,ISS) * 1 SUMVAR END IF END DO END IF C . . . Interpolation of the 5-year total investment flow. C . . . For calibration use read in value of vintage capital. DO ISS = 1,NISS(IO,L) FL1 = KAFLOW(ISS,IO,IVIN-1,L) IF (M .NE. 0) THEN KA(ISS,IO,IVIN,L) = & SUMINTRP(FL1,KAFLOW(ISS,IO,IVIN,L)) ELSE KA(ISS,IO,IVIN,L) = KAPRIOR(ISS,IO,0,L) END IF END DO C . . . For depletable and constrained resources, compute invested C . . . capacity using the amount produced per period based on expected C . . . prices and the nameplate lifetime of the investment. ICHAR = 1 RPT = .FALSE. RLE = .FALSE. IF (NRSCHAR(ICHAR,IO,L) .GE. 1) THEN DO ISS = 1,NISS(IO,L) BETAN(ISS) = 1.0 IRHO = NIN + 1 IF (Z(IO,ISS) .GT. 0.0) THEN IVIN = M ICHAR = 1 XNP = NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN)*NSTEP RHO = A(IRHO,IDEF(IO,ISS,L),IVIN,L) Z1 = A(NIN,IDEF(IO,ISS,L),IVIN,L) ** (1.0 / RHO) & * KA(ISS,IO,IVIN,L) Z2 = Z(IO,ISS) ** (-1.0 / RHO) EQDEP(IO,ISS,L)=(A(0,IDEF(IO,ISS,L),IVIN,L)*Z1*Z2) & * XNP ELSE EQDEP(IO,ISS,L) = 0.0 END IF C . . . . . Set installed reserves and deduct from resource base.

Page 111: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

111

C . . . . . Note that PRCONVRT units are expressed in physical units per C . . . . . 1.0E6 1985 dollars. RESERVE(ISS) = EQDEP(IO,ISS,L) * PRCONVRT(IO,L) IF (RESERVE(ISS).LT.0.0) RESERVE(ISS) = 0.0 C . . . . . Check if reserves associate with desired investment exceed C . . . . . available reserves. If so, scale investment and EQDEP etc. C . . . . . Added conditional statement AND to correct for divide by zero error C . . . . . when reserve is zero and drsctmp is negative. IF (RESERVE(ISS) .GT. DRSCTMP(IO,ISS,L) .AND. & DRSCTMP(IO,ISS,L) .GT. 0.0) THEN RLE = .TRUE. PCT = DRSCTMP(IO,ISS,L) / RESERVE(ISS) PCT = 1.0 BETAN(ISS) = PCT EQDEP(IO,ISS,L) = PCT * EQDEP(IO,ISS,L) KA(ISS,IO,IVIN,L) = PCT * KA(ISS,IO,IVIN,L) KAFLOW(ISS,IO,IVIN,L) = PCT * KAFLOW(ISS,IO,IVIN,L) RESERVE(ISS) = DRSCTMP(IO,ISS,L) END IF IF (DRSCTMP(IO,ISS,L) .EQ. 0.0) RESERVE(ISS) = 0.0 END DO IF (RLE) THEN DO ISS = 1,NISS(IO,L) IF (ABS((BETAN(ISS) - BETA(ISS))) .GT. .1) & RPT = .TRUE. END DO END IF IF (RPT) THEN ICNT = ICNT + 1 DO ISS = 1,NISS(IO,L) BETA(ISS) = BETAN(ISS) END DO IF (ICNT .LE. 5) GO TO 205 END IF DO ISS = 1,NISS(IO,L) DRSVTMP(IO,ISS,IVIN,L) = RESERVE(ISS) DRSCTMP(IO,ISS,L) = DRSCTMP(IO,ISS,L) - RESERVE(ISS) END DO END IF END DO C . Check profitablility of delayed investments. DO 400 IO = 1,NIO DO 400 ISS=1,NISS(IO,L) C . . . Add current period's annual demand for capital. LINVST = NTECHCHAR(2,IDEF(IO,ISS,L),L,IVIN) + 1 KDEM(ISS,IO,M,L) = KAFLOW(ISS,IO,IVIN,L)/FLOAT(LINVST) C . . . For delayed investments, loop over past vintages and check C . . . profitability of continuing the investment further. IVIN = M-(LINVST-1) DO WHILE (IVIN .LE. M-1) IT = M - IVIN DENOM = 0.0 IF ((LINVST-1) .GT. IT) THEN DO J = IT, LINVST-1 DENOM = DENOM + & 1/((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-J-1))) END DO ELSE DENOM = 1. END IF DENOM = DENOM * ((1.0+PI(NIN,IDEFS(IO,ISS,L),L,M,1))** & (NSTEP*(LINVST-IT-1)))/FLOAT(LINVST) C . . . . Calculate expected profit term based on current C . . . . period's prices and previous period's technology C . . . . to be used in delayed investment scale.

Page 112: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

112

CALL EXPPROFIT DEXP1 = EXPPROF(ISS,IO,L,M)/DENOM C . . . . Test to see if ongoing investment is still as profitable. C . . . . If as profitable, continue investment at previous period C . . . . level. If less profitable scale the investment. IF(KAFLOW(ISS,IO,IVIN,L) .GT. 0.0) THEN IF ((DEXP1 / DEXPPROF(ISS,IO,L,M-1)) & .GE. 1.0) THEN KDEM(ISS,IO,M,L) = KDEM(ISS,IO,M,L) & + KAFLOW(ISS,IO,IVIN,L) & / FLOAT(LINVST) ELSE IF (DEXPPROF(ISS,IO,L,M-1) .GT. 0.0) THEN EXPRATIO = DEXP1 & / DEXPPROF(ISS,IO,L,M-1) ELSE EXPRATIO = DEXP1 / AVPR END IF EXPRATIO = MIN(1.0D0,EXPRATIO) C EXPRATIO = 1.0 KAFLOWT(ISS,IO,IVIN,L) = KAFLOW(ISS,IO,IVIN,L) & * EXPRATIO KA(ISS,IO,IVIN,L) = KA(ISS,IO,IVIN,L) * EXPRATIO KDEM(ISS,IO,M,L) = KDEM(ISS,IO,M,L) & + KAFLOWT(ISS,IO,IVIN,L) & / FLOAT(LINVST) C . . . . . . If disminishing investment in depletable or constrained C . . . . . . renewable investment, add committed reserves back to C . . . . . . resource base. IF (NRSCHAR(1,IO,L) .GE. 1) THEN DRSCTMP(IO,ISS,L) = DRSCTMP(IO,ISS,L) & + DRSVTMP(IO,ISS,IVIN,L) & * (1. - EXPRATIO) DRSVTMP(IO,ISS,IVIN,L) = EXPRATIO & * DRSVTMP(IO,ISS,IVIN,L) END IF END IF END IF IVIN = IVIN + 1 END DO 400 CONTINUE RETURN END

Page 113: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

113

C*********************************************************************

SUBROUTINE OPERATENEW C This subroutine operates the newly installed capacity C of all subsectors and HOMs in sector IO. It computes C demands for all marketed commodities. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' REAL*8 Z1,Z2,SIGMA,RHO C . Compute the factor input demands for each subsector of sector IO. IVIN = M DO 900 ISS=1,NISS(IO,L) ISIGMA = NIN + 1 IRHO = ISIGMA C . . Skip to next subsector if delayed investment not yet on-line. IF ((M-IVIN).LT.NTECHCHAR(2,IDEF(IO,ISS,L),L,IVIN)) GO TO 900 C . . Skip to next subsector if alpha(0) is zero. IF (A(0,IDEF(IO,ISS,L),IVIN,L) .EQ. 0.0) GO TO 900 C . . Compute input demands for the CES function. The first step C . . is to compute the value of Z(IO,ISS). SIGMA = ACST(ISIGMA,IDEF(IO,ISS,L),IVIN,L) Z(IO,ISS) = 0.0 DO IN=1,NIN-1 IF (ACST(IN,IDEF(IO,ISS,L),IVIN,L) .NE. 0.0) THEN Z(IO,ISS) = Z(IO,ISS) + ACST(IN,IDEF(IO,ISS,L),IVIN,L) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) ** SIGMA END IF END DO RHO = A(IRHO,IDEF(IO,ISS,L),IVIN,L) C . . Go back through the CES function again using the fixed C . . inputs. Z(IO,ISS) = 1.0 - Z(IO,ISS) * (PRCV(IO,L,M) * & A(0,IDEF(IO,ISS,L),IVIN,L))** (-SIGMA) C . . Capital is now the only fixed input IF (KA(ISS,IO,IVIN,L) .GT. 0.0 .AND. Z(IO,ISS) .GT. 0.0) THEN Z1 = A(NIN,IDEF(IO,ISS,L),IVIN,L)*KA(ISS,IO,IVIN,L)**RHO Z1 = Z1**(1.0/RHO) Z2 = Z(IO,ISS) ** (-1.0 / RHO) C . . . Compute the profit rate (profit per unit of capital invested) PROFITS(IO,ISS,IVIN,L) = Z1 * Z2**(1.0 - RHO) * PRCV(IO,L,M) & * A(0,IDEF(IO,ISS,L),IVIN,L) C . . . Use Z(IO,ISS) as a place holder for all of the non-input related C . . . terms of the input demand functions. Z(IO,ISS) = Z1 * Z2 & * (PRCV(IO,L,M) * A(0,IDEF(IO,ISS,L),IVIN,L)) & ** (1.0 / (1.0 - RHO)) ELSE PROFITS(IO,ISS,IVIN,L) = 0.0 Z(IO,ISS) = 0.0 Z1 = 0.0 Z2 = 0.0 END IF C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Alternative profit calculation for Leontief technologies. IF(SIGMA1(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN CAPQ = LEON(NIN,IDEF(IO,ISS,L),IVIN,L) / & LEON(0,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ VALQ = QCAP * PRCV(IO,L,M) VALIN = 0.0D0 DO IN=1,NIN-1 VALIN = VALIN + QCAP * LEON(IN,IDEF(IO,ISS,L),IVIN,L) /

Page 114: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

114

1 LEON(0,IDEF(IO,ISS,L),IVIN,L) * 2 PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) END DO RPROF = (VALQ - VALIN) * KA(ISS,IO,IVIN,L) PROFITS(IO,ISS,IVIN,L) = MAX(0.0D0,RPROF) END IF C Use profit per unit of capital as metric for limiting output C of new vintages C First calculate profit per unit of capital. IF(KA(ISS,IO,IVIN,L) .GT. 0.0d0) THEN PROFRATE(IO,ISS,L,M,ivin) = & PROFITS(IO,ISS,IVIN,L) / KA(ISS,IO,IVIN,L) ELSE PROFRATE(IO,ISS,L,M,ivin) = 0.0d0 END IF C Then compare with threshhold. If above threshhold, FAC = 1.0. If below threshhold, C scale as a function of profit rate. PRMIN = 0.05d0 RATIO = PROFRATE(IO,ISS,L,M,ivin) / PRMIN IF(PROFRATE(IO,ISS,L,M,ivin) .GE. PRMIN) THEN FAC = 1.0d0 ELSE FAC = 3.0d0 * RATIO**2.d0 - 2.0d0 * RATIO**3.d0 END IF C End of Leontief code. C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C . . First compute direct demands from the CES production/cost C . . function then add in demands from HOM activities. DO 800 IN = 1,NIN-1 C . . . Skip to 400 if Alpha(in) is zero. IF(A(IN,IDEF(IO,ISS,L),IVIN,L).EQ.0.0) GO TO 400 C . . . For all Alpha not equal to zero, follow normal C . . . path. This is where emissions computations will C . . . be done later EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = fac * Z(IO,ISS) & * (A(IN,IDEF(IO,ISS,L),IVIN,L) & / PI(IN,IDEFS(IO,ISS,L),L,IVIN,1)) & ** (1.0 / (1.0 - RHO)) C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Alternative input-demand calculation for Leontief technologies. IF(SIGMA1(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN CAPQ = LEON(NIN,IDEF(IO,ISS,L),IVIN,L) / & LEON(0,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ QTEMP = QCAP * KA(ISS,IO,IVIN,L) RINQ = LEON(IN,IDEF(IO,ISS,L),IVIN,L) / 1 LEON(0,IDEF(IO,ISS,L),IVIN,L) RINTEMP = fac * QTEMP * RINQ EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = RINTEMP END IF C End of Leontief code. C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C . . . Compute costs and sales COST(IN,IDEFS(IO,ISS,L),IVIN,L) = & COST(IN,IDEFS(IO,ISS,L),IVIN,L) & + EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) C . . . Collect transportation costs for markets with imports. C . . . Divide by PI(NIO...) to get physical units for supply sector. TRNP(IN,L) = TRNP(IN,L) + TR(IN,L,M) * EXIMPORT(IN,L,M) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & / PI(NETE,IDEFS(IO,ISS,L),L,IVIN,1) C . . . Collect tax receipts C . . . Ad valorem taxes ITC = 1 IF (IN .EQ. NIN-1) ITC = 2 IF ((TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) .GT. 0.0) THEN TAX(ITC,IO,L) = TAX(ITC,IO,L) +

Page 115: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

115

& (P(IN,L,M) + TR(IN,L,M) * EXIMPORT(IN,L,M)) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & * (TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) ELSE IF ((TXPRO(IN,IDEFS(IO,ISS,L),L,M)-1.0) .LT. 0.0) THEN SUBSID(IN,L) = SUBSID(IN,L) & - (P(IN,L,M) + EXIMPORT(IN,L,M) * TR(IN,L,M)) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & * (TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) END IF C . . . Per Unit taxes IF (TXADD(IN,IDEFS(IO,ISS,L),L,M) .GT. 0.0) THEN TAX(ITC,IO,L) = TAX(ITC,IO,L) + & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) * & TXADD(IN,IDEFS(IO,ISS,L),L,M) ELSE IF (TXADD(IN,IDEFS(IO,ISS,L),L,M) .LT. 0.0) THEN SUBSID(IN,L) = SUBSID(IN,L) - & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) * & TXADD(IN,IDEFS(IO,ISS,L),L,M) END IF IF (CPRICER(IN,IDEFS(IO,ISS,L),L,M) .GT. 0.0) THEN oilfac=1.d0 TAX(5,IO,L) = TAX(5,IO,L) + oilfac & * CPRICER(IN,IDEFS(IO,ISS,L),L,M) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) END IF C . . . Collect adjustment factor--representing distribution and C . . . markup factors. Divide by PI(NIO...) to get physical units C . . . for supply sector. WHSL(IN,L)=WHSL(IN,L)+(ADJ(IN,IDEFS(IO,ISS,L),L,M) - 1.0) & * (((P(IN,L,M) + TR(IN,L,M) * EXIMPORT(IN,L,M)) & * TXPRO(IN,IDEFS(IO,ISS,L),L,M)) & + TXADD(IN,IDEFS(IO,ISS,L),L,M)) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) / & PI(NETE,IDEFS(IO,ISS,L),L,IVIN,1) 400 IF (IN .EQ. IO) THEN PRDVIN(IO,ISS,IVIN,L) = fac * A(0,IDEF(IO,ISS,L),IVIN,L) & * Z1 * Z2 C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Alternative output calculation for Leontief technologies. IF(SIGMA1(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN CAPQ = LEON(NIN,IDEF(IO,ISS,L),IVIN,L) / & LEON(0,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ QTEMP = fac * QCAP * KA(ISS,IO,IVIN,L) PRDVIN(IO,ISS,IVIN,L) = QTEMP END IF C End of Leontief code. C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ SALES(1,IO,L,M) = SALES(1,IO,L,M) + PRDVIN(IO,ISS,IVIN,L) SALES(2,IO,L,M) = SALES(2,IO,L,M) & + PRDVIN(IO,ISS,IVIN,L) * PRCV(IN,L,M) C . . . . If IN=IO then subtract output from demand. EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & - PRDVIN(IO,ISS,IVIN,L) C . . . . . . If depletable reserve, subtract output from reserves. C . . . . . . Add in out-year interpolation of depletion. ICHAR=1 IF (NRSCHAR(ICHAR,IO,L) .EQ. 2) THEN IF (M .GT. 0) THEN FL1 = PRDVNPRE(IO,ISS,IVIN,L) ELSE FL1 = PRDVIN(IO,ISS,IVIN,L) END IF C . . . . . Note that for the initial period all of the capital C . . . . . stock is not in operation for the full period. The C . . . . . interpolation rules reduce the draw on reserves to

Page 116: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

116

C . . . . . .6 of the draw if the capital stock were fully available. DEPLETE = SUMINTRP(FL1,PRDVIN(IO,ISS,IVIN,L)) deplete = deplete * prconvrt(io,L) C . . . . . Check to be sure depletion is not greater that C . . . . . available reserves. Needs to affect production levels C . . . . . so will implement only if negative reserves in first C . . . . . period. IF (DEPLETE .LE. DRSVTMP(IO,ISS,IVIN,L)) THEN DRSVTMP(IO,ISS,IVIN,L) = DRSVTMP(IO,ISS,IVIN,L) & - DEPLETE ELSE DEPLETE = DRSVTMP(IO,ISS,IVIN,L) DRSVTMP(IO,ISS,IVIN,L) = 0.0 END IF END IF END IF C . . Calculate excess demand by input for current period. ED(IN,IO,L,M) = ED(IN,IO,L,M) + & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) 800 CONTINUE PROF(IO,L) = PROF(IO,L) + PROFITS(IO,ISS,IVIN,L) 900 CONTINUE RETURN END

Page 117: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

117

*********************************************************************

SUBROUTINE OPERATEOLD C This subroutine operates technology IVIN, installed in a previous C period for all subsectors and HOMs in sector IO. It computes C computes demands for all marketed commodities. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' REAL*8 KDEMAND REAL*8 Z1,Z2,SIGMA logical print parameter(small = 0.5) C . PIVCLIM sets point at which a vintage begins to be operated at part C . capacity. PARAMETER (PIVCLIM = .15) C . Compute retrofit investments/existing capital stocks operations. DO 2000 ISS = 1,NISS(IO,L) ISIGMA = NIN + 1 IRHO = ISIGMA C . . Initialize PRDVIN(IO,ISS,IVIN,L) = 0.0 PROFITS(IO,ISS,IVIN,L) = 0.0 KDEMAND = 0.0 C . . Check to see if the sub-sector vintage is in operation C . . (considering if it has been retired or is a delayed C . . investment not yet on line). IF (KAPRIOR(ISS,IO,IVIN,L) .LE. 0.0) GO TO 2000 IF((M-IVIN).LT.NTECHCHAR(2,IDEF(IO,ISS,L),L,IVIN)) GO TO 2000 C . . Retire orginal IVIN(-3) vintage by 1/(Lifetime-3) each period for C . . technologies with lifetime greater than 5 periods, starting with C . . period 1 until full lifetime is reached, at which time all stock C . . is retired(retirement is done in the next set of code). This applies C . . to vintage -3 capital stock only because this vintage can have more C . . one period's worth of stock. ICHAR = 3 IF((M.GE.1).AND.(IVIN.EQ.-3).AND. & (NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN).GT.(M-IVIN))) THEN KA(ISS,IO,IVIN,L) = KAPRIOR(ISS,IO,IVIN,L) * & (1.0-(1.0/(NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN)-(M+2)))) END IF C . . Check to see if nameplate life has been exceeded. If so, C . . set profit rate negative so capital will be scrapped. ICHAR = 3 IF(NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN).LE.(M-IVIN)) & THEN PROFITS(IO,ISS,IVIN,L) = -1.0 GO TO 1200 END IF DO 300 IRF = 1,NRF(ISS,IO,IVIN,L) C . . . Check to see if the retrofit technology was previously C . . . installed. If so, update the capital stock and go on C . . . to the next technology. IF (KCPRIOR(IRF,IDEF(IO,ISS,L),IVIN,L).GT.0.0) THEN KC(IRF,IDEF(IO,ISS,L),IVIN,L) = & KCPRIOR(IRF,IDEF(IO,ISS,L),IVIN,L) C . . . . If the technology is required, buy it. ELSE IF (MYRETRO(IRF,ISS,IO,L) .EQ. M) THEN KC(IRF,IDEF(IO,ISS,L),IVIN,L) = & C(NIN,IRF,IDEF(IO,ISS,L),IVIN,L) & * KAPRIOR(ISS,IO,IVIN,L) KDEMAND = KDEMAND + KC(IRF,IDEF(IO,ISS,L),IVIN,L)

Page 118: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

118

C . . . . If the technology has not been installed and is not C . . . . required check its profitability. If profitable buy it. ELSE PROFITS(IO,ISS,IVIN,L) = -C(NIN,IRF,IDEF(IO,ISS,L),IVIN,L) DO IN = 1,NIN-1 PROFITS(IO,ISS,IVIN,L) = PROFITS(IO,ISS,IVIN,L) & + PERETRO(IN,IDEF(IO,ISS,L),IVIN,L) & * C(IN,IRF,IDEF(IO,ISS,L),IVIN,L) END DO IF (PROFITS(IO,ISS,IVIN,L) .LE. 0.0) THEN KC(IRF,IDEF(IO,ISS,L),IVIN,L)= 0.0 ELSE KC(IRF,IDEF(IO,ISS,L),IVIN,L) = & C(NIN,IRF,IDEF(IO,ISS,L),IVIN,L) & * KAPRIOR(ISS,IO,IVIN,L) KDEMAND = KDEMAND + KC(IRF,IDEF(IO,ISS,L),IVIN,L) END IF END IF 300 CONTINUE C . . Operate or retire existing vintage. C . . Check the profitability of the technology at present prices. C . . Begin by computing the profitability of retrofit technologies. DO IRF = 1,NRF(ISS,IO,IVIN,L) C . . . Check to see if the retrofit technology is in operation. C . . . If it is not, go on to the next retrofit technology. C . . . If it is, begin to compute operating profit. IF (KC(IRF,IDEF(IO,ISS,L),IVIN,L) .GT. 0.0) THEN DO IN = 1,NIN-1 PROFITS(IO,ISS,IVIN,L) = PROFITS(IO,ISS,IVIN,L) & + PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) & * C(IN,IRF,IDEF(IO,ISS,L),IVIN,L) & * KAPRIOR(ISS,IO,IVIN,L) END DO END IF END DO C . . Compute profitability for sub-sector ISS for the core C . . technology. C . . Compute input demands for the CES function. The first step C . . is to compute the value of Z(IO,ISS) (see variable dictionary). SIGMA = ACST(ISIGMA,IDEF(IO,ISS,L),IVIN,L) Z(IO,ISS) = 0.0 DO IN = 1,NIN-1 Z(IO,ISS) = Z(IO,ISS) + ACST(IN,IDEF(IO,ISS,L),IVIN,L) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) ** SIGMA END DO RHO = A(IRHO,IDEF(IO,ISS,L),IVIN,L) C . . Go back through the CES function again using the C . . fixed inputs. This is Z as given by equation 11 in C . . the Tokyo paper. Z(IO,ISS) = 1.0-Z(IO,ISS) * & (PRCV(IO,L,M)*A(0,IDEF(IO,ISS,L),IVIN,L)) & ** (-ACST(ISIGMA,IDEF(IO,ISS,L),IVIN,L)) C . . Capital is now the only fixed input. IF (KA(ISS,IO,IVIN,L) .GT. small .AND. Z(IO,ISS) .GT. 0.0) THEN Z1 = A(NIN,IDEF(IO,ISS,L),IVIN,L)*KA(ISS,IO,IVIN,L)**RHO Z1 = Z1**(1.0/RHO) Z2 = Z(IO,ISS) ** (-1.0 / RHO) C . . . Keep Z1 as Y(1/í) see KEY EQUATIONS above. C . . . Z(IO,ISS) is now equal to Z see KEY EQUATIONS above. C . . . Hold Z(-1/í) as the variable Z2. C . . . Use Z(IO,ISS) as a place holder for all of the non-input C . . . related terms of the input demand functions. PROFITS(IO,ISS,IVIN,L) = PROFITS(IO,ISS,IVIN,L) & + Z1 * (Z2 ** (1.0 - RHO)) & * PRCV(IO,L,M) * A(0,IDEF(IO,ISS,L),IVIN,L) C . . . Use total variable costs as base to compare profits to for the C . . . purpose of scaling output of existing vintages. PIVCRATIO = Z(IO,ISS)/(1. - Z(IO,ISS)) ELSE PROFITS(IO,ISS,IVIN,L) = 0.0 Z(IO,ISS) = 0.0

Page 119: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

119

PIVCRATIO = 0.0 Z1 = 0.0 Z2 = 0.0 END IF C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Alternative profit calculation for Leontief technologies. IF(SIGMA2(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN CAPQ = LEON(NIN,IDEF(IO,ISS,L),IVIN,L) / & LEON(0,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ VALQ = QCAP * PRCV(IO,L,M) VALIN = 0.0D0 DO IN=1,NIN-1 VALIN = VALIN + QCAP * LEON(IN,IDEF(IO,ISS,L),IVIN,L) / 1 LEON(0,IDEF(IO,ISS,L),IVIN,L) * 2 PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) END DO RPROF = (VALQ - VALIN) * KA(ISS,IO,IVIN,L) PROFITS(IO,ISS,IVIN,L) = MAX(0.0D0,RPROF) PIVCRATIO = Max(0.,(valq-valin)) / Valin END IF C End of Leontief code. C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1200 CONTINUE ICHAR = 1 IF (PROFITS(IO,ISS,IVIN,L) .LE. 0.0) THEN C . . . If the profit rate is less than zero, retire capital stocks and C . . . zero retrofit investment demands. KA(ISS,IO,IVIN,L) = 0.0 KDEMAND = 0.0 DO IRF = 1,NRF(ISS,IO,IVIN,L) KC(IRF,IDEF(IO,ISS,L),IVIN,L) = 0.0 END DO FAC = 0.0 C . . If capital stock is a depletable reserve that has been C . . exhausted, retire capital stock and zero retrofit demands. ELSE IF (NRSCHAR(ICHAR,IO,L) .GE. 1 .AND. & DRSVTMP(IO,ISS,IVIN,L) .LE. 0.0) THEN KA(ISS,IO,IVIN,L) = 0.0 KDEMAND = 0.0 DO IRF = 1,NRF(ISS,IO,IVIN,L) KC(IRF,IDEF(IO,ISS,L),IVIN,L) = 0.0 END DO ELSE C . . . In order to get a continuous supply function, it is necessary C . . . to idle part of a vintage for low profit rates. t1 has C . . . the profit rate for sector io. IF (M .NE. 0) THEN IF (PIVCRATIO .GE. PIVCLIM) THEN FAC = 1.0 ELSE FAC = PIVCRATIO / PIVCLIM END IF ELSE FAC = 1.0 END IF C Use profit per unit of capital as an aternative measure for limiting output C of old vintages C First calculate profit per unit of capital. IF(KA(ISS,IO,IVIN,L) .GT. 0.0d0) THEN PROFRATE (IO,ISS,L,M,ivin)= ! for each vintage & PROFITS(IO,ISS,IVIN,L) / KA(ISS,IO,IVIN,L) ELSE PROFRATE (IO,ISS,L,M,ivin)= 0.0d0 END IF C Then compare with threshhold. If above threshhold, FAC = 1.0. C If below threshhold, scale as a function of profit rate. PRMIN = 0.05d0

Page 120: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

120

RATIO = PROFRATE (IO,ISS,L,M,ivin)/ PRMIN IF(PROFRATE (IO,ISS,L,M,ivin).GE. PRMIN) THEN FAC = 1.0d0 ELSE FAC = 3.0d0*RATIO**2.d0 - 2.0d0*RATIO**3.d0 END IF C . . . For depletable resources need to be sure that production does C . . . exceed available optimal production levels from reserves. C . . . First compute adjusted production. PRDVIN(IO,ISS,IVIN,L) = fac * A(0,IDEF(IO,ISS,L),IVIN,L) & * Z1 * Z2 C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Alternative output calculation for Leontief technologies. IF(SIGMA2(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN CAPQ = LEON(NIN,IDEF(IO,ISS,L),IVIN,L) / & LEON(0,IDEF(IO,ISS,L),IVIN,L) QCAP = 1.0D0 / CAPQ QTEMP = fac * QCAP * KA(ISS,IO,IVIN,L) PRDVIN(IO,ISS,IVIN,L) = QTEMP END IF C End of Leontief code. C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PCT = 1.0 IF (NRSCHAR(ICHAR,IO,L) .EQ. 2) THEN IF (M .GT. 0) THEN FL1 = PRDVNPRE(IO,ISS,IVIN,L) ELSE FL1 = PRDVIN(IO,ISS,IVIN,L) END IF DEPLETE = SUMINTRP(FL1,PRDVIN(IO,ISS,IVIN,L)) DEPLETE = DEPLETE * PRCONVRT(IO,L) IF (M .NE. 0) THEN IF (DEPLETE .GT. DRSVTMP(IO,ISS,IVIN,L)) THEN PCT = DRSVTMP(IO,ISS,IVIN,L) / DEPLETE PCT=1.0 !Temporarily disable depletion calculations PRDVIN(IO,ISS,IVIN,L) = PCT * PRDVIN(IO,ISS,IVIN,L) deplete = drsvtmp(io,iss,ivin,l) FAC = PCT * FAC END IF ELSE FAC = 1.0 END IF C . . . subtract output from reserves DRSVTMP(IO,ISS,IVIN,L) = DRSVTMP(IO,ISS,IVIN,L) & - DEPLETE END IF PROFITS(IO,ISS,IVIN,L) = FAC * PROFITS(IO,ISS,IVIN,L) PROF(IO,L) = PROF(IO,L) + PROFITS(IO,ISS,IVIN,L) C . . . If the profit rate is greater than zero, continue to operate C . . . the vintage. Compute excess demands. Z(IO,ISS) = Z1 * Z2 & * (PRCV(IO,L,M) * A(0,IDEF(IO,ISS,L),IVIN,L)) & ** (1.0 / (1.0 - RHO)) C . . . First compute direct demands from the CES production/cost C . . . function then add in demands from HOM activities. DO 1800 IN=1,NIN-1 C . . . Skip to 400 if Alpha(in) is zero. IF (A(IN,IDEF(IO,ISS,L),IVIN,L) .EQ. 0.0) GO TO 400 C . . . . For all Alpha not equal to zero, compute demands C . . . . per equation ___ in the Tokyo paper. Eventually all emissions C . . . . code will in second part of if statement. This is now done C . . . . at the sector level in GHG. EDVIN(IN,IDEF(IO,ISS,L),IVIN,L) = fac * Z(IO,ISS) & * (A(IN,IDEF(IO,ISS,L),IVIN,L) & / PI(IN,IDEFS(IO,ISS,L),L,IVIN,1)) & ** (1.0 / (1.0 - RHO)) C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C Alternative calculation for Leontief technologies.

Page 121: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

121

IF(SIGMA2(IDEF(IO,ISS,L),L) .LT. 0.05D0) THEN RINQ = LEON(IN,IDEF(IO,ISS,L),IVIN,L) / 1 LEON(0,IDEF(IO,ISS,L),IVIN,L) RINTEMP = PRDVIN(IO,ISS,IVIN,L) * RINQ EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = RINTEMP END IF C End of Leontief code. C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C . . . . Add in retrofit technology demands for factors. DO IRF = 1,NRF(ISS,IO,IVIN,L) IF (KC(IRF,IDEF(IO,ISS,L),IVIN,L) .GT. 0.0) THEN EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L)-fac & * C(IN,IRF,IDEF(IO,ISS,L),IVIN,L) & * KAPRIOR(ISS,IO,IVIN,L) END IF END DO C . . . . Compute total costs and sales COST(IN,IDEFS(IO,ISS,L),IVIN,L) = & COST(IN,IDEFS(IO,ISS,L),IVIN,L) & + EDVIN(IN,ISS,IVIN,L) & * PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) C . . . . Collect transportation costs for markets with imports C . . . . Divide by PI(NIO...) to get physical units for supply C . . . . sector. TRNP(IN,L) = TRNP(IN,L) + TR(IN,L,M) * EXIMPORT(IN,L,M) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & / PI(NETE,IDEFS(IO,ISS,L),L,IVIN,1) C . . . . Collect tax receipts C . . . . Ad valorem taxes ITC = 1 IF (IN .EQ. NIN-1) ITC = 2 IF ((TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) .GT. 0.0) THEN TAX(ITC,IO,L) = TAX(ITC,IO,L) + & (P(IN,L,M) + TR(IN,L,M) * EXIMPORT(IN,L,M)) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & * (TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) ELSE IF ((TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) .LT. 0.0) & THEN SUBSID(IN,L) = SUBSID(IN,L) & - (P(IN,L,M) + EXIMPORT(IN,L,M) & * TR(IN,L,M)) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & * (TXPRO(IN,IDEFS(IO,ISS,L),L,M) - 1.0) END IF C . . . Per Unit taxes IF (TXADD(IN,IDEFS(IO,ISS,L),L,M) .GT. 0.0) THEN TAX(ITC,IO,L) = TAX(ITC,IO,L) + & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) * & TXADD(IN,IDEFS(IO,ISS,L),L,M) ELSE IF (TXADD(IN,IDEFS(IO,ISS,L),L,M) .LT. 0.0) THEN SUBSID(IN,L) = SUBSID(IN,L) - & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) * & TXADD(IN,IDEFS(IO,ISS,L),L,M) END IF C . . . . Collect adjustment factor--representing distribution and C . . . . markup factors. Divide by PI(NIO...) to get physical units C . . . . for supply sector. WHSL(IN,L)=WHSL(IN,L)+(ADJ(IN,IDEFS(IO,ISS,L),L,M)-1.0) & * (((P(IN,L,M) + TR(IN,L,M) & * EXIMPORT(IN,L,M)) & * TXPRO(IN,IDEFS(IO,ISS,L),L,M)) & + TXADD(IN,IDEFS(IO,ISS,L),L,M)) & * EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & / PI(NETE,IDEFS(IO,ISS,L),L,IVIN,1) 400 IF (IN .EQ. IO) THEN SALES(1,IO,L,M) = SALES(1,IO,L,M) & + PRDVIN(IO,ISS,IVIN,L) SALES(2,IO,L,M) = SALES(2,IO,L,M) & + PRDVIN(IO,ISS,IVIN,L) * PRCV(IN,L,M)

Page 122: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

122

C . . . . . If IN=IO then subtract output from demand EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) = & EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) & - PRDVIN(IO,ISS,IVIN,L) END IF C . . Calculate demand for all inputs and vintages. ED(IN,IO,L,M) = ED(IN,IO,L,M) & + EDVIN(IN,IDEFS(IO,ISS,L),IVIN,L) 1800 CONTINUE C . . . Maintain sum of capital investment demands for current period. KDEM(ISS,IO,M,L) = KDEM(ISS,IO,M,L) + fac * KDEMAND END IF !end of if profits < 0 2000 CONTINUE RETURN END

Page 123: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

123

C**********************************************************************

SUBROUTINE OUTEXCEL C OUTEXCEL is a subroutine which creates time series of certain C variables to be written to a .CSV file. This .CSV file will C then be used to create graphs in EXCEL. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' real*8 eds(32,0:nmp),sharesum REAL*8 FPOP(NLP,0:NMP), ! female population & MPOP(NLP,0:NMP), ! male population & GNPR(NLP,0:NMP), ! GNP growth rate & DEMAND(NINP,NISP,NLP,0:NMP), ! Total demand by industry by sector & TOTDMD(NINP,NLP,0:NMP), ! Total demand by input & ENDEM(NISP,0:NLP,0:NMP), ! Total energy demand by sector & SECEMS(NISP,0:NMP), ! global emissions by sector & TMP1, ! total capital stock & WPEPRD(2,0:NMP), ! World primary energy production & NETIMP(NINP,NLP,0:NMP), ! net exports & LAND(4,0:NLP,0:NMP), ! Land area(total, ag, hh) & TOTAL, ! temporary total of any output & SECSHR(NISP,NLP,0:NMP), ! sector share of total elec demand ($) & ELECTOT(NLP,0:NMP), ! total elec gen by period and region & ELECSHR(NISP,NLP,0:NMP), ! sector share of total elec demand (ej) & EMGAS(NGSP), EMGASG(NGSP,0:NM), & SHAREelecRE(4,0:NMP) !temp debug C Base year for real GDP calculations INTEGER TBASE C Base year for printing output INTEGER BASEYR C . .Date and Time for DEC INTEGER(2) tmpday, tmpmonth, tmpyear INTEGER(2) tmphour, tmpminute, tmpsecond, tmphund CHARACTER(1) mer INTEGER sub logical print print = .false. 100 FORMAT(I5,',',25(F10.3,',')) 101 FORMAT(I5,',',50(F16.4,',')) 102 FORMAT(I5,',',2(F10.0,','),4(F10.3,','),5(F10.0,',')) 103 FORMAT(I5,',',50(G12.6,',')) 110 FORMAT(I5,',',25(F12.2,',')) 200 FORMAT(I5,',',50(g12.6,',')) 900 FORMAT(I2, '/', I2.2, '/', I4.4,', ',I2, ':', I2.2, & ':', I2.2, ':', I2.2, ' ',A, 'm') 1001 FORMAT(30(F15.3,',')) 1002 FORMAT(5(F14.3,',')) 1102 FORMAT(10(A10,',')) 1109 FORMAT(40(A10,',')) 1120 FORMAT(2(I5,','),30(F10.0,',')) 1122 FORMAT(2(I5,','),1(A10,','),40(F10.2,',')) 1003 FORMAT(30(I5,',')) 1004 FORMAT(1(A10,','),30(F15.3,',')) 1005 FORMAT(1(A10,','),5(F14.3,','),1(',')) 1006 FORMAT(1(A16,','),3(','),1(F14.3,',')) 450 FORMAT(45(A10,',')) 480 FORMAT(1(A80,',')) 500 FORMAT(13('Per ',I5,',','Prod.',',','Cons.',',','Trade',',', & 'CO2(MMTC)',2(','))) 501 FORMAT(13(1(A10,','),3(','),1(F12.0,','','))) 502 FORMAT(13(1(A10,','),4(F14.2,','),1(','))) 503 FORMAT(13(1(A10,','),9(F14.2,','),1(',')))

Page 124: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

124

C Find date and time CALL GETDAT(tmpyear, tmpmonth, tmpday) CALL GETTIM(tmphour, tmpminute, tmpsecond, tmphund) IF (tmphour .GT. 12) THEN mer = 'p' tmphour = tmphour - 12 ELSE mer = 'a' END IF C ******************************** C Set base year for regions BASEYR = 1990 C ******************************** C . . Create necessary time series arrays. C . . Initialize variables for global reporting. DO MPER = 0, NM WPEPRD(1,MPER) = 0.0 WPEPRD(2,MPER) = 0.0 END DO DO MPER = 0,NM DO IS = 1,NIS SECEMS(IS,MPER) = 0.0 END DO END DO DO M = 0,NM TMP1 = 0.0 DO LL = 1,NL L = MRKDEF(0,3+LL) DO IN = NIN-3, NIN PRCONVRT(IN,L) = 1 END DO C . . Total demand by input. Sum across all sectors for each C . . input. DO IN = 1,NIN TOTDMD(IN,L,M) = 0.0 DO IS = 1,NIS IF (IS.LE.NIO .AND. IN.EQ.IS) THEN DEMAND(IN,IS,L,M) = (ED(IN,IS,L,M) & + SALES(1,IS,L,M))*PRCONVRT(IN,L) ELSE DEMAND(IN,IS,L,M) = ED(IN,IS,L,M) & * PRCONVRT(IN,L) END IF IF (IN.GT.NIO) THEN DEMAND(IN,NIS,L,M) = DEMAND(IN,NIS,L,M) & + SALES(1,IN,L,M) END IF IF (IS.EQ.NIS-3) THEN !TRADE TOTDMD(IN,L,M) = TOTDMD(IN,L,M) ELSE TOTDMD(IN,L,M) = TOTDMD(IN,L,M) & + DEMAND(IN,IS,L,M) END IF END DO NETIMP(IN,L,M) = ED(IN,NIS-3,L,M) END DO C Calculate share of total consumption for electricity by sector C The shares will be multiplied by total electricity generation to arrive C at electricity consumption by sector. IN=8 DO IS=1,NIS SECSHR(IS,L,M) = DEMAND(IN,IS,L,M) / TOTDMD(IN,L,M) END DO C Base year for real GDP is stored in integer TBASE. C If TBASE = 0, then base year = BASEYR. C If TBASE = 1, then base year = BASEYR + 5. TBASE = 0 RCONS(L,M) = 0.0 RGOVT(L,M) = 0.0 RTRD(L,M) = 0.0 DO IN = 1,NIO RCONS(L,M) = RCONS(L,M) + ED(IN,NIS,L,M) 1 * PI(IN,IDEFS(NIS,1,L),L,tbase,2) RGOVT(L,M) = RGOVT(L,M) + ED(IN,NIS-1,L,M)

Page 125: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

125

1 * PI(IN,IDEFS(NIS-1,1,L),L,tbase,2) IF(ED(IN,NIS-3,L,M) .GT. 0.0) THEN RTRD(L,M) = RTRD(L,M) + ED(IN,NIS-3,L,M) * & P(IN,L,tbase) ELSE RTRD(L,M) = RTRD(L,M) + ED(IN,NIS-3,L,M) & * P(IN,L,tbase) END IF END DO C add household consumption of land and labor to real GDP !Land RCONS(L,M) = RCONS(L,M) + ED(NIN-2,NIS,L,M) * & PI(NIN-2,IDEFS(NIS,1,L),L,tbase,2) & + SALES(1,NIN-2,L,M) * & PI(NIN-2,IDEFS(NIS,1,L),L,tbase,2) !Labor RCONS(L,M) = RCONS(L,M) + ED(NIN-1,NIS,L,M) * & PI(NIN-1,IDEFS(NIS,1,L),L,tbase,2) & + SALES(1,NIN-1,L,M) * & PI(NIN-1,IDEFS(NIS,1,L),L,tbase,2) !Gov RGOVT(L,M) = RGOVT(L,M) + ED(NIN-2,NIS-1,L,M) * & PI(NIN-2,IDEFS(NIS,1,L),L,tbase,2) RGOVT(L,M) = RGOVT(L,M) + ED(NIN-1,NIS-1,L,M) * & PI(NIN-1,IDEFS(NIS,1,L),L,tbase,2) RINVST(L,M) = ED(NIN,NIS-2,L,M) RGNP(L,M) = RCONS(L,M) + RINVST(L,M) + & RGOVT(L,M) + RTRD(L,M) RGNPW(L,M) = RGNP(L,M) / SALES(1,NIN-1,L,M) C . . Land in use data--total, agriculture, households. C . . Land market is in market NIN-2. LAND(1,L,M) = TOTDMD(NIN-2,L,M) LAND(2,L,M) = ED(NIN-2,1,L,M) LAND(3,L,M) = NHH(L,M) * R(2,L,M) LAND(4,L,M) = 0.0 DO IK = 2,NIS-1 LAND(4,L,M) = LAND(4,L,M) + ED(NIN-2,IK,L,M) END DO MPOP(L,M) = 0.0 FPOP(L,M) = 0.0 EMPLOY(L,M) = SALES(1,NIN-1,L,M) DO NA = 1,NAGE MPOP(L,M) = MPOP(L,M) + POPGCM(1,NA,M) FPOP(L,M) = FPOP(L,M) + POPGCM(2,NA,M) END DO C*********************************************************** C OUTPUT FILES C*********************************************************** C . . Write time series to .CSV file if current period is the last C . . period. IF (M.EQ.NM .OR. ISOL.GT.0) THEN C WRITE LIST OF INPUT FILES WRITE(30,*) WRITE(30,*) WRITE(30,480)CASENAME WRITE(30,480)CASENOTE DO IFILE=1,INFILES WRITE(30,480)FILES(IFILE) END DO C*********************************************************** C ENERGY & EMISSIONS & FINANCIAL OUTPUT C*********************************************************** WRITE(30,"(/'**** Region',I4,' ****')")L C . Date and Time WRITE (30, 900) tmpmonth, tmpday, tmpyear,tmphour,tmpminute, & tmpsecond,tmphund,mer IWRITE=0 IF (iwrite.eq.1) THEN WRITE (30,*)Isub(L),', SubNesting electricity Techs? Isub' WRITE (30,*)',,if >0 then subnesting in the electrcity sector'

Page 126: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

126

WRITE (30,*)',,if =0 then no subnesting' WRITE (30,*)ISUBexp(L),', SubNesting share exp switch? ISUBexp' WRITE (30,*)RHOINVsub(L),', SubNesting share exp value? &RHOINVsub' ! WRITE (30,*)Iprofitoption(L),',profit option: ' WRITE (30,*)',,if >0 then cost share in electricity sector' WRITE (30,*)',,if =0 then expected profit share for investment' WRITE (30,*)'---new subnesting logit exponents---' WRITE (30,*)RHOINV(8,L),', RHOINV_Electricity sector logit &exponent and for FF vs Renewable nest' WRITE (30,*)RHOINVpkbs(L),', RHOINVpkbs_peak vs base nest' ! logit parm for peak base nest WRITE (30,*)RHOINVfsl(L),', RHOINVfsl_fossil fuel nests' ! logit parm for fossil nest WRITE (30,*)RHOINVrnw(L),', RHOINVrnw_ among renewables nest' ! logit parm for fossil renewable nest WRITE (30,*)RHOINVccs(L),', RHOINVccs_C capture' WRITE(30,*) WRITE(30,*)LINVST,', Investment option Used' WRITE(30,*) ! carbon capture efficiency by new electrcity generating ff technologies WRITE(30,*)1-sqccs,', Capture effciency ccs technologies' WRITE(30,*) END IF WRITE (30,*) WRITE (30,*)Iseqsw(L),', Soil Sequestering offset (from McCarl)? &Iseqsw in asm.csv' WRITE (30,*)',,if >0 then soil sequestration of carbon' WRITE (30,*)',,if =0 then no sequestration' ! IF(DEFLATOR(L).LT.0.0001) THEN DEFLATOR(L)=1.0 END IF WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)' Real GNP (1990 mil.)' WRITE(30,*)'YR,RGNP,' DO MPER = 0,NM IYR = BASEYR + MPER * 5 IF (MPER.GT.0) THEN GNPR(L,MPER) = (RGNP(L,MPER)/RGNP(L,MPER-1))**0.2 -1 END IF WRITE(30,"(I5,',',5(F12.0,','),3(F10.3,','))") & IYR,RGNP(L,MPER)*DEFLATOR(L) END DO IF(Iprofitoption(L).gt.0) then WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Beta in' WRITE(30,450)'in', 'betain' DO in = 1,16 WRITE(30,101)in,(Betain(in,L)) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Beta B' WRITE(30,450)'in', 'betaB' DO in = 1,3 WRITE(30,101)in,(BetaB(in,L)) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Beta F' WRITE(30,450)'in', 'betaF' DO in = 1,2 WRITE(30,101)in,(Betaf(in,L)) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Beta E' WRITE(30,450)'in', 'betae' DO in = 1,4 WRITE(30,101)in,(Betae(in,L)) END DO

Page 127: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

127

END IF ! end if: write if not expected profit sharing but if investment is based on cost sharing WRITE(30,*) WRITE(30,*)'# of Periods of Delay in Electricity Technologies & coming on Line' WRITE(30,"(17(A10,','))") & (TECHNAME(8,ISS,L),ISS=1,NISS(8,L)) WRITE(30,"((17(G12.0,',')))") & (issDelay(L,ISS),ISS=1,NISS(8,L)) WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'GHG Emissions (MMTC Equivalent)' WRITE(30,450)'Year','CO2','CH4','N20','HFC','PFC','SF6', &'ODSsub','Tot','TtCrl','CO2-Offs','Tot-Offs','Offs','CPr', &'CRv','OfP','EmS','NGGCseq','IGCCseq','PCseq' DO MPER = 0,NM IYR = BASEYR + MPER * 5 ETOTOT = 0.0 DO IX = 1,NGSP EMGAS(IX) = 0.0 !initialize local END DO DO IX = 1,NSOURCE(L) EMGAS(EMC(IX,3,L)) = EMGAS(EMC(IX,3,L)) & + EM(IX,L,MPER) EMGASG(EMC(IX,3,L),MPER) = & EMGASG(EMC(IX,3,L),MPER) & + EM(IX,L,MPER) !global END DO if (ISUB(L).eq.1) then SeqNGCCccs = IOemis(2,IDEFS(8,14,L),MPER,3)*(1-sqccs)/sqccs SeqIGCCccs = IOemis(3,IDEFS(8,15,L),MPER,3)*(1-sqccs)/sqccs SeqPCccs = IOemis(3,IDEFS(8,16,L),MPER,3)*(1-sqccs)/sqccs else SeqNGCCccs = 0.D0 SeqIGCCccs = 0.D0 SeqPCccs = 0.D0 end if WRITE(30,101)IYR,(EMGAS(JGAS),JGAS=1,7),SUM(EMGAS),EMTOT(L,MPER) &,EMGAS(1)-EmSave(L,Mper),EMTOT(L,MPER)-EmSave(L,Mper), &-1*EmSave(L,Mper),P(NIN-3,l,mper),P(NIN-3,l,mper)*EMTOT(L,MPER), &EmSqPSav(l,mper),EmSave(L,Mper), &SeqNGCCccs,SeqIGCCccs,SeqPCccs END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Carbon Dioxide Emissions by Source (MMTC)' WRITE(30,450)'Year',(EMCLABEL(IX,L),IX=1,NSOURCE(L)) c Global totals DO IX = 1,NSOURCE(L) EM(IX,0,M) = EM(IX,0,M) + EM(IX,L,M) END DO DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,101)IYR, (EM(IX,L,MPER), IX=1,NSOURCE(L)) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)' Carbon Policy Summary' WRITE(30,*)'Year,C.Target(MMTC),C.Trd(MMTC),C.Price(90$),', & 'C.Price(Local),C.Trd Rev.(Local)' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,110)IYR, & CARBONLIM(L,MPER),TRADE(1,NIN-3,L,MPER), & P(NIN-3,L,MPER),P(NIN-3,L,MPER)*EXCHRATE(L), & TRADE(1,NIN-3,L,MPER)*P(NIN-3,L,MPER)*EXCHRATE(L) END DO WRITE(30,*) WRITE(30,"(' Emissions and C_Revenue from Elec. Prod.

Page 128: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

128

& In Region ',I3)")L WRITE(30,"('Year,Oilemm,Gasemm,Coalemm(24.08),R.Oilemm(20.43), &GasT&Demm(13.65),oilrev,gasrev,coalrev,roilrev,gast&drev')") DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',80(g12.6,','))")IYR, & DEMAND (3,8,L,MPER)*20.43, & DEMAND (4,8,L,MPER)*13.65, & DEMAND (5,8,L,MPER)*24.08, & DEMAND (9,8,L,MPER)*20.43, & DEMAND (10,8,L,MPER)*13.65, & DEMAND (3,8,L,MPER)*20.43*P(NIN-3,l,mper), & DEMAND (4,8,L,MPER)*13.65*P(NIN-3,l,mper), & DEMAND (5,8,L,MPER)*24.08*P(NIN-3,l,mper), & DEMAND (9,8,L,MPER)*20.43*P(NIN-3,l,mper), & DEMAND (10,8,L,MPER)*13.65*P(NIN-3,l,mper) END DO C revenue of carbon fees on electricity generation is simply demand C for electricity in Exajoules times emission factor times carbon price C to add carbon fees to electricity-specific fuel demand ... C presently we pay electricity prices...but we do have fuel-specific electricity generation investments WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Emissions by Sector' WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' DO MPER = 0,NM IYR = BASEYR + MPER * 5 DO IS = 1,NIS ! sum global totals SECEMS(IS,MPER) = SECEMS(IS,MPER) + ED(NIN-3,IS,L,MPER) END DO WRITE(30,200)IYR,(ED(NIN-3,IO,L,MPER), IO = 1,NIO), & (ED(NIN-3,IS,L,MPER), IS = NIS-1,NIS) END DO WRITE(30,*) ! end use co2 emissions WRITE(30,*)'End Use CO2 Emissions' WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) DO MPER = 0,12 IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemisCO2(IO,Mper,L),IO=1,NIO) END DO WRITE(30,*) WRITE(30,*)'Electricity Generation in kWh' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (ELECGEN(ISS,L,MPER)*1000000/3.60,ISS=1,NISS(8,L)) END DO IF(Iprofitoption(L).gt.0) then WRITE(30,*) WRITE(30,*)'Levelized cost mills/kWh' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (LevCost(L,ISS,MPER),ISS=1,NISS(8,L)) END DO END IF WRITE(30,*) WRITE(30,*)'Expected Profit rates: EXPPROF()' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (EXPPROF(ISS,8,L,MPER),ISS=1,NISS(8,L)) END DO WRITE(30,*) WRITE(30,*)'Actual Profit rates for that time

Page 129: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

129

&period' WRITE(30,"(3(A5,17(A10,',,,,')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) WRITE(30,'(",",17("ivin=-3,-2,-1,0,"))') DO MPER = 0,NM IYR = BASEYR + MPER * 5 DO IO=1,NIO if (IO.eq.8)write(30,"((i4,','),80(g12.6,','))")iyr, &((PROFRATE(IO,ISS,L,MPER,ivin),ivin=MPER-3,MPER),ISS=1,NISS(IO,L)) ENDDO ENDDO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)' Capital demand in the Electricity subsectors' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"((I5,',',19(g12.6,',')))")IYR, & (KDEM(ISS,8,MPER,L),ISS=1,NISS(8,L)) END DO IF(Iprofitoption(L).gt.0) then ! Check share calculations WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Electricity Subsector Total Investment Shares' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)),'check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do iss=1,NISS(8,L) sharesum = sharesum + SHAREstore(2,MPER,ISS) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREstore(2,MPER,ISS),ISS=1,NISS(8,L)), & sharesum END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Electricity Subsector Endogenous Investment Shares' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)),'check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do iss=1,NISS(8,L) sharesum = sharesum + SHAREstore(1,MPER,ISS) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREstore(1,MPER,ISS),ISS=1,NISS(8,L)), & sharesum END DO if (1.eq.1) then !temp switch for turning share reporting on or off WRITE(30,*) WRITE(30,*)'Fossil Renewables Nuclear & Hydro level total investment shares' WRITE(30,"(3(A5,17(A10,',')))")',', & 'Fossil','Renewables','Nuclear','Hydro','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,4 sharesum = sharesum + SHAREelec(ins,MPER,2) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREelec(ins,MPER,2),INS=1,4), & sharesum END DO WRITE(30,*) WRITE(30,*)'Fossil Renewables Nuclear & Hydro level endogenous investment shares' WRITE(30,"(3(A5,17(A10,',')))")',',

Page 130: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

130

& 'Fossil','Renewables','Nuclear','Hydro','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,4 sharesum = sharesum + SHAREelec(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREelec(ins,MPER,1),INS=1,4), & sharesum END DO WRITE(30,*) WRITE(30,*)'Peak Base level endogenous investment shares' WRITE(30,"(3(A5,17(A10,',')))")',', & 'Peak','Base','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,2 sharesum = sharesum + SHAREfrnh1(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREfrnh1(ins,MPER,1),INS=1,2), & sharesum END DO WRITE(30,*) WRITE(30,*)'Renewables level total investment shares' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=6,11),'check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,6 sharesum = sharesum + SHAREfrnh2(ins,MPER,2) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREfrnh2(ins,MPER,2),INS=1,6), & sharesum END DO WRITE(30,*) WRITE(30,*)'Renewables level endogenous investment shares' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=6,11),'check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,6 sharesum = sharesum + SHAREfrnh2(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREfrnh2(ins,MPER,1),INS=1,6), & sharesum END DO WRITE(30,*) WRITE(30,*)'Peak level endogenous investment shares' WRITE(30,"(3(A5,17(A10,',')))")',', & 'Oil','Gas','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,2 sharesum = sharesum + SHAREpkbs1(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREpkbs1(ins,MPER,1),INS=1,2), & sharesum END DO WRITE(30,*) WRITE(30,*)'Base level endogenous investment shares' WRITE(30,"(3(A5,17(A10,',')))")',', & 'Coal','NGCC','IGCC','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,3 sharesum = sharesum + SHAREpkbs2(ins,MPER,1)

Page 131: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

131

end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREpkbs2(ins,MPER,1),INS=1,3), & sharesum END DO WRITE(30,*) WRITE(30,*)'CCS level endogenous investment shares - PC' WRITE(30,"(3(A5,17(A10,',')))")',', & 'PC','PCccs','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,2 sharesum = sharesum + SHAREccs1(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREccs1(ins,MPER,1),INS=1,2), & sharesum END DO WRITE(30,*) WRITE(30,*)'CCS level endogenous investment shares - NGCC' WRITE(30,"(3(A5,17(A10,',')))")',', & 'NGCC','NGCCccs','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,2 sharesum = sharesum + SHAREccs2(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREccs2(ins,MPER,1),INS=1,2), & sharesum END DO WRITE(30,*) WRITE(30,*)'CCS level endogenous investment shares - IGCC' WRITE(30,"(3(A5,17(A10,',')))")',', & 'IGCC','IGCCccs','check sum=1' DO MPER = 0,NM IYR = BASEYR + MPER * 5 sharesum = 0.d0 do ins=1,2 sharesum = sharesum + SHAREccs3(ins,MPER,1) end do WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (SHAREccs3(ins,MPER,1),INS=1,2), & sharesum END DO end if !end temp switch for turning share reporting on or off END IF ! WRITE(30,*) ! End use co2 emissions by fuel WRITE(30,*)'End Use CO2 Emissions - Oil' WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) DO MPER = 0,NM if (io.eq.8) then sub = 9 else sub = 1 end if IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemis(1,IDEFS(IO,sub,L),MPER,3),IO=1,NIO) END DO WRITE(30,*) ! End use co2 emissions by fuel WRITE(30,*)'End Use CO2 Emissions - Gas' WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) DO MPER = 0,NM if (io.eq.8) then sub = 9 else sub = 1 end if IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemis(2,IDEFS(IO,sub,L),MPER,3),IO=1,NIO) END DO

Page 132: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

132

WRITE(30,*) ! End use co2 emissions by fuel WRITE(30,*)'End Use CO2 Emissions - Coal' WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) DO MPER = 0,NM if (io.eq.8) then sub = 9 else sub = 1 end if IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemis(3,IDEFS(IO,sub,L),MPER,3),IO=1,NIO) END DO WRITE(30,*) ! End use co2 emissions by fuel WRITE(30,*)'Elec - End Use CO2 Emissions - Oil' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemis(1,IDEFS(8,ISS,L),MPER,3),ISS=1,NISS(8,L)) END DO WRITE(30,*) ! End use co2 emissions by fuel WRITE(30,*)'Elec - End Use CO2 Emissions - Gas' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemis(2,IDEFS(8,ISS,L),MPER,3),ISS=1,NISS(8,L)) END DO WRITE(30,*) ! End use co2 emissions by fuel WRITE(30,*)'Elec - End Use CO2 Emissions - Coal' WRITE(30,"(3(A5,17(A10,',')))")',', & ((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(i4,',',60(g12.6,','))")IYR, & (IOemis(3,IDEFS(8,ISS,L),MPER,3),ISS=1,NISS(8,L)) END DO C Don't use a deflator if one has not been read in for region IF(DEFLATOR(L).LT.0.0001) THEN DEFLATOR(L)=1.0 END IF WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,290) 290 FORMAT(' Nominal GNP by components and Labor Productivity & (1990 mil.)') WRITE(30,*)'Year,Nom. Cons,Nom. Inv.,Nom. Govt,Nom. TB,', & 'Nom. GNP,GNP GR,NGNP/work,NGNP/Cap' DO MPER = 0,NM IYR = BASEYR + MPER * 5 IF (MPER.GT.0) THEN GNPR(L,MPER) = (GNP(L,MPER)/GNP(L,MPER-1))**0.2 -1 END IF GNP(L,MPER) = CONS(L,MPER)+KTOT(L,MPER)+GOVMT(L,MPER)+ & EXIM(L,MPER) WRITE(30,"(I5,',',5(F12.0,','),3(F10.3,','),g12.6)")IYR, & CONS(L,MPER)*DEFLATOR(L),KTOT(L,MPER)*DEFLATOR(L), & GOVMT(L,MPER)*DEFLATOR(L),EXIM(L,MPER)*DEFLATOR(L), & GNP(L,MPER)*DEFLATOR(L),GNPR(L,MPER), & WAGE(4,L,MPER)*DEFLATOR(L), & GNP(L,MPER)/POPLM(L,MPER)*DEFLATOR(L) CONS(0,MPER) = CONS(0,MPER) + CONS(L,MPER)/EXCHRATE(L) KTOT(0,MPER) = KTOT(0,MPER) + KTOT(L,MPER)/EXCHRATE(L) GOVMT(0,MPER) = GOVMT(0,MPER) + GOVMT(L,MPER)/EXCHRATE(L) EXIM(0,MPER) = EXIM(0,MPER) + EXIM(L,MPER)/EXCHRATE(L) GNP(0,MPER) = GNP(0,MPER) + GNP(L,MPER)/EXCHRATE(L) END DO

Page 133: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

133

WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,300) 300 FORMAT(' Real GNP by components and Labor Productivity & (1990 mil.)') WRITE(30,*)'YR,RCons,RInv,RGovt,RTB,', & 'RGNP,GNP GR,RGNP/Work,RGNP/Cap,' DO MPER = 0,NM IYR = BASEYR + MPER * 5 IF (MPER.GT.0) THEN GNPR(L,MPER) = (RGNP(L,MPER)/RGNP(L,MPER-1))**0.2 -1 END IF WRITE(30,"(I5,',',5(F12.0,','),3(F10.3,','))") & IYR, & RCONS(L,MPER)*DEFLATOR(L),RINVST(L,MPER)*DEFLATOR(L), & RGOVT(L,MPER)*DEFLATOR(L),RTRD(L,MPER)*DEFLATOR(L), & RGNP(L,MPER)*DEFLATOR(L),GNPR(L,MPER), & RGNPW(L,MPER)*DEFLATOR(L), & RGNP(L,MPER)/POPLM(L,MPER)*DEFLATOR(L) RCONS(0,MPER) = RCONS(0,MPER) + RCONS(L,MPER)/EXCHRATE(L) RINVST(0,MPER) = RINVST(0,MPER) + RINVST(L,MPER)/EXCHRATE(L) RGOVT(0,MPER) = RGOVT(0,MPER) + RGOVT(L,MPER)/EXCHRATE(L) RTRD(0,MPER) = RTRD(0,MPER) + RTRD(L,MPER)/EXCHRATE(L) RGNP(0,MPER) = RGNP(0,MPER) + RGNP(L,MPER)/EXCHRATE(L) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,330) 330 FORMAT(' Real ED by components and prices and sales') WRITE(30,*)'Yr,RCns,Pilshh,Saleslshh, &Pilbshh,Saleslbshh,Rgov,Rinvst,Piinvst,Rtrd' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',40(g12.6,','))")IYR, & Rcons(l,mper), & Pi(nin-2,idefs(nis,1,l),L,mper,1), & Sales(1,nin-2,l,mper), & Pi(nin-1,idefs(nis,1,l),L,mper,1), & Sales(1,nin-1,l,mper), & Rgovt(l,mper), & Rinvst(l,mper),Pi(nin,idefs(nis,1,l),L,mper,1), & Rtrd(l,mper) ENDDO WRITE(30,*) WRITE(30,"(' Region gross Production = Sales')") WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) DO MPER = 0,NM write(30,"(i5,',',34(g12.6,','))")mper, & (Sales(1,io,l,mper),io=1,nisp) ENDDO Write(30,*) WRITE(30,"(' Region ADJ matrix i=26')") WRITE(30,"(A5,23(A12,','))")'Year,', & (TECHNAME(3,ISS,L),ISS=1,NISS(3,L)), & (TECHNAME(4,ISS,L),ISS=1,NISS(4,L)), & (TECHNAME(5,ISS,L),ISS=1,NISS(5,L)), & (TECHNAME(6,ISS,L),ISS=1,NISS(6,L)), & (TECHNAME(7,ISS,L),ISS=1,NISS(7,L)), & (TECHNAME(8,ISS,L),ISS=1,NISS(8,L)), & (TECHNAME(9,ISS,L),ISS=1,NISS(9,L)), & (TECHNAME(10,ISS,L),ISS=1,NISS(10,L)) DO MPER = 0,NM do in=26,nin write(30,"(i5,',',34(g12.6,','))")mper, & (ADJ(in,io,l,mper),io=1,nisp) enddo enddo WRITE(30,*) WRITE(30,*)'Prices fixed (T) or float (F)' WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' WRITE(30,'(",",42(L2,","))')Baseyr,(IPFIX(KK,L,1),KK=1,NIN) WRITE(30,*) WRITE(30,"(' Region Pi = market prices ',I3)")

Page 134: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

134

WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) do mper=0,nm IYR = BASEYR + MPER * 5 write(30,"(i5,',',34(g12.6,','))")iyr, & (P(IN,L,mper),in=1,nin) enddo WRITE(30,*) WRITE(30,*) WRITE(30, & "(' Region prices received for each commodity produced',I3)") WRITE(30,450)'Year',(SECNAME(IO,L),IO=1,NIO) do mper=0,nm IYR = BASEYR + MPER * 5 write(30,"(i5,',',34(g12.6,','))")iyr, & (PRCV(IS,L,mper),is=1,nis) enddo WRITE(30,*) WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Fossil Fuel Energy Consumption by Sector (in EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' C Calculate total energy consumption (not incl. electricity) by sector DO MPER = 0,NM DO IS=1,NIO DO IN=3,7 ENDEM(IS,L,MPER)=ENDEM(IS,L,MPER)+DEMAND(IN,IS,L,MPER) END DO DO IN=9,10 ENDEM(IS,L,MPER)=ENDEM(IS,L,MPER)+DEMAND(IN,IS,L,MPER) END DO END DO END DO DO MPER = 0,NM DO IS=NIS-1,NIS DO IN=3,7 ENDEM(IS,L,MPER)=ENDEM(IS,L,MPER)+DEMAND(IN,IS,L,MPER) END DO DO IN=9,10 ENDEM(IS,L,MPER)=ENDEM(IS,L,MPER)+DEMAND(IN,IS,L,MPER) END DO END DO END DO C Subtract from R. Oil, Gas T&D, and Coal Products sectors the primary consumption of C Crude Oil, N. Gas, and Coal so that the amounts are not double counted DO MPER = 0,NM ENDEM(6,L,MPER)=ENDEM(6,L,MPER)-DEMAND(5,6,L,MPER) ENDEM(9,L,MPER)=ENDEM(9,L,MPER)-DEMAND(3,9,L,MPER) ENDEM(10,L,MPER)=ENDEM(10,L,MPER)-DEMAND(4,10,L,MPER) END DO DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & (ENDEM (IS,L,MPER),IS = 1,NIO), & (ENDEM (IS,L,MPER),IS = NIS-1,NIS) C Calculate global totals DO IS=1,NIO ENDEM(IS,0,MPER)=ENDEM(IS,0,MPER)+ENDEM(IS,L,MPER) END DO DO IS=NIS-1,NIS ENDEM(IS,0,MPER)=ENDEM(IS,0,MPER)+ENDEM(IS,L,MPER) END DO END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Refined Oil and Gas Production (in EJ)' WRITE(30,"(A5,15(A12,1h,))")'Year,', & ((TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)),IO=9,10) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',10(G13.3,','))")IYR, & (ROUT(9,ISS,L,MPER)*PRCONVRT(9,L),ISS=1,NISS(9,L)), !refined oil

Page 135: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

135

& (ROUT(10,ISS,L,MPER)*PRCONVRT(10,L),ISS=1,NISS(10,L)) !Gas T&D END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Net Export of Energy (in EJ)' WRITE(30,*)'Year,C.Oil,N.Gas,Coal,Coal Prd.,Uran,Elec,R.Oil,', & 'R.Gas,Total' DO MPER = 0,NM IYR = BASEYR + MPER * 5 IF (NL.GT.1) THEN TOTAL = 0.0 DO IO = 3,8 TOTAL = TOTAL + TOTPRD(IO,L,MPER) & - TOTDMD(IO,L,MPER) END DO TOTAL = TOTAL + TOTPRD(9,L,MPER) & - TOTDMD(9,L,MPER) & + TOTPRD(10,L,MPER) & - TOTDMD(10,L,MPER) WRITE(30,"(I5,',',9(F9.2,','))")IYR, & ((TOTPRD(IO,L,MPER)-TOTDMD(IO,L,MPER)),IO=3,10), & TOTAL ELSE TOTAL = NETIMP(3,L,MPER) & + NETIMP(4,L,MPER) & + NETIMP(5,L,MPER) & + NETIMP(6,L,MPER) & + NETIMP(7,L,MPER) & + NETIMP(8,L,MPER) & + NETIMP(9,L,MPER) & + NETIMP(10,L,MPER) WRITE(30,200)IYR, & (NETIMP(IN,L,MPER),IN=3,10), & TOTAL END IF END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Electricity Generated (in EJ)' WRITE(30,"(3(A5,17(A10,',')))")'Year,', &((TECHNAME(8,ISS,L)),ISS=1,NISS(8,L)),'Total' DO MPER = 0,NM IYR = BASEYR + MPER * 5 ELECTOT(L,MPER) = 0.0 DO ISS = 1,NISS(8,L) ELECTOT(L,MPER)=ELECTOT(L,MPER)+ELECGEN(ISS,L,MPER) END DO WRITE(30,"(3(I5,',',17(g12.6,',')))")IYR, & (ELECGEN(ISS,L,MPER),ISS=1,NISS(8,L)), & ELECTOT(L,MPER) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Primary Energy Consumption (in PJ)' WRITE(30,450)'Year', 'Oil', 'Gas', 'Coal', & 'Year', 'elecOil', 'elecGas', 'elecCoal' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,101)IYR,(PriEnergyC(IX,L,Mper), IX=3,5), & IYR,PriEnergyCelec(9,L,Mper), & PriEnergyCelec(4,L,Mper), & PriEnergyCelec(5,L,Mper) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Fuel Consumption for Elec. Prod. (in EJ)' WRITE(30,*)'Year,Oil,Gas,Coal,R.Oil,N.Gas' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & DEMAND (3,8,L,MPER), & DEMAND (4,8,L,MPER),

Page 136: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

136

& DEMAND (5,8,L,MPER), & DEMAND (9,8,L,MPER), & DEMAND (10,8,L,MPER) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Crude Oil Consumption (EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' IN = 3 !crude oil input DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & (DEMAND (IN,IS,L,MPER),IS = 1,NIO), & (DEMAND (IN,IS,L,MPER),IS = NIS-1,NIS) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Natural Gas Consumption (EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' IN = 4 !natural gas input DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & (DEMAND (IN,IS,L,MPER),IS = 1,NIO), & (DEMAND (IN,IS,L,MPER),IS = NIS-1,NIS) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Coal Consumption (EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' IN = 5 !Coal input DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & (DEMAND (IN,IS,L,MPER),IS = 1,NIO), & (DEMAND (IN,IS,L,MPER),IS = NIS-1,NIS) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'R. Oil Consumption (EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' IN = 9 !refined oil input DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & (DEMAND (IN,IS,L,MPER),IS = 1,NIO), & (DEMAND (IN,IS,L,MPER),IS = NIS-1,NIS) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'R. Gas Consumption (EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' IN = 10 !gas t&d input DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR, & (DEMAND (IN,IS,L,MPER),IS = 1,NIO), & (DEMAND (IN,IS,L,MPER),IS = NIS-1,NIS) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Elect Consumption (EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' IN = 8 !electricity input DO MPER = 0,NM IYR = BASEYR + MPER * 5 C Calculate share of total electricity generation by sector DO IS=1,NIS ELECSHR(IS,L,MPER)=SECSHR(IS,L,MPER)* & (ELECTOT(L,MPER)-NETIMP(8,L,MPER)) END DO WRITE(30,200)IYR, & (ELECSHR (IS,L,MPER),IS = 1,NIO), & (ELECSHR (IS,L,MPER),IS = NIS-1,NIS)

Page 137: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

137

END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Primary Energy Consumption (in PJ)' WRITE(30,450)'Year', 'Oil', 'Gas', 'Coal', & 'Year', 'elecOil', 'elecGas', 'elecCoal' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,101)IYR,(PriEnergyC(IX,L,Mper), IX=3,5), & IYR,PriEnergyCelec(9,L,Mper), & PriEnergyCelec(4,L,Mper), & PriEnergyCelec(5,L,Mper) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Output by Non-Energy Production Sector ', & '(1990 million currency)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,2), & (SECNAME(IO,L),IO=11,NIO) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',14(F15.0,','))")IYR, & (TOTPRD(IO,L,MPER),IO=1,2), & (TOTPRD(IO,L,MPER),IO=11,NIO) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Agricultural Demand in ' WRITE(30,*)'Year,Oil,R.Oil,GasT&D,Hhold,Govt,Hhold/Cap.' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',6(F13.3,','))")IYR,ED(1,3,L,MPER), & ED(1,9,L,MPER), & ED(1,10,L,MPER), & ED(1,NIS,L,MPER), & ED(1,NIS-1,L,MPER), & ED(1,NIS,L,MPER)/POPLM(L,MPER) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Demographics (1,000s)' WRITE(30,*)'Year,Tot.Pop,WAGE-M,WAGE-F,', & 'WAGE-Tot.,Employed' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',5(F13.0,','))")IYR,POPLM(L,MPER), & WAGE(1,L,MPER), WAGE(2,L,MPER), & WAGE(1,L,MPER)+WAGE(2,L,MPER), & EMPLOY(L,MPER) POPLM(0,MPER) = POPLM(0,MPER) + POPLM(L,MPER) WAGE(1,0,MPER) = WAGE(1,0,MPER) + WAGE(1,L,MPER) WAGE(2,0,MPER) = WAGE(2,0,MPER) + WAGE(2,L,MPER) EMPLOY(0,MPER) = EMPLOY(0,MPER) + EMPLOY(L,MPER) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Total Capital Stock and Carbon Permit Revenues' WRITE(30,*)'Year,1000employed,Capital,CpermRev,Sav,RE, &GovDef,Profit,GovMt' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',18(F13.2,','))")IYR, & EMPLOY(L,MPER), & KWORK(L,MPER),CRBPRICETOT(L,MPER), & SAVING(L,MPER),-ED(NIN,NIS,L,MPER)-SAVING(L,MPER), & GOVDEFT(L,MPER),TPROF(L,MPER), & GovMT(L,Mper) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Pricepaid information'

Page 138: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

138

WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Carbon','Land', & 'Labor','Capital' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"((I5,','),30(f13.6,','))")IYR, & (PPDELEC(IN,L,MPER),IN=1,NIN-1), & P(NIN,L,MPER) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Energy Investment' WRITE(30,"(A5,23(A12,','))")'Year,', & (TECHNAME(3,ISS,L),ISS=1,NISS(3,L)), & (TECHNAME(4,ISS,L),ISS=1,NISS(4,L)), & (TECHNAME(5,ISS,L),ISS=1,NISS(5,L)), & (TECHNAME(6,ISS,L),ISS=1,NISS(6,L)), & (TECHNAME(7,ISS,L),ISS=1,NISS(7,L)), & (TECHNAME(8,ISS,L),ISS=1,NISS(8,L)), & (TECHNAME(9,ISS,L),ISS=1,NISS(9,L)), & (TECHNAME(10,ISS,L),ISS=1,NISS(10,L)) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',23(G13.3,','))")IYR, & (KDEM(ISS,3,MPER,L),ISS=1,NISS(3,L)), & (KDEM(ISS,4,MPER,L),ISS=1,NISS(4,L)), & (KDEM(ISS,5,MPER,L),ISS=1,NISS(5,L)), & (KDEM(ISS,6,MPER,L),ISS=1,NISS(6,L)), & (KDEM(ISS,7,MPER,L),ISS=1,NISS(7,L)), & (KDEM(ISS,8,MPER,L),ISS=1,NISS(8,L)), & (KDEM(ISS,9,MPER,L),ISS=1,NISS(9,L)), & (KDEM(ISS,10,MPER,L),ISS=1,NISS(10,L)) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Investment by Other Sectors' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,2), & (SECNAME(IO,L),IO=11,NIO) DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',14(G13.3,','))")IYR, & (KDEM(1,IO,MPER,L),IO=1,2), & (KDEM(1,IO,MPER,L),IO=11,NIO) END DO WRITE(30,*) WRITE(30,"(' Region',I3)")L WRITE(30,*)'Production and Consumption by Sector' WRITE(30,500) (MPER, MPER=0,NM) DO IN=1,NIO WRITE(30,502) (SECNAME(IN,L),EPRD(IN,L,MPER), & EDEM(IN,L,MPER),ETRADE(IN,L,MPER), & CO2(IN,L,MPER),MPER=0,NM) END DO WRITE(30,501) ('Total CO2 (MMTC)',TOTCO2(L,MPER),MPER=0,NM) WRITE(30,*) C IWRITE=0 IF (iwrite.eq.1) THEN IF (L.eq.11) then Write(30,*)"McCarl's carbon price and sequester pathways" Write(30,*)"Price,Biofuel,Agsoil,Affor,Total" DO IP=1,401 write(30,"(5(g12.6,','))") EmSeqP(L,IP), & (EmSeq(L,IP,IQ),IQ=1,4) END DO Endif END IF END IF !end of the if m.eq.nm END DO !end of the regional do loop END DO !end of period loop (0:nm) C*********************************************************** C GLOBAL RESULTS C*********************************************************** C . Write out totals for multi-region results.

Page 139: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

139

IF (NL.GT.1) THEN WRITE(30,*) WRITE(30,*)'********* GLOBAL TOTALS *********' C . . Date and Time WRITE (30, 900) tmpmonth, tmpday, tmpyear,tmphour,tmpminute, & tmpsecond,tmphund,mer WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'GHG Emissions (TgC Equivalent)' WRITE(30,*)'Year,CO2,CH4,N20,HFCs,PFCs,SF6,ODSsub' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,103)IYR,(EMGASG(JGAS,MPER),JGAS=1,7) END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Carbon Dioxide Emissions by Source (TgC)' WRITE(30,*)'Year' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,101)IYR, (EM(IX,0,MPER), IX=1,NSOURCE(L)) END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Emissions of all Gases (MMT of gas)' WRITE(30,*)'Year,CO2,CH4,N20,HFCs,PFCs,SF6,CO,NOX,SOX,VOC,PM10' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,102)IYR END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'CO2 Emissions From Energy Cons. by Sector (MMTC)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200)IYR,(SECEMS(IS,MPER),IS = 1,NIO), & (SECEMS(IS,MPER),IS = NIS-1,NIS) END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Global Nominal GNP Components (Million US$)' WRITE(30,*)'Year,Nom. Cons,Nom. Inv.,Nom. Govt,Nom. TB,', & 'Nom. GNP' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',5(F12.0,','),F7.2,',')")IYR, & CONS(0,MPER),KTOT(0,MPER),GOVMT(0,MPER),EXIM(0,MPER), & GNP(0,MPER) END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Global Real GNP Components (Base year Million US$)' WRITE(30,*)'Year,Real Cons,Real Inv.,Real Govt,Real TB,', & 'Real GNP' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',5(F12.0,','),F7.2,',')")IYR, & RCONS(0,MPER),RINVST(0,MPER),RGOVT(0,MPER), & RTRD(0,MPER),RGNP(0,MPER) END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Global Primary Energy Consumption (in EJ)' WRITE(30,*)'Year,C.Oil,N.Gas,Coal,Bio,Uran,Hydro,Renew,Total' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,200) IYR,(PRI(I,0,MPER),I=1,6), & 0.0,(TOTPRI(0,MPER)) END DO WRITE(30,*) WRITE(30,*)'Global Total'

Page 140: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

140

WRITE(30,*)'Fossil Fuel Energy Consumption by Sector (in EJ)' WRITE(30,450) 'Year',(SECNAME(IO,L),IO=1,NIO),'Govt','HHold' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,*)IYR END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Global Primary Energy Production (in EJ)' WRITE(30,*)'Year,C.Oil,N.Gas,Coal,Uran,Hydro,Renew,Total' DO MPER = 0,NM IYR = BASEYR + MPER * 5 PRTOTAL=0.0 PRTOTAL= & TOTPRD(3,0,MPER)+ & TOTPRD(4,0,MPER)+ & TOTPRD(5,0,MPER)+ & TOTPRD(7,0,MPER)+ & WPEPRD(1,MPER)+WPEPRD(2,MPER) WRITE(30,200)IYR, & TOTPRD(3,0,MPER), & TOTPRD(4,0,MPER), & TOTPRD(5,0,MPER), & TOTPRD(7,0,MPER), & WPEPRD(1,MPER),WPEPRD(2,MPER), & PRTOTAL END DO WRITE(30,*) WRITE(30,*)'Global Total' WRITE(30,*)'Global Demographics (1000s)' WRITE(30,*)'Year,Tot.Pop,WAGE-M,WAGE-F,', & 'WAGE-Tot.,Employed' DO MPER = 0,NM IYR = BASEYR + MPER * 5 WRITE(30,"(I5,',',5(F13.0,','))")IYR,POPLM(0,MPER), & WAGE(1,0,MPER), WAGE(2,0,MPER), & WAGE(1,0,MPER)+WAGE(2,0,MPER), & EMPLOY(0,MPER) END DO END IF C WRITE LIST OF INPUT FILES WRITE(30,*) WRITE(30,*) WRITE(30,480)CASENAME WRITE(30,480)CASENOTE DO IFILE=1,INFILES WRITE(30,480)FILES(IFILE) END DO C DO MPER=0,NM IYR = BASEYR + MPER * 5 WRITE(30,*) '---------------------------' WRITE(30,*) 'PERIOD ',MPER WRITE(30,*) '---------------------------' WRITE(30,*) WRITE(30,*) 'Units for all tables are 1990 Million Currency ' WRITE(30,*) WRITE(30,*) 'I-O Table Region:',L WRITE(30,450) ' ',(SECNAME(IO,L),IO=1,NIO),'Carbon', & 'Trade','Invest','Govt','HHold' DO IN=1,NIO WRITE(30,1004) SECNAME(IN,L), & (BAL2(IN,IS,L,MPER)/PRCONVRT(IN,L),IS=1,NIS) END DO DO IN=23,27 WRITE(30,1004) SECNAME(IN,L), & (ED(in,io,l,mper),io=1,27) enddo END DO RETURN END

Page 141: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

141

C**********************************************************************

SUBROUTINE POSTINI C POSTINI is a subroutine which initizes variables for the next period C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' INCLUDE 'DB_DATA.BLK' C . Local Variables REAL*8 RBASEADD,TMP1 ! growth in resources INTEGER NVINI REAL*8 COSTK(NIOP,20,-3:NMP,NLP),ALPHA(0:NINP),BETA(0:NINP) C ++++++ Local variables for fixed-coefficient technologies REAL*8 LEON1(0:NINP,NDEFP,IVIN0P:NMP,NLP) C ++++++ End of new local variables C New code for inclusion of short-term elasticities of technical C substitution. This code should come before anything else in the C POSTINI subroutine. C At the end of each model period, technical coefficients are converted C from the original long-term elasticity of substitution to a short- C term elasticity. This means that after the first period of operation, C capital stocks are locked into a lower elasticity. C Change tech coefficients for current period only, unless we are C still in the calibration period (period 0). Then all vintages C will be adjusted. ISTART = M IF(M .EQ. 0) ISTART = -3 C Code to turn off short-run elasticities c ISTART = 13 DO LL = 1, NL L = MRKDEF(0,3+LL) C Restore alpha0 parameters from A0SAVE array. This is needed C to avoid conflicts with the A0ADJ subroutine. C These parameters are originally set in the TECH subroutine, C which is called once before period 0. DO IVIN = ISTART,M C First obtain implicit cost of capital. This is not the interest C rate in the SGM, but is equal to Other Value Added (profits) divided by C capital stock. Each vintage will have its own implicit cost of capital. DO IO=1,NIO DO ISS=1,NISS(IO,L) IF(KA(ISS,IO,IVIN,L) .GT. 1.0) THEN COSTK(IO,ISS,IVIN,L) = PROFITS(IO,ISS,IVIN,L)/ & KA(ISS,IO,IVIN,L) ELSE COSTK(IO,ISS,IVIN,L) = 0.0 END IF END DO END DO C Copy alpha coefficients into ALPHA(...) DO IO=1,NIO DO ISS=1,NISS(IO,L) IF(COSTK(IO,ISS,IVIN,L) .GT. 0.0001D0) THEN DO IN=0,NIN+1 ALPHA(IN) = A(IN,IDEF(IO,ISS,L),IVIN,L) END DO RHO1 = ALPHA(NIN+1) RHO2 = RHOST(IDEF(IO,ISS,L),L) EXPA0 = (RHO1/RHO2)*(1.D0 - RHO2)/(1.0D0 - RHO1) EXPAI = (1.0D0 - RHO2)/(1.0D0 - RHO1) EXPP = (RHO1 - RHO2)/(1.0D0 - RHO1) BETA(0) = ALPHA(0)**EXPA0 PSUBJ = PRCV(IO,L,M) DO IN=1,NIN-1 PSUBI = PI(IN,IDEFS(IO,ISS,L),L,IVIN,1)

Page 142: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

142

IF(PSUBI .GT. 0.0) THEN BETA(IN) = ALPHA(IN)**EXPAI * (PSUBJ/PSUBI)**EXPP ELSE BETA(IN) = 0.0 END IF END DO PSUBI = COSTK(IO,ISS,IVIN,L) BETA(NIN) = ALPHA(NIN)**EXPAI * (PSUBJ/PSUBI)**EXPP C ++++++ New code for fixed-coefficient technologies EXPA0 = RHO1/(1.0D0 - RHO1) EXPAI = 1.0D0/(1.0D0 - RHO1) EXPP = EXPAI LEON1(0,IDEF(IO,ISS,L),IVIN,L) = 1.0d0 DO IN=1,NIN-1 PSUBI = PI(IN,IDEFS(IO,ISS,L),L,IVIN,1) IF(PSUBI .GT. 0.0) THEN LEON1(IN,IDEF(IO,ISS,L),IVIN,L) = ALPHA(0)**EXPA0 * 1 ALPHA(IN)**EXPAI * (PSUBJ/PSUBI)**EXPP ELSE LEON1(IN,IDEF(IO,ISS,L),IVIN,L) = 0.0 END IF END DO PSUBI = COSTK(IO,ISS,IVIN,L) LEON1(NIN,IDEF(IO,ISS,L),IVIN,L) = ALPHA(0)**EXPA0 * 1 ALPHA(NIN)**EXPAI * (PSUBJ/PSUBI)**EXPP C Overwrite global array of Leontief coefficients. C Do this only if this sector began with CES coefficients. IF(SIGMA1(IDEF(IO,ISS,L),L) .GE. 0.05D0) THEN DO IN=0,NIN LEON(IN,IDEF(IO,ISS,L),IVIN,L) = & LEON1(IN,IDEF(IO,ISS,L),IVIN,L) END DO END IF C ++++++ End of new code segment C Overwrite old alpha coefficients, replace rho DO IN=0,NIN A(IN,IDEF(IO,ISS,L),IVIN,L) = BETA(IN) END DO A(NIN+1,IDEF(IO,ISS,L),IVIN,L) = RHO2 C Create transformed alpha coefficients. SIG = 1.D0 / (1.D0 - RHO2) ACST(0,IDEF(IO,ISS,L),IVIN,L) = & A(0,IDEF(IO,ISS,L),IVIN,L)**(SIG*RHO2) DO IN=1,NIN ACST(IN,IDEF(IO,ISS,L),IVIN,L) = & A(IN,IDEF(IO,ISS,L),IVIN,L)**SIG END DO ACST(NIN+1,IDEF(IO,ISS,L),IVIN,L) = - RHO2 * SIG END IF END DO ! end ISS loop END DO ! end IO loop END DO ! end IVIN loop C Update A0SAVE array. We need to store the alpha0 parameters C because they may be modified by A0ADJ. DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IVIN= NVIN0,NM A0SAVE(ISS,IO,IVIN,L) = A(0,IDEF(IO,ISS,L),IVIN,L) END DO END DO END DO C Store price paid (by electricity sector) for reporting. DO IN=1,NIN PPDELEC(IN,L,M) = PI(IN,IDEFS(8,1,L),L,M,1) END DO END DO ! end of LL loop C End of code for short-term elasticities. KAPrior = 0 DO LL = 1, NL L = MRKDEF(0,3+LL) WAGE(3,L,M) = SALES(1,NIN-1,L,M) WAGE(4,L,M) = GNP(L,M) / WAGE(3,L,M) DO IO = 1, NIO DO ISS = 1,NISS(IO,L)

Page 143: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

143

C . . . . . . Compute adder for growth in resource base. RBASEADD = DRSCE0(IO,ISS,L) * & ((1.0+RESGRO(IO,ISS,L,M))**(M*NSTEP) & - (1.0+RESGRO(IO,ISS,L,M))**((M-1)*NSTEP)) DRSCE(IO,ISS,L) = DRSCTMP(IO,ISS,L) + RBASEADD IF (DRSCE(IO,ISS,L).LT.0) DRSCE(IO,ISS,L) = 0.0 RESC(IO,ISS,L,M) = DRSCE(IO,ISS,L) !moved from outexcel IF (M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M).GT.-3) THEN NVINI = M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M) ELSE NVINI = -3 END IF DO IVIN = NVINI,M DRSVE(IO,ISS,IVIN,L) = DRSVTMP(IO,ISS,IVIN,L) KAPRIOR(ISS,IO,IVIN,L) = KA(ISS,IO,IVIN,L) DO IRF = 1,NRF(ISS,IO,IVIN,L) KCPRIOR(IRF,IDEF(IO,ISS,L),IVIN,L) = & KC(IRF,IDEF(IO,ISS,L),IVIN,L) END DO END DO END DO END DO END DO C Excursion for FSU economic collapse after 1990. C This code throws away some of the capital stock at the C end of period 1. DO LL = 1, NL L = MRKDEF(0,3+LL) IF(M.EQ.0 .AND. L.EQ.4) THEN DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IVIN = NVIN0,M KAPRIOR(ISS,IO,IVIN,L) = 0.53*KAPRIOR(ISS,IO,IVIN,L) KAFLOW(ISS,IO,IVIN,L) = 0.53*KAFLOW(ISS,IO,IVIN,L) END DO END DO END DO ELSE IF(M.EQ.1 .AND. L.EQ.4) THEN DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IVIN = NVIN0,M KAPRIOR(ISS,IO,IVIN,L) = 0.70*KAPRIOR(ISS,IO,IVIN,L) KAFLOW(ISS,IO,IVIN,L) = 0.70*KAFLOW(ISS,IO,IVIN,L) END DO END DO END DO ELSE IF(M.EQ.0 .AND. L.EQ.13) THEN DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IVIN = NVIN0,M KAPRIOR(ISS,IO,IVIN,L) = 0.5*KAPRIOR(ISS,IO,IVIN,L) KAFLOW(ISS,IO,IVIN,L) = 0.5*KAFLOW(ISS,IO,IVIN,L) END DO END DO END DO END IF END DO C . . Save this period's resource investment and depletion flows C . . as the next period's previous flows for the 5-yr interpolation DO LL = 1, NL L = MRKDEF(0,3+LL) DO IO = 1, NIO DO ISS = 1, NISS(IO,L) EQDEPPRE(IO,ISS,L) = EQDEP(IO,ISS,L) IF (M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M).GT.-3) THEN NVINI = M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M) ELSE NVINI = -3 END IF DO IVIN = NVINI,M PRDVNPRE(IO,ISS,IVIN,L) = PRDVIN(IO,ISS,IVIN,L) END DO END DO END DO END DO C . Compute world population by gender and age group POPM(M) = 0.

Page 144: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

144

DO NG=1,2 DO NA=1,NAGE DO LL=1,NL L = MRKDEF(0,3+LL) POPM(M) = POPM(M) + POPLM(L,M) POPGCM(NG,NA,M) = POPGCM(NG,NA,M) + POPGCLM(NG,NA,L,M) END DO POPGM(NG,M) = POPGM(NG,M) + POPGCM(NG,NA,M) END DO END DO C . Update starting prices for the next period. This overides C . the prices read in in SGMDAT1.FOR. IPFIX allows selective use C . of override for case where market price is given. This is use C . where imports supply gap at fixed price. eg. where there is a world C . price for oil. IPFIX = .true. is to use read in value. IF (M .LT. NM) THEN IF (READINPRICE .EQ. 'NO') THEN DO LL=1,NL L = MRKDEF(0,3+LL) DO IN = 1,NIN IF (.NOT. IPFIX(IN,L,M+1)) THEN P(IN,L,M+1) = P(IN,L,M) END IF END DO END DO END IF END IF C Copy trade values into the trade sector of the ED array. DO LL=1,NL L = MRKDEF(0,3+LL) DO IN=1,NIN-1 IF(MKTLINK(IN,L) .EQ. 1) THEN ED(IN,NIS-3,L,M) = TRADE(1,IN,L,M) END IF END DO END DO C Sum production by vintage into ROUT TMP1 = 0.0 DO LL = 1,NL L = MRKDEF(0,3+LL) DO IN = NIN-3, NIN PRCONVRT(IN,L) = 1 END DO C . .Total production by sector. DO IO = 1,NIO TOTPRD(IO,L,M) = 0.0 DO ISS = 1,NISS(IO,L) ROUT(IO,ISS,L,M) = 0.0 VOUT(IO,ISS,L,M) = 0.0 RESV(IO,ISS,L,M) = 0.0 IF (M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M).GT.-3) THEN NVINI = M+1-NTECHCHAR(3,IDEF(IO,ISS,L),L,M) ELSE NVINI = -3 END IF DO IVIN = NVINI,M TMP1 = TMP1 + KAPRIOR(ISS,IO,IVIN,L) ROUT(IO,ISS,L,M) = ROUT(IO,ISS,L,M) & + PRDVIN(IO,ISS,IVIN,L) VOUT(IO,ISS,L,M) = VOUT(IO,ISS,L,M) & + PRDVIN(IO,ISS,IVIN,L) & * P(IO,L,M) RESV(IO,ISS,L,M) = RESV(IO,ISS,L,M) & + DRSVE(IO,ISS,IVIN,L) END DO TOTPRD(IO,L,M) = TOTPRD(IO,L,M) & + ROUT(IO,ISS,L,M) * PRCONVRT(IO,L) END DO END DO KWORK(L,M) = TMP1 / SALES(1,NIN-1,L,M) END DO RTEST1 = CRESERV(M,5) RTEST2 = PRDVIN(5,1,M,L) RTEST3 = 1.0d0 C Store data for use by DBOUT2K. These data are used for the EPA model linkage C activity.

Page 145: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

145

C Marginal (for new capital only) cost of capital DO IO=1,NIO DO ISS=1,NISS(IO,L) COSTK_STORE(IO,ISS,M) = COSTK(IO,ISS,M,L) END DO END DO C Capital stock by production sector (electricity disaggregated) DO IO=1,NIO DO ISS=1,NISS(IO,L) KA_STORE(ISS,IO,M) = 0.0d0 DO IVIN=M-3,M KA_STORE(ISS,IO,M) = KA_STORE(ISS,IO,M) + KA(ISS,IO,IVIN,L) END DO END DO END DO C Profits time series by production sector (electricity disaggregated) DO IO=1,NIO DO ISS=1,NISS(IO,L) PROFITS_STORE(IO,ISS,M) = 0.0d0 DO IVIN=M-3,M PROFITS_STORE(IO,ISS,M) = PROFITS_STORE(IO,ISS,M) + & PROFITS(IO,ISS,IVIN,L) END DO END DO END DO C Store values of inputs by production sector DO IO=1,NIS DO IN=1,NIN IOVAL_STORE(IO,IN,M) = 0.0d0 DO ISS=1,NISS(IO,L) DO IVIN=M-3,M IOVAL_STORE(IO,IN,M) = IOVAL_STORE(IO,IN,M) + & COST(IN,IDEFS(IO,ISS,L),IVIN,L) END DO END DO END DO END DO C Store profits (electricity aggregated) into IOVAL_STORE array. DO IO=1,NIO IN=NIN IOVAL_STORE(IO,IN,M) = 0.0d0 DO ISS=1,NISS(IO,L) DO IVIN=M-3,M IOVAL_STORE(IO,IN,M) = IOVAL_STORE(IO,IN,M) + & PROFITS(IO,ISS,IVIN,L) END DO END DO END DO RETURN END

Page 146: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

146

C**********************************************************************

SUBROUTINE POSTPER C POSTPER is a subroutine which writes the values of output variables C from the GPCM to a data file for testing purposes. C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' C . Local Variables REAL*8 NET(NINP,NLP), ! total cost of input by sector & TMP(100,30), ! temp variable used by TABLE & KTOTAL(NLP), ! Total investment & TCOST(NISSP), ! Cost by Vintage & tcap(nlp), ! Total Capital in Use & TCON1(NINP,NLP,0:NMP), ! Total consumption by industry & TRD1(NINP,NLP,0:NMP), ! trade & REV(NINP,NLP), ! revenue by sector & totacc(6), ! industry accounts data & totfac(4,NLP), ! factor payments & KAAGE(NIOP,NLP,2), ! average age of capital by sector & TCAPW(NLP), ! Average age of capital stock & REG(NLP), ! Stores active region numbers & PERINC(NLP), ! Stores personal income & HHWAGES(NLP), ! Stores HH wages & PERCAPK(NLP), ! Stores per capita income in thousands & PEREMP(NLP) ! Percent employed CHARACTER SEX(2)*8 ! gender titles INTEGER*2 IHR,IMIN,ISEC,I100TH ! Time variables INTEGER*2 IYR, IMON, IDAY ! Date Variables INTEGER MINVIN(NIOP,NLP) ! Maximum Lifetime of any subsetor C . .Date and Time for DEC INTEGER(2) tmpday, tmpmonth, tmpyear INTEGER(2) tmphour, tmpminute, tmpsecond, tmphund CHARACTER(1) mer logical print print = .false. C Find date and time CALL GETDAT(tmpyear, tmpmonth, tmpday) CALL GETTIM(tmphour, tmpminute, tmpsecond, tmphund) IF (tmphour .GT. 12) THEN mer = 'p' tmphour = tmphour - 12 ELSE mer = 'a' END IF 900 FORMAT(I2, '/', I2.2, '/', I4.4,', ',I2, ':', I2.2, & ':', I2.2, ':', I2.2, ' ',A, 'm') DO LL = 1, NL L = MRKDEF(0,3+LL) TCAP(L) = 0.0 TCAPW(L) = 0.0 DO IO = 1, NIO KAAGE(IO,L,1) = 0.0 KAAGE(IO,L,2) = 0.0 DO ISS = 1,NISS(IO,L) DO IVIN = NVIN0,M AGE = (5. * (M - IVIN)) + 2.5 KAAGE(IO,L,1) = KAAGE(IO,L,1) + AGE & * KA(ISS,IO,IVIN,L) KAAGE(IO,L,2) = KAAGE(IO,L,2) + KA(ISS,IO,IVIN,L) TCAP(L) = TCAP(L) + KA(ISS,IO,IVIN,L) TCAPW(L) = TCAPW(L) + AGE * KA(ISS,IO,IVIN,L) END DO END DO if(kaage(io,l,2) .gt. 0.0) then KAAGE(IO,L,1) = KAAGE(IO,L,1) / KAAGE(IO,L,2) end if END DO

Page 147: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

147

if(tcap(l) .gt. 0.0) then TCAPW(L) = TCAPW(L) / TCAP(L) end if END DO C . Compute maximum lifetime of any subsector within a sector DO LL = 1, NL L = MRKDEF(0,3+LL) DO IO = 1, NIO MINVIN(IO,L) = M DO MK = NVIN0,M DO ISS = 1, NISS(IO,L) IF ((M-MK).LT.NTECHCHAR(3,IDEF(IO,ISS,L),L,MK)) THEN IF (MINVIN(IO,L).GT.MK) THEN MINVIN(IO,L) = MK END IF END IF END DO END DO END DO END DO C . Microsoft uses this format for the date and time call. C . . Date and Time WRITE (11,*) WRITE (11, 900) tmpmonth, tmpday, tmpyear,tmphour,tmpminute, & tmpsecond,tmphund,mer 998 FORMAT(1(A28,','),',',',',1(I2,',')) 999 FORMAT(1(A19,','),',',',',1(I2,',')) 1000 FORMAT(1(I5,','),1(A21,',')) 1001 FORMAT(1(I5,','),1(F15.0,','),1(A18,',')) 1002 FORMAT(10(A10,',')) 1003 FORMAT(3(I5,','),10(F15.0,',')) 1004 FORMAT(1(I5,','),10(F15.0,',')) 1005 FORMAT(1(A10,','),',',',',10(F15.0,',')) 1006 FORMAT(1(A8,','),20(I5,',')) 1007 FORMAT(1(I5,','),10(F15.0,',')) 1008 FORMAT(1(I5,','),1(A10,','),30(F15.0,',')) 1009 FORMAT(15(A10,',')) 1010 FORMAT(1(A10,','),15(F10.0,',')) 1011 FORMAT(3(I5,','),15(A10,',')) 1012 FORMAT(1(I5,','),15(F10.0,',')) 1013 FORMAT(30(A10,',')) 1014 FORMAT(1(F15.0,','),1(A21,',')) 1015 FORMAT(2(I5,','),20(F10.0,',')) 1016 FORMAT(1(F10.0,','),1(A30,',')) 1017 FORMAT(1(F12.0,','),1(A8,',')) 1018 FORMAT(20(I5,',')) 1019 FORMAT(2(A10,','),20(I5,',')) 1020 FORMAT(2(I5,','),15(F10.0,',')) 1021 FORMAT(1(I5,','),1(F15.0,','),1(A30,',')) 1022 FORMAT(2(I5,','),1(A10,','),15(F10.2,',')) 1999 FORMAT(1(I5,','),30(F10.4,',')) 877 FORMAT(20(F10.5,1h,)) c Save data for database output vindatasave(1,:,:,:,:,M) = PRDVIN vindatasave(2,:,:,:,:,M) = PROFITS WRITE(11,*) WRITE(11,*) '**********************' WRITE(11,999) 'RESULTS FOR PERIOD ',M WRITE(11,*) '**********************' C . Solution Algorithm Results WRITE(11,1014)SSQED,'Criterion Function' WRITE(11,1014)SUMED,'Sum Excess Demand' WRITE(11,1000)NL,'No. of Regions' WRITE(11,1000)ISOL,'No. Unsolved Markets' WRITE(11,1000)MODL,'No. Model Evaluations' WRITE(11,1000)IREP,'No. of Iterations' WRITE(11,*) WRITE(11,1002)'Region','Market','Commodity','Price', & 'ED','Production','Demand' DO MRK = 1,NMRK INN = MRKDEF(MRK,2) L = MRKDEF(MRK,4)

Page 148: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

148

TEMP = MRKPRD(MRK) + MRKED(MRK) WRITE(11,1003)L,MRK,INN, & P(INN,L,M),MRKED(MRK),MRKPRD(MRK),TEMP END DO C . Write out aggregate gnp and components. WRITE(11,*) WRITE(11,1002)'Region','GNP','Consumption', & 'Government','Investment','Trade Bal.' DO LL = 1, NL L = MRKDEF(0,3+LL) write(11,1004)L,GNP(L,M), & CONS(L,M),GOVMT(L,M),KTOT(L,M),EXIM(L,M) END DO C . Break out demands by Intermeadiate output, consumption, investment, C . government, and inport/export DO LL = 1,NL L = MRKDEF(0,3+LL) WRITE(11,*) WRITE(11,*)'Demand Components' WRITE(11,*) WRITE(11,1002)'Region','Industry','Total','Intermed.', & 'Consumpt.','Investment','Government','Trade' DO IN = 1,NIN MRK = ISECDF(IN,L) TDMND = MRKPRD(MRK) + MRKED(MRK) DIOT = 0. DO IO = 1,NIO DIOT = DIOT + ED(IN,IO,L,M) END DO C . . . Output has been subtracted from own sector demand so add it C . . . back in(Only for production sectors). C . . . First do the hhold sector which supplies land, labor, and capital. C . . . Then do the production sectors. IF (IN .GT. NIO) THEN TCONT = SALES(1,IN,L,M) + ED(IN,NIS,L,M) ELSE TCONT = ED(IN,NIS,L,M) DIOT = DIOT + MRKPRD(MRK) END IF WRITE(11,1008)L,SECNAME(IN,L),TDMND,DIOT,TCONT, & ED(IN,NIS-2,L,M),ED(IN,NIS-1,L,M),ED(IN,NIS-3,L,M) DIO(IN,L,M) = DIOT TCON(IN,L,M) = TCONT TRD(IN,L,M) = ED(IN,NIS-3,L,M) TCON1(IN,L,M) = TCONT TRD1(IN,L,M) = ED(IN,NIS-3,L,M) END DO END DO C . GNP and its major components are calculated at base year prices. WRITE(11,*) WRITE(11,*)'Output at Base Year Prices' WRITE(11,1002)'Region','Consumpt.','Investment','Government', & 'Trade','GNP','GNP/Worker' DO LL = 1,NL L = MRKDEF(0,3+LL) RCONS(L,M) = 0.0 RGOVT(L,M) = 0.0 RTRD(L,M) = 0.0 DO IN = 1,NIO RCONS(L,M) = RCONS(L,M) + TCON1(IN,L,M) RGOVT(L,M) = RGOVT(L,M) + ED(IN,NIS-1,L,M) IF(TRD1(IN,L,M) .GT. 0.0) THEN RTRD(L,M) = RTRD(L,M) + TRD1(IN,L,M) * P(IN,L,0) ELSE RTRD(L,M) = RTRD(L,M) + TRD1(IN,L,M) & * PI(IN,IDEFS(NIS,1,L),L,0,2) END IF END DO RCONS(L,M) = RCONS(L,M) + TCON1(NIN-1,L,M) * & PI(NIN-1,IDEFS(NIS,1,L),L,0,2) RGOVT(L,M) = RGOVT(L,M) + ED(NIN-2,NIS-1,L,M) * & PI(NIN-2,IDEFS(NIS,1,L),L,0,2) RGOVT(L,M) = RGOVT(L,M) + ED(NIN-1,NIS-1,L,M) * & PI(NIN-1,IDEFS(NIS,1,L),L,0,2) RTRD(L,M) = RTRD(L,M) + TRD1(NIN,L,M) RINVST(L,M) = ED(NIN,NIS-2,L,M)

Page 149: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

149

RGNP(L,M) = RCONS(L,M) + RINVST(L,M) + & RGOVT(L,M) + RTRD(L,M) RGNPW(L,M) = RGNP(L,M) / SALES(1,NIN-1,L,M) WRITE(11,1007)L,RCONS(L,M),RINVST(L,M),RGOVT(L,M), & RTRD(L,M),RGNP(L,M),RGNPW(L,M) END DO C . Print out sector specific results. C . First compute total cost of input by sector. DO LL = 1,NL L = MRKDEF(0,3+LL) DO IO = 1, NIO NET(IO,L) = 0.0 DO IN = 1,NIN-1 DO ISS = 1,NISS(IO,L) DO IVIN = NVIN0,M NET(IO,L) = NET(IO,L) & + COST(IN,IDEFS(IO,ISS,L),IVIN,L) END DO END DO END DO END DO END DO C . Now generate total investment DO LL = 1,NL L = MRKDEF(0,3+LL) KTOTAL(L) = 0.0 DO IO = 1,NIO K(IO,L,M) = 0.0 DO ISS = 1,NISS(IO,L) K(IO,L,M) = K(IO,L,M) + KAFLOW(ISS,IO,M,L) END DO KTOTAL(L) = KTOTAL(L) + K(IO,L,M) END DO END DO C . Now print investment, output from each vintage of capital, and inputs C . from each sector. WRITE(11,*) IVIN = M DO LL = 1,NL L = MRKDEF(0,3+LL) DO IO = 1,NIO WRITE(11,*)'-----------------------------' WRITE(11,*)'Production Sector' WRITE(11,'(A20)') SECNAME(IO,L) WRITE(11,*)'-----------------------------' WRITE(11,*) WRITE(11,1002) 'Region','Sector','Subsectors' DO ISS = 1, NISS(IO,L) WRITE(11,1011) L,IO,ISS,TECHNAME(IO,ISS,L) END DO WRITE(11,*) WRITE(11,1002)'Region','Sector','Sec. Inv.' WRITE(11,1020) L,IO,K(IO,L,M) WRITE(11,*) WRITE(11,*)'Subsector Investment Determinants' WRITE(11,1009)'Region','Sector','Subsector', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)) WRITE(11,1022)L,IO,'Curr EXPR', & (DEXPPROF(ISS,IO,L,M), ISS=1,NISS(IO,L)) WRITE(11,1022)L,IO,'Prev EXPR', & (DEXPPROF(ISS,IO,L,M-1),ISS=1,NISS(IO,L)) WRITE(11,1022)L,IO,'Prev KAFLOW.', & (KAFLOW(ISS,IO,M-1,L), ISS=1,NISS(IO,L)) WRITE(11,1022)L,IO,'KDEM m-1', & (KDEM(ISS,IO,M-1,L), ISS=1,NISS(IO,L)) WRITE(11,1022)L,IO,'KDEM m-2', & (KDEM(ISS,IO,M-2,L), ISS=1,NISS(IO,L)) WRITE(11,1022)L,IO,'Investmnt', & (KAFLOW(ISS,IO,M,L), ISS=1,NISS(IO,L)) write(11,*) write(11,*)'Output by Subsector and Vintage' WRITE(11,1009)'Region','Sector','Vintage', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L))

Page 150: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

150

DO IVIN = MINVIN(IO,L),M WRITE(11,1003) L,IO,IVIN, & (PRDVIN(IO,ISS,IVIN,L), ISS=1,NISS(IO,L)) END DO write(11,*) write(11,*)'Capital by Subsector and Vintage' WRITE(11,1009)'Region','Sector','Vintage', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)) DO IVIN = MINVIN(IO,L),M WRITE(11,1003) L,IO,IVIN, & (KAPRIOR(ISS,IO,IVIN,L),ISS=1,NISS(IO,L)) END DO write(11,*) write(11,*)'Profits by Subsector and Vintage' WRITE(11,1009)'Region','Sector','Vintage', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)) DO IVIN = MINVIN(IO,L),M WRITE(11,1003) L,IO,IVIN, & (PROFITS(IO,ISS,IVIN,L), ISS=1,NISS(IO,L)) END DO write(11,*) write(11,*)'Cost of Inputs by Subsector and Vintage' WRITE(11,1009)'Region','Sector','Vintage', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)) DO IVIN = MINVIN(IO,L),M DO ISS = 1,NISS(IO,L) TCOST(ISS) = 0.0 DO IK = 1,NIN TCOST(ISS) = TCOST(ISS) & + COST(IK,IDEFS(IO,ISS,L),IVIN,L) END DO END DO WRITE(11,1003) L,IO,IVIN, & (TCOST(ISS), ISS=1,NISS(IO,L)) END DO write(11,*) IF (NRSCHAR(1,IO,L) .GE. 1) THEN WRITE(11,*)'Reserves by Subsector (Grade)' WRITE(11,1009)'Region','Sector','Vintage', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)) DO IVIN = MINVIN(IO,L),M WRITE(11,1003) L,IO,IVIN, & (DRSVE(IO,ISS,IVIN,L),ISS=1,NISS(IO,L)) END DO IVIN = M !Reinitialize IVIN WRITE(11,*)'Resources by Subsector (Grade)' WRITE(11,1009)'Region','Sector','Vintage', & (TECHNAME(IO,ISS,L),ISS=1,NISS(IO,L)) WRITE(11,1003) L,IO,IVIN, & (DRSCE(IO,ISS,L),ISS=1,NISS(IO,L)) write(11,*) END IF write(11,*)'Costs Incurred by Sector' write(11,1002)'Region','Sector','Inputs','Price Paid', & 'Total Cost' DO IN = 1,NIN costin = 0.0 do iss = 1, niss(io,l) do ivin = nvin0,m costin = costin + cost(in,IDEFS(IO,ISS,L),ivin,l) end do end do C . . . . Pibar has the average cost across subsectors of an input. if (in .eq. io) then demand = ed(in,io,l,m) + mrkprd(isecdf(in,l)) if (demand .gt. 0.0) then pibar = costin / demand else pibar = 0.0 end if write(11,1020)L,in, & demand,pibar,costin else if (ed(in,io,l,m) .gt. 0.0) then pibar = costin / ed(in,io,l,m) else pibar = 0.0

Page 151: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

151

end if write(11,1020)L,in, & ed(in,io,l,m),pibar,costin end if end do WRITE(11,1008)L,'Total Cost',NET(IO,L) write(11,*) write(11,*)'Revenue for Sector' write(11,1002)'Region','Sector','Deliveries','Price Recd', & 'Revenue' totrev = 0.0 do ik = 1,nis if (ik .eq. io) then demand = ed(ik,io,l,m) + mrkprd(isecdf(ik,l)) revenue = demand * p(io,l,m) totrev = totrev + revenue write(11,1020)L,ik,demand,p(io,l,m),revenue else revenue = ed(io,ik,l,m) * p(io,l,m) totrev = totrev + revenue write(11,1020)L,ik,ed(io,ik,l,m),p(io,l,m),revenue end if end do REV(IO,L) = totrev WRITE(11,1008)L,'Total Rev',totrev end do end do write(11,*) WRITE(11,*)'-----------------------------' WRITE(11,*)'End of Sector Detail' WRITE(11,*)'-----------------------------' WRITE(11,*) C *********************** C end of Sector Loop C *********************** C . Develop and print out total factor payments for the production C . sector. 1 = wages, 2 = rents, 3 = profits, 4 = taxes write(11,*)'Total Industry Factor Payments' write(11,*) DO LL = 1, NL L = MRKDEF(0,3+LL) reg(ll)=MRKDEF(0,3+LL) do ik = 1,4 totfac(ik,l) = 0.0 end do do io = 1,nio do iss = 1,niss(io,l) do ivin = nvin0,m totfac(1,l) = totfac(1,l)+cost(nin-1,IDEFS(IO,ISS,L),ivin,l) totfac(2,l) = totfac(2,l)+cost(nin-2,IDEFS(IO,ISS,L),ivin,l) totfac(3,l) = totfac(3,l)+profits(io,iss,ivin,L) end do end do do ik = 1,5 totfac(4,l) = totfac(4,l) + tax(ik,io,l) end do totfac(4,l) = totfac(4,l) + (-1.0 * xitc(io,l)) end do END DO write(11,1006)'Regions',(MRKDEF(0,3+LL),LL=1,NL) write(11,1010)'Wages',(totfac(1,reg(l)),l=1,nl) write(11,1010)'Rents',(totfac(2,reg(l)),l=1,nl) write(11,1010)'Profits',(totfac(3,reg(l)),l=1,nl) write(11,1010)'Taxes',(totfac(4,reg(l)),l=1,nl) C . Print sector excess demands WRITE(11,*) WRITE(11,*)'Sector Excess Demands' DO LL = 1,NL L = MRKDEF(0,3+LL) WRITE(11,*) WRITE(11,1013)'Region',' ',(SECNAME(IO,L),IO=1,NIS) DO IN = 1,NIN WRITE(11,1008)L,SECNAME(IN,L),(ED(IN,IO,L,M),IO=1,NIS) END DO END DO

Page 152: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

152

C . Print out sector results, Total output including own consumption, C . Sales including own consumption, Profits, Retained Earnings, C . and Sales Less Costs. WRITE(11,*) write(11,*)'Sector Results' WRITE(11,1002)'Region','Sector','Phys. Out.','Sales', & 'Revenue','Profits','Ret. Earn.','Costs' DO LL = 1,NL L = MRKDEF(0,3+LL) do ik = 1,6 totacc(ik) = 0.0 end do DO IO = 1,NIO totacc(1) = totacc(1) + sales(1,io,l,m) totacc(2) = totacc(2) + sales(2,io,l,m) totacc(3) = totacc(3) + rev(io,l) totacc(4) = totacc(4) + prof(io,l) totacc(5) = totacc(5) + rete(io,l) totacc(6) = totacc(6) + net(io,l) WRITE(11,1008)L,SECNAME(IO,L),SALES(1,IO,L,M), & SALES(2,IO,L,M),REV(IO,L),PROF(IO,L),RETE(IO,L),NET(IO,L) END DO write(11,1008)L,'Totals',(totacc(ik),ik=1,6) END DO C . Generate green house gas emissions C . Place DO LOOP by NL here and not in GHG.F to be C . consistent with MODEL1.F. c DO LL = 1,NL c L = MRKDEF(0,3+LL) c CALL GHG c END DO C . Output Results from the Government Sector. WRITE(11,*) WRITE(11,*)'Government Sector Results' WRITE(11,*) WRITE(11,*)'Receipts by Sector' WRITE(11,1002)'Region','Sector','TXPRO and TXADD','SS Tax', & 'Corp. and Pers. Inc.','IBT','ITC','Carbon Revenue' DO LL = 1,NL L = MRKDEF(0,3+LL) DO IS = 1,NIS WRITE(11,1015)L,IS,(TAX(IK,IS,L),IK=1,4), & (-1.0*XITC(IS,L)),TAX(5,IS,L) END DO WRITE(11,1001)L,TOTTAX(L),'Total Revenue' WRITE(11,1021)L,XITCTOT(L), & 'Total Rev. as Investment Credit' END DO WRITE(11,*) WRITE(11,*)'Subsidy by Sector' WRITE(11,1002)'Region','Sector','Amount' DO LL = 1,NL L = MRKDEF(0,3+LL) DO IS = 1,NIS WRITE(11,1020)L,IS,SUBSID(IS,L) END DO WRITE(11,1021)L,SUBSIDY(L,M),'Total Subsidies' END DO WRITE(11,*) WRITE(11,1002)'Region','Govt Xfers' DO LL = 1,NL L = MRKDEF(0,3+LL) WRITE(11,1021)L,GOVTR(L,M) END DO WRITE(11,*) WRITE(11,*)'Government Expenditures' WRITE(11,1002)'Region','Subsector','Price','Units', & 'Amount','Total' DO LL = 1,NL L = MRKDEF(0,3+LL) DO ISS = 1,NISS(NIS-1,L) TEMP = PGC(ISS) * GE(ISS,L,M) WRITE(11,1020)L,ISS,PGC(ISS),GE(ISS,L,M),TEMP

Page 153: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

153

END DO WRITE(11,1001)L,GOVMT(L,M),'Total Exp.' END DO C . Output Results from the Household Sector. WRITE(11,*) WRITE(11,*)'Household Sector Results' WRITE(11,*) DO LL = 1,NL L = MRKDEF(0,3+LL) perinc(L) = hhinc(1,l) + hhinc(2,l) + hhinc(3,l) - hhinc(4,l) & + hhinc(6,l) + hhinc(7,l) hhwages(l)= hhinc(2,l)+hhinc(5,l) percapk(l)=1000*PERCAP(L,M) peremp(l)=empr(l,m)*100 END DO write(11,1006)'Regions',(MRKDEF(0,3+LL),LL=1,NL) WRITE(11,1010)'Wages',(HHWAGES(MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'Dividends',(HHINC(1,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'Rents',(HHINC(3,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'Inc Taxes',(HHINC(4,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'SS. Taxes',(HHINC(5,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'Xfer Pymts',(HHINC(6,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'C Perm Ref.',(HHINC(7,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'Pers Inc.',(PERINC(MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'HH Savings',(HHINC(8,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'HH Rent Pd',(HHINC(9,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'HH Wages',(HHINC(10,MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'HH Prchase',(PINC(MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'No of HH',(NHH(MRKDEF(0,3+LL),M),LL=1,NL) WRITE(11,1010)'Land Spply', & (SALES(1,NIN-2,MRKDEF(0,3+LL),M),LL=1,NL) WRITE(11,1010)'PerCap Inc', & (PERCAPK(MRKDEF(0,3+LL)),LL=1,NL) WRITE(11,1010)'Male Pop.',(POPGLM(1,MRKDEF(0,3+LL),M),LL=1,NL) WRITE(11,1010)'Fem. Pop.',(POPGLM(2,MRKDEF(0,3+LL),M),LL=1,NL) WRITE(11,1010)'% Employed',(PEREMP(MRKDEF(0,3+LL)),LL=1,NL) C . . Now print out consumer expenditure results. WRITE(11,*) ISS=1 WRITE(11,*)'Consumer Expenditure' WRITE(11,1002)'Region','Commodity','Consumption', & 'Price','Amount' totcons = 0.0 DO LL = 1,NL L = MRKDEF(0,3+LL) DO IN = 1,NIO T1 = ED(IN,NIS,L,M)*PI(IN,IDEFS(NIS,ISS,L),L,M,1) totcons = totcons + t1 WRITE(11,1020)L, & IN,ED(IN,NIS,L,M),PI(IN,IDEFS(NIS,ISS,L),L,M,1),T1 END DO write(11,1001)l,totcons,'Total Cons.' END DO C . National Income Accounting Results WRITE(11,*) DO LL = 1, NL L = MRKDEF(0,3+LL) WRITE(11,*)'National Income Accounts' WRITE(11,'(3X,''Region '',I3/)')L WRITE(11,1016)(-ED(NIN,NIS,L,M)),'Saving plus Retained Earnings' WRITE(11,1016)tcap(l),'Total Capital in Use' WRITE(11,1016)tcapw(l),'Average Age of Capital' WRITE(11,1016)(tcap(l) / WAGE(3,l,m)),'Total Capital per Worker' WRITE(11,1016)WAGE(4,l,m),'Total GNP per Worker' END DO C . Output demographic data for labor force and government transfers. WRITE(11,*) WRITE(11,*)'Demographic Data for Labor Force', & ' and Government Transfers' DO LL = 1,NL L = MRKDEF(0,3+LL) WRITE(11,'(3X,''Region '',I3/)')L WRITE(11,1014)POPLM(L,M),'Total Population' WRITE(11,1014)WAGE(1,L,M),'Working Age Pop. Male' WRITE(11,1014)WAGE(2,L,M),'Working Age Pop. Fem.' WRITE(11,1014)SALES(1,NIN-1,L,M),'Labor Supply' WRITE(11,1016)100*YNGOLD(L,M),'Under 15 or Over 65(%)'

Page 154: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

154

WRITE(11,1014)POPGCLM(1,1,L,M),'Male Births' WRITE(11,1014)POPGCLM(2,1,L,M),'Fem. Births' WRITE(11,*) END DO C . Output population data by Age and Sex SEX(1) = 'Males- ' SEX(2) = 'Females-' WRITE(11,*)'Population Data by Region and Total' MY=1990+M*5 DO NG = 1,2 WRITE(11,*) WRITE(11,'(3X,A8,I4)')SEX(NG),MY WRITE(11,1013)' ',' ','Region No.' WRITE(11,1019)'From Age','To Age',(MRKDEF(0,3+LL),LL=1,NL) DO NA = 1,NAGE WRITE(11,1015)(NA-1)*5,(NA*5)-1, & (POPGCLM(NG,NA,MRKDEF(0,3+LL),M), & LL = 1,NL),POPGCM(NG,NA,M) END DO END DO IF(M.EQ.NM) THEN WRITE (11,*) WRITE (11, 900) tmpmonth, tmpday, tmpyear,tmphour,tmpminute, & tmpsecond,tmphund,mer END IF RETURN END

Page 155: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

155

C**********************************************************************

SUBROUTINE PPS C PPS is a subroutine which takes world prices of commodities and C converts them to regional prices incorporating taxes, C transporation, and any region-specific cost factors. Expected C future prices used for investment decisions are also calculated. C C Code added to compute conversion factor for electricity subsector C so that the correct units are used in the expected profit C calculation. This conversion factror is then folded into a new C elcectrictiy subsector price received and expected price C price received. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' PARAMETER (IOIL = 3, IGAS = 4, ICOAL = 5) REAL*8 TSUM,PIT,PIET C . Add transport costs, tariffs, taxes, and adjustments to get sector C . specific prices. Note that because the NINth price is the interest C . rate, no taxes, tariffs or transport costs are applied. C Compute price received from world prices C Elec expected price conversion if (m.eq.0) then IS=8 DO ISS = 1, NISS(IS,L) DO IN = 1, NIN if (SVRIOTOT(IDEFS(IS,ISS,L),L).ne.0) then PRCONVRTiss(IS,ISS,L) = BASEGENG(ISS,L)/ & (SVRIOTOT(IDEFS(IS,ISS,L),L)*1000) end if PELECCONV(ISS,L)=PRCONVRTiss(IS,ISS,L)/PRCONVRT(IS,L) END DO END DO end if do mm = m, nm+4 DO IS=1,NIO PRCV(IS,L,Mm) = (P(IS,L,Mm) + TR(IS,L,Mm) 1 * EXIMPORT(IS,L,Mm))/ (1.d0+TXIBT(IS,L,Mm)) if (IS.eq.8) then do ISS=1,NISS(IS,L) PrcvELEC(ISS,L,mm)=PELECCONV(ISS,L)*PRCV(IS,L,Mm) end do end if END DO end do DO IS=1,NIS DO ISS=1,NISS(IS,L) IDEFSNO = IDEFS(IS,ISS,L) IVIN = M DO IN=1,NIN-1 NGCCcd=14 NCoalIGCCcd=15 NPCcd=16 IF(IS.eq.8.and.ISS.ge.NGCCcd) then RedCfee(IN,IDEFS(IS,ISS,L),L,M)= & 9.D0*CPRICER(IN,IDEFS(IS,ISS,L),L,M) ! see GETCFEE ELSE RedCfee(IN,IDEFS(IS,ISS,L),L,M)=0.d0 ENDIF PI(IN,IDEFSNO,L,IVIN,1) = & ((P(IN,L,M)+TR(IN,L,M) & * EXIMPORT(IN,L,M)) & * TXPRO(IN,IDEFS(IS,ISS,L),L,M) & + TXADD(IN,IDEFS(IS,ISS,L),L,M) & + CPRICER(IN,IDEFS(IS,ISS,L),L,M)) & * ADJ(IN,IDEFS(IS,ISS,L),L,M) END DO PI(NIN,IDEFSNO,L,IVIN,1) = P(NIN,L,M)

Page 156: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

156

& + ADJ(NIN,IDEFS(IS,ISS,L),L,M) PI(NIN+1,IDEFSNO,L,IVIN,1) = P(NIN,L,M) & + ADJ(NIN+1,IDEFS(IS,ISS,L),L,M) IF (IS .LE. NIO & .AND. (M+4).GT.NTECHCHAR(3,IDEF(IS,ISS,L),L,M)) & THEN NVIN0 = M+1-NTECHCHAR(3,IDEF(IS,ISS,L),L,M) ELSE IF (IS .GT. NIO) THEN NVIN0 = M END IF DO IVIN=NVIN0,M DO IN=1,NIN+1 PI(IN,IDEFSNO,L,IVIN,1) = PI(IN,IDEFSNO,L,M,1) END DO END DO NVIN0 = -3 C . . . Save prices(PI) for current vintage for use in price C . . . expectation option later in the subroutine. IVIN=M DO IN=1,NIN+1 PI(IN,IDEFSNO,L,IVIN,2) = & PI(IN,IDEFSNO,L,IVIN,1) END DO END DO END DO C . Compute expected future prices. Begin by setting the vintage to C . the present period and ICHAR to 1 so the name-plate lifetime for C . capital in NTECHCHAR is used to develop expected revenue and cost C . streams. ICHAR= 1 DO 1000 IO=1,NIO DO 900 ISS=1,NISS(IO,L) IVIN = M IDEFSNO = IDEFS(IO,ISS,L) IDEFNO = IDEF(IO,ISS,L) NP = NTECHCHAR(ICHAR,IDEFNO,L,IVIN) C . . . If NOPT=0 use the input price array to develop expected C . . . price vector. This is a good idea only if the prices are C . . . near solution values. C . . . BRANCH ONE IN FUTURE PRICE COMPUTATION--USE READ IN PRICES. C . . . ********************************************************** IF (NOPT(ISS,IO,L) .EQ. 0) THEN c If a non-zero future carbon price is read in, use it c If not (ie a target is read) some estimation will be needed DO MFOR2=M,M+NP-1 IF(P(NIN-3,L,MFOR2).GT.0.0) THEN C -------------NOTE-------------------------------------------------------------- c The code below is copied out of GETCFEE and has not been tested under NOPT =0. C ------------------------------------------------------------------------------- DO IN = 1,NIO CARBF(IN,L) = 0.0 END DO DO IX = 1,NSOURCE(L) IF (EMC(IX,5,L) .EQ. -1) CYCLE IF (CARBPRICEP(3,L) .EQ. 1 .OR. EMC(IX,5,L) .EQ. 1) & THEN ITIN = EMC(IX,4,L) CARBF(ITIN,L) = CARBF(ITIN,L) + EMC(IX,10,L) & * PRCONVRT(ITIN,L) * GWP(EMC(IX,3,L),L,M) END IF END DO DO IN = 1,NIO !22 CPRICER(IN,IDEFS(IO,ISS,L),L,M) = P(NIN-3,L,MFOR2) & * CARBF(IN,L)

Page 157: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

157

& * EXCHRATE(L) END DO END IF !non 0 future Carbon price END DO !for all future periods DO 800 IN = 1,NIN-1 PIE(IN,ISS,IO,L) = 0.0 IF (in .eq. io) then PE(IO,ISS,L) = 0.0 TSUM = 0.0 end if DO 700 MFOR = M,M + NP - 1 C . . . . . . . . . Interpolate to get annual prices between periods. DO IYR = 0, NSTEP-1 XYR = FLOAT(IYR)/FLOAT(NSTEP) PYR = PRCV(IN,L,MFOR) + XYR * (PRCV(IN,L,MFOR+1) & - PRCV(IN,L,MFOR)) ADJYR = ADJ(IN,IDEFS(IO,ISS,L),L,MFOR) + XYR & * (ADJ(IN,IDEFS(IO,ISS,L),L,MFOR+1) & - ADJ(IN,IDEFS(IO,ISS,L),L,MFOR)) C TEMP = (((PYR + TR(IN,L,MFOR) & * EXIMPORT(IN,L,MFOR)) & * TXPRO(IN,IDEFS(IO,ISS,L),L,MFOR) & + TXADD(IN,IDEFS(IO,ISS,L),L,MFOR) & + CPRICER(IN,IDEFS(IO,ISS,L),L,M)) & * ADJYR) C MYEARS = MFOR * NSTEP + IYR - M * NSTEP PIE(IN,ISS,IO,L) = PIE(IN,ISS,IO,L) + TEMP & /(1.0 + PI(NIN,IDEFSNO,L,IVIN,1)) & ** (MYEARS) if (in .eq. io) then TSUM = TSUM + TEMP & / (1.0 + PI(NIN+1,IDEFSNO,L,IVIN,1)) & ** (MYEARS) C . . . . . . Compute expected price received for commodities. PE(IO,ISS,L) = PE(IO,ISS,L) + PYR & / (1.0 + PI(NIN,IDEFSNO,L,IVIN,1)) & ** (MYEARS) end if END DO C . . . . . . Compute expected prices for retrofits. if (in .eq. io) then IVINR = MFOR - NP PERETRO(IO,IDEFNO,IVINR,L) = TSUM end if 700 CONTINUE 800 CONTINUE C . . . . BRANCH TWO IN FUTURE PRICE COMPUTATION--USE CURRENT PERIOD C . . . . PRICES OR COMPUTE TREND ON COMPLETE PRICE C . . . . ********************************************************** C . . . . If NOPT=1 then compute expected future prices C . . . . assuming that current prices and taxes will remain C . . . . unchanged. C . . . . If NOPT>=2 then compute expected future prices on the C . . . . basis of a trend extrapolation. First compute the C . . . . appropriate trend in prices. ELSE IF (NOPT(ISS,IO,L) .GE. 1) THEN C . . . . . . IT is the period from which the extrapolation is C . . . . . . done. T is a real used to compute the root. If C . . . . . . NOPT = 1, then IT = M, T = 0, RATE = 1. IF (NOPT(ISS,IO,L) .EQ. 1) THEN RATE = 1.0 MYEARS = NP*NSTEP-1 PIT = PI(NIN,IDEFSNO,L,IVIN,1) PIET = (1.0/(1.0+PIT))**0.5 & *(1.0+(1.0/PIT))*(1.0-(1.0/(1.0+PIT)) & **(MYEARS+1)) PE(IO,ISS,L) = PIET * PRCV(IO,L,M) PEELEC(IO,ISS,L) = PIET * PrcvELEC(ISS,L,M) ! DO IN = 1,NIN-1 PIE(IN,ISS,IO,L) = PIET

Page 158: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

158

& * PI(IN,IDEFSNO,L,IVIN,1) END DO ELSE IT = M - (NOPT(ISS,IO,L)- 1) T = M - IT DO IN=1,NIN-1 RATE = & (PI(IN,IDEFSNO,L,M,2) & /PI(IN,IDEFSNO,L,IT,2)) ** (1 / T) MYEARS = NP*NSTEP-1 PIT = PI(NIN,IDEFSNO,L,IVIN,1) PIET = RATE*(1.0/(1.0+PIT))**0.5 & *(1.0+(1.0/PIT))*(1.0-(1.0/(1.0+PIT)) & **(MYEARS+1)) if (in .eq. io) PE(IO,ISS,L) = PIET * PRCV(IO,L,M) PIE(IN,ISS,IO,L) = PIET & * PI(IN,IDEFSNO,L,IVIN,1) PIT = PI(NIN+1,IDEFSNO,L,IVIN,1) if (in .eq. io) then DO MFOR = M, M+NP-1 IVINR = MFOR-NP MYEARS = (MFOR-M+1)*NSTEP-1 PERETRO(IN,IDEFNO,IVINR,L) = & RATE & * PI(IN,IDEFSNO,L,IVIN,1) & *(1.0/(1.0+PIT))**0.5 & *(1.0+(1.0/PIT))*(1.0-(1.0/(1.0+PIT)) & **(MYEARS+1)) END DO end if END DO END IF C . . Exact solution for present value calculation. C . . . BRANCH 3 OF THE FUTURE PRICE COMPUTATION. FIX TAX AND OTHER C . . . MARGINS AND ONLY INFLATE THE PRODUCERS COST PORTION. C . . . ************************************************************ C . . . If NOPT<=-1 then compute expected future prices on the C . . . basis of a trend extrapolation of the F.O.B. price and C . . . use given taxes and tariffs as given. First compute the C . . . appropriate trend in prices. If NOPT=-1, use current C . . . F.O.B. price. ELSE IF (NOPT(ISS,IO,L) .LE. -1) THEN DO 2000 IN=1,NIN-1 IF(NOPT(ISS,IO,L) .EQ. -1) THEN RATE = 1 ELSE IT = M + NOPT(ISS,IO,L) + 1 T = - (NOPT(ISS,IO,L) + 1) RATE = (P(IN,L,M) / P(IN,L,IT)) ** (1 / T) END IF PIE(IN,ISS,IO,L) = 0.0 if (in .eq. io) PE(IO,ISS,L) = 0.0 TSUM = 0.0 DO 1900 MFOR=M,M+NP T = MFOR C TEMP = (((P(IN,L,M) * (RATE ** T) + TR(IN,L,M) & * EXIMPORT(IN,L,M)) & * TXPRO(IN,IDEFS(IO,ISS,L),L,MFOR) & + TXADD(IN,IDEFS(IO,ISS,L),L,MFOR) & + CPRICER(IN,IDEFS(IO,ISS,L),L,M)) & * ADJ(IN,IDEFS(IO,ISS,L),L,MFOR)) C PIE(IN,ISS,IO,L) = PIE(IN,ISS,IO,L) + TEMP & / (1.0+PI(NIN,IDEFSNO,L,IVIN,1)) & ** (MFOR - M) if (in .eq. io) then PE(IO,ISS,L) = & PE(IO,ISS,L) & + (P(IN,L,M) * (RATE ** T)) & / (1.0+PI(NIN,IDEFSNO,L,IVIN,1)) & ** (MFOR - M) TSUM = TSUM & + TEMP / (1.0+PI(NIN+1,IDEFSNO,L,IVIN,1)) & ** (MFOR - M) IVINR = MFOR - NP

Page 159: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

159

PERETRO(IN,IDEFNO,IVINR,L) = TSUM end if 1900 CONTINUE 2000 CONTINUE END IF 900 CONTINUE 1000 CONTINUE RETURN END

Page 160: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

160

C***********************************************************************

SUBROUTINE SGMCTRL C This subroutine reads the input files control file and assigns C these input files to the FILES array used by the rest of the C program. C C It calls the PARSECOM subroutine to strip commas and/or spaces C at the end of input file names. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' CHARACTER*40 TABLEMRK DATA TABLEMRK/'NEW_FILE'/ 1000 FORMAT(A72) OPEN(5,FILE='SGMCTRL.CSV') C Read case name and case notes, and output file name. READ(5,*) ! line 1 READ(5,*) ! line 2 READ(5,1000)CASENAME ! line 3 READ(5,1000)CASENOTE ! line 4 READ(5,1000)DBNAME ! line 5 CALL PARSECOM(DBNAME) READ(5,1000)OUT1FILE ! line 6 CALL PARSECOM(OUT1FILE) READ(5,*) ! line 7 READ(5,*) ! line 8 c READ(5,1000)ENBLFILE c CALL PARSECOM(ENBLFILE) READ(5,*) ! line 8 READ(5,1000)ENEMFILE ! line 9 CALL PARSECOM(ENEMFILE) ! line 10 READ(5,*) ! line 11 READ(5,*) ! line 12 READ(5,*) ! line 13 CALL NEXTTABLE(TABLEMRK,INDIC) ! line 17 triggered by New File on line 16 C The nexttable subroutine sets INDIC=0 when it reaches the end C of a file, else returns 1. Loop while INDIC=1, else finished. INFILES=0 DO WHILE(INDIC.EQ.1) INFILES = INFILES+1 READ(5,1000)FILES(INFILES) CALL PARSECOM(FILES(INFILES)) CALL NEXTTABLE(TABLEMRK,INDIC) END DO CLOSE (5) RETURN END

Page 161: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

161

!**********************************************************************

SUBROUTINE SGMDATA C This subroutine reads in the input data blocks C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' CHARACTER*4 RATE,POPS CHARACTER*40 TABLEMRK,FIELDMRK,SCENMRK,FILETYPE INTEGER GASMRK,POLTYPE,PSTART DATA TABLEMRK/'INPUT_TABLE'/ DATA FIELDMRK/'INPUT_FIELD'/ DATA SCENMRK/'NEW_SCENARIO'/ REAL*8 TMPGWP(NGSP) integer iy(nmp) ! years for income elasticity values real*8 xx(0:nmp), ! input elasticity values & y(0:nmp) ! interpolated income elasticity values KM = 9 ! Check for 'EXCEPTIONS' heading on file. If it's there, ! call NEXTSCEN to check for scenario specific data. ! NEXTSCEN will only read new data in an exception file. READ(IUNIT,'(A40)') FILETYPE IF(FILETYPE .EQ. 'EXCEPTIONS') CALL NEXTSCEN(SCENMRK,INDIC) !****************************************************************** ! . Read in data set !****************************************************************** ! find the location of the first input data. CALL NEXTTABLE(TABLEMRK,INDIC) ! The nexttable subroutine returns INDIC=0 when it reaches the end ! of a file, else returns 1. Loop while INDIC=1, else finished. DO WHILE(INDIC.EQ.1) READ(IUNIT,*) ! Read the variable indicator label and select the right code. READ(IUNIT,'(I3)')IVARNUM READ(IUNIT,*) READ(IUNIT,*) if (l .eq. 10) then ivarnum = ivarnum end if 1000 FORMAT(30I6) SELECT CASE(IVARNUM) !***************** General Information and Price Data ************* ! . Read in numbers of products, factor inputs, sectors, regions, ! . emissions coefficients, first vintage, number of periods, number of ! . markets, solution option, investment option, ! . and solution control parameters. CASE(115) READ(IUNIT,1000)ISCNO ! Scenario Number CASE(1) READ(IUNIT,1000)NIO ! Number of production sectors

Page 162: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

162

CASE(2) READ(IUNIT,1000)NIN ! Number of inputs(rows in ED matrix) ! Do the following as soon as NIN is known. ! Set array for grouping sectors into categories for technical ! change parameters JCAPITAL=1 JLABOR=2 JENERGY=3 JMATRL=4 JLAND=5 JENDOIL=6 JENDGAS=7 JENDCOAL=8 JENDELEC=9 NINPCAT=9 ! Set array for grouping sectors into categories for Household ! and Government AEEIs JHHOIL=1 JHHGAS=2 JHHCOAL=3 JHHELEC=4 NINAEEI=4 ! Need to make the following code more general. INBLOCK(1) = JMATRL ! Agriculture INBLOCK(2) = JMATRL ! ETE INBLOCK(3) = JENERGY ! Crude Oil INBLOCK(4) = JENERGY ! Natural Gas INBLOCK(5) = JENERGY ! Coal INBLOCK(6) = JENERGY ! INBLOCK(7) = JENERGY ! INBLOCK(8) = JENERGY ! Electricity INBLOCK(9) = JENERGY ! Refined Petroleum INBLOCK(10) = JENERGY ! Distributed Gas IF(NIN .GT. 14) THEN DO IN=11,NIN-4 INBLOCK(IN) = JMATRL ! New sectors END DO END IF INBLOCK(NIN-3) = JMATRL ! Carbon INBLOCK(NIN-2) = JLAND ! Land INBLOCK(NIN-1) = JLABOR ! Labor INBLOCK(NIN) = JCAPITAL ! Capital INBLOCK(NIN+1) = JMATRL ! Set index of energy inputs NNRGINP=0 DO IN=1,NINP IF (INBLOCK(IN) .EQ. JENERGY) THEN NNRGINP=NNRGINP + 1 NRGINP(NNRGINP) = IN END IF END DO CASE(3) READ(IUNIT,1000)NIS ! Number of Producers + consumers(cols in ED) CASE(4) READ(IUNIT,1000)NL ! Number of regions CASE(5) READ(IUNIT,1000)NEM ! Number of emissions CASE(6)

Page 163: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

163

READ(IUNIT,1000)NVIN0 ! earliest vintage in model(0 is base period) CASE(7) READ(IUNIT,1000)NM ! Number of periods 9 for 2030; 23 for 2100 CASE(8) READ(IUNIT,1000)NMRK ! Number of markets CASE(9) READ(IUNIT,1000)NETE ! everything else sector(numeraire) CASE(10) READ(IUNIT,1000)ISOPT ! Solution option CASE(12) READ(IUNIT,'(i6,3f6.0)')ICRBTXOPT,CrbPriceRcyPct(1:3) ! carbon price option CASE(14) READ(IUNIT,'(f8.4)')SOLCONV ! Solution criteria CASE(15) READ(IUNIT,'(A3)')TECHINT ! type of interpolation in TECH (LIN or EXP) ! . Read in market definition data, input, sector of origin, number of ! . regions trading and regions. This is the market to model sector ! . mapping. CASE(17) DO MRK = 0,NMRK READ(IUNIT,1000)(MRKDEF(MRK,I),I=1,3+NL) END DO ! . Create market mapping by input and region number ! . (inverse of the above mrkdef mapping). Use region number ! . in market 0. MRKDEF in the argument for ISECDF provides ! . the proper region number. CASE(19) ! Now created after MRKDEF is read in ! DO IDUM = 1,NIN ! READ(IUNIT,1000)IN,(ISECDF(IN,MRKDEF(0,3+LL)),LL=1,NL) ! write(67,'(1x,2i5,'' isecdf'')')(isecdf(in,l),l=1,nl) ! END DO ! . Read in number of subsectors by region, sector CASE(20) READ(IUNIT,1000) L,(NISS(IS,L), IS=1,NIS) ! . Collapse production sector and subsector into one dimension. ! . Create mapping for these using IDEF. IDEFNO = 0 DO IO = 1, NIO DO ISS = 1, NISS(IO,L) IDEF(IO,ISS,L) = 1 + IDEFNO IDEFNO = IDEF(IO,ISS,L) END DO END DO ! . Collapse all sectors and subsector into one dimension. ! . Create mapping for these using IDEFS.

Page 164: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

164

IDEFSNO = 0 DO IS = 1, NIS DO ISS = 1, NISS(IS,L) IDEFS(IS,ISS,L) = 1 + IDEFSNO IDEFSNO = IDEFS(IS,ISS,L) END DO END DO 2000 FORMAT(30F17.0) 3000 FORMAT(I8,30F17.0) 3010 FORMAT(2I8,30F17.0) 3020 FORMAT(I8,30F17.0) 3030 FORMAT(3I8,30F17.0) 4000 FORMAT(A72) ! . Read logical variables to fix a price rather than let a market solve ! . for it. IPFIX = .true. if price is to be fixed. CASE(21) READ(IUNIT,'(2I3,42L2)') L,MSTART,(IPFIX(KK,L,MSTART),KK=1,NIN) DO M = MSTART,NM DO KK = 1,NIN IPFIX(KK,L,M) = IPFIX(KK,L,MSTART) END DO END DO ! . Read in the indicator variable specifying the option chosen for ! . predicting future prices by region, sector, and subsector. CASE(23) DO IO = 1,NIO READ(IUNIT,1000) L,IDUM,(NOPT(ISS,IO,L), & ISS=1,NISS(IO,L)) END DO ! . Read in names of already existing sectors (SECNAME) and ! subsectors/technologies (TECHNAME) CASE(24) READ (IUNIT,'(3I3,A)') L,IO,ISS,TECHNAME(IO,ISS,L) CALL PARSECOM(TECHNAME(IO,ISS,L)) CASE(124) DO IIO=1,NIO READ (IUNIT,'(2I3,A)') L,IO,SECNAME(IO,L) CALL PARSECOM(SECNAME(IO,L)) END DO ! . Read in multiplicative adjustment factors mapping PI into actual ! . prices paid by period, region, sector, input, and subsector. ! . Note that NIN and NIN+1 elements are additive adjustments to ! . interest rates.(include government and hhold) CASE(25) READ(IUNIT,'(4I8,27F13.0)') L,IDUM,IS,ISS, & (ADJ(IN,IDEFS(IS,ISS,L),L,0), IN=1,NIN+1) READ(IUNIT,'(4I8,27F13.0)') L,IDUM,IS,ISS, & (ADJZ(IN,IDEFS(IS,ISS,L),L), IN=1,NIN+1) READ(IUNIT,'(4I8,27F13.0)') L,IDUM,IS,ISS, & (TADJZ(IN,IDEFS(IS,ISS,L),L), IN=1,NIN+1) ! . Inheritance Version ! . Read in transportation cost multiplier by period, input, region. ! . A value of 1.0 indicates an importer while 0.0 indicates closed ! . or exporter. CASE(26) ! . . Read default eximport, by input (and region for now) ! . . Inherit defaults to future periods.

Page 165: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

165

DO IDUM = 1, NIN-1 READ(IUNIT,'(3I6,F17.0)')L,IN,MSTART,EXIMPORT(IN,L,MSTART) DO M=MSTART,NM+4 EXIMPORT(IN,L,M) = EXIMPORT(IN,L,MSTART) END DO END DO ! . Read in transportation costs by period, input, and region CASE(27) 2006 FORMAT(2I3,27F17.0) READ(IUNIT,2006) L,IDUM,(TR(IN,L,0), IN=1,NIN) READ(IUNIT,2006) L,IDUM,(TRZ(IN,L), IN=1,NIN) READ(IUNIT,2006) L,IDUM,(TTRZ(IN,L), IN=1,NIN) ! . Read in proportional taxes by period, region, sector, input, and ! . subsector. ! . Data Inheritance Version ! . Index to table. CASE(28) ! . Read defaults, and bequeath their bounty to their progeny. DO XDUM = 1, NIN READ(IUNIT,'(3I6,F17.0)')L,IN,MSTART, & TXPRO(IN,IDEFS(1,1,L),L,MSTART) ! . Inherit defaults to all sector/subsectors,regions,periods ! . . (separate regions eventually) DO M = MSTART,NM+4 DO IS = 1,NIS DO ISS=1,NISS(IS,L) TXPRO(IN,IDEFS(IS,ISS,L),L,M) = & TXPRO(IN,IDEFS(1,1,L),L,MSTART) END DO END DO END DO END DO ! . Read in overrides and exceptions to TXPRO defaults (if any) CASE(29) CALL NEXTFIELD(FIELDMRK,INDIC) READ(IUNIT,'(5I8,F17.0)')L,IN,IS,ISS,MSTART, & TXPRO(IN,IDEFS(IS,ISS,L),L,MSTART) DO WHILE (L.GT.0) DO M=MSTART,NM+4 TXPRO(IN,IDEFS(IS,ISS,L),L,M) = & TXPRO(IN,IDEFS(IS,ISS,L),L,MSTART) END DO READ(IUNIT,'(5I8,F17.0)')L,IN,IS,ISS,MSTART, & TXPRO(IN,IDEFS(IS,ISS,L),L,MSTART) END DO ! . Read in additive taxes by period, region, sector, input, and ! . subsector. ! . Data Inheritance Version. ! . Index to table. CASE(30) ! . Read defaults, and bequeath their bounty to their progeny. DO XDUM = 1, NIN READ(IUNIT,'(3I6,F17.0)')L,IN,MSTART, & TXADD(IN,IDEFS(1,1,L),L,MSTART) ! . Inherit defaults to all sector/subsectors,regions,periods

Page 166: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

166

! . . (separate regions eventually) DO M = MSTART,NM+4 DO IS = 1,NIS DO ISS=1,NISS(IS,L) TXADD(IN,IDEFS(IS,ISS,L),L,M) = & TXADD(IN,IDEFS(1,1,L),L,MSTART) END DO END DO END DO END DO ! . Read in overrides and exceptions to defaults (if any) CASE(31) CALL NEXTFIELD(FIELDMRK,INDIC) READ(IUNIT,'(5I8,f17.0)')L,IN,IS,ISS,MSTART, & TXADD(IN,IDEFS(IS,ISS,L),L,MSTART) DO WHILE (MSTART .GT. 0) ! . . Make same for all regions for now. DO M=MSTART,NM+4 TXADD(IN,IDEFS(IS,ISS,L),L,M) = & TXADD(IN,IDEFS(IS,ISS,L),L,MSTART) END DO READ(IUNIT,'(5I8,f17.0)')L,IN,IS,ISS,MSTART, & TXADD(IN,IDEFS(IS,ISS,L),L,MSTART) END DO !*********************************************************** ! . Read in population data ! Contents of POPDATA moved into this subroutine to ! limit subroutines used for inputing data !*********************************************************** RATE = 'RATE' POPS = 'POPS' ! . Determine whether population data set is in rate format or absolute ! . population format. Rate type must have RATE in first four spaces of ! . line and population data must have POPS in this position. CASE(100) READ (IUNIT,'(I8,A4)') L,POPTYPE(L) ! . . Read in population data for the US. This expects to have 21 age ! . . groups from base year through 2030. Males first and then females. CASE(32) NAGE = 16 NSTEP = 5 DO M=0,NM READ(IUNIT,'(2I8,30F12.0)')L,IDUM1, & (POPGCLM(1,NA,L,M),NA=1,NAGE) END DO CASE(33) NAGE = 16 NSTEP = 5 DO M=0,NM READ(IUNIT,'(2I8,30F12.0)')L,IDUM1, & (POPGCLM(2,NA,L,M),NA=1,NAGE) END DO

Page 167: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

167

! . . Read in initial population data and rate information to develop ! . . populations over time. ! . . This data is for base year which is period 0 in the model so set M = 0 NAGE = 16 NSTEP = 5 M = 0 ! . . Read in base period population data - Male CASE(34) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(POPGCLM(1,NA,L,M),NA=1,NAGE) ! . . Read in base period population data - Female CASE(35) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(POPGCLM(2,NA,L,M),NA=1,NAGE) ! . . Read in initial and terminal age-specific annual fertility rates CASE(36) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(FCLM(NA,L,M),NA=1,NAGE) CASE(37) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(FCLZ(NA,L),NA=1,NAGE) ! . . Read in initial and terminal death rates by gender, region, age group - Male CASE(38) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(SVGCLM(1,NA,L,M),NA=1,NAGE) CASE(39) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(SVGCLZ(1,NA,L),NA=1,NAGE) ! . . Read in initial and terminal death rates by gender, region, age group - Female CASE(40) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(SVGCLM(2,NA,L,M),NA=1,NAGE) CASE(41) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(SVGCLZ(2,NA,L),NA=1,NAGE) ! . . Read in male birth fractions by age group, region CASE(42) NAGE = 16 NSTEP = 5

Page 168: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

168

M = 0 READ(IUNIT,*)L,(GCLM(NA,L),NA=1,NAGE) ! . . Read in initial/terminal migration rates by gender, age group, region - Male CASE(43) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(XMIG(1,NA,L,M),NA=1,NAGE) CASE(44) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(XMIGZ(1,NA,L),NA=1,NAGE) ! . . Read in initial/terminal migration rates by gender, age group, region - Female CASE(45) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(XMIG(2,NA,L,M),NA=1,NAGE) CASE(46) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(XMIGZ(2,NA,L),NA=1,NAGE) ! . . Read in time-to-terminal fertility rate by age group, region CASE(47) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(TFCLZ(NA,L),NA=1,NAGE) ! . . Read in time-to-terminal death rates by gender, age, region - Male CASE(48) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(TSVGCLZ(1,NA,L),NA=1,NAGE) ! . . Read in time-to-terminal death rates by gender, age, region - Female CASE(49) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,(TSVGCLZ(2,NA,L),NA=1,NAGE) ! . . Read in time-to-terminal net migration rate by region ! . . This is inconsistent; does not have NAGE. CASE(50) NAGE = 16 NSTEP = 5 M = 0 READ(IUNIT,*)L,TXMIGZ(L) !************** Greenhouse Gas Emissions Data ************** ! . Read in greenhouse gas emissions coeficients CASE(51) DO I=1, NSRCP READ (IUNIT,*)L,XDUM,EMCLABEL(I,L),(EMC(I,J,L), J = 1, 5)

Page 169: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

169

& ,(EMCADJ(I,L,IM), IM = 0, NM) CALL PARSECOM(EMCLABEL(I,L)) END DO ! EMCADJ is for adjustments on EMC over time from exogenous factors ! eg a value of -0.10 decreases the coeficient by 10% for that year DO I=NSRCP,1,-1 !count down from the last one until there is a non-0 coef IF (EMC(I,1,L) .GT. 0) THEN NSOURCE(L) = I !set NSOURCE to the last used source EXIT END IF END DO CONTINUE ! if ISEQSW=1 sequestration offsets ! Note iseqsw operates in CARBONPRICE CASE(344) READ(IUNIT,'(i6,I6)')L,ISEQSW(L) continue ! Reads in GWP's for all Gases ! you only really need this in one of the input files CASE(332) NGAS = NGSP DO J = 1, NGAS READ (IUNIT,*)L,IDUM,(GWP(J,L,IM), IM = 0, NM) END DO ! case 333 is an old format for gwp which didn't allow variation over time ! the real GWP variable GWP() is set to TMPGWP for all time periods CASE(333) NGAS = NGSP READ (IUNIT,*)(TMPGWP(J), J = 1, NGAS) DO J = 1, NGAS GWP(J,:,:) = TMPGWP(J) END DO ! case 334 is for data about an emissions mitigating technology CASE(334) READ (IUNIT,*)L,IX,JEMT(IX,1:9,L),EMTJPR(IX,L) READ(IUNIT,*) DO J = 1, JEMT(IX,1,L) READ (IUNIT,*)L,IDUM,EMT(IX,J,:,L) END DO EMT(IX,0,:,L) = 0.0d0 ! case 335 is for data about a SIMPLE emissions mitigating technology CASE(335) READ (IUNIT,*)L,IX,JEMTSIMP(IX,L) READ(IUNIT,*) DO J = 1, 2 READ (IUNIT,*)L,EMTSIMP(IX,1:JEMTSIMP(IX,L),J,L) END DO !************************************************************** ! . Read in IO values by regions, sector, subsector, and input. ! . Read in elastivity of substitution. CASE(53) DO IN = 1, NIN READ(IUNIT,'(5I3,F12.0)')L,IDUM,IS,ISS,MSTART, & RIOVAL(IN,IDEFS(IS,ISS,L),L) END DO

Page 170: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

170

READ(IUNIT,'(5I3,F12.0)')L,IDUM,IS,ISS,MSTART, & RIBT(IDEFS(IS,ISS,L),L) READ(IUNIT,'(5I3,2F17.0)')L,IDUM,IS,ISS,MSTART, & A(NIN+1,IDEF(IS,ISS,L),MSTART,L), & RHOST(IDEF(IS,ISS,L),L) IF (ABS(RHOST(IDEF(IS,ISS,L),L)) .LT. 0.001d0) THEN RHOST(IDEF(IS,ISS,L),L) = A(NIN+1,IDEF(IS,ISS,L),MSTART,L) END IF SIGMA1(IDEF(IS,ISS,L),L) = 1.0d0 / (1.0d0 - & A(NIN+1,IDEF(IS,ISS,L),MSTART,L)) SIGMA2(IDEF(IS,ISS,L),L) = 1.0d0 / (1.0d0 - & RHOST(IDEF(IS,ISS,L),L)) ! . Read in IO values for final demand sectors by regions, sector, ! . subsector, and imput. CASE(97) DO IN = 1, NIN READ(IUNIT,'(5I3,F12.0)')L,IDUM,IS,ISS,MSTART, & RIOVAL(IN,IDEFS(IS,ISS,L),L) END DO ! Read in technical change for calculation of terminal alphas CASE(101) READ(IUNIT,'(4I8,12f17.0)') L,IO,ISS,MSTART, & TAZ(IDEF(IO,ISS,L),L), & TECHSOLM(ISS,IO,L,MSTART), & (TECHNN(J,IDEF(IO,ISS,L),L,MSTART),J=1,NINPCAT) ! Pass initial period values to all periods DO M = MSTART,NM TECHSOLM(ISS,IO,L,M) = TECHSOLM(ISS,IO,L,MSTART) DO J=1,NINPCAT TECHNN(J,IDEF(IO,ISS,L),L,M)=TECHNN(J,IDEF(IO,ISS,L),L,MSTART) END DO END DO ! Read in technical change for calculation of terminal alphas by Period CASE(401) DO MM=0,NM READ(IUNIT,'(4I8,12f17.0)') L,IO,ISS,MSTART, & TECHSOLM(ISS,IO,L,MM), & (TECHNN(J,IDEF(IO,ISS,L),L,MM),J=1,NINPCAT) END DO ! . Read in exogenous investment demand for each sector by region, ! . sector, and time period. ! . This should index to NIS when the capital part of GOVT and HHOLD ! . are in place. CASE(54) READ(IUNIT,'(2I4,23f17.0)') L,MSTART, & (EXOINVST(IO,L,MSTART), IO=1,NIO) DO IO = 1,NIO DO M = MSTART,NM EXOINVST(IO,L,M) = EXOINVST(IO,L,MSTART) END DO END DO ! . Read in logit parameter for allocating sector investments to ! . subsectors by sector, region. CASE(55) READ(IUNIT,3000) L,(RHOINV(IO,L), IO=1,NIO) ! . Read in total investment scale and elasticity of profit rate

Page 171: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

171

! . paratmeters. CASE(56) READ(IUNIT,'(I3,16F12.0)') L,SCLINV(L),ACCINV(L),RINV(L) ! . Read in investment elasticity of excess profit rate parameters ! . by sector, region. CASE(57) READ(IUNIT,3000) L, (RPROFIT(IO,L), IO = 1,NIO) ! . Read in scale parameter for excess profit rate accelerator by ! . sector, region. CASE(58) READ(IUNIT,3000) L, (SCLPROFT(IO,L), IO = 1,NIO) ! . Read in technology characteristics variable NTECHCHAR(ICHAR,,,,,) ! . by region, sector, subsector, vintage, and characteristic. ! . where ! . . ICHAR=1: nameplate lifetime of the technology ! . . ICHAR=2: number of periods between initial investment and ! . . first operation ! . . ICHAR=3: maximum allowable lifetime ! . . ICHAR=4: lifetime of the technology renovation. ! . . ICHAR=5: number of periods until initial investment ! . . ICHAR=6: period in which investment is no longer allowed CASE(59) READ(IUNIT,1000) L,IO,ISS, & (NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,NVIN0), ICHAR=1,6) ! Pass values to all other vintages DO IVIN = NVIN0+1,NM DO ICHAR=1,6 NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN) = & NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,NVIN0) END DO END DO ! . Read in prior capital stocks by region, sector, subsector, ! . and vintage. CASE(60) READ(IUNIT,'(3I6,5F15.0)') L,IO,ISS, & (KAPRIOR(ISS,IO,IVIN,L), IVIN=NVIN0,0) ! . Read in capital stock annual investment by region, sector, ! . subsector for the M=-1 and m=0 vintages. CASE(61) READ(IUNIT,'(3I6,5F15.0)') L,IO,ISS, & (KAFLOW(ISS,IO,IVIN,L),IVIN=-1,0), & (EXPPROF(ISS,IO,L,IVIN),IVIN=-1,0) DO IO = 1,NIO K(IO,L,0) = 0.0 K(IO,L,-1) = 0.0 DO ISS = 1,NISS(IO,L) K(IO,L,0) = K(IO,L,0) + KAFLOW(ISS,IO,0,L) K(IO,L,-1) = K(IO,L,-1) + KAFLOW(ISS,IO,-1,L) DEXPPROF(ISS,IO,L,-1) = EXPPROF(ISS,IO,L,-1) DEXPPROF(ISS,IO,L,0) = EXPPROF(ISS,IO,L,0) END DO SDEXPRF(IO,L,-1) = EXPPROF(1,IO,L,-1) END DO ! . Read in capital stock vintage investment by region, sector, ! . subsector for the M=-2 and m=-1 vintages. This data is used ! . to determine the baseline growth rate used in the investment ! . equation. ! CASE(62)

Page 172: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

172

! READ(IUNIT,'(3I6,5F15.0)') L,IO,ISS, ! & (VINTINV(ISS,IO,IVIN,L),IVIN=-2,-1) ! . Read in previous levels of GNP by region CASE(63) READ(IUNIT,3000) L,(GNP(L,MIND), MIND = -2,0) ! . Read in the work-age population for 1985 and 1990 and the GNP per worker ! . for 1980 and 1985 CASE(64) READ(IUNIT,'(3I3,F16.0)')L,IDUM,IDUM,WAGE(1,L,-1) READ(IUNIT,'(3I3,F16.0)')L,IDUM,IDUM,WAGE(2,L,-1) READ(IUNIT,'(3I3,F16.0)')L,IDUM,IDUM,WAGE(1,L,0) READ(IUNIT,'(3I3,F16.0)')L,IDUM,IDUM,WAGE(2,L,0) READ(IUNIT,'(3I3,F16.0)')L,IDUM,IDUM,WAGE(4,L,-2) READ(IUNIT,'(3I3,F16.0)')L,IDUM,IDUM,WAGE(4,L,-1) ! . Read in Labor force for base year CASE(96) READ(IUNIT,'(I3,F16.0)')L,ED(NIN-1,NIS,L,0) ! . Read in land used in base year CASE(98) READ(IUNIT,'(I3,F16.0)')L,ED(NIN-2,NIS,L,0) ! . Read in total savings for base year CASE(99) READ(IUNIT,'(I3,F16.0)')L,ED(NIN,NIS,L,0) ! . Read in total retained earnings for base year CASE(110) READ(IUNIT,'(I3,F16.0)')L,TRETE(L) ! . Read in number of households in base year CASE(112) READ(IUNIT,'(I3,F16.0)')L,NHH(L,0) ! . Read in government transfer to households in base year CASE(113) READ(IUNIT,'(I3,F16.0)')L,GOVTR(L,0) ! Read in dollars to physical quantities conversion factors for ! each sector in each region. CASE(65) DO IO = 1, NIO READ(IUNIT,'(2I3,15F15.0)')L,IDUM,PRCONVRT(IO,L) END DO CASE(66) ! . Read in sector in which new technology will be active. ! Will continue to look for new technologies until the sector ! specification is 0. READ (IUNIT,1000)L,IO ! . Define subsector and increment number of subsectors NISS(IO,L) = NISS(IO,L) + 1 ISS = NISS(IO,L) IDEF(IO,ISS,L) = 1 + IDEFNO IDEFNO = IDEF(IO,ISS,L)

Page 173: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

173

IDEFS(IO,ISS,L) = 1 + IDEFSNO IDEFSNO = IDEFS(IO,ISS,L) ! . Read in name of new technology READ (IUNIT,*) READ (IUNIT,'(A40)') TECHNAME(IO,ISS,L) CALL PARSECOM(TECHNAME(IO,ISS,L)) ! . Read in ISSGROUP - subsector of electricity generation sector in ! . which the new technology will be active READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,'(I8)') ISSGROUP(IO,ISS,L) ! . Read in technology characteristics variable NTECHCHAR(ICHAR,,,,,) ! . by region, sector, subsector, and characteristic for vintage 0. ! . where ! . . ICHAR=1: nameplate lifetime of the technology ! . . ICHAR=2: number of periods between initial investment and ! . . first operation ! . . ICHAR=3: maximum allowable lifetime ! . . ICHAR=4: lifetime of the technology renovation. ! . . ICHAR=5: period initial investment is allowed ! . . ICHAR=6: period in which investment is no longer allowed READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) IVIN = 0 READ(IUNIT,'(15I6)')(NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN), & ICHAR=1,6) ! . . To avoid subscript out of range, don't let IV exceed NMP IF(NTECHCHAR(5,IDEF(IO,ISS,L),L,0) .GT. NMP) & NTECHCHAR(5,IDEF(IO,ISS,L),L,0) = NMP ! Read in technical change parameter for new technology READ(IUNIT,*) READ(IUNIT,'(2f17.0)') TAZ(IDEF(IO,ISS,L),L), & TECHSOLM(ISS,IO,L,0) ! . Assign vintage 0 NTECHCHAR and TECHSOLM values to all vintages DO IVIN = 1, NM DO ICHAR = 1, 6 NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,IVIN) = & NTECHCHAR(ICHAR,IDEF(IO,ISS,L),L,0) TECHSOLM(ISS,IO,L,IVIN) = TECHSOLM(ISS,IO,L,0) END DO END DO ! . Read in input-output data of the new technology READ(IUNIT,*) READ(IUNIT,*) IV = NTECHCHAR(5,IDEF(IO,ISS,L),L,0) & - NTECHCHAR(2,IDEF(IO,ISS,L),L,0) READ(IUNIT,*) DO IN = 1, NIN READ(IUNIT,'(5I3,F12.0)')L,IDUM,IDUM,IDUM,MSTART, & RIOVAL(IN,IDEFS(IO,ISS,L),L) END DO READ(IUNIT,'(5I3,F12.0)')L,IDUM,IDUM,IDUM,MSTART, & RIBT(IDEFS(IO,ISS,L),L) READ(IUNIT,'(5I3,2F17.0)')L,IDUM,IS,ISS,MSTART, & A(NIN+1,IDEF(IS,ISS,L),MSTART,L), & RHOST(IDEF(IS,ISS,L),L)

Page 174: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

174

IF (ABS(RHOST(IDEF(IS,ISS,L),L)) .LT. 0.0001) THEN RHOST(IDEF(IS,ISS,L),L) = A(NIN+1,IDEF(IS,ISS,L),MSTART,L) END IF ! . Read in capital stock of new technology ! . KAPRIOR(ISS,IO,IVIN,L) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,'(3I6,F15.0)')L,IDUM,IDUM, & KAPRIOR(ISS,IO,IV,L) ! . Read in additive adjustment to interest rate for new investment ! . for new subsector. (ADJ(NIN), ADJZ(NIN), TADJZ(NIN)) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,*) READ(IUNIT,'(15F11.0)') ADJ(NIN,IDEFS(IO,ISS,L),L,0), & ADJZ(NIN,IDEFS(IO,ISS,L),L),TADJZ(NIN,IDEFS(IO,ISS,L),L) ! . Have TXPRO and TXADD inherit values from the first subsector of ! . the given sector DO M = 0, NM+4 DO IN = 1, NIN IF(TXPRO(IN,IDEFS(IO,ISS,L),L,M).EQ.0.0) & TXPRO(IN,IDEFS(IO,ISS,L),L,M) = TXPRO(IN,IDEFS(IO,1,L),L,M) IF(TXADD(IN,IDEFS(IO,ISS,L),L,M).EQ.0.0) & TXADD(IN,IDEFS(IO,ISS,L),L,M) = TXADD(IN,IDEFS(IO,1,L),L,M) END DO END DO ! . Have ADJ, ADJZ and TADJZ inherit values from the first subsector ! . of the given sector DO IN = 1, NIN-1 IF(ADJ(IN,IDEFS(IO,ISS,L),L,0).EQ.0.0) & ADJ(IN,IDEFS(IO,ISS,L),L,0) = ADJ(IN,IDEFS(IO,1,L),L,0) IF(ADJZ(IN,IDEFS(IO,ISS,L),L).EQ.0.0) & ADJZ(IN,IDEFS(IO,ISS,L),L) = ADJZ(IN,IDEFS(IO,1,L),L) IF(TADJZ(IN,IDEFS(IO,ISS,L),L).EQ.0.0) & TADJZ(IN,IDEFS(IO,ISS,L),L) = TADJZ(IN,IDEFS(IO,1,L),L) END DO ! . Have NOPT inherit values from the first subsector of the given sector NOPT(ISS,IO,L) = NOPT(1,IO,L) !***************************************************************** ! . Read in Government, Households, Land, Labor, etc... data ! . Read in Government subsectors fixed weights per region, ! . sector, and subsector. ! . Inheritance Version CASE(67) ! . . Inherit defaults to future periods. DO IN = 1, NIN READ(IUNIT,'(3I6,5f17.0)')L,IDUM,MSTART, & (GC(IN,ISS,L,MSTART),ISS=1,NISS(NIS-1,L)) DO M=MSTART,NM DO ISS = 1,NISS(NIS-1,L) GC(IN,ISS,L,M) = GC(IN,ISS,L,MSTART) END DO END DO END DO ! . Read in Government preference function coefficients per region, ! . period, subsector. ! . Inheritance Version

Page 175: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

175

CASE(68) ! . . Inherit defaults to future periods. READ(IUNIT,'(4I6,f17.0)')L,IDUM,ISS,MSTART,GF(ISS,L,MSTART) DO M=MSTART,NM GF(ISS,L,M) = GF(ISS,L,MSTART) END DO ! . Read in Government Deficits for each region and period. CASE(69) DO M = 0,NM READ(IUNIT,3010) L,IDUM,GOVDEF(L,M) END DO ! . Read in household savings function coefficient per region and period CASE(70) READ(IUNIT,3020) L,S(0,L,0) ! . Read in Household consumer demand function coefficients ! . for each produced input(in) per region and period. Demands for ! . labor, land, and capital expenditures are handled separately. ! . Inheritance Version CASE(71) ! . . Inherit defaults to future periods. DO IN = 1, NIO READ(IUNIT,'(3I6,3f17.0)')L,IDUM,MSTART, & (E(I,IN,L,MSTART),I=1,2) DO M=MSTART,NM DO I = 1,2 E(I,IN,L,M)=E(I,IN,L,MSTART) END DO END DO END DO CASE (171) ! override values to allow income elasticity to change over time Read (iunit, '(i6)')nval do ival = 1,nval read(iunit,'(3i6,f17.0)')l,in,iy(ival),xx(ival) end do call interp(nval,0,iy,xx,y) do m = 0,nm e(1,in,L,m) = y(m) end do ! . Read in Labor supply function coefficients per region, period, and ! . gender. CASE(72) DO NG = 1, 2 READ(IUNIT,'(2I6,3f17.0)')L,IDUM,LB(0,NG,L,0) END DO ! . . Read in total land per region CASE(73) READ(IUNIT,2006) L,MSTART,TLA(L,MSTART) ! . . Inherit defaults to future periods. DO M=MSTART,NM TLA(L,M)=TLA(L,MSTART) END DO

Page 176: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

176

! . . Read in land supply function coefficients CASE(74) READ(IUNIT,'(I6,3f17.0)') L,R(0,L,0) ! . . Read in retained earnings per sector (io) region and period CASE(75) DO IO = 1, NIO READ(IUNIT,'(2I6,2f17.0)')L,IDUM,RE(0,IO,L,0) END DO ! . . Read in corporate income tax rate per region and period CASE(76) READ(IUNIT,'(2I6,2f17.0)') L,MSTART,CITR(L,MSTART) DO M=MSTART,NM CITR(L,M) = CITR(L,MSTART) END DO ! . Read in social security tax rate per region and period CASE(77) READ(IUNIT,'(2I6,2f17.0)') L,MSTART,SSTR(L,MSTART) DO M=MSTART,NM SSTR(L,M) = SSTR(L,MSTART) END DO ! . Read in Personal income tax rate per region and period CASE(78) READ(IUNIT,'(2I6,2f17.0)') L,MSTART,PITR(L,MSTART) DO M=MSTART,NM PITR(L,M) = PITR(L,MSTART) END DO ! . Read in trade balance data. Note that negative data is an import. ! . Inheritance Version CASE(80) ! . . Inherit defaults to future periods. ! . . Use I=0 as the original data value for trade and I=1 as the trade ! . . that includes market excess demand. Trade with I=1 must be ! . . initialized here, however, to the original. ! . . Do inherit base year trade to future periods. DO IN = 1, NIN READ(IUNIT,'(3I6,4f17.0)')L,IDUM,MSTART, & TRADE(0,IN,L,MSTART) DO M=MSTART+1,NM DO I = 0,1 TRADE(I,IN,L,M) = TRADE(0,IN,L,MSTART) END DO CAPTRD(L,M) = TRADE(0,NIN,L,M) !Store initial value END DO TRADE(1,IN,L,MSTART)=TRADE(0,IN,L,MSTART) END DO !******************************************************** ! . . Read in resource data. !******************************************************** ! . . Read in resource type indicator variables. CASE(81)

Page 177: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

177

DO IO=1,NIO READ(IUNIT,1000) L,IDUM, & (NRSCHAR(ICHAR,IO,L),ICHAR = 1,1) END DO ! . . Read in amounts of uninvested, depletable resources by region, ! . . product, and graded subsector. read only if depletable CASE(82) DO IO=1,NIO IF(NRSCHAR(1,IO,L).EQ.2) THEN READ(IUNIT,3010) L,IDUM, & (DRSCE(IO,ISS,L), ISS=1,NISS(IO,L)) ! . . . . . . . Store initial values (to be used for growth calcs.) DO ISS=1,NISS(IO,L) DRSCE0(IO,ISS,L) = DRSCE(IO,ISS,L) END DO END IF END DO ! . . Read in remaining capacity or reserves in invested capital in ! . . depletable resources for vintages up to present. ! . . Read only if depletable. CASE(83) READ(IUNIT,3030) L,IO,ISS, & (DRSVE(IO,ISS,IVIN,L), IVIN=NVIN0,0) ! . .Read in initial, terminal, and time-to-terminal growth rates ! . . in depletable resources CASE(84) DO IO=1,NIO IF(NRSCHAR(1,IO,L).EQ.2) THEN READ(IUNIT,3010)L,IDUM,(RESGRO(IO,ISS,L,0), ISS=1,NISS(IO,L)) END IF END DO CASE(85) DO IO=1,NIO IF(NRSCHAR(1,IO,L).EQ.2) THEN READ(IUNIT,3010)L,IDUM,(RESGRZ(IO,ISS,L), ISS=1,NISS(IO,L)) END IF END DO CASE(86) DO IO=1,NIO IF(NRSCHAR(1,IO,L).EQ.2) THEN READ(IUNIT,3010)L,IDUM,(TRESGRZ(IO,ISS,L), ISS=1,NISS(IO,L)) END IF END DO !******************************************************* ! . . Read in policy variables. !****************************************************** ! . . Read in investment tax credit rates. CASE(88) DO IO = 1,NIO READ(IUNIT,2000)XDUM,XDUM,XITCR(IO) END DO ! . Read in initial period for investment tax credit policy. CASE(89) READ(IUNIT,1000)IDUM,ITCPD !************************************************************

Page 178: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

178

! CARBON POLICY VARIABLES !************************************************************ 1007 FORMAT(4I5,1F8.0,1I5,1F8.0,1I5,1F8.3) ! Read in switch by region to (de)activate carbon policy CASE(90) DO LL=1,NL READ(IUNIT,*)L,CARBPRICEP(1,L) !"0" for no policy, "1" for policy END DO ! Read in carbon policy settings, including exogenous prices or targets, ! the start period for the policy, and the use of CO2-only or carbon equivalent ! CARBPRICEP(1,L) Activate carbon policy, 0 for no policy, 1 for policy ! CARBPRICEP(2,L) specify price (0), extrenal target (1), or internal ! target (enter year for reference oeriod) ! CARBPRICEP(3,L) CO2 or Ce basis, 0 for CO2, 1 for Ce ! CARBPRICEP(4,L) Internal (1) or external (0) target ! CARBPRICEP(5,L) Reference period for internal target ! CARBPRICEP(6,L) start period for policy ! CARBDATA(1,L,M) exogenous carbon price ! CARBDATA(2,L,M) external target ! CARBDATA(3,L,M) fraction of internal target year CASE(290) DO LL=1,NL READ(IUNIT,*)L,POLTYPE,CARBPRICEP(3,L),CARBPRICEP(6,L), & (CARBVAR(L,M),M=0,NM) ! Determine the type of policy: "0" for exogenous price, ! "1" for exogenous targets, or enter a year (e.g., 2005) ! for the base year of internal target IF (POLTYPE.EQ.0) THEN !Carbon price CARBPRICEP(2,L) = 0 ELSE IF (POLTYPE.EQ.1) THEN !External carbon target CARBPRICEP(2,L) = 1 CARBPRICEP(4,L) = 0 ELSE IF (POLTYPE.GE.1990) THEN !Internal carbon target CARBPRICEP(2,L) = 1 CARBPRICEP(4,L) = 1 CARBPRICEP(5,L) = (POLTYPE-1990)/5 !Ref. period for internal target END IF ! Set CARBDATA for taxes, external targets or internal targets DO M=0,NM IF (POLTYPE.EQ.0) THEN CARBDATA(1,L,M) = CARBVAR(L,M) CARBDATA(2,L,M) = 0 ELSE IF (POLTYPE.EQ.1) THEN CARBDATA(2,L,M) = CARBVAR(L,M) ELSE IF (POLTYPE.GE.1990) THEN CARBDATA(3,L,M) = CARBVAR(L,M) END IF END DO END DO CASE (291) ! Variable to allow carbon price to apply to individual fuels. DO LL=1,NL READ(IUNIT,*)L,(CarbPriceAdj(in,L),in=1,nin) END DO CASE(390) !Read in emissions targets for calibrating carbon price path DO LL=1,NL READ(IUNIT,*)L,(EMTARGET(L,M),M=0,NM) END DO !************************************************************ ! END CARBON POLICY VARIABLES !************************************************************

Page 179: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

179

! Read in switch for price control. 'YES' to use price table (variable 92); ! 'NO' to use last periods prices as starting points for solution. CASE(102) READ(IUNIT,'(A2)')READINPRICE ! . Read in updated price control for fixed price paths. CASE(92) DO M=0,NM READ(IUNIT,'(2I8,27F16.0)')L,IDUM,(P(IN,L,M),IN=1,NIN) END DO ! . . Extend prices by 4 periods for price expectations. ! . . For exogenously set prices, c. oil, use growth rate from ! previous period DO M = NM+1,NM+4 DO IN = 1,NIN IF (IPFIX(IN,L,M)) THEN P(IN,L,M) = P(IN,L,M-1)*(P(IN,L,M-1)/P(IN,L,M-2)) ELSE P(IN,L,M) = P(IN,L,M-1) END IF END DO END DO ! . . Exchange rate for converting currency into base year US dollars. CASE(95) READ(IUNIT,'(I5,F12.0)')L,EXCHRATE(L) ! Household AEEI by fuel CASE(116) DO M=0,NM READ(IUNIT,'(2I8,4f17.0)') L,IDUM, & (HHAEEI(J,L,M),J=1,NINAEEI) END DO ! Government AEEI by fuel CASE(316) DO M=0,NM READ(IUNIT,'(2I8,4f17.0)') L,IDUM, & (GVAEEI(J,L,M),J=1,NINAEEI) END DO ! Read in fixed labor supply fraction time path CASE(117) DO M=0,NM READ(IUNIT,*) L,MDUM,LFIX(L,M) END DO ! Read in multiplier for projected output (used for investment) CASE(119) DO M=0,NM READ(IUNIT,*) L,MDUM,QPROJ(L,M) END DO ! Read Directly calibration wedges by time period CASE(125) READ(IUNIT,'(4I8,f17.0)') L,IO,ISS,MSTART,WEDGE(IO,ISS,L,MSTART) ! Fill in gaps between periods DO WHILE (L.GT.0) DO M=MSTART,NM WEDGE(IO,ISS,L,M)=WEDGE(IO,ISS,L,MSTART) ! WDGMRK signals code that new wedge exists

Page 180: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

180

IWDGMRK(IO,ISS,L,M)=1 END DO READ(IUNIT,'(4I8,f17.0)') L,IO,ISS,MSTART,WEDGE(IO,ISS,L,MSTART) END DO ! . Read in indirect business tax rates by sector and region. CASE(201) DO XDUM = 1, NIO READ(IUNIT,'(3I6,f17.0)')L,IS,MSTART,TXIBT(IS,L,MSTART) END DO DO M=MSTART+1,NM DO IS=1,NIO TXIBT(IS,L,M) = TXIBT(IS,L,MSTART) END DO END DO ! . Read in exogenous investment for nuclear power. CASE(202) DO IDUM = 0,9 READ(IUNIT,'(4I6,f17.0)')L,NELEC,JNUC,MSTART,EXONUC(IDUM,L) END DO DO M=MSTART+1,NM EXONUC(M,L) = EXONUC(MSTART,L) END DO ! . Read in exogenous investment for hydro power. CASE(203) DO IDUM = 0,9 READ(IUNIT,'(4I6,f17.0)')L,NELEC,JHYDRO,MSTART,EXOHYDRO(IDUM,L) END DO DO M=MSTART+1,NM EXOHYDRO(M,L) = EXOHYDRO(MSTART,L) END DO ! Read in GNP deflator (if necessary) default = 1 CASE(205) READ(IUNIT,3000)L,DEFLATOR(L) ! Read in indicator by region to run old IMPEX subroutine CASE(206) READ(IUNIT,1000)L,IMPOLD(L) ! Regional solution criteria case(207) do l=1,nl read(iunit,1000)ll,regsol(l) end do ! Exogenous carbon trading for a region, in the local currency units CASE(209) DO M=1,NM READ(IUNIT,*)L,MM,CRBTREXO(L,M) ! Also assign to fixed trade array for carbon TRADE(0,NIN-3,L,M) = CRBTREXO(L,M) TRADE(1,NIN-3,L,M) = CRBTREXO(L,M) END DO ! Switch for fixed electricity investment by subsector ! 1 = fixed, 0 = not fixed CASE(211) DO J=1,NISS(8,L)

Page 181: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

181

READ(IUNIT,*) L,IS,ISS,MSTART,JELFIX(L,ISS,MSTART) END DO DO M=MSTART+1,NM DO ISS=1,NISS(8,L) JELFIX(L,ISS,M) = JELFIX(L,ISS,MSTART) END DO END DO ! Copy into JFIXINV array DO M=MSTART+1,NM IO = 8 DO ISS = 1,NISS(IO,L) JFIXINV(IO,ISS,L,M) = JELFIX(L,ISS,M) END DO END DO ! Exogenous investment values for electricity subsectors CASE(212) DO M = 0,9 READ(IUNIT,*)L,IS,ISS,MSTART, 1 EXOELEC(L,ISS,MSTART) END DO DO M=MSTART+1,NM EXOELEC(L,ISS,M) = EXOELEC(L,ISS,MSTART) END DO ! Copy into FIXINV arra DO M=MSTART+1,NM IO = 8 DO ISS = 1,NISS(IO,L) FIXINV(IO,ISS,L,M) = EXOELEC(L,ISS,M) END DO END DO ! Base-Year Investment Share Vector CASE(213) DO IO=1,NIO READ(IUNIT,*)L,IDUM,SHAREINV(IO,L) END DO ! CAPMAT = 0.0 DO I=1,NIO CAPMAT(I,1:NIO,L) = SHAREINV(I,L) END DO ! Base-Year Investment Share Matrix CASE(214) DO IO=1,NIO READ(IUNIT,*)L,IDUM,(CAPMAT(IO,J,L),J=1,NIO) END DO ! convert to investment shares and store in CAPSHR DO J=1,NIO SUM = 0.0D0 DO I=1,NIO SUM = SUM + CAPMAT(I,J,L) END DO DO I=1,NIO IF(SUM .GT. 0.001) THEN CAPSHR(I,J,L) = CAPMAT(I,J,L)/SUM ELSE CAPSHR(I,J,L) = 0.0D0 END IF END DO END DO ! Base-Year Investment Matrix for Government (used in SGM-Japan only) CASE(215) DO IO=1,NIO READ(IUNIT,*)L,IDUM,(CAPMATG(IO,J,L),J=1,NIO)

Page 182: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

182

END DO ! Calculate shrares to allocate purchases of construction equipment. SUM = 0.0D0 DO J=1,NIO SUM = SUM + CAPMATG(16,J,6) END DO DO J=1,NIO SHARE16G(J) = CAPMATG(16,J,6) / SUM END DO ! Calculate ratios of capital to row 16. DO J=1,NIO SUM = 0.0D0 DO I=1,NIO SUM = SUM + CAPMATG(I,J,6) END DO IF(CAPMATG(16,J,6) .GT. 0.001D0) THEN CAPR16G(J) = SUM / CAPMATG(16,J,6) ELSE CAPR16G(J) = 0.0D0 END IF END DO ! . Read in IO values by regions, sector, subsector, and input. ! . Read in elastivity of substitution directly, not as rho. ! . This replaces CASE(53). CASE(216) DO IN = 1, NIN READ(IUNIT,'(5I3,F20.0)')L,IDUM,IS,ISS,MSTART, & RIOVAL(IN,IDEFS(IS,ISS,L),L) END DO READ(IUNIT,'(5I3,F20.0)')L,IDUM,IS,ISS,MSTART, & RIBT(IDEFS(IS,ISS,L),L) READ(IUNIT,'(5I3,2F20.0)')L,IDUM,IS,ISS,MSTART, & S1,S2 SIGMA1(IDEF(IS,ISS,L),L) = S1 SIGMA2(IDEF(IS,ISS,L),L) = S2 IF(S1 .GE. 0.05) THEN A(NIN+1,IDEF(IS,ISS,L),MSTART,L) = (S1 - 1.0D0)/S1 ELSE A(NIN+1,IDEF(IS,ISS,L),MSTART,L) = -19.0D0 END IF IF(S2 .GE. 0.05) THEN RHOST(IDEF(IS,ISS,L),L) = (S2 - 1.0D0)/S2 ELSE RHOST(IDEF(IS,ISS,L),L) = -19.0D0 END IF ! Indicator for type of investment equation ! LINVEST = 0 original investment equations ! LINVEST = 1 uses KDEM for energy transformation sectors only ! LINVEST = 2 uses KDEM for all producing sectors CASE(220) READ(IUNIT,1000)L,LINVEST(L) ! Dollar value for carbon-free backstop CASE(301) DO M=1,NM READ(IUNIT,*)IDUM,CFBSTOP(M) END DO ! Electricity Generation by fuel in base year in GWh CASE(305) READ(IUNIT,*)L,(BASEGENG(ISS,L),ISS=1,16) ! 16 (NISSP)

Page 183: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

183

CASE(345) c DO IP=1,401 READ(IUNIT,*)L,EmSeqP(L,IP),(EmSeq(L,IP,IQ),IQ=1,4) END DO c New technologies subnesting option CASE(346) !ISUB = 0: Legacy SGM - no subnests READ(IUNIT,*)L,ISUB(L) !ISUB = 1: subnest - 1 subnest level: (coal, PCcd, IGCC, ICCcd) ! (gas, NGCC, NCCCcd) !ISUB = 2: subnest- 1 subnest level: (coal, PCcd) ! (IGCC, IGCCcd) ! (NGCC, NGCCcd) !ISUB = 3: Use the following subnest structure: c c Electricity Sector Subnesting Diagram c ------------------------------------- c c electricity--------------------------- c /\ | | c / \ | | c / \ | | c / \ | | c / \ | | c fossil renewables nuclear hydro c /\ / / / \ \ \ c / \ / / / \ \ \ c / \ w b w w s g c peak base a i i i o e c /\ /|\ s o n n l o c / \ / | \ t m d d a t c oil gas / | \ e a r h c / | \ s o o e c coal ngcc igcc s n f p r c /\ /\ /\ v m c / \ / \ / \ c no ccs no ccs no ccs c ! New technologies subnesting option for new exponent or subnest CASE(347) READ(IUNIT,*)L,ISUBexp(L) !ISUBexp = 1: subnest with new

!ROHINVsub exponent for subnest share !ISUBexp = 2: subnest with new ROHINVsub exponent for subnest share

CASE(348) READ(IUNIT,*) L,RHOINVsub(L) CASE(349) READ(IUNIT,*) L,IProfitOption(L)

!IProfitOption=0 !Traditional SGM expected profit calculation

!IProfitOption=1 !Change price received in electricity !subsector so it is consistent with !units used for quantities !IProfitOption=2 !Use levelized cost per kWh !instead of expected profits

CASE(350) READ(IUNIT,*) L,RHOINVccs(L) !logit sharing exponent for knife edge !carbon capture and sequestration level nests CASE(351) READ(IUNIT,*) L,RHOINVpkbs(L) !logit sharing exponent for peak base level nest CASE(352) READ(IUNIT,*) L,RHOINVfsl(L) !logit sharing exponent for fossil nest CASE(353) READ(IUNIT,*) L,RHOINVrnw(L) !logit sharing exponent for renewables nest

Page 184: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

184

CASE(354) !delay option mainly used DO INS = 1,NISS(8,L) !for advanced fossil techs READ(IUNIT,*) L,ISS,issDelay(L,ISS) !forces investment shares to issDelay(L,ISS) = (issDelay(L,ISS) - 1990) / 5

!zero until introduction year END DO !is reached CASE(355) !Input cost of capital DO INS = 1,NISS(8,L) READ(IUNIT,*) L,ISS,Kcost(ISS,L) END DO CASE(356) !Beta parameters for lowest level subnests DO INS = 1,NISS(8,L) READ(IUNIT,*) L,ISS,BETAin(ISS,L) END DO CASE(357) !Beta parameters for base subnetst (ngcc, igcc, pc) DO count = 1,3 READ(IUNIT,*) L,INS,BetaB(INS,L) END DO CASE(358) !Beta parameters for fossil subnetst (peak v. base) DO count = 1,2 READ(IUNIT,*) L,INS,BetaF(INS,L) END DO CASE(359) !Beta parameters for elec subnest (fossil, renewable, nuclear, hydro) DO count = 1,4 READ(IUNIT,*) L,INS,BetaE(INS,L) END DO c End subnest reads ! Switch to activate writing solution output to screen during model run ! value of '1' to writes to screen, other values do not write to screen CASE(400) READ(IUNIT,*) SCREEN CASE DEFAULT write(*,*)'variable number',ivarnum,'was assigned but does not' & ,'exist in the read-in program' END SELECT CALL NEXTTABLE(TABLEMRK,INDIC) END DO ! Create MKTLINK to inidicate which markets are open or closed for ! each region and ISECDF which is the inverse link from inputs for a ! region to their market numbers DO MRK=1,NMRK NR=MRKDEF(MRK,3) IN=MRKDEF(MRK,2) IF(NR.EQ.1) THEN L=MRKDEF(MRK,3+NR) ISECDF(IN,L)=MRK ! Still mark as open if price is fixed or sector is ETE sector IF(IPFIX(IN,L,1) .OR. IN.EQ.NETE) THEN MKTLINK(IN,L)=1 ELSE MKTLINK(IN,L)=0 END IF ELSE DO LL=1,NR L=MRKDEF(MRK,3+LL) MKTLINK(IN,L)=1 ISECDF(IN,L)=MRK END DO END IF END DO

Page 185: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

185

RETURN END !********************************************************************* ! . Subroutine to advance to next input table. ! . Gets file to one line past the marker. Returns 1 if successful, ! . returns a 0 on end-of-file.

SUBROUTINE NEXTFIELD(FIELDMRK,INDIC) !********************************************************************* CHARACTER*40 FIELDIN,FIELDMRK 3000 FORMAT(A40) READ(5,3000,END=10) FIELDIN CALL PARSECOM(FIELDIN) DO WHILE (FIELDIN.NE.FIELDMRK) READ(5,3000,END=10) FIELDIN CALL PARSECOM(FIELDIN) END DO READ(5,*) INDIC=1 RETURN ! . . On end of file 10 CONTINUE INDIC=0 RETURN END !********************************************************************* ! . Subroutine for parsing to comma or blank ! . the data input field tag.

SUBROUTINE PARSECOM(CH) C*********************************************************************** CHARACTER*(*) CH ! . First check for comma. I=INDEX(CH,',')-1 IF(I.GT.0 .AND. I.LT.72) THEN CH=CH(:I) RETURN END IF RETURN END !********************************************************************* ! . Subroutine to advance to next input table. ! . Gets file to one line past the marker. Returns 1 if successful, ! . returns a 0 on end-of-file.

SUBROUTINE NEXTTABLE(TABLEMRK,INDIC) !********************************************************************* CHARACTER*40 TABLEIN,TABLEMRK 3000 FORMAT(A40) READ(5,3000,END=10) TABLEIN IF (TABLEIN .EQ. 'END_SCENARIO') GOTO 10 DO WHILE (TABLEIN.NE.TABLEMRK) READ(5,3000,END=10) TABLEIN CALL PARSECOM(TABLEIN) END DO

Page 186: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

186

INDIC=1 RETURN ! . . On end of file 10 CONTINUE INDIC=0 RETURN END !********************************************************************* ! . Subroutine to advance to next scenario exceptions ! . Gets file to one line past the marker. Reads scenario specific ! . file titles if successful.

SUBROUTINE NEXTSCEN(SCENMRK,INDIC) !********************************************************************* C . Include common blocks INCLUDE 'COMMON.BLK' CHARACTER*40 SCENMRK,SCENIN 3000 FORMAT(A40) READ(5,3000,END=10) SCENIN CALL PARSECOM(SCENIN) DO WHILE (SCENIN.NE.SCENMRK) READ(5,3000,END=10) SCENIN CALL PARSECOM(SCENIN) END DO READ(5,*) READ(5,3000) CASENAME READ(5,3000) CASENOTE READ(5,*) READ(5,3000) OUT1FILE CALL PARSECOM(OUT1FILE) READ(5,*) READ(5,3000) ENEMFILE CALL PARSECOM(ENEMFILE) READ(5,*) READ(5,*) READ(5,*) RETURN ! . . On end of file 10 CONTINUE INDIC=0 RETURN END C C ****************************************C

SUBROUTINE INTERP(N,ISTART,IY,X,Y) ! Taken from Wigley's MAGICC program ! linearly interpolate any periods with out data in input ! extend last element if last data entry is not the final period C*********************************************************************** Parameter(KEND = 23) ! allows for 23 periods in SGM (to 2100) c ! dimensions in common block though! integer IY(100) Real*8 X(0:100),Y(0:100) do i=1,n ! convert years to index numbers iy(i) = (iy(i) - 1990) / 5 end do IEND=ISTART+IY(N) DO I=0,IY(N)-1 DO K=1,N

Page 187: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

187

IF(I.GE.IY(K).AND.I.LT.IY(K+1))THEN J=I+ISTART Y(J)=X(K)+(I-IY(K))*(X(K+1)-X(K))/(IY(K+1)-IY(K)) ENDIF END DO END DO Y(IEND)=X(N) c c If last year in profile (relative to 1990) not KEND, then assume c constant parameter value from last year specified in parameter profile c to KEND. c if(iy(n).lt.KEND) then do i=iend+1,KEND y(i) = x(n) end do end if c RETURN END

Page 188: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

188

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

C SGM FUNCTION LIBRARY C Contains: FIFGE, SUMINTRP, TABLE C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C***********************************************************************

FUNCTION FIFGE(A,B,I,J) C C FIFGE stands for First If First is Greater than or Equal to. C This function is used to switch on or off policies depending C on relevant conditions such as time, vintage, etc. C The function takes the value A if I>=J, else it takes value B. C*********************************************************************** IF(I.GE.J) THEN FIFGE = A ELSE FIFGE = B END IF RETURN END C***********************************************************************

FUNCTION SUMINTRP(FL1,FL2) C SUMINTRP is a function subprogram which returns the sum of annual C flows linearly interpolated between 5-yr endpoint values. This C function is used for updating stock variables at 5-yr intervals C including capital stocks, depletable reserves, and depletable C resource bases. C The sum of linearly interpolated annual flows for the 5-year period C starting with the current model period t and going back over the C previous 4 years can be shown equal to 2 times the annual flow at C time t-5 plus 3 times the flow at time t. C FL1 is the flow at t-5. FL2 is the flow at t. C*********************************************************************** IMPLICIT DOUBLE PRECISION (A-H,O-Z) SUMINTRP = (2.0 * FL1) + (3.0 * FL2) RETURN END C*********************************************************************** FUNCTION Techinterp(m0,ml,mm,x0,xl,itype) C Function to provide two types of interpolation for technology C coefficients. The first is exponential, which assumes uniform C rates of change of technology. The second, which is the default, C in order to provide conformity with old data sets, is linear, C which results in higher rates of change in earlier periods, and lower C rates in later periods. EXP is the preferred option. C C Arguments C m0 is the initial period * nstep C ml is the final period * nstep C mm is the interpolated period * nstep, C where nstep is the number of years in a time step C x0 is the value in the initial period C xl is the value in the final period C C*********************************************************************** IMPLICIT DOUBLE PRECISION (A-H,O-Z)

Page 189: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

189

REAL*8 m0,ml,mm REAL*8 x0,xl,fx character*3 itype fx = mm/(ml - m0) c if (itype .eq. 'EXP') then if(x0 .gt. 0.0) then techinterp = (x0 ** (1. - fx)) * xl ** fx else techinterp = -(abs(x0) ** (1. - fx)) * abs(xl) ** fx end if c else c techinterp = x0 + (xl - x0) * fx c end if end C***********************************************************************

FUNCTION TECHINTERP(m0,ml,mm,x0,xl,itype) C Function to provide two types of interpolation for technology C coefficients. The first is exponential, which assumes uniform C rates of change of technology. The second, which is the default, C in order to provide conformity with old data sets, is linear, C which results in higher rates of change in earlier periods, and lower C rates in later periods. EXP is the preferred option. C C Arguments C m0 is the initial period * nstep C ml is the final period * nstep C mm is the interpolated period * nstep, C where nstep is the number of years in a time step C x0 is the value in the initial period C xl is the value in the final period C C*********************************************************************** IMPLICIT DOUBLE PRECISION (A-H,O-Z) REAL*8 m0,ml,mm REAL*8 x0,xl,fx character*3 itype fx = mm/(ml - m0) c if (itype .eq. 'EXP') then if(x0 .gt. 0.0) then techinterp = (x0 ** (1. - fx)) * xl ** fx else techinterp = -(abs(x0) ** (1. - fx)) * abs(xl) ** fx end if c else c techinterp = x0 + (xl - x0) * fx c end if end C**********************************************************************

SUBROUTINE SOLUTN C Modified Newton-Raphson search for market equilibrium prices. C N-R is modified to call a non-derivative based line search when C it finds a discontinuity that causes the derivative to provide C inadequate information for a given market. Also modified in that C derivatives from the previous iteration are recycled for markets C that are within tolerance, which reduces model evaluations. C C********************************************************************** C C Notes and explanations: C C Each period, the markets whose price is fixed or which haven't C come on line are weeded out to avoid a singular matrix error. C Prices are perturbed to get derivatives (elasticities) for the

Page 190: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

190

C N-R search. If, after a few calls, any markets are off by a set C amount, the line search SOLVE is called for them before the N-R C procedure continues. SOLVE is also called when an iteration C price causes a market's production to go to zero. In both cases C SOLVE is called because the N-R routine is faced with a discont- C inuity. Also, after 1 iteration, if a market is solved within a set C tolerance, the derivative is recycled for the next iteration, C saving a model evaluation. C C After the first period, the derivatives from the solution set of C the previous period are re-used for the first iteration of the C current period, also potentially reducing model evaluations. C C If the procedure is unsuccessful after a number of tries, the C SOLUTA is called to finish the job. C C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' PARAMETER (TINY = .0001, WEE = 1.E-12) DIMENSION NEWT(NMRKP),ICLOSE(NMRKP),MSOLCALL(NMRKP) DIMENSION ISORT(NMRKP),IPRESORT(NMRKP) REAL*8 DEMI(NMRKP),SUPI(NMRKP),DP(NMRKP),DELTA,XVEC(NMRKP) REAL*8 UIJ(NMRKP,NMRKP),VIJ(NMRKP,NMRKP),W(NMRKP,NMRKP) REAL*8 DUMMAT(NMRKP,NMRKP) !Not used, needed for GAUSSJ REAL*8 pmrk,EDSAVE(NINP,NISP,NLP),SALESTMP(1,NINP,NLP) REAL*8 TESTL(NLP) ISOL = 0 ! Needed to generate model output correctly DELTAP = 0.00001D0 ! Derivative delta TEST = SOLCONV ! Model convergence criterion TESTWO = .1 ! minimum value for WAYOFF CONV = TEST ! Used in SOLVE TEST2S = 5 * TEST ! Tolerance for testing to call SOLVE (change to 5 from 10) TESTCLOS = TEST ! Tolerance for test if derivative can be re-used MAXNEWT = Max(60,2*NL) ! Max N-R iterations allowed before solution fails maxmodl = NMRK * 25 ! Max number of model runs to cutting wayoff mmaxmodl = nmrk*250000 ! Absolute max to quit--way to high to be effective WAYOFF = 1.0 ! Tolerance to call solve immediately NUMNUTS = 0 ! Number of Newton iterations before check to call solve ! for markets that are still outside TEST2S IORDOPT0 = 1 ! Indicator for order in calling Solve for markets in which ! derivative is not working c if (m.eq.11) IORDOPT0 = 0 c 0 = straight Gauss Seidel c 1 = order by percent disequilibrium C 2 = order by absolute diseqilibrium c 3 = random between options 0, 1 and 2 imesscnt = 0 ! counter for number of lines in debug array imodmescnt = 0 ! counter for lines im model debug array modmess = ' ' ! reset model message array to blank at each period message = ' ' ! reset message array to blank at each period ixvectcnt = 0 ! counter for number of xvec evaluations c regional solution criteria DO LL=1,NL L1=MRKDEF(0,3+LL) IF(REGSOL(L1).GT.0.0) THEN TESTL(L1)=REGSOL(L1) ELSE TESTL(L1)= TEST END IF END DO NFAIL=1 ! Model solve indicator NITRNEWT=-1 !No. of iterations CALL RANDOM_SEED() !Initialize random number generator C Big Do WHILE loop that runs whole thing until convergence DO WHILE(NFAIL.EQ.1) C Test to see if max iterations exceeded IF(NITRNEWT.GT.MAXNEWT) THEN

Page 191: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

191

c ----------------------------------------------------- WRITE(6,*)'N-R SOLUTION FAILED IN PERIOD ',M &,P(NIN-3,L,M) WRITE(messnew,*)'N-R SOLUTION FAILED IN PERIOD ,',M,',' &,P(NIN-3,L,M) WRITE(114,*)'N-R SOLUTION FAILED IN PERIOD ',M &,P(NIN-3,L,M) c -------------------------e---------------------------- imesscnt = imesscnt + 1 message(imesscnt) = messnew msol = 1 write (36,'(a100)')(message(i),i=1,imesscnt) write (36,'(a100)')(modmess(i),i=1,imodmescnt) !HP addition c ---------------------------------------- c write (6,*)' imesscnt = ',imesscnt ! write to file c open(1,FILE='..\outputs\message.txt') c write (1, '(a100)') (message(i),i=1,imesscnt) c ---------------------------------------- return ELSE NITRNEWT=NITRNEWT+1 C (De)activate writing to screen during run IF (SCREEN.EQ.1) THEN write(6,*)'n-r iter ',nitrnewt write(6,*)'Market',' Input',' Region',' Period', & ' Excess Demand',' Prices' write(messnew,*)'n-r iter ,',nitrnewt,',' imesscnt = imesscnt + 1 message(imesscnt) = messnew write(messnew,*)'Market,',' Input,',' Region,',' Period,', & 'LN(Excess Demand),','Ex.Demand, ',' Supply, ', & ' Prices,' imesscnt = imesscnt + 1 message(imesscnt) = messnew END IF END IF C Get initial values from inital model run DO I = 1,NMRK IMRK = I INN = MRKDEF(IMRK,2) NR = MRKDEF(IMRK,3) C Update all regional prices with the 1st region prices L1 = MRKDEF(IMRK,4) IF (.NOT. IPFIX(INN,L1,M)) THEN DO LL = 1,NR L = MRKDEF(IMRK,3+LL) P(INN,L,M) = P(INN,L1,M) END DO END IF END DO MRK=1 CALL MODEL2 ************************************************************************ C Loop over markets in Newton-Raphson (N-R) Search, check disequilibrium isolcall=0 !Flag tells if SOLVE has been called this iteration isolcnt=0 !Number of times SOLVE called C Initialize flags to call solve at false (0) DO I=1,NNEWT MSOLCALL(I)=0 END DO 10 CONTINUE izerop=0 C Assign mapping to markets that do not have prices fixed or zero C production and demands in that period (to avoid singular matrix)

Page 192: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

192

C NNEWT stores the dimension of the matrix C NEWT stores pointers from matrix dimensions to the market numbers NNEWT=0 DO IMRK=1,NMRK INN = MRKDEF(IMRK,2) NR = MRKDEF(IMRK,3) L = MRKDEF(IMRK,4) IXX = ISECDF(NIN-3,L) IF (IMRK.EQ.IXX) THEN IF (CARBPRICEP(1,L) .EQ. 1.AND. CARBPRICEP(6,L) .LE. M & .AND. CARBPRICEP(2,L) .EQ.1 ) THEN IF(MRKED(IXX) .LE. 0 .AND. P(NIN-3,L,M) .LT. 0.1) THEN WRITE(messnew,*)IXX,',',(NIN-3),',',MRKED(IXX),',', & P(NIN-3,L,M),',',' CARBON Price,' imesscnt = imesscnt + 1 message(imesscnt) = messnew DO LL=1,NR LLL=MRKDEF(IMRK,3+LL) IPFIX(NIN-3,LLL,M) = .TRUE. P(NIN-3,LLL,M) = 0.1 END DO ELSE IF (IPFIX(NIN-3,L,M) .AND. MRKED(IXX) .GT. 0) THEN WRITE(messnew,*)IPFIX(NIN-3,L,M),',',MRKED(IXX),',' imesscnt = imesscnt + 1 message(imesscnt) = messnew DO LL=1,NR LLL=MRKDEF(IMRK,3+LL) IPFIX(NIN-3,LLL,M) = .FALSE. CALL RANDOM_NUMBER(XGHOST) P(NIN-3,LLL,M) = 1.0+XGHOST END DO END IF END IF END IF IF(IPFIX(INN,L,M)) THEN C Trade now computed in IMPEX in new RON regions IF(IMPOLD(L).EQ.1) THEN DO LL = 1,NR L = MRKDEF(IMRK,3+LL) IF (INN.NE.(NIN-3)) & TRADE(1,INN,L,M) = TRADE(1,INN,L,M) - MRKLED(IMRK,L) END DO MRK=IMRK CALL MODEL1 END IF ELSE IF(MRKPRD(IMRK).GT.wee .OR. & (MRKED(IMRK)+mrkprd(imrk)).GT.wee) THEN NNEWT = NNEWT+1 NEWT(NNEWT) = IMRK END IF END DO c Also cut Wayoff if number of model evals. gets too big if(modl.gt.maxmodl) then IF (SCREEN.EQ.1) THEN write(6,*)'cutting wayoff down ',modl write(messnew,*)'cutting wayoff down, ',modl,',' imesscnt = imesscnt + 1 message(imesscnt) = messnew END IF C call soluta maxmodl=maxmodl*2 wayoff=max(wayoff/2,testWO) if(modl.gt.mmaxmodl) then !Quit

Page 193: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

193

write(6,*)'model failed to solve within ',modl,' calls' write(messnew,*)'model failed to solve within ,', & modl,',',' calls,' imesscnt = imesscnt + 1 message(imesscnt) = messnew msol = 1 write (36,'(a100)')(message(i),i=1,imesscnt) write (36,'(a100)')(modmess(i),i=1,imodmescnt) !HP addition return end if C RETURN end if NFAIL=0 !Initialize at success, resets to fail if not convererged ixvectcnt = ixvectcnt + 1 if (nitrnewt .gt. 10)test2s = test DO I=1,NNEWT IMRK=NEWT(I) ! Assign pointer to market index C Store demands and supplies for elasticity computations DEMI(I) = (MRKED(IMRK) + MRKPRD(IMRK)) SUPI(I) = MRKPRD(IMRK) INN = MRKDEF(IMRK,2) L1 = MRKDEF(IMRK,4) C Compute X vector IF(SUPI(I).GT.0.D0 .AND. DEMI(I).GT.0.D0) THEN XVEC(I) = DLOG(DEMI(I)) - DLOG(SUPI(I)) IF (DABS(XVEC(I)) .GT. TESTL(L1) .AND. SCREEN .EQ. 1) & write(6,'(I5,I8,I9,I7,G16.4,F14.6)')imrk,inn,L1,M,xvec(i), & P(INN,L1,M) IF (DABS(XVEC(I)) .GT. TESTL(L1)) Then end if C If either prod. or demand is zero, flag to call SOLVE ELSE MSOLCALL(I)=1 izerop=1 !Indicates call to SOLVE due to zero production C XVEC(I) = (SUPI(I)-DEMI(I))/MAX(DABS(SUPI(I)),DABS(DEMI(I))) IF (SCREEN.EQ.1) THEN write(6,'(I5,I8,I9,A16,F14.6)')imrk,inn,L1,'Call Solve', & P(INN,L1,M) END IF c write(messnew,"(4(I4,','),A16,',',F14.6,',')")ixvectcnt, & imrk,inn,L1,'Call Solve',P(INN,L1,M) imesscnt = imesscnt + 1 message(imesscnt) = messnew END IF C Check for close to convergence IF (DABS(XVEC(I)) .GT. TESTL(L1))THEN NFAIL=1 ICLOSE(I)=0 IF(DABS(XVEC(I)).LT.TESTCLOS) THEN ICLOSE(I)=1 END IF ELSE ICLOSE(I)=1 END IF END DO C If all markets have converged, return, else continue IF(NFAIL.EQ.0) THEN if(m.gt.1 .or. nitrnewt.gt.0) then IF(SCREEN.EQ.1) THEN WRITE(6,*) WRITE(6,*)'N-R SOLVED IN PD. ',M,' IN ',NITRNEWT, & ' ITERATIONS and modl ',modl END IF WRITE(messnew,*) imesscnt = imesscnt + 1 message(imesscnt) = messnew WRITE(messnew,*)'N-R SOLVED IN PD. ,',M,', IN ,',NITRNEWT, & ', ITERATIONS and modl ,',modl,','

Page 194: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

194

imesscnt = imesscnt + 1 message(imesscnt) = messnew ISOL = 0 WRITE(36,"('N-R SOLVED IN PD. ,',i3,', IN ,',i3, & ', ITERATIONS and modl ,',i5,',')")M,Nitrnewt,modl c ------------------------------------------------- if (messageout) then write (36,'(a100)')(message(i),i=1,imesscnt) write (36,'(a100)')(modmess(i),i=1,imodmescnt) end if c -------------------------------------------------- RETURN end if END IF C If solve has been called this iter., better redo all derivatives IF (ISOLCALL.EQ.1) THEN DO I=1,NNEWT ICLOSE(I)=0 END DO END IF C After a few passes, if any single market is off by a lot, solve it C separately first before doing the elasticities. Also, solve C any market whose production went to zero on last iteration. ISOLCALL=0 IF(NITRNEWT.GE.NUMNUTS)THEN DO I=1,NNEWT IF (DABS(XVEC(I)).GT.TEST2S) THEN MSOLCALL(I)=1 END IF END DO END IF c If solve called too much this pass, could be bouncing C so skip call and redo derivatives (unless call was to be made C to avoid zero production) if(isolcnt.gt.(nmrk/6) .and. izerop.eq.0) then do i=1,nnewt msolcall(i)=0 end do isolcnt=0 end if c if a market is ever way way off, solve it so it doesn't drag others C out with it, regardless of no. of iterations if(nitrnewt.gt.0) then do i=1,nnewt if(dabs(xvec(i)).gt.wayoff) then msolcall(i)=1 end if end do end if ************************************************* C Compute order for calling solve C First set order option IF(IORDOPT0.LE.2) THEN IORDOPT=IORDOPT0 ELSE IF (IORDOPT0.EQ.3) THEN CALL RANDOM_NUMBER(XGHOST) IF(XGHOST.GT.0.67) THEN IORDOPT=1 ELSE IF(XGHOST.LE.0.33) THEN IORDOPT=0 ELSE IORDOPT=2 END IF END IF NISOLVE=0 DO I=1,NNEWT !First map all being called

Page 195: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

195

IF(MSOLCALL(I).EQ.1) THEN NISOLVE=NISOLVE+1 IPRESORT(NISOLVE)=I END IF END DO c perform a sort for descending order of diseqilibrium DISMAX=0.0 DO I=1,NISOLVE DISMAX=0.0 DO J=1,(NISOLVE+1-I) IMAP=IPRESORT(J) IF(IORDOPT.EQ.1) THEN TESTDIS = DABS(XVEC(IMAP)) ELSE TESTDIS = DABS(DEMI(IMAP)-SUPI(IMAP)) END IF IF(TESTDIS.GT.DISMAX) THEN DISMAX=TESTDIS IMAX=IMAP JMAX=J END IF END DO IF(IORDOPT.GE.1) THEN ISORT(I) = IMAX DO J2=JMAX,NISOLVE-I IPRESORT(J2) = IPRESORT(J2+1) END DO ELSE ISORT(I) = IPRESORT(I) END IF END DO c --------------------------------------------------------- C Reset modmess index if about to exceed array bounds IF(imodmescnt.GT.200000) THEN imodmescnt=1 modmess = ' ' ! reset model message array to blank write(messnew,*) 'modmess array bound exceeded: imodmescnt reset' write (6,*)'modmess array bound exceeded: imodmescnt reset' imodmescnt = imodmescnt + 1 modmess(imodmescnt) = messnew END IF c ---------------------------------------------------- if(screen .eq. 1) then if (nisolve .gt. 0) then write (6,*)' NITRNEWT = ',NITRNEWT ! temp output write (6,*)' modl = ',modl ! temp output c write (6,*)' imesscnt = ',imesscnt ! temp output c write (6,*)' imodmescnt = ',imodmescnt ! temp output write (6,*)' CPrice = ',P(NIN-3,L,M) ! temp output write(0,"(i4,' Markets sent to Solve'/(16i4))") & nisolve,(isort(i),i=1,nisolve) else write(0,"('No Markets sent to Solve')") end if end if C Call SOLVE for those in need of assistance DO I2=1,NISOLVE I=ISORT(I2) ISOLCALL=1 MRK=NEWT(I) MSOLCALL(I)=0 !Reset isolcnt=isolcnt+1 isolvec=0 c if(screen .eq. 1) write (6,*)'mrk to solve',mrk write (messnew,*)'mrk to solve,',mrk,',' imesscnt = imesscnt + 1 message(imesscnt) = messnew c ------------------------------------------------------- C Reset message index if about to exceed array bounds

Page 196: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

196

IF(imesscnt.GT.20000) THEN imesscnt=1 message = ' ' ! reset message array to blank write(messnew,*) 'message array bound exceeded: imesscnt reset' write (6,*)'message array bound exceeded: imesscnt reset' imesscnt = imesscnt + 1 message(imesscnt) = messnew END IF c ---------------------------------------------------- 20 CALL SOLVE isolvec=isolvec+1 C Verify solve criterion (since it can kick out early) IMRK=NEWT(I) ! Assign pointer to market index C Store demands and supplies for elasticity computations DEMI(I) = (MRKED(IMRK) + MRKPRD(IMRK)) SUPI(I) = MRKPRD(IMRK) XVEC(I) = DLOG(max(DEMI(I),wee)) - DLOG(max(SUPI(I),wee)) IF (ISOLVEC .GT. 30) THEN IF(SCREEN.EQ.1) THEN WRITE(6,*)'Call to SOLVE exceeds 30' WRITE(messnew,*)'Call to SOLVE exceeds 30,' imesscnt = imesscnt + 1 message(imesscnt) = messnew END IF GO TO 30 c END IF L1 = MRKDEF(IMRK,4) IF (DABS(XVEC(I)).GT.TESTL(L1)) GO TO 20 !Pardon my goto 30 ISOL=0 !To keep output in outexcel.for ok END IF END DO C Recheck convergence and compute new excess demands IF(ISOLCALL.EQ.1) THEN IF(SCREEN.EQ.1) THEN WRITE(6,*)'Solve called, iordopt = ,',iordopt WRITE(messnew,*)'Solve called, iordopt = ,',iordopt imesscnt = imesscnt + 1 message(imesscnt) = messnew END IF GO TO 10 END IF C Store unperturbed ED's to EDSAVE. DO LL = 1, NL L = MRKDEF(0,3+LL) DO IS = 1, NIS DO IN = 1, NIN EDSAVE(IN,IS,L)=ED(IN,IS,L,M) SALESTMP(1,IN,L)=SALES(1,IN,L,M) END DO END DO END DO if(nitrnewt .le. 10) then !skip NR if too many iterations ************************************************************************ C Here is the meat of the Newton-Raphson C Re-use last period's derivatives for first iteration IF(M.LE.1 .OR. NITRNEWT.GE.1) THEN C Compute numerical elasticities DO I=1,NNEWT ! Loop over markets (matrix rows) C Use original ED's for regions not in market. DO LL = 1, NL

Page 197: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

197

L = MRKDEF(0,3+LL) DO IS = 1, NIS DO IN = 1, NIN ED(IN,IS,L,M)=EDSAVE(IN,IS,L) SALES(1,IN,L,M)=SALESTMP(1,IN,L) END DO END DO END DO c Only compute new deriv if indiv. market is not close C (or if it's first pass) C ICLOSE(I) = 0 IF (ICLOSE(I).EQ.0 .OR. NITRNEWT.EQ.0 .OR. READINPRICE.EQ.'YE') & THEN IMRK = NEWT(I) INN = MRKDEF(IMRK,2) NR = MRKDEF(IMRK,3) C Perturb prices L1 = MRKDEF(IMRK,4) PMRK = P(INN,L1,M) DELTA = PMRK*DELTAP DO LL = 1,NR L = MRKDEF(IMRK,3+LL) P(INN,L,M) = PMRK + DELTA END DO C Call the model with the price perturbation MRK=IMRK CALL MODEL1 INN = MRKDEF(IMRK,2) NR = MRKDEF(IMRK,3) L1 = MRKDEF(IMRK,4) C Loop over markets and compute the own- and cross-elasticities DO J=1,NNEWT ! Fills out matrix columns JMRK = NEWT(J) !Assign pointer to market DEMTMP = (MRKED(JMRK) + MRKPRD(JMRK)) UIJ(J,I)=(DEMTMP-DEMI(J))/DEMI(J)/(DELTA/(P(INN,L1,M)-DELTA)) SUPTMP = MRKPRD(JMRK) VIJ(J,I)=(SUPTMP-SUPI(J))/SUPI(J)/(DELTA/(P(INN,L1,M)-DELTA)) END DO C Return prices to original value pmrk = p(inn,l1,m) DO LL = 1,NR L = MRKDEF(IMRK,3+LL) P(INN,L,M) = pmrk - DELTA END DO END IF !If Block that checks if market already close or solved END DO C Compute W matrix, invert, multiply by X vector to get new prices C for next iteration. DO I=1,NNEWT DO J=1,NNEWT W(I,J)=UIJ(I,J)-VIJ(I,J) END DO END DO C Call matrix inversion subroutine to invert W. CALL GAUSSJ(W,NNEWT,NMRKP,dummat,1,1) END IF !If Block to check if first iteration

Page 198: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

198

C Multiply W inverse by XVEC to get price changes. DO I=1,NNEWT DP(I)=0.0 DO J=1,NNEWT TEMP=-W(I,J)*XVEC(J) DP(I)=DP(I)+TEMP END DO IF(DP(I).LT. -0.8D0) DP(I)= -0.8D0 C IF(DP(I).GT. 1.5D0) DP(I)= 1.5D0 C IF(DP(I).LT.-1.D0) DP(I)=-0.9D0 END DO C Compute new prices. if(nfail.eq.1) then DO I=1,NNEWT IMRK=NEWT(I) INN = MRKDEF(IMRK,2) NR = MRKDEF(IMRK,3) L1 = MRKDEF(IMRK,4) pmrk = p(inn,l1,m) DO LL = 1,NR L = MRKDEF(IMRK,3+LL) P(INN,L,M) = pmrk*(1.D0+DP(I)) END DO END DO end if ************************************************************************ end if ! end skip NR END DO ! End of big Do While loop return END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C GAUSSJ is a Numerical Recipes routine used here for inverting a C matrix. It is used here instead of MINV from the ERB because C it is more general in that it allows the order of the matrix to C be less than the memory allocation dimension of the matrix. C C a is the two-dimensional matrix to be inverted C n is the order of the matrix C np is the physical dimension of the 'a' array from the main program C b is a matrix (not used here) C m,mp are the columns of b (not used here) C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C AN INDEPENDENT LICENCE NEEDS TO BE OBTAINED BY EVERY USER FROM NUMERICAL RECIPES C BEFORE USING GAUSSJ IN COMPILING THIS MODEL C SEE http://www.nr.com/com/storefront.html CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

SUBROUTINE GAUSSJ(a,n,np,b,m,mp) END C (C) Copr. 1986-92 Numerical Recipes Software ************************************************************************

Page 199: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

199

C**********************************************************************

SUBROUTINE SOLVE C This subroutine establishes bounds for the solution price such that C the sign of excess demand changes from one bound to the other. It C then calls BRENT to establish the price to the desired accuracy. C C Subroutines Called: BRENT, MODEL C*********************************************************************** C . Include Common Blocks INCLUDE 'COMMON.BLK' PARAMETER (TINY = .00001,WEE = 1.E-8, SMALL = .01) logical ifprint ifprint = .false. C . Find a pair of prices for which the sign of ED changes. C . DE has an estimated value for demand elasticity and SE has an C . estimated value for supply elasticity. Initial values for these C . need to be provided. MULT is a multiplicative adjustment factor C . to improve the liklyhood of getting a bracketing value. C . isol = -1 indicates market excess demand function is ill behaved. C . isol = 0 indicates market solution found. C . isol = 1 indicates solution not found within 4 iterations. INN = MRKDEF(MRK,2) C . The first region in the market definition is the slot which holds C . the market price in the P array. L = MRKDEF(MRK,4) ITR = 1 PRICE(MRK,ITR) = P(INN,L,M) PROD(MRK,ITR) = MRKPRD(MRK) EXD(MRK,ITR) = MRKED(MRK) if (m.eq.11 .and. l .eq. 12 .and. inn.eq.9) ifprint = .true. 100 CONTINUE IF (ITR .EQ. 1) THEN C . . Compute change in price using tanh(exd/prod). The constant C . . limits price change to +/- 50%. DELP(ITR) = .5 * TANH(EXD(MRK,ITR) / (PROD(MRK,ITR) + TINY)) PRICE(MRK,ITR+1) = (1 + DELP(ITR)) * PRICE(MRK,ITR) ELSE DELP(ITR) = .5 * TANH((ITR * EXD(MRK,ITR)) / & (PROD(MRK,ITR) + TINY)) PRICE(MRK,ITR+1) = (1 + DELP(ITR)) * PRICE(MRK,ITR) END IF INN = MRKDEF(MRK,2) NR = MRKDEF(MRK,3) DO LL = 1,NR L = MRKDEF(MRK,3+LL) P(INN,L,M) = PRICE(MRK,ITR+1) END DO C . Now call model to get new excess demand CALL MODEL1 ITR = ITR + 1 PROD(MRK,ITR) = MRKPRD(MRK) EXD(MRK,ITR) = MRKED(MRK) C . if demand and supply both zero then have a solution. IF (PROD(MRK,ITR) .LT. SMALL & .AND. ABS(EXD(MRK,ITR)) .LT. SMALL) THEN ISOL = 0 RETURN

Page 200: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

200

END IF C . If excess demand sufficiently small then have a solution. IF (ABS(EXD(MRK,ITR)) .LT. CONV) THEN C . . Current price satisfies convergence requirement ISOL = 0 RETURN END IF IF ((EXD(MRK,ITR) * EXD(MRK,ITR-1)) .LT. 0.) THEN C . . Bracketed prices achieved, set up to call BRENT CALL BRNT ISOL = IBR RETURN END IF C . Is this branch needed? IF (ABS(EXD(MRK,ITR)) .GT. ABS(EXD(MRK,ITR-1))) THEN C . . pathologic behavior of excess demand indicated, leave isol = -1 IF (ITR .GT. 4) THEN C . . . No bracket achieved on price after 4 tries. ISOL = 1 RETURN END IF GO TO 100 END IF C . Bracketed prices not achieved, continue search. IF (ITR .GT. 4) THEN C . . No bracket achieved on price after 4 tries. C . . Record error exits for debugging purposes. ISOL = 1 RETURN END IF GO TO 100 END

Page 201: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

201

C*********************************************************************

SUBROUTINE TECH C This module computes time-dependent technological coefficients that C are used in the production sectors of the model. C*********************************************************************** C . Include common blocks INCLUDE 'COMMON.BLK' PARAMETER (FMIN = 10.E-25) logical print INTEGER JENDFUEL(NINP),JHHFUEL(NINP) !End-Use fuels mapping C Assign mapping of fuels to inputs. JENDFUEL(9)=JENDOIL JENDFUEL(10)=JENDGAS JENDFUEL(5)=JENDCOAL JENDFUEL(8)=JENDELEC JHHFUEL(9)=JHHOIL JHHFUEL(10)=JHHGAS JHHFUEL(5)=JHHCOAL JHHFUEL(8)=JHHELEC C Set non-neutral technical change for crude gas input equal to that for C gas T&D input. This allows for technical change for regions that receive C gas from the crude sector instead of the T&D sector JENDFUEL(4)=JENDFUEL(10) JHHFUEL(4)=JHHFUEL(10) print = .false. if(TECHINT .eq. 'EXP' .or. TECHINT .eq. 'exp') then TECHINT = 'EXP' else TECHINT = 'LIN' end if C Compute HouseHold sector energy input coefficients by fuel and period C based on input household AEEIs (HHAEEI) DO IN = 1,NIN JH=JHHFUEL(IN) IF(JH.NE.0) THEN DO IM=1,NM FACTOR = (1.0 + HHAEEI(JH,L,IM))**NSTEP E(0,IN,L,IM) = E(0,IN,L,IM-1)/FACTOR END DO END IF END DO C Compute Government sector energy input coefficients by fuel and period C based on input government AEEIs (GVAEEI) DO IN = 1,NIN JH=JHHFUEL(IN) IF(JH.NE.0) THEN DO ISS = 1, NISS(NIS-1,L) DO IM=1,NM FACTOR = (1.0 + GVAEEI(JH,L,IM))**NSTEP GC(IN,ISS,L,IM) = GC(IN,ISS,L,IM-1)/FACTOR END DO END DO END IF END DO C********************************************************************* DO IO=1,NIO DO ISS=1,NISS(IO,L) IDEFP=IDEF(IO,ISS,L) RHO = A(NIN+1,IDEF(IO,ISS,L),0,L)

Page 202: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

202

C . . Set IVIN1 equal to first commercial period IVIN1 = NTECHCHAR(5,IDEF(IO,ISS,L),L,0) ivin1 = min(nm,ivin1) DO IVIN=(IVIN1+1),NM A(0,IDEFP,IVIN,L) = A(0,IDEFP,IVIN-1,L) * & (1+TECHSOLM(ISS,IO,L,IVIN))**NSTEP LEON(0,IDEFP,IVIN,L) = LEON(0,IDEFP,IVIN-1,L) * & (1+TECHSOLM(ISS,IO,L,IVIN))**NSTEP DO IN = 1,NIN J = INBLOCK(IN) C If an energy input, use fuel-specific change if given JB=JENDFUEL(IN) IF(J.EQ.JENERGY .AND. JB.NE.0) THEN IF(TECHNN(JB,IDEFP,L,IVIN).NE.0.D0) J = JB END IF FACTOR = (1.0 + TECHNN(J,IDEFP,L,IVIN))**NSTEP A(IN,IDEFP,IVIN,L) = A(IN,IDEFP,IVIN-1,L) * & FACTOR**RHO LEON(IN,IDEFP,IVIN,L) = LEON(IN,IDEFP,IVIN-1,L) / & FACTOR END DO !end of do in DO IN = NIN+1,(NIN+NEM+1) A(IN,IDEFP,IVIN,L) = A(IN,IDEFP,IVIN1,L) LEON(IN,IDEFP,IVIN,L) = LEON(IN,IDEFP,IVIN1,L) END DO END DO !end of do over vintages END DO ! end of subsectors END DO ! end of sectors C********************************************************************* C Normalize CES technical coefficients so that alpha-zero equals 1. C This allows alpha-zero to be used for energy supply calibration. DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IVIN = NVIN0,NM RHO = A(NIN+1,IDEF(IO,ISS,L),IVIN,L) SIG = 1.d0 / (1.d0 - RHO) HICKS = A(0,IDEF(IO,ISS,L),IVIN,L) IF(HICKS .GT. 0.0d0) THEN DO IN=1,NIN A(IN,IDEF(IO,ISS,L),IVIN,L) = 1 A(IN,IDEF(IO,ISS,L),IVIN,L) * (HICKS**RHO) END DO A(0,IDEF(IO,ISS,L),IVIN,L) = 1.0d0 END IF END DO END DO ! end of ISS loop END DO ! end of IO loop C End of CES coefficient normalization. C ***************************************************************** C . Save A0 coeficients so that adjustment process to achieve C . desired GNP track doesn't overwrite the baseline data. DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IVIN= NVIN0,NM A0SAVE(ISS,IO,IVIN,L) = A(0,IDEF(IO,ISS,L),IVIN,L) END DO END DO END DO C . Compute transformed alpha matrix by region, sector, subsector,

Page 203: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

203

C . input, vintage DO IO=1,NIO DO ISS = 1,NISS(IO,L) IRHO = NIN + NEM + 1 DO IVIN = NVIN0,NM RHO = A(IRHO,IDEF(IO,ISS,L),IVIN,L) SIG = 1. / (1. - RHO) ACST(0,IDEF(IO,ISS,L),IVIN,L) = & A(0,IDEF(IO,ISS,L),IVIN,L)**(SIG*RHO) DO IN = 1,IRHO - 1 ACST(IN,IDEF(IO,ISS,L),IVIN,L) = & A(IN,IDEF(IO,ISS,L),IVIN,L)**SIG END DO ACST(IRHO,IDEF(IO,ISS,L),IVIN,L) = - RHO * SIG END DO END DO END DO C . . Compute sector-specific price adjustment factors as a time- C . . dependent interpolation of initial and terminal values. DO IS=1,NIS DO ISS=1,NISS(IS,L) DO IN=1,NIN+1 DO IM=1,NM+4 IF ((NSTEP*IM) .LT. TADJZ(IN,IDEFS(IS,ISS,L),L)) THEN FXZ = (NSTEP*IM)/TADJZ(IN,IDEFS(IS,ISS,L),L) ELSE FXZ = 1.0 END IF ADJ(IN,IDEFS(IS,ISS,L),L,IM)=ADJ(IN,IDEFS(IS,ISS,L),L,0) & * (1.0-FXZ) & + ADJZ(IN,IDEFS(IS,ISS,L),L)*FXZ END DO END DO END DO END DO C Replace wedges with direct read-in wedges where applicable DO IO=1,NIO DO ISS=1,NISS(IO,L) DO IM=1,NM IF (IWDGMRK(IO,ISS,L,IM).EQ.1) THEN ADJ(NIN,IDEFS(IO,ISS,L),L,IM) = WEDGE(IO,ISS,L,IM) END IF END DO END DO END DO C . Compute growth in resource base for depletables, by time period DO IO=1,NIO IF(NRSCHAR(1,IO,L).EQ.2) THEN DO ISS=1,NISS(IO,L) DO IM=1,NM IF ((NSTEP*IM) .LT. TRESGRZ(IO,ISS,L)) THEN FXZ = (NSTEP*IM)/TRESGRZ(IO,ISS,L) ELSE FXZ = 1.0 END IF RESGRO(IO,ISS,L,IM) = RESGRO(IO,ISS,L,0) * (1.0-FXZ) & + RESGRZ(IO,ISS,L) * FXZ END DO END DO END IF END DO C . . Compute region-specific transportation cost factors as a time- C . . dependent interpolation of initial and terminal values. DO IN=1,NIN

Page 204: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

204

DO IM=1,NM+4 IF ((NSTEP*IM) .LT. TTRZ(IN,L)) THEN FXZ = (NSTEP*IM)/TTRZ(IN,L) ELSE FXZ = 1.0 END IF TR(IN,L,IM) = TR(IN,L,0) * (1.0-FXZ) & + TRZ(IN,L) * FXZ END DO END DO RETURN END

Page 205: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

205

Figure 1 A Basic Flowchart of the SGM 1

1 after: The SGM 2000 User’s Guide. Unpublished.

by Chris MacCracken and Paul Runci Global Climate Change Group Pacific Northwest National Laboratory

SGM PROGRAM (MAIN)

Display Screen (BANNER)

Control and Input (SGMCTRL & SGMDATA)

Demographics (DEMOG)

Prices: Current & Expected Future (PPS)

Carbon Taxes (CARBONTAX)

Final Demand Sectors

Household Demand (HHOLD)

Government Demand (GOVT)

Sector Investment (INVST)

Trade (IMPEX)

Excess Demand (MODEL1 & 2)

Initialize Next Period and Compute Energy Balance (POSTINI & EBAL)

Production Sectors

Investment (NEWINV)

Expected Profit (EXPPROFIT)

Operate New Capital (OPERATENEW)

Operate Old Capital (OPERATEOLD)

Model Solution (SOLUTN & SOLVE)

Output (OUTEXCEL)

Start of Period Loop

End of Period Loop

Calculation of CES Coefficients and Model Parameters (CESCALC, PPS, FIXC & TECH)

Base Year Execution (MODEL1, POSTINI & EBAL)

If some markets remain

If fi l i d

Initialize Final Demand (ACCOUNT)

Emissions (GHG & GHGEMIS)

Page 206: SGM Model Code version 1.0 · 2014-09-30 · PNNL-15037-1 SGM Model Code I Joint Global Change Research Institute Model Group Antoinette L. Brenkert (editor) January 28, 2005 Prepared

206

JGCRI’s Software User Acknowledgement

JGCRI SOFTWARE USER ACKNOWLEDGEMENT

The User of the Software provided by PNNL through the Joint Global Change Research Institute acknowledges the following:

1. In order to facilitate the maximum usefulness of this software, the USER is requested to: Notify PNNL of any publication of new findings that may be discovered through the use of the

Software. Communicate any errors it discovers in the Software to the Software developers at PNNL.

Make available to PNNL any nonproprietary improvements or modifications to the Software code (in cases where the software code is also provided). Note that modifications of the Software that are not later incorporated by PNNL into the standard version of the Software will not be

supported by PNNL. In publicizing results obtained from use of the Software, acknowledge the use of the Software

by the following citation(s):

SGM Edmonds J.A., H.M. Pitcher, and R.D. Sands (2004) The Second Generation Model: An Overview

(Pacific Northwest National Laboratory, Richland, WA. PNNL-14916).

2. User recognizes that the Software code is provided by PNNL on an as-is basis without support. Neither the U.S. Government nor the U.S. Department of Energy, nor any of their

employees, nor Battelle Memorial Institute, nor any of its affiliates or subsidiaries, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process

disclosed, or represents that its use would not infringe privately owned rights.

3. User represents and warrants that it shall not export the Software from the United States directly or indirectly without first complying with all requirements of the

Export Administration Regulations, including the requirement for obtaining any export license, if applicable.

4. In order to facilitate timely notification of Software updates and other communication with users, the User is requested not to redistribute the Software. Software

can be obtained through the web address below. Notification of Software updates and maintenance information will be provided only to those Users who register with the Joint

Global Change Research Institute (see below).

5. The USER is shall not state or imply the endorsement of PNNL, BATTELLE, or JGCRI of any results derived from use of the Software.

6. Communications with the software developers can be conducted through the following

addresses:

User Registration globalchange.umd.edu (look under “models”)

e-mail [email protected]

Postal mail Software Distribution Coordinator

Joint Global Change Research Institute Pacific NW National Laboratory and University of Maryland

8400 Baltimore Avenue Suite 201

College Park, MD 20740 USA