Previous Page Table of Contents Next Page


Chapter 6
Program AEZCCS05 LP Report Writer

Program AEZCCS05 reads the output from the AEZ land productivity assessment (program AEZCCS03) and the solution file LPSOL generated by the LP package to print out summary tables at a level of detail as indicated in the control file. It can be meaningful to call the program repeatedly with the same LP solution file but modified control parameters, e.g. to investigate the consequences of alternative soil conservation levels on the long term production potential.

6.1 Program Logic and Overview

Program AEZCCS05 resembles in many aspects the LP Matrix Generator AEZCCS04 discussed in the previous chapter. There are, however, important differences.

Both programs use the same scenario control input data, file CTRL$$$, (subroutine CTRLIN) where the user specifies the mode of operation and, optionally, a set of constraints. Aggregation indices, conversion weights and various technical coefficients at different levels of aggregation are read from a data set as specified on the scenario control file (subroutine L0ADT1). Then, the livestock systems definition tables are processed (subroutine LOADT2), and crop specific input requirements in table function format are read into memory (subroutine LOADTM). Several data buffers are cleared (subroutine CLRALL) which are to hold output summary statistics.

The program logic consists of two nested loops. The outer loop runs over land inventory records, the inner loop over crop combination records within a cell.

The main program loop starts with reading the cell information record from the productivity assessment file, an unformatted sequential file created by program AEZCCS03 (subroutine CELLIN). Then, basic accounting of cell extents takes place (subroutine ACCALC), the applicable population density is retrieved, and the crop combination records relating to the current cell are copied to a temporary working file (subroutine TBGET).

The temporary file is re-read and the crop combination records are processed (subroutine CMBIN). Each crop combination record is tested for non-zero activity level in the LP solution (subroutine LPSOL). If applicable, various land area counters are updated (subroutine ACCALC), and production from the currently considered crop combination is determined (subroutine QCCALC). The input requirements for production in terms of seeds, fertilizer, power and pesticides are derived from the technology matrix (subroutine INPUTS) and the respective weight in the objective function of the LP is calculated (function OBJFUN). The aggregate land use and production counters are updated (subroutine UPDCNT).

FIGURE 6.1
Information flow in program AEZCCS05

After having processed all the crop combination records available in the current land inventory cell, the program proceeds with reading the next cell information record continuing this operation cycle until all cells have been read and dealt with.

Finally, the program turns to the livestock activities (subroutine LVSIN). While processing all the crop combination information, the program also calculates and aggregates data on feed supply by livestock zone. This information is used to generate livestock zone and livestock system specific feed balances and production accounts (subroutine QLCALC).

If no errors or infeasibilities have been detected so far, the program ends with printing detailed information on land use, crop choice, production, yields, feed balances and input requirements, comparing supported population densities to estimated base year (1980 in the Kenya Case Study) and projected population densities in the year 2000 (subroutine LPTAB).

The print file contains information on land use by cell, crop tables showing land classes, yields and production under bad, average, and good climatic conditions, livestock production accounts, input requirement tables, and a district summary. The information flow in program AEZCCS05 is shown in Figure 6.1.

6.2 Input/Output File Sizes and Connections

Unit NrFile nameFileb)typeRecord length  (bytes)Number of recordsa)File size  (bytes)I/Oc) mode
5CTRL$$$e)FS80VR
6PRINTERFS132V-W
9OUT$$$e)FS132V≤ 1 MbW
10LPSOLd)FS36V≤ 128 KbR
11POPDISTUR118801041235520R
12EXTENTSUR5940104617710R
18SUMMARYUR197491233573 KbRW
10COMMDATFS80132≤ 1000R
10LVSDATFS8055≤ 1000R
10TECHMATFS8045636480R
17SCR305d)US≤ 125V≤ 32 KbRW
19BIN.$ $ $e)US≤ 56V≤ 10 MbR

a) ‘V’ indicates a variable, district or country specific number of records.

b) FS = formatted sequential, UR = unformatted random access, US = unformatted sequent.

c) R = input, W = output.

d) The size of the temporary working file SCR305 and the size of the LP solution file LPSOL largely depend on the complexity of the land inventory and the number of admissible crop combinations that have to be processed but are small compared to overall disk requirements of the AEZ-CCSpackage.

e) ‘$$$’ in file names BIN.$$$ and OUT.$$S has to be replaced by the respective three digit district codes.

6.3 Subprogram Description

