c
c  _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
c  _/                                                                _/
c  _/          Program to provide test output for h4bmkp.f:          _/
c  _/          ********************************************          _/
c  _/          surface 400s4369z H4 surface evaluation routines      _/
c  _/          (4004369.26), also known as the BMKP H4 surface       _/
c  _/          ---Version of 6 July 2001: Arnold I. Boothroyd        _/
c  _/                                                                _/
c  _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
c
c
c  Any QUESTIONS/PROBLEMS/COMMENTS concerning this programme can be
c  addressed to: boothroy@cita.utoronto.ca or pgmartin@cita.utoronto.ca
c
c
c**********************************************************************
c
c  This program calls the BMKP H4 surface routines in the file h4bmkp.f
c  and compares calculated H4 surface energies and derivatives against
c  stored values that are known to be accurate.  It outputs a message
c  to the standard output (Fortran unit 6) giving the largest of the
c  differences, and stating whether these lie in the acceptable range.
c
c  To compile and run this test program use, e.g., the commands
c
c    f77 -O -o h4bmkp_test h4bmkp_test.f h4bmkp.f
c    ./h4bmkp_test
c
c**********************************************************************
c
c  ALL VARIABLES ARE DOUBLE PRECISION (real*8)
c
c**********************************************************************
c
      program h4bmkp_test
c     ===================
c
      implicit double precision (a-h,o-z)
c
c***** set  n_full_out  below to the number of test conformations for
c      which you wish to produce full individual test output (NOTE
c      that differences are checked for ALL of the test conformations,
c      regardless of the value of n_full_out):
c
      parameter ( n_full_out = 0 )
c
      dimension cc(4,3), r(6), dVdcc(4,3), dVdr(6)
c
      parameter ( ntry = 22, ntry6 = 6 * ntry, ntry12 = 4 * 3 * ntry )
c
      dimension cc_try(4,3,ntry), Vfit_val(ntry), derr_other(6,ntry),
     $     dVdcc_val(4,3,ntry), cc_init(ntry12), derr_init(ntry6),
     $     dVdcc_init(ntry12), Vfit_get(ntry), derr_get(ntry),
     $     dVdcc_get(4,3,ntry)
      equivalence ( cc_try(1,1,1), cc_init(1) ),
     $     ( derr_other(1,1), derr_init(1) ),
     $     ( dVdcc_val(1,1,1), dVdcc_init(1) )
c
      data ( cc_init(i), i = 1, 64 ) /
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $ -0.500000000d0,  0.500000000d0,  3.100000000d0, -3.100000000d0,
     $  0.116940549d0, -0.116940549d0, -0.725031403d0,  0.725031403d0,
     $  0.137051579d0, -0.137051579d0, -0.849719790d0,  0.849719790d0,
     $ -0.466413736d0,  0.466413736d0,  2.891765161d0, -2.891765161d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  1.724094000d0,  3.474094000d0,
     $ -0.300000000d0,  0.300000000d0,  0.000000000d0,  0.000000000d0,
     $ -0.059672307d0,  0.059672307d0, -1.388902004d0, -2.798673460d0,
     $  0.293813509d0, -0.293813509d0, -0.317185782d0, -0.639137554d0,
     $ -0.010622514d0,  0.010622514d0, -0.971001814d0, -1.956593768d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  1.750000000d0,
     $ -0.500000000d0,  0.500000000d0,  1.900000000d0,  1.900000000d0,
     $ -0.262504312d0,  0.262504312d0,  0.997516385d0,  0.146728450d0 /
