Run C2Vsim on Linux

The California Central Valley Groundwater-Surface Water Simulation Model (C2VSim) is an integrated numerical model that simulates water movement through the linked land surface, groundwater and surface water flow systems in California’s Central Valley.

In this post I’d like to highlight the changes of the input files needed to run C2Vsim on Linux systems.

First we create a similar to *.bat file for linux e.g. an file.

Because I want to switch easily between the debug and release versions of IWFM I’ll have the script switching to debug mode when the user provides a zero input. e.g. ./ 0

At the first lines of the file I define some user input as follows

The first line is the path to the IWFM executables and the second is a temporary name whose purpose will be explained shortly.

The next part of the script identifies which version the user chooses

Next we enter the Preprocessor folder and run the preprocessing part of the program. The last line moves the output of the program to the simulation folder

Next its time to run the main simulation program. However we need to fix the input and output paths. Unfortunately linux paths are not recognized by IWFM, therefore all input and output files should be located under the simulation folder. This is as easy as to remove the ../Results/ from all input and output filenames inside the file. Once this is taken care, the follow snippet will enter the simulation folder run the model and move the output files from the Simulation folder to Results folder to keep everything neat and clean

After the simulation is finished we can run the Budget. Similar to above IWFM does not understands linux paths and we have to put the input files in the same folder as the main input. The following snippet enters the Budget directory and copies all the required inputs from results to the budget folder after appending a prefix defined by the user. This prefix will be handy later to delete those files. However we need to change the filenames of the input budget file. To do so we have to change the ..\Results\ with temp_ or any temp name defined by the user above. Next run the budget and copy the results to the ../Results folder without the prefix temp. Last we delete all the files with temp prefix to keep the folder clean

The last step is to run the Zbudget. For each budget zone we have to repeat the following lines. First we enter the Z-Budget folder and copy the required input from the Results folder to the Z-Budget folder while appending the prefix temp for the same reasons that were explained previously. We have also to modify the namefiles inside the input file as we did previously (replace the ..\Results\ with temp_). After the Zbudget code is executed the result is copied to the ../Results folder without the prefix and finally remove the temporary files.

That concludes the simulation and exit the Z-Budget folder


IMPORTANT NOTE: IWFM is case sensitive. CVPrint.dat is different from CVprint.dat


Leave a Reply

Your email address will not be published. Required fields are marked *