Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001, Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 00038 #pragma ident "@(#) libf/fio/length.c 92.1 06/21/99 10:37:21" 00039 #include <foreign.h> 00040 #include <fortran.h> 00041 #include <liberrno.h> 00042 #include <sys/param.h> 00043 #include <errno.h> 00044 #include "fio.h" 00045 00046 /* 00047 * _LENGTH_ 00048 * 00049 * Intrinsic LENGTH function returns the amount of data 00050 * transferred by the preceding BUFFER IN or BUFFER OUT request. 00051 * 00052 * Return Value 00053 * 00054 * The size in words of the preceding BUFFER IN/OUT statement. 00055 * Partial words are counted. 00056 * 00057 * Returns 0 if of an end-of-file or an error occurs, or after a 00058 * read or write of a zero-length record. 00059 * 00060 * Undocumented feature: S2 is assigned on exit the 00061 * "unused bit count". This is the number of bits untransferred 00062 * in the last word of the previous I/O request. 00063 * 00064 * Define duplicate entry points 00065 * 00066 * _LENGTH_ - if user declares it INTRINSIC with CF90 00067 * LENGTH - if user declaris it EXTERNAL or CALL's it 00068 * $LENGTH - if user declares it INTRINSIC with CF77 00069 * _LENGTH - if user declares it INTRINSIC with CF77 6.0.0.3 or 00070 * previous on the T3D (obsolete) 00071 */ 00072 #ifdef _UNICOS 00073 #pragma _CRI duplicate _LENGTH_ as LENGTH 00074 #pragma _CRI duplicate _LENGTH_ as $LENGTH 00075 #ifdef _CRAYMPP 00076 #pragma _CRI duplicate _LENGTH_ as _LENGTH 00077 #endif 00078 #endif /* _UNICOS */ 00079 00080 _f_int 00081 _LENGTH_(_f_int *unump) 00082 { 00083 unum_t unum; 00084 unit *cup; 00085 int ret, s2ret; 00086 struct fiostate cfs; 00087 00088 unum = *unump; 00089 00090 STMT_BEGIN(unum, 0, T_LENGTH, NULL, &cfs, cup); /* lock the unit */ 00091 /* 00092 * If not connected, do an implicit open. Abort if the open fails. 00093 */ 00094 if (cup == NULL) 00095 cup = _imp_open(&cfs, SEQ, UNF, unum, 0, NULL); 00096 00097 WAITIO(cup, { cup->uerr = 1; } ); /* await outstanding I/O */ 00098 00099 if (cup->uerr) { 00100 ret = 0; 00101 s2ret = 0; 00102 } 00103 else { 00104 ret = (cup->ulrecl + BITS_PER_WORD - 1) / BITS_PER_WORD; 00105 s2ret = (ret * BITS_PER_WORD) - cup->ulrecl; 00106 } 00107 00108 STMT_END(cup, T_LENGTH, NULL, &cfs); /* unlock the unit */ 00109 00110 #ifdef _CRAY1 00111 (void) _sets2(s2ret); 00112 #endif 00113 00114 return( (_f_int) ret); 00115 }