c
      data ( cc_init(i), i = 65, 128 ) /
     $  0.407968814d0, -0.407968814d0, -1.550281495d0, -1.644830021d0,
     $ -0.121049299d0,  0.121049299d0,  0.459987335d0,  1.986329521d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  1.996078000d0,  3.814731000d0,
     $ -0.500000000d0,  0.500000000d0,  1.152436000d0,  2.202436000d0,
     $ -0.344380059d0,  0.344380059d0,  0.624689154d0,  1.193851930d0,
     $  0.131941929d0, -0.131941929d0,  1.483857208d0,  2.835818993d0,
     $  0.337629534d0, -0.337629534d0, -1.649353620d0, -3.152101703d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  1.515544000d0,
     $  0.000000000d0,  0.000000000d0,  1.212436000d0,  0.337435000d0,
     $ -0.700000000d0,  0.700000000d0,  0.000000000d0,  0.000000000d0,
     $ -0.054721165d0,  0.054721165d0, -0.823042406d0,  0.877465257d0,
     $  0.209158325d0, -0.209158325d0,  0.827777467d0,  1.240905109d0,
     $ -0.665776531d0,  0.665776531d0,  0.327699127d0,  0.317718788d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  1.093216000d0, -1.093216000d0 /
c
      data ( cc_init(i), i = 129, 192 ) /
     $ -0.560273000d0,  0.560273000d0,  0.806247000d0,  1.434846000d0,
     $  0.057256454d0, -0.057256454d0,  0.875696431d0, -1.104722351d0,
     $  0.089005673d0, -0.089005673d0, -0.654363398d0,  0.298340547d0,
     $ -0.550186807d0,  0.550186807d0,  0.806300038d0,  1.394448174d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  1.974336000d0,
     $  0.000000000d0,  0.000000000d0,  0.697136000d0,  0.935898000d0,
     $ -0.563175000d0,  0.563175000d0,  1.666967000d0,  1.951857000d0,
     $ -0.004023890d0,  0.004023890d0,  0.553700523d0,  1.983655886d0,
     $ -0.115419841d0,  0.115419841d0, -0.088532760d0,  1.322558920d0,
     $  0.551206086d0, -0.551206086d0, -1.717659821d0, -1.702821390d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  1.368548000d0,
     $  0.000000000d0,  0.000000000d0,  2.172190000d0,  3.477432000d0,
     $ -1.122129000d0,  1.122129000d0,  2.733512000d0,  4.289816000d0,
     $ -0.690060433d0,  0.690060433d0,  0.720924558d0,  1.994829760d0,
     $  0.707616370d0, -0.707616370d0, -1.242380023d0, -0.916615187d0,
     $ -0.531290094d0,  0.531290094d0,  3.182335135d0,  5.248661647d0 /
c
      data ( cc_init(i), i = 193, ntry12 ) /
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  6.013498000d0,
     $  0.000000000d0,  0.000000000d0,  0.519615000d0, 11.448340000d0,
     $ -0.300000000d0,  0.300000000d0,  0.000000000d0, 12.288553000d0,
     $ -0.098656340d0,  0.098656340d0, -0.443078038d0, -3.280063428d0,
     $ -0.137830716d0,  0.137830716d0,  0.270180851d0, 15.928892591d0,
     $ -0.247527009d0,  0.247527009d0,  0.026151641d0,  7.331217261d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $ -0.500000000d0,  0.500000000d0,  4.900000000d0,  6.100000000d0,
     $  0.396861455d0, -0.396861455d0, -3.889242263d0, -4.841709756d0,
     $  0.303859319d0, -0.303859319d0, -2.977821328d0, -3.707083695d0,
     $  0.013057538d0, -0.013057538d0, -0.127963875d0, -0.159301966d0,
     $  0.000000000d0,  0.000000000d0,  0.000000000d0,  0.000000000d0,
     $  0.000000000d0,  0.000000000d0,  1.585248000d0, -1.585248000d0,
     $ -0.820061000d0,  0.820061000d0,  1.240761000d0,  2.039482000d0,
     $  0.556274676d0, -0.556274676d0, -0.735047519d0, -1.490050506d0,
     $  0.047921939d0, -0.047921939d0,  1.493260493d0, -1.684948190d0,
     $ -0.600634678d0,  0.600634678d0,  1.132421002d0,  1.270116978d0 /
