UNICOS utilities for FORTRAN/C character variable interaction
The FORTRAN CHARACTER variable descriptor holds three items of information about the variable:- The word address
- The bit offset
- The bit length
- _fcdtocp
- Is a conversion utility that converts a FORTRAN character descriptor to a C
character point.
- _fcdlen
- Extracts the length from a FORTRAN character descriptor.
- _cptofcd
- Converts a C character pointer to a FORTRAN character descriptor.
A sample C routine that requires a FORTRAN character variable as input might be:
#includewhile the FORTRAN program that calls OPENIT might look likeint fd; void OPENIT(fcd) _fcd fcd; { char *malloc(); char *cpp = _fcdtocp(fcd); unsigned len = _fcdlen(fcd); char *cp = malloc(len+1); strncpy(cp,cpp,len) cp[len] = '\0'; fd = creat(cp,6777); }
PROGRAM FRED CHARACTER FILE*20 FILE='MYDATA.DAT' CALL OPENIT(FILE) STOP END