#!/usr/bin/env python3
# Copyright 2021 - Barcelona Supercomputing Center
# Author: Rodrigo Martín Posada
# MIT License
import matplotlib.pyplot as plt
import numpy as np

dirs = ['work_python_fortran_4_4', 'work_fortran_fortran_4_4']

if __name__ == '__main__':
    fig, axs = plt.subplots(2,2, figsize=(15,15))
    for i in range(2):
        for j in range(2):
            for dir_i, directory in enumerate(dirs):
                for var_id in range(2):
                    f = open(directory+'/ocean_results_'+str(var_id)+'_'+str(i+j), 'r')
                    content = np.array(f.read().split()).astype(float)
                    label = 'Fortran' if directory[5] == 'f' else 'Python'
                    axs[i,j].plot(content, label = label+'_var'+str(var_id), alpha=0.8)
                    f.close()
                    axs[i,j].legend()
                    axs[i,j].set_title('Process '+str(i+j))
    
    fig.savefig('results.png')