Lexical error in reading a file

I have been using PG fotran in Unix for some years. Lately when I am running a program I get the following error message

PGFIO-F-225/list-directed read/unit=475/lexical error-- unknown token type.
File name = /home/mark/GEMSS/Apps/BP-DeepwaterHorizon/Cleanup/Dispersant/SubSurfaceDispData_v5.txt formatted, sequential access record = 47
In source file /home/mark/GEMSS/Srcs/COSIM/COS3D/CleanSubs2_v1.f90, at line number 284

I have been using this model for sometime. It was running ok. All of a sudden it is giving me this error message. Based on the error message, I can figure out that the input file has some characters that the program does not want to see it. But then I have not modified this input file for sometime. Only thing I have done is adding some new code. I checked the code many time so far variable mismatch etc.

I debugged the code and found out that at one line number 47, program is not able to read it. I even tried to read it a a big string to see if the program can read. Bu all I got was an empty string at line number 47.

I spent many days figureing out the problem. I need help from the fotrum


Hi Venkat,

Can you please post the code which reads the file, the open statement for this file, as well as an example of the record that it’s failing to read?


Hi Mat,
Thanks for your quick response.
I have copied the code. But the format got changed. I apologize fot that.
The line where the program fails to read is


First 5 variables are integer(4)
6,7,8 are rea(4)
9 is character(256)

Entry ActivateTVDDispAppSubSurface



SSurfaceDispMass = 0.0

SSDispRegionFileNameOld = SSDispRegionFileName

Do While(DispSSurface)

If(mdltime >= DispSSSTime .and. mdltime <= DispSSETime) Then

SSurfaceDispMass = SSDispFlowRate*dt/60.0 !gallons per min to gallons

If(SSDispRegionFileName /= SSDispRegionFileNameOld) Call ReadSSDispPolygon



If(mdltime < DispSSSTime) Return

Read(NFDispSS,*,End=992) Year,Month,Day,Hour,Minute,SSDuration,SSDispFlowRate,SSDispERatio,SSDispRegionFileName

Write(,) Year,Month,Day,Hour,Minute,SSDuration,SSDispFlowRate,SSDispERatio,SSDispRegionFileName

Write(NFlog,*) Year,Month,Day,Hour,Minute,SSDuration,SSDispFlowRate,SSDispERatio,SSDispRegionFileName

DispSSSTime = dble(DTTM2Julian(Year,Month,Day,Hour,Minute))

DispSSETime = DispSSSTime + dble(SSDuration)*1440.0d+00

End If


992 Close(NFDispSS)

DispSSurface = .False.


End Do



What happens if you remove the comma within the quotes?

I.e. change



  • Mat