corrections of max... ranges of arrays
[unres4.git] / source / wham / enecalc.f90
index fd5f6ca..ecbce9d 100644 (file)
@@ -5,7 +5,7 @@
 !
       use geometry_data, only:nres
       use energy_data
-      use control_data, only:maxthetyp1
+!      use control_data, only:maxthetyp1
       use energy, only:etotal,enerprint,rescale_weights
 #ifdef MPI
       use MPI_data
@@ -704,9 +704,9 @@ write(iout,*)"enecalc_ i ntot",i,ntot
         ithetyp_all(i,iparm)=ithetyp(i)
       enddo
       do iblock=1,2
-      do i=-maxthetyp1,maxthetyp1
-        do j=-maxthetyp1,maxthetyp1
-          do k=-maxthetyp1,maxthetyp1
+      do i=-nthetyp-1,nthetyp+1
+        do j=-nthetyp-1,nthetyp+1
+          do k=-nthetyp-1,nthetyp+1
             aa0thet_all(i,j,k,iblock,iparm)=aa0thet(i,j,k,iblock)
             do l=1,ntheterm
               aathet_all(l,i,j,k,iblock,iparm)=aathet(l,i,j,k,iblock)
@@ -976,9 +976,9 @@ write(iout,*)"end of store_parm"
         ithetyp(i)=ithetyp_all(i,iparm)
       enddo
       do iblock=1,2
-      do i=-maxthetyp1,maxthetyp1
-        do j=-maxthetyp1,maxthetyp1
-          do k=-maxthetyp1,maxthetyp1
+      do i=-nthetyp-1,nthetyp+1
+        do j=-nthetyp-1,nthetyp+1
+          do k=-nthetyp-1,nthetyp+1
             aa0thet(i,j,k,iblock)=aa0thet_all(i,j,k,iblock,iparm)
             do l=1,ntheterm
               aathet(l,i,j,k,iblock)=aathet_all(l,i,j,k,iblock,iparm)
@@ -1608,34 +1608,34 @@ write(iout,*)"end of store_parm"
       allocate(gthet_all(3,-ntyp:ntyp,iparm)) !(3,-ntyp:ntyp,max_parm)
       allocate(theta0_all(-ntyp:ntyp,iparm),&
         sig0_all(-ntyp:ntyp,iparm),sigc0_all(-ntyp:ntyp,nParmSet)) !(-ntyp:ntyp,max_parm)
-      allocate(aa0thet_all(-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,iparm))
+      allocate(aa0thet_all(-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,2,iparm))
 !(-maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,max_parm)
-      allocate(aathet_all(maxtheterm,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,iparm))
+      allocate(aathet_all(ntheterm,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,2,iparm))
 !(maxtheterm,-maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,max_parm)
-      allocate(bbthet_all(maxsingle,maxtheterm2,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,iparm))
-      allocate(ccthet_all(maxsingle,maxtheterm2,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,iparm))
-      allocate(ddthet_all(maxsingle,maxtheterm2,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,iparm))
-      allocate(eethet_all(maxsingle,maxtheterm2,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,iparm))
+      allocate(bbthet_all(nsingle,ntheterm2,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,2,iparm))
+      allocate(ccthet_all(nsingle,ntheterm2,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,2,iparm))
+      allocate(ddthet_all(nsingle,ntheterm2,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,2,iparm))
+      allocate(eethet_all(nsingle,ntheterm2,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,2,iparm))
 !(maxsingle,maxtheterm2,-maxthetyp1:maxthetyp1,
 !     & -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,2,max_parm)
