As an alternative to using the VBA environment in Excel, a Fortran program can also be created to generate the same results as the previous Element Statistics Example and write them to a text file. As before, the database from the dynamic analysis of Flexcom Example K1 will be used for demonstration. This example should be run in Flexcom before proceeding, in order to generate the required database files.
Firstly, create a new, empty Fortran project with a suitable name and location.
Creating an empty Fortran project
Next, add a new file by right-clicking on Source Files in the solution explorer and selecting Add and New Item. Create a Fortran Free-Form File (.f90) called Main, or otherwise, according to your own naming conventions.
Creating Main Fortran file
Similarly, add the Flexcom_Interfaces.f90 file by choosing ‘add an existing file’ and navigating to the location of the file. This file contains the procedures used during Database Access Routines.
Next, copy and paste mcsdar.lib, mcsdar.dll and seabed.dll from the Flexcom bin folder into the same folder as the .vfproj file.
Adding the required libraries and DLLs
Finally, in Visual Studio, right-click on the project name and select properties
Accessing the project properties
Navigate to the Input section under the Linker heading and insert the path to the location of mcsdar.lib into the Additional Dependencies box. It may be necessary to enclose the path in a set of inverted commas (for example, "C:\Database Access Routines\Get Positions\Get Positions\mcsdar.lib").
Including mcsdar.lib as an additional dependency in the project Linker
Within the program in Main.f90, it is necessary to include the text:
use Flexcom_interfaces
This will call the Database Access Routines located in Flexcom_Interfaces.f90 and will allow you to use the predefined Database Access procedures.
It is important to note when debugging the project using Visual Studio that the processor used corresponds to the equivalent DLLs and libraries. When debugging using the 32 bit processor, it is important to use the DLLs and libraries from the Bin folder of the 32 bit version of Flexcom. Similarly, DLLs and libraries from the 64 bit installation of Flexcom are used with the 64 bit debugging processor. The processor to be used can be selected from the drop-down on the main toolbar or in the Configuration Manager, accessed through the Build menu.
Choosing the correct debugging processor
Two sample Fortran solution files are located in the example folder. One, named Fortran (x32), should be used if you have installed the 32 bit version of Flexcom, while the second, named Fortran (x64), should be used if you have installed the 64 bit version of Flexcom. Each of the project files contain code with supplementary comments to help the reader understand the process used.
In brief, main.f90 first uses the GetDatabaseInfo function to find the number of parameters in the model. This allows the number of elements and number of timesteps to be found.
Next the GetRequestedHistory function is used to find the output analysis times in the model.
The program then loops over each element and local node number. Within this loop, the GetRequestedHistory function is used again to get the Effective Tension and Local-Y Bending Moment of the particular node. The maximum, minimum and mean Effective Tension and Local-Y Bending Moment is then calculated.
Finally, the variance, and subsequently the standard deviation, is calculated and the above results are written to a text file.