[comp.lang.fortran] fortran ncargraphics curses

simon@giaea.gi.oz (simon shields) (05/30/91)

ENVIRONMENT - HP9000/825 HP-UX

Hi All

I was wondering if anyone has tried mixing "curses" routines with fortran and
ncargraphics. I tried unsuccessfully. I set up a test program in C which used
curses to read in a character at a time. This worked fine. I put this routine
into a library and linked it with my ncargraphics routines and it got stuck at
the "initscr" curses routine. I then set up a fortran test program (calling the
c routines from within fortran), to do the same thing and it also worked fine.
I put this routine into a library and again "initscr" was the stumbling block.

test.c
-------

/*
     FILE
	 test.c
     PURPOSE
	 To test curses

	  #include <curses.h>
	  cc [ flags ] file ...  -lcurses [ libraries ]

     DESCRIPTION
	  These routines provide a method for updating screens with
	  reasonable optimization.  To initialize curses routines, the
	  initscr() routine must be called before calling any other
	  routine that deals with windows and screens.	The endwin()
	  routine should be called before exiting.  To get character-
	  at-a-time input without echoing, (most interactive, screen
	  oriented-programs need this) after calling initscr() the
	  program should call ``nonl(); cbreak(); noecho();''

*/

#include <stdio.h>
#include <curses.h>

main()
{  extern char getach() ; char c ;
   putchar(getach(&c)) ;
   fflush(stdout) ;
}

char getach(c) char *c ;
{
    initscr();
    nonl();
    cbreak();
    noecho();
    flushinp() ;
    *c=getchar() ;
    fflush(stdout) ;
    endwin() ;
    return(*c) ;
}

flushout()
{
    fflush(stdout) ;
}

-----------
test.f
-----------

$ALIAS hpux_read="read" c (%val, %ref, %val)
$ALIAS hpux_initscr="initscr" c 
$ALIAS hpux_nonl="nonl" c 
$ALIAS hpux_cbreak="cbreak" c 
$ALIAS hpux_noecho="noecho" c 
$ALIAS hpux_flushinp="flushinp" c 
$ALIAS hpux_endwin="endwin" c 
	subroutine getach(c)
      integer read     !  (int fildes, char *buf, unsigned nbyte)
	integer fildes/0/, nbyte/1/
	character c, getchar

      call hpux_initscr
      call hpux_nonl
      call hpux_cbreak
      call hpux_noecho
      call hpux_flushinp
      i = hpux_read (fildes, c, nbyte)
      call hpux_endwin
	return 
	end 

----------
I used ar to make up the library thus
ar rv 1.a test.o
And the ncar call was
ncargf77 -g +T -o fourier.7 fourier.7.f 1.a -lcurses

Compiling and linking went off without a hitch. 

If anyone has a clue please give us a buzz (even if you've got something you
think I should try.

Thanks for trying.