Distance logo

Distance Developers Guide

Visual Basic and Fortran

Jump down to:

Introduction

Distance currently has one Fortran-based analysis engine, MCDS, that does two types of analysis:


MCDS

MCDS is a standalone executable. For full details of MCDS usage, input file formats, output file formats and return codes, see Appendix - MCDS Engine Reference, Distance 6.2 Release 1 User’s Guide, p307-344


How Distance for Windows invokes MCDS

Distance for Windows invokes MCDS as follows:

C:\Programs\DISTAN~1\Ec "C:\Programs\DISTAN~1\MCDS.exe 0, C:\Users\mjj\AppData\Local\Temp\dst3C5.tmp \options 2>C:\Users\mjj\AppData\Local\Temp\dst3C4.tmp" 

Microsoft Jet database configuration

ProjectSettingsMemo table:

Section Key Setting
AnalysisEngine CDS Description=Conventional distance sampling;
Order=1;
PrpProgID=D6CDSPrp.CDSProperties;
PrpLicense=olvnunjlmlnnnlukjlmj;
EngIntProgID=D6CDSNEI.CDSNEngineInterface;
LogProgID=D6CDSDet.CDSLog;
LogLicense=cgpgobbcgbhbcb;
ResProgID=D6CDSDet.CDSResults;
ResLicense=ononwlpmlmjlmpmpqj;
ExeName=MCDS.exe;
AnalysisEngine MCDS Description=Multiple covariates distance sampling;
Order=2;
PrpProgID=D6CDSPrp.CDSProperties;
PrpLicense=olvnunjlmlnnnlukjlmj;
EngIntProgID=D6CDSNEI.CDSNEngineInterface;
LogProgID=D6CDSDet.CDSLog;
LogLicense=cgpgobbcgbhbcb;
ResProgID=D6CDSDet.CDSResults;
ResLicense=ononwlpmlmjlmpmpqj;
ExeName=MCDS.exe;
AnalysisEngineDefaultDefinition CDS “Engine=CDS;
Options;
Stratification=None;
Sample /LayerType=20;
Selection=Sequential;
Lookahead=1;
Maxterms=5;
Confidence=95;
Print=Selection;
End;
Data /Structure=Flat;
End;
Estimate;
Distance;
Density by All;
Encounter by All;
Detection by All;
Size by All;
Estimator /Key=HN /Adjust=CO /Criterion=AIC;
Monotone=Strict;
Pick=AIC;
GOF;
Cluster /Bias=GXLOG;
VarN=Empirical;
End;”
AnalysisEngineDefaultDefinition MCDS “Engine=MCDS;
Options;
Stratification=None;
Sample /LayerType=20;
Selection=Specify;
Confidence=95;
Print=All;
End;
Data /Structure=Flat;
End;
Estimate;
Distance;
Density by All;
Encounter by All;
Detection by All;
Size by All;
Estimator /Key=HN /Adjust=CO /NAP=0;
Monotone=None;
Pick=AIC;
GOF;
Cluster /Bias=GXLOG;
VarN=Empirical;
End;”

The AnalysisEngine values are as follows:

Name Value
Description Human-readable description of analysis engine
Order Position in Model Definition Properties dialog
PrpProgID Properties library and class name
PrpLicense Licence key for above value, created using GenerateLicenseKey.exe
EngIntProgID NEngine interface library and class name
LogProgID Details library and Log class name
LogLicense Licence key for above value, created using GenerateLicenseKey.exe
ResProgID Results library and class name
ResLicense Licence key for above value, created using GenerateLicenseKey.exe
ExeName Analysis engine executable name

ProjectSettingsBoolean table:

Section Key
AnalysisEngineCDS RequiresGeoObjects
AnalysisEngineCDS RunInProcess
AnalysisEngineMCDS RequiresGeoObjects
AnalysisEngineMCDS RunInProcess
AnalysisDetails UseEC

MCDS Visual Basic invocation implementation overview

Class Analysis Engines\CDS\NEngineInterface\Classes\CDSNEngineInterface.cls:

Class Analysis Engines\CDS\NEngineInterface\Classes\DatabaseInterface.cls:

Class Analysis Engines\CDS\NEngineInterface\Classes\DataFileMaker.cls:

Class Analysis Engines\CDS\NEngineInterface\Classes\InputFileMaker.cls:

Class Analysis Engines\Shared Stuff\NEngineInterfaceUtilities\Classes\CDSProcess.cls:


MCDS implementation notes

Random numbers

MCDS generates random numbers using the Compaq Visual Fortran function random_number, seeded from clock or a user-defined value. Two random number congruential generators are used. See L’Ecuyer 1988 or the Visual Fortran manual for more details.

Random numbers are used for to bootstrap resampling

Covariates

Covariates are set in the Fortran file PARAMS.INC. MAXFACS specifies the number of factor levels per covariate:

PARAMETER (SMALL1=1.0E-3, SMALL2=1.0E-10, SMALL3=1.0E-12,
...
$          MAXFACS=200,MAXCV=MAXCOVS*(MAXFACS-1))

The default is 200. One developer has tried with 50 factors which seems to work.

Stack sizes

Hexadecimal Decimal MB
800 000 8388608 8
1 000 000 16777216 16
1 400 000 20971520 20
2 800 000 41943040 40
6 400 000 104857600 100