function solution_write ( node_num, node_u, solution_file_name, time ) %% SOLUTION_WRITE writes the solution to a file. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 28 August 2006 % % Author: % % John Burkardt % % Parameters: % % Input, integer NODE_NUM, the number of nodes. % % Input, real NODE_U(NODE_NUM), the coefficients of % the solution. % % Input, string SOLUTION_FILE_NAME, the name of the file % in which the data should be stored. % % Input, real TIME, the current time. % debug = 1; solution_unit = fopen ( solution_file_name, 'wt'); if ( solution_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'SOLUTION_WRITE - Warning!\n' ); fprintf ( 1, ' Could not write the solution file "%s".\n', ... solution_file_name ); return; end for node = 1 : node_num fprintf ( solution_unit, '%14f\n', node_u(node) ); end fclose ( solution_unit ); if ( debug ) fprintf ( 1, ' Wrote the solution file "%s" for time T = %f.\n', ... solution_file_name, time ); return; end return end