Module mpsge

module mpsge

        ! Types
    public type line
    public type linelist
    public type symbol
    public type domain
    public type field
    public type record
    public type taxlist
    public type netput
    public type endowment
    public type endowmentlist
    public type netputlist
    public type nest
    public type nestlist
    public type function
    public type GPCoeffVarReal
    public type GPDeclaration

        ! Variables
    type (line), public, pointer :: inputfile
    type (function), public, pointer :: functionlist
    type (symbol), public, pointer :: idlist
    type (symbol), public, pointer :: idlast
    character (len=32), public :: modelname
    integer, public :: nfun = 0
    integer, public, parameter :: iomps = 10
    integer, public, parameter :: iogms = 11
    logical, public :: splitlog = .false.
    logical, public :: log = .true.
    logical, public :: readvars
    integer, public, parameter :: iotabgp = 11
    integer, public, parameter :: iocmfgp = 12
    integer, public :: NHeaderGP = 0
    integer, public :: LengthGPDeclarationName
    type (GPDeclaration), public, pointer :: GPDeclarationList
    type (GPDeclaration), public, pointer :: GPDeclarationLast

        ! Subroutines and functions
    public subroutine readmps ()
    public subroutine readline (L, input, lineno)
    public subroutine readfield (input, f)
    public subroutine lower (word)
    public subroutine upper (word)
    public subroutine tab2blank (line)
    public integer function dimension (d)
    public subroutine echoprint ()
    public subroutine parse ()
    public subroutine findid (name, id)
    public subroutine addid (name, type, s, L)
    public subroutine domaincopy (d1, d2)
    public subroutine addlineref (L, s)
    public subroutine domainadd (name, dm, L)
    public logical function indomain (s, dm)
    public logical function subset (d1, d2)
    public subroutine split (field, ident, arg, span, condtn)
    public subroutine readdomain (dtext, d, L)
    public subroutine newline (L)
    public subroutine newsymbol (s)
    public subroutine newfunction (fn)
    public subroutine newdomain (d)
    public subroutine newfield (f)
    public subroutine newrecord (r)
    public subroutine newtax (t)
    public subroutine newnetput (np)
    public subroutine newnest (n)
    public subroutine union (d1, u)
    public subroutine findsubdomain (d1, d2, subdomain)
    public logical function singleton (string)
    public subroutine writeparam (ident, index, d, string)
    public subroutine domainlabels (d, dl)
    public subroutine writedomain (d, string)
    public subroutine readvar ()
    public subroutine chkprod ()
    public subroutine chkfield (f, fieldno, pfield)
    public subroutine readnest ()
    public subroutine parsenestid (nestid, ident, parentid)
    public subroutine readcoef ()
    public subroutine nesttype (fn, n, output)
    public subroutine readelem (np, f, taxagent, lastfield)
    public subroutine sectors ()
    public logical function numeric (string)
    public subroutine addnetput (np, n, f)
    public subroutine addtax (np, t)
    public subroutine lasttax (np, t)
    public subroutine findnest (nestid, fn, n)
    public subroutine addsubnest (n, np)
    public logical function quoted (arg)
    public logical function eqv (t1, t2)
    public subroutine consumers ()
    public subroutine chkdemand ()
    public subroutine chkdfield (f, fieldno, e)
    public subroutine ConvertToGP ()
    public subroutine StartTABGP ()
    public subroutine WriteProdQuantityFormula (OutputQuantity, InputQuantity, InputsSubDomain)
    public subroutine WriteSumsGP (ThisDomain, OutputString, NSum)
    public subroutine EndSumsGP (NSum, OutputString)
    public subroutine WriteProdDemandEquation (ThisProdFunction)
    public subroutine WriteProdZeroProfitEquation (ProdDemandVariable, OutputQuantity, OutputPrice, InputQuantity, InputPrice, InputsSubDomain)
    public subroutine WriteProdUpdate (InputQuantity, InputPrice, ThisProdVar)
    public subroutine GPCommentFunction (ThisFunction)
    public subroutine NewGPCoeffVar (ThisCoeffVar)
    public logical function IsReal (ThisString)
    public subroutine GetProdTopVariableElast (ThisFunction, ThisVariable, ThisElasticity)
    public subroutine GetProdPriceQuantity (ThisFunction, IOType, ThisPrice, ThisQuantity)
    public subroutine GetInputsSubDomain (ThisFunction, ThisSubdomain)
    public subroutine ReadCoeffGP (ThisCoefficient)
    public subroutine DeclareGPCoeffVar (ThisGPCoeffVar)
    public subroutine GetProdVariableGP (ThisProdFunction, ThisVar)
    public subroutine GetDemandPriceQuantities (ThisDemandFunction, DemandPrice, DemandQuantity, DFieldExists, EndowmentPrice, EndowmentQuantity, EFieldExists, DemandTopVariable)
    public subroutine GetDemandVariableGP (ThisTopVar, EndowmentPrice, ThisDemandVar)
    public subroutine WriteDemandUpdate (ThisDemandVar, EndowmentPrice, EndowmentQuantity)
    public subroutine WriteDemandMarketClearingEquation (DemandTopVar, DemandPrice)
    public subroutine WriteDemandIncomeBalanceEquation (ThisDemandTopVar, EndowmentPrice, EndowmentQuantity, ThisDemandVar)
    public subroutine WriteArguments (FirstArg, OutputText, LenOutput)
    public subroutine WriteRecord (DescText, ThisRecord)
    public subroutine WriteField (DescText, ThisField)
    public subroutine GPSet2Index (CurrentSet, CurrentIndex)
    public subroutine MarkAsDeclaredGP (ThisSymbol)
    public subroutine ArgToAllsGP (TheseArgs, OutputString)
    public subroutine CoeffVarToGP (ThisCoeffVar, OutputString)
    public subroutine ArgToGP (TheseArgs, OutputString)
    public subroutine DeclareFieldGP (DeclarationType, ThisField)
    public subroutine WriteNest (DescText, ThisNest)
    public subroutine NewGPDeclaration (ThisGPDeclaration)
    public subroutine AddGPDeclaration (type, name)
    public logical function HasBeenDeclaredGP (type, name)

