It's quite common in C-code to see stuff like:
which will return a pointer to a block of memory big enough to hold 100 ints. Is there any equivalent in fortran?
I have a binary file which is opened as:
I know that the file contains "records" which consist of a header with 20 integers, 20 real numbers and 80 characters, then another
N real numbers. Each file can have hundreds of records. Basically, I'd like to read or write to a particular record in this file (assuming
N is a fixed constant for simplicity).
I can easily calculate the position in the file I want to write if I know the size of each data-type:
header_size = SIZEOF_INT*20 + SIZEOF_FLOAT*20 + SIZEOF_CHAR*80 data_size = N*SIZEOF_FLOAT position = (record_num-1)*(header_size+data_size)+1
Currently I have
!Hardcoded :-( SIZEOF_INT = 4 SIZEOF_FLOAT = 4 SIZEOF_DOUBLE = 8 SIZEOF_CHAR = 1
Is there any way to do better?
- The code is meant to be run on a variety of platforms with a variety of compilers. A standard compliant solution is definitely preferred.