Name :AEZCCS05
Type:Main program
Purpose :LP Report Writer program for population supporting capacity assessment.
Called by :none
Calls to :CELLIN, CLRALL, CMBIN, CTRLIN, LPSOL, LPTAB, LVSIN, TBGET
Arguments :none
Box Ref. :1.6
  
Name :ACCALC (nflag)
Type:subroutine
Arguments :integer
 nflag : routine control flag
Purpose :Set up cell acreage counters.
Called by :CMBIN, TBGET
Calls to :CLR4BR
Box Ref. :5.13*
  
Name :CELLIN (eof, nfeas)
Type:subroutine
Arguments :integer*2, integer*2
 eof : end-of-file indicator
 nfeas : number of feasible crops in current cell
Purpose :Read in land inventory record from unformatted sequential file.
Called by :MAIN
Calls to :none
Box Ref. :5.4
  
Name :CLRALL
Type:subroutine
Arguments :none
Purpose :Clear and initialize relevant data buffers.
Called by :MAIN
Calls to :CLR4BR, CLR8BR
Box Ref. :5.2
  
Name :CLR2BI (buf, n, val)
Type:subroutine
Arguments :integer*2(), integer, integer
 buf : data buffer to be initialized
 n. : number of elements to be initialized
 val : value to be assigned to data buffer elements
Purpose :Initialize a specified number of elements of a two byte integer array to a given value.
Called by :CMBIN, CTRLIN, L0ADT2
Calls to :none
Box Ref. :none
  
Name :CLR4BI (buf, n, val)
Type:subroutine
Arguments :integer*40, integer, integer
 buf : data buffer to be initialized
 n : number of elements to be initialized
 val : value to be assigned to data buffer elements
Purpose :Initialize a specified number of elements of a four byte integer array to a given value.
Called by :CTRLIN
Calls to :none
Box Ref. :none
  
Name :CLR4BR (buf, n, val)
Type:subroutine
Arguments :real*4(), integer, real*4
 buf : data buffer to be initialized
 n. : number of elements to be initialized
 val : value to be assigned to data buffer elements
Purpose :Initialize a specified number of elements of a four byte real array to a given value.
Called by :ACCALC, CLRALL, CTRLIN, INPUTS, L0ADT2, LPTAB, LVSIN, QCCALC, QLCALC, UPDCNT
Calls to :none
Box Ref. :none
  
Name :CMBIN
Type:subroutine
Arguments :none
Purpose :Read in and process crop combination records relevant in current cell.
Called by :MAIN
Calls to :ACCALC, CLR2BI, LPSOL, QCCALC, UPDCNT
Box Ref. :5.6
  
Name :CTRLIN
Type:subroutine
Arguments :none
Purpose :Read scenario control file and open required files.
Called by :MAIN
Calls to :CLR2BI, CLR4BI, CLR4BR, ERROR, L0ADT1, L0ADT2, LOADTM
Box Ref. :5.1
  
Name :DIVI (a, b)
Type:real*4 function
Arguments :real*4, real*4
 a : nominator
 b.:denominator
Purpose :Divide a by b checking for floating zero divide.
Called by :LPTAB
Calls to :none
Box Ref. :5.19
  
Name :ERROR (ityp, ifatal)
Type:subroutine
Arguments :integer, integer
 ityp : error code
 ifatal : error level
Purpose :Display an error message.
Called by :CTRLIN, LOADT1, LOADT2
Calls to :none
Box Ref. :5.12*
  
Name :INPUTS (icrp, yield, req)
Type:subroutine
Arguments :integer, real*4, real*40
 icrp : crop code
 yield : crop yield
 req : input requirements
Purpose :Interpolate input requirements from table functions given in technology matrix.
Called by :QCCALC, QLCALC
Calls to :CLR4BR, ISGLYS, TMIDX, TTAB
Box Ref. :5.20*
  
Name :ISGLYS (islu)
Type:logical function
Arguments :integer*2
 islu : soil unit code
Purpose :Is soil a Gleysol ?
Called by :INPUTS
Calls to :none
Box Ref. :5.23
  
Name :ISLITH (iphs)
Type:logical function
Arguments :integer*2
 iphs : soil phase code
Purpose :Is soil phase of type lithic ?
Called by :INPUTS
Calls to :none
Box Ref. :5.26
  
Name :ISRFED (kfirst)
Type:logical function
Arguments :integer
 kfirst : first crop in sequential crop combination
Purpose :Check if land can be used for rainfed production.
Called by :TBGET
Calls to :none
Box Ref. :5.15
  
