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

Putting my output in a window??

gtwatson
Beginner
1,592 Views
First a little background. I learned FTN IV in 1966 and write code to solve my own problems, so I am stuck in the dark ages of fortran programming. I use CVF6.6 to write some simple code to read in data from a file and I use the OPEN to write the results out to another output file. I usually use the CONsole where a DOS looking window opens up and I can get text to print out there. I want to get a little fancier and maybe open up a window where my output file would be displayed and the user could send it to the default Windows printer. Someone suggested to try to pass the file to NOTEPAD or WORDPAD, but I am at a loss to figure out how to do this. I have looked at the SAMPLE programs, but they do not resemble the fortran I am used to writing and look more like C++. Is there a simple way to pass my output file to NOTEPAD?

TIA... George
0 Kudos
10 Replies
Steven_L_Intel1
Employee
1,592 Views
Hi George..

You should soon get a response I sent to you through CVF support. The solution I recommend is FortranWinPrint.f90.

Steve
0 Kudos
gtwatson
Beginner
1,592 Views
Thanks for the reply. I looked at forprint and I must be getting dumber by the day. When I add my code (where statements start at column 7 with line continuation in column 6 like I learned in 1966) I get all kinds of compile errors. It does not like my comment lines with a capital C in column 1. Is there some kind of switch somewhere to tell the compiler that the statements start in column 7?

I was able to add the USE fortran_winprint line to my CON workspace and add the f90 code to that workspace and get it to compile and run, but I wanted to get away from the CON window opening up.
0 Kudos
Steven_L_Intel1
Employee
1,592 Views
You don't need to edit the Fortran_WinPrint.f90 code. Just add this file to your project and add the USE line to your source.

You want to create a program that doesn't open a console window at all? Then what you want is a Fortran Windows Application project. Here you have a WinMain routine as the main entry point instead of a main program. A minimal such program is this:

integer*4 function WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
integer hInstance, hPrevInstance, lpszCmdLine, nCmdShow
! Your code goes here
end function WinMain


You don't have to worry about the arguments, though you can supply hInstance to Win32 API calls that want it.

Steve
0 Kudos
gtwatson
Beginner
1,592 Views
Steve;
I did as you said and I get 30 compile errors when I added my code to the piece you started. Here is a bit of what I have:

integer*4 function WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow )
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
integer hInstance, hPrevInstance, lpszCmdLine, nCmdShow
! Your code goes here





C PROGRAM IRREG
C
C THIS PROGRAM WILL READ A PLS-POLE POSTPROC FILE
C AND CALCULATE THE CORRECT SAFETY FACTOR FOR THE POLE
C SHAFT BASED ON MY RESEARCH ON LOCAL BUCKLING OF
C IRREGULAR POLYGONAL SHAPES WHERE THE WIDE FLAT IS
C NOT IN UNIFORM COMPRESSION
C GTW - APRIL 10, 2003
C
CHARACTER*12 STOCK,BPLATE,SHAPE,SHPROP,EL(200),JL(200),JP(200),D1,
1 D2,D3,D4,D5,D6,D7,LCNAME(40)

CHARACTER DUMMY*79,HEADER*80,
1 DUMMY2*80,TITLE1*80,TITLE2*80,POLEFILE*80,LCAFILE*80,PROP*25,
1 SHPDES*20,FLC*26

REAL LMOI,LMOM,LSHR
DIMENSION TLEN(30),THICK(30),SPLEN(30),YIELD(30)
1 ,DIST(200),OD(200),AREA(200),TMOI(200),LMOI(200),
1 WOVERTMX(200),FY(200),FA(200),PTHICK(200),DFT(200),
1 TMOM(200),LMOM(200),TORQ(200),AXIAL(200),
1 TSHR(200),LSHR(200),POVRA(200),SIGALOW(200),FACTOR(200),
1 ACTALOW(200),ACTALON(200)
use Fortran_WinPrint
integer istat

INTEGER*2 IERR
OPEN(UNIT=2,FILE='C:PLSTEMPPOSTPROC',STATUS='OLD',READONLY)

OPEN(UNIT=4,FILE='C:PLSTEMPSTRESS.TXT',STATUS='UNKNOWN')



CALL GETTIM(IHR,IMIN,ISEC,NOGO)
CALL GETDAT(IYR,IMON,IDAY)

WRITE(4,141)IMON,IDAY,IYR
141 FORMAT(/15X,'THE DATE IS ',I2.2,1X,I2.2,1X,I4.4)
WRITE(4,142)IHR,IMIN,ISEC
142 FORMAT(15X,'THE TIME IS ',I2.2,':',I2.2,':',I2.2)

