From: Fortran_follower on
Dear Friends,

Recently I've started learning Fortran 95.
I want to convert the date format mentioned below to Modified Julian
Day format (MJD)
04-Aug-2001 00:10:52
04-Aug-2001 00:10:53
04-Aug-2001 00:10:54
04-Aug-2001 00:10:55
04-Aug-2001 00:10:56
04-Aug-2001 00:10:57
04-Aug-2001 00:10:58
04-Aug-2001 00:10:59
04-Aug-2001 00:11:00
04-Aug-2001 00:11:01

Since, the month is in alphabetical form, I am finding difficulty to
deal with char/string arrays in fortran.

Can any one please help me how to come up with this issue...!!

Thanks in advance.

Praveen.

From: e p chandler on
On Nov 6, 10:25 am, Fortran_follower <ezeepravee...(a)gmail.com> wrote:
> Dear Friends,
>
> Recently I've started learning Fortran 95.
> I want to convert the date format mentioned below to Modified Julian
> Day format (MJD)
> 04-Aug-2001 00:10:52
> 04-Aug-2001 00:10:53
> 04-Aug-2001 00:10:54
> 04-Aug-2001 00:10:55
> 04-Aug-2001 00:10:56
> 04-Aug-2001 00:10:57
> 04-Aug-2001 00:10:58
> 04-Aug-2001 00:10:59
> 04-Aug-2001 00:11:00
> 04-Aug-2001 00:11:01
>
> Since, the month is in alphabetical form, I am finding difficulty to
> deal with char/string arrays in fortran.
>
> Can any one please help me how to come up with this issue...!!
>
> Thanks in advance.
>
> Praveen.

There are two simple ways that come to mind.

1. Create an array (look up table) which contains 12 entries. Each of
these is a character variable of 3 characters. For each record in the
input file, loop through the list of month names until one matches the
month_field. Then your array index is the month number. For example
'Aug' would be in position 8.

2. Create a single character variable of 36 characters containing
'JanFeb.......'. Use INDEX to find the position of the month_field
within the larger string. Adjust that number to return a number from 1
to 12.

-- e