-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Location: 2 : // 3 : // http://people.sc.fsu.edu/~jburkardt/freefem_src/io_test/io_test.edp 4 : // 5 : // Discussion: 6 : // 7 : // This example illustrates how FreeFem++ can read and write text files. 8 : // 9 : // Note that a file containing a vector must have an initial record 10 : // listing the number of elements in the file. Thus, the file "input.txt" 11 : // has the form: 12 : // 13 : // 11 14 : // 0 1 2 3 4 15 : // 5 6 7 8 9 16 : // 10 17 : // 18 : // Licensing: 19 : // 20 : // This code is distributed under the GNU LGPL license. 21 : // 22 : // Modified: 23 : // 24 : // 04 February 2015 25 : // 26 : // Reference: 27 : // 28 : // John Chrispell, Jason Howell, 29 : // Finite Element Approximation of Partial Differential Equations 30 : // Using FreeFem++, or, How I Learned to Stop Worrying and Love 31 : // Numerical Analysis. 32 : // 33 : // Frederic Hecht, 34 : // New development in FreeFem++, 35 : // Journal of Numerical Mathematics, 36 : // Volume 20, Number 3-4, 2012, pages 251-265. 37 : // 38 : cout << "\n"; 39 : cout << "io_test:\n"; 40 : cout << " FreeFem++ version\n"; 41 : cout << " Read values from the file 'input.txt'\n"; 42 : cout << " Write their square roots to the file 'output.tx ... : t'\n"; 43 : // 44 : // Declare IN to be an input unit. 45 : // 46 : ifstream in ( "input.txt" ); 47 : // 48 : // Declare U to be a real array indexed by integers. 49 : // 50 : real[int] u(11); 51 : // 52 : // Read data from "input.txt" into U. 53 : // 54 : in >> u; 55 : // 56 : // Declare V to be a real array indexed by integers. 57 : // 58 : real[int] v(11); 59 : // 60 : // Manipulate the data and print it to convince us it got here. 61 : // 62 : for ( int j = 0; j < 11; j++ ) 63 : { 64 : v[j] = sqrt ( u[j] ); 65 : cout << " " << u[j] 66 : << " " << v[j] << "\n"; 67 : } 68 : // 69 : // Declare OUT to be an output unit. 70 : // 71 : ofstream out ( "output.txt" ); 72 : // 73 : // Write V to the output unit. 74 : // 75 : out << v; 76 : // 77 : // Terminate. 78 : // 79 : cout << "\n"; 80 : cout << "io_test\n"; 81 : cout << " Normal end of execution.\n"; 82 : 83 : sizestack + 1024 =1696 ( 672 ) io_test: FreeFem++ version Read values from the file 'input.txt' Write their square roots to the file 'output.txt' 0 0 1 1 2 1.41421 3 1.73205 4 2 5 2.23607 6 2.44949 7 2.64575 8 2.82843 9 3 10 3.16228 io_test Normal end of execution. times: compile 0.004061s, execution 0.000208s, mpirank:0 CodeAlloc : nb ptr 3489, size :468512 mpirank: 0 Ok: Normal End