Skip to content

Commit bf6fef5

Browse files
committed
Version with external lib (final)
1 parent e9abffd commit bf6fef5

File tree

9 files changed

+100
-72
lines changed

9 files changed

+100
-72
lines changed

Ext_Lib/Save_AD_dnSVM-3.0.zip

86.1 KB
Binary file not shown.
-85.1 KB
Binary file not shown.
Binary file not shown.

Ext_Lib/get_QDUtilLib.sh

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
#!/bin/bash
22

3+
EXTLIB_TYPE=$1
4+
35
echo "In get_QDUtilLib.sh"
46
pwd
57

6-
FC=$1
7-
OPT=$2
8-
OMP=$3
9-
LAPACK=$4
10-
ExtLibDIR=$5
11-
12-
ext_obj="_"$FC"_opt"$OPT"_omp"$OMP
13-
14-
SAVE_version=Save_QDUtilLib-0.4
8+
SAVE_version=Save_QDUtilLib-0.5
159
LOC_version=QDUtilLib
1610

17-
test -f $ExtLibDIR/$LOC_version/"libQD"$ext_obj.a && exit 0
18-
1911
rm -rf QDUtilLib* #always remove the link
2012

2113

2214
#latest release
23-
version=https://github.com/lauvergn/QDUtilLib/archive/refs/tags/v0.4.zip
15+
version=https://github.com/lauvergn/QDUtilLib/archive/refs/tags/v0.5.zip
2416
#latest HEAD version
2517
#version=https://github.com/lauvergn/QDUtilLib/archive/refs/heads/main.zip
2618

27-
#curl -LJ $version --output $LOC_version.zip
19+
test -z $EXTLIB_TYPE && curl -LJ $version --output $LOC_version.zip
20+
test $EXTLIB_TYPE != 'loc' && curl -LJ $version --output $LOC_version.zip
21+
2822
test -e $LOC_version.zip && echo $LOC_version.zip file exist || cp $SAVE_version.zip $LOC_version.zip
2923

3024
unzip $LOC_version.zip
@@ -36,7 +30,5 @@ LIBDIR=`ls -d QDUtilLib*`
3630

3731
ln -s $LIBDIR $LOC_version
3832

39-
cd $LIBDIR
40-
make lib FC=$FC OPT=$OPT OMP=$OMP LAPACK=$LAPACK ExtLibDIR=$ExtLibDIR
4133

42-
echo "End get_QDUtilLib.sh"
34+
echo "End get_QDUtilLib.sh"

Ext_Lib/get_dnSVM.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
#!/bin/bash
22

3+
EXTLIB_TYPE=$1
4+
35
echo "In get_dnSVM.sh"
46
pwd
57

68

7-
FC=$1
8-
OPT=$2
9-
OMP=$3
10-
LAPACK=$4
11-
ExtLibDIR=$5
12-
13-
ext_obj="_"$FC"_opt"$OPT"_omp"$OMP
14-
15-
SAVE_version=Save_AD_dnSVM-AD_dnSVM_dev
9+
SAVE_version=Save_AD_dnSVM-3.0
1610
LOC_version=AD_dnSVM
1711

18-
test -f $ExtLibDIR/$LOC_version/"libAD_dnSVM"$ext_obj.a && exit 0
19-
2012

2113
rm -rf AD_dnSVM* #always remove the link
2214

@@ -26,19 +18,19 @@ rm -rf AD_dnSVM* #always remove the link
2618
version=https://github.com/lauvergn/AD_dnSVM/archive/refs/heads/AD_dnSVM_dev.zip
2719

2820

29-
curl -LJ $version --output $LOC_version.zip
21+
test -z $EXTLIB_TYPE && curl -LJ $version --output $LOC_version.zip
22+
test $EXTLIB_TYPE != 'loc' && curl -LJ $version --output $LOC_version.zip
23+
3024
test -e $LOC_version.zip && echo $LOC_version.zip file exist || cp $SAVE_version.zip $LOC_version.zip
3125

3226
unzip $LOC_version.zip
3327
rm -f $LOC_version.zip
3428

29+
3530
LIBDIR=`ls -d AD_dnSVM*`
3631
#echo $LIBDIR
3732

3833
ln -s $LIBDIR $LOC_version
3934

40-
cd $LIBDIR
41-
make lib FC=$FC OPT=$OPT OMP=$OMP LAPACK=$LAPACK ExtLibDIR=$ExtLibDIR
42-
4335
echo "End get_dnSVM.sh"
4436

SRC/Model_m.f90

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,14 +2759,16 @@ SUBROUTINE Write_QdnV_FOR_Model(Q,PotVal,QModel,Vec,NAC,info,name_file)
27592759
close(nio_loc)
27602760

