1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> 2 3<!--Converted with LaTeX2HTML 2018.3 (Released July 19, 2018) --> 4<HTML lang="EN"> 5<HEAD> 6<TITLE>assert, assert_alloc, assert_directory_present, assert_present, fatal_error</TITLE> 7<META NAME="description" CONTENT="assert, assert_alloc, assert_directory_present, assert_present, fatal_error"> 8<META NAME="keywords" CONTENT="subroutines"> 9<META NAME="resource-type" CONTENT="document"> 10<META NAME="distribution" CONTENT="global"> 11 12<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> 13<META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0"> 14<META NAME="Generator" CONTENT="LaTeX2HTML v2018.3"> 15 <link rel='apple-touch-icon' sizes='180x180' href='images/favicons/apple-touch-icon.png?v=2017'> 16 <link rel='icon' type='image/png' sizes='32x32' href='images/favicons/favicon-32x32.png?v=2017'> 17 <link rel='icon' type='image/png' sizes='16x16' href='images/favicons/favicon-16x16.png?v=2017'> 18 <link rel='manifest' href='images/favicons/manifest.json?v=2017'> 19 <link rel='mask-icon' href='images/favicons/safari-pinned-tab.svg?v=2017' color='#5bbad5'> 20 <link rel='shortcut icon' href='images/favicons/favicon.ico?v=2017'> 21 <meta name='apple-mobile-web-app-title' content='HEALPix'> 22 <meta name='application-name' content='HEALPix'> 23 <meta name='msapplication-config' content='images/favicons/browserconfig.xml?v=2017'> 24 <meta name='theme-color' content='#ffffff'> 25 26<LINK REL="STYLESHEET" HREF="subroutines.css"> 27 28<LINK REL="next" HREF="sub_brag_openmp.htm"> 29<LINK REL="previous" HREF="sub_apply_mask.htm"> 30<LINK REL="next" HREF="sub_brag_openmp.htm"> 31</HEAD> 32 33<body text="#000000" bgcolor="#FFFFFA"> 34 35<DIV CLASS="navigation"><!--Navigation Panel--> 36<A 37 HREF="sub_apply_mask.htm"> 38<IMG WIDTH="63" HEIGHT="24" ALT="previous" SRC="prev.png"></A> 39<A 40 HREF="sub_HEALPix_F90_subroutines.htm"> 41<IMG WIDTH="26" HEIGHT="24" ALT="up" SRC="up.png"></A> 42<A 43 HREF="sub_brag_openmp.htm"> 44<IMG WIDTH="37" HEIGHT="24" ALT="next" SRC="next.png"></A> 45<A ID="tex2html324" 46 HREF="sub_TABLE_CONTENTS.htm"> 47<IMG WIDTH="65" HEIGHT="24" ALT="contents" SRC="contents.png"></A> 48<BR> 49<B> Previous:</B> <A 50 HREF="sub_apply_mask.htm">apply_mask</A> 51 52<B>Up:</B> <A 53 HREF="sub_HEALPix_F90_subroutines.htm">HEALPix/F90 subroutines</A> 54 55<B> Next:</B> <A 56 HREF="sub_brag_openmp.htm">brag_openmp</A> 57<B> Top:</B> <a href="main.htm">Main Page</a></DIV> 58<!--End of Navigation Panel--> 59 60<H1><A ID="SECTION1600"></A> 61<A ID="sub:assert"></A> 62<BR> 63 64</H1> 65 66<P> 67<b><font size=+6><FONT COLOR="#CC0000">assert,assert_alloc, assert_directory_present, <SPAN CLASS="MATH"><IMG STYLE="height: 0.23ex; vertical-align: -0.10ex; " SRC="sub_img9.png" 68 ALT="$\ldots$"></SPAN></FONT></font></b><hr> 69<H3>The Fortran90 module misc_utils contains a few routines to test an assertion and return an error 70 message if it is false.</H3> 71Location in HEALPix directory tree: <a href="https://sourceforge.net/p/healpix/code/1005/tree/trunk/src/f90/mod/misc_utils.F90"><b>src/f90/mod/misc_utils.F90</b></a> 72 73<P> 74 75<BIG CLASS="LARGE"><SPAN CLASS="textbf">SUBROUTINES: </SPAN></BIG> 76<BR> 77<TT>call assert(test [, msg, errcode])</TT> 78 79<P> 80<TABLE CELLPADDING=3> 81<TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 82<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=350>if <TT>test</TT> is true, proceeds with normal code execution. If 83 <TT>test</TT> is false, issues a standard error message 84 (unless <TT>msg</TT> is provided) and stops the code execution with the status 85 <TT>errcode</TT> (or 1 by default).</TD> 86<TD ALIGN="LEFT"> </TD></TR> 87</TABLE> 88<BR> 89<P> 90<TT>call assert_alloc(status, code, array)</TT> 91 92<P> 93<TABLE CELLPADDING=3> 94<TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 95<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=350>if <TT>status</TT> is 0, proceeds with normal code execution. If 96 not, issues an error message indicating a problem during memory allocation 97 of 98 <TT>array</TT> in program <TT>code</TT>, and stops the code execution.</TD> 99<TD ALIGN="LEFT"> </TD></TR> 100</TABLE> 101<BR> 102<P> 103<TT>call assert_directory_present(directory)</TT> 104 105<P> 106<TABLE CELLPADDING=3> 107<TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 108<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=350>issues an error message and stops the code execution if 109 the directory named <TT>directory</TT> can not be found</TD> 110<TD ALIGN="LEFT"> </TD></TR> 111</TABLE> 112<BR> 113<P> 114<TT>call assert_not_present(filename)</TT> 115 116<P> 117<TABLE CELLPADDING=3> 118<TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 119<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=350>issues an error message and stops the code execution if 120 a file with name <TT>filename</TT> already exists.</TD> 121<TD ALIGN="LEFT"> </TD></TR> 122</TABLE> 123<BR> 124<P> 125<TT>call assert_present(filename)</TT> 126 127<P> 128<TABLE CELLPADDING=3> 129<TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 130<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=350>issues an error message and stops the code execution if 131 the file named <TT>filename</TT> can not be found.</TD> 132<TD ALIGN="LEFT"> </TD></TR> 133</TABLE> 134<BR> 135<P> 136<TT>call fatal_error([msg])</TT> 137 138<P> 139<TT>call fatal_error</TT> 140 141<P> 142<TABLE CELLPADDING=3> 143<TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 144<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=350>issue an (optional user defined) error message and stop the code execution.</TD> 145<TD ALIGN="LEFT"> </TD></TR> 146</TABLE> 147<BR> 148<P> 149<P> 150<hr><H1>ARGUMENTS</H1> 151 152<TABLE CELLPADDING=3 BORDER="1"> 153<TR><TH ALIGN="LEFT" VALIGN="TOP" WIDTH=150><SPAN CLASS="textbf">name & dimensionality</SPAN></TH> 154<TH ALIGN="LEFT" VALIGN="TOP" WIDTH=25><SPAN CLASS="textbf">kind</SPAN></TH> 155<TH ALIGN="LEFT" VALIGN="TOP" WIDTH=40><SPAN CLASS="textbf">in/out</SPAN></TH> 156<TH ALIGN="LEFT" VALIGN="TOP" WIDTH=235><SPAN CLASS="textbf">description</SPAN></TH> 157</TR> 158<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> </TD> 159<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25> </TD> 160<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40> </TD> 161<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235> </TD> 162</TR> 163<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150> 164test</TD> 165<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>LGT</TD> 166<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 167<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>result of a logical test</TD> 168</TR> 169<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>msg OPTIONAL</TD> 170<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>CHR</TD> 171<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 172<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>character string describing nature of error</TD> 173</TR> 174<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>errorcode OPTIONAL</TD> 175<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>I4B</TD> 176<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 177<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>error status given to code interruption</TD> 178</TR> 179<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>status</TD> 180<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>I4B</TD> 181<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 182<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>value of the <TT>stat</TT> flag returned by the F90 <TT>allocate</TT> command</TD> 183</TR> 184<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>code</TD> 185<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>CHR</TD> 186<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 187<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>name of program or code in which allocation is made</TD> 188</TR> 189<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>array</TD> 190<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>CHR</TD> 191<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 192<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>name of array allocated</TD> 193</TR> 194<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>directory</TD> 195<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>CHR</TD> 196<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 197<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>directory name (contains a '/')</TD> 198</TR> 199<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=150>filename</TD> 200<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=25>CHR</TD> 201<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=40>IN</TD> 202<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=235>file name</TD> 203</TR> 204</TABLE> 205 206<P> 207<HR><H1>EXAMPLE:</H1> 208<tt>program my_code 209<BR> 210use misc_utils 211<BR> 212real, allocatable, dimension(:) :: vector 213<BR> 214integer :: status 215<BR> 216real :: a = -1. 217<BR> 218<BR> 219allocate(vector(12345),stat=status) 220<BR> 221call assert_alloc(status, 'my_code', 'vector') 222<BR> 223<BR> 224call assert_directory_present('/home') 225<BR> 226<BR> 227call assert(a > 0., 'a is NEGATIVE !!!') 228<BR> 229<BR> 230end program my_code 231<BR></tt> 232<blockquote> Will issue a error message and stops the code if <TT>vector</TT> can not be allocated, will stop the 233 code if '/home' is not found, and will stop the code and complain loudly about it 234because <TT>a</TT> is actually negative. 235</blockquote> 236 237<P> 238 239<P> 240 241 242<P> 243 244<P> 245 246<DIV CLASS="navigation"><HR> 247<!--Navigation Panel--> 248<A 249 HREF="sub_apply_mask.htm"> 250<IMG WIDTH="63" HEIGHT="24" ALT="previous" SRC="prev.png"></A> 251<A 252 HREF="sub_HEALPix_F90_subroutines.htm"> 253<IMG WIDTH="26" HEIGHT="24" ALT="up" SRC="up.png"></A> 254<A 255 HREF="sub_brag_openmp.htm"> 256<IMG WIDTH="37" HEIGHT="24" ALT="next" SRC="next.png"></A> 257<A ID="tex2html324" 258 HREF="sub_TABLE_CONTENTS.htm"> 259<IMG WIDTH="65" HEIGHT="24" ALT="contents" SRC="contents.png"></A> 260<BR> 261<B> Previous:</B> <A 262 HREF="sub_apply_mask.htm">apply_mask</A> 263 264<B>Up:</B> <A 265 HREF="sub_HEALPix_F90_subroutines.htm">HEALPix/F90 subroutines</A> 266 267<B> Next:</B> <A 268 HREF="sub_brag_openmp.htm">brag_openmp</A> 269<B> Top:</B> <a href="main.htm">Main Page</a></DIV> 270<!--End of Navigation Panel--> 271<ADDRESS> 272Version 3.50, 2018-12-10 273</ADDRESS> 274</BODY> 275</HTML> 276