- #1
solarblast
- 152
- 2
Win 7 MinGW compilers.
I have a txt file that has empty lines that I'd like to pass by when reading them. Each line is assumed to be 85 characters. Here's a snippet of code:
Open(unit=astro_in, file="METEOR_LegacyInputToNML.txt", status = "OLD")
do while(.True.)
Read(unit=astro_in, fmt="(a85)", iostat=eof) card ! Read file card)
if ( (card(1:5) == 'GROUP') ) then
Write(*,*) "crd:",card
else if (card(1:3) == 'EOD') then
exit
else if (len(card) == 0) then
Write(*,*) "Blank", card
end if
len(card) is always 85 even if I have a line devoid of characters. len(card) is always seeing 85. How do I determine if a line is blank? Here's a few lines of the file.
GROUP Station #01 CARDS 02 fmt 501
# Station data
# ---R---|---PHIP--|---PHI---|--RLONG--|---TP----|-BN|--FL--|-STAHGT-|--COBS-|
# f10.4 f10.8 f10.8 f10.8 f10.7 f4.0 f7.3 f9.4 a8
6364.1543 .95003538 .953223371.97825229 .100000 6.203.200 00.6480MEANOK A
6364.2581 .94493380 .948132841.97141644 .100000 6.203.200 00.6721NEWBROOK B
GROUP MetTime #02 CARDS 01 fmt 502
# Time of meteor obs, no. obs per station, ... for each station
#H|MM|--SS--|----XJDM----|-NM|-NM|-NS|-NS|METNO|not input
# 2f3.0 F7.3 F13.5 I4 I4 I4 I4 A6 A6
2 12 13.0002435400.82885 40 39 1045MEANOK R2-1
GROUP SolarHz #03 CARDS 06 fmt 503
Maybe the file needs to be DAT??
I have a txt file that has empty lines that I'd like to pass by when reading them. Each line is assumed to be 85 characters. Here's a snippet of code:
Open(unit=astro_in, file="METEOR_LegacyInputToNML.txt", status = "OLD")
do while(.True.)
Read(unit=astro_in, fmt="(a85)", iostat=eof) card ! Read file card)
if ( (card(1:5) == 'GROUP') ) then
Write(*,*) "crd:",card
else if (card(1:3) == 'EOD') then
exit
else if (len(card) == 0) then
Write(*,*) "Blank", card
end if
len(card) is always 85 even if I have a line devoid of characters. len(card) is always seeing 85. How do I determine if a line is blank? Here's a few lines of the file.
GROUP Station #01 CARDS 02 fmt 501
# Station data
# ---R---|---PHIP--|---PHI---|--RLONG--|---TP----|-BN|--FL--|-STAHGT-|--COBS-|
# f10.4 f10.8 f10.8 f10.8 f10.7 f4.0 f7.3 f9.4 a8
6364.1543 .95003538 .953223371.97825229 .100000 6.203.200 00.6480MEANOK A
6364.2581 .94493380 .948132841.97141644 .100000 6.203.200 00.6721NEWBROOK B
GROUP MetTime #02 CARDS 01 fmt 502
# Time of meteor obs, no. obs per station, ... for each station
#H|MM|--SS--|----XJDM----|-NM|-NM|-NS|-NS|METNO|not input
# 2f3.0 F7.3 F13.5 I4 I4 I4 I4 A6 A6
2 12 13.0002435400.82885 40 39 1045MEANOK R2-1
GROUP SolarHz #03 CARDS 06 fmt 503
Maybe the file needs to be DAT??