Name :LOADT1
Type:subroutine
Arguments :none
Purpose :Load crop specific conversion factors and weights.
Called by :CTRLIN
Calls to :ERROR
Box Ref. :5.9
  
Name :LOADT2
Type:subroutine
Arguments :none
Purpose :Load livestock systems parameters.
Called by :CTRLIN
Calls to :CLR2BI, CLR4BR, ERROR
Box Ref. :5.10
  
Name :LOADTM
Type:subroutine
Arguments :none
Purpose :Load technology matrix.
Called by :CTRLIN
Calls to :none
Box Ref. :5.11
  
Name :LPSOL (ctype, ncol, ierr)
Type:real*4 function
Arguments :character*l, integer*4, integer
 ctype : constraint type indicator
 ncol : routine control flag
 ierr : error return code
Purpose :Extract relevant activity level from file LPSOL.
Called by :CMBIN, LVSIN, MAIN
Calls to :none
Box Ref. :5.3*
  
Name :LPTAB
Type:subroutine
Arguments :none
Purpose :Tabulate district results and save on scenario summary file.
Called by :MAIN
Calls to :CLR4BR, CLR8BR, DIVI
Box Ref. :5.8
  
Name :LVSIN
Type:subroutine
Arguments :none
Purpose :Evaluate livestock systems and prepare for summary tables.
Called by :MAIN
Calls to :CLR4BR, LPSOL, QLCALC
Box Ref. :5.7
  
Name :OBJFUN (mode, kfirst, qval, pcost)
Type:real*4 function
Arguments :integer, integer, real*4, real*4
 mode : routine control flag, program mode
 kfirst : first crop in sequential crop combination
 qval : production value
 pcost : production cost
Purpose :Return weight of current activity in linear objective function.
Called by :QCCALC, QLCALC
Calls to :none
Box Ref. :5.21*
  
Name :PYLOSS (sloss, ithz, days, islu, iphs)
Type:real*4 function
Arguments :real*4, integer*2, integer*2, integer*2, integer*2
 sloss : annual soil loss
 ithz : thermal zone code
 days : number of days in LGP
 islu : soil unit code
 iphs : soil phase code
Purpose :Convert estimated soil loss to productivity loss.
Called by :TBGET
Calls to :ISLITH
Box Ref. :5.16
  
Name :QCCALC
Type:subroutine
Arguments :none
Purpose :Calculate production, input requirements, and value of objective function for a given sequential crop combination.
Called by :CMBIN
Calls to :CLR4BR, INPUTS, OBJFUN, TLUFCT
Box Ref. :5.17
  
Name :QLCALC
Type:subroutine
Arguments :none
Purpose :Calculate production, feed requirements, and value of objective function for a given livestock system.
Called by :LVSIN
Calls to :CLR4BR, INPUTS, OBJFUN
Box Ref. :5.7
  
Name :TBGET
Type:subroutine
Arguments :none
Purpose :Set up cell specific yet crop combination independent information.
Called by :MAIN
Calls to :ACCALC, ISRFED, PYLOSS, UPDCNT
Box Ref. :5.5
  
Name :TLUFCT (itech)
Type:real*4 function
Arguments :integer
 itech : input level indicator
Purpose :Return pasture/livestock productivity adjustment factor.
Called by :QCCALC
Calls to :none
Box Ref. :5.22
  
Name :TMIDX (days, isglys, yldfct)
Type:integer function
Arguments :integer*2, logical, real*4
 days : number of days in LGP
 isglys : gleysol indicator
 yldfct. : productivity factor
Purpose :Return land class index for look-up in technology matrix.
Called by :INPUTS
Calls to :none
Box Ref. :5.24
  
Name :TTAB (yld, kr, lc, req)
Type:subroutine
Arguments :real*4, integer, integer, real*4()
 yld : crop yield
 kr : index of crop in technology matrix
 lc : land class index
 req : input requirements
Purpose :Look up input requirements in technology matrix.
Called by :INPUTS
Calls to :none
Box Ref. :5.25
  
Name :UPDCNT (nflag)
Type:subroutine
Arguments :integer
Purpose :Update counters holding district totals.
Called by :CMBIN, TBGET
Calls to :CLR4BR
Box Ref. :5.14*

6.4 Program Control Data, File CTRL$$$

Each AEZCCS program is controlled by a short input data file which is usually read from standard input. Refer to section 5.4 in the previous chapter for a discussion of scenario control input data file CTRL$$$ which is used for both, to run LP Matrix Generator program AEZCCS04 and LP Report Writer program AEZCCS05.

