Документ взят из кэша поисковой машины. Адрес оригинального документа : http://xmm.vilspa.esa.es/sas/5.4.1/doc/ssclib.ps.gz
Дата изменения: Fri Jan 10 21:56:01 2003
Дата индексирования: Tue Oct 2 02:23:24 2012
Кодировка:

Поисковые слова: arp 220
XMM-Newton Science Analysis System Page: 1
ssclib
January 10, 2003
Abstract
Library of Fortran 90 utilities needed for SAS task development.
1 Description
This library consists of a series of Fortran 90 modules useful for the development of SAS tasks. Each
module is described in a separate section below. Each module is contained in a separate le and will be
compiled separately. The resulting object les will be combined into a single library le.
2 List Parsing
Module name: parse list mod
Author: Dean Hinshaw (University of Leicester, dah@star.le.ac.uk)
This subroutine parses a string containing a delimited list into an array of strings, one element for each
member of the list. The calling sequence is:
SUBROUTINE parse_list(in_str, out_array, in_delim)
CHARACTER(LEN=*), DIMENSION(:), POINTER :: out_array
CHARACTER(LEN=*), :: in_str
CHARACTER(LEN=1), OPTIONAL, INTENT(IN) :: in_delim
where in str is the string to be parsed, out array is returned array of strings, and in delim is the
delimeter seperating the list items. in delim is an optional parameter, and if not given defaults to a
space. Note that in any case list items may not contain spaces. The user also must take care that the
pointer passed as out array has suфcient length to hold the parsed strings.
Additional, if in str begins with an \@", then the string is taken as a lename the list items, one item
for each line of the le.
xmmsas 20030110 1802-5.4.1

XMM-Newton Science Analysis System Page: 2
3 Find a Free I/O Unit
Module name: get free io unit mod
Author: Clive Page (University of Leicester, cgp@star.le.ac.uk)
This subroutine returns a number of a free I/O unit, i.e. one that is not currently allocated to and le.
Teh calling sequence is:
SUBROUTINE get_free_io_unit(nunit)
INTEGER, INTENT(out) :: nunit ! unit number free for use
4 Quick Sorting
Module name: sort mod
Author: Clive Page (University of Leicester, cgp@star.le.ac.uk)
This module contains subroutines to sort a data array into ascending order using Hoare's quick-sort
algorithm. There is a generic interface which supports data types INTEGER, REAL, DOUBLE PRECISION,
and CHARACTER (any length).
The simplest call is:
CALL quick_sort(array)
The array argument has INTENT(INOUT) and returns the data sorted into ascending order.
In some cases it is desirable to know the original order of the data points, for example to sort another
array in the same way. In this case an optional second argument may be given; it returns an integer array
of the same size containing numbers in the range 1 to size(array) which tell you the original position of
each element returned sorted. For example if you do:
unsorted_array = array
call quick_sort(array, index)
then unsorted array(index(i)) = array(i) for all i in [lbound(array), ubound(array)]. Note that array is
always returned sorted, whether index is supplied or not. This can be something to be careful of. Suppose
you have a data structure array which you want to sort in order of one of its constituents, for example a
structure that stores gtis:
type :: gtiType
real(kind(0d0)) :: time
logical :: isStart
end type gtiType
type(gtiType) :: gtiArray(100)
! Fill gtiArray
xmmsas 20030110 1802-5.4.1

