Porting from 32-bit to 64-bit

I need to port my Fortran and C programs from 32-bits to 64-bits. For those of you that have done this before, any recommendation on what I need to watch out for? Any problems you encountered? Is there a particular methodology I should follow?

I’ve done a lot of this. The first thing to remember is that int , long char * and the like are now
64-bit pointers, not 32 bits. “long” is now sizeof(long) == 8. To keep things straight
I define a macro called LONG64 that makes 64 bit (long long for gcc and intel) ints
wherever it is used. (microsoft used __long64 :-)

The next major problem with 32-64 conversions is using casts.
an int* pointer casted to a long * (LONG64 *) pointer can reference a non-8 byte
boundary. This leads to mayhem in the CPU. some boxes will shift for you, some won’t.

Lots of system calls have 64 bit variants (fstat64, lseek64, fadvise64_64, timers…)
better use the correct one or you will be limited to 2GB of file/address space.
Be explicit in your integer variable sizes.

One word of caution… when defining a struct, put all your pointers together,
ints together, longs together…

struct foo {
char *bogus;
int * bogus2;
int *anotherone;

if you have

struct bad {
int a;
long b;
int c;
long d;

and try to walk the pointer to *bad down to each variable, you will find the compiler
MAY have inserted padding for you, and in strange places, or even re-ordered elements
within the struct! if you have to order struct elements, put explicit padding in them.

or, get an alpha running osf1, it has a porting assistant :-) :-)