c
      data Vfit_val /
     $     -0.1145904318206971d0, -0.1145904321354952d0,
     $      0.1595022527364836d0,  0.1595022521845414d0,
     $     -0.1049424539407363d0, -0.1049424538272188d0,
     $     -0.2203533042998073d0, -0.2203533042362201d0,
     $      0.1359855545069924d0,  0.1359855544080642d0,
     $      0.1049479152802464d0,  0.1049479159370015d0,
     $     -0.1277814215196244d0, -0.1277814213644118d0,
     $     -0.2108983430354923d0, -0.2108983430826140d0,
     $      1.2111151593142029d0,  1.2111151599798233d0,
     $     -0.2892824146805810d0, -0.2892824144114552d0,
     $     -0.0938009222353434d0, -0.0938009222785217d0 /
c
      data ( derr_init(i), i = 1, 60 ) /
     $     5.551d-17,2.510d-15,4.905d-16,4.905d-16,8.327d-17,4.905d-16,
     $     1.017d-11,1.016d-11,1.483d-11,1.483d-11,1.483d-11,1.483d-11,
     $     1.617d-15,1.568d-15,1.874d-15,1.874d-15,5.551d-16,1.867d-15,
     $     4.132d-10,4.132d-10,4.132d-10,4.132d-10,4.132d-10,4.132d-10,
     $     3.109d-15,3.390d-15,7.022d-15,7.022d-15,2.554d-15,7.022d-15,
     $     1.488d-12,1.913d-12,1.118d-12,1.118d-12,5.475d-13,1.118d-12,
     $     4.990d-07,1.744d-07,1.895d-07,1.895d-07,9.870d-10,1.895d-07,
     $     1.311d-10,1.420d-07,3.278d-09,3.278d-09,1.420d-07,3.278d-09,
     $     5.274d-16,2.814d-16,4.163d-16,4.163d-16,4.637d-16,4.163d-16,
     $     3.886d-16,1.628d-16,3.331d-16,3.331d-16,3.608d-16,3.469d-16/
c
      data ( derr_init(i), i = 61, ntry6 ) /
     $     6.501d-06,3.875d-05,3.427d-05,3.427d-05,6.355d-06,3.427d-05,
     $     1.048d-05,2.762d-06,2.275d-05,2.275d-05,2.762d-06,2.275d-05,
     $     1.443d-15,1.039d-15,9.159d-16,9.159d-16,1.249d-15,9.159d-16,
     $     9.298d-16,8.652d-16,1.804d-15,1.804d-15,8.327d-16,1.804d-15,
     $     1.388d-17,1.386d-17,6.939d-18,6.939d-18,6.939d-18,6.939d-18,
     $     1.388d-17,9.134d-18,1.388d-17,1.388d-17,6.939d-18,1.388d-17,
     $     0.000d+00,2.116d-16,4.441d-16,4.441d-16,2.220d-16,4.441d-16,
     $     0.000d+00,1.806d-16,5.551d-17,5.551d-17,2.220d-16,5.551d-17,
     $     4.052d-15,7.476d-15,4.843d-15,4.843d-15,5.551d-17,4.843d-15,
     $     9.807d-13,9.807d-13,9.807d-13,9.807d-13,9.807d-13,9.807d-13,
     $     2.720d-06,1.000d-06,6.998d-06,6.998d-06,1.900d-06,6.998d-06,
     $     2.767d-07,1.741d-07,1.741d-07,1.741d-07,1.741d-07,1.741d-07/
