pictures/imod_logo.png

iMOD User Manual version 5.2 (html)


8.1General introduction

This chapter contains a detailed description of a library of tools or functions that is available in iMOD-Batch mode.


8.1.1What is an iMOD Batch Function?

An iMOD Function in general is a procedure to perform a specific task in iMOD or on iMOD files returning a new file or a series of files. Functions can be found on many places in the menu structure of the iMOD Graphical User Interface (GUI). For instance functions to:

An iMOD Batch Function can be used outside the iMOD GUI and its operation is controlled by parameters in an *.INI file, the initialization file.

Below you find an example of the content of a PLOT.INI file. It describes the keywords and parameters for the Function PLOT, for plotting IDF or IPF files to a PNG file.

FUNCTION=PLOT
IDFFILE=D:\DATA\AHN.IDF
GENFILE=D:\DATA\PROV.GEN
OUTFILE=D:\DATA\PLOT.PNG

In general an *.INI file contains keywords some of which are compulsory (e.g. the Function name), others are optional. iMOD searches for the keywords in the entire file so there is no fixed order of keywords allowing you to insert white lines and remarks. Examples of the set up of such an *.INI file for all available iMOD Batch function is given in the following paragraphs.

The advantage of using the iMOD Batch mode instead of the iMOD Graphical User Interface (GUI) is manifold:

The number of functions in iMOD Batch mode is expected to grow gradually. Not all functions in the iMOD GUI are (yet) available in iMOD Batch mode (e.g. create IDF from scratch). On the other hand, some functions are available in iMOD Batch mode but not in the GUI (e.g. Modelcopy).


8.1.2How to run an iMOD Batch Function?

To start an iMOD Batch procedure first open a Dos command window. How? Search for ’CMD’ in ’All Programs’ under the Windows start button pictures/h6-h71/windowsstart.png). In that DOS window, simply enter the name of the iMOD executable followed by the name of the *.INI file, e.g. "iMOD_V5_1_X64R.exe IDFSCALE.INI", (see figure 8.1) and press Enter. The program will stop after the function, described by the *.INI file, is executed.

pictures/h6-h71/iMOD-batch-in-DOS.png

Figure 8.1: Example of command in DOS box to run an iMOD Batch script.

An iMOD batch function can also be started from the maim menu. See section 4.5 for an explanation.


8.1.3Using DOS scripting (*.BAT file) to organize iMOD Batch Functions

The iMOD Batch functions can be used as described above, however, to introduce more options these functions can also be controlled in a DOS Batch file (*.BAT) using DOS scripting. Of course you can use your favourite scripting languages (e.g. Python or Matlab) to create and execute any iMOD Batch *.INI file.

This is an example of a *.BAT file creating (line 1-4) and executing (line 5) the PLOT.INI file:

ECHO FUNCTION=PLOT \(>\) PLOT.INI
ECHO IDFFILE=D:\DATA\AHN.IDF \(>\)\(>\) PLOT.INI
ECHO GENFILE=D:\DATA\PROV.GEN \(>\)\(>\) PLOT.INI
ECHO OUTFILE=D:\DATA\PLOT.PNG \(>\)\(>\) PLOT.INI
iMOD_V5_1_X64R.exe PLOT.INI

A *.BAT file is recognized in Windows as a Dos script and starts running by double clicking the *.BAT file.


8.1.4Examples of advanced DOS scripting options

Advanced DOS scripting options enables you to make more complex use of iMOD Batch functions. This paragraph gives you some examples of advances options. On the internet there are plenty sites available giving basic or advanced DOS scripting tips and tricks in more detail (e.g. http://www.robvanderwoude.com/batchcommands.php).

With the installation of iMOD an example of a *.BAT file is copied to the Tutorial folder. Search for ..\TUTORIALS \TUT_Map_Analyse \SubsoilSystem \iMOD-Batch-example-IDFCALC.BAT. Open the file, read some tips and tricks, double click and experience that this iMOD Batch function calculates the thickness of a series of 6 aquifers.

Below we describe some examples of advanced DOS scripting options.

Batch array definition
In addition to the described batch looping commands, it is also possible to define arrays within the batch environment. This might be helpful in case e.g. there are multiple files with different filenames that can be divided into a number of subgroups and that need to be processed in a similar way. For example:

SETLOCAL ENABLEDELAYEDEXPANSION
SET N=0
FOR %%A IN (KHV, KVV) DO (
SET VAR[!N!]=%%A
SET /A N+=1
) FOR /L %%I IN (0,1,1) DO (
FOR /L %%J IN (1,1,12) DO (
ECHO FUNCTION=IDFCALC \(>\) CALC_IDF.INI
ECHO FUNC= \(”\)C=A*B\(”\) \(>\)\(>\) CALC_IDF.INI
ECHO NREPEAT=1 \(>\)\(>\) CALC_IDF.INI
ECHO ABC1= \(”\)D:\MODEL\FACTOR.IDF\(”\) \(”\)D:\MODEL\DATA\!VAR[%%I]!_L%%J.IDF\(”\)
\(”\)D:\MODEL\DATA\!VAR[%%I]!_L%%J_FACTOR.IDF\(”\) \(>\)\(>\) CALC_IDF.INI

D:\IMOD_VERSIES\IMOD_V5.1\IMOD_X64R.EXE CALC_IDF.INI
))

In this example two type of files can be distinguished, files with 1. "KHV" and 2. "KVV" information. Each file category contains 12 files; one for each layer. All files need to be multiplied by specific factor grid, saved in Factor.idf. With the outer loop the file category is controlled and with the second loop the layers per category. Array definition can be applied to multiple cases and serve as a helpful tool to shorten your batch-scripts.

The iMOD Batch function are categorized into several topics related to IDF, IPF, ISG and GEN files and described on the following pages.


8.1.5iMOD Python Package

The iMOD Python package is an addition to iMOD and iMODFLOW, intended to facilitate working with groundwater models from Python. It does this by supporting reading and writing of the different iMOD file formats to existing objects often used in Python data processing.

It can be installed with “pip install imod”. The source code is freely available at https://gitlab.com/deltares/imod/imod-python. Issues with the package can be reported there, and code contributions are also welcome. Documentation can be found at https://deltares.gitlab.io/imod/imod-python/.