-      allocate(ffthet_all1(maxdouble,maxdouble,maxtheterm3,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,iparm))
-      allocate(ggthet_all1(maxdouble,maxdouble,maxtheterm3,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,iparm))
-      allocate(ffthet_all2(maxdouble,maxdouble,maxtheterm3,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,iparm))
-      allocate(ggthet_all2(maxdouble,maxdouble,maxtheterm3,&
-        -maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,&
-        -maxthetyp1:maxthetyp1,iparm))
+      allocate(ffthet_all1(ndouble,ndouble,ntheterm3,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,iparm))
+      allocate(ggthet_all1(ndouble,ndouble,ntheterm3,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,iparm))
+      allocate(ffthet_all2(ndouble,ndouble,ntheterm3,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,iparm))
+      allocate(ggthet_all2(ndouble,ndouble,ntheterm3,&
+        -nthetyp-1:nthetyp+1,-nthetyp-1:nthetyp+1,&
+        -nthetyp-1:nthetyp+1,iparm))
 !(maxdouble,maxdouble,maxtheterm3,-maxthetyp1:maxthetyp1,&
 !-maxthetyp1:maxthetyp1,-maxthetyp1:maxthetyp1,max_parm)
       allocate(dsc_all(ntyp1,iparm),dsc0_all(ntyp1,nParmSet)) !(ntyp1,max_parm)
@@ -1644,33 +1644,33 @@ write(iout,*)"end of store_parm"
       allocate(censc_all(3,maxlob,-ntyp:ntyp,iparm)) !(3,maxlob,-ntyp:ntyp,max_parm)
       allocate(gaussc_all(3,3,maxlob,-ntyp:ntyp,iparm)) !(3,3,maxlob,-ntyp:ntyp,max_parm)
       allocate(sc_parmin_all(65,ntyp,iparm)) !(65,ntyp,max_parm)