27612761
END SUBROUTINE Write_QdnV_FOR_Model
2762-
SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv)
2762+
2763+
SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv,AnaNum_Test)
27632764
USE ADdnSVM_m, ONLY : dnMat_t,alloc_dnMat,dealloc_dnMat,Write_dnMat, &
27642765
get_maxval_OF_dnMat, operator(-)
27652766
IMPLICIT NONE
27662767

2767-
TYPE (Model_t), intent(inout) :: QModel
2768-
real (kind=Rkind), intent(in) :: Q(:)
2769-
integer, intent(in) :: nderiv
2768+
TYPE (Model_t), intent(inout) :: QModel
2769+
real (kind=Rkind), intent(in) :: Q(:)
2770+
integer, intent(in) :: nderiv
2771+
logical, intent(inout), optional :: AnaNum_Test
27702772

27712773
! local variables
27722774
TYPE (dnMat_t) :: Mat_diff
@@ -2775,6 +2777,7 @@ SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv)
27752777
TYPE (dnMat_t) :: Vec_ana,Vec_num
27762778

27772779
real (kind=Rkind) :: MaxMat,MaxDiffMat
2780+
logical :: AnaNum_Test_loc
27782781

27792782
!----- for debuging --------------------------------------------------
27802783
character (len=*), parameter :: name_sub='Check_analytical_numerical_derivatives'
@@ -2834,7 +2837,9 @@ SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv)
28342837
write(out_unitp,'(3a,l9)') 'With ',QModel%QM%pot_name, &
28352838
': Potential diff (numer-ana), ZERO? ',(MaxDiffMat/MaxMat <= step)
28362839

2837-
IF (MaxDiffMat/MaxMat > step .OR. debug) THEN
2840+
AnaNum_Test_loc = (MaxDiffMat/MaxMat <= step)
2841+
2842+
IF (MaxDiffMat/MaxMat > step .OR. debug) THEN
28382843
write(out_unitp,*) 'Potential diff (ana-numer)'
28392844
CALL Write_dnMat(Mat_diff,nio=out_unitp)
28402845
END IF
@@ -2851,6 +2856,9 @@ SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv)
28512856
write(out_unitp,'(3a,l9)') 'With ',QModel%QM%pot_name, &
28522857
': NAC diff (numer-ana), ZERO? ',(MaxDiffMat/MaxMat <= step)
28532858

2859+
AnaNum_Test_loc = AnaNum_Test_loc .AND. (MaxDiffMat/MaxMat <= step)
2860+
2861+
28542862
IF (MaxDiffMat/MaxMat > step .OR. debug) THEN
28552863
write(out_unitp,*) 'NAC diff (ana-numer)'
28562864
CALL Write_dnMat(Mat_diff,nio=out_unitp)
@@ -2870,6 +2878,8 @@ SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv)
28702878
write(out_unitp,'(3a,l9)') 'With ',QModel%QM%pot_name, &
28712879
': Vec diff (numer-ana), ZERO? ',(MaxDiffMat/MaxMat <= step)
28722880

2881+
AnaNum_Test_loc = AnaNum_Test_loc .AND. (MaxDiffMat/MaxMat <= step)
2882+
28732883
IF (MaxDiffMat/MaxMat > step .OR. debug) THEN
28742884
write(out_unitp,*) 'Vec diff (ana-numer)'
28752885
CALL Write_dnMat(Mat_diff,nio=out_unitp)
@@ -2889,6 +2899,8 @@ SUBROUTINE Check_analytical_numerical_derivatives(QModel,Q,nderiv)
28892899
CALL dealloc_dnMat(Vec_num)
28902900
CALL dealloc_dnMat(Mat_diff)
28912901

2902+
IF (present(AnaNum_Test)) AnaNum_Test = AnaNum_Test_loc
2903+
28922904
IF (debug) THEN
28932905
write(out_unitp,*) ' END ',name_sub
28942906
flush(out_unitp)

Tests/TEST_model.f90

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
PROGRAM TEST_model
4141
IMPLICIT NONE
4242

43+
!CALL test_TwoD_Valahu2022() ; stop
44+
!CALL test_H3() ; stop
45+
4346
!CALL test_ClH2p_op56() ; stop
4447
!CALL test_H3() ; stop
4548