XMM-Newton Science Analysis System Page: 3
In this case to sort the logicals as well you will need to do something like the following:
type(gtiType) :: temp_gtiArray(size(gtiArray))
temp_gtiArray%time = gtiArray%time
call quick_sort(temp_gtiArray%time, index)
do i = 1, size(gtiArray)
temp_gtiArray(i)%isStart = gtiArray(index(i))%isStart
! NOT temp_gtiArray(i) = gtiArray(index(i))!! The times are already sorted.
end do
gtiArray = temp_gtiArray
Note that the quick-sort algorithm is on average about twice as fast as heap-sort but becomes much
slower for special cases. This quick-sort algorithm was designed to cope with nearly-sorted data as well
as random data without any signi cant degradation in speed. Note that it is not a stable sort, i.e. equal
values will not necessarily remain in the same relative order.
5 Array Reallocation
Module name: reallocate mod
Author: Dean Hinshaw (University of Leicester, dah@star.le.ac.uk)
This subroutine can be used to reallocate memory space for a pointer to an array, retaining any data
already stored in the array. The calling sequence is:
SUBROUTINE realloc_real32(p, n)
INTEGER, INTENT(in) :: n
where p can have any of the possible speci cations:
REAL(KIND=single), POINTER, DIMENSION(:) :: p
REAL(KIND=double), POINTER, DIMENSION(:) :: p
INTEGER(KIND=int8), POINTER, DIMENSION(:) :: p
INTEGER(KIND=int16), POINTER, DIMENSION(:) :: p
INTEGER(KIND=int32), POINTER, DIMENSION(:) :: p
LOGICAL(KIND=bool), POINTER, DIMENSION(:) :: p
CHARACTER(LEN=*), POINTER, DIMENSION(:) :: p
and n is the size of the reallocated array. The lower bound value of the old array is retained.
If n is greater than the original array size, then the all data from the old array is retained, and the array
values greater then the original array size are unde ned. If n is less than the original array size, then the
rst n data elements from the old array are retained.
xmmsas 20030110 1802-5.4.1

XMM-Newton Science Analysis System Page: 4
6 Constants Module
Module name: constants
Authors: Richard West (University of Leicester, rgw@star.le.ac.uk), Ian Stewart (University of Leicester,
ims@star.le.ac.uk).
The constants module de nes a set of widely used mathematical and physical constants. The constants
are de ned as \double precision" (real (kind=double)).
6.1 Pi-related constants
Name Value Description
Pi 3.1415926535897931 
TwoPi 2.0*Pi 2
FourPi 4.0*Pi 4
PiOverTwo 0.5*Pi =2
OneOverPi 1.0/Pi 1=
OneOverTwoPi 0.5/Pi 1=2
6.2 Angle conversion factors
Name Value Description
DegToRad TwoPi/360.0 Degrees to radians
PiOn180 TwoPi/360.0 Degrees to radians
ArcminToRad DegToRad/60.0 Arcminutes to radians
ArcsecToRad DegToRad/3600.0 Arcseconds to radians
RadToDeg 360.0/TwoPi Radians to degrees
RadToArcmin RadToDeg*60.0 Radians to arcminutes
RadToArcsec RadToDeg*3600.0 Radians to arcseconds
6.3 Solid angle conversion factors
Name Value Description
SqDegToSterad DegToRad 2 Square degrees to
steradian
SqArcminToSterad SqDegToSterad/3600.0 Square arcminutes
to steradians
SqArcsecToSterad SqDegToSterad/1:296 10 7 Square arcseconds
to steradian
SteradToSqDeg RadToDeg 2 Steradian to square
degrees
SteradToSqArcmin SteradToSqDeg*3600.0 Steradian to square
arcminutes
SteradToSqArcsec SteradToSqDeg*1:296 10 7 Steradian to square
arcseconds
xmmsas 20030110 1802-5.4.1

XMM-Newton Science Analysis System Page: 5
6.4 Square roots
Name Value Description
RootTwo 1.4142135623730951 p
2
RootThree 1.7320508075688772
p
3
RootTen 3.1622776601683795
p
10
RootPi 1.7724538509055159 p

6.5 Natural log-related
Name Value Description
NapierE 2.7182818284590455 e
lnTwo 0.6931471805599453 ln 2
lnTen 2.3025850929940459 ln 10
lnPi 1.1447298858494002 ln 
6.6 Fundamental physical constants
Name Value Description
SpeedOfLight 299792458.0 c (m/sec)
PlanckH 6:62606876  10 34 h (J/sec)
NewtonG 6:673  10 11 G (m 3 /kg/s 2 )
ElectronQ 1:602176462  10 19 G (m 3 /kg/s 2 )
Boltzmann 1:3806503  10 23 G (m 3 /kg/s 2 )
StefanBoltzmann 5:670400  10 8 G (m 3 /kg/s 2 )
Avogadro 6:02214199  10 23 G (m 3 /kg/s 2 )
6.7 Energy conversion factors
Name Value Description
ErgToeV 1.0d-7 / ElectronQ erg to eV
ErgTokeV ErgToeV/1000.0 erg to keV
eVToErg 1.0/ErgToev eV to ergs
keVToErg 1000.0/ErgToev keV to ergs
References
xmmsas 20030110 1802-5.4.1