#!/bin/bash

#set -x # to debug

############################################################################
# Sylvain Watelet - 11/09/2013 						   #
# Handling of ODV files containing only one depth but several measurements #
# or a depth axis AND speed components					   #
# (for the moment, only for CurrDir, CurrSpd and another scalar field)     #
############################################################################

echo "one depth (or speed+depth) ?"
sleep 0.1

#################
### Functions ###
#################

## max function ##
x=5
y=4
function max          # Returns larger of two numbers.
{
if [ $1 -eq $2 ]
then
echo $1
else
  if [ $1 -gt $2 ]
  then
  echo $1
  else
  echo $2
  fi
fi
}

####################
### MAIN PROGRAM ###
####################

inputfile=$1 # /home/sylvain/DIVA/usersw31234-data_centre43-2013-09-03_result/7011_20130903_125015.txt
path_metadata=$(echo $inputfile | awk -F "/" '{print $NF}')
metadata_num=$(echo $path_metadata | awk -F "_" '{print $NF}')
metadata_num=${metadata_num:0:4}
path_metadata=$(echo $inputfile | sed s/$path_metadata//g)

#if [ "$#" != "1" ]
#then
#Echo =======================================
#Echo Usage:  divaguessform datafile
#Echo =======================================
#exit
#fi

{
read delimiter
} < ODVdelimiter

if [ "$delimiter" == "t" ]
then
delimiter="\t"
fi

### Detection of files with speed components and also a depth axis ####

a=$(grep -i "pressure" ODVcolumns | wc -l)
b=$(grep -i "press" ODVcolumns | wc -l)
c=$(grep -vi -e "bot.depth" -e "bot.\ depth" ODVcolumns | grep -i "depth" | wc -l)
x=$(grep -i "currdir" ODVcolumns | wc -l)
y=$(grep -i "currspd" ODVcolumns | wc -l)

let flag_depth=$a+$b+$c
let flag_speed=$x+$y

### Determination of the vertical axis ###
flag_depth_speed=0
if [ $flag_depth -gt 0 ] && [ $flag_speed -eq 2 ]
then
echo "this file has a depth axis AND speed components"
flag_depth_speed=1
sleep 1
else

	zfound1=$(grep -i "pressure" ODVcolumns | wc -l)
	zfound2=$(grep -i "press" ODVcolumns | wc -l)
	let zfound=$zfound1+$zfound2
	if [ "$zfound" -le "0" ]
	then
	:
	else 
	exit # => coordinate = pressure
	fi

	zfound1=$(grep -vi -e "bot.depth" -e "bot.\ depth" ODVcolumns | grep -i "depth" | wc -l)
	zfound2=$(grep -i -e "bot.depth" -e "bot.\ depth" ODVcolumns | wc -l)
	if [ "$zfound1" -ge "$zfound2" ]
	then
	exit # => depth axis (m) is present
	else
	botdepthcol=$(grep -i -e "bot.depth" -e "bot.\ depth" ODVcolumns | head -1 | awk -F "$delimiter" '{print $3}') #echo $botdepthcol
	fi

fi

	if [ -f "$inputfile" ]
	then
	#echo Trying to make data (temporal) averaging on data file $inputfile
	#echo Number of lines in the data file : wc -l $inputfile
	datalines=$(wc -l $inputfile | awk '{print $1}')
	headerlines=$(head -1000 $inputfile | grep "//"  | wc -l)
	let userlines=$datalines-headerlines
	let userlines=$userlines-1
	let beginline=$headerlines+3
	echo data $datalines, header $headerlines, user $userlines, begin $beginline
	fi

### Metadata file (only needed for 1 depth files)

if [ $flag_depth_speed == 0 ]
then
	metadata_file=$(ls $path_metadata*$metadata_num*metadata*)
	ret=$?
	if [ $ret != 0 ]; then
	  echo "Warning: no metadata file found"
	  exit $ret
	fi
fi

### Value of the exclusion value given by the user ###

valexodvuser=$(awk 'NR==22 {print $1}' input/param.par)
echo valexodvuser = $valexodvuser

### Trying to see if exclusion value is present in the input file ###

valexodv=$(grep -a MissingValueIndicators $inputfile | awk -F ">" '{print $2}' | awk -F "<" '{print $1}')
echo  valexodv =  $valexodv
if [ -z $valexodv ] 
then 
echo valexodv empty or "unset"
valexodv=$valexodvuser
echo "=> valexodv ="  $valexodv
fi
#//<MissingValueIndicators>NaN</MissingValueIndicators>

datacol1=0
datacol2=0
counter=0
nvarscal=0

for var in `cat varlist`
do
if [[ $var == "CurrDir" || $var == "CurrSpd" ]]
then
echo Working on parameter $var : a vector field
	if [ $var == "CurrDir" ]
	then
	datacol1=$(grep "$var" ODVcolumns | head -1 |  awk -F "$delimiter" '{print $3}')
	echo "=> col" $datacol1
	else
	datacol2=$(grep "$var" ODVcolumns | head -1 |  awk -F "$delimiter" '{print $3}')
	echo "=> col" $datacol2
	units_vector=$(grep "$var" ODVcolumns | head -1 |  awk '{print $2}')
	fi
counter=$(($counter + 1))

elif [[ $var == "u_star" || $var == "v_star" ]]
then
:

else

######################
### SCALAR average ###
######################

echo Working on parameter $var : a scalar field
#head ODVcolumns
datacol=$(grep "$var" ODVcolumns | head -1 |  awk -F "$delimiter" '{print $3}')
units_scalar=$(grep "$var" ODVcolumns | head -1 |  awk '{print $2}')
echo "=> col" $datacol

if [ -z $datacol ]
then
continue # skip the rest of the loop (absence of $var in $inputfile)
fi

ave=0
nexcluded=0
nempty=0
tmp=0
	for i in `seq $beginline $datalines` ### SCALAR average
	do
if [ $flag_depth_speed == 0 ]
then
	tmp=$(awk -F "$delimiter" -v i=$i -v datacol=$datacol 'NR==i {print $datacol}' $inputfile) # -v : assign a value to a variable, can't be done in the ' ' part !!!
fi
	## Empty field ##
		if [ -z $tmp ]
		then 
		tmp=0
		nempty=$(($nempty+1))
		echo nempty $var = $nempty
		fi
	## Exclusion value ##
		if [ $tmp == $valexodvuser ] || [ $tmp == $valexodv ]
		then
		tmp=0
		nexcluded=$(($nexcluded+1))
		echo nexcluded $var = $nexcluded
		fi
if [ $flag_depth_speed == 0 ]
then
	ave=$(echo "$tmp + $ave" | bc -l) # bash can't work with decimal numbers => addition via bc -l (-l => scale=20)
fi

	if [ $(($i%50)) == 0 ] 
	then
	echo "please wait ..." $i"/"$datalines
	fi
	
	done

ave=$(echo "$ave/($datalines-$beginline+1-$nexcluded-$nempty)" | bc -l)
#declare -A ave_tab  ## declaration of an associative array (not mandatory if bash 4.0)
ave_tab[$var]=$ave  ### début de généralisation à plusieurs variables scalaires, à poursuivre...
echo ave $var = ${ave_tab[$var]}
var_scal=$var
ave_var_scal=${ave_tab[$var]}
nvarscal=$(($nvarscal+1))
	if [ $nvarscal -gt 1 ]
	then
	echo "!!!! ERROR : more than 1 scalar variable in your input file, please modify divaonedepthODV4 !!!"
	exit
	fi

fi
done


######################
### VECTOR average ###
######################

if [ $counter == 2 ]
then

pi=3.1415926535897932384626433832795

ave_u_star=0
ave_v_star=0
nexcluded=0
nempty=0
tmp=0
for i in `seq $beginline $datalines`
do
if [ $flag_depth_speed == 0 ]
then
tmp=$(awk -F "$delimiter" -v i=$i -v pi=$pi -v datacol1=$datacol1 -v datacol2=$datacol2 'NR==i {print $datacol2*cos($datacol1*(pi/180))}' $inputfile)
verif1=$(awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 'NR==i {print $datacol1}' $inputfile)
verif2=$(awk -F "$delimiter" -v i=$i -v datacol2=$datacol2 'NR==i {print $datacol2}' $inputfile)

### Empty field ###
test_empty=0
	if [ -z $verif1 ] || [ -z $verif2 ] # + handling of non-existence of verif to avoid the next if
	then 
	maxvalue=$(max $valexodv $valexodvuser)
	verif1=$(($maxvalue+1))
	verif2=$(($maxvalue+1))
	tmp=0
	nempty=$(($nempty+1))
	echo nempty vector = $nempty
	test_empty=1
	fi
## Exclusion value ##
	if [ $verif1 == $valexodvuser ] || [ $verif2 == $valexodvuser ] || [ $verif1 == $valexodv ] || [ $verif2 == $valexodv ]
	then
	tmp=0
	nexcluded=$(($nexcluded+1))
	echo nexcluded vector = $nexcluded
	fi

tmp=$(echo $tmp | sed -e 's/[eE]+*/*10^/') # replace e by *10^ (in order to use bc)
ave_u_star=$(echo "$tmp + $ave_u_star" | bc -l) 

tmp=$(awk -F "$delimiter" -v i=$i -v pi=$pi -v datacol1=$datacol1 -v datacol2=$datacol2 'NR==i {print $datacol2*sin($datacol1*(pi/180))}' $inputfile) 

### Empty field ###
	if [ $test_empty == 1 ]
	then 
	tmp=0
	fi
# Exclusion value
	if [ $verif1 == $valexodvuser ] || [ $verif2 == $valexodvuser ] || [ $verif1 == $valexodv ] || [ $verif2 == $valexodv ]
	then
	tmp=0
	fi
tmp=$(echo $tmp | sed -e 's/[eE]+*/*10^/') # * is the repetition character (here we are searching e or E followed by zero or more "+")
ave_v_star=$(echo "$tmp + $ave_v_star" | bc -l)
fi

if [ $(($i%50)) == 0 ] 
then
echo "please wait ..." $i"/"$datalines
fi

done

ave_u_star=$(echo "$ave_u_star/($datalines-$beginline+1-$nexcluded-$nempty)" | bc -l)
ave_v_star=$(echo "$ave_v_star/($datalines-$beginline+1-$nexcluded-$nempty)" | bc -l)
echo ave_u_star $ave_u_star, ave_v_star $ave_v_star

else
:
fi

if [ $flag_depth_speed == 0 ]
then
## Reading of Bot.Depth, Station, Metadata Depths !!
echo $beginline,$botdepthcol
botdepth=$(awk -F "$delimiter" -v beginline=$beginline -v botdepthcol=$botdepthcol 'NR==beginline {print $botdepthcol}' $inputfile)
station=$(awk -F "$delimiter" -v beginline=$beginline 'NR==beginline {print $2}' $inputfile)
echo botdepth = $botdepth, station = $station

mindepth_col=$(awk -F "," -v var='"Minimum instrument depth (m)"' '{for(n=1;n<=NF;n++) if($n == var) print n}' $metadata_file)
maxdepth_col=$(awk -F "," -v var='"Maximum instrument depth (m)"' '{for(n=1;n<=NF;n++) if($n == var) print n}' $metadata_file)
echo $mindepth_col, $maxdepth_col
if [ -z $mindepth_col ] || [ -z $maxdepth_col ]
then 
echo "no depth in metadata" 
exit
fi
mdepth_line=$(grep -n "$station" $metadata_file)
mdepth_line=${mdepth_line:0:1}
echo $mdepth_line
mindepth=$(awk -F "," -v mdepth_line=$mdepth_line -v mindepth_col=$mindepth_col 'NR==mdepth_line {print $mindepth_col}' $metadata_file)
mindepth=$(echo $mindepth | sed s/'"'//g)
maxdepth=$(awk -F "," -v mdepth_line=$mdepth_line -v maxdepth_col=$maxdepth_col 'NR==mdepth_line {print $maxdepth_col}' $metadata_file)
maxdepth=$(echo $maxdepth | sed s/'"'//g)
echo mindepth = $mindepth, maxdeph = $maxdepth
instr_depth=$(echo "($mindepth+$maxdepth)/2." | bc ; scale=4)
echo $instr_depth
botdepth=$instr_depth
echo measurement depth = $botdepth

## Reading of contour.depth and extraction of 2 surrounding depth values

contourfile="input/contour.depth"
depth1=-99999
depth2=-99999

if [[ -f "$contourfile" ]]
then
count=0
	while read line  
	do   
	count=$(($count+1))
		if [[ "$botdepth" -ge "$line" && $count == 1 ]]
		then
		depth1=$(($botdepth+10))
		depth2=$(($botdepth-10))
		botdepth=-999 # to exit the if block
		elif [[ "$botdepth" -ge "$line" && "$botdepth" -lt "$line_old" ]]
		then
		depth1=$line_old
		depth2=$line
		else
		:
		fi
	line_old=$line
	done < $contourfile
echo depth1 = $depth1, depth2 = $depth2
else
echo "error : please provide a contour.depth file"
fi

fi

######################################
#### Writing a new ODV data file #####
######################################

outputfile=$(echo $inputfile | sed s/.txt/_bis.txt/g)
rm $outputfile

#######
for i in `seq 1 $(($beginline-2))` 
do
awk -F "$delimiter" -v i=$i 'BEGIN {OFS=FS} NR==i {print $0}' $inputfile >> $outputfile # OFS = Output Field Separotor !! (tab here)
done

#########
i=$(($i+1))
if [ $flag_depth_speed == 0 ]
then

if [ -z $datacol ]
then
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v var_scal=$var_scal -v units_scalar=$units_scalar -v units_vector=$units_vector 'BEGIN {OFS=FS} NR==i {$datacol1="u_star"" "units_vector;$datacol2="v_star"" "units_vector;print($0,"Depth [m]")}' $inputfile >> $outputfile
else
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v datacol=$datacol -v var_scal=$var_scal -v units_scalar=$units_scalar -v units_vector=$units_vector 'BEGIN {OFS=FS} NR==i {$datacol1="u_star"" "units_vector;$datacol2="v_star"" "units_vector;$datacol=var_scal" "units_scalar ;print($0,"Depth [m]")}' $inputfile >> $outputfile
fi

else

if [ -z $datacol ]
then
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v var_scal=$var_scal -v units_scalar=$units_scalar -v units_vector=$units_vector 'BEGIN {OFS=FS} NR==i {$datacol1="u_star"" "units_vector;$datacol2="v_star"" "units_vector;print $0}' $inputfile >> $outputfile
else
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v datacol=$datacol -v var_scal=$var_scal -v units_scalar=$units_scalar -v units_vector=$units_vector 'BEGIN {OFS=FS} NR==i {$datacol1="u_star"" "units_vector;$datacol2="v_star"" "units_vector;$datacol=var_scal" "units_scalar ;print $0}' $inputfile >> $outputfile
fi

fi


###########

if [ $flag_depth_speed == 0 ]
then

i=$(($i+1))
if [ -z $datacol ]
then
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v ave_u_star=$ave_u_star -v ave_v_star=$ave_v_star -v depth1=$depth1 'BEGIN {OFS=FS} NR==i {$datacol1=ave_u_star;$datacol2=ave_v_star;print($0,depth1)}' $inputfile >> $outputfile
else
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v datacol=$datacol -v ave_u_star=$ave_u_star -v ave_v_star=$ave_v_star -v ave_var_scal=$ave_var_scal -v depth1=$depth1 'BEGIN {OFS=FS} NR==i {$datacol1=ave_u_star;$datacol2=ave_v_star;$datacol=ave_var_scal;print($0,depth1)}' $inputfile >> $outputfile
fi

i=$(($i+1))
if [ -z $datacol ]
then
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v ave_u_star=$ave_u_star -v ave_v_star=$ave_v_star -v depth2=$depth2 'BEGIN {OFS=FS} NR==i {$datacol1=ave_u_star;$datacol2=ave_v_star;print($0,depth2)}' $inputfile >> $outputfile
else
awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v datacol=$datacol -v ave_u_star=$ave_u_star -v ave_v_star=$ave_v_star -v ave_var_scal=$ave_var_scal -v depth2=$depth2 'BEGIN {OFS=FS} NR==i {$datacol1=ave_u_star;$datacol2=ave_v_star;$datacol=ave_var_scal;print($0,depth2)}' $inputfile >> $outputfile
fi

else

	for i in `seq $beginline $datalines`
	do
	u_star=$(awk -F "$delimiter" -v i=$i -v pi=$pi -v datacol1=$datacol1 -v datacol2=$datacol2 'NR==i {print $datacol2*cos($datacol1*(pi/180))}' $inputfile)
	v_star=$(awk -F "$delimiter" -v i=$i -v pi=$pi -v datacol1=$datacol1 -v datacol2=$datacol2 'NR==i {print $datacol2*sin($datacol1*(pi/180))}' $inputfile)
	verif1=$(awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 'NR==i {print $datacol1}' $inputfile)
	verif2=$(awk -F "$delimiter" -v i=$i -v datacol2=$datacol2 'NR==i {print $datacol2}' $inputfile)

	if [ -z $verif1 ] || [ -z $verif2 ]
	then
	u_star=$valexodvuser
	v_star=$valexodvuser
	fi
	
	if [ $verif1 == $valexodvuser ] || [ $verif2 == $valexodvuser ] || [ $verif1 == $valexodv ] || [ $verif2 == $valexodv ]
	then
	u_star=$verif1
	v_star=$verif2
	fi	
	
	awk -F "$delimiter" -v i=$i -v datacol1=$datacol1 -v datacol2=$datacol2 -v u_star=$u_star -v v_star=$v_star 'BEGIN {OFS=FS} NR==i {$datacol1=u_star;$datacol2=v_star;print $0}' $inputfile >> $outputfile
	
	if [ $(($i%50)) == 0 ] 
	then
	echo "please wait ..." $i"/"$datalines "(writing a new file (case depth+speed))"
	fi
	
	done

fi

### Modification of datasource file

sed -i s:"$inputfile":"$outputfile":g datasource  # '/' replaced by ':' because paths with / in the variables

### Modification of varlist file

index=0
for var in `cat varlist`
do
if [[ $var == "u_star" || $var == "v_star" ]]
then
index=$(($index+1))
var_star=$var
fi
done

if [ $index == 0 ]
then 
echo "u_star" >> varlist
echo "v_star" >> varlist
elif [ $index == 1 ]
then
	if [ $var_star == "u_star" ]
	then
	echo "v_star" >> varlist
	else
	echo "u_star" >> varlist
	fi
elif [ $index == 2 ]
then 
:
else
echo "ERROR related to varlist file !!!!!"
fi

###################################################################################
### TIME handling #################################################################
### Warning if the time series ends later than the period specified by the user ###
###################################################################################

start_time_col=$(grep -i "yyyy" ODVcolumns | awk -F "$delimiter" '{print $3}')
julian_time_col=$(grep -i "julian" ODVcolumns | awk -F "$delimiter" '{print $3}')

start_jul_time=$(awk -F "$delimiter" -v beginline=$beginline -v julian_time_col=$julian_time_col 'NR==beginline {print $julian_time_col}' $inputfile)
end_jul_time=$(awk -F "$delimiter" -v datalines=$datalines -v julian_time_col=$julian_time_col 'NR==datalines {print $julian_time_col}' $inputfile)

delta_time=$(echo "$end_jul_time-$start_jul_time" | bc -l)

start_time=$(awk -F "$delimiter" -v beginline=$beginline -v start_time_col=$start_time_col 'NR==beginline {print $start_time_col}' $inputfile)
#echo $start_time
year=${start_time:0:4}
month=${start_time:5:2}
day=${start_time:8:2}
hour=${start_time:11:2}
min=${start_time:14:2}
sec=${start_time:17:6}

day_start=$day
month_start=$month
year_start=$year

sup_day=$(echo "($sec+$min*60.+$hour*3600.)/86400" | bc -l)
day=$(echo "$day+$sup_day" | bc -l)

month=10#$month ## BASE#NUMBER => remove 0 before month
month=$(($month+0)) ## to be sure month is a number (not a character)

while true
do
#echo $year,$month,$day
	if [ $(echo "$day > 32" | bc -l) -eq 1 ] && ([ $month == 1 ] || [ $month == 3 ] || [ $month == 5 ] || [ $month == 7 ] || [ $month == 8 ] 		|| [ $month == 10 ] || [ $month == 12 ])
	then
	month=$(($month+1))
	day=$(echo "$day-31" | bc -l)
		if [ $month == 13 ]
		then
		month=$(($month-12))
		year=$(($year+1))
		fi
	elif [ $(echo "$day > 31" | bc -l) -eq 1 ] && ([ $month == 4 ] || [ $month == 6 ] || [ $month == 9 ] || [ $month == 11 ])
	then
	month=$(($month+1))
	day=$(echo "$day-30" | bc -l)
	elif [ $(echo "$day > 30" | bc -l) -eq 1 ] && [ $month == 2 ]
	then
	month=$(($month+1))
	day=$(echo "$day-29" | bc -l)
	elif [ $(echo "$day > 29" | bc -l) -eq 1 ] && [ $month == 2 ] && [ $(($year%4)) == 0 ]
	then
	month=$(($month+1))
	day=$(echo "$day-28" | bc -l)
	else
	month_end=$month
	year_end=$year
	day_end=$day
	break
	fi
done

echo "date start =" $year_start,$month_start,$day_start
echo "date end   =" $year_end,$month_end,$day_end

## user period ##

l=0  
while read line
	do
	l=$(($l+1))
	year_period_begin[l]=${line:0:4}
	year_period_end[l]=${line:4:8}
		if [ $year_start -ge ${year_period_begin[l]} ] && [ $year_start -le ${year_period_end[l]} ] && [ $year_end -gt ${year_period_end[l]} ]
		then
		echo "!!! WARNING !!!! => a file has a time period straddling 2 user-defined periods"
		else
		echo "no problem with the years"
		fi
	done < yearlist

m=0  
while read line
	do
	m=$(($m+1))
	month_period_begin[m]=${line:0:2}
	month_period_end[m]=${line:2:2}
		if [ ${month_period_begin[l]} -le ${month_period_end[l]} ] ## usual case
		then
		:
		else ## rare case
			if [ $month_start -le ${month_period_end[l]} ] 
			then
			month_start=$(($month_start+12))
			month_end=$(($month_end+12))
			fi
			month_period_end=$month_period_end+12
		fi
		if [ $month_start -ge ${month_period_begin[l]} ] && [ $month_start -le ${month_period_end[l]} ] && [ $month_end -gt ${month_period_end[l]} ]
		then
		echo "!!! WARNING !!!! => a file has a time period straddling 2 user-defined periods"	
		else
		echo "no problem with the months"
		fi
	done < monthlist

echo "one depth !"
sleep 0.5


# à faire : 

# - moyenne temporelle data (OK) + donner 2 depth grace à contour.depth (OK)
# écriture dans nouveau fichier (OK)
# tester les unités des vitesses (bien des cm/s et des K ?) (OK)
# attention si currdir et currspd sont inversés ! (OK)
# ajouter colonne "Depth [m]" ! (OK)
# changer le datasource (OK)
# ajouter u_star et v_star à la varlist (OK)
# - valeur d'exclusion (from fichier de données (lecture (ok), gestion dans les ave (ok) + from param.par (ok))) (OK)
# problème en cas de colonne incomplete... => awk bugge (cfr val d'exclusion ?) => tests avec -z (OK)
# - if temporel (sortie de monthlist) (OK)
# gestion de monthlist si le mois de départ est plus grand que le mois de fin. ex : "1202" (pour le moment, certains dépassements de période non détectés (très rare)) (OK)
# appel de ce script dans divadoall (attention : ODVcolumns doit déjà etre créé, mais divaguessform devra etre relancé après passage dans ce script) (OK)
# flag pour éviter l'utilisation de ce script (OK)
# gestion plusieurs depth mais qd meme variables currspd et currdir (OK)


# perspectives :

# champ indivergentiel u,v (après l'analyse des u*,v* !)
# généralisation à plusieurs variables scalaires et d'autres variables vectorielles














