|
|
|
|
||
|
DEFINITION MODULE LolaIO; (******************************************************************* Module LolaIO (Version 1.0) Copyright (c) 2004-2006 by Dimitrios Gyalistras and ETH Zurich. Purpose File input/output of binary data stored in "longitude-latitude" ("lola") format. Remarks References: Waszkewitz, J., Lenzen, P. & Gillet, N. (1996). The PINGO package (Procedural INterface for Grib formatted Objects) - Version 1.1. Deutsches Klimarechenzentrum (DKRZ) Technical Report No. 11, Hamburg, Germany, 214pp. http://www.mad.zmaw.de/Pingo/pingohome.html Programming o Design Dimitrios Gyalistras 12/08/2004 o Implementation Dimitrios Gyalistras 12/08/2004 ETH Zurich Systems Ecology CHN E 35.1 Universitaetstrasse 16 8092 Zurich SWITZERLAND URLs: <mailto:RAMSES@env.ethz.ch> <http://www.sysecol.ethz.ch> <http://www.sysecol.ethz.ch/SimSoftware/RAMSES> Last revision of definition: 29/08/2004 DG *******************************************************************) FROM DMFiles IMPORT TextFile; FROM LgMatrices IMPORT LVector; IMPORT Errors; (**************************************) (*##### General declarations #####*) (**************************************) CONST (* result codes returned *) allOk = Errors.allOk; reachedEof = Errors.userBase + 1; notDone = Errors.onlyAnInsert; CONST MaxCoords = 180; TYPE CoordsList = ARRAY [1..MaxCoords] OF LONGREAL; LolaHeaderRec = RECORD date : LONGINT; time : LONGINT; code : LONGINT; level : LONGINT; nLon : LONGINT; nLat : LONGINT; nListedLon : LONGINT; nListedLat : LONGINT; info1 : LONGINT; info2 : LONGINT; lon : CoordsList; lat : CoordsList; END; (**************************************) (*##### Auxiliary procedures #####*) (**************************************) PROCEDURE ClearLolaHeaderRec( VAR hdr: LolaHeaderRec ); PROCEDURE CalcCoordsListsFromSectorInfo( nX, nY : LONGINT; inputsInDegrees : BOOLEAN; (* FALSE: minLon, minLat, cellSize are given in CH meters grid *) minLon : LONGREAL; minLat : LONGREAL; cellSize : LONGREAL; VAR nLon : LONGINT; VAR nLat : LONGINT; VAR nListedLon : LONGINT; VAR nListedLat : LONGINT; VAR lon : CoordsList; VAR lat : CoordsList; VAR resCode : INTEGER; VAR errTxt : ARRAY OF CHAR ); PROCEDURE CalcSectorInfoFromCoordsLists( nLon : LONGINT; nLat : LONGINT; nListedLon : LONGINT; nListedLat : LONGINT; lon : CoordsList; lat : CoordsList; resultsInDegrees : BOOLEAN; (* FALSE: minLon, minLat, cellSize are given in CH meters grid *) VAR nX, nY : LONGINT; VAR minLon : LONGREAL; VAR minLat : LONGREAL; VAR cellSize : LONGREAL; VAR resCode : INTEGER; VAR errTxt : ARRAY OF CHAR ); (*************************************) (*##### File I/O procedures #####*) (*************************************) PROCEDURE ReadLolaRecord( VAR inFile : TextFile; (* must be open for reading *) VAR hdr : LolaHeaderRec; VAR data : LVector; (* is newly allocated if too small *) VAR resCode : INTEGER; VAR errTxt : ARRAY OF CHAR ); PROCEDURE WriteLolaRecord( VAR outFile : TextFile; (* must be open for writing *) VAR hdr : LolaHeaderRec; (* VAR for speed-up only *) data : LVector; VAR resCode : INTEGER; VAR errTxt : ARRAY OF CHAR ); END LolaIO.
|
||
|
|
|