end module mpsge
Routines for constructing and manipulating general equilibrium models implemented with MPSGE

Author: Thomas Rutherford

Version: 1.0


Description of Types

line

public type line
    character (len=2048) :: text
Input records are limited to 2048 characters
    integer :: lineno
Line number in the input file
    type (record), pointer :: record
Record to which this line belongs
    type (line), pointer :: next
Pointer to the next line
end type line
Defines a line of MPSGE source code.

linelist

public type linelist
    type (line), pointer :: line
    type (linelist), pointer :: next
end type linelist
Defines a list of input lines as they have been read from the input file.

symbol

public type symbol
    character (len=31) :: name
Symbol identifier
    character (len=9) :: type
One of set, parameter, sector, commodity, consumer, auxiliary
    type (linelist), pointer :: lines
Points to lines in which this symbol appears
    type (symbol), pointer :: next
Points to next symbol in the global list
    integer :: dim
Dimension of the symbol (undefined=-1,scalar=0, vector=1, etc.)
    logical :: DeclaredGP
Whether this has been declared in the GEMPACK TAB file
end type symbol
Elements of the symbol table include various MPSGE variables (commodity prices, sectoral activity level, consumer incomes and auxiliary variables). The symbol table also includes sets and parameters which are encountered in the input file. This list is maintained to provide some context checking on input.

domain

public type domain
    type (symbol), pointer :: s
Pointer to this set in the symbol table
    type (domain), pointer :: next
Pointer to the next set in this domain (unassociated if no more dimensions)
    integer :: dim
Dimension of this domain
end type domain
A domain is simply a list of sets. This list may include quoted singletons as well as references to GAMS sets. Each element of the set is represented by a pointer to the set in the symbol table

field

public type field
    character (len=255) :: label
Verbatim text of leading label
    character (len=255) :: data
Verbatim text of following field
    character (len=255) :: identtext
Identifier text (data excluding domain and condition)
    character (len=255) :: argtext
Substring text of the identitier argument domain if present
    character (len=255) :: spantext
