Topic: Getting Started with Simply Fortran

My previous experience with Fortran has all been DOS based.  Is there a manual or tutorial that shows what  I need to do in order to be able to use Simply Fortran?  I am running a 64 bit version of Windows 7.

Hacking around, I have been able to compile, but when I attempt to run my program Simply Fortran does not recognize my data files.  I get an error message "Fortran runtime error:  File 'input1.txt' does not exist.  Press any key to continue...

Any suggestions?

Thanks

Re: Getting Started with Simply Fortran

If you've successfully compiled your program, it sounds like you're doing great.  I would guess that the error you're seeing is related to some directory confusion.  To simplify things, first make sure that the program executable that you've compiled and your data files, "input1.txt" in this case, are in the same directory.  Next, select "Launch..." from the Options menu.  Ensure that the working directory is either blank (if your SImply Fortran version is current) or points to the directory where your exectutable and data files reside.  Now try launching your program again.

If you're still having troubles, there could possibly be a bug in Simply Fortran.  An alternative would be to open a command prompt, navigating to the directory with the exectuable, and running the compiled program manually to see if the directory error still occurs.

Please let us all know if you have more success or if things seem to remain broken.  Because everything compiled, I suspect there is just some minor confusion with paths on the part of Simply Fortran.

Jeff Armstrong
Approximatrix, LLC

Re: Getting Started with Simply Fortran

Dear Brad

(Is that your name?)

I too am a refugee from F77 and DOS.
I have a very large structural engineering project that I have been developing over many years.  8000 lines of code.

Since discovering Simply Fortran ('SF') I have set myself the task of
(1) porting my project to SF
(2) creating a GUI
(3) carrying out further development.

I had a bit of learning to do to get hang of SF.  Well worth doing.  What Jeff done as a front end to GNU F90 and the 'Insight' debugger is exceedingly good.

I then accomplished (1) almost immediately.  The source code was all F77 and SF uses F90, of which F77 works fully in its original form, as a subset with a all the F90 improvements available as if they were extensions to F77. 

For (2) my GUI, I have alighted on DISLIN.  It is given away free by the author's generosity, for non-commercial use, and it is totally superb.
To solve your problem with your program not finding your input files, you can use the DISLIN statements, USE DISLIN nad CALL DWGFIL, as shown below. 
THis brings up a Win Doze dilename requester dialog, in which you can enter a pathname by mouse-clicking.
     
      USE DISLIN   ! At start of your code
      :
      :
      CALL DWGFIL('INPUT file name', FiNAME, '*.IN*')
      IF ( LEN_TRIM(FiNAME).GT.0 ) THEN
C        User has entered an input file name
C        So attempt to open it
          OPEN(UNIT=LUI,
     +        FILE=FiNAME,
     +        STATUS='OLD',
     +        ERR=50,
     +        IOSTAT=IOCODE )

