## Issues with porting Fortran code

I have a Fortran (F77) code which I used to use at my previous institution that I am having trouble with at my new job. I used to compile it with ifort on computers running Fedora (14 if I recall correctly). At my new job they don't have ifort so I have had to revert to the use of g77 (f77) on systems running Red Hat.

It took awhile, and a little help, to figure out that one of my codes would compile but crash once executed because g77 didn't automatically initialize all variables to zero. Luckily switches do exist to make g77 do this and I thought I was home free. This week, I tried running what is essentially the same code, but I get an ''illegal unit number error" when opening a file. I have Googled extensively to both understand the problem and find a solution but have ultimately been unsuccessful. I know illegal unit numbers can come from choosing things out of the range of 0 to 99, but in this case the unit number in question is 87!! Furthermore, the other code I had trouble with previously includes the exact same subroutine where that file is opened and it doesn't cause a problem!!!

Any and all suggestions are useful. Please let me know if I can supply any additional information that might help pinpoint the problem.

Thanks.
 PhysOrg.com science news on PhysOrg.com >> Galaxies fed by funnels of fuel>> The better to see you with: Scientists build record-setting metamaterial flat lens>> Google eyes emerging markets networks
 It's a simple open statement: Code:  open(87,file='data/fort_HALPHA.22') And yes I have tried adding a status='old' statement but I get the same error which is as follows: open: illegal unit number apparent state: unit 87 (unnamed) last format: list io lately reading sequential formatted external IO Abort (core dumped)
 Maybe the problem is not when opening the file...looks like that already worked...maybe the problem is at some reading statement somewhrw else where somehow the unit number is not correct. Is the code long? May want to post it

## Issues with porting Fortran code

The whole code is quite long, here is the portion where the file is read(it coincides with the end of the subroutine):

Code:
      nxbal=0
do i=1,nxbal
end do
close(87)
stnnec=10.0**stnnec
stnchc=10.0**stnchc
iwarnc=0
return
end
There is also a related issue that I didn't mention in my first post because I found a way to solve it even though it shouldn't be a problem at all. There is an input file that the code cannot find (''file not found'' type of error). The name of the input file is read as a string in another input file. However, if I hardcode the filename in the open command, then there is no problem. The relevant code for that follows:

Code:

open(iunit4,file='data/grid_DA_FINAL',status='old')