#!/bin/bash

echo  $co2_conf_var
echo  "$co2_conf_var"
echo  '$co2_conf_var'

temp1=""
lines=""
line_number=1
IFS=' ' read -ra ADDR <<< $co2_conf_var
for i in "${ADDR[@]}"; do
    SUB='FileInputVars'
    if grep -q "$SUB" <<< "$i"; then
        lines[line_number]=$temp1
        line_number=$line_number+1
        echo $temp1
        temp1=""
        echo "Start of the new line"
        
    else
        temp1="$temp1 $i"
        echo "No match found" 
    fi 
    echo  $i
done

echo $lines 


cat << EOF
# YAML file input
    RunLengthSec    : - ${leg_length_sec}
    TimeStepSec     : - ${cpl_freq_amip_sec}
    StartYear       : - ${leg_start_date_yyyymmdd:0:4}
    StartMonth      : - ${leg_start_date_yyyymmdd:4:2}
    StartDay        : - ${leg_start_date_yyyymmdd:6:2}
    FixYear         : - ${ifs_cmip_fixyear}
    FileInputVars1  : - ${sst_conf_var:21:${#sst_conf_var}}
    FileInputVars2  : - ${sic_conf_var:21:${#sic_conf_var}}


    XXX3            : - ${co2_conf_var:21:${#co2_conf_var}}


    XXX4            : - ${oasis_conf_var:21:${#oasis_conf_var}}
    LDebug          : - false
EOF
