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