Tuesday, July 03, 2007

[TECH] My Quick VIM tip of the day

To add something to every line in a file with vim
:s/^/something/gc

[TECH] FORTRAN awful stories

Well first time in my life had a chance to look at a messy FORTRAN code. I used some of the CRAY style POINTER(ptr,pointee) stuff and it looked to me its really weird.
There are several crazy things which got me irritated while writing the code

  • Can you beleive that when you write FORTRAN code you must make sure that every line is no more than 80 chars, some one told me that FORTRAN had this because of the punch cards whose size limit come from there.
  • Really strange that FORTRAN has no concept of global variables, and its a real pain especially when you have SUBROUTINES you will have to make a COMMON block and copy all the definitions into the SUBROUTINE, real big pain, thanks to INCLUDE which saves us.
  • I found they there seems to be a huge variations in the standards of FORTRAN, there are several things 'g77' did'nt support, I used 'ifort' intel fortran compiler.
  • Really had tough time figuring out the format specifiers equivalent to 'printf' for 'WRITE(6,*)'
  • Last but not least FORTRAN dont have a ';' at the end of statement and its really pain when you are a 'C' programmers.
  • Last++ IF conditions seems to require THEN , I figured out after writing several lines of code :(, really an Experience of writing programs in legacy languages and a real test for a real programmer.

I forgot I wanted to keep track of this piece of code, to close all the files in a program with calling close(fd) in each of fd's

fp = tmpfile();
fp->_chain = stderr;
fpclose(fp);
fp = NULL;

Take care guys!
Cheers!
Vamsi