Commission on Crystallographic Computing

Portable graphic interface for the Fortran program Jana2000

Michal Dusek and Vaclav Petricek

Institute of Physics, Academy of sciences of the Czech Republic, Na Slovance 2, 182 21 Praha 8, Czech Republic.
E-mail:
dusek@fzu.czand petricek@fzu.cz; WWW: http://www-xray.fzu.cz/jana/jana.html;

FTP: ftp://ftp.fzu.cz/pub/cryst/jana2000/

Introduction

Jana2000 [1] is a crystallographic computing system with graphical user interface freely available in http://www-xray.fzu.cz/jana/jana.html. It runs on UNIX and Windows platforms without any change of the look and feel (see Fig 1) and with exactly the same way of control. The program is distributed as compiled binary file for Windows and as a source code for UNIX. The Windows version is developed with Lahey Fortran 95 [2] and Winteracter [3].

[JANA2000 in Windows]  [JANA2000 in Unix]

Fig 1: The basic window of Jana2000 in Windows (a) and UNIX (b) environment.

Most of the system is written in Fortran77 and is common for both UNIX and Windows platforms (see Fig. 2). The development of the graphic interface started in the early 90's when the portability of higher level graphics libraries between various Unix platforms was rather limited. Moreover, the version for Windows ran in a DOS mode with completely different graphics possibilities. Therefore the most convenient way was to use only primitive graphics elements like plotting of line, filling of area, testing of keyboard and mouse events etc. and create own higher level graphics objects. With this access the same look and behaviour of the graphic interface was guaranteed under UNIX and DOS.

[JANA2000 flow diagram]

Fig. 2: Flow diagram of Jana2000. The blue and yellow objects are part of Jana2000 and they are written in Fortran77 and C language, respectively. The white objects must be available in the computer (X11 and Windows API in the user side, Winteracter only for compilation of the Windows version).

At present DOS emulation is no more used for Jana2000 and the problem of a platform independent graphics could be solved using for instance OpenGL libraries. However, we decided to keep our original graphic objects for the following reasons:

  • They are independent on any other software.
  • Their control is very similar to that we could get with professional package.
  • They are fast and reliable.
  • They do not require any preliminary installation at the user side.

Description

Jana2000 runs in a typical event loop, meaning that it waits - after initialization of the graphics and creating of the basic window - for the keyboard, mouse or expose events. Those events trigger an action, typically opening of a user dialogue or starting of some calculation. In order to keep the graphics fast and simple Jana2000 uses only one window for all purposes; user menus, forms and other objects are plotted in that window instead of using child windows as typically do professional graphic systems. Another maybe more limiting difference of standard systems is that cut-and-paste functions utilizing clipboard are not possible with graphics of Jana2000. We hope to activate these functions in future.

The high-level objects, graphics primitives and events testing can be used elsewhere in the common part of Jana2000 (Fig. 2) as the corresponding procedures are written in FORTRAN. Every such graphical request is processed in the following sequence:

Calling procedure -> JANALIB -> GLIB, where JANALIB containing the high level objects (Fig. 3) is common for UNIX and Window environment while GLIB that calls graphic primitives and event testing is different.

[graphics object in JANA2000]

Fig. 3: Example of a high-level graphic object in Jana2000

Under Windows GLIB calls functions of Winteracter that represent Fortran-to-Windows API interface. However, Winteracter does not cover all necessary API functions so some of them are called through a special interface written in C. As the second way is more stable it will be preferred in the future. The Windows API functions are automatically available in any Windows operating system and on the level used in Jana2000 their behaviour is independent on the type of Windows starting from Windows95.

Under UNIX the calling sequence is:

GLIB -> FORTRAN part of FG -> C part of FG -> X11,

where FG is still part of Jana2000. The C part of FG calls directly functions of X11 library that is free software automatically available in any system with X-windows. Its portability across UNIX platforms is guaranteed. The FORTRAN part of FG has been developed in order to unify FORTRAN->C communication. Normally each compiler offers special directives for this purpose that could be very inconvenient because UNIX version of Jana2000 is compiled by users. However, if the arguments of C functions called from FORTRAN are 4 byte integers no special directives are necessary and the code is completely platform independent. Therefore, the main reason for FORTRAN part of FG is to convert any argument to integers. Another source of incompatibility inheres in names of C functions as some FORTRAN compiler expect underscores at the end of function names and the others not. Also case of letters is not guaranteed. This problem is solved in the Makefile that defines this behaviour for various systems and compilers and manages that a proper function names are activated in the FG header files.

Availability

Jana2000 is free software that can be used without any limitation on the assumption that its authors are properly cited. The source code can be downloaded with the UNIX installation files from the above mentioned WWW page. However, the only supported usage of the system is for crystallographic computing. Usage of the graphics interface and other internal libraries is not documented.

References

[1] Petricek,V. and Dusek,M.(2000). The crystallographic computing system JANA2000. Institute of Physics, Praha, Czech Republic

[2] Lahey Fortran 95, version 5.6 (http://www.lahey.com/)

[3] Winteracter, version 2.0 (http://www.winteracter.com/)


These pages are maintained by the Commission Last updated: 15 Oct 2021