c
      data ( dVdcc_init(i), i = 1, 32 ) /
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.3641959592425479d0, -0.3641959592425473d0,
     $      0.0028787786242194d0, -0.0028787786242200d0,
     $     -0.0851785504619483d0,  0.0851785504619485d0,
     $     -0.0006732919130251d0,  0.0006732919130250d0,
     $     -0.0998272620991160d0,  0.0998272620991162d0,
     $     -0.0007890823181913d0,  0.0007890823181911d0,
     $      0.3397319944655561d0, -0.3397319944655566d0,
     $      0.0026854038140390d0, -0.0026854038140385d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0731715881999419d0,  0.0731715881999450d0,
     $     -0.1840789071829474d0,  0.0377357307830606d0 /
c
      data ( dVdcc_init(i), i = 33, 64 ) /
     $      1.8842487630156846d0, -1.8842487630156850d0,
     $      0.0000000000000000d0,  0.0000000000000003d0,
     $      0.3158457302202645d0, -0.4337374059777908d0,
     $      0.1482909648397964d0, -0.0303992890822700d0,
     $     -1.8588540216215150d0,  1.8319309101490571d0,
     $      0.0338654460412865d0, -0.0069423345688283d0,
     $      0.0255082939168905d0, -0.1079280982749267d0,
     $      0.1036723946462070d0, -0.0212525902881708d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0483077863489645d0,  0.0297833983009491d0,
     $     -0.1006967969141118d0,  0.0226056122641979d0,
     $      0.3946983431500806d0, -0.1146118009133619d0,
     $     -0.1900091451745223d0, -0.0900773970621960d0,
     $      0.1837345019207132d0, -0.0746518163891939d0,
     $     -0.0508012282994742d0, -0.0582814572320453d0 /
c
      data ( dVdcc_init(i), i = 65, 96 ) /
     $     -0.3246591905138660d0,  0.0919069520870101d0,
     $      0.1604760305741994d0,  0.0722762078526570d0,
     $      0.1376897511627988d0, -0.0017704096770738d0,
     $     -0.1338282441391415d0, -0.0020910973465833d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0161978998129615d0,  0.0307576769640190d0,
     $     -0.1157536394085636d0,  0.0687980626315832d0,
     $      0.3325071429410372d0, -0.3099343136767224d0,
     $     -0.0613167156174913d0,  0.0387438863453845d0,
     $      0.2276457377801806d0, -0.2160754928411998d0,
     $     -0.0324284653214527d0,  0.0208582203785768d0,
     $     -0.0732341646016871d0,  0.1093375372532545d0,
     $     -0.0875046478389491d0,  0.0514012751718011d0,
     $     -0.2315978140627947d0,  0.1958621914398561d0,
     $      0.0919237503836337d0, -0.0561881277606951d0 /
c
      data ( dVdcc_init(i), i = 97, 128 ) /
     $      0.0960848673819654d0,  0.0960848673819726d0,
     $      0.1420229294531820d0, -0.3341926642171199d0,
     $      0.0515312861407187d0,  0.0515312861407141d0,
     $     -0.1422731863212724d0,  0.0392106140398394d0,
     $      0.1307146969003845d0, -0.1307146969003843d0,
     $     -0.0000000000000034d0,  0.0000000000000032d0,
     $      0.0453922816057780d0,  0.0249528267838127d0,
     $      0.2002727987998610d0, -0.2706179071894513d0,
     $      0.0601903549681097d0,  0.1383080343512056d0,
     $     -0.0024380945062322d0, -0.1960602948130829d0,
     $      0.1526122895780600d0, -0.0960366841478262d0,
     $     -0.0172243905939040d0, -0.0393512148363303d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $     -0.1138051554529961d0,  0.1948489192841474d0,
     $     -0.2932428340350640d0,  0.2121990702219746d0 /
