Skip to content

Commit e7a0181

Browse files
committed
added the script used to generate the "truth" values
1 parent a279cc3 commit e7a0181

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

scripts/validate.sh

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/bin/bash
2+
3+
#
4+
# Download the old minpack and test files from Netlib
5+
# and compile and run all the tests.
6+
#
7+
# This was used to generate the comparisons for the unit tests.
8+
#
9+
10+
COMPILER=gfortran
11+
12+
rm -rf lib
13+
rm -rf test
14+
15+
mkdir lib
16+
mkdir test
17+
18+
# minpack library files:
19+
wget https://netlib.org/minpack/chkder.f
20+
wget https://netlib.org/minpack/dogleg.f
21+
wget https://netlib.org/minpack/dpmpar.f
22+
wget https://netlib.org/minpack/enorm.f
23+
wget https://netlib.org/minpack/fdjac1.f
24+
wget https://netlib.org/minpack/fdjac2.f
25+
wget https://netlib.org/minpack/hybrd.f
26+
wget https://netlib.org/minpack/hybrd1.f
27+
wget https://netlib.org/minpack/hybrj.f
28+
wget https://netlib.org/minpack/hybrj1.f
29+
wget https://netlib.org/minpack/lmder.f
30+
wget https://netlib.org/minpack/lmder1.f
31+
wget https://netlib.org/minpack/lmdif.f
32+
wget https://netlib.org/minpack/lmdif1.f
33+
wget https://netlib.org/minpack/lmpar.f
34+
wget https://netlib.org/minpack/lmstr.f
35+
wget https://netlib.org/minpack/lmstr1.f
36+
wget https://netlib.org/minpack/qform.f
37+
wget https://netlib.org/minpack/qrfac.f
38+
wget https://netlib.org/minpack/qrsolv.f
39+
wget https://netlib.org/minpack/r1mpyq.f
40+
wget https://netlib.org/minpack/r1updt.f
41+
wget https://netlib.org/minpack/rwupdt.f
42+
43+
mv *.f lib
44+
45+
# test programs:
46+
wget https://netlib.org/minpack/ex/file15
47+
wget https://netlib.org/minpack/ex/file16
48+
wget https://netlib.org/minpack/ex/file17
49+
wget https://netlib.org/minpack/ex/file18
50+
wget https://netlib.org/minpack/ex/file19
51+
wget https://netlib.org/minpack/ex/file20
52+
53+
mv file15 ./test/file15.f
54+
mv file16 ./test/file16.f
55+
mv file17 ./test/file17.f
56+
mv file18 ./test/file18.f
57+
mv file19 ./test/file19.f
58+
mv file20 ./test/file20.f
59+
60+
# modify the tests to read the data from the files
61+
# note: this is mac sed:
62+
sed -i -e 's| READ (NREAD,50) NPROB,N,NTRIES| if (ic==0) open(unit=NREAD,file="file21",status="OLD");READ (NREAD,50) NPROB,N,NTRIES|g' ./test/file15.f
63+
sed -i -e 's| READ (NREAD,50) NPROB,N,NTRIES| if (ic==0) open(unit=NREAD,file="file21",status="OLD");READ (NREAD,50) NPROB,N,NTRIES|g' ./test/file16.f
64+
sed -i -e 's| READ (NREAD,50) NPROB,N,M,NTRIES| if (ic==0) open(unit=NREAD,file="file22",status="OLD");READ (NREAD,50) NPROB,N,M,NTRIES|g' ./test/file17.f
65+
sed -i -e 's| READ (NREAD,50) NPROB,N,M,NTRIES| if (ic==0) open(unit=NREAD,file="file22",status="OLD");READ (NREAD,50) NPROB,N,M,NTRIES|g' ./test/file18.f
66+
sed -i -e 's| READ (NREAD,50) NPROB,N,M,NTRIES| if (ic==0) open(unit=NREAD,file="file22",status="OLD");READ (NREAD,50) NPROB,N,M,NTRIES|g' ./test/file19.f
67+
sed -i -e 's| LDFJAC = 10| LDFJAC = 10; open(unit=NREAD,file="file23",status="OLD")|g' ./test/file20.f
68+
69+
sed -i -e 's| DATA NREAD,NWRITE /5,6/| DATA NREAD,NWRITE /500,6/|g' ./test/file15.f
70+
sed -i -e 's| DATA NREAD,NWRITE /5,6/| DATA NREAD,NWRITE /500,6/|g' ./test/file16.f
71+
sed -i -e 's| DATA NREAD,NWRITE /5,6/| DATA NREAD,NWRITE /500,6/|g' ./test/file17.f
72+
sed -i -e 's| DATA NREAD,NWRITE /5,6/| DATA NREAD,NWRITE /500,6/|g' ./test/file18.f
73+
sed -i -e 's| DATA NREAD,NWRITE /5,6/| DATA NREAD,NWRITE /500,6/|g' ./test/file19.f
74+
sed -i -e 's| DATA NREAD,NWRITE /5,6/| DATA NREAD,NWRITE /500,6/|g' ./test/file20.f
75+
76+
# input files:
77+
wget https://netlib.org/minpack/ex/file21
78+
wget https://netlib.org/minpack/ex/file22
79+
wget https://netlib.org/minpack/ex/file23
80+
81+
# compile tests:
82+
$COMPILER -O0 -ffixed-line-length-none ./lib/*.f ./test/file15.f -o test_hybrd_O0_$COMPILER
83+
$COMPILER -O0 -ffixed-line-length-none ./lib/*.f ./test/file16.f -o test_hybrj_O0_$COMPILER
84+
$COMPILER -O0 -ffixed-line-length-none ./lib/*.f ./test/file17.f -o test_lmder_O0_$COMPILER
85+
$COMPILER -O0 -ffixed-line-length-none ./lib/*.f ./test/file18.f -o test_lmstr_O0_$COMPILER
86+
$COMPILER -O0 -ffixed-line-length-none ./lib/*.f ./test/file19.f -o test_lmdif_O0_$COMPILER
87+
$COMPILER -O0 -ffixed-line-length-none ./lib/*.f ./test/file20.f -o test_chkder_O0_$COMPILER
88+
89+
# run tests:
90+
./test_hybrd_O0_$COMPILER > output_test_hybrd_O0_$COMPILER.txt
91+
./test_hybrj_O0_$COMPILER > output_test_hybrj_O0_$COMPILER.txt
92+
./test_lmder_O0_$COMPILER > output_test_lmder_O0_$COMPILER.txt
93+
./test_lmstr_O0_$COMPILER > output_test_lmstr_O0_$COMPILER.txt
94+
./test_lmdif_O0_$COMPILER > output_test_lmdif_O0_$COMPILER.txt
95+
./test_chkder_O0_$COMPILER > output_test_chkder_O0_$COMPILER.txt
96+
97+
# compile tests:
98+
$COMPILER -O2 -ffixed-line-length-none ./lib/*.f ./test/file15.f -o test_hybrd_O2_$COMPILER
99+
$COMPILER -O2 -ffixed-line-length-none ./lib/*.f ./test/file16.f -o test_hybrj_O2_$COMPILER
100+
$COMPILER -O2 -ffixed-line-length-none ./lib/*.f ./test/file17.f -o test_lmder_O2_$COMPILER
101+
$COMPILER -O2 -ffixed-line-length-none ./lib/*.f ./test/file18.f -o test_lmstr_O2_$COMPILER
102+
$COMPILER -O2 -ffixed-line-length-none ./lib/*.f ./test/file19.f -o test_lmdif_O2_$COMPILER
103+
$COMPILER -O2 -ffixed-line-length-none ./lib/*.f ./test/file20.f -o test_chkder_O2_$COMPILER
104+
105+
# run tests:
106+
./test_hybrd_O2_$COMPILER > output_test_hybrd_O2_$COMPILER.txt
107+
./test_hybrj_O2_$COMPILER > output_test_hybrj_O2_$COMPILER.txt
108+
./test_lmder_O2_$COMPILER > output_test_lmder_O2_$COMPILER.txt
109+
./test_lmstr_O2_$COMPILER > output_test_lmstr_O2_$COMPILER.txt
110+
./test_lmdif_O2_$COMPILER > output_test_lmdif_O2_$COMPILER.txt
111+
./test_chkder_O2_$COMPILER > output_test_chkder_O2_$COMPILER.txt

0 commit comments

Comments
 (0)