Topic: Questions from a (SF-)beginner

After more than 30 years in aerodynamics, developing and using CFD tools, I retired recently and now want to reanimate some F77-codes which I had written and used originally under Linux. Looking for a "low-cost" Fortran development tool for Windows I found Simply Fortran - and to date, I really like it.

Now I have three questions (I am using version 2.6 Build 1470 under Windows 8):

1. (the simple one):
-------------------------
is there an option (in the editor) to "just" compile a single modified source code without clicking "Build now!" ?

2. (another simple one):
------------------------------
after having modified a number of source files from the project list, the editor panels indicate unsaved alterations by this little icon. If I now do a File/Exit I get the (very useful) warning that there are unsaved changes. First idea of course is to do Project/Save Project, but obviously that does not include a save on all source files. The tedious way is to activate each editor panel individually and do File/Save. I noticed that a "Build Now! will also save all sources so that I can exit without warning. Is there something like an option "Save All Sources" or the possibility to select multiple source files from the project panel to which File/Save will apply ?

3. (the complex one):
---------------------------
I would like to enhance my codes with a GUI (which I never managed to do under Linux).  After browsing a bit in your forum I came across DISLIN, which seems to be just right for my purpose, including the plotting capabilities. On the DISLIN homepage several versions are offered for download, I picked dl_10_gc.zip (64 bit), unpacked it, ran their setup.exe and set the environment variable DISLIN accordingly.

I did search the forum for DISLIN usage but find the information rather scattered. Is there a documentation about what has to be done further to be able to use DISLIN (not signing up to your package server to begin with) ?

Thanks,
Norbert

2 (edited by davidb 2013-12-06 10:52:08)

Re: Questions from a (SF-)beginner

1. I don't think so. With Fortran 90 onwards the dependencies between files make single file compiles less useful than in F77.
2. A Save All option of the file menu would be a good idea. Maybe this can be added for the next update.

I don't know much about DISLIN. Perhaps you could create a DISLIN library using SF, then add this library to the project that you want to use it in?

BTW I think you need the MingW version, dl_10_mg.zip

I will download it myself and have a go.

--
David

Re: Questions from a (SF-)beginner

Norbert,

David did a good job answering your questions, but I'll try to add a few notes:

1. Are you suggesting you just want to compile one file to an object file?  If so, there is no way to do that in Simply Fortran.  However, I'm not sure that's a particularly bad thing.  If that's the only file that's changed, clicking "Build Now!" is about as costly as only compiling that one file.  If you're asking if you can quickly compile one file to an executable without going through the process of creating a project, then, yes, that is possible.

2.  A Save All feature would be great!  Consider it implemented.

