Re: Date representation
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Date representation         

Group: comp.lang.fortran · Group Profile
Author: Kurt Kallblad
Date: Sep 11, 2008 06:41

"Marin Brkic" wrote in message
news:ufihc4t8ibr99bfabvqrfghiidreokes5s@4ax.com...
> Hello all,
>
> please, if you can, i need your help. I have a list
> 2008.09.09 1.2 1.3 1.4
> 2008.09.14 1.5 1.6 1.7
> 2008.09.16 1.8 1.9 2.0
> 2008.09.17 2.1 2.2 2.3 (just throwing numbers here)
>
> The first number is the date. The rest are some temperature,
> pressure
> ... etc. The dates are not all, some are missing.
>
> I need to calculate some values, and draw some plots, but I'm
> having
> trouble figuring out how to load the dates into fortran. For
> example,
> if you were to need to plot this on a time basis, what would be
> the
> appropriate course to take ?
>
> I was thinking about trying to load the date as a string, split
> it
> into parts, calculate what date is what day of the year (so
> 2008.09.09
> would be, I don't know - 278th day) and then making further on.
> Is there a better way ?
>
> I would appreciate all your ideas and suggestions on this
> matter,
>
> with regards
> Marin

Looking at your example I guess that the amount of data is not
more than you easily can keep in memory and it is a quick job to
read the file. In cases like that I read the file twice. The
first reading is used to determine the needed array sizes. Then I
allocate the arrays, rewind the file and read in the data.

Some nostalgia which may be useful:

Below you will find a routine to convert the dates to JULDAG.
These are not the Julian day but my own day numbers. These
numbers start with 1 for 1901-01-01 and ends with 72684 for
2099-12-31, this to get rid of leap year problems. The original
version was on punched cards but it is still in use in some
commercial programs. A small Swedish wordlist is attached to help
you to understand the variables.

Kurt

SUBROUTINE CALEND(IAR,IMAN,IDAG,JULDAG,NRDAG,IVDAG)

DIMENSION NDM(13,2)

DATA NDM/0,31,59,90,120,151,181,212,243,273,304,334,365,

+
0,31,60,91,121,152,182,213,244,274,305,335,366/NU/6/

IF (IAR.LT.1901.OR.IAR.GT.2099) GO TO 10

IF (IMAN.LT.1.OR.IMAN.GT.12) GO TO 10

N=1

IF (MOD(IAR,4).EQ.0) N=2

IF (IDAG.LT.1.OR.IDAG.GT.NDM(IMAN+1,N)-NDM(IMAN,N)) GO TO
10

NRDAG=IDAG+NDM(IMAN,N)

JULDAG=IAR-1901

JULDAG=JULDAG*365+JULDAG/4+NRDAG

IVDAG=MOD(JULDAG,7)+1

RETURN

10 WRITE(NU,20) IAR,IMAN,IDAG

20 FORMAT(' **** FELAKTIGT ARGUMENT TILL CALEND'//1X,3I10)

STOP

END

IAR år year

IMAN månad month

IDAG dag day

JULDAG juldag x-mas day

NRDAG dagnummer daynumber 1 - 365/366

IVDAG veckodag day of week 1 = Monday

FELAKTIGT erroneous

TILL to
no comments
diggit! del.icio.us! reddit!