English 中文(简体)
Porting sun studio compatible fortran 77 to gcc: format specifier in READ, FORMAT
原标题:

I have some old fortran 77 I m trying to port to gcc on Windows.

I m using gfortran 4.4.

The statement uses READ(FOO, (F) , ERR=BAR) BAZ and gcc is complaining about F. From what I ve seen it looks like F needs a size associated with it. There are also FORMAT statements which use a similar construct.

What is the proper way to port this? It seems like using F alone on sun studio compilers just fits to the proper size. But gfortran complains about it not being a non-negative or positive width.

Any ideas how to port this?

最佳回答

This is a formatted read. It should be READ(FOO, (FN.M) , ERR=BAR) BAZ, N and M specific numbers, where N is the field width in characters and M is the number of digits after the decimal point. On input M doesn t matter if the data has a decimal point, because the decimal point will override the format specification. If you aren t sure that the input data will always fit within this strict specification, it is probably better to switch to format-free input: READ(FOO, * , ERR=BAR) BAZ. This is also called list-directed i/o. This is very flexible and guessing, probably better matches what the extension "F" was doing. (format-free / list-directed is different from unformatted, which is for binary files without any conversion of the bits.)

问题回答

暂无回答




相关问题
How do I fix this Fortran text parser for Lapack within Gem5

After about an hour, I need to ask for some help. I ve downloaded the math benchmark Lapack to run within a few CPU configurations for the simulation tool Gem5, which lets you build X86 computers and ...

gfortran, DLL, underscore

I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention. Running dumpbin /export foo.dll gives me something like: ... 7 6 ...

Getting started with a new code in an unfamiliar language

I m starting a new project in a language I m less familiar with (FORTRAN) and am in the discovery phase. Normally reading through and figuring out code is a fairly simple task, however, this code ...

assigning values to an integer array within a Fortran module

I have a module in Fortran called QFoo. It defines a type QFooType. I want to initialize all the elements of integer array is_n to 0 and want to do it within the module. Could someone help? Thank ...

WinDbg and Intel Visual Fortran

Has anyone used WinDbg to debug an Intel Visual Fortran routine? If I have the Fortran source file that crashes with an AccViol, how can I use WinDbg to determine the line that is crashing?

converting MATLAB code to Fortran [closed]

I a medical researcher with code written in MATLAB 2009b that runs very slowly because of a self-referential loop (not sure of the programming lingo here), i.e., the results of the first iteration is ...

热门标签