"Fossies" - the Fresh Open Source Software Archive

Member "netcdf-fortran-4.4.5/nf03_test/f03lib.c" (31 Jan 2019, 1863 Bytes) of package /linux/misc/netcdf-fortran-4.4.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * $Id: fort03.c,v 1.9 2007/07/28 13:14:00 rick Exp $
    3  *
    4  * This file contains support functions for FORTRAN code.  For example,
    5  * under HP-UX A.09.05, the U77 library doesn't contain the exit()
    6  * routine -- so we create one here.
    7  */
    8 
    9 /*
   10    Modified fortlib.c - We remove all cfortran.h stuff to make 
   11    compiling easier. Also functions are modified to be extern
   12    and not static so FORTRAN can see them
   13 
   14    Version 1. July  2007 first vesion 
   15    Version 2. April 2009 - modified for netCDF 4.0.1
   16       
   17    Modified by: Richard Weed, Ph.D
   18    Center for Advanced Vehicular Systems
   19    Misssissippi State University
   20    rweed@.cavs.msstate.edu
   21 */
   22 
   23 #include <stdlib.h>
   24 #include <limits.h>
   25 #include <float.h>
   26 
   27 
   28 extern double
   29 myrand(int iflag)
   30 {
   31     if (iflag != 0)
   32     srand(iflag);
   33 
   34     /*
   35      * Return a pseudo-random value between 0.0 and 1.0.
   36      *
   37      * We don't use RAND_MAX here because not all compilation
   38      * environments define it (e.g. gcc(1) under SunOS 4.1.3).
   39      */
   40     return (rand() % 32768) / 32767.0;
   41 }
   42 
   43 
   44 extern int
   45 myshift(int value, int amount)
   46 {
   47     if (amount < 0)
   48     value >>= -amount;
   49     else
   50     if (amount > 0)
   51     value <<= amount;
   52     return value;
   53 }
   54 
   55 #include <signal.h>
   56 extern void
   57 nc_ignorefpe(int doit)
   58 {
   59     if(doit)
   60         (void) signal(SIGFPE, SIG_IGN);
   61 }
   62 
   63 extern double cmax_uchar()
   64 {
   65     return UCHAR_MAX;
   66 }
   67 
   68 extern double cmin_schar()
   69 {
   70     return SCHAR_MIN;
   71 }
   72 
   73 extern double cmax_schar()
   74 {
   75     return SCHAR_MAX;
   76 }
   77 
   78 extern double cmin_short()
   79 {
   80     return SHRT_MIN;
   81 }
   82 
   83 extern double cmax_short()
   84 {
   85     return SHRT_MAX;
   86 }
   87 
   88 extern double cmin_int()
   89 {
   90     return INT_MIN;
   91 }
   92 
   93 extern double cmax_int()
   94 {
   95     return INT_MAX;
   96 }
   97 
   98 extern double cmin_long()
   99 {
  100     return LONG_MIN;
  101 }
  102 
  103 extern double cmax_long()
  104 {
  105     return LONG_MAX;
  106 }
  107 
  108 extern double cmax_float()
  109 {
  110     return FLT_MAX;
  111 }
  112 
  113 extern double cmax_double()
  114 {
  115     return DBL_MAX;
  116 }