Академический Документы
Профессиональный Документы
Культура Документы
/bin/sh --login
# --------------------------------------------------------------------------# install_wwatch3 : install WAVEWATCH III in the present directory.
#
Working from tar files (and wwatch3_arc).
#
#
Hendrik L. Tolman
#
December 2006
#
February 2012
#
#
Copyright 2009-2012 National Weather Service (NWS),
#
National Oceanic and Atmospheric Administration. All rights
#
reserved. WAVEWATCH III is a trademark of the NWS.
#
No unauthorized use without permission.
#
# --------------------------------------------------------------------------# 1. Preparations
# --------------------------------------------------------------------------# 1.a Internal variables
aux=`\ls
ftn=`\ls
inp=`\ls
tst=`\ls
doc=`\ls
wwatch3.*.aux.tar`
wwatch3.*.ftn.tar`
wwatch3.*.inp.tar`
wwatch3.*.tst.tar`
wwatch3.*.doc.tar`
tmp='ww3_temp'
ww3_env='.wwatch3.env'
#
#
#
#
#
tar
tar
tar
tar
tar
file
file
file
file
file
with
with
with
with
with
auxiliaries
source code
input files
test programs
docblocks (NCEP only)
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
*******************************'
*** Installing WAVEWATCH III ***'
*******************************'
main_dir=`pwd`
echo ' '
fi
echo "Installing in $main_dir"
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n " OK ? [y/n] "
read OK
done
if [ "$OK" = 'n' ] || [ "$OK" = 'N' ]
then
echo ' ' ; echo 'Change to correct directory '
echo ' ' ; echo ' *** INSTALL ABORTED *** ' ; echo ' ' ; exit
fi
cd $main_dir
# 1.d Set up environment - - - - - - - - - - - - - - - - - - - - - - - - - - echo ' '
echo 'Setting up environment variables.'
if [ -f $home_dir/$ww3_env ]
then
echo " Setup file $ww3_env found in $home_dir"
set `grep WWATCH3_LPR $home_dir/$ww3_env` ; shift
prnt="$*"
echo "
Printer (listings)
: $prnt"
set `grep WWATCH3_F77 $home_dir/$ww3_env` ; shift
fort="$*"
echo "
FORTRAN comp. (aux only) : $fort"
set `grep WWATCH3_CC $home_dir/$ww3_env` ; shift
cc="$*"
echo "
C Compiler (aux only)
: $cc"
set `grep WWATCH3_TMP $home_dir/$ww3_env` ; shift
temp_dir="$*"
echo "
Scratch directory
: $temp_dir"
set `grep WWATCH3_SOURCE $home_dir/$ww3_env` ; shift
s_source="$*"
echo "
Save source code
: $s_source"
set `grep WWATCH3_LIST $home_dir/$ww3_env` ; shift
s_list="$*"
echo "
Save listings
: $s_list"
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n " Update settings ? [y/n] "
read OK
case $OK in
'y'|'Y') do_set='y' ;;
'n'|'N') do_set='n' ;;
esac
done
else
echo ' No setup file found.'
prnt=printer
fort=f77
cc=cc
temp_dir=
if [ -d /tmp ]
then
if [ -n "$user" ]
then
temp_dir=/tmp/$user
else
if [ -n "$USER" ]
then
temp_dir=/tmp/$USER
fi
fi
fi
s_source=no
s_list=no
do_set='y'
fi
if [ "$do_set" = 'y' ]
then
echo ' '
echo "Modifying set-up :"
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ]
do
echo ' '
echo -n "
Printer for listings [$prnt] : "
instr="$NULL" ; read instr
if [ -n "$instr" ]
then
prnt="$instr"
fi
echo -n "
Compiler for aux. [$fort] : "
instr="$NULL" ; read instr
if [ -n "$instr" ]
then
fort="$instr"
fi
echo -n "
Compiler for aux. [$cc] : "
instr="$NULL" ; read instr
if [ -n "$instr" ]
then
cc="$instr"
fi
OK="$NULL"
' '
" Modified set up :"
"
Printer (listings)
:
"
FORTRAN comp. (aux only) :
"
C Compiler (aux only)
:
"
Scratch directory
:
"
Save sources
:
"
Save listings
:
-n " New settings OK ? [y/n] "
OK
$prnt"
$fort"
$cc"
$temp_dir"
$s_source"
$s_list"
'#'
'# Environment variables for wavewatch III'
'# ---------------------------------------'
'#'
' '
"WWATCH3_LPR
$prnt"
"WWATCH3_F77
$fort"
"WWATCH3_CC
$cc"
"WWATCH3_DIR
$main_dir"
"WWATCH3_TMP
$temp_dir"
"WWATCH3_SOURCE $s_source"
"WWATCH3_LIST
$s_list"
' '
>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
$ww3_env
if [ ! -d $temp_dir ]
then
mkdir $temp_dir
fi
cd $temp_dir
rm -f * 2> /dev/null
cd $main_dir
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n 'Continue with actual implementation ? [y/n] '
read OK
done
if [ "$OK" = 'n' ] || [ "$OK" = 'N' ]
then
echo ' '
echo '
*******************************'
echo '
***
End of program
***'
echo '
*******************************'
echo ' '
exit
else
echo ' '
echo 'Starting actual implementation ...'
echo ' Use Ctrl-C to terminate program ...'
echo ' '
fi
# 1.f Test presence of files - - - - - - - - - - - - - - - - - - - - - - - - if [ -f "$aux" ]
then
echo "Auxiliary file $aux found ..."
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
[y/n] "
[y/n] "
[y/n] "
'y'|'Y') do_tst='y' ;;
'n'|'N') do_tst='n' ;;
esac
done
else
echo "Test cases $tst not found"
do_tst='n'
fi
if [ -f "$doc" ]
then
echo "Docblocks $doc found ..."
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n " Update NCO documentation ?
read OK
case $OK in
'y'|'Y') do_doc='y' ;;
'n'|'N') do_doc='n' ;;
esac
done
fi
[y/n] "
- - - - - - - - - - - - - - - - - - - - - - -
--------------------------------------------------------------------------- #
2. Set up auxiliaries
#
--------------------------------------------------------------------------- #
2.a Check if requested and ID output
if [ "$do_aux" = 'y' ]
then
echo ' ' ; echo ' '
echo ' ************************'
echo '*** Set up auxiliaries ***'
echo ' *****************************************************************'
echo "
Directory $main_dir/aux"
if [ "$go_on" = 'y' ]
then
echo "
Updating $code.f in $main_dir/aux"
cp $code.f $main_dir/aux/.
if [ -f "$main_dir/exe/$code" ] && [ "$do_all" = 'n' ]
then
echo "
Previous $code found in $main_dir/exe"
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n "
Update this file ? [y/n] "
read OK
case $OK in
'y'|'Y') go_on='y' ;;
'n'|'N') go_on='n' ;;
esac
done
fi
if [ "$go_on" = 'y' ]
then
echo "
Updating $code in $main_dir/bin"
echo "
Compiling ..."
if `$fort $code.f > fort.out 2> fort.err`
then
rm -f $main_dir/bin/$code
if [ -f a.out ]
then
echo "
Storing ..."
mv a.out ../bin/$code
else
echo ' ' ; echo "
*** FILE a.out NOT FOUND *** "
echo ' ' ; cat fort.out ; echo ' ' ; cat fort.err ; echo ' '
fi
else
echo ' ' ; echo "
*** ERROR IN COMPILING $code.f *** "
echo ' ' ; cat fort.out ; echo ' ' ; cat fort.err ; echo ' '
fi
fi
fi
rm -f $code.f
rm -f fort.*
done
# 2.d C objects ( presently not used ) - - - - - - - - - - - - - - - - - - - #
#
#
do
echo ' '
case $list in
1) echo 'Scripts for compiling and linking :'
echo '-----------------------------------'
goto=bin
files='ad3 ad3_test w3_make w3_new make_makefile.sh make_MPI'
files="$files switch.gen `ls comp.*` `ls link.*`" ;;
2) echo 'GrADS aux scripts'
echo '-----------------'
goto=aux
files='map2_1.gs map2_2.gs map2_3.gs map_s3.gs spec.gs source.gs'
files="$files 1source.gs colorset.gs cbarn.gs spec_ids.gen"
files="$files profile.gs" ;;
3) echo 'Other :'
echo '-------'
goto=bin
files=`ls` ;;
esac
if [ -z "$files" ]
then
echo ' No files found'
else
for file in $files
do
if [ -f "$main_dir/$goto/$file" ] && [ "$do_all" = 'n' ]
then
echo " File $file already exists."
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n "
Update this file ? [y/n] "
read OK
case $OK in
'y'|'Y') mv $file $main_dir/$goto/. ;;
'n'|'N') rm $file ;;
esac
done
else
if [ -f "$main_dir/$goto/$file" ]
then
echo " Updating $file ..."
else
echo " Storing $file ..."
fi
mv $file $main_dir/$goto/.
fi
done
fi
done
# 2.f comp and link shell scripts - - - - - - - - - - - - - - - - - - - - - echo ' '
echo 'Compile and link shell scripts :'
echo '--------------------------------'
cd $main_dir/bin
2>
2>
2>
2>
2>
2>
2>
2>
/dev/null
/dev/null
/dev/null
/dev/null
/dev/null
/dev/null
/dev/null
/dev/null
--------------------------------------------------------------------------- #
3. Set up source codes
#
--------------------------------------------------------------------------- #
3.a Check if requested and ID output
if [ "$do_ftn" = 'y' ]
then
echo ' ' ; echo ' '
echo ' *********************************'
echo '*** Set up propgram source code ***'
echo ' *****************************************************************'
echo "
Directory $main_dir/ftn"
else
echo " New file $file ..."
mv $file $main_dir/ftn/.
file_o="`echo $file | sed 's/\./ /' | awk '{print $1}'`.o"
rm -f $main_dir/obj/$file_o
nr_differ=`expr $nr_differ + 1`
fi
cp $main_dir/old.files $main_dir/old.files.temp
sed -n "/$file/!p" $main_dir/old.files.temp > $main_dir/old.files
rm -f $main_dir/old.files.temp
done
fi
if [ "$nr_the_same" != '0' ]
then
echo " $nr_the_same files unchanged."
fi
done
if [ "`wc -c $main_dir/old.files | awk '{ print $1}'`" -gt '2' ]
then
echo ' '
echo 'Files not in archive :'
echo '----------------------'
for not_in in `cat $main_dir/old.files`
do
echo " $not_in"
done
fi
rm -f $main_dir/old.files
rm -f $main_dir/old.files.temp
echo ' '
echo "$nr_differ files updated or added"
fi
#
#
#
#
--------------------------------------------------------------------------- #
4. Set up input files
#
--------------------------------------------------------------------------- #
4.a Check if requested and ID output
if [ "$do_inp" = 'y' ]
then
echo ' ' ; echo ' '
echo ' ************************'
echo '*** Set up input files ***'
echo ' *****************************************************************'
echo "
Directory $main_dir/inp"
else
if [ "$do_all" = 'y' ]
then
echo " Updating $file ..."
mv $file $main_dir/inp/.
else
echo " File $file already exists."
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n "
Update this file ? [y/n] "
read OK
done
case $OK in
'y'|'Y') ok=y ;;
'n'|'N') ok=n ;;
esac
if [ "$ok" = 'y' ]
then
echo " Updating $file ..."
mv $file $main_dir/inp/.
else
rm $file
fi
fi
fi
else
echo " New file $file ..."
mv $file $main_dir/inp/.
fi
done
if [ "$nr_the_same" != '0' ]
then
echo " $nr_the_same files unchanged."
fi
# 4.d Links to work directory - - - - - - - - - - - - - - - - - - - - - - - cd $main_dir/inp
echo
echo 'Set up links to work directory ...'
files=`ls *.inp *.ww3`
cd $main_dir/work
for file in $files
do
if [ ! -f $file ]
then
ln -s ../inp/$file .
fi
done
fi
#
#
#
#
--------------------------------------------------------------------------- #
5. Set up test cases
#
--------------------------------------------------------------------------- #
5.a Check if requested and ID output
if [ "$do_tst" = 'y' ]
then
echo ' ' ; echo ' '
echo ' ***********************'
echo '*** Set up test cases ***'
echo ' *****************************************************************'
echo "
Directory $main_dir/test"
# 5.b Unpack tar file in $tmp - - - - - - - - - - - - - - - - - - - - - - - echo ' '
echo "Unpacking $tst in $tmp ..."
cd $main_dir/$tmp
tar -xf ../$tst
# 5.c Tests by types - - - - - - - - - - - - - - - - - - - - - - - - - - - - for list in 1 2 3 4
do
echo ' '
case $list in
1) echo 'Propagation tests :' ; \
echo '-------------------' ; files=`ls ww3_tp*` ;;
2) echo 'Source term tests :' ; \
echo '-------------------' ; files=`ls ww3_ts*` ;;
3) echo 'Multi-scale tests :' ; \
echo '-------------------' ; \
files=`ls mww3_test_* mww3_case_* mww3_data_*.tar.gz` ;;
4) echo 'Other tests :' ; \
echo '-------------' ; files=`ls` ;;
esac
nr_the_same='0'
if [ -z "$files" ]
then
echo ' No files found'
else
for file in $files
do
if [ -f $main_dir/test/$file ]
then
if `cmp $file $main_dir/test/$file > /dev/null 2> /dev/null`
then
rm -f $file
nr_the_same=`expr $nr_the_same + 1`
echo " File $file unchanged."
else
if [ "$do_all" = 'y' ]
then
echo " Updating $file ..."
mv $file $main_dir/test/.
else
echo " File $file already exists."
OK="$NULL"
until [ "$OK" = 'y' ] || [ "$OK" = 'Y' ] || \
[ "$OK" = 'n' ] || [ "$OK" = 'N' ]
do
echo -n "
Update this file ? [y/n] "
read OK
done
case $OK in
'y'|'Y') ok=y ;;
'n'|'N') ok=n ;;
esac
if [ "$ok" = 'y' ]
then
echo " Updating $file ..."
mv $file $main_dir/test/.
else
rm $file
fi
fi
fi
else
echo " New file $file ..."
mv $file $main_dir/test/.
fi
done
fi
if [ "$nr_the_same" != '0' ]
then
echo " $nr_the_same files unchanged."
fi
done
fi
# 5.d Make executable - - - - - - - - - - - - - - - - - - - - - - - - - - - cd $main_dir/test
chmod 700 *
chmod 644 *.tar.gz
#
#
#
#
--------------------------------------------------------------------------- #
6. Set up docblocks
#
--------------------------------------------------------------------------- #
6.a Check if requested and ID output
if [ "$do_doc" = 'y' ]
then
echo ' ' ; echo ' '
echo ' *********************'
echo '*** Set up docblocks ***'
echo ' *****************************************************************'
echo "
Directory $main_dir/doc90"
if [ "$nr_the_same" != '0' ]
then
echo " $nr_the_same files unchanged."
fi
fi
#
#
#
#
--------------------------------------------------------------------------- #
7. Clean up and final remarks
#
--------------------------------------------------------------------------- #
7.a Remove scratch directory
*******************************'
***
End of program
***'
*******************************'