Topic: Warnings and errors...part II

Hi,

I am not an experienced programmer. I do mostly minor changes to existing programs. Up until recently, I was using Fortran Power station 4 but upgrading my computer to Windows 7 64bits made it impossible to use it anymore. Snif!

I found Simply Fortran a few months ago and it was simple to install and to work with. I was able to load my files and compile my program (I am recompiling the hydrological model SWAT: http://swatmodel.tamu.edu/software/swat-model/).  I got a few errors at first but managed to make them disappear. For example a variable declaration would not be recognized. I had to delete and rewrite or to push le line to the 7th column. I now only have warnings, quite a number, but only warnings.  However, my executable is much slower than it used to be (execs compiled with Fortran Power Station  4 & previous trials with Simply Fortran).

Is the slowness due to the numerous warnings I get or are there settings I could use to speed up the execution of my program?

Here are the warnings I mostly get. I am not too worried about variable or dummy unused. The changes in values are not that important either. Could you help me decipher what the others are?

1.    Nonconforming tab character at (1)
2.    Unused variable ‘whatever’ declared at (1)
3.    ‘functionname’ declared at (1) is also the name of an intrinsic. It can only be called via an explicit interface or if declared EXTERNAL
4.    Possible change of value in conversion from REAL(8) to REAL(4) at (1)
5.    Line truncated at (1)  -- ! I managed to put all within col 7 to 76 as it seems it accepts to code only within these columns. Why?
6.    Label 6 at (1) defined but not used
7.    Unused dummy argument ‘name’ at (1)
8.    CHARACTER expression will be truncated in assignment (10/13) at (1) (see line below)
      reccnstps = '             '

Also, sometimes error messages appear where the syntax is the same as elsewhere and I don’t get error messages there. For example, why is this telling me Invalid character in name at line (1)? Or Expected expression in WRITE statement at (1)? Then I rewrite it the same way and I get no error!!!!
       write (100,*) 'year',';','day',';','hru',';','cmass',';','sol_rsd',
    &   ';','mancmass'

Thank you for you help.

Isabelle

Re: Warnings and errors...part II

Isabelle,

I would first try changing some settings.  By default, the target processor is "generic," meaning the code should actually work on an i386 (extremely dated) and no optimizations are enabled.  If you open the Compiler Options dialog from the Options menu, you can change most of these settings.  I would suggest the following:

1. From the Target CPU box, select "native" rather than generic.  The code should now be tuned for your system

2. Disable debugging using the appropriate checkbox

3. Enable some costly optimizations using -O2 or -O3 in the Fortran Compiler flags.  You can either select them in the dropdown or type them yourself. 

The online help actually has some more details of the optimization settings if you select the topic "Options That Control Optimization" under "GCC Command Options." 

The combination of the suggestions above will hopefully give you an initial, sizable speed improvement.

Now the warnings you are seeing shouldn't affect execution speed, generally speaking (at least those you've outlined).  Unused variables and arguments aren't really a big deal, and the tab character warnings are a reminder of the GNU developers' strict adherence to standards.

The error you're seeing with the "write" statement is indeed puzzling.  Do you get the error in the editor, or does it appear when you perform a build?  If you see the error in the editor while working, it can occasionally be due to the transient nature of the editor contents and possibly incomplete code being passed into the compiler for syntax checking as you type.  The real-time syntax checking isn't "ideal" yet, so you might be experiencing a bug, which I will certainly look into.

Jeff Armstrong
Approximatrix, LLC

Re: Warnings and errors...part II

Hi Jeff,

I did what you said. I then cleaned and recompiled the program and retried it. It is still very very slow. A previous version runs in 1 hour. My version takes all day! 

I have copied 1 of the 324 lines of the build process. As I am not sure what all this means. So I am asking once again some help.

""C:\Program Files (x86)\Simply Fortran\mingw\bin\gfortran.exe"" -c -o build\zeroini.o -mtune=native -IC:/PROGRA~2/SIMPLY~1/mingw/include/  -Jmodules .\zeroini.f

What do the -c -o mean?

-mtune=native.  I suppose this is related to the target CPU option I changed before. I have an Intel(R) Core(TM i7 CPU X 990 @3.47Ghz 2.79 Ghz with Windows 7 64 bits. However, when I look at the Task manager, the program seems to be running in 32 bits (*32 follows). Is this normal?

Any suggestion?

Isabelle

Re: Warnings and errors...part II

Isabelle,

The "-c" flag instructs the compiler to compile the source code only (rather than compile and link).

The "-o" flag is followed by the object filename, the compiler's target.

The "-mtune" flag is working as desired, but Simply Fortran uses a 32-bit compiler that does not produce 64-bit executables.  This may change in the future, but it shouldn't be any slower an executable.

One thing I did notice was that you don't have any optimization flags.  Did you enter "-O2" in the Fortran compiler flags in the Compiler Options dialog?  If so, there could be a bug causing it not to show up in the makefile.  You could also add the same flag in the Project Options dialog instead.

I'm surprised by the scale of the slowness you're experiencing.  Could there be any other differences?

Jeff Armstrong
Approximatrix, LLC

Re: Warnings and errors...part II

Hi Jeff,

Thanks again. Yes, I did enter the -O2 flag, in the compiler and project options. It still gives me no messages indicating that it took it into consideration. See the example below. 

""C:\Program Files (x86)\Simply Fortran\mingw\bin\gfortran.exe"" -c -o build\zeroini.o -mtune=native -IC:/PROGRA~2/SIMPLY~1/mingw/include/ -O2 -Jmodules .\zeroini.f

I have taken the code from a partner. I only changed 1 file, 2 numbers. That's it. And recompiled it. That person was using Visual Fortran plugged into Visual Fortran and created a release version. Is there the equivalent in Simply Fortran?

Thanks,

isabelle

Re: Warnings and errors...part II

Isabelle,

You're right in that the "-O2" flag is present.  I would be surprised in any event if enabling optimization would cut your runtime from one day to one hour.  Is your code performing some sort of calculation relying on convergence criteria?

One issue I did notice in your original post was the warning about a function name being the same as an intrinsic.  Your code is probably now calling the intrinsic rather than the function you wish.  You may want to fix that by renaming the offending function to something else (and all references to said function).  Currently your program may be calling something entirely unexpected.

Another option, if you're compiling FORTRAN 77 code, is to add the "-std=legacy".  The "legacy" option may disable some intrinsics introduced after FORTRAN 77 that could be causing the warning I've pointed out above. 

I'm afraid I don't have too many other ideas without some knowledge of the code.  Again, I'd be surprised if GNU Fortran were producing an executable with an order of magnitude slowdown compared to CVF.  I suspect some other factor is at play here, and I don't necessarily think it's due to your code changes.   Rather I believe there is a subtle difference between how the two compilers are treating the code of interest.

Jeff Armstrong
Approximatrix, LLC