home *** CD-ROM | disk | FTP | other *** search
- /*
- * Support functions for FORTRAN interface to Hippo
- * by Paul Kunz, SLAC, June 1991
-
- * Copyright (C) 1991 The Board of Trustees of
- * The Leland Stanford Junior University. All Rights Reserved.
- *
- * $Id: fhippo.c,v 1.5 1992/01/24 02:31:42 pavel Rel $
- *
- * This set of functions is the second level interface between the
- * FORTRAN user and the Hippo package which is written in C.
- * All the functions the user sees are in FORTRAN and defined in
- * hippof.f. At this level, one has C functions to support that
- * FORTRAN. System dependencies on how to make C callable from
- * FORTRAN will be found here. Each function has two versions,
- * for example, with and with out a trailing '_' because some
- * FORTRAN compilers adds the underscore and it can not be turned
- * off.
- *
- * Report bugs to hippo_bug@ebnextk.slac.stanford.edu
- *
- */
-
- #include <stdlib.h>
- #include <string.h>
- #include "hippo.h"
-
- #ifdef VMS
- /* Special stuff to deal with descriptors in VMS Fortran: */
- #include descrip
- #endif /* VMS */
-
- /*
- * Interfaces to h_arrayFill() from hparrayFill()
- */
- int hfarrayfill( int *ntaddr, float *data )
- {
- return h_arrayFill( (ntuple) *ntaddr, data );
- }
- int hfarrayfill_( int *ntaddr, float *data)
- {
- return hfarrayfill( ntaddr, data );
- }
-
- /*
- * Interfaces to h_clrNt() from hpclrNt()
- */
- int hfclrnt( int *ntaddr )
- {
- return h_clrNt( (ntuple) *ntaddr );
- }
- int hfclrnt_( int *ntaddr )
- {
- return hfclrnt( ntaddr );
- }
-
- /*
- * Interfaces to h_freeNt() from hpfreeNt()
- */
- int hffreent( int *ntaddr )
- {
- return h_freeNt( (ntuple) *ntaddr );
- }
- int hffreent_( int *ntaddr )
- {
- return hffreent( ntaddr );
- }
-
- /*
- * Interfaces to h_new() from hpnew()
- */
- ntuple hfnew( int *ndim )
- {
- return h_new( *ndim);
- }
- ntuple hfnew_( int *ndim )
- {
- return hfnew( ndim );
- }
-
- /*
- * Interfaces to h_setNtLabel() from hpsetNtLabel()
- */
- #ifndef VMS
- int hfsetntlabel( int *ntaddr, int *dim, char *label, int *lenchar )
- #else
- int hfsetntlabel( int *ntaddr, int *dim, struct dsc$descriptor *label_d,
- int *lenchar )
- #endif /* VMS */
- {
- char *name;
- int i, len, ret_val;
-
- len = *lenchar;
- name = (char *)malloc( (len+1)*sizeof(char) );
- #ifndef VMS
- strncpy(name, label, len);
- #else
- strncpy(name, label_d->dsc$a_pointer, len);
- #endif /* VMS */
-
- /* Trim the trailing blanks */
- for ( i = (len-1); i >= 0; i-- ) {
- if ( name[i] != ' ' ) {
- name[i+1] = '\0';
- break;
- }
- }
- ret_val = h_setNtLabel( (ntuple) *ntaddr, *dim, name);
-
- free(name);
- return ret_val;
- }
-
- int hfsetntlabel_( int *ntaddr, int *dim, char *label, int *lenchar )
- {
- return hfsetntlabel( ntaddr, dim, label, lenchar );
- }
-
-
- /*
- * Interfaces to h_setNtTitle() from hpsetNtTitle()
- */
- #ifndef VMS
- int hfsetnttitle( int *ntaddr, char *title, int *lenchar )
- #else
- int hfsetnttitle( int *ntaddr, struct dsc$descriptor *title_d, int *lenchar )
- #endif /* VMS */
- {
- char *name;
- int i, len, ret_val;
-
- len = *lenchar;
- name = (char *)malloc( (len+1)*sizeof(char) );
- #ifndef VMS
- strncpy(name, title, len );
- #else
- strncpy(name, title_d->dsc$a_pointer, len);
- #endif /* VMS */
-
- /* Trim the trailing blanks */
- for ( i = (len-1); i >= 0; i-- ) {
- if ( name[i] != ' ' ) {
- name[i+1] = '\0';
- break;
- }
- }
-
- ret_val = h_setNtTitle( (ntuple) *ntaddr, name);
-
- free(name);
- return ret_val;
- }
- int hfsetnttitle_( int *ntaddr, char *title, int *lenchar )
- {
- return hfsetnttitle( ntaddr, title, lenchar );
- }
-
-
-
- /*
- * Interfaces to h_write() from hpwrite()
- */
- #ifndef VMS
- int hfwrite( char *filename, int *daddr, int *ntaddr, int *lenchar )
- #else
- int hfwrite( struct dsc$descriptor *filename_d, int *daddr, int *ntaddr,
- int *lenchar )
- #endif /* VMS */
- {
- char *name;
- int i, len, ret_val;
-
- len = *lenchar;
- name = (char *) malloc( (len+1)*sizeof(char) );
- #ifndef VMS
- strncpy( name, filename, len );
- #else
- strncpy( name, filename_d->dsc$a_pointer, len);
- #endif /* VMS */
-
- /* Trim the trailing blanks */
- for ( i = (len-1); i >= 0; i-- ) {
- if ( name[i] != ' ' ) {
- name[i+1] = '\0';
- break;
- }
- }
-
- ret_val = h_write(name, (display *) daddr, (ntuple *) ntaddr );
-
- free(name);
- return ret_val;
- }
- int hfwrite_( char *filename, int *daddr, int *ntaddr, int *lenchar )
- {
- return hfwrite( filename, daddr, ntaddr, lenchar );
- }
-
-