@@ -2457,7 +2460,9 @@ SUBROUTINE test_TwoD_RJDI2014
24572460
END SUBROUTINE test_TwoD_RJDI2014
24582461
SUBROUTINE test_TwoD_Valahu2022
24592462
USE QDUtil_NumParameters_m, out_unitp => out_unit, in_unitp => in_unit
2460-
USE QDUtil_m, ONLY : Write_Vec
2463+
USE QDUtil_m, ONLY : Write_Vec, TO_string
2464+
USE QDUtil_Test_m
2465+
24612466
USE ADdnSVM_m
24622467
USE Model_m
24632468
IMPLICIT NONE
@@ -2467,6 +2472,25 @@ SUBROUTINE test_TwoD_Valahu2022
24672472
integer :: ndim,nsurf,nderiv,i,option
24682473
TYPE (dnMat_t) :: PotVal
24692474

2475+
TYPE (test_t) :: test_var
2476+
logical :: val_test,res_test
2477+
real (kind=Rkind), parameter :: ZeroTresh = ONETENTH**10
2478+
real (kind=Rkind), parameter :: Qref(*) = [-1.5_Rkind,0.0_Rkind]
2479+
real (kind=Rkind), parameter :: d0V(*) = [-4712.3889803846896_Rkind,ZERO, &
2480+
ZERO,14137.166941154068_Rkind]
2481+
real (kind=Rkind), parameter :: d1V(*) = [-9.0949470177292824E-013_Rkind,ZERO,&
2482+
ZERO,-12566.370614359173_Rkind, &
2483+
ZERO,ZERO,ZERO,ZERO]
2484+
real (kind=Rkind), parameter :: d2V(*) = [4188.7902047863909_Rkind,ZERO,ZERO, &
2485+
4188.7902047863909_Rkind,ZERO,ZERO, &
2486+
ZERO,ZERO,ZERO,ZERO, &
2487+
ZERO,ZERO,9.0949470177292824E-013_Rkind,&
2488+
ZERO,ZERO,8377.5804095727799_Rkind]
2489+
2490+
real (kind=Rkind), parameter :: dnV(*) = [d0V,d1V,d2V]
2491+
real (kind=Rkind), parameter :: Gref(*) = [4188.7902047863909_Rkind,ZERO,ZERO,4188.7902047863909_Rkind]
2492+
2493+
CALL Initialize_Test(test_var,test_name='TwoD_Valahu2022')
24702494

24712495
write(out_unitp,*) '---------------------------------------------'
24722496
write(out_unitp,*) '---------------------------------------------'
@@ -2480,6 +2504,7 @@ SUBROUTINE test_TwoD_Valahu2022
24802504
allocate(Q(QModel%ndim))
24812505