Substring text of the spanning domain if present (# notation)
    character (len=255) :: condtn
Substring text of the conditional clause if present
    type (symbol), pointer :: ident
Pointer to field idenfier if the field is readable. Fields beginning with "(" are skipped.
    type (domain), pointer :: arg
Pointer to argument domain if it is readable
    type (domain), pointer :: span
Points to span domain if it is present
    type (line), pointer :: line
Points to source line
    type (field), pointer :: next
Pointer to next field in the data file. The final field in a datafile is unassociated.
end type field
An MPSGE input file consists of a series of records. Each record is composed of one or more fields. An input field consist of a label and some field text. A field in an MPSGE model consists of two primary components: the label and the field data. The field data in turn consists of the identifier, the identifier argument, the spanning sets and the condition clause.

record

public type record
    type (field), pointer :: firstfield
Points to the first field in this record
    type (line), pointer :: line
Points to the input line where this record begins.
    integer :: nfield
Counts the number of fields in this record
    type (record), pointer :: next
end type record
This type describes a record in an MPSGE function, possibly spanning multiple lines if there are continuations (lines "+" in the first column)

taxlist

public type taxlist
    type (field), pointer :: a
Pointer to A: field which identifes agent who collects this tax revenue:
    type (field), pointer :: t
Pointer to T: field which defines an exogenous ad-valorem tax rate:
    type (field), pointer :: n
Pointer to N: field indicating the auxiliary variable which determines the ad-valorem tax rate. For a given tax entry, either T: or N: will be used, but not both:
    type (field), pointer :: m
Pointer to an M: field defining the multiplier which is to be applied on the previously listed endogenous tax. An M: field must follow immediately after an N: field.
    type (taxlist), pointer :: next
Next tax applied on the same production input or output. This is unassociated if there are no more applicable taxes:
end type taxlist
A tax coefficient on a production input or output consists of:

netput

public type netput
    type (field), pointer :: f
Pointer to the I: or O: field
    type (field), pointer :: qref
Pointer to the associated Q: field in the same record
    type (field), pointer :: pref
Pointer to the associated P: field in the same record
    type (domain), pointer :: d
Pointer to the domain of this netput
    type (domain), pointer :: sd
Pointer to the subdomain of the netput
    type (taxlist), pointer :: t
Pointer to the taxes which apply to this netput
    character (len=1024) :: nestcount
    integer :: nestfields
    logical :: output
Logical flag for an output coefficient
    integer :: index
Integer index associated with this netput
end type netput
This type defines an input or output in a production block. The domain associated with a netput consists of the union of sets in the function declaration block and the commodity price. For example, if we have
 
      $prod:y(i,t)
              o:p(j,t)        q:y0(i)
              ...
 
then the domain of the netput, d, is (i,t,j), and the subdomain of the netput, sd, is (j).

endowment

public type endowment
    type (field), pointer :: f
Pointer to the E: field
    type (field), pointer :: q
Pointer to the Q: field
    type (field), pointer :: r
Pointer to the R: field
    type (domain), pointer :: d
Pointer to the domain of the endowment
    type (domain), pointer :: sd
Pointer to the subdomain of the endowment
    integer :: index
end type endowment

endowmentlist

public type endowmentlist
    type (endowment), pointer :: e
    type (endowmentlist), pointer :: next
end type endowmentlist
List of endowment records

netputlist

public type netputlist
    type (netput), pointer :: np
Netput at this location in the list
    type (field), pointer :: f
Nest assignment field
    type (netputlist), pointer :: next
Pointer to next element in list (nul if last input)
end type netputlist
List of netputs references from the associated nest.

nest

public type nest
    character (len=255) :: ident
Identifier text for this nest
    character (len=255) :: parentid
Identifier text for the parent nest
    character (len=255) :: value
Text field of the elasticity value
    logical :: output
Logical flag identifies type of nest (output or input)
    type (field), pointer :: f
Pointer to the input field which defines the nest
    type (nest), pointer :: parent
Pointer to parent nest
    type (nestlist), pointer :: nlist
Pointer to parent nestlist entry
    type (netputlist), pointer :: elements
Pointer to a list of constituent inputs or outputs
    type (nestlist), pointer :: subnests
Pointer to a list of constituent nests
    type (nest), pointer :: next
Pointer to next nest in current function
    integer :: index
Integer index associated with this nest
    integer :: level
Level in the nesting structure (top level = 0)
    logical :: assigned
Flag that all the logic for this nest has been written
end type nest
Nest type characterizes a CES nest in a cost function.

nestlist

public type nestlist
    type (nest), pointer :: n
Pointer to a nest in this list
    type (nestlist), pointer :: next
Pointer to next element of the list
end type nestlist
Linked list of nests used to represent the nested CES substitution structure:

function

public type function
    type (record), pointer :: firstrecord
Pointer to first input record in this function
    integer :: nrecord
Count of number of records in this function
    integer :: nfield
Count of number of fields in this function
    type (nest), pointer :: inputs
Points to the top level input nest
    type (nest), pointer :: outputs
Points to the top level output nest
    type (field), pointer :: demand
Points to the demand field
    type (endowmentlist), pointer :: endowments
Points to the endowments declared in this $demand block
    type (function), pointer :: next
Pointer in linked list of all functions
end type function
An MPSGE production or demand function

GPCoeffVarReal

public type GPCoeffVarReal
    character :: type
    character (len=15) :: name
    type (domain), pointer :: arg
end type GPCoeffVarReal

GPDeclaration

public type GPDeclaration
    character (len=2) :: type
'cs' for Coeff, 'vc' for Variable, 'eq' for equation
    character (len=LengthGPDeclarationName) :: name
Coeff/Var/EQuation name
    type (GPDeclaration), pointer :: next
Pointer to the next declaration in this list
end type GPDeclaration

Description of Variables

inputfile

type (line), public, pointer :: inputfile
Pointer to first line in the linked list of input file lines

functionlist

type (function), public, pointer :: functionlist
Pointer to the first function in linked list

idlist

type (symbol), public, pointer :: idlist
Pointer to the first symbol

idlast

type (symbol), public, pointer :: idlast
Pointer to the last symbol

modelname

character (len=32), public :: modelname

nfun

integer, public :: nfun = 0
Number of functions in the MPSGE file

iomps

integer, public, parameter :: iomps = 10
Unit number of the MPSGE file

iogms

integer, public, parameter :: iogms = 11
Unit number of the resulting GAMS file

splitlog

logical, public :: splitlog = .false.
Flag for log output of field parsing operation

log

logical, public :: log = .true.
Flag for general log output

readvars

logical, public :: readvars
Flag for current input ot declaration records

iotabgp

integer, public, parameter :: iotabgp = 11
Unit number of the output GEMPACK TAB file

iocmfgp

integer, public, parameter :: iocmfgp = 12
Unit number of the output GEMPACK Command file

NHeaderGP

integer, public :: NHeaderGP = 0
Number of headers data is read from in TAB file

LengthGPDeclarationName

integer, public :: LengthGPDeclarationName

GPDeclarationList

type (GPDeclaration), public, pointer :: GPDeclarationList
Pointer to first in list

GPDeclarationLast

type (GPDeclaration), public, pointer :: GPDeclarationLast
Pointer to last in list

Description of Subroutines and Functions

readmps

public subroutine readmps ()
    ! Calls: newfield, newfunction, newrecord, readfield, readline
end subroutine readmps
Master routine to read an MPSGE input file: None of the logical structure of the underlying economic model is formulated at this stage.

readline

public subroutine readline (L, input, lineno)
    type (line), pointer :: L
    character (len=*) :: input
    integer :: lineno
    ! Calls: newline, tab2blank
end subroutine readline
Read to the next non-blank line from the input file, incrementing the line count:

readfield

public subroutine readfield (input, f)
    character (len=*) :: input
    type (field), pointer :: f
    ! Calls: lower
end subroutine readfield
Read the last field from a line of input, using the colon to locate the label and the data components:

lower

public subroutine lower (word)
    character (len=*) :: word
Character to be placed in lower case.
end subroutine lower
Fold a character string to lower case.

upper

public subroutine upper (word)
    character (len=*) :: word
Character to be placed in upper case.
end subroutine upper
Fold a character string to upper case.

tab2blank

public subroutine tab2blank (line)
    character (len=*) :: line
Line to scan for tabs
end subroutine tab2blank
Convert tabs on an input line to spaces:

dimension

public integer function dimension (d)
    type (domain), pointer :: d
Domain to be evaluated
end function dimension
Evaluate the dimension of a domain by counting the number of set identifiers in the linked list defining the domain:

echoprint

public subroutine echoprint ()
end subroutine echoprint
Generate an echoprint of the file. This is currently very preliminary, and will later be recoded to produce a more carefully formatted report.

parse

public subroutine parse ()
    ! Calls: findid, readdomain, split
end subroutine parse
Parse all fields in the file into constituent elements:

findid

public subroutine findid (name, id)
    character (len=*), intent(in) :: name
Identifier for the symbol to be located
    type (symbol), pointer :: id
Pointer into the master list for the located symbol.
end subroutine findid
Return pointer to given identifier

addid

public subroutine addid (name, type, s, L)
    character (len=*), intent(in) :: name
Name of the identifier to be added to the master list
    character (len=*), intent(in) :: type
Description of the type of item to be introduced:
  • set: a GAMS set identifier
  • parameter : a GAMS parameter identifier
  • sector : an MPSGE sector (acivity variable)
  • commodity : an MPSGE commodity (price variable)
  • consumer : an MPSGE consumer (income variable)
  • auxiliary : an MPSGE auxiliary variable
    type (symbol), pointer :: s
    type (line), pointer :: L
    ! Calls: newsymbol
end subroutine addid
Introduce a new identifier in the master list.

domaincopy

public subroutine domaincopy (d1, d2)
    type (domain), pointer :: d1
Domain to be copied
    type (domain), pointer :: d2
New domain to be created as a copy of d1
    ! Calls: newdomain
end subroutine domaincopy

addlineref

public subroutine addlineref (L, s)
    type (line), pointer :: L
Line in which the symbol is referenced
    type (symbol), pointer :: s
Symbol which is referenced
end subroutine addlineref
Add an entry in the linked list of line numbers which refer to a given symbol.

domainadd

public subroutine domainadd (name, dm, L)
    character (len=*), intent (in) :: name
Identier of set to be added to the domain
    type (domain), pointer :: dm
Domain to which this set is to be introduced
    type (line), pointer :: L
Line in which the set reference was made.
    ! Calls: addid, addlineref, findid, newdomain
end subroutine domainadd
Add a set element to the domain

indomain

public logical function indomain (s, dm)
    type (symbol), pointer :: s
Set to be located
    type (domain), pointer :: dm
Domain in which the set is to be located.
end function indomain
Logical function which reports whether a set with a given name is in a domain:

subset

public logical function subset (d1, d2)
    type (domain), pointer :: d1
Subset domain
    type (domain), pointer :: d2
Superset domain
end function subset
Tets whether one domain (d1) is a subst of another (d2).

split

public subroutine split (field, ident, arg, span, condtn)
    character (len=*), intent(in) :: field
    character (len=*), intent(out) :: ident
    character (len=*), intent(out) :: arg
    character (len=*), intent(out) :: span
    character (len=*), intent(out) :: condtn
end subroutine split
Split up an input field into the constituent elements

readdomain

public subroutine readdomain (dtext, d, L)
    character (len=*), intent(in) :: dtext
Domain to be parsed
    type (domain), pointer :: d
Pointer to the domain list
    type (line), pointer :: L
Pointer to source line
    ! Calls: domainadd, lower
end subroutine readdomain
Read a domain and parse into a series of set elements.

newline

public subroutine newline (L)
    type (line), pointer :: L
end subroutine newline
Allocate a new line and assign default values

newsymbol

public subroutine newsymbol (s)
    type (symbol), pointer :: s
end subroutine newsymbol
Allocate a new symbol and assign default values for all the symbol characteristics

newfunction

public subroutine newfunction (fn)
    type (function), pointer :: fn
end subroutine newfunction
Allocate a new function pointer with default values

newdomain

public subroutine newdomain (d)
    type (domain), pointer :: d
end subroutine newdomain
Allocate a new domain pointer with default values

newfield

public subroutine newfield (f)
    type (field), pointer :: f
end subroutine newfield
Allocate a new field with default values

newrecord

public subroutine newrecord (r)
    type (record), pointer :: r
end subroutine newrecord
Allocate a new record with default values

newtax

public subroutine newtax (t)
    type (taxlist), pointer :: t
end subroutine newtax
Allocate a new tax record with default values

newnetput

public subroutine newnetput (np)
    type (netput), pointer :: np
end subroutine newnetput
Allocate a new netput with default values

newnest

public subroutine newnest (n)
    type (nest), pointer :: n
end subroutine newnest
Allocate a new nest with default values

union

public subroutine union (d1, u)
    type (domain), pointer :: d1
    type (domain), pointer :: u
    ! Calls: newdomain
end subroutine union
Add d1 to union, excluding quoted singletons

findsubdomain

public subroutine findsubdomain (d1, d2, subdomain)
    type (domain), pointer :: d1
    type (domain), pointer :: d2
    type (domain), pointer :: subdomain
    ! Calls: newdomain
end subroutine findsubdomain
Determine the subdomain of d1 in d2, i.e. those element of d1 which are not in d2:
 
                  subdomain = d1 \ (d1 ^ d2)
 
The output is the set of elements in d1 which are not singletons and not in d2.

singleton

public logical function singleton (string)
    character (len=*) :: string
end function singleton

writeparam

public subroutine writeparam (ident, index, d, string)
    character (len=*) :: ident
    integer :: index
    type (domain), pointer :: d
    character (len=*) :: string
    ! Calls: writedomain
end subroutine writeparam

domainlabels

public subroutine domainlabels (d, dl)
    type (domain), pointer :: d
    character (len=32), dimension (10) :: dl
end subroutine domainlabels

writedomain

public subroutine writedomain (d, string)
    type (domain), pointer :: d
    character (len=*) :: string
end subroutine writedomain

readvar

public subroutine readvar ()
    ! Calls: addid, findid
end subroutine readvar
Read through variable declarations

chkprod

public subroutine chkprod ()
    ! Calls: chkfield
end subroutine chkprod
Read through records for each of the functions and add symbols to the master list as they are encountered. Check that the input data conforms to syntax rules.

chkfield

public subroutine chkfield (f, fieldno, pfield)
    type (field), pointer :: f
    integer :: fieldno
    logical :: pfield
    ! Calls: addid, findid
end subroutine chkfield
Evaluate fields in a production block record: - identifier dimension and type must be consistent - i: and o: must only appear as leading fields and reference prices - q: field must be second and reference a parameter - p: fields may appear only once and must reference parameter - a: field must reference a consumer - n: field must reference an auxiliary variable - m: field must reference a parameter - t: field must reference a parameter

readnest

public subroutine readnest ()
    ! Calls: addsubnest, findnest, newnest, parsenestid
end subroutine readnest
Read nest assignments from the first record of each $prod block

parsenestid

public subroutine parsenestid (nestid, ident, parentid)
    character (len=*) :: nestid
Identifier for nest
    character (len=*) :: ident
Identifier of the nest itself
    character (len=*) :: parentid
Identifier of the nest parent
end subroutine parsenestid
Split a nest elasticity field into a nest identifier and a parent identifier:

readcoef

public subroutine readcoef ()
    ! Calls: addnetput, findid, findnest, findsubdomain, nesttype, newfield, newnetput, readelem, union
end subroutine readcoef
Read through the production function coefficients: - Create netput descriptions of each production input and output - Create linked list data structure characterizing the nested CES function

nesttype

public subroutine nesttype (fn, n, output)
    type (function), pointer :: fn
Function we fare looking at
    type (nest), pointer :: n
Nest from which to trace
    logical :: output
Flag for whether this is an output nest
end subroutine nesttype
Introduce type definitions for nests beginning at n and proceeding to the top of the tree.

readelem

public subroutine readelem (np, f, taxagent, lastfield)
    type (netput), pointer :: np
Netput to which this should be assigned
    type (field), pointer :: f
Field for which logic is to be introduced
    type (field), pointer :: taxagent
Field which defines applicable tax agent field
    type (field), pointer :: lastfield
Pointer to the previous field in this record (if one)
    ! Calls: addtax, lasttax
end subroutine readelem
Read a single field and introduce the associated logic in a netput descriptor:

sectors

public subroutine sectors ()
    ! Calls: findid
end subroutine sectors
Create symbol table entries for the production sectors

numeric

public logical function numeric (string)
    character (len=*) :: string
String to be evaluated (.true. if a Fortran-readable numeric value)
end function numeric
Determine which a string is numeric:

addnetput

public subroutine addnetput (np, n, f)
    type (netput), pointer :: np
Netput to be added
    type (nest), pointer :: n
Nest in which the netput is to be introduced
    type (field), pointer :: f
Field in which the nest assignment is made (for condition if any)
end subroutine addnetput
Add a netput to a nest.

addtax

public subroutine addtax (np, t)
    type (netput), pointer :: np
Netput to which tax is applied
    type (taxlist), pointer :: t
Pointer to the tax field
    ! Calls: lasttax, newtax
end subroutine addtax
Add a tax coefficient to the associated linked list for a production netput:

lasttax

public subroutine lasttax (np, t)
    type (netput), pointer :: np
Netput to be queried
    type (taxlist), pointer :: t
On output points to the last tax coefficient
end subroutine lasttax
Set pointer to the last tax applied to a given netput:

findnest

public subroutine findnest (nestid, fn, n)
    character (len=*) :: nestid
String descriptor of the nest to be located
    type (function), pointer :: fn
Function in which to locate the nest
    type (nest), pointer :: n
Pointer to the located nest
end subroutine findnest
Generate a pointer to the nest with a given name in a particular function:

addsubnest

public subroutine addsubnest (n, np)
    type (nest), pointer :: n
Nest to be added as a subnest
    type (nest), pointer :: np
Nest to which the subnest is to be introduced
end subroutine addsubnest
At a subnest to a nest. This requires creation of a nestlist if one does not already exist

quoted

public logical function quoted (arg)
    character (len=*) :: arg
end function quoted
Returns .true. if the argument is quoted text, i.e. a character string beginning and ending with a pair of single or double quotes.

eqv

public logical function eqv (t1, t2)
    character (len=*) :: t1
    character (len=*) :: t2
end function eqv
Public function determines whether two strings are identical apart from case.

consumers

public subroutine consumers ()
end subroutine consumers

chkdemand

public subroutine chkdemand ()
    ! Calls: chkdfield, findsubdomain, union
end subroutine chkdemand
Read through records for each of the demand functions and add symbols to the master list as they are encountered. Check that the input data conforms to syntax rules.

chkdfield

public subroutine chkdfield (f, fieldno, e)
    type (field), pointer :: f
    integer :: fieldno
    type (endowment), pointer :: e
    ! Calls: addid, findid
end subroutine chkdfield
Evaluate fields in a demand block record:

ConvertToGP

public subroutine ConvertToGP ()
    ! Calls: DeclareGPCoeffVar, GPCommentFunction, GetDemandPriceQuantities, GetDemandVariableGP, GetInputsSubDomain, GetProdPriceQuantity, GetProdTopVariableElast, GetProdVariableGP, ReadCoeffGP, StartTABGP, WriteDemandIncomeBalanceEquation, WriteDemandMarketClearingEquation, WriteDemandUpdate, WriteNest, WriteProdDemandEquation, WriteProdQuantityFormula, WriteProdUpdate, WriteProdZeroProfitEquation, WriteRecord, findid
end subroutine ConvertToGP

StartTABGP

public subroutine StartTABGP ()
    ! Calls: upper
end subroutine StartTABGP

WriteProdQuantityFormula

public subroutine WriteProdQuantityFormula (OutputQuantity, InputQuantity, InputsSubDomain)
    type (GPCoeffVarReal) :: OutputQuantity
    type (GPCoeffVarReal) :: InputQuantity
    type (domain), pointer :: InputsSubDomain
    ! Calls: ArgToAllsGP, CoeffVarToGP, EndSumsGP, WriteSumsGP
end subroutine WriteProdQuantityFormula

WriteSumsGP

public subroutine WriteSumsGP (ThisDomain, OutputString, NSum)
    type (domain), pointer :: ThisDomain
    character (len=*), intent(out) :: OutputString
    integer, intent(out) :: NSum
    ! Calls: GPSet2Index
end subroutine WriteSumsGP

EndSumsGP

public subroutine EndSumsGP (NSum, OutputString)
    integer, intent(in) :: NSum
    character (len=*), intent(out) :: OutputString
end subroutine EndSumsGP

WriteProdDemandEquation

public subroutine WriteProdDemandEquation (ThisProdFunction)
    type (function), pointer :: ThisProdFunction
    ! Calls: AddGPDeclaration, ArgToAllsGP, CoeffVarToGP, GetProdPriceQuantity, GetProdTopVariableElast, GetProdVariableGP
end subroutine WriteProdDemandEquation

WriteProdZeroProfitEquation

public subroutine WriteProdZeroProfitEquation (ProdDemandVariable, OutputQuantity, OutputPrice, InputQuantity, InputPrice, InputsSubDomain)
    type (GPCoeffVarReal) :: ProdDemandVariable
    type (GPCoeffVarReal) :: OutputQuantity
    type (GPCoeffVarReal) :: OutputPrice
    type (GPCoeffVarReal) :: InputQuantity
    type (GPCoeffVarReal) :: InputPrice
    type (domain), pointer :: InputsSubDomain
    ! Calls: ArgToAllsGP, CoeffVarToGP, EndSumsGP, WriteSumsGP
end subroutine WriteProdZeroProfitEquation

WriteProdUpdate

public subroutine WriteProdUpdate (InputQuantity, InputPrice, ThisProdVar)
    type (GPCoeffVarReal), intent(in) :: InputQuantity
    type (GPCoeffVarReal), intent(in) :: InputPrice
    type (GPCoeffVarReal), intent(in) :: ThisProdVar
    ! Calls: ArgToAllsGP, CoeffVarToGP
end subroutine WriteProdUpdate

GPCommentFunction

public subroutine GPCommentFunction (ThisFunction)
    type (function), pointer :: ThisFunction
end subroutine GPCommentFunction

NewGPCoeffVar

public subroutine NewGPCoeffVar (ThisCoeffVar)
    type (GPCoeffVarReal) :: ThisCoeffVar
end subroutine NewGPCoeffVar

IsReal

public logical function IsReal (ThisString)
    character (len=*) :: ThisString
end function IsReal

GetProdTopVariableElast

public subroutine GetProdTopVariableElast (ThisFunction, ThisVariable, ThisElasticity)
    type (function), pointer :: ThisFunction
    type (GPCoeffVarReal) :: ThisVariable
    type (GPCoeffVarReal) :: ThisElasticity
    ! Calls: findid
end subroutine GetProdTopVariableElast

GetProdPriceQuantity

public subroutine GetProdPriceQuantity (ThisFunction, IOType, ThisPrice, ThisQuantity)
    type (function), pointer :: ThisFunction
    character, intent(in) :: IOType
    type (GPCoeffVarReal) :: ThisPrice
    type (GPCoeffVarReal) :: ThisQuantity
end subroutine GetProdPriceQuantity

GetInputsSubDomain

public subroutine GetInputsSubDomain (ThisFunction, ThisSubdomain)
    type (function), pointer :: ThisFunction
    type (domain), pointer :: ThisSubdomain
end subroutine GetInputsSubDomain

ReadCoeffGP

public subroutine ReadCoeffGP (ThisCoefficient)
    type (GPCoeffVarReal) :: ThisCoefficient
    ! Calls: upper
end subroutine ReadCoeffGP

DeclareGPCoeffVar

public subroutine DeclareGPCoeffVar (ThisGPCoeffVar)
    type (GPCoeffVarReal), intent(in) :: ThisGPCoeffVar
    ! Calls: DeclareFieldGP, newfield, newsymbol
end subroutine DeclareGPCoeffVar

GetProdVariableGP

public subroutine GetProdVariableGP (ThisProdFunction, ThisVar)
    type (function), pointer :: ThisProdFunction
    type (GPCoeffVarReal) :: ThisVar
    ! Calls: GetProdPriceQuantity, GetProdTopVariableElast
end subroutine GetProdVariableGP

GetDemandPriceQuantities

public subroutine GetDemandPriceQuantities (ThisDemandFunction, DemandPrice, DemandQuantity, DFieldExists, EndowmentPrice, EndowmentQuantity, EFieldExists, DemandTopVariable)
    type (function), pointer :: ThisDemandFunction
    type (GPCoeffVarReal), intent(out) :: DemandPrice
    type (GPCoeffVarReal), intent(out) :: DemandQuantity
    logical :: DFieldExists
    type (GPCoeffVarReal), intent(out) :: EndowmentPrice
    type (GPCoeffVarReal), intent(out) :: EndowmentQuantity
    logical :: EFieldExists
    type (GPCoeffVarReal), intent(out) :: DemandTopVariable
    ! Calls: lower
end subroutine GetDemandPriceQuantities

GetDemandVariableGP

public subroutine GetDemandVariableGP (ThisTopVar, EndowmentPrice, ThisDemandVar)
    type (GPCoeffVarReal), intent(in) :: ThisTopVar
    type (GPCoeffVarReal), intent(in) :: EndowmentPrice
    type (GPCoeffVarReal), intent(out) :: ThisDemandVar
end subroutine GetDemandVariableGP

WriteDemandUpdate

public subroutine WriteDemandUpdate (ThisDemandVar, EndowmentPrice, EndowmentQuantity)
    type (GPCoeffVarReal), intent(in) :: ThisDemandVar
    type (GPCoeffVarReal), intent(in) :: EndowmentPrice
    type (GPCoeffVarReal), intent(in) :: EndowmentQuantity
    ! Calls: ArgToAllsGP, CoeffVarToGP
end subroutine WriteDemandUpdate

WriteDemandMarketClearingEquation

public subroutine WriteDemandMarketClearingEquation (DemandTopVar, DemandPrice)
    type (GPCoeffVarReal), intent(in) :: DemandTopVar
    type (GPCoeffVarReal), intent(in) :: DemandPrice
    ! Calls: ArgToAllsGP, CoeffVarToGP, GetProdPriceQuantity, GetProdTopVariableElast, lower
end subroutine WriteDemandMarketClearingEquation

WriteDemandIncomeBalanceEquation

public subroutine WriteDemandIncomeBalanceEquation (ThisDemandTopVar, EndowmentPrice, EndowmentQuantity, ThisDemandVar)
    type (GPCoeffVarReal), intent(in) :: ThisDemandTopVar
    type (GPCoeffVarReal), intent(in) :: EndowmentPrice
    type (GPCoeffVarReal), intent(in) :: EndowmentQuantity
    type (GPCoeffVarReal), intent(in) :: ThisDemandVar
    ! Calls: CoeffVarToGP, EndSumsGP, WriteSumsGP
end subroutine WriteDemandIncomeBalanceEquation

WriteArguments

public subroutine WriteArguments (FirstArg, OutputText, LenOutput)
    type (domain), pointer :: FirstArg
    character (len=255) :: OutputText
    integer :: LenOutput
end subroutine WriteArguments

WriteRecord

public subroutine WriteRecord (DescText, ThisRecord)
    character (len=*), intent(in) :: DescText
    type (record), pointer :: ThisRecord
    ! Calls: WriteField
end subroutine WriteRecord

WriteField

public subroutine WriteField (DescText, ThisField)
    character (len=*), intent(in) :: DescText
    type (field), pointer :: ThisField
    ! Calls: WriteArguments
end subroutine WriteField

GPSet2Index

public subroutine GPSet2Index (CurrentSet, CurrentIndex)
    type (symbol), pointer :: CurrentSet
    character (len=*) :: CurrentIndex
end subroutine GPSet2Index

MarkAsDeclaredGP

public subroutine MarkAsDeclaredGP (ThisSymbol)
    type (symbol), pointer :: ThisSymbol
    ! Calls: lower
end subroutine MarkAsDeclaredGP

ArgToAllsGP

public subroutine ArgToAllsGP (TheseArgs, OutputString)
    type (domain), pointer :: TheseArgs
    character (len=*), intent(out) :: OutputString
    ! Calls: GPSet2Index
end subroutine ArgToAllsGP

CoeffVarToGP

public subroutine CoeffVarToGP (ThisCoeffVar, OutputString)
    type (GPCoeffVarReal) :: ThisCoeffVar
    character (len=*), intent(out) :: OutputString
    ! Calls: ArgToGP, upper
end subroutine CoeffVarToGP

ArgToGP

public subroutine ArgToGP (TheseArgs, OutputString)
    type (domain), pointer :: TheseArgs
    character (len=*), intent(out) :: OutputString
    ! Calls: GPSet2Index
end subroutine ArgToGP

DeclareFieldGP

public subroutine DeclareFieldGP (DeclarationType, ThisField)
    character (len=*), intent(in) :: DeclarationType
    type (field), pointer :: ThisField
    ! Calls: AddGPDeclaration, ArgToAllsGP, ArgToGP, MarkAsDeclaredGP, lower, upper
end subroutine DeclareFieldGP

WriteNest

public subroutine WriteNest (DescText, ThisNest)
    character (len=*) :: DescText
    type (nest), pointer :: ThisNest
    ! Calls: WriteField
end subroutine WriteNest

NewGPDeclaration

public subroutine NewGPDeclaration (ThisGPDeclaration)
    type (GPDeclaration), pointer :: ThisGPDeclaration
end subroutine NewGPDeclaration
Allocate a new GPDeclaration and assign default values for all the characteristics

AddGPDeclaration

public subroutine AddGPDeclaration (type, name)
    character (len=*), intent(in) :: type
    character (len=*), intent(in) :: name
    ! Calls: NewGPDeclaration
end subroutine AddGPDeclaration
Introduce a new GPDeclaration in the master list.

HasBeenDeclaredGP

public logical function HasBeenDeclaredGP (type, name)
    character (len=*), intent(in) :: type
    character (len=*), intent(in) :: name
    ! Calls: lower
end function HasBeenDeclaredGP