Документ взят из кэша поисковой машины. Адрес оригинального документа : http://star.arm.ac.uk/~csj/lines/lte/lte_line
Дата изменения: Tue Nov 13 15:53:43 2001
Дата индексирования: Tue Oct 2 07:39:59 2012
Кодировка:

Поисковые слова: п п п п п п п п п п п п
#
#############################################################################
# #
# C Shell script ' lte_line ' #
# #
# L T E _ L I N E S #
# #
# Function : Concatenate the atomic data for the #
# selected ions into a single file #
# #
# Revised for new data structure #
# #
#############################################################################


#____________Some initial settings :

set noglob

alias rm 'rm -f' ### Enable easy deleting and renaming.
alias mv 'mv -f'
set nonomatch

unalias cd

set Ldir = $LINES_LTE ### Name of directory with atomic data.
### This must be specified by the user.

set Ddir = $Ldir ### The default directory for atomic data

set ext = .d ### Default filename extention for atomic
### data files.

set lines = 'lines.d' ### Name for new atomic data file. ( Already
### existing file under this name will be
### renamed to .old and file .old will be
### deleted )



#------------------------------------------------------------------------------
# 1 ION SELECTION
#------------------------------------------------------------------------------

#____________information :

echo ""
echo "_________________________________________________________________"
echo ""
echo " L T E _ L I N E S : construct a linelist for SPECTRUM input"
echo ""
echo " Allowed ions are:"
echo " HeI, LiI, CI, CII, CIII, CIV, NII, NIII, OI, OII, OIII, NeI"
echo " Ne II, MgII, AlII, AlIII, Si I, SiII, SiIII, SiIV, PII, PIII"
echo " P IV, S II, S III, ClII, AII, CaII, TiII, CrII, FeI, FeII, FeIII"
echo " More information in /home/model/LINES_LIST/oinformation.t"
echo ""
echo " Ion id's are coded eg: SiII = Si2, FeIII = Fe3 "
echo ""
echo " The script you are using is not case sensitive."
echo " For eg. : 'si2','SI2','Si2' and even 'sI2' will be treated as SiII"
echo ""
echo " Groups may be selected eg: SiII,SiIII,SiIV = Si% "
echo " Multiple species may be selected eg: C%,N%,O% "
echo " or eg: C% N% O% "
echo " All ions can be selected eg: all "
echo " Filetype may be omitted (default .d) "
echo ""
echo " Data may be selected from the default (assessed) data provided. "
echo " Alternatively, personal datafiles for the line data "
echo " may be introduced. The two may not be mixed. "
echo ""
echo "__________________________________________________________________"
echo ""



#_________If list is given :

if ( $#argv != 0 ) then

echo -n 'You have selected : '
echo $argv ### Anouncing user arguments he passed.
echo -n 'from the default (assessed) data directory'
echo ""

set List = "$argv" ### Defining ion list and passing it
goto Prep ### to preparation.

endif



Prompt:
#__________Prompt for data directory :

echo 'Directory for data .. '
echo ' for default (assessed) data '
echo ' . for current directory '
echo ' for another directory '
echo -n ' ... ' ### Prompt for data directory.
set Ddir = ( `echo $< ` )

if ( ${Ddir} == "" ) then ### Verify data directory exists.
set Ddir = $Ldir
else if ( ${Ddir} == "." ) then
set Ddir = $cwd
else
if (-r $Ddir) goto Ions
echo " >>> Directory '${Ddir}' not found"
goto Prompt
endif



Ions:
#__________Prompt for list of ions :

echo -n 'Select ions .. '
set List = ( `echo $< ` ) ### Prompt for ion list.
echo ""

if ( $#List == 0 ) goto Ions ### Empty entry not valid



Prep:
#__________Preparing list :


##### Converting :
# *) '%' to '?'
# *) ',' to space
# *) everything to upper case
# *) letters, which are second in names of ion-files, to lower case

set Ls = ( `echo $List | tr "%,[a-z]" "? [A-Z]" | tr "DEGILR" "degilr"` )

if ( $#Ls == 0 ) goto Prompt ### List is empty ( only ","-s and spaces ).


##### Correcting possible errors of converting :
# *) "Ca" was converted to "CA"
# *) "Li" was converted to "li"
# *) "Sc" was converted to "SC"

set List = ()

foreach v ( $Ls[*] ) ### Checking every name in list converted.

if ( $v =~ 'li'* \
|| $v =~ 'CA'* )\
set v = `echo $v | tr "lA" "La" ` ### Correcting error.
if ( $v =~ 'SC'* ) set v = `echo $v | tr "SC" "Sc" `

set List = ( $List $v ) ### Checked names - back to ion-list.

end


##### Case of decision all :

if ( $List[1] == All ) set List = \
( He? Li? C? N? O? Ne? Mg? Al? Si? P? S? Cl? A? Ca? Ti? Cr? Fe? Ni? )





#------------------------------------------------------------------------------
# 2 LINELIST CREATION
#------------------------------------------------------------------------------


#________Preparing data and current directories


##### Preparing for the work :


unset noglob

set Ground = $cwd ### Remembering user's directory

rm .Scratch ### Creating "invisible" work file in user's directory.
echo -n '' > .Scratch




#__________GENERATING FILE


@ res = 0 ### Initiation of "result" variable.



##### Inserting ion-files named in the ion-list :

cd $Ddir ### Go to data directory

while ( $#List != 0 ) # ### Loop through the ion-list.

set v = "$List[1]"

if ( "$v:e" == '' ) set v = "$v"\.d ### If no extension set the
### default extension.

set L = ( `ls $v ` ) ### Listing all files, matching
if ( $#L != 0 ) goto OK ### the name.


##### If there's no matching file, inform user about failure.
echo "*###### not included ######* : ""$v"
echo ""
goto Cont ### Continue


OK:
###### If there are matching files, insert them :

@ res++ ### Increasing "result" variable.

cat $L >> ${Ground}/.Scratch ### Inserting the files.

echo "*---------included---------* : "$L
### Informing user, that the files are included.

Cont: ### Continue with next name.
shift List

end

cd $Ground ### return to base directory

##### If no succesful file matches - do not generate a new file

if ( $res == 0 ) then
echo "********* No lines"
goto Fail ### Terminating the program.
endif


##### Inserting end line ( file "endl.d" ) :

cat $Ldir/endl.d >> ${Ground}/.Scratch

if ( $status != 0 ) then ### The file is not found - new file
### cannot be created.

echo "********* Cannot complete creation of new data file."
goto Fail ### Terminating the program.

endif


##### If possible, inserting references ( file "refs.f" ) :

cat $Ldir/refs.d >> ${Ground}/.Scratch

if ( $status != 0 ) then ### The file is not found - informing user
### that references are not included.

echo "*--------- List of references is not included."
echo ""

endif




#__________SUCCESFUL END

rm ${lines:r}.old ### Deleting old version.

if ( -e $lines ) then ### File with lines already exists.

mv $lines ${lines:r}.old ### Renaming it as old and informing
echo '' ### user about it.
echo "Old linelist in '${lines:r}.old'"

endif


mv .Scratch $lines ### Renaming new file as file
echo '' ### with lines and informug
echo "Linelist in file '${lines}'" ### user about it.
echo ''


echo " Bye." ### End of the program.
echo ''

exit 1 ### Exiting program with non-zero exit code.


Fail:
##### Terminating the program :

echo ""
echo " Bye."
echo ""

rm .Scratch ### work file.

exit 1 ### Terminating program with non-zero exit code.





###############################################################################