24822506
nderiv=2
2507+
CALL Append_Test(test_var,'== TESTING with nderiv= ' // TO_string(nderiv))
24832508

24842509
write(out_unitp,*) '---------------------------------------------'
24852510
write(out_unitp,*) '----- CHECK POT -----------------------------'
@@ -2490,7 +2515,9 @@ SUBROUTINE test_TwoD_Valahu2022
24902515
CALL get_Q0_Model(Q,QModel,option)
24912516
write(out_unitp,*) 'Q(:) (no unit):'
24922517
CALL Write_Vec(Q,out_unitp,QModel%ndim)
2493-
CALL Check_analytical_numerical_derivatives(QModel,Q,nderiv)
2518+
CALL Check_analytical_numerical_derivatives(QModel,Q,nderiv,AnaNum_Test=res_test)
2519+
2520+
CALL Logical_Test(test_var,test1=res_test,info='Ana-Num test: T ? ' // TO_string(res_test) )
24942521

24952522
write(out_unitp,*) '---------------------------------------------'
24962523
write(out_unitp,*) '---------------------------------------------'
@@ -2505,8 +2532,17 @@ SUBROUTINE test_TwoD_Valahu2022
25052532
write(out_unitp,*) 'Energy (2*pi Hz)'
25062533
CALL Write_dnMat(PotVal,nio=out_unitp)
25072534

2508-
! For testing the model
2509-
CALL Write_QdnV_FOR_Model(Q,PotVal,QModel,info='TwoD_Valahu2022')
2535+
! For testing the model, Q, PotVal, G
2536+
res_test = all(abs(Q-Qref) < ZeroTresh)
2537+
CALL Logical_Test(test_var,test1=res_test,info='Q == Qref: T ? ' // TO_string(res_test) )
2538+
2539+
res_test = all(abs(get_Flatten(PotVal)-dnV) < ZeroTresh)
2540+
CALL Logical_Test(test_var,test1=res_test,info='PotVal == dnV: T ? ' // TO_string(res_test) )
2541+
2542+
res_test = all(abs(reshape(QModel%QM%d0GGdef,[size(QModel%QM%d0GGdef)])-Gref) < ZeroTresh)
2543+
CALL Logical_Test(test_var,test1=res_test,info='d0GGdef == Gref: T ? ' // TO_string(res_test) )
2544+
2545+
CALL Flush_Test(test_var)
25102546

25112547
CALL dealloc_dnMat(PotVal)
25122548
deallocate(Q)
@@ -2515,7 +2551,8 @@ SUBROUTINE test_TwoD_Valahu2022
25152551
write(out_unitp,*) '- END CHECK POT -----------------------------'
25162552
write(out_unitp,*) '---------------------------------------------'
25172553

2518-
2554+
! finalize the tests
2555+
CALL Finalize_Test(test_var)
25192556

25202557
END SUBROUTINE test_TwoD_Valahu2022
25212558
SUBROUTINE test_HNO3

Tests/run_tests

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,24 @@
55
here=`pwd`
66

77

8-
#for ExternalF90 in gfortran ifort pgf90 nagfor
9-
for ExternalF90 in gfortran
8+
for FC in gfortran
9+
do
10+
for OPT in 0 1
11+
do
12+
for OMP in 0 1
13+
do
14+
for LAPACK in 0 1
1015
do
11-
export ExternalF90
1216
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1317
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
14-
echo $ExternalF90
18+
echo $FC OPT=$OPT OMP=$OMP LAPACK=$LAPACK
1519
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1620
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
17-
for ExternalOPT in 0 1
18-
do
19-
export ExternalOPT
20-
21-
for ExternalOMP in 0 1
22-
do
23-
export ExternalOMP
24-
25-
echo
26-
27-
cd ..
28-
make clean > $here/comp.log 2>&1
29-
cd $here
21+
echo
3022

31-
./run_test_QML
23+
./run_test_QML $FC $OPT $OMP $LAPACK
3224

33-
34-
done
35-
done
36-
25+
done
26+
done
27+
done
3728
done

makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ OPT = 1
1111
OMP = 1
1212
## Lapack/blas/mkl? Empty: default with Lapack; 0: without Lapack; 1 with Lapack
1313
LAPACK = 1
14+
## how to get external libraries; "loc" (default): from local zip file, Empty or something else (v0.5): from github
15+
EXTLIB_TYPE = loc
1416
#=================================================================================
1517
#=================================================================================
1618
ifeq ($(FC),)
@@ -43,7 +45,7 @@ QML_ver := $(shell awk '/QML/ {print $$3}' version-QML)
4345
QML_path := $(shell pwd)
4446

4547
# Extension for the object directory and the library
46-
ext_obj=_$(FFC)_opt$(OOPT)_omp$(OOMP)
48+
ext_obj=_$(FFC)_opt$(OOPT)_omp$(OOMP)_lapack$(LLAPACK)
4749

4850
# library name
4951
QMLIBA=libQMLib$(ext_obj).a
@@ -213,16 +215,18 @@ $(QMLIBA): $(OBJ)
213215
# AD_dnSVM + QDUTIL Lib
214216
#===============================================
215217
#
216-
$(ExtLibDIR):
217-
@echo directory $(ExtLibDIR) does not exist
218-
exit 1
219-
220-
$(QDLIBA): $(ExtLibDIR)
221-
cd $(ExtLibDIR) ; ./get_QDUtilLib.sh $(FFC) $(OOPT) $(OOMP) $(LLAPACK) $(ExtLibDIR)
218+
$(QDLIBA):
219+
@test -d $(ExtLibDIR) || (echo $(ExtLibDIR) "does not exist" ; exit 1)
220+
@test -d $(QD_DIR) || (cd $(ExtLibDIR) ; ./get_QDUtilLib.sh $(EXTLIB_TYPE))
221+
@test -d $(QD_DIR) || (echo $(QD_DIR) "does not exist" ; exit 1)
222+
cd $(QD_DIR) ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) ExtLibDIR=$(ExtLibDIR)
222223
@echo " done " $(QDLIBA) " in QML"
223224

224-
$(ADLIBA): $(ExtLibDIR)
225-
cd $(ExtLibDIR) ; ./get_dnSVM.sh $(FFC) $(OOPT) $(OOMP) $(LLAPACK) $(ExtLibDIR)
225+
$(ADLIBA):
226+
@test -d $(ExtLibDIR) || (echo $(ExtLibDIR) "does not exist" ; exit 1)
227+
@test -d $(AD_DIR) || (cd $(ExtLibDIR) ; ./get_dnSVM.sh $(EXTLIB_TYPE))
228+
@test -d $(AD_DIR) || (echo $(AD_DIR) "does not exist" ; exit 1)
229+
cd $(AD_DIR) ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) ExtLibDIR=$(ExtLibDIR)
226230
@echo " done " $(AD_DIR) " in QML"
227231
#===============================================
228232
#

0 commit comments

Comments
 (0)