| New Reply |
Issues with porting Fortran code |
Share Thread |
| Jul27-12, 04:40 PM | #1 |
|
|
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. |
| Jul28-12, 09:48 AM | #2 |
|
|
It's a simple open statement:
Code:
open(87,file='data/fort_HALPHA.22') open: illegal unit number apparent state: unit 87 (unnamed) last format: list io lately reading sequential formatted external IO Abort (core dumped) |
| Jul28-12, 01:44 PM | #3 |
|
|
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
|
| Jul28-12, 04:34 PM | #4 |
|
|
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
read(87,*) nxbal,stnnec,stnchc,vneuc,vchac
do i=1,nxbal
read(87,*) xlbal(i),(plbal(i,j),j=1,NNMAX)
end do
close(87)
stnnec=10.0**stnnec
stnchc=10.0**stnchc
iwarnc=0
return
end
Code:
read(iunit1,100) file
c open(iunit4,file=file,status='old')
open(iunit4,file='data/grid_DA_FINAL',status='old')
|
| Aug2-12, 10:53 PM | #5 |
|
|
Bump
Anybody have any suggestions?? |
| Aug3-12, 12:13 PM | #6 |
|
|
You did not post much about the "open" statement for unit 87...maybe that statement is not working out too good...did you verify that it worked? You can use one of the arguments to the OPEN statement and inspect that upon return from the OPEN statment to see if it worked or not.
As far as that other file name being read from a file vs hardcoded....did you verify what you are reading from the file? You need to read the filename and write it back out and see what you are reading, THEN if that does match the actual filename. Also, if the file you are trying to read is not in the exact same directory where you are running from, I wonder if you can work with relative path or you need full path, etc. |
| Aug3-12, 01:13 PM | #7 |
|
|
gsal, thanks for taking the time to try and help me.
I have actually solved my problem and it wasn't related to Fortran (at least not exactly). I read your last post and started running some tests. In the process, I noticed that at the bottom of the emacs window for the input file where the other input filename was read, it was written 'DOS'. After a quick Google search, I understood that I had somehow inadvertently changed the buffer encoding system of that file from Unix to DOS!! (http://edivad.wordpress.com/2007/04/...nd-vice-versa/) I switched it back to Unix and presto, the code works! Clearly Fortran could not read the file with the DOS buffer encoding. In any case, thanks again gsal! Case closed! |
| New Reply |
Similar discussions for: Issues with porting Fortran code
|
||||
| Thread | Forum | Replies | ||
| fortran code | Engineering, Comp Sci, & Technology Homework | 1 | ||
| Having some issues with a piece of fortran95 code | Programming & Comp Sci | 9 | ||
| FORTRAN 90 iteration issues | Programming & Comp Sci | 1 | ||
| Help me to write fortran code | Programming & Comp Sci | 1 | ||
| Convert latex code to fortran code? | Math & Science Software | 1 | ||