BUCK=26210.48789
C THIS IS PI^2*E/(12*(1-.3^2)) FOR THE BUCKLING CONSTANT


The above code wraped but is correct in my Developer Studio. It looks like my problem is that I use the old Syntax because the compiler does not recognize my comment lines as comments, and does not recognize my continued lines as continued. The tabs are also not recognized. In my window the cap C is in column 1 and the statements begin in column 7
0 Kudos
Steven_L_Intel1
Employee
1,592 Views
Move the USE to just after the FUNCTION. Make sure that all the lines start in column 7 (the !DEC$ line can start in column 1.) Make sure that no lines go past column 72.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,592 Views
Perhaps it should be emphasized that source routines with ".for" or ".f" extension are recognized by the compiler as fixed form (old, 7-72), and the ones with ".f90" as free form (new, 0-132).

Jugoslav
0 Kudos
gtwatson
Beginner
1,592 Views
Hi Steve;
I am getting a warning message when I compile.

Here are the first few lines of my code which is irreg2.for:

integer*4 function WinMain( hInstance, hPrevInstance, lpszCmdLine,
1 nCmdShow )
use Fortran_WinPrint
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
integer hInstance, hPrevInstance, lpszCmdLine, nCmdShow
integer istat






C PROGRAM IRREG
C
C THIS PROGRAM WILL READ A PLS-POLE POSTPROC FILE
C AND CALCULATE THE CORRECT SAFETY FACTOR FOR THE POLE
C SHAFT BASED ON MY RESEARCH ON LOCAL BUCKLING OF
C IRREGULAR POLYGONAL SHAPES WHERE THE WIDE FLAT IS
C NOT IN UNIFORM COMPRESSION
C GTW - APRIL 10, 2003

CHARACTER*12 STOCK,BPLATE,SHAPE,SHPROP,EL(200),JL(200),JP(200),D1,
1 D2,D3,D4,D5,D6,D7,LCNAME(40)

CHARACTER DUMMY*79,HEADER*80,
1 DUMMY2*80,TITLE1*80,TITLE2*80,POLEFILE*80,LCAFILE*80,PROP*25,
1 SHPDES*20,FLC*26

REAL LMOI,LMOM,LSHR
DIMENSION TLEN(30),THICK(30),SPLEN(30),YIELD(30)
1 ,DIST(200),OD(200),AREA(200),TMOI(200),LMOI(200),
1 WOVERTMX(200),FY(200),FA(200),PTHICK(200),DFT(200),
1 TMOM(200),LMOM(200),TORQ(200),AXIAL(200),
1 TSHR(200),LSHR(200),POVRA(200),SIGALOW(200),FACTOR(200),
1 ACTALOW(200),ACTALON(200)


Here is the end of the code:

WRITE(*,112)
112 FORMAT(//5X,'THE OUTPUT FILE IS C:PLSTEMPSTRESS.TXT '//)
WRITE(*,*)'THE MAXIMUM PERCENT USED WAS ',CONTROL*100
IF(CONTROL.GT.1.0) WRITE(*,*)'THIS POLE IS OVERSTRESSED'


close(4)

open (unit=1,file='C:PLSTEMPSTRESS.TXT',form='formatted',
1 status='old',action='read')
istat = Print_Unit (1, Default_Printer=.FALSE.)
close (1)
999 STOP
C END
end function WinMain

And here is the error message I am getting:
--------------------Configuration: irreg2 - Win32 Debug--------------------
Compiling Fortran...
G:PROGiregpolyTESTINGirreg2.for
G:PROGiregpolyTESTINGirreg2.for(1) : Warning: The return value of this FUNCTION has not been defined. [WINMAIN]
integer*4 function WinMain( hInstance, hPrevInstance, lpszCmdLine,
-------------------------^

irreg2.obj - 0 error(s), 1 warning(s)

0 Kudos
Steven_L_Intel1
Employee
1,592 Views
Right - you need to add a:

WinMain = 0

in there somewhere. Also, replace the STOP with CONTINUE.

Steve
0 Kudos
gtwatson
Beginner
1,592 Views
Hi Steve;
I got the FOR to compile after I put in your 2 suggestions.
Now I get a link error:

-------------------Configuration: irreg2 - Win32 Debug--------------------
Linking...
dfor.lib(DFORMAIN.OBJ) : error LNK2001: unresolved external symbol _MAIN__
Debug/irreg2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

irreg2.exe - 2 error(s), 0 warning(s)
0 Kudos
james1
Beginner
1,592 Views
You need to define your project as a Windows project or if compiling from the command line use the /winapp switch.

James
0 Kudos
Reply