C        No ERR, so say so and set file-opened return value of LUI
C        CALL DISP(0,FiNAME//' opened.',LEN(FiNAME)+8,0)
        WRITE(LUS,'('' Input file opened:''/'' '',A)') FiNAME
          LUI=LUISET
          GO TO 60

50       CONTINUE
C        Input filename entered but file not found and/or not opened
C        Return a request to open the same filename as an echo file
C        Set return value of LUI to LUK because input file-not-opened
          WRITE(LUS,'(' Error code [',I4,'].',$)') IOCODE

      ELSE
C        User has not entered an input filename
         LUI=LUK

60    END IF


I give at the end of this post the source code for a program I wrote as a DISLIN learning exercise.  It doesn't do anything hugely useful, but it was a grat help to me in learning how to use DISLIN with SF.

Lastly, for program development, if you are accustomed only to Fortran for DOS then you are in for a hell of a treat.  SF can do SOURCE LEVEL DEBUGGING.
You see you source code and step through it, watching the program execute, line by line, and watching the values of all program variables as they change.

I'll sign off now with (below) the example code for learning how to use DISLIN,
----
John


      PROGRAM Roots
C     -------------
C     Example showing how to use DISLIN to greate a Fortran GUI
C     Jmw
C     30-03-2011

C     The concept is to display a window, with buttons, menus,
C     input (fields) and output panel(s), and simply wait for the user
C     to do stuff.  The user enters data in input fields
C     then activates various parts of the program by clicking buttons
C     or selecting actions from pull-down menus.
C     Each part of the program is executed in a subroutine, which always
C     returns control to the user in the main top window.

      USE dislin
      IMPLICIT NONE
      CHARACTER*8 aValu
      CHARACTER*5 Header
      INTEGER ipMain,ipTopM,ipTopL,ipTopR,ipBtmM,idMActs,idSqre,idSqRt,
     +        idIN, idOUT, CALL1,CALL2,CALL3,CALL4,CALL5,CALL6, i

      COMMON aValu, idIN, idOUT
     
      EXTERNAL Square, SqRoot, CuRoot
     
      aValu='        '
C-----------------------------------------------------------------------
C     DESIGN THE MAIN WINDOW LAYOUT

C     Size, position and title
      CALL SWGWTH(24)
      CALL SWGSIZ(408,420)
      CALL SWGPOS(425,225)
     
      Header='ROOTS'
      Print*, Header
      CALL SWGTIT(Header)
     
C     Define main window ipMain, stacked vertically
      CALL WGINI('VERT',ipmain)
     
C     Divide the top area of ipMain, ipTopM, horizontally
         CALL WGBAS(ipMain,'HORI',ipTopM)
         
C        Define the L and R vertical stacks in ipTopM
         CALL WGBAS(ipTopM,'VERT',ipTopL)
         CALL WGBAS(ipTopM,'VERT',ipTopR)
         
C        Repeatedly redefine ipMain's bottom area until far enough down
         DO i=1,12
           CALL WGBAS(ipmain,'HORI',ipBtmM)
           END DO
C-----------------------------------------------------------------------
C     Menus

C     New menu
      CALL WGPOP(ipmain,'Actions',idMActs)
     
C       Menu entries
        CALL WGAPP(idMActs,'Square',CALL1)
        CALL SWGCBK(CALL1, SQUARE)
       
        CALL WGAPP(idMActs,'SqRoot',CALL2)
        CALL SWGCBK(CALL2, SQROOT)
       
        CALL WGAPP(idMActs,'CuRoot',CALL3)
        CALL SWGCBK(CALL3, CUROOT)
       
C     Help menu
      CALL SWGHLP('Enter a numeric value then|'//
     +            'click an action button, or|'//
     +            'select a menu action.')
C-----------------------------------------------------------------------
C     Prompt, messages and data entry field - in the top area, LH stack
      CALL WGLAB(ipTopL,'Simple JMW Fortran GUI example',i)
      CALL WGLTXT(ipTopL,'Enter a value',aValu,48,idIN)
C-----------------------------------------------------------------------
C     Buttons - in the top area, RH stack
      CALL WGPBUT(ipTopR,'SQUARE',CALL4)
      CALL SWGCBK(CALL4, SQUARE)
     
      CALL WGPBUT(ipTopR,'SQROOT',CALL5)
      CALL SWGCBK(CALL5, SQROOT)
     
      CALL WGPBUT(ipTopR,'CuROOT',CALL6)
      CALL SWGCBK(CALL6, CUROOT)
C-----------------------------------------------------------------------
C     Output panel - in the bottom area
      CALL SWGWTH(52)   
      CALL WGSTXT(ipBtmM,14,999,idOUT)
C-----------------------------------------------------------------------
C     Activate
      CALL WGFIN
C-----------------------------------------------------------------------
      STOP
      END
C-----------------------------------------------------------------------     
   
   

      SUBROUTINE SQUARE
      USE dislin
      IMPLICIT NONE
      CHARACTER*8 aValu
      CHARACTER*20 StringR
      INTEGER idIN, idOUT
      REAL Value
      COMMON aValu, idIN, idOUT
     
C     Read the keyboard input value from idIN
      CALL GWGTXT(idIN,aValu)
      CALL GWGFLT(idIN,Value)
     
C     Run this part of the program
C     (It would normally contain a lot more than this)
      CALL SWGTXT(idOUT,
     +            TRIM(aVALU)//' (squared) = '//
     +            STRINGR(Value**2,'(F8.3)'))
      RETURN
      END
C-----------------------------------------------------------------------



      SUBROUTINE SQROOT
      USE dislin
      IMPLICIT NONE
      CHARACTER*8 aValu
      CHARACTER*20 StringR
      INTEGER idIN, idOUT
      REAL Value
      COMMON aValu, idIN, idOUT
     
C     Read the keyboard input value from idIN
      CALL GWGTXT(idIN,aValu)
      CALL GWGFLT(idIN,Value)
     
C     Run this part of the program
C     (It would normally contain a lot more than this)
      CALL SWGTXT(idOUT,
     +     'Square root ('//TRIM(aVALU)//') = '//
     +      STRINGR(SQRT(Value),'(F8.3)'))
      RETURN
      END
C-----------------------------------------------------------------------



      SUBROUTINE CUROOT
      USE dislin
      IMPLICIT NONE
      CHARACTER*8 aValu
      CHARACTER*20 StringR
      INTEGER idIN, idOUT
      REAL Value
      COMMON aValu, idIN, idOUT
     
C     Read the keyboard input value from idIN
      CALL GWGTXT(idIN,aValu)
      CALL GWGFLT(idIN,Value)
     
C     Run this part of the program
C     (It would normally contain a lot more than this)
      CALL SWGTXT(idOUT,
     +     'Cube root ('//TRIM(aVALU)//') = '//
     +      STRINGR(10**(LOG10(Value)/3),'(F8.3)'))
      RETURN
      END
C-----------------------------------------------------------------------



      FUNCTION STRINGR(RValu,F)
C     Returns real RValu as a string
C     F is the format specification, such as '(F8.3)'
      Character STRINGR*20, F*80
      REAL RValu
      WRITE(STRINGR,F) RValu
      RETURN
      END
C-----------------------------------------------------------------------

Re: Getting Started with Simply Fortran

John,

I was wondering if DISLIN works on windows 7 on a 64 bit machine. I am struggling for a while to simply get an executable from the dislin examples. No luck.

I tried to use INTEL FORTRAN/GFORTRAN/MINGW32-GFORTRAN. No luck
I was able to get it to work on VMware machnie with the Compaq Visual Fortran (obviously 32 bit system with XP pro)

I badly need it to work on a 64 bit machine with Windows 7 Ultimate

Please advise

Tuli

Re: Getting Started with Simply Fortran

I am using Win 7 Professional, 64-bit.
Simply Fortran works perfectly.
DISLIN does as well.

Simply Fortran is running as a 32-bit application.  Geoff has told me it should also be configurable as a 64-bit product but I haven't tried it.

To run DISLIN I needed Geoff's help in working out where to put everything.
As far as I recall, after installing DISLIN and setting environment variables, there are two files that Simply Fortran needs to be able to find.  One is "disgf.a".  The other is "dislin.mod".  Both of mine are ADDed to the project just as if they were F77 or F90 source files, and Simply Fortran recognises them for what they are.

Geoff was muttering something about posting a quick-start guide for how exactly to use DISLIN.  I think that would be really, really helpful.
---
John

Re: Getting Started with Simply Fortran

John is correct, Simply Fortran can compile DISLIN applications properly on 64-bit Windows.  The resulting program will be a 64-bit executable if you're employing the GNU Fortran compiler distributed with Simply Fortran. 

If you need an example project to get started with DISLIN, please send an email to support@approximatrix.com.  What I had been suggesting in an earlier post was that perhaps a page with some example projects would be useful.  With such a page, someone could simply download the example DISLIN project.

Jeff Armstrong
Approximatrix, LLC