A simple Fortran project

Single Fortran files can be compiled and run without creating a project. Simply open the file and press Ctrl+Shift+B to build and then Ctrl+F5 to run or use a right mouse button click and select Run to Cursor. You can change the associated compiler options using the Options dialog selected from the main Tools meanu.

When this approach is inadequate you will need to create either a project shell or a full project as follows.

In order to get started we shall create a new project containing a very simple Fortran program. Select New Project from the main File menu.

a) Select the Project Type.

b) Browse to an existing folder to hold your project source files or type in the Location of a new folder.

c) Type in the Name of the project file (we shall call this Project1). The extension (.ftn95p) will be added for you. For simplicity the project file name can be the same as the name of the folder. It will also be the default name of the target (the executable or DLL).

d) Click on the Open button to create the project.

Now we add a new item to the project. In the Project Explorer window, use the right mouse button to click on the Project1 item and then select Add New Item from the resulting popup menu.

Note the Build menu item in this popup menu that we shall use in a moment. Note also the item in the tree called References . This is used to provide references to additional libraries and DLLs when they are needed in the linking process. Select Free format source file in the resulting dialog box and type in a name for the file (we shall call this freeformat1.f95). The location is normally the project folder. Click on Open to create the file and to add it to the project. The file will be opened for you.

When the child window is maximised its name appears on a Files bar. If the Files bar is not visible, select Files Bar in the main View menu.

Type in a simple program.

Now click on Build in the Project Explorer popup menu (see above). The program is automatically compiled and linked and any error messages are reported in the Output window. After a successful build you can run the program by selecting Start from the Project Explorer popup menu (or press Ctrl+F5).

Tracking compilation error messages

If your program contains compilation errors, these appear in the Output dialog. Double click on an error line in order to go to the error in the source file.


Changing between modes

When a project is created in Plato it is automatically set to be a Win32 application in CheckMate mode. In order to change the mode, use the Configuration drop down list on the main toolbar.

Release mode can be selected when a solution is ready for use/shipping. The Debug and Checkmate modes plant debugging code that allows you to step into the code using the Silverfrost Win32 debugger (SDBG) which is automatically called by Plato. The Checkmate mode is recommended for development.

Note that you can also change from Win32 to .NET. However, for .NET it is better to use Microsoft Visual Studio because the Silverfrost plug-in for Visual Studio provides an intergrated debugger for .NET.

The simplest way to get started using SDBG is to set the cursor on a line in the program, click on the right mouse button and select Run to Cursor from the popup menu.

This launches SDBG and sets a break point at the cursor position. You can then use SDBG to view the local variables, step through the program, etc. For further information see Using SDBG.

Changing the compiler options

So far we have used the default compiler command line options based on CheckMate. Options for a project can be changed from the Project Properties dialog. Click with the right mouse button on the Project1 item in the Project Explorer window and select Properties.

This displays the Project Properties dialog that contains a section like that show below. Change the entries in this dialog in order to configure the project as a whole.

The Output File Type is one of EXE, DLL and MDL.

The linker options can also be changed from this dialog box. To do this select Linker Options from the tree on the left hand side.

When your project contains a number of files, you can set different command line options for a particular file by using the File Properties window as follows.

Click with the right mouse button on the file freeformat1.f95 in the Project Explorer window and select Properties from the popup menu.

From the Custom compiler options drop down list you can opt to Append to or Override the global project options. Now type in the options in the box labeled Custom switches. For example, if the project is set to debug rather than Checkmate mode then a particular file might be set to CheckMate mode with the following entry.

Creating a Solution

You can combine more than one project into a Plato Solution. For example, you could combine a project to create a Fortran executable together with a project to create an associated DLL that is called by the executable.

If a project is open and you then open or create another project, you are prompted to either close the existing project or create a Solution that includes the two projects. Further projects can then be added to this solution. Existing solutions can also be opened directly from the Open Project dialog.

The Project/Solution Explorer window will display the project for the currently active file. Alternatively you can right click on the current project node in the Explorer window and the popup menu provides options to view another project or remove the current project from the solution.

Plato does not provide a mechanism to build a solution as one action. You must select each project in turn and build them separately and in the right order.

Creating additional source file folders

The Project Explorer window automatically provides a node for Source Files, for Include Files and also for Resource Files. The Include and Resource File folders are automatically populated by Plato whilst you have control over the files to add to the list of Source Files.

Also you can add named folders for new grouping of your source files. Simply right click on the project node and select Add New Folder, then click on the default folder name in order to change the name to your choice. Source files can then be dragged from one folder to another.

Note also that a source file can renamed by selecting the node for the file and then using a siingle click on the node to begin editing the name. Click elsewhere to end the edit.

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited