Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Port Fortran Power Station 4.0 Project to Intel Visual Fortran Project/Solution

Schabort__Victor
Beginner
2,241 Views

I have code developed with visual components / dialogs written in Fortran Power Station that I want to port to Intel Parallel Studio in Microsoft Visual Studio.

Is there any economical way port the project files into the new environment?

0 Kudos
31 Replies
andrew_4619
Honored Contributor II
1,737 Views

Well the last time I used Powerstation was in a previous century so my memory might not be that good....

If I recall well Powestation never made windows applications only ms-dos applications, I recall using microsoft graphics primatives to create a user interface. I think you will need to do some work but maybe not much work ...

Your phrase "visual components / dialogs" worries me. What graphics does this program use (if any)? Do you have and third party libraries that are used?  How many fortran source files do you have? Is it a mixed language program?

I think maybe you need to give us some more information.

You could just create a new project (of the correct type) in Visual studio, add your source files to the project and then look at what errors result as a starting point. 

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,737 Views

I would add to Andrew's suggestion to avoid any temptation to modernize your code. Change only what is necessary to get the code to build, and then to get the user interface (if any) to work.

An additional tip. If you have an older version of Windows, e.g. Windows 7 (or XP) that is still running and with your tools. You might try that first. IOW try introduce only a minimal amount of runtime environment as possible during your port.

Jim Dempsey

0 Kudos
Schabort__Victor
Beginner
1,737 Views

Thanks for answers!

It is a FORTRAN program. MSFLIB is used. No graphics is used, only simple dialogs with input field controls and command button controls.

I have created a new project solution (QuickWin), included all code modules.

Also included the (resource.fd) as well as the script (script.rc) defining the different dialogs in the project

.

also off course USE IFLOGM.

"

      USE              IFLOGM
      USE              MSFLIB
      USE              IFPORT
      
      IMPLICIT NONE
     
      INCLUDE         'RESOURCE.FD'
      INCLUDE         'GLOBAL.CMN'
      INCLUDE         'STD_PAR'

The program compiles and runs, but the dialogs are not initialized, because the dialog references is still undefined at run time i.e.:

      Ret = DlgInit( IDD_DIALOG1, dlg  )

Ret is false since IDD_DIALOG1 is undefined an therefre aslo dlg, so the Dialog cannot be activated......

How do I make the dialog identifiers visible in the code - its declared in the .fd file and defined in the script, but the program somehow does not see it at run time?

I also struggle to view the script.rc in the resource editor viewer....it gives identifier errors ...

 

0 Kudos
GVautier
New Contributor II
1,737 Views

andrew_4619 wrote:

If I recall well Powestation never made windows applications only ms-dos applications, I recall using microsoft graphics primatives to create a user interface. I think you will need to do some work but maybe not much work ...

PowerSation 4 (under Window NT and 9x) was able to create QuickWin apps.

PowerStation 1 (under Windows 3.x and 9x) wasn't. Only "dos" application.

http://www.emsps.com/oldtools/msforv.htm

 

 

 

0 Kudos
andrew_4619
Honored Contributor II
1,737 Views

Schabort, Victor wrote:
How do I make the dialog identifiers visible in the code - its declared in the .fd file and defined in the script, but the program somehow does not see it at run time?

I also struggle to view the script.rc in the resource editor viewer....it gives identifier errors ...

The resource editor saves an .rc file, script.rc in your case and resource.h (header include for C language).  Intel have a utility deftofd.exe that takes the .h file and makes a fortran include .fd file. You normally set a pre-build step to do this automatically. If you do a forum  search you will find instructions on this.

I presume this is an old .rc file? Fixing it is possible with a text editor but a bit hard to know what the problem is. If it is one or two simple dialogs creating a new resource file might be easier.  You could post the broken .rc and .h so we can look at them ....

0 Kudos
Schabort__Victor
Beginner
1,737 Views

Thanks for the answer.

I created a simple project solution to test and understand the mechanics of a simple fortran program with dialogs.

--------------------

program test
       USE      IFLOGM      
       include 'resource.fd'      
       
       type(dialog) dlg
       logical      return
       integer      retint
     
       return = DLGINIT(IDD_DIALOG1,dlg)
     
       retint = DlgModal(dlg)
      
      end program test

-----------------------

It basically does exactly the same, so the problem is on my side - I miss some small step to create a dialog app. The IDD_DIALOG1 is still undefined at run time and therefore return is false and the dialog init is unsuccessful. 

I used ResEdit 1.6.6x64  resource Editor  and when I create a dialog without problems, save it in a .rc project file, but I cannot reopen it again. It gives "identifier errors". Maybe I should use another resource editor. I have a professional version of Intel Parallel Studio XE2018 with MVS 2015 and would think the it includes a resource editor which I can integrate.

Here is the simple dialog .rc code generated by ResEdit.:

--------------------------

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"

LANGUAGE 0, SUBLANG_NEUTRAL
IDD_DIALOG1 DIALOG 0, 0, 528, 224
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "Ms Shell Dlg"
{
    COMBOBOX        0, 40, 76, 48, 30, CBS_DROPDOWN | CBS_HASSTRINGS, WS_EX_LEFT
    AUTOCHECKBOX    "Check", 0, 131, 78, 37, 8, 0, WS_EX_LEFT
    PUSHBUTTON      "Cancel", IDCANCEL1, 129, 24, 50, 14, 0, WS_EX_LEFT
    DEFPUSHBUTTON   "OK", IDOK1, 129, 7, 50, 14, 0, WS_EX_LEFT
}

-------------

I did include "deftofd resource.h resource.fd" in the command line property of the recource.h page custom build step. So the .fd file is created during compilation to make the variable identifiers visible. I basically followed all the instructions exactly as the online Dev Zone documentation on dialog apps.

 

0 Kudos
Schabort__Victor
Beginner
1,737 Views

I compiled a sample modelss dialogs project created by the project wizard without any changes.

It did exactly the same. the dialog is not initialized. 

0 Kudos
andrew_4619
Honored Contributor II
1,737 Views

If you have c installed in Vs you get the Vs resource editor which is much better imo than resedit. I used to use resedit years back but I had some problems and then found everything much more seamless and painless in Vs resource editor.   I suggest trying to open your RC file in vs. 

 

Also if your program is quickwin you need a message pump loop and to call initialsettings.  Look at one of the ifort quickwin sample programs.

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,737 Views

You do not need to create a QuickWin application in order to use dialog boxes.

  INTERFACE
    integer(4) FUNCTION ControlPanel(arg)      ! or integer(DWORD)
     !DEC$ ATTRIBUTES STDCALL, ALIAS:"_controlpanel" :: ControlPanel

     integer(4),POINTER :: arg                 ! or integer(DWORD)

    END FUNCTION
   END INTERFACE

...
integer(INT_PTR_KIND()) :: ControlPanelHandle = 0
integer(INT_PTR_KIND()) :: ControlPanelStack = 0      ! inherit
integer(INT_PTR_KIND()) :: ControlPanelArg = 0
integer(4) :: ControlPanelFlags = 0                   ! or integer(DWORD)
integer(INT_PTR_KIND()) :: ControlPanelThread_ID = 0
...
! Create seperate thread to run the Modal Dialog control pannel
ControlPanelHandle = CreateThread(&
  & NULL, ControlPanelStack, loc(ControlPanel), loc(ControlPanelArg), &
  & ControlPanelFlags, loc(ControlPanelThread_ID))
...
integer(4) FUNCTION ControlPanel(arg)
!DEC$ ATTRIBUTES STDCALL, ALIAS:"_controlpanel" :: ControlPanel
    USE IFLOGM
    use   GlobalData
    implicit none
    INCLUDE 'RESOURCE.FD'
    integer(4),POINTER :: arg
    integer(4) returnVal, ns
    CHARACTER(256) text
    LOGICAL retlog
    external ControlPanelCallBack
    retlog = DLGINIT( IDD_DIALOG1, ControlPanelDlg )
    if(.not. retlog) write(*,*) "Dialog error for IDD_DIALOG1"
    call DlgSetTitle( ControlPanelDlg, ControlPanelTitle )
! set your callback functions here
    retlog = DlgSetSub( ControlPanelDlg, IDC_RADIO1, ControlPanelCallBack )
...
    ControlPannelRunning = .true. ! Used by main program to know modal dialog is running
    returnVal = DlgModal( ControlPanelDlg ) ! Doesn't return unless cancled (or IDC_event not specified)
    ControlPanelExit = .TRUE.     ! Used by main program to know modal dialog has completed
    ControlPanelPause = .FALSE.   ! Used by main program
    ControlPanel = returnVal
end FUNCTION ControlPanel
...
SUBROUTINE ControlPanelCallBack( dlg, id, callbacktype )
!DEC$ ATTRIBUTES DEFAULT :: ControlPanelCallBack
  USE IFLOGM
    use GlobalData
    implicit none
    INCLUDE 'RESOURCE.FD'
  TYPE (dialog) dlg
  INTEGER id, callbacktype, iStat
  CHARACTER(256), automatic :: text
  LOGICAL retlog
  INTEGER cel, far, retint
  real(8), automatic :: xyz(3)
  text = 'undefined'
  ControlPanelPauseRefresh = .true.
  NextDisplayTime = 0 ! update now

  SELECT CASE (id)
    CASE (IDC_RADIO1)
    ! Radio button 1 selected by user so
    ! change display accordingly
      vIavDisplayFrame = 0   ! vIavDisplayFrame = 0 Inertial Frame
      ! vIavDisplayFrame = 1 Orbital Frame
    CASE (IDC_RADIO2)
...
  END SELECT
END SUBROUTINE ControlPanelCallBack

Jim Dempsey

0 Kudos
Schabort__Victor
Beginner
1,737 Views

Thanks for the feedback.

I still cannot get it to work.

I also created a Windows project exactly from the demo template provided provided by MS VS IDE (similar to the code you provided), complied perfectly, but the dialog initialization still returns 0 when calling DlgInit(IDD_WinApp1_DIALOG, gdlg) at runtime....

Not sure where to go to now...if none of the demo codes work, then there is some other problem in the installation setup maybe...

Really frustrating.

0 Kudos
Schabort__Victor
Beginner
1,737 Views

Andrew, I do not have the c installed (VS with Fortran) and cannot find the resource editor for dialogs, thats why I tried to use ResEdit.

Is there any way to find a working Dialog editor - ResEdit is not reading its own created .rc files....

0 Kudos
andrew_4619
Honored Contributor II
1,737 Views

If you don't have the c licence have you looked a Vs community edition? That includes c and you can install Fortran in that. I don't know any other resource editors. The resource editor is part of the ms c package. 

0 Kudos
Schabort__Victor
Beginner
1,737 Views

We paid a lot of money - I don't think this is the community edition - here is the system info:

Microsoft Visual Studio 2015 Shell (Integrated)
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.7.03056

Installed Version: IDE Standard

Microsoft Visual Studio Tools for Applications 2015   00322-10000-00000-AA661
Microsoft Visual Studio Tools for Applications 2015

Visual Basic 2015   00322-10000-00000-AA661
Microsoft Visual Basic 2015

Visual C# 2015   00322-10000-00000-AA661
Microsoft Visual C# 2015

Intel® Advisor 2018 Update 2   
Intel® Advisor 2018 Update 2, (build 550069), Copyright © 2009-2018 Intel Corporation. All rights reserved.

Intel® Inspector 2018 Update 2   
Intel® Inspector 2018 Update 2, (build 550070), Copyright © 2009-2018 Intel Corporation. All rights reserved.

Intel® Parallel Studio XE 2018 Update 2 Composer Edition for Fortran Windows*   Package ID: w_comp_lib_2018.2.185
Intel® Parallel Studio XE 2018 Update 2 Composer Edition for Fortran Windows* Integration for Microsoft Visual Studio* 2015, Version 18.0.0038.14, Copyright © 2002-2018 Intel Corporation. All rights reserved.
* Other names and brands may be claimed as the property of others.

Intel® VTune™ Amplifier 2018 Update 2   
Intel® VTune™ Amplifier 2018 Update 2, (build 550381), Copyright © 2009-2018 Intel Corporation. All rights reserved.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,737 Views

When you (sysadmin) installed the VS Shell, did they have the option to include C++ (as well as C# and VB)?

I haven't done this, maybe someone else can comment on this, you may be able to use the C# resource editor to construct your xxx.rc file.

Jim Dempsey

0 Kudos
andrew_4619
Honored Contributor II
1,737 Views

The resource editor comes with c++ only, you have to select that on the install, it does not install by default.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,737 Views

Thanks Andrew_4619

The user then may be able to make a C# dialog that is called from Fortran (with some finagling).

Jim Dempsey

0 Kudos
Schabort__Victor
Beginner
1,737 Views

Sorry, but I still find myself in a confused place.

I used the Dialog sample code example supplied with the Fortran Parallel Station XE 2018 installation  

(..\Parallel Studio XE - Fortran\ipsxe2018_samples_win_20171109\compiler_f\Dialog\TEMP) - see attach zip

It compiles 100% and runs, but the dialog identifiers are undefined at run-time, so the program cannot execute further.

This code example should run as it is in my view??

I have no idea why the Dialog Identifiers are still undefined.

 

I am not sure about the C++ option at installation - I will try an re-install and see what the options are...

 

0 Kudos
Schabort__Victor
Beginner
1,737 Views

I think the .rc files are not complied, since the MS SDK is not present.?

Thats why runtime does not see the external dialog identifiers  - but why is there no link errors?

I'm going to install it and make sure the resource compiler is active.

Hope its on the right track

 

0 Kudos
andrew_4619
Honored Contributor II
1,737 Views

OK I loaded that sample from the intel zip and loaded the provided vfprog into VS2017

 It runs fine but maybe you are finding in debug the resource constants are undefined in debug? This is because you need to compile with the option /debug-parameters:all  for the debugger to display the values. This does not effect program operation.

As a side note I had to "Fix" the TEMP.rc as #include "afxres.h" gave a file not found error which stopped compilation.

I replaced this line with:

#include "winres.h"
#include "winver.h"

To get it to work. I do not know if that is and sdk install issue on my machine or a problem with the sample....

 

 

0 Kudos
Schabort__Victor
Beginner
1,523 Views

Thanks Andrew

I get the following errors - although the program executes - but I am sure the TEMP.rc does not compile.

So there need to be some description elements in the RC script file?

Description                                                                  Project     File            Line

XML document must contain a root level element      TEMP     TEMP.RC    118

Invalid Token 'Text' at root level of document              TEMP     TEMP.RC    1

0 Kudos
Reply