next up previous contents
Next: Using the Standard User Up: Adding Code to SNOMAN Previous: Introduction   Contents

Changing an SU User

The following are available:-

For example, let's suppose you want to generate positions randomly within a box. There is no built in generator to do this so you will need your own version of POS_USER and must modify it so that it takes the box dimensions from the MCPI bank. To do this you have to carry out the following steps:-

  1. Take a copy of the dummy pos_user.for from the code directory into your own private directory.

  2. At once you hit a snag. You will also need the include file monte.inc. There are five choices open to you:-

    1. Take a copy of the .inc file from the code area.

    2. If on UNIX you could set up soft links for all the .inc files you need.

    3. If on VMS create a logical name, say SNO_INCDIR, that points the directory holding the include files and then do:-
      include SNO_INCDIR:monte.inc

    4. Just hardwire the required directory e.g.:-
      include /usr/snoguest/snoman/2_07/code/monte.inc
      An easy way to globally change such hardwiring is to copy all the .for files into a temporary file, do a global replace, and then use EXTRACT to split the file apart again.

    5. If your compiler includes an option to specify the directories to search for include files (and most compilers do) then use this feature e.g. VMS:-
      FORT/INCLUDE=U1:[WEST.SNOMAN.3_00.CODE] pos_user.for
      and UNIX:-
      f77 -I../snoman/$SNO_SNOMAN_VER/code pos_user.for

    The last solution is by far the best if the facility is available to you. Of the other schemes, none is ideal although 3 and 4 do allow you to move the code to a new directory without having to worry about the include files. They all require you to review their use when changing versions of SNOMAN. However this is no bad thing; the .inc files represent a large part of the interface between SNOMAN and the user code and this should be checked when changing versions.

  3. Now modify the routine to generate the required distribution. The following will work:-
     
          subroutine pos_user( ipart,xyz )
     
    *     Pick position within a box.
     
          implicit none
     
          include 'monte.inc'
     
          integer           ipart
          real              xyz(3)
     
          real              snoran
     
          xyz(1) = pos_param(ipart,1) + snoran(1)*pos_param(ipart,2)
          xyz(2) = pos_param(ipart,3) + snoran(1)*pos_param(ipart,4)
          xyz(3) = pos_param(ipart,5) + snoran(1)*pos_param(ipart,6)
     
          end
    

  4. Link the code together with SNOlib. If your local software librarian has installed the development tools then you will have a environmental variables (VMS: logical name) called SNO_TOOLS which points to a directory containing the tools. If not then consult him/her about how to link. Assuming the tools are set up then all you need to do is:-

    $SNO_TOOLS/link_snolib.scr "*.o"
    (VMS: @SNO_TOOLS:LINK_SNOLIB pos_user)
    This will combine all the object files together with SNOlib and create the executable file my_snoman.exe. Note: on VMS you cannot wildcard object files. To link selected object files specify a space separated (VMS: comma separated) list of names. To define the output file supply it as the optional second parameter e.g.:-

    $SNO_TOOLS/link_snolib.scr "a.o b.o" test.exe
    (VMS: @SNO_TOOLS:LINK_SNOLIB A.OBJ,B.OBJ TEST.EXE)
    links the object files a and b to make the executable file test.exe.

  5. Take a copy of mc_generator.dat and change the position parameters in the MCPI from:-
       40
       2. 1000000. 1. 2120000. 1.
       0. 0. 0. 0. 0.
    
    to:-
       60
       1. 1.  10. 20. 100. 300.
       0. 0. 0. 0.
    
    which, with the new version of POS_USER, creates points with X in the range 1. to 2., Y in the range 10. to 30. and Z in the range 100. to 400.

  6. Run my_snoman.exe and type @run.


next up previous contents
Next: Using the Standard User Up: Adding Code to SNOMAN Previous: Introduction   Contents
sno Guest Acct 2009-09-09