c
      data ( dVdcc_init(i), i = 129, 160 ) /
     $      0.2918226125761804d0, -0.2064428443620119d0,
     $      0.0675250122636398d0, -0.1529047804793134d0,
     $     -0.1295608364509605d0,  0.1918619637347152d0,
     $     -0.2638974305212932d0,  0.2015963032375381d0,
     $      0.0084273068805278d0, -0.0610058907893875d0,
     $      0.1304420855654242d0, -0.0778635016655729d0,
     $      0.2850526639639829d0, -0.2001300011624813d0,
     $      0.0624018875583843d0, -0.1473245503628885d0,
     $      0.0415203128936094d0,  0.0180695567892401d0,
     $     -0.0972435971548059d0,  0.0376537274719564d0,
     $      0.0241186172735671d0,  0.1064314908402105d0,
     $     -0.1140625578120234d0, -0.0164875503017540d0,
     $      0.2335166447772201d0,  0.0012304460385838d0,
     $     -0.1831783327902180d0, -0.0515687580255861d0,
     $      0.0465395297297485d0,  0.0940940438578309d0,
     $     -0.1511453832349027d0,  0.0105118096473233d0 /
c
      data ( dVdcc_init(i), i = 161, 192 ) /
     $      0.0645213287213646d0, -0.0516929505826495d0,
     $     -0.0410413239535456d0,  0.0282129458148306d0,
     $     -0.2247370414720812d0, -0.0113945124156544d0,
     $      0.1774586397463518d0,  0.0586729141413838d0,
     $      0.0004079653773875d0,  0.0002405754209709d0,
     $     -0.0465124748115429d0,  0.0458639340131845d0,
     $      0.0019682044371523d0,  0.0010160025425088d0,
     $     -0.0456971985023924d0,  0.0427129915227313d0,
     $     -0.0839649980578212d0,  0.0880889245381225d0,
     $     -0.0548474646983608d0,  0.0507235382180596d0,
     $     -0.0522382990819660d0,  0.0538789052597310d0,
     $     -0.0439067495351917d0,  0.0422661433574266d0,
     $      0.0536880787973882d0, -0.0551449246932076d0,
     $     -0.0101357609762921d0,  0.0115926068721115d0,
     $     -0.0379856745131232d0,  0.0426245189287542d0,
     $     -0.0723142610014679d0,  0.0676754165858370d0 /
c
      data ( dVdcc_init(i), i = 193, 224 ) /
     $      0.0000004799204965d0,  0.0000005347148537d0,
     $      0.0000005493873178d0, -0.0000015640226680d0,
     $      1.2836252164477293d0,  1.2843879288484479d0,
     $     -2.5680102152223037d0, -0.0000029300738738d0,
     $      2.3199842909338342d0, -2.3204225124534021d0,
     $      0.0004414148584770d0, -0.0000031933389089d0,
     $     -0.3317086089590525d0, -1.8582586491169821d0,
     $      2.1899664445598468d0,  0.0000008135161876d0,
     $      1.7333387262773052d0, -0.3981963942665523d0,
     $     -1.3351382150787134d0, -0.0000041169320392d0,
     $      1.9787529779187294d0, -1.8498291463516892d0,
     $     -0.1289219294695648d0, -0.0000019020974753d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0 /
c
      data ( dVdcc_init(i), i = 225, 256 ) /
     $      0.3221196173787136d0, -0.3215481420448210d0,
     $      0.1067337331273339d0, -0.1073052084612265d0,
     $     -0.2556737215124770d0,  0.2552201284475506d0,
     $     -0.0847170090434006d0,  0.0851706021083270d0,
     $     -0.1957580962481070d0,  0.1954108000370416d0,
     $     -0.0648640788223111d0,  0.0652113750333765d0,
     $     -0.0084121783358203d0,  0.0083972542134203d0,
     $     -0.0027873595232887d0,  0.0028022836456887d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $      0.0000000000000000d0,  0.0000000000000000d0,
     $     -0.0474310011575919d0,  0.0370536015857172d0,
     $     -0.0323692121591663d0,  0.0427466117299596d0,
     $      0.0204533985061267d0, -0.0271565433333268d0,
     $      0.0400338508163813d0, -0.0333307059893615d0,
     $     -0.0170637776892022d0,  0.0209129029221635d0,
     $     -0.0293330016588353d0,  0.0254838764260092d0 /
