casasglobal-org / pbdm-workflow

Workflow to run PBDM executables compiled from Pascal source code
GNU General Public License v3.0
0 stars 0 forks source link

GisOutputInterval = 7 gives weird ASCII output #11

Closed luisponti closed 9 months ago

luisponti commented 9 months ago

GisOutputInterval is set in readinputs.pas https://github.com/casasglobal-org/pascal-pbdm-olive-demo/blob/main/oliveGIS/readinputs.pas

and used in GisOutput.pas for generating ASCII output https://github.com/casasglobal-org/pascal-pbdm-olive-demo/blob/main/oliveGIS/GisOutput.pas

In olive.pas https://github.com/casasglobal-org/pascal-pbdm-olive-demo/blob/main/oliveGIS/olive.pas

the program checks if the remainder of ModelDay divided by isOutputInterval is zero and, if the condition is met, it writes the ASCII output file:

        if( ((GisOutputInterval<>365) and ((ModelDay mod GisOutputInterval)=0) and (EndFileWritten=false)) )then DoGisOutput:=true;

ModelDay goes from 1 to ndays (it's the daily run loop in olive.pas):

ndays is the number of days included in the current model run:

    ndays:=round(ModelEndDate-ModelStartDate)+1;

In principle, it should work for any ModelDay where (ModelDay mod GisOutputInterval)=0

Not sure, @Federica1992, we might want to try with GisOutputInterval = 10 and see if the output looks better or if it makes any difference.

Meanwhile, I will try to reproduce this error on Windows to see if the bug might be related to the containerization.

luisponti commented 9 months ago

@Federica1992

Test performed using Windows machine (see system specs below) and it seems to work correctly. It generates output every seven days. See for example snippet below from OliveSummaries.txt file.

image

Note that only one OliveDaily.txt file is produced (for Villacidro, the last weather file processed), which is the normal behavior when running on a Windows machine.

I recall that the olive container in the pbdm workflow also generated multiple OliveDaily.txt files, which might be an indication of some problems with input/output or with how the executable interprets file signals of sorts.

OS Name Microsoft Windows 7 Professional
Version 6.1.7601 Service Pack 1 Build 7601
Other OS Description    Not Available
OS Manufacturer Microsoft Corporation
System Name ZEN-PC
System Manufacturer ASUSTeK Computer Inc.
System Model    UX31E
System Type x64-based PC
Processor   Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz, 1801 Mhz, 2 Core(s), 4 Logical Processor(s)
BIOS Version/Date   American Megatrends Inc. UX31E.214, 14/08/2012
SMBIOS Version  2.6
Windows Directory   C:\Windows
System Directory    C:\Windows\system32
Boot Device \Device\HarddiskVolume1
Locale  United States
Hardware Abstraction Layer  Version = "6.1.7601.24545"
User Name   zen-PC\Luigi
Time Zone   W. Europe Standard Time
Installed Physical Memory (RAM) 4,00 GB
Total Physical Memory   3,90 GB
Available Physical Memory   1,39 GB
Total Virtual Memory    7,81 GB
Available Virtual Memory    2,09 GB
Page File Space 3,90 GB
Page File   C:\pagefile.sys

olivetest.zip

luisponti commented 9 months ago

@Federica1992 I have identified and fixed the bug affecting weekly runs.

The number of output files was maximum 256 because the counter variable that gets incremented to name output files was of type Byte, an ordinal integer with range 0 to 255: https://www.freepascal.org/docs-html/3.0.2/ref/refsu4.html#x26-250003.1.1

I changed the type of that variable to a larger integer, recompiled, and now it seems to work.

Unfortunately, I had to install Windows XP Mode e Virtual PC becuase my Windows 7 professional refused to install the Delphi 3 container using compatibility mode.