6.5 Commodity Aggregation Data, File COMMDAT

Refer to section 5.5 of the previous chapter for a description of input file COMMDAT containing three record types, CF, CQ, and AG, which refer to three different levels of commodity aggregation, namely, crop list, agricultural production, and aggregate food commodity list, respectively. Each record type contains commodity name information and technical coefficients such as conversion weights and extraction coefficients. Examples of record formats taken from the Kenya Case Study can be found in Appendix D.

6.6 Livestock System Definition Data, File LVSDAT

This text file contains three record types, LZ, LS, and LQ, which refer to livestock zone definition records, livestock system definition, and livestock product definition, respectively. Refer to section 5.6 in the previous chapter for a description of the record formats and to Appendix D for examples.

6.7 Technology Matrix, File TECHMAT

Refer to section 5.7 in the previous chapter for a description of input file TECHMAT containing crop, land class, and technology specific input requirements in terms of seeds, fertilizer, power, and pesticides.

6.8 Scenario Summary Tables, File OUT$$$

Depending on the setting of control parameter IPRINT the LP Report Writer Program generates scenario summary tables at different levels of detail. Information can be obtained on cell-wise characteristics and use, summary tables in terms of the three commodity levels considered in the model, i.e. crop level, agricultural production level, aggregate final food consumption level, livestock system feed balance and production tables, and a district summary table. Examples 6.1 to 6.4 show selected results obtained for South Nyanza district in Kenya under a food maximizing strategy at intermediate level of inputs.

EXAMPLE 6.1
District summary table. South Nyanza district, food maximizing strategy
DISTRICT SUMMARY : # SOUTH NYANZA DISTRICT (601) - NYANZA PROVINCE
    
District Population (present)945000
District Population (projected)1919903
  
Calories from Rainfed Production 1471951
Calories from Irrigated Production 0
Total Calories from Agric. Production 1471951
    
Protein from Rainfed Production 42348
Protein from Irrigated Production 0
Total Protein from Agric. Production 42348
    
Calories/cap/day (MIN, AVG, MAX)97021003011
Protein /cap/day (MIN, AVG, MAX)273604859
Calorie/Protein Ratio (MIN, AVG, MAX)35.634.835.1
    
Present Population Density (cap/ha)1.606
Projected Population Density (cap/ha)3262
Supported Population Density (cap/ha)2.954
    
Present / Supported Density0.544
Projected / Supported Density1.105
    
Land Use Statistics : 
 hapercent
District Area588500100.0
-Urban Area70771.2
Agriculture Land58142398.8
-Irrigated Land00.
Rainfed Land581423988
-Forest/Park Land6980.1
-Non-Suitable Land130212.2
-Idle Land00.0
-Range Land24660641.9
-NS-Range Land00.
Arable Land282435480
-Fallow Land6387210.9
Area Harvested, primary21856237.1
Area Harvested, secondary174300
Area Harvested, total392863
Cropping Intensity1.797

EXAMPLE 6.2
Final product supply. South Nyanza district, food maximizing strategy
Final Product Supply
COMMODITYSupplyTarget%
1CEREALS273390273394100.0
2PULSES3148631486100.0
3ROOTS140150140153100.0
4SUGAR2457524575100.0
5OILS1114672016.5
6BANANAS1232341961462.8
7FUELWD191990191990100.0
8MEAT100923494228.9
9MILK140150140153100.0
10EGGS19201920100.0

EXAMPLE 6.3
Food production statistics. South Nyanza district, food maximizing strategy
COMMODITYAcreagae (ha)Yields (kg/ha)Production (mt)
P.HarvFallowArable S.HarvT.HarvMINAVG MAXMINAVG MAXIrrgtdTotal
BRARLEY424211175359190461472081000161812796149994406149
MAXEE11924134594153634132400251640396117217931000582950294510690295029
MILLET779320369633135902138518656468039021248216615012482
RICE566618947561820613873451912122462511264616977012646
SORGH12409344615857109332334217051690139661210121020012101
WHEAT89624911441133202916967813613431761280101781
GRAM00093937111123971022010
GRNDNT3809968477626396449416624146026645313941705313
BEANS0001412141250292391714135530413
PIGPEA20484611726601352051979616662057163803422742216034227
SOYBEAN0001734173449193254853344410334
CASSAVA9093252211615090937547946610426686298607494601066074
SW.POT1010114154423557013403
WH.POT604018527693221626121601005314757135226295192390062951
BANANA14290441518705014290911110146147691301961449812113260144961
SUGCANE9874325113125098742298024668273702269072457502702460245750
TOTAL21364162466276306174300386141