c
      data ( dVdcc_init(i), i = 257, ntry12 ) /
     $     -0.0480433579569623d0,  0.0381851981879856d0,
     $     -0.0343108868583598d0,  0.0441690466273366d0,
     $      0.0082888256607259d0, -0.0146624819035816d0,
     $      0.0247550634459971d0, -0.0183814072027811d0 /
c
      write(6,5) ntry
 5    format(' '/'BMKP H4 surface test of',i3,' conformations:',
     $     '  Check energy  "Vfit"  and its'/
     $     '=========================================',
     $     '  cartesian derivatives  "dVdcc".')
c
      ideriv = 2
      n_full_do = n_full_out
c
      dmax_Vfit = 0.d0
      dmax_dVdcc = 0.d0
      Derr_max = 0.d0
c
      do k = 1, ntry
c
         do i = 1, 4
            cc(i,1) = cc_try(i,1,k)
            cc(i,2) = cc_try(i,2,k)
            cc(i,3) = cc_try(i,3,k)
         enddo
c
         call h4bmkp( cc, Vfit, r, dVdcc, dVdr, Derr, ideriv )
c
         Vfit_get(k) = Vfit
c
         dmax_Vfit = max( dmax_Vfit , abs( Vfit - Vfit_val(k) ) )
c
         derr_get(k) = Derr
c
         Derr_max = max( Derr_max , Derr )
c
         do j = 1, 3
            do i = 1, 4
               dVdcc_get(i,j,k) = dVdcc(i,j)
               dmax_dVdcc = max( dmax_dVdcc ,
     $              abs( dVdcc(i,j) - dVdcc_val(i,j,k) ) )
            enddo
         enddo
c
      enddo
c
c BMKP H4 surface test of 22 conformations:  Check energy  "Vfit"  and its
c =========================================  cartesian derivatives  "dVdcc".
c
c Below:  "max{delta:Vfit}"  is the maximum absolute difference between the
c  22 calculated Vfit values and the corresponding correct stored values,
c  "max{delta:dVdcc}"  is the similar maximum absolute difference over the
c  derivatives with respect to each point's 12 cartesian coordinates, and
c  "max{Derr}" is the maximum returned value of the calculated error in the
c  derivatives  "dVdr"  with respect to the 6 distances.  All are in atomic
c  units (energy in hartrees, distance in bohrs).  The max{...} values should
c  be small but non-zero, and should lie within the limits quoted underneath:
c
c           max{delta:Vfit}      max{delta:dVdcc}          max{Derr}
c Limits  1.000E-17:1.000E-10   1.000E-17:1.000E-09   1.000E-07:5.000E-05
c
c  For our tests of several different machine types, operating systems, fortran
c  compilers, and optimization levels: the max{...} values lay in the ranges:
c
c         5.551E-17:1.830E-13   5.551E-17:2.668E-11   6.355E-06:3.875E-05
c
      write(6,10) ntry, dmax_Vfit, dmax_dVdcc, Derr_max
 10   format(' '/' Below:  "max{delta:Vfit}"  is the maximum absolute',
     $     ' difference between the'/i4,' calculated Vfit values and',
     $     ' the corresponding correct stored values,'/'  "max{delta:',
     $     'dVdcc}"  is the similar maximum absolute difference over',
     $     ' the'/'  derivatives with respect to each point''s 12',
     $     ' cartesian coordinates, and'/'  "max{Derr}" is the',
     $     ' maximum returned value of the calculated error in the'/
     $     '  derivatives  "dVdr"  with respect to the 6 distances.',
     $     '  All are in atomic'/'  units (energy in hartrees,',
     $     ' distance in bohrs).  The max{...} values should'/
     $     '  be small but non-zero, and should lie within the',
     $     ' limits quoted underneath:'/' '/
     $     ' max{delta:Vfit}=',1p,e10.3,'  max{delta:dVdcc}=',e10.3,
     $     '  max{Derr}=',e10.3/' '/' Limits 1.000E-17:1.000E-10',
     $     '          1.000E-17:1.000E-09   1.000E-07:5.000E-05'/' ')
