Home > Archive > Fortran > June 2007 > Compiled with MS FORTRAN 5 my Program executes in colour but not with g95
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Compiled with MS FORTRAN 5 my Program executes in colour but not with g95
|
|
| les.denning@tiscali.co.uk 2007-06-20, 8:06 am |
| I before posting here I did adopt my usual approach of try it and see!
So on the basis that the F77 code used write(6,'(''escape codes")') to
output the ansi escape sequences that changed the background and text
colours in the old 16 bit "DOS box/Command Prompt" windows, I tried
the following with gfortran and g95 but unfortunately with no success.
The 'color xy' syntax being the new way the background and text
colours are set in my XP's 32 bit Command Prompt windows at the
prompt. So ever the optimist I tried this little FORTRAN program:
program coltest
c Version abc170607
write(6,'(''color 09'')')
write(6,'(''color '',i1,i1)')0,9
10 write(6,*)
write(6,*)
write(6,'('' Some text'')')
write(6,'('' *********'')')
write(6,*)
end
and what you get is:
C:\FORTRAN\SourceCode>gfortran -o coltest coltest.for
C:\FORTRAN\SourceCode>coltest
color 09
color 09
Some text
*********
I guess this is really no surprise.
I was given anther suggestion so flushed with another gush of optimism
I modified my little tester program to include the new code like this:
program coltest
c Version Les170607
c Revised Les190607 as per Dr. Shene
write(6,'(''color 09'')')
write(6,'(''color '',i1,i1)')0,9
write(6,*)
write(6,'('' Some text'')')
write(6,'('' *********'')')
write(6,*)
write(*,*) "This is the first line"
write(*,*) CHAR(11)
write(*,*) "This is the second line"
write(*,*) CHAR(12), CHAR(32), "This is the", CHAR(32), CHAR(32),
>"third line"
end program coltest
C:\My FORTRAN>g95 -o coltest coltest.for
C:\My FORTRAN>>coltest
color 09
color 09
Some text
*********
This is the first line
♂
This is the second line
♀ This is the third line
C:\My FORTRAN>
The printed symbol (represented by $#9792; above) that the write(*,*)
CHAR(11) produces is reminiscent of what I get with the orginal ANSI
escape codes so maybe I am flogging a dead horse as the saying goes.
Any help or advice would be very much appreciated.
Regards,
Les.
| |
| Steve Lionel 2007-06-20, 10:06 pm |
| On Jun 20, 8:46 am, les.denn...@tiscali.co.uk wrote:
> The printed symbol (represented by $#9792; above) that the write(*,*)
> CHAR(11) produces is reminiscent of what I get with the orginal ANSI
> escape codes so maybe I am flogging a dead horse as the saying goes.
You are. The MS Fortran is giving you a 16-bit executable. In
Windows 2000 and later, only 16-bit executables can use ANSI escape
sequences (in conjunction with ANSI.SYS), 32-bit EXEs cannot.
Steve
| |
| les.denning@tiscali.co.uk 2007-06-20, 10:06 pm |
|
I have had one of those Eureka moments!
So just to complete the picture after some digging and delving I came
up with what just may be the obvious and it works!
program coltest
c Version Les200607
character(8) command
command(1:8)='color 08'
CALL SYSTEM(COMMAND)
end program coltest
Compiled with both the g95 and gfortran compilers this little routine
changes the screen background and text colours in accordance with
this:
C:\My FORTRAN>color /?
Sets the default console foreground and background colors.
COLOR [attr]
attr Specifies color attribute of console output
Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
If no argument is given, this command restores the color to what it
was
when CMD.EXE started. This value either comes from the current
console
window, the /T command line switch or from the DefaultColor registry
value.
The COLOR command sets ERRORLEVEL to 1 if an attempt is made to
execute
the COLOR command with a foreground and background color that are the
same.
Example: "COLOR fc" produces light red on bright white
C:\My FORTRAN>
Regards,
Les.
| |
| les.denning@tiscali.co.uk 2007-06-20, 10:06 pm |
| On Jun 20, 5:53 pm, dpb <n...@non.net> wrote:
> I posted that "eureka moment" solution about 10 minutes after your
> question according to my newsreader's timestamps... :)
>
You did indeed post this:
iret = system('color xy')
and thank you for it.
I saw your post after I posted the line CALL SYSTEM(COMMAND) and
seeing it puzzled me because
I am sure the form you gave to use SYSTEM in ought to work but....
I did try STATUS = SYSTEM(COMMAND) with STATUS declared integer but
the compilers I am using would not have it. The compiler message said
a variable was expected after the =
This I found bizzare especially as I had tracked down both of these
lines in the fortran manual and had cut and pasted them into my tester
program.
So yes thank you for that it is certainly an answer with some
compilers I am sure.
I am going to revisit your form of the usage to see if I can bottom
out why my neither g95 or gfortran would accept my code. This points
the finger at a shortcoming of mine I guess.
Regards,
Les.
| |
| les.denning@tiscali.co.uk 2007-06-20, 10:06 pm |
|
> I am going to revisit your form of the usage to see if I can bottom out why my neither g95 or gfortran would accept my code. This points the finger at a shortcoming of mine I >guess.
OK I hold my hand up, this works:
program coltest
c Version Les200607
integer STATUS
character(8) command
command(1:8)='color 08'
c CALL SYSTEM(COMMAND)
STATUS = SYSTEM(COMMAND)
end program coltest
The comment c on the CALL line made all the difference. It's one or
the other it seems which after all is fair enough I guess.
Now having had a play I find that this colour changing technique is OK
but not as flexible as the old ANSI.sys escape codes were, as it
flirts the whole screen, scroll back buffer to boot to the new colour
regime. Whereas my the old 16 bit executable only changed the colours
from the point of issuing the command onwards. Now even I believe this
is a bridge to far for the lastest implementation....... but does
someone know better? Oh for a smiley :) or a wink ;)
| |
| Steven G. Kargl 2007-06-20, 10:06 pm |
| In article <1182365494.414755.85710@g4g2000hsf.googlegroups.com>,
les.denning@tiscali.co.uk writes:
>
>
> OK I hold my hand up, this works:
>
> program coltest
> c Version Les200607
> integer STATUS
> character(8) command
> command(1:8)='color 08'
> c CALL SYSTEM(COMMAND)
> STATUS = SYSTEM(COMMAND)
> end program coltest
>
> The comment c on the CALL line made all the difference. It's one or
> the other it seems which after all is fair enough I guess.
From gfortran.info:
This intrinsic is provided in both subroutine and function forms;
however, only one form can be used in any given program unit.
--
Steve
http://troutmask.apl.washington.edu/~kargl/
| |
| Richard Maine 2007-06-20, 10:06 pm |
| <les.denning@tiscali.co.uk> wrote:
> c CALL SYSTEM(COMMAND)
> STATUS = SYSTEM(COMMAND)
> end program coltest
>
> The comment c on the CALL line made all the difference. It's one or
> the other it seems which after all is fair enough I guess.
Yes. System is a compiler-dependentextension. It is a fairly common one,
but details do vary from one compiler to another. On some compilers it
is a function. On others it is a subroutine. (Other details also vary).
I think there are even some compilers that accept it either way, but
trying to use it both ways in the same scoping unit is likely to cause
problems with having the same name used for 2 different things.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
| |
| les.denning@tiscali.co.uk 2007-06-20, 10:06 pm |
| Guys,
Thank you for your patience with my elderly incompetence, good advice
and follow up information.
All to help a complete stranger it is remarkable generosity and very
much appreciated.
For anyone who wants to play with the screens colours as an
alternative to the obvious, color xy at the COMMAND PROMPT try this
with the syntax: coltest xy
program coltest
c Version Les200607
INTEGER :: i
integer STATUS
character(8) command
CHARACTER(len=32) :: arg
DO i = 1, iargc()
CALL getarg(i, arg)
END DO
command(1:8)='color '//arg
write(*,*)"]",command,"["
CALL SYSTEM(COMMAND)
c STATUS = SYSTEM(COMMAND)
end program coltest
Thanks again.
Regards,
Les.
| |
| les.denning@tiscali.co.uk 2007-06-20, 10:06 pm |
| I am a well meaning amateur at this and a rusty one at that. Having
written the original source code a decade or more ago, not as a
computer programmer I hasten to add just an engineer who needed to do
some sums, when you wrote:
>
> "Try whatever is the F77 extension name for passing a command to the shel=
l=2E
>
I was at a loss and the code below is the best way I have to explain
my dilemma.
>From my simple point of view the ANSI escape sequence was passed with
the WRITE statement not a command.
c***************************************
*******************************
c*SUBROUTINE FOR COLOUR IF THE DRIVER ANSI.SYS IS LOADED IN
CONFIG.SYS*
c***************************************
*******************************
c
subroutine colour(nc,moncol,Ifg,Ibg)
c
character*6 moncol
if (nc.eq.6.and.moncol(1:3).eq.'col') then
write(6,'('' ['',I2,'';
1;'',I2,''m'',''[K'',''[1A'')')Ifg,Ibg
else
write(6,*)
endif
return
end
c
c
c***************************************
**********************************
c* SUBROUTINE TO WRITE LAST MENU ITEM OUTPUT TO THE RESULTS FILE
TRS.RES *
c***************************************
**********************************
c
subroutine writefile(ItemOk,FileFlag)
c
include 'trs.inc'
c integer fWhite,bBlue
character*1 FileFlag
c
GoOn =3D 0
if (ItemOk.ne.0) then
FileFlag=3D'y'
call colour(6,moncol,fWhite,bBlue)
if(ItemOk.eq.20) write(6,'(3x,
>''Review of Previously Displayed Screens is complete.'',/)')
So 'Review of Previously Displayed Screens is complete.' is displayed
in white on a blue background.
With this technique you could present each line of screen output with
a different colour regime should you so wish and still can with the
source code compiled to a 16 bit executable. For a reason I am
beginning to question I thought moving to a 32 bit executable would be
better and in some respects it is. Scroll bars without resorting to
SCROLLit.exe for one thing.
I bet you are not used to coping with an old duffer like me!
Regards,
Les.
| |
| John Harper 2007-06-20, 10:06 pm |
| In article <1182352972.284263.73730@k79g2000hse.googlegroups.com>,
<les.denning@tiscali.co.uk> wrote:
>
>I have had one of those Eureka moments!
>
>So just to complete the picture after some digging and delving I came
>up with what just may be the obvious and it works!
>
> program coltest
>c Version Les200607
> character(8) command
> command(1:8)='color 08'
> CALL SYSTEM(COMMAND)
> end program coltest
>
>Compiled with both the g95 and gfortran compilers this little routine
>changes the screen background and text colours
What operating system does that work on? My unix one says at run time:
color: not found
after compiling with g95, and leaves everything the same colour it was.
-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
| |
| Terence 2007-06-20, 10:06 pm |
| For years we've been giving away the TAU Systems sources to anything
on-screen for text writing reading and editing and decorating in 256
colours, and scrolling and much more, for
1) MS F77 calling conventions to MSDOS services.
2) CVF F95 calling conventions to internal services and API's.
Both use the same fortran calls and so work with whatever you compile
with.
Note, these are Text User Interfaces, not graphics.
There is no need to use the ANSI control code methods.
If you change the compiler you just change the library linked with the
programs.
| |
| les.denning@tiscali.co.uk 2007-06-21, 10:06 pm |
| On Jun 21, 6:51 pm, dpb <n...@non.net> wrote:
> You can still get the objective, but it's more work -- ...................
Wow that's a mouthful and more than an earful for me but mistake me
not I extend my thanks for all the information you have presented me
with. I will take stock and read it again in a minute as after a
couple of passes I often get the gist of what seemed beyond me the
first time through! Maybe I am on a convergent track though as today I
have been pointed at DISLIN a g95 compatible Graphical Library Library
from http://www.mps.mpg.de/dislin/windows.html and I have download the
G95 (Mingw) Option. This one says it is for use with the Mingw g95
compiler I have been using. You are right that I have the gfortran
compiler too and for some things they seem interchangeable but I have
a suspicion that is not true for all.
The explanation of the way ANSI.sys is a TSR (that abbreviation
stirred the dormant memory cells and I had to go to Wiki to awaken
them) sifting through the write statement's contents for bits it knew
what to do with brought a clarity to what I could see was happening
without a real concept of the mechanism. Yes of course I see now why
the color command cannot influence particular characters. Thank you
for your guidance on this voyage od discovery!
I will see if I can understand what I have in this DISLIN download
shortly.
Regards,
Les.
| |
| les.denning@tiscali.co.uk 2007-06-21, 10:06 pm |
| On Jun 21, 7:44 pm, les.denn...@tiscali.co.uk wrote:
>
> I will see if I can understand what I have in this DISLIN download shortly.
Having spent some time with DISLIN I see what it is and it does
produce some very nice outputs but unless I am mistaken there is not
the "dynamic" interactive aspect that I am looking for.
This may be me slowly apprecating and beginning to understand what I
have already been told about needing access to the Windows API.
I am more used to a "Forum posting enviroment" where you can upload
"pictures" but here are some links to photobucket where I have put
some screen shots from my 16 bit executable displaying the colours I
was used to having before compiling it to the 32 bit executable:
Typically the white text is information and the yellow text is for
prompts and input.
http://img.photobucket.com/albums/v634/LesD123/trs1.jpg
http://img.photobucket.com/albums/v634/LesD123/trs2.jpg
http://img.photobucket.com/albums/v634/LesD123/trs3.jpg
Does this help explain my dilemma?
I know there will be some who fall about laughing at the antiquity
that I want to perpetuate but I can take it! :)
Regards,
Les.
| |
| Terence 2007-06-22, 4:16 am |
| > I don't know much of DISLIN other than knowing it exists so can't
> usefully comment on its features. Terence's user library sounded like
> perhaps an useful alternative that basically does the "wrapper" thing I
> was talking about but he didn't give a link for more info and I didn't
> try a search. If it works w/ other than the MS or CVF compilers, I
> couldn't parse the precise meaning in his previous posting.
Just e-mail me for the TUI sources, saying if you want the F77 (MSDOS
and command-line via cmd.exe or command.com) or the F90/95 version.
DOS version is used since 1985 till today and the calling (using)
commercial programs are updated quarterly and never, ever give any
problems. The calls here are to ASM routines which call MSDOS
services. Best just to use the SAPLIB.lib library when linking to be
totally transparent.
Note W2K and XP computer targets need the compiled executable to have
stack increased 4k beyond the default to accommodate Microsoft's
"security fixes" which use the user stack (!!!!).
You need to use EXEMOD.exe which itself has to be upgraded by 4K for
the same reason. Will supply this on request
The F90/95 version certainly compile/runs on CVF6.6c, but untested for
Intel 9.x (or any other fortran compiler) and probably would need
other USE statements and some changes for the CVF internals that Intel
doesn't have or support. Will supply TUI.F90 and TUIMOD.F90 interface.
This has Integer*4 versions of some DOS Integer*2 calls (with
differerent names) as well as the Integer*2 versions.
The calls here are to Fortran functions which then call the
appropriate internal or API and return a result code as well as as
operation.
I also have DISLIN (no relation), and the author wrote to say he no
longer wants fees for it.
| |
| Edward N Bromhead 2007-06-23, 8:06 am |
| Les,
I'm a big fan of Salford (now Silverfrost) FTN - was FTN77, then FTN90,
is now FTN95. This has routines for setting the colour on text screens,
positioning the cursor etc etc etc, although you need to download the
FTN77 documentation to get that section of the manual (it isn't in the
online
help file). The free for personal use compiler also allows you to write
programs for windows including graphics and a proper windows interface -
but doesn't turn its nose up at simple text mode if that is what you want.
Eddie
| |
| les.denning@tiscali.co.uk 2007-06-24, 4:20 am |
| On Jun 23, 10:10 am, "Edward N Bromhead"
<edward.bromh...@deletethisbitbinternet.com> wrote:
> Les,
>
> I'm a big fan of Salford (now Silverfrost) FTN - was FTN77, then FTN90,
> is now FTN95. This has routines for setting the colour on text screens,
> positioning the cursor etc etc etc, although you need to download the
> FTN77 documentation to get that section of the manual (it isn't in the
> online
> help file). The free for personal use compiler also allows you to write
> programs for windows including graphics and a proper windows interface -
> but doesn't turn its nose up at simple text mode if that is what you want.
>
> Eddie
Hi Eddie,
Thanks for the thumbs up on Salford FTN90. I used their FTN77 years
ago with the power system transient analysis program ATP I will keep
it in mind.
Right now I am trying to get off the ground with Terence's TUI.F90 and
TUIMOD.F90 interface that he has kindly made available to me.
Les.
| |
| Terence 2007-06-24, 8:09 am |
| Kes,
I have dislin and checked what it did.
It was quite respectable for when it was written, but it is DOS only.
(Unless the prof wrote a new one after about 20 years!)
Terence Wright
| |
| Terence 2007-06-24, 8:09 am |
| K,L? Oh well, near enough!
And I thought it was "reply to author"!
Maybe the mouse is sick.
| |
| les.denning@tiscali.co.uk 2007-06-24, 7:08 pm |
| On Jun 24, 10:46 am, Terence <tbwri...@cantv.net> wrote:
> Kes,
> I have dislin and checked what it did.
> It was quite respectable for when it was written, but it is DOS only.
> (Unless the prof wrote a new one after about 20 years!)
> Terence Wright
The one I downloaded came from here:
http://www.mps.mpg.de/dislin/windows.html
and it sure looks like it is Windows based now!
Take a look at the Examples.
I have drawn a blank trying to find an API library for my free g95
compiler to try with your TUIMOD.F90 and TUI.F90 files for the moment.
I shall go a Googling again but I have run out of steam right now.
Regards,
Les.
| |
| Richard Maine 2007-06-24, 7:08 pm |
| <les.denning@tiscali.co.uk> wrote:
> On Jun 24, 10:46 am, Terence <tbwri...@cantv.net> wrote:
>
> The one I downloaded came from here:
>
> http://www.mps.mpg.de/dislin/windows.html
>
> and it sure looks like it is Windows based now!
And more brands of Unix than I care to list (including Linux and OS X),
plus VMS. All in all, a pretty wide a list of supported compilers and
operating systems.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
| |
| Terence 2007-06-24, 7:08 pm |
| (Les)
> The one I downloaded came from here:
>
> http://www.mps.mpg.de/dislin/windows.html
I checked again and I found the same name in an htm.TAR file (of date
far more recent) by a different author, but still MS-DOS. This version
has the follwing information (shortened by me). There is also a 9.1
version around.
Date : 07.11.2005
Version: 9.0 / MS-DOS
Author : Helmut Michels,
| |
| Terence 2007-06-24, 7:08 pm |
|
>
> And more brands of Unix than I care to list (including Linux and OS X),
> plus VMS. All in all, a pretty wide a list of supported compilers and
> operating systems. (R. Maine)
Here's the full list I dug out of the documentatiion on what I just un-
tarred.
It does seem there is GNU and G77 supprt and reference to G90
elsewhere.
-----------------------------------------------------------
File Computer/Oper.-System Compiler
-----------------------------------------------------------
dl_90_dj.zip IBM-PC / MS-DOS GNU-GCC (DJGPP v2)
dl_90_g7.zip IBM-PC / MS-DOS G77 (DJGPP v2)
gcl_50.zip IBM-PC / MS-DOS
-----------------------------------------------------------
| |
| Richard Maine 2007-06-24, 7:08 pm |
| Terence <tbwright@cantv.net> wrote:
>
> Here's the full list I dug out of the documentatiion on what I just un-
> tarred.
> It does seem there is GNU and G77 supprt and reference to G90
> elsewhere.
>
> -----------------------------------------------------------
> File Computer/Oper.-System Compiler
> -----------------------------------------------------------
> dl_90_dj.zip IBM-PC / MS-DOS GNU-GCC (DJGPP v2)
> dl_90_g7.zip IBM-PC / MS-DOS G77 (DJGPP v2)
> gcl_50.zip IBM-PC / MS-DOS
> -----------------------------------------------------------
I don't know where that came from... ah, but pawing around the web site
shows something a lot like that (one version newer, but ortherwise very
simillar) under the download page for msdos. The downloads for other
operating systems are also at the same site, but oddly, if you go to the
ms-dos page only the msdos ones are there. :-) A full and current list
can be found at dslin's web site at
<http://www.mps.mpg.de/dislin/overview.html>
The list is way too long for me to bother copying.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
| |
| michels@mps.mpg.de 2007-06-25, 10:07 pm |
| On 24 Jun., 11:46, Terence <tbwri...@cantv.net> wrote:
> Kes,
> I havedislinand checked what it did.
> It was quite respectable for when it was written, but it is DOS only.
> (Unless the prof wrote a new one after about 20 years!)
> Terence Wright
I have started writing DISLIN before 20 years, but it was not finished
at that time.
The current version 9.1 was released in November 2006. The next
version 9.2 will be
released in September 2007, hopefully. DISLIN supports many operating
systems.
MS-DOS is just one of them and not the most important.
Regards,
Helmut Michels
http://www.dislin.de
|
|
|
|
|