3.  If you'd like to manually use DISLIN yourself, you need to download dl_10_mg.zip, which is the 64-bit distribution for MinGW-W64.  You've downloaded the Cygwin distribution, which will not work with Simply Fortran's compiler.  Additionally, you'll need to include either dislin.f90 or dislin_d.f90 in your projects to construct the proper DISLIN modules (unless you're working strictly in FORTRAN 77).  The DISLIN folks provide module files, but they won't be compatible with Simply Fortran's compiler.  Their prebuilt *.mod files are for quite an old version of the Fortran compiler.  Finally, make sure to link against dismg.a or dismg_d.a either by including it in your project or creating the proper linker flags. 

The package manager sets up the above automatically, but it can be done manually without too much effort.

I hope the above answers your questions.  If you have any more, please feel free to post them!

Jeff Armstrong
Approximatrix, LLC

Re: Questions from a (SF-)beginner

David and Jeff,

thanks a lot for your quick replies (what time do you start working ? :-)

1. I agree. Just to check the syntax Build Now! is quick enough (at least with only a few sources in the project)

2. Great. This will be useful when you want to interrupt your work, knowing that you have made a lot of changes
    in various sources which are  not yet ready to be compiled.

3. I will try to follow your instructions with  dl_10_mg.zip.

    Is it enough to just unpack this archive to have access to the files or do I have to run their setup.exe ?

    For the moment I will strictly stay with FORTRAN 77 (never made it to F90). Do I still need to include the
    dislin.f90 or dislin_d.f90 files in my project - or would this cause a conflict with  my f77 sources ?

    What's the difference between  dislin.f90 and dislin_d.f90 or dismg.a and dismg_d.a ?

     General question: will a mixture of f77 and f90 sources work ?

Thanks,
Norbert

5 (edited by davidb 2013-12-06 15:48:30)

Re: Questions from a (SF-)beginner

As far as I can see, there isn't a dislin_d.f90, only dislin.f90.

The dislin.f90 file allows you to put USE statements in your code so the compiler can check if you have the interface for each call correct.

You don't need this file in your project if you are writing F77 code, but then it will be your responsibility to get the interface correct.

You can add any F90 features you want to use to your F77 files. If your files are fixed formatted (column 1 for comment, 1-6 for label, 6 for continuation, 7-72 for code) you have to keep to this when you add new code.

You can mix F90 free format source code and F77 fixed format source code, but they need to be separate files. Use *.f90 for F90 source code and *.f for F77.

I have no idea why there is a  dismg.a and dismg_d.a.

--
David

Re: Questions from a (SF-)beginner

jeff wrote:

Norbert,
Are you suggesting you just want to compile one file to an object file?  If so, there is no way to do that in Simply Fortran.

If you are working only with F77 source there won't be any file dependencies and a single file compile might make a lot of sense. One thing you can do is create a Console tool in the Toolbox, then go to the console and compile the old fashioned way using the command line

gfortran -c source.f

I don't think there is a way of specifying the current selected tab in the Toolbox; if there was you could create a compile tool.

--
David

Re: Questions from a (SF-)beginner

Norbert,

You can mix fixed-format and free-format source code in a single project without any problems.  If you want to restrict your fixed-format code to the FORTRAN 77 standard, however, that really can't be achieved.  That said, there really isn't much reason to enforce the FORTRAN 77 standard anyway unless your code is odd in some way; almost all FORTRAN 77 should compile just fine without forcing FORTRAN 77 compliance.

You shouldn't need to use dislin.f90 in your project if you don't plan on using Fortran 90 features.

The "_d" suffix in DISLIN designates that it is a double-precision library.  Only ever include one or the other, never both files.

You shouldn't need to run DISLIN's setup.exe (I know I never have).  I'm not sure what it does other than copy files into a directory. 

And David,

There is no single file compile option because it shouldn't be necessary.  I'm not saying it wouldn't serve a purpose, but, in general, it isn't overly useful.  If you want to check syntax only, Simply Fortran's built-in syntax checks (also available via the Project Issues panel) should suffice.  If you're seeing inconsistencies between the compiler output when you build and the reported errors and warnings on the Project Issues panel, let me know as that would be a bug.

Jeff Armstrong
Approximatrix, LLC

Re: Questions from a (SF-)beginner

Thanks for the explanations concerning mixed f77/f90 code, that's clear now.

Jeff seems to be right that DISLIN's setup does nothing more than copying files. When I went to get rid of the wrong distribution I first tried to do a regular Windows Uninstall, but DISLIN does not show up in the list of installed applications. So I simply removed the directory where I had stored the Cygwin distribution and "installed" the MinGW-W64 distribution.

I'm still struggling to integrate DISLIN manually. This is what I tried:

DISLIN provides two example codes, "exa" and "map", both in a f77 and a f90 version,

First I tried to get "exa_f77" to run

-  set the environment variable "DISLIN = D:\DISLIN_dl_10_mg"  (that's where the files reside)
   and complemented the Windows PATH by "D:\DISLIN_dl_10_mg\win"  (following DISLIN's instructions)

-  created a new project "exa_f77"

-  added the  following files to this project
     exa_f77.for
     dislin.f90
     dismg.a

-   added  "D:\DISLIN_dl_10_mg" to Search Directories/Library Directories

-  Build Now! (after Save Project) produces the following errors:

Generating Makefile... Okay
==============================================================================
Open Watcom Make Version 1.9 (Built on Feb  4 2013)
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
    "C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -o "exa_f77.exe" -static -mwindows "build\dislin.o" "build\exa_f77.o" "D:\DISLIN_dl_10_mg\dismg.a" -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/ -LD:/DISLIN_dl_10_mg
D:\DISLIN_dl_10_mg\dismg.a(qqwini.o):qqwini.c:(.text+0x2302): undefined reference to `__imp_glReadPixels'
D:\DISLIN_dl_10_mg\dismg.a(qqwini.o):qqwini.c:(.text+0x230e): undefined reference to `__imp_glRasterPos2i'
D:\DISLIN_dl_10_mg\dismg.a(qqwini.o):qqwini.c:(.text+0x231a): undefined reference to `__imp_glDrawPixels'
...
< many more similar messages >
...
D:\DISLIN_dl_10_mg\dismg.a(qqwini.o):qqwini.c:(.text+0x1433e): undefined reference to `__imp_glClearColor'
D:\DISLIN_dl_10_mg\dismg.a(qqwini.o):qqwini.c:(.text+0x14357): undefined reference to `__imp_glClearColor'
D:\DISLIN_dl_10_mg\dismg.a(qqwini.o):qqwini.c:(.text+0x14362): undefined reference to `__imp_glClear'
c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\DISLIN_dl_10_mg\dismg.a(qqwini.o): bad reloc address 0x0 in section `.data'
c:/program files (x86)/simply fortran 2/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (exa_f77.exe) returned a bad status
Error(E02): Make execution terminated

* Failed *

-   trying the example "map_f90.f90" in the same way produces this error:

Generating Makefile... Okay
==============================================================================
Open Watcom Make Version 1.9 (Built on Feb  4 2013)
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See [URL removed due to post limitation] for details.
    "C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -c -o "build\map_f90.o" -g -ID:/FORTRAN-Applications/DISLIN_Examples/map_f90/../../../DISLIN_dl_10_mg/gf/real64  -Jmodules "..\..\..\DISLIN_dl_10_mg\examples\map_f90.f90"
..\..\..\DISLIN_dl_10_mg\examples\map_f90.f90:9.10:

      USE DISLIN
          1
Fatal Error: Cannot read module file 'dislin.mod' opened at (1), because it was created by a different version of GNU Fortran
Error(E42): Last command making (build\map_f90.o) returned a bad status
Error(E02): Make execution terminated

* Failed *




What am I missing / doing wrong ?

Norbert

Re: Questions from a (SF-)beginner

A few things are going wrong.  First, don't add DISLIN's directory to the library or include search directories in Simply Fortran.  It will lead to the second error you found: "...because it was created by a different version of GNU Fortran."

Second, DISLIN has a number of dependencies on Windows, which is why I normally encourage using the SF Package Manager to handle DISLIN projects.  You also need to link to a few Windows libraries.  Specifically, add the following to your Linker Flags under Project Options:

-luser32 -lgdi32 -lopengl32

After that either the fixed- or free-format examples should compile.

Jeff Armstrong
Approximatrix, LLC

Re: Questions from a (SF-)beginner

My linker options are:
-ldis -luser32 -lgdi32 -lopengl32

I add dislin.f90 to the project outline

I too came into F90/F95 etc from a long history of F77 code-writing.
F90 etc compiles F77 code without a problem.
One can just take advantage of any F90 features as and when discovering them and finding them useful.

I've nearly finished a very large project in Simply Fortran using DISLIN for the Windows GUI, with tabulated input fields, on-screen buttons, and diagrams in one of the Window panes.
---
John.