c
      if ( dmax_Vfit .lt. 1.d-17 .or. dmax_Vfit .gt. 1.d-10 ) then
         write(6,11)
 11      format(' There is a problem with the Vfit values.'/' ')
         if ( dmax_dVdcc .lt. 1.d-17 .or. dmax_Vfit .gt. 1.d-9 ) then
            write(6,12)
 12         format(' There is a problem with the dVdcc values.'/' ')
            if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 )
     $           write(6,13)
 13         format(' There is a problem with the dVdr values.'/' ')
         else if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 ) then
            write(6,13)
         endif
      else if ( dmax_dVdcc .lt. 1.d-17 .or. dmax_Vfit .gt. 1.d-9 ) then
         write(6,14)
 14      format(' Vfit is O.K.,',
     $        ' but there is a problem with the dVdcc values.'/' ')
         if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 )
     $        write(6,13)
      else if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 ) then
         write(6,15)
 15      format(' Vfit and dVdcc are O.K.,',
     $        ' but there is a problem with the dVdr values.'/' '/
     $        ' You should be able to use the BMKP surface,',
     $        ' as long as you do NOT use dVdr.'/' ')
      else
         write(6,18) ntry
 18      format(' ***** Calculated values for the',i3,
     $        ' tested conformations are ALL CORRECT.'/' ')
      endif
c
      if ( n_full_do .le. 0 ) stop
c
      write(6,19) n_full_do
 19   format(' '/' Full comparison for',i3,' points:',
     $     ' for Vfit and dVdcc, calculated and stored'/
     $     ' values are output, as well as the difference;',
     $     ' for Derr, calculated value is'/
     $     ' output, as well as six stored values',
     $     ' (for six system/optimization-levels):')
c
      do k = 1, min( n_full_do , ntry )
c
         write(6,20) k, Vfit_get(k), Vfit_val(k),
     $        Vfit_get(k) - Vfit_val(k), derr_get(k),
     $        ( derr_other(i,k), i = 1, 6 )
 20      format(' '/' ***Point',i3,': Vfit',f16.12,' Vstored',f16.12,
     $        ' diff',f16.12/' Derr',1p,e10.3,' cf.',6e10.3)
c
         do i = 1, 4
            do j = 1, 3
               write(6,30) i, j, cc_try(i,j,k),
     $              dVdcc_get(i,j,k), dVdcc_val(i,j,k),
     $              dVdcc_get(i,j,k) - dVdcc_val(i,j,k)
 30            format(' cc(',i1,',',i1,')',f13.9,' dVdcc',f13.9,
     $              ' stored',f13.9,' diff',f13.9)
            enddo
         enddo
c
      enddo
c
      write(6,10) ntry, dmax_Vfit, dmax_dVdcc, Derr_max
c
      if ( dmax_Vfit .lt. 1.d-17 .or. dmax_Vfit .gt. 1.d-10 ) then
         write(6,11)
         if ( dmax_dVdcc .lt. 1.d-17 .or. dmax_Vfit .gt. 1.d-9 ) then
            write(6,12)
            if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 )
     $           write(6,13)
         else if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 ) then
            write(6,13)
         endif
      else if ( dmax_dVdcc .lt. 1.d-17 .or. dmax_Vfit .gt. 1.d-9 ) then
         write(6,14)
         if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 )
     $        write(6,13)
      else if ( Derr_max .lt. 1.d-7 .or. Derr_max .gt. 5.d-5 ) then
         write(6,15)
      else
         write(6,18) ntry
      endif
c
      stop
      end
