For Programmers: Free Programming Magazines  


Home > Archive > Fortran > September 2005 > WRITE-- FORMAT question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author WRITE-- FORMAT question
prasad413in@gmail.com

2005-09-28, 3:58 am

Hello,
I am trying to Write an text file as output. It should be in this
Format

:Product: Qaanaaq_iono.txt
:Issued: 2005 Sep 28 0625 UTC
# Prepared by the U.S. Dept. of Commerce, NOAA, Space Environment
Center.
# Please send comments and suggestions to sec.webmaster@noaa.gov
#
# Units for foF2, MUF(D), foEs, foE, fMUF, foF1, fxI & fbEs = MHz
# Units for yF2, D, hmE, h'F, h' & hmF2 = km
# Units for TEC = 10^16 el/m^2
# Missing data: -1.0,-1,-1.00
#
# Real-Time Ionosonde Data
# Qaanaaq N77E290 AFRL-DGS-256
#
# UT Date Time
# YR MO DA HHMM foF2 hmF2 M(D) D h'F yF2 fMUF h' fxI foF1 foE
hmE foEs fbEs ITEC
#-------------------------------------------------------------------------------------------
2005 09 27 0000 4.7 -1 2.89 3000 225 83 4.4 400 5.9 -1.0 -1.0
-1 3.2 -1.0 5.2
2005 09 27 0008 4.4 -1 2.91 3000 230 78 4.3 425 5.8 -1.0 -1.0
-1 2.9 -1.0 4.1
2005 09 27 0015 4.4 -1 2.83 3000 245 95 4.1 410 5.9 -1.0 -1.0
-1 3.4 -1.0 5.0
2005 09 27 0030 4.1 -1 3.08 3000 245 66 4.0 385 5.7 -1.0 -1.0
-1 2.8 -1.0 3.1
2005 09 27 0045 4.4 -1 2.71 3000 225 104 4.2 460 6.0 -1.0 -1.0
-1 2.8 -1.0 5.4
2005 09 27 0100 4.2 -1 2.85 3000 240 106 3.5 335 5.8 -1.0 -1.0
-1 3.3 -1.0 5.0
2005 09 27 0115 3.9 -1 2.99 3000 232 77 3.7 385 5.0 -1.0 -1.0
-1 2.9 -1.0 3.1
2005 09 27 0130 3.9 -1 2.98 3000 230 78 3.1 285 5.8 -1.0 -1.0
-1 3.4 -1.0 3.1
2005 09 27 0145 4.4 -1 3.09 3000 245 70 4.0 340 5.8 -1.0 -1.0
-1 4.4 -1.0 3.7
2005 09 27 0200 4.3 -1 2.44 3000 250 135 3.9 500 6.1 -1.0 -1.0
-1 2.8 -1.0 6.6
2005 09 27 0215 4.4 -1 2.97 3000 245 105 3.3 260 5.9 -1.0 -1.0
-1 2.7 -1.0 5.5
2005 09 27 0230 4.4 -1 2.90 3000 224 81 4.1 395 5.8 -1.0 -1.0
-1 3.5 -1.0 4.2


I wrote this simple WRITE Fornmat

OPEN (204, FILE= IONO_filename, STATUS= 'UNKNOWN', ERR = 2040)

C
C Print statements.....

C
WRITE (204, fmt = 'A80')?????????????????
(

WRITE (204,2044) YEAR, MONTH, DAY, HOURS, MINS,
* foF2, hmF2, MD, D, hF, yF2, fMUF, h, fxI,
* foF1, foE, hmE, foEs, fbEs, ITEC


2044 FORMAT (I4,x,I2,x,I2,2x,I2,I2,
* 4x,F4.1,x,I3,x,F4.2,x,I4,x,I3,x,I3,x,F4.1,x,I3,x,F4.1,
* x, F4.1,x, F4.1,x,I3,x,F4.1,x,F4.1,x,F8.1)

CLOSE(204)

I can write the Format for the Table of Numbers, but how to write the
Character string ????????????

WHAT FORMAT should I use to Write the Text such as below, I know I can
use character A80 format.. But I am not sure.. ANy ideas???

:Product: Qaanaaq_iono.txt
:Issued: 2005 Sep 28 0625 UTC
# Prepared by the U.S. Dept. of Commerce, NOAA, Space Environment
Center.
# Please send comments and suggestions to sec.webmaster@noaa.gov
#
# Units for foF2, MUF(D), foEs, foE, fMUF, foF1, fxI & fbEs = MHz
# Units for yF2, D, hmE, h'F, h' & hmF2 = km
# Units for TEC = 10^16 el/m^2
# Missing data: -1.0,-1,-1.00
#
# Real-Time Ionosonde Data
# Qaanaaq N77E290 AFRL-DGS-256
#
# UT Date Time
# YR MO DA HHMM foF2 hmF2 M(D) D h'F yF2 fMUF h' fxI foF1 foE
hmE foEs fbEs ITEC


Thanks
Pra

Arjen Markus

2005-09-28, 3:58 am

Is the text fixed?

Then:

write(204, '(a)' )
* 'line 1',
* 'line 2',
...

will do too. The repetition count (80) is not needed. Each string is
written to a separate line, because the format as a whole is repeated.

Regards,

Arjen

Jan Vorbrüggen

2005-09-28, 3:58 am

For such cases, the best way to go is to use just the A format, which will
take the length from the character constant or variable in the I/O list.
Two caveats: 1) Fortran CHARACTER variables are blank-padded. If your header
lines are in stored in such variables, and you do not want the trailing
blanks to be also written, use the TRIM intrinsic in the I/O list item.
2) Some of your lines seem longer than 80 characters. No problem, but make
sure the record length of your output file is large enough to hold all the
information you need. Best is to specify it in the OPEN statement.

Jan
prasad413in@gmail.com

2005-09-28, 3:58 am

Thanks.. It worked.. But the date is variable 2005 Sep 28 0625 UTC How
to deal with this one?

Pra

Dick Hendrickson

2005-09-28, 7:00 pm



pra413in@gmail.com wrote:

> Thanks.. It worked.. But the date is variable 2005 Sep 28 0625 UTC How
> to deal with this one?
>

The same way you dealt with the date and time in format
2044. Use whatever explicit format you need. For example
write (204,2045) year, month, day, hour, minute, 'UTC'
2045 format (1x, i4, 1x, a3, 1x, i2, 1x, 2i2.2, 1x, a3)

If the date is stored in character variables instead
of integers, you'll need a descriptors instead of
I ones.

I used "2i2.2" for the hour and minute to force leading
zeros, so you'll get "0605" instead of " 6 5".

Dick Hendrickson

> Pra
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com