-      allocate(v0_all(-maxtor:maxtor,-maxtor:maxtor,2,iparm))
+      allocate(v0_all(-ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
 !(-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
-      allocate(v1_all(maxterm,-maxtor:maxtor,-maxtor:maxtor,2,iparm))
-      allocate(v2_all(maxterm,-maxtor:maxtor,-maxtor:maxtor,2,iparm))
+      allocate(v1_all(maxterm,-ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
+      allocate(v2_all(maxterm,-ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
 !(maxterm,-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
-      allocate(vlor1_all(maxlor,maxtor,maxtor,iparm))
-      allocate(vlor2_all(maxlor,maxtor,maxtor,iparm))
-      allocate(vlor3_all(maxlor,maxtor,maxtor,iparm)) !(maxlor,maxtor,maxtor,max_parm)
-      allocate(v1c_all(2,maxtermd_1,-maxtor:maxtor,-maxtor:maxtor,&
-        -maxtor:maxtor,2,iparm))
-      allocate(v1s_all(2,maxtermd_1,-maxtor:maxtor,-maxtor:maxtor,&
-        -maxtor:maxtor,2,iparm))
+      allocate(vlor1_all(maxlor,ntortyp,ntortyp,iparm))
+      allocate(vlor2_all(maxlor,ntortyp,ntortyp,iparm))
+      allocate(vlor3_all(maxlor,ntortyp,ntortyp,iparm)) !(maxlor,maxtor,maxtor,max_parm)
+      allocate(v1c_all(2,maxtermd_1,-ntortyp:ntortyp,-ntortyp:ntortyp,&
+        -ntortyp:ntortyp,2,iparm))
+      allocate(v1s_all(2,maxtermd_1,-ntortyp:ntortyp,-ntortyp:ntortyp,&
+        -ntortyp:ntortyp,2,iparm))
 !(2,maxtermd_1,-maxtor:maxtor,-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
-      allocate(v2c_all(maxtermd_2,maxtermd_2,-maxtor:maxtor,&
-        -maxtor:maxtor,-maxtor:maxtor,2,iparm))
+      allocate(v2c_all(maxtermd_2,maxtermd_2,-ntortyp:ntortyp,&
+        -ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
 !(maxtermd_2,maxtermd_2,-maxtor:maxtor,-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
-      allocate(v2s_all(maxtermd_2,maxtermd_2,-maxtor:maxtor,&
-        -maxtor:maxtor,-maxtor:maxtor,2,iparm))
+      allocate(v2s_all(maxtermd_2,maxtermd_2,-ntortyp:ntortyp,&
+        -ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
 !(maxtermd_2,maxtermd_2,-maxtor:maxtor,-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
-      allocate(b1_all(2,-maxtor:maxtor,iparm))
-      allocate(b2_all(2,-maxtor:maxtor,iparm)) !(2,-maxtor:maxtor,max_parm)
-      allocate(cc_all(2,2,-maxtor:maxtor,iparm))
-      allocate(dd_all(2,2,-maxtor:maxtor,iparm))
-      allocate(ee_all(2,2,-maxtor:maxtor,iparm)) !(2,2,-maxtor:maxtor,max_parm)
-      allocate(ctilde_all(2,2,-maxtor:maxtor,iparm))
-      allocate(dtilde_all(2,2,-maxtor:maxtor,iparm)) !(2,2,-maxtor:maxtor,max_parm)
-      allocate(b1tilde_all(2,-maxtor:maxtor,iparm)) !(2,-maxtor:maxtor,max_parm)
+      allocate(b1_all(2,-nloctyp:nloctyp,iparm))
+      allocate(b2_all(2,-nloctyp:nloctyp,iparm)) !(2,-maxtor:maxtor,max_parm)
+      allocate(cc_all(2,2,-nloctyp:nloctyp,iparm))
+      allocate(dd_all(2,2,-nloctyp:nloctyp,iparm))
+      allocate(ee_all(2,2,-nloctyp:nloctyp,iparm)) !(2,2,-maxtor:maxtor,max_parm)
+      allocate(ctilde_all(2,2,-nloctyp:nloctyp,iparm))
+      allocate(dtilde_all(2,2,-nloctyp:nloctyp,iparm)) !(2,2,-maxtor:maxtor,max_parm)
+      allocate(b1tilde_all(2,-nloctyp:nloctyp,iparm)) !(2,-maxtor:maxtor,max_parm)
       allocate(app_all(2,2,iparm),bpp_all(2,2,nParmSet),&
         ael6_all(2,2,iparm),ael3_all(2,2,nParmSet)) !(2,2,max_parm)
       allocate(aad_all(ntyp,2,iparm),bad_all(ntyp,2,nParmSet)) !(ntyp,2,max_parm)
@@ -1686,13 +1686,13 @@ write(iout,*)"end of store_parm"
       allocate(v2sccor_all(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp,iparm))
 !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp,max_parm)
       allocate(nlob_all(ntyp1,iparm)) !(ntyp1,max_parm)
-      allocate(nlor_all(-maxtor:maxtor,-maxtor:maxtor,2,iparm))
-      allocate(nterm_all(-maxtor:maxtor,-maxtor:maxtor,2,iparm))
+      allocate(nlor_all(-ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
+      allocate(nterm_all(-ntortyp:ntortyp,-ntortyp:ntortyp,2,iparm))
 !(-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
-      allocate(ntermd1_all(-maxtor:maxtor,-maxtor:maxtor,&
-        -maxtor:maxtor,2,iparm))
-      allocate(ntermd2_all(-maxtor:maxtor,-maxtor:maxtor,&
-        -maxtor:maxtor,2,iparm))
+      allocate(ntermd1_all(-ntortyp:ntortyp,-ntortyp:ntortyp,&
+        -ntortyp:ntortyp,2,iparm))
+      allocate(ntermd2_all(-ntortyp:ntortyp,-ntortyp:ntortyp,&
+        -ntortyp:ntortyp,2,iparm))
 !(-maxtor:maxtor,-maxtor:maxtor,-maxtor:maxtor,2,max_parm)
       allocate(nbondterm_all(ntyp,iparm)) !(ntyp,max_parm)
       allocate(ithetyp_all(-ntyp1:ntyp1,iparm)) !(-ntyp1:ntyp1,max_parm)