Merge branch 'lipid' of mmka.chem.univ.gda.pl:unres into lipid
[unres.git] / source / unres / src_MD-M-newcorr / pinorm.f
diff --git a/source/unres/src_MD-M-newcorr/pinorm.f b/source/unres/src_MD-M-newcorr/pinorm.f
new file mode 100644 (file)
index 0000000..91392bf
--- /dev/null
@@ -0,0 +1,17 @@
+      double precision function pinorm(x)
+      implicit real*8 (a-h,o-z)
+c                                                                      
+c this function takes an angle (in radians) and puts it in the range of
+c -pi to +pi.                                                         
+c                                                                    
+      integer n                                                        
+      include 'COMMON.GEO'
+      n = x / dwapi
+      pinorm = x - n * dwapi
+      if ( pinorm .gt. pi ) then                                      
+         pinorm = pinorm - dwapi
+      else if ( pinorm .lt. - pi ) then                               
+         pinorm = pinorm + dwapi
+      end if                                                          
+      return                                                          
+      end