next up previous contents
Next: Notes Up: pil Previous: Parameters   Contents


Calling PIL library functions from Fortran 90

Applications can use PIL services in one of 2 different modes. The first one ISDC_SINGLE_MODE is the simplest one. In this mode application simply includes PIL definitions from compiled module file (USE PIL_F90_API statement), calls PILINIT, plays with parameters by calling PILGETXXX/PILPUTXXX functions and finally shuts down PIL library by calling PILCLOSE. The skeleton code is given below.

PROGRAM SKELETON

USE PIL_F90_API

integer :: r
REAL*8  :: real8vec(5)

r = PILINIT()
if (ISDC_OK /= r) STOP

r = PILGETBOOL("boolname1", INTVAR)
r = PILGETREAL("realname3", REALVAR)
r = PILGETREALVECTOR("real8vecname", 5, real8vec(1))

! now execute application code ...
r = PILEXIT(ISDC_OK)

END

The second mode, called ISDC_SERVER_MODE allows for multiple rereads of parameter file. Using this method application can exchange data with other processes via parameter file (provided other processes use locks to assure exclusive access during read/write operation). One example of code is as follows :

PROGRAM SKELETON2

USE PIL_F90_API

integer :: r

r = PILINIT()
if (ISDC_OK /= r) STOP

DO
  r = PILRELOADPARAMETERS()
  r = PILGETBOOL("boolname1", INTVAR)
  r = PILGETREAL("realname3", REALVAR)
  IF (BREAKCONDITION) BREAK

! now execute loop code ...

  r = PILPUTINT("intname45", INTVAR)
  r = PILFLUSHPARAMETERS()

  IF  (BREAKCONDITION) BREAK

ENDDO

r = PILEXIT(ISDC_OK)
END

After initial call to PILINIT application jumps into main loop. In each iteration it rereads parameters from file (there is no need to call PILRELOADPARAMETERS during first iteration), Based on new values of just read-in parameters (which might be modified by another process) application may decide to exit from loop or continue. If it decides to continue then after executing application specific loop code it calls PILFLUSHPARAMETERS to signal other process that it is done with current iteration. Algorithm described above is very simple, and it real applications can be much more complicated.

As mentioned earlier, applications written for ISDC should not use PILINIT/PILCLOSE directly. Instead they should use COMMONINIT/COMMONEXIT functions from ISDC's Common Library.



Subsections
next up previous contents
Next: Notes Up: pil Previous: Parameters   Contents
Bryan Irby 2004-10-05