Topic: How do I structure the Progress Bar example

What do I need to do to make the Progress bar example work?

I tried the Main Program code shown in the example here: https://approximatrix.wordpress.com/201 … pgraphics/

That main code throw an error because of a missing "progress.mod"

I saw the code above the Main Program - code for the progress bar broken up by descriptions. In another example, the one for creating a graph, even though coding parts were broken up by description, at the end, the whole exampled could be copied and run (on the Mac). But that appears to not be the case with Progress Bar.

I looked at the code above the main program and didn't see any exact "progress" label. Was the code above just saved as a .mod file and named "progress". If so, I must have missed any reference to that.

It looks like I could copy the progress bar code lines out from the descriptions but the last line is just:
call bar(5, 25, progress_completed+5, 50)
with no sort of end/return or termination line under it.

Do I copy everything from:
type progresswindow
to:
call bar(5, 25, progress_completed+5, 50)
and save that in a txt file named progress.mod
Then add Progress.mod to the project file list?

Just trying to get some solid ground on the PC side. I didn't see anything about "mod" in the documentation list. I do have a Fortran 90/95 and an older Fortran 77 reference coming - but I'm sure those deal the language itself. I'm looking for info on the setup/organization of the SF environment.

My world is like ... This is a Main Program, it's saved in a file what has to have a .f90 (.etc) extension and is added to the Project outline. This is a Subroutine. It begins and ends like this .. It can be embedded in the main program - best practices are at the beginning but could be anywhere - or it can be saved in a module (text file whose name ends .mod) and that text file is added to the files under the project outline. Is there some SF documentation that explains things like that?

Thinking back decades, I might have worked in some environments where modules (collections of subroutines) could undergo some kind of "pre-compile" so they were just linked in and didn't add to the compile time of the main program. Maybe it was another language.

Re: How do I structure the Progress Bar example

At the end of the example are two source files:

Both files must be added to a project.  The progress bar example is a bit more complex than other examples, so it is broken in to two separate files.

Modules in Fortran code are defined in Fortran source files.  So the file progress.f90 contains a module.  When you compile this file, the compiler produces a file "progress.mod" that contains human-unreadable code defining some aspects of the module.  Module files are never written by hand.  The documentation really doesn't talk much about files ending in ".mod" because they are effectively useless to the user; they are only used by the compiler and the build system.

Jeff Armstrong
Approximatrix, LLC

Re: How do I structure the Progress Bar example

Jeff, thank you - that’s what I recall from past Fortran/Basic compilers I’ve used (over 20 years ago!). The “units” are Fortran source that is compiled to another file (.mod) and those files are added to the project. I’m sorry I missed those two source files. I’ll use the links you provided above and also review the Wordpress page again to see where I missed the links there.

Re: How do I structure the Progress Bar example

I thought it would compile and coordinate both files at the same time - but I now know I have to compile the mod file as a separate step - learning curve stuff.

When I compiled the progress.f90 file, I thought it would result in a file with .mod as an extension or somewhere in the name. As it doesn't, then it's up to me to carefully name my files so later (sometimes months and months) I easily identify the mod files?

Also, there was a bit of screen flash in the example. Have there been any improvement to refine that to a smoother rendition? Just ask'n.

Re: How do I structure the Progress Bar example

I think you might still be a little confused about .mod files.  A Fortran source file that declares a "module" will, when compiled, produce a .mod file for every module present in that Fortran source file as well as an object file.  For example, if I have a file subs.f90 that contains:

module m_first

    contains
    ...
end module m_first

module m_second

    contains
    ...
end module m_second

I will get the following files produced when I compile it:

  • subs.o - The compiled Fortran object file

  • m_first.mod - Information produced by the compiler about the public interfaces in the module m_first

  • m_second.mod - Information produced by the compiler about the public interfaces in the module m_second

The module files are extremely compiler-specific, but they do not contain any object code.  They should be thought of a compiler-readable descriptions of a Fortran module.

Now I might have a second Fortran file main.f90 that makes use of one of the modules:

program main
use m_first
implicit none

    ...
end program main

In order for the compiler to compile main.f90, it needs to know how to deal with/what's available in a module named m_first.  To find this information, it looks for a file m_first.mod and reads it in.

In this simple example, you may have noticed something important.   The file subs.f90 must be compiled first to produce the module description prior to compiling main.f90.  That means, if we're working on the command line, the following will not work:

gfortran -o main.exe main.f90 subs.f90

but the following will work:

gfortran -o main.exe subs.f90 main.f90

If you're using the Simply Fortran development environment directly, and main.f90 and subs.f90 are in the same project, Simply Fortran will know that it must ensure that subs.f90 should be compiled first.  Simply Fortran will also effectively hide the .mod files in a subdirectory during builds because they're not really of any use (unless you start talking about integrating multiple projects together, but don't worry about that).

You should never be adding module files (ending in .mod) to a project.  Simply Fortran will ignore them.  You also don't need to pass them to the compiler directly.  It will find the ones it needs or complain if they aren't present.

Jeff Armstrong
Approximatrix, LLC

Re: How do I structure the Progress Bar example

Okay, that makes sense. I created a new project (ProgressBar.prj) and added progress.f90 and prmain.f90.

Then I saved the project and went through the build. And, as you'd expect, it threw and error because there was no .mod file. So I did a build on the progress.f90 file first. From what I understand above, that created the necessary .mod file in a subdirectory. I see it now in a sub folder inside the project folder.

But the name of the file that contains the "use" routines stays the same. It's up to me to remember, if there are several files, if they've been compiled or not - though I'll certainly be "reminded" when I compile the main program. ... getting there ....

Re: How do I structure the Progress Bar example

designer wrote:

Then I saved the project and went through the build. And, as you'd expect, it threw and error because there was no .mod file. So I did a build on the progress.f90 file first. From what I understand above, that created the necessary .mod file in a subdirectory. I see it now in a sub folder

I don't exactly understand what you're saying happened here.  If you have a project file with those two Fortran source files in it, you should be able to select "Build Project" from the build menu, and everything will just work.  I do not expect the behavior you're describing at all.  How did you manage to do "a build on the progress.f90 file first?"  Was this from within the development environment somehow?

I'm afraid I don't understand the steps you're taking at all.  Can you send the project file and the generated makefile to support@approximatrix.com?  Something is clearly wrong.

Jeff Armstrong
Approximatrix, LLC

Re: How do I structure the Progress Bar example

Jeff - I'll try to repeat the steps first. Today has been a rough "computer day" with ISP issues. I'll try to repeat tonight for tomorrow at the latest.

Re: How do I structure the Progress Bar example

System Win7 Professional
SimplyFortran 3.10, build 3202

Jeff - it works as advertised this time around. This time I didn't open anything. I just put the two downloads in the Project Outline panel, saved the project, then ran a build and a launch.

I believe it gave me grief the first time because I double clicked a file to see the code. So on Build, it only built the open file (probably it was prmain) instead of both of them.

Now I know better - or rather understand that if a file is open, only that file will be built an not the others in the panel.