Using DEC Fortran and the PC farm on Windows NT 4 - LHCb

advertisement
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Using DEC Fortran and the PC farm on Windows NT 4
by Eric van Herwijnen, LHC-B (eric.van.herwijnen@cern.ch)
version 1, 1 december 1997
Introduction
Windows NT is in heavy use as a desktop system in LHC-B for most daily work. Clearly, it would be nice
to be able to do programming tasks in the same environment. For batch processing, Linux is also being
used more and more.
This document describes the steps that are necessary to compile and execute Fortran programs on Windows
NT4 at CERN, and how to use the PC farm to do batch processing. The route sometimes contains some
unexpected turnings, so keep this guide handy when you are about to embark.
Word 97 version:
PostScript version:
http://lhcb.cern.ch/userguides/word/pcsfguide.doc
http://lhcb.cern.ch/userdocs/postscript/pcsfguide.ps
1
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Table of Contents
USING DEC FORTRAN AND THE PC FARM ON WINDOWS NT 4 ................................................. 1
INTRODUCTION ............................................................................................................................................ 1
TABLE OF CONTENTS .................................................................................................................................. 2
1. DIGITAL VISUAL FORTRAN VERSION 5 .................................................................................................... 3
2. USING VISUAL FORTRAN TO COMPILE SICB ........................................................................................... 6
3. EXECUTING SICB.EXE .............................................................................................................................12
4. USING PCSF, THE CERN PC SIMULATION FACILITY .............................................................................14
ACKNOWLEDGMENTS .................................................................................................................................19
2
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
1. Digital Visual Fortran version 5
DEC Fortran may be installed on Windows NT 4 or Windows 95. Click on the command More Windows
95 groups, and select the 'Development' folder:
Then select 'Install Digital Visual Fortran 5":
3
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Remember to note down the serial number as you'll need it during the installation:
Once you have succesfully installed Digital Visual Fortran 5.0, you need to install upgrade 1 of both the
software and the documentation:
The last step is to update your environment variables with the correct pointers to the CERN library files.
Choose the 'New' version of the CERN library.
4
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Now you are ready to use DEC Visual Fortran to compile and execute Fortan programs such as SICB on
Windows NT 4.
5
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
2. Using Visual Fortran to compile SICB
Open the Developer Studio as shown above. Start a blank workspace, by going into File, New, and
clicking on the "workspace" tab. You may call your workspace 'sicb' for example. If your intention is to
use the PC farm later, you should save your workspace on a disk that is accessible from a NICE server, for
example your "J:/" disk.
Now create a new project within your sicb workspace, by clicking on the "Projects" tab. You may call this
project "sicb" again, or choose some other name. This project must be a "Win32 Console Application". Be
sure to check the button "Add to current workspace":
6
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
The project sicb will contain only the main Fortran program, and the CERN library files. All our own
subroutines will go into a library, for which we need to create a separate (sub) project. Create a new
project, called "sicblib", which is of type "Win32 Static Library", check "Add to current workspace" and
check the dependency of sicb (the project containing the main routine):
Make sicblib into the active project by going into Project, Set Active Project, check sicblib:
So far, Visual Fortran will have automatically created a directory for the workspace (called Sicb), with
inside it two subdirectories (called Sicb and Sicblib) for us. At this point it is a good idea to fetch the latest
version of the Sicb tar file from cernsp, for example version 1.12 can be found at
7
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
/afs/cern.ch/lhcb/cvs/checkout/v112.dbx/v112.tar. This version contains source code with no include
files; the common blocks are fully expanded. This is because we have not yet found a convenient way to
invoke the C preprocessor to expand these include files with Visual Fortran. Expand the tar file by using
winzip32, which is called automatically if you double click on it in the Windows Explorer. Expand the files
into the sicb project directory. Also fetch the standard distribution tar file at
/afs/cern.ch/lhcb/cvs/checkout/v112.tar. This file should be expanded into a directory v112 which is a
subdirectory of the sicb project directory.
If you want to do code development, it is probably best to stick with the default project active
configuration, which is 'Debug'. The compiler runs at 0 optimization and allows you to use the interactive
debugger.
If you are sure your program doesn't contain any errors, and you don't need to do any debugging, you can
change the active settings by going into Build, Set Active Configuration. Select the line with 'Win 32
Release' in it and click on OK. Do the same for the library project (first change the active project as
described above):
Now we can add our subroutines into the siclib project by going into Project, Add to project, Files:
8
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Select all files with extension .f (that you put into the sicb folder before, see above), and click on ok:
This action will have inserted too many files into the library project. You need to remove the following
ones (and insert them into the sicb main project): all files starting with Fg (these are Geant routines that
overwrite the dummy routines in the CERN library); fsicb (the main program); fsicbint (an interactive
version, remove it completely); fugeom, fuginit, and fuglast:
Now change the active project to be sicb instead of sicblib, and add the above mentioned files to it. In
addition, add the following files from the CERN library: GEANT321.LIB, GRAFLIB.LIB,
GRAFX11.LIB, IX_HIGZ.LIB, JETSET74.LIB, KERNLIB.LIB, MATHLIB.LIB, PACKLIB.LIB,
PAWLIB.LIB, PHTOOLS.LIB
These files are found in the directory: Z:\P32\CERN\new\DF\LIB (and have extension .LIB).
9
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Depending on the version of the CERN library, you may also need the file GFHSTA.OBJ which contains a
bugfix to Geant.
Finally, we need to add the file sicb.dat into the project. It will be somewhere inside sicb, after the
expansion of the tar file. This file will have to be moved later to correspond with the environment variable
settings.
We now need to set some options for the linker. Click on Project Settings, and choose the Link tab. This
may take a long time if all files are visible in the FileView. Although the executable in this case is
debuggable, it works the same for the Release version. Add the string "/nodefaultlib:"OLDNAMES.lib" to
the end of the string in the Project Options window:
Now we are ready to compile the sicb executable, sicb.exe. To do this, simply go to the Build menu, under
which should be mentioned "Build sicb.exe":
10
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Now Visual Fortran will build the executable, and place it in a subdirectory of the sicb project directory
called "Release":
11
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
3. Executing sicb.exe
To execute sicb.exe, you need to define some environment variables, modify the data file, place the field
map in the correct place and tell the system where to find it.
First make sure that your directory structure is similar to the one shown in the figure above, i.e. the file
sicb.dat should be placed inside the Release (or debug) directory, and the fieldmap should be placed in
Release/Sim/Data. The V111 (or later versions of sicb) directory structure comes straight from the
expanded standard (not source code only) tar file.
On Windows NT, the environment variables are set via the control panel, by clicking on the the System
icon, then selecting the tab marked 'Environment':
Five variables should be defined, using the variables %HOMESHARE% and %HOMEPATH% instead of
absolute disk letters and directory paths because absolute settings are not known in the batch environment.
They are shown in the table below:
Variable
Value
LHCBDBASE
%HOMESHARE%%HOMEPATH%\Sicb\Sicb\V111\Dbase
LHCBHOME
%HOMESHARE%%HOMEPATH%\Sicb\Sicb\Release
LHCBROOT
%HOMESHARE%%HOMEPATH%\Sicb\Sicb
LHCBVERS
V111
SICBCARDS
%HOMESHARE%%HOMEPATH%\Sicb\Sicb\Release\sicb.dat
The LHCBVERS variable should contain the version number of the version of sicb that you are using.
Now modify the file "standard.stream" in the directory Sicb\Sicb\V111\Dbase to contain the correct
location of the field map, in terms of the environment variables defined above:
12
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Now use Visual Fortran to edit the sicb.dat file, to make sure the output it writes goes to the correct place:
For example, in the case of a muon run shown below, the minimum bias events are written into a file
mbias_1.dat. If this file should be written onto the NICE disk, the filename should be prefixed by the
variable string %HOMESHARE%%HOMEPATH%\. If this file is to be written on the disk of the batch
PC, for later staging and writing onto tape, it is not necessary to write it onto a NICE disk first, and the
prefix is not required.
13
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
To execute sicb.exe, click on the button with the exclamation mark, or go there via the Build menu. If a
subroutine was edited since the last compilation, it will automatically be recompiled.
4. Using PCSF, the CERN PC Simulation Facility
A userguide to PCSF can be found at http://wwwinfo.cern.ch/~boissat/pcsf/intro.html. Before using this
facility you need to register your NICE/CERNSP account with the UCO, or directly with Christian Boissat.
You also need a SHIFT/CORETAPES account. When this has been done, you need to install the lsf batch
environment on your PC.
Now you can use the Submit tool to send a job to PCSF, and the List tool to query their progress.
14
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
At the end of the job the submitter is informed by email if the job ran correctly or not. The simplest way to
run a job is via a simple script (.bat file), as follows:
rem
rem Define your home directory
rem
set home=%homeshare%%homepath%
echo. >> %home%\LSFJOB\jobs
echo Job started >> %home%\LSFJOB\jobs
echo "===================================" >> %home%\LSFJOB\jobs
time /t >> %home%\LSFJOB\jobs
Date /t >> %home%\LSFJOB\jobs
echo.
echo "===================================" >> %home%\LSFJOB\jobs
echo.
rem
rem Copy Fortran source files from user home directory to the current
farm working one
rem
for %%f in (sicb.exe) do copy %home%\SICB\SICB\RELEASE\%%f .
rem Set the CERN environment variables
rem ==================================
call %cern_local%\batch\CernEnv
rem Set the CERN libraries names to build the user's application
rem ============================================================
call cernlib packlib
echo.
echo "===================================" >> %home%\LSFJOB\jobs
echo.
15
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
Rem Run application we have been built
sicb.exe >> %home%\LSFJOB\jobs
%home%\LSFJOB\Sdispose Mbias_1.dat sp024 lhcbdata RZ1017 1 -FF -L23040
>> %home%\LSFJOB\jobs
time
time
Date
echo
echo
echo
/t
/t >> %home%\LSFJOB\jobs
/t >> %home%\LSFJOB\jobs
"===================================" >> %home%\LSFJOB\jobs
Job Finished
>> %home%\LSFJOB\jobs
"===================================" >> %home%\LSFJOB\jobs
This script executes sicb.exe, then calls the Sdispose.bat script which stages the output and writes it onto
tape.
The source of the Sdispose.bat script is:
@echo off
rem
rem
Purpose:
rem
Sdispose.cmd shell script for copying data file from disk
to tape
rem
Syntax:
rem
Sdispose {local_file} {stage_host} {pool_name} {vid} {fseq}
[ {args} ]
rem
Example:
rem
Sdispose stage.out sp024 lhcbdata Y10501 12 -s10 -FF L131072
rem
setlocal
set rootdir=%HOMESHARE%%HOMEPATH%\SICB\SICB\RELEASE
set infile=%rootdir%\Sdispose.sh
set path=Z:\P32\Cygnus\Cygwin32\bin;%path%
set local_file=%1
set stage_host=%2
set pool_name=%3
set vid=%4
set fseq=%5
set args=%6 %7 %8 %9
if exist %infile% (
bash < %infile%
goto end
)
:usage
echo.
echo Usage: %0 {local_file} {stage_host} {pool_name} {vid} {fseq}
{args}.
:end
echo.
endlocal
The Sdispose.sh command is a Bash script (which is known in the batch environment):
# Bash script
16
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
#
set -x
# Debug mode
PATH=//Z/P32/Batch/bin:${PATH}
# Path
USAGE=">>> Usage: Sdispose {local_file} {stage_host} {pool_name} {vid}
{fseq} [ {args} ]."
#
#
Usage
if [ -z "${LOCAL_FILE}" -o -z "${STAGE_HOST}" -o -z "${POOL_NAME}" -o z "${VID}" -o -z "${FSEQ}" ]
then
echo "${USAGE}"
exit 1
#elif [ ! -f ${LOCAL_FILE} ]
#then
#
echo "File not found."
#
exit 2
fi
#
#
Let's go
stageout -h ${STAGE_HOST} -p ${POOL_NAME} -V ${VID} -q ${FSEQ} ${ARGS}
remote_path=`stageqry -h ${STAGE_HOST} -p ${POOL_NAME} -V ${VID} -q
${FSEQ} -P | tr -s '\r'`
if [ -n "${remote_path}" ]
then
rfcp ${LOCAL_FILE} ${remote_path}
echo stageput -h ${STAGE_HOST} -p ${POOL_NAME} -V ${VID}
else
exit 3
fi
exit 0
#EOF
To read the tape and write the file on disk, run the following job:
rem
rem Define your home directory
rem
set home=%homeshare%%homepath%
echo. >> %home%\LSFJOB\jobs
echo Job started >> %home%\LSFJOB\jobs
echo "===================================" >> %home%\LSFJOB\jobs
time /t >> %home%\LSFJOB\jobs
Date /t >> %home%\LSFJOB\jobs
echo.
echo "===================================" >> %home%\LSFJOB\jobs
echo.
%home%\LSFJOB\Sfetch %home%\Sicb\Sicb\Mbias_1.dat sp024 lhcbdata RZ1017
1 -FF -L23040 >> %home%\LSFJOB\jobs
rem Copy the result of the work back to user's home directory
rem copy *.out
%home%\LSFJOB\
17
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
The Sfetch.bat script looks as follows:
@echo off
rem
rem
Purpose:
rem
Sfetch.cmd shell script for copying data file from tape to
disk
rem
Syntax:
rem
Sfetch {local_file} {stage_host} {pool_name} {vid} {fseq} [
{args} ]
rem
Example:
rem
Sfetch stage.in sp024 lhcbdata Y10501 12 -s10 -FF -L131072
rem
setlocal
set rootdir=%HOMESHARE%%HOMEPATH%\SICB\SICB\RELEASE
set infile=%rootdir%\Sfetch.sh
set path=Z:\P32\Cygnus\Cygwin32\bin;%path%
set local_file=%1
set stage_host=%2
set pool_name=%3
set vid=%4
set fseq=%5
set args=%6 %7 %8 %9
if exist %infile% (
bash < %infile%
goto end
)
:usage
echo.
echo Usage: %0 {local_file} {stage_host} {pool_name} {vid} {fseq}
{args}.
:end
echo.
endlocal
And the Sftech.sh file:
# Bash script
#
set -x
# Debug mode
PATH=//Z/P32/Batch/bin:${PATH}
# Path
USAGE=">>> Usage: Sfetch {local_file} {stage_host} {pool_name} {vid}
{fseq} [ {args} ]."
#
#
Usage
if [ -z "${LOCAL_FILE}" -o -z "${STAGE_HOST}" -o -z "${POOL_NAME}" -o z "${VID}" -o -z "${FSEQ}" ]
then
echo "${USAGE}"
exit 1
fi
#
18
Using DEC Fortran and the PC farm on Windows NT 4 - version 1 07/03/16
#
Let's go
stagein -h ${STAGE_HOST} -p ${POOL_NAME} -V ${VID} -q ${FSEQ} ${ARGS}
remote_path=`stageqry -h ${STAGE_HOST} -p ${POOL_NAME} -V ${VID} -q
${FSEQ} -P | tr -s '\r'`
if [ -n "${remote_path}" ]
then
rfcp ${remote_path} ${LOCAL_FILE}
else
exit 2
fi
exit 0
#EOF
Note that this rather indirect route is required because the standard staging commands can not be used in
the batch environment as there is no way to catch a variable from a command and put it back in a variable
in a .bat file. The source of these scripts may be found at http://lhcb.cern.ch/software, follow the links to
sicb.
Acknowledgments
I wish to thank Valery Fine, without who I would have been unable to do this work; Christian Boissat for
his help with using the farm, writing the scripts for staging and his help in getting the service running.
Finally I would like to thank Andrei Tsaregorodtsev for his help, patience and helpful suggestions.
19
Download