```bash
# Load bash variables into memory
source .bashvars

# Create output directory, if it doesn't exist.
mkdir --parents "${trimmed_reads_dir}"

# Change to directory with raw reads
cd "${raw_reads_dir}"

# Create arrays of FastQ R1 files and sample names
# Do NOT quote R1_fastq_pattern variable
for fastq in ${R1_fastq_pattern}
do
  fastq_array_R1+=("${fastq}")

  # Use parameter substitution to remove all text up to and including last "." from
  # right side of string.
  R1_names_array+=("${fastq%%.*}")
done



############ RUN FASTP ############
# Uses parameter substitution (e.g. ${R1_sample_name%%_*})to rm the _R[12]

# Run fastp on files
echo "Beginning fastp trimming."
echo ""

time \
for index in "${!fastq_array_R1[@]}"
do
  # Get sample name
  R1_sample_name="${R1_names_array[index]}"
  
  trimmed_fastp_name="${R1_sample_name}.fastp-R1-${max_read_length}bp-auto_adapters-polyG"


  # Begin fastp trimming
  ${programs_array[fastp]} \
  "${fastp}" \
  --in1 ${fastq_array_R1[index]} \
  --out1 ${trimmed_reads_dir}/${trimmed_fastp_name}.fq.gz \
  --trim_poly_g \
  --length_limit ${max_read_length} \
  --thread ${threads} \
  --html "${trimmed_fastp_name}.html" \
  --json "${trimmed_fastp_name}.json" \
  --report_title "${trimmed_fastp_name}"
    
  # Move to trimmed directory
  # This is done so checksums file doesn't include excess path
  cd ${trimmed_reads_dir}

  # Generate md5 checksums for newly trimmed files
  {
    md5sum "${trimmed_fastp_name}.fq.gz"
  } >> "${trimmed_checksums}"
    
  # Change back to to raw reads directory
  cd "${raw_reads_dir}"

done

echo ""
echo "fastp trimming complete."
echo ""

echo "Trimmed FastQs MD5 checksums:"
echo ""

cat "${trimmed_reads_dir}/${trimmed_checksums}"

############ END fastp ############

```