Compiling with CVF
From MohidWiki
Please follow these instructions step by step and until the end:
Contents
Creating a new project
- Make sure you have installed in your computer Microsoft Visual Studio 6.0 (Compaq Visual Fortran 6 Developer Studio) and Compaq Visual Fortran 6.6c. If you don’t have both installed, please install them.
- Get your HDF5 libraries (*.libs) and modules (*.mod) files from Source Safe (folder named "\Libs").
- Open the Compaq Visual Fortran 6 Developer Studio.
- Select "File... New".
- Select the Projects tab.
- Create a Fortran Console Application. Name it "MohidWater" for example, and define a path to the folder where you want to place the project. Click OK.
- Get all FORTRAN code files from SourceSafe and add them to the project. Right-click in the Source Files folder (in the project tree), and select "Add Files To Folder...". Add all the files containing the modules. For example, to compile MohidWater, add all files in folders Mohid_Base_1, Mohid_Base_2 and MohidWater. Other projects may need modules from Mohid_Base_1, Mohid_Base_2.
- Note that the files mpif.f90, GOTMVariables_in.f90 and GOTMVariables_out.f90 are NOT to be included in the project. These files are INCLUDE files which means they must be placed in the same folder as the rest of source code files. Also the file "ModuleSequentialAssimilation.f90" is only to be included in the project if the optional compilation directives for this code are active. Normally they are not, so don't include the module in the project.
Release settings
Please follow the steps below and set them EXACTLY as they are presented. Do not make additional changes in the settings unless you’re testing some optimizations. Note that settings under "Debug" and "Release" configurations are slightly different. Please select "Release" configuration and apply this settings first.
- Select "Project...Settings"
- Select the "Fortran" tab
- Select "Compilation Diagnostics" in the dropdown box
- Check ALL the check boxes ("Argument Mismatch", "Data Alignment", etc)
- Set the "Fortran Standards Checking" to "Fortran 95"
- Select "Floating Point" in the dropdown box
- Set "Floating Point Exception Handling" to "3*". NOTE: This will enable your executable to create and work with NaN. If you set the value to "0" the program will stop when NaN are created, but it will run slower.
- Select "PreProcessor" in the dropdown box
- Write the path to the HDF5 libraries in "INCLUDE and USE Paths" text box
- Check "Use FPP" check box
- Select the "Link" tab
- For the "Input" item in the "Category" dropdown box, write the path to the HDF5 libraries in "Additional library paths" text box
- For the "General" and "Input" items in the "Category" dropdown box, add the following line in the “Object/library modules” text box:
kernel32.lib hdf5.lib hdf5_hl.lib hdf5_fortran.lib zlib.lib szlib.lib
Debug settings
Use the default settings for a "Debug" application and perform the same steps as for the "Release" configuration, except in the following step:
- Select "Project...Settings...Fortran"
- Select "Floating Point" in the dropdown box
- Set "Floating Point Exception Handling" to "0".
Build
- Select "Build...Build [name of the executable]"
Optional compilation settings
To perform optional compilation, just add the compilation pre-processor keywords in "Project...Settings...Fortran...PreProcessor", in the "Predefined Preprocessor Symbols" text box.
Exclude modules
Some modules can be completely excluded from compilation. If your simulations do not use these modules you can use this pre-processor keywords.
_LAGRANGIAN_ excludes Modules Lagrangian + Jet + Oil _AIR_ excludes Modules InterfaceWaterAir + Atmosphere _WAVES_ excludes Module Waves _SEDIMENT_ excludes Modules SedimentProperties + Consolidation
Compile with MPI
In order to compile Mohid with MPI you must include the following pre-processor keyword. See more on Compiling Mohid with MPI
_USE_MPI includes MPI code
Compile with OpenMP
See more on Compiling Mohid with OpenMP.
Other options
Other keywords can also be used.
_SHORT_LINE_LENGTH sets line_length = 64 (default line_length is 256) _LONG_LINE_LENGTH sets line_length = 1024(default line_length is 256) _GUI_ includes GUI code
Stack reserve settings
This option enables you to reserve more RAM to your executable which is useful when running "heavy" simulations. You can normally find out you need this if you get an error in your simulation process saying "stack overflow". To do this follow these steps:
- Select "Project...Settings"
- Select the "Link" tab
- Select "Output" in the "Category" dropdown box
- In the "Stack allocations" area, define e.g. 64000000(or more) in the "Reserve" text box.
Additional Developer Studio settings
- Select "Tools...Options"
- Select "Tabs" tab
- Select "Fortran" in the dropdown box
- Select "Insert spaces" radio button