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/s2uo.c 92.1 06/18/99 18:41:02" 00039 #include <fortran.h> 00040 #include <cray/fmtconv.h> 00041 #include <cray/portdefs.h> 00042 00043 #define MXBITS 64 /* Number of bits in an octal value */ 00044 #define MXDGTS 22 /* Number of digits in one octal value */ 00045 #define MXSIZE (MXDGTS + 1) /* Size of one octal value plus blank */ 00046 #define DGSIZE 3 /* Size of one octal digit (in bits) */ 00047 #define UNDP (MODEUN | MODEDP) 00048 00049 extern oc_func _S2UO; /* Interface must match oc_func prototype */ 00050 00051 /* 00052 * _S2UO() Convert Fortran integer variable to octal format. 00053 * 00054 * Entry: 00055 * value Address of logical variable 00056 * fca Address of first unpacked character 00057 * mode Address of mode bits 00058 * width Address of field width 00059 * digits Address of digits field 00060 * exp Unused 00061 * scale Unused 00062 * 00063 * Exit: 00064 * result Points to end of output field 00065 * 00066 * Note: This routine has the same parameters as S2UI, etc. in 00067 * libc. It does CRAYs implementation of the O edit 00068 * descriptor (automatically masks the field down to the 00069 * size specified by the edit descriptor and always does 00070 * leading zeroes if the digits field is not set by the 00071 * user (digits is 1 and MODE77)). It also handles double- 00072 * precision values via two calls to _s2uo if the field 00073 * width is large enough. 00074 */ 00075 00076 long * 00077 _S2UO( 00078 const void *value, 00079 long *fca, 00080 const long *mode, 00081 const long *width, 00082 const long *digits, 00083 const long *exp, 00084 const long *scale 00085 ) 00086 { 00087 int64 datum; 00088 #ifdef _F_INT4 00089 int32 datum32; 00090 #endif 00091 #if defined(_F_INT2) && defined(__mips) 00092 _f_int2 datum16; 00093 _f_int1 datum8; 00094 #endif 00095 long fd, fw, m77, nfd, *ptr; 00096 00097 fd = *digits; 00098 fw = *width; 00099 00100 #ifdef _F_INT4 00101 if ((*mode & MODEHP) != 0) 00102 datum = *(_f_int4 *)value; 00103 else 00104 #if defined(_F_INT2) && defined(__mips) 00105 if ((*mode & MODEWP) != 0) 00106 datum = *(_f_int2 *)value; 00107 else if ((*mode & MODEBP) != 0) 00108 datum = *(_f_int1 *)value; 00109 else 00110 #endif 00111 #endif 00112 { 00113 datum = *(_f_int8 *)value; 00114 } 00115 ptr = fca; 00116 m77 = (*mode & MODE77); /* Fortran 77 mode */ 00117 00118 /* Check if double-precision value and field is large enough. */ 00119 00120 if ((*mode & UNDP) == UNDP && fw > MXSIZE) { 00121 00122 if (fd == 1 && m77 != 0) 00123 fd = fw; 00124 00125 fw -= MXSIZE; 00126 nfd = fd - MXDGTS; 00127 00128 if (nfd < 0) 00129 nfd = 0; 00130 else 00131 if (nfd > fw) 00132 nfd = fw; 00133 00134 if (m77 != 0) { /* If Fortran 77 mode */ 00135 long mask, temp; 00136 00137 temp = fw * DGSIZE; 00138 mask = (temp < MXBITS) ? ((1 << temp) - 1) : ~0; 00139 datum = datum & mask; 00140 } 00141 00142 ptr = _s2uo(&datum, ptr, mode, &fw, &nfd, exp, scale); 00143 00144 datum = *((int64 *)value + 1); 00145 fw = MXSIZE; 00146 00147 if (fd > MXDGTS) 00148 fd = MXDGTS; 00149 } 00150 else 00151 if (fd == 1 && m77 != 0) 00152 fd = (fw > MXDGTS) ? MXDGTS : fw; 00153 00154 if (m77 != 0) { /* If Fortran 77 mode */ 00155 long mask, temp; 00156 00157 temp = fw * DGSIZE; 00158 mask = (temp < MXBITS) ? ((1 << temp) - 1) : ~0; 00159 datum = datum & mask; 00160 } 00161 00162 #ifdef _F_INT4 00163 if ((*mode & MODEHP) != 0) { 00164 datum32 = datum; 00165 value = &datum32; 00166 } 00167 else 00168 #if defined(_F_INT2) && defined(__mips) 00169 if ((*mode & MODEWP) != 0) { 00170 datum16 = datum; 00171 value = &datum16; 00172 } 00173 else if ((*mode & MODEBP) != 0){ 00174 datum8 = datum; 00175 value = &datum8; 00176 } 00177 else 00178 #endif 00179 #endif 00180 value = &datum; 00181 00182 return( _s2uo(value, ptr, mode, &fw, &fd, exp, scale) ); 00183 }