<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?action=history&amp;feed=atom&amp;title=GMIN_SANITY_module</id>
	<title>GMIN SANITY module - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?action=history&amp;feed=atom&amp;title=GMIN_SANITY_module"/>
	<link rel="alternate" type="text/html" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=GMIN_SANITY_module&amp;action=history"/>
	<updated>2026-05-13T18:44:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=GMIN_SANITY_module&amp;diff=1184&amp;oldid=prev</id>
		<title>Adk44: Created page with &quot;==Introduction== The GMIN SANITY module is intended to contain basic sanity check functions which can be used to help us check that we aren&#039;t doing anything stupid - for e...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=GMIN_SANITY_module&amp;diff=1184&amp;oldid=prev"/>
		<updated>2019-05-10T17:22:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Introduction== The &lt;a href=&quot;/ro-walesdocs/wiki/index.php/GMIN&quot; title=&quot;GMIN&quot;&gt;GMIN&lt;/a&gt; SANITY module is intended to contain basic sanity check functions which can be used to help us check that we aren&amp;#039;t doing anything stupid - for e...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Introduction==&lt;br /&gt;
The [[GMIN]] SANITY module is intended to contain basic sanity check functions which can be used to help us check that we aren&amp;#039;t doing anything stupid - for example trying to make a Cartesian displacement in an angle-axis system. You can find it here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
~/svn/GMIN/source/sanity.f90&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It contains functions which return .TRUE. if the test is passed, and as a result should be called as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! Sanity check - are the coordinates in XYZ Cartesian? &lt;br /&gt;
! Check if the SIZE is a multiple of 3&lt;br /&gt;
   TEST=.FALSE.&lt;br /&gt;
   TEST=CHECK_DIMENSION(SIZE(XYZ),3)&lt;br /&gt;
   IF (.NOT.TEST) THEN&lt;br /&gt;
      STOP &amp;#039;Coordinates in a non-Cartesian basis passed to ROTATION_ABOUT_AXIS&amp;#039;&lt;br /&gt;
   ENDIF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this way, we can print helpful error messages from the routines where the check fails to aid in debugging problems, without having to recode the entire check each time.&lt;br /&gt;
&lt;br /&gt;
==Coding principles==&lt;br /&gt;
[[Image:Coding.jpg|thumb|A useful way of thinking while coding|400px|right]]&lt;br /&gt;
&lt;br /&gt;
In order to make these checks as easy to use as possible, you must adhere to a few basic coding principles when adding such checks&lt;br /&gt;
&lt;br /&gt;
* all check functions must return .TRUE. if the check is passed&lt;br /&gt;
* code blocks must be indented in a manner consistent with the rest of the module (3 spaces)&lt;br /&gt;
* variable names must be understandable e.g. MAX_STEP rather than S&lt;br /&gt;
* avoid using GOTOs!&lt;br /&gt;
* all functions must be fully commented (in English)&lt;br /&gt;
* all arguments must be fully explained&lt;br /&gt;
* check functions should NOT print anything - printing should come from where the function is called. See the example call above - printing is done within the STOP command if the check fails.&lt;br /&gt;
&lt;br /&gt;
==Example: CHECK_DIMENSION==&lt;br /&gt;
The call above comes from the [[GMIN MOVES module]]. We are using CHECK_DIMENSION to make sure that the coordinate array XYZ being used for moves assuming a Cartesian basis are indeed Cartesian:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
FUNCTION CHECK_DIMENSION(ARRAYSIZE, EXPECTED)&lt;br /&gt;
! Function to check the dimension of the ARRAY passed in.&lt;br /&gt;
! Returns .TRUE. if the dimension is as EXPECTED.&lt;br /&gt;
!&lt;br /&gt;
! Arguments:&lt;br /&gt;
! &lt;br /&gt;
! ARRAYSIZE: The size of the array to be checked&lt;br /&gt;
! EXPECTED: The expected dimension of the ARRAY&lt;br /&gt;
   IMPLICIT NONE&lt;br /&gt;
   INTEGER, INTENT(IN) :: EXPECTED&lt;br /&gt;
   INTEGER, INTENT(IN) :: ARRAYSIZE&lt;br /&gt;
   LOGICAL             :: CHECK_DIMENSION&lt;br /&gt;
&lt;br /&gt;
   CHECK_DIMENSION=.FALSE.&lt;br /&gt;
&lt;br /&gt;
   IF (MODULO(ARRAYSIZE, EXPECTED) == 0) THEN&lt;br /&gt;
      CHECK_DIMENSION=.TRUE.&lt;br /&gt;
   ENDIF&lt;br /&gt;
END FUNCTION&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--[[User:Csw34|Csw34]] 17:25, 14 April 2014 (UTC)&lt;/div&gt;</summary>
		<author><name>Adk44</name></author>
	</entry>
</feed>