EXAMPLE 6.4
Crop production statistics. South Nyanza district, food maximizing strategy

 Land Productivity classesProduction (mt)yields (kg/ha)
CROP> 8080–6060–4040–2020–0P.HarvFallowArableS.HarvT.HarvMINAVGMAXMINAVGMAX
BARL 10160757913427144242111753591885612812736125991320810001618
BARL 20000000019196233129812391642
MAIZ l8609035125204512209158682795947287693791366136589870361975271255
MAIZ 296272932911502102113758562699341184623212085449806734173357991178
MAIZ 383049522017132685058638175477618528064867024459714428819607351416642261
MAIZ 419124237514060392311925116155141943813355314844258268716202191
MAIZ 5191287942832296096492982126313509999104762797344160104827974416
MAIZ 60170033565102687813350002687212697451330579136274952
MAIZ 700231820313944070313186914112159629253585
MAIZ 809010001083314101084815720544514501896
MAIZ 900508186069420890206941271538218818422183154
MLLT 100282111201395369176413214146097934854913854332625
MLLT 201128351217600640016688068376677631897627967747111261428
RICE 10000000 2669266947713632013179511754
RICE 206201943020056512656421362181169552172991888881174
RICE 3000000004274270732440171570
RICE 40000000073730268503501167
RICE 500271394903662124349058234485460456627335102712621635
SRGH 10198315465063151719803410698170132219691713087130407769
SRGH 200569452705096143365293451301400345755972736741091
SRGH 300000000201201 28132178141657888
SRGH 40007707719970773011216539014512130
SRGH 50009210921277119809212911482199331516092164
WHEA 10048160820226104610761896290151124381537971286
WHEA 2760000762399571335227036339520362740
GRAM 10000000093937102271111239
GRND 100164716366133448574201263959832129413878253566921308
GRND 2337129000465111577046555411751592119125253420
BEAN 100000000134413447139152253291388
BEAN 2000000006868022300322447
PIGP 10006062835426912147218279
PIGP 20333818713335245154067850275780771069652615402039 
PIGP 31661497091501523245761980801523213617261403150889417162069
SOYB 100000000173417348533444149193254
CASV2419531561555609093252211615090936862986074948017547946610426
SPOT 30001010101134141544235570
WPOT 1003643203969949520416675195046471622468711166
WPOT 200271175044612056604462297303244885147679210054
WPOT 3910179252915800519816336831200539810550579698325519541073815422
BANANA010810458372401429044151870501429013019614498121132891111014614789
SUGCAN00155783180987432511312509874226907245750270248229802488827370
COTTON003444377047211407612804721      
GRASS0310781841854959142151246606184272650330246606579916637741650736235225862639
ACACSEN0045127401319147146601319172920912157131115851635
CALICAL0001110111121230111180208213162518801925
CASUCUN01616260029132324029191210171052313034913612
LEUCLEU007979233390434340390013031533033383927
SESBSES05112647106588732732006588264252731828190401141474279
EUCACAM0023693501171130130101171052006118044425225
EUCAGLO033140582412597257806806307257314953685638852434050795354
EUCAGRA0131313044013070145214523013070932629420397968713572077495
EUCASAL01522943570460051151110460055432379427225120551725918
CROPS27343588869414109269125821856263872282435174300392863      
PASTURE0310781841854959142151246606184272650330246606      
TREES08286932355149234798386638664034798      

References

FAO, 1976. A Framework for Land Evaluation, FAO Soils Bulletin 32, FAO, Rome. FAO, 1978–81. Report on the Agro-ecological Zones Project, Vols. 1–4, Methodology and Results for Africa, World Resources Report 48/1, FAO, Rome. FAO, 1984. Population Supporting Capacity Assessment Kenya, Mission Report, AGL,

FAO, Rome. FAO, 1987. World Agriculture: Toward 2000, FAO, Report No. C87/27, Rome. IBM. Mathematical Programming System - Extended (MSPX), and Generalized Upper Bounding (GUB), IBM Document No. SH20-0968-1, IBM Corporation, New York.

Murtagh, B.A. and Saunders, M.A. 1977. MINOS - A Large Scale Nonlinear Programing System, Technical Report SOL 77–9, Stanford University, California.


Previous Page Top of Page Next Page