#!/bin/bash

# Recuperation de la liste des atlas existants

local=`pwd`

for comp in T0 T0F TT CPLtest T0A CPL5to6 CPLV5.3to5 Guides5.3et5 V5.4 ; do

COMP_D=/prodigfs/ipslfs/http/dods/web/html/fabric/lmdz/MultiSimu/$comp
cd $COMP_D/ATLAS

ref=`awk ' { print $1"_"$2 } ' ../def.txt | head -1`
echo REF F F  F  FF  FF $ref
pwd

for f in *${ref}* ; do  line=`echo $f | sed -e 's/.html//' -e 's/_/ /g'` ; proj=`echo $line | awk ' { print $2 } '` ; seas=`echo $line | awk ' { print $3 }' ` ; vars="" ; virg="" ; for var in `grep 'LEFT.*.(' $f | cut -d\( -f2 | cut -d\) -f1` ; do vars="$vars$virg$var" ; virg="," ; done ; echo $seas $proj $vars ; done > ../atlas-def

for f in *${ref}* ; do  line=`echo $f | sed -e 's/.html//' -e 's/_/ /g'` ; proj=`echo $line | awk ' { print $2 } '` ; seas=`echo $line | awk ' { print $3 }' ` ; vars="" ; virg="" ; for var in `grep 'LEFT.*.(' $f | cut -d\( -f2 | cut -d\) -f1` ; do vars="$vars$virg$var" ; virg="," ; done ; for sim in `awk ' { print $1"_"$2 } ' ../def.txt` ; do echo ${sim}+${seas}+${proj}+$vars ; done ; done > atlas_OK

cd $local

done
