MVLib - Short Writeup - Version 4.0
Routines for temporal index manipulation - Last update: April 4, 2012
Source code available for local users only
In the second column of the following table, S stays for "Subroutine", I stays for "Integer function" and R stays for "Real function".
How to obtain a string containing the date
All these funcions are affected by the value of MVLib parameter 'Data Style'.
monthofyear(im,iy,data) S Returns in string variable data the name of the month specified by the input integer variable im, if the second integer argument is greater than zero the year is also added to the string. As an example, a call with th arguments (10,2003,data) returns data="October, 2003"; a call with th arguments (2,-1,data) returns data="February". The routines is affected by the value of MVLib parameter 'Data Style'.
datafromday(id,im,iy,data) S Returns in the string variable data the date specified by the the input integer variables id, im, and iy specifiyng the day, month and year respectively.
datafromhour (ih,id,im,iy,data) S Returns in the string variable data the date specified by the the input integer variables ih, id, im, and iy specifiyng the hour, day, month and year respectively.
datafrommin (imm,ih,id,im,iy,data) S Returns in the string variable data the date specified by the the input integer variables imm, ih, id, im, and iy specifiyng the minutes, hour, day, month and year respectively.
datafromindex(index,year,data) S Returns in the string variable data the date corresponding to the julian day passed as first argument. The second argument specifies the the year and it is needed to take into account the leap years.
datafromindex15(index,year,data) S Returns in the string variable data the date corresponding to the 15-minutes index passed as first argument, such index is =1 for Jan 1, h: 00.00, =2 for Jan 1, h: 00.15, etc. The second argument specifies the the year and it is needed to take into account the leap years.
datafrommm5index(index,data) S Returns in the string variable data the date corresponding to the MM5 temporal index passed as first argument.
How to manipulate MM5 and CHyM temporal index
Please note: all these functions are affected by the current value of Calendar internal flag, if this flag is set to 0 (default) the actual calendar is used; if this flag is set to 1 the leap years are not considered (february is always 28 days long); if this flag is set to 2 all the months are considered 30 days long.
mm5index(ih,id,im,iy) I Returns the MM5 temporal index from the input integer variables ih, id, im, and iy specifiyng the hour, day, month and year respectively. The MM5 temporal index is in the form YYMMDDHH.
increasemm5index(index) or
increasetime(index)
I Increases by one hour the MM5 index passed as argument, as an example if input integer is 02123123 increasemm5index will return 03010100.
decreasemm5index(index) or
decreasetime(index)
I Decreases by one hour the MM5 index passed as argument, as an example if input integer is 03010100 decreasemm5index will return 02123123.
nslicetoskip(idate1,idate2) I Returns the number of hourly time slice to skip between the coded dates specifyed by the two integer arguments. As an example if the arguments are 12021000 and 12021120 respectively the function returns 44 (namely 1 day + 20 hours). The special value -1 is returned if the second argument is earlier respect to the first one.
indtimeal(date1,date2) I The integer function indtimeal (INDex of TIME ALignment) allows to check if the temporal indexes passed as arguments are in the right alignment, namely if the first date is earlier respect to the second one, if this is the case the function returns 1; if the second time index is earlier respect to the first one, the function returns -1; if the two arguments are identical, the function returns 0.
gmafrommm5index
(index,ora,giorno,mese,anno)
S From MM5 index passed as first argument, returns four integer variables specifiyng the hour, day, month and year respectively.
datafrommm5index(index,data) S Returns in the string variable data the date corresponding to the MM5 temporal index passed as first argument.
Conversion from julian day to date and viceversa
index1d((id,im,iy) or
julianday(id,im,iy)
I Returns the julian day (1-366) corresponding to the day specified by the the input integer variables id, im, and iy specifiyng the day, month and year respectively.
index3h(ih,id,im,iy) I Returns the index correspondig to a 3-hours interval. index=1 corresponds to "Jan, 1 h: 00.00", index=2 corresponds to "Jan, 1 h: 03.00", index=2921=8*365+1 corresponds to the midnight of "Dec, 31" for non leap years.
index1h(ih,id,im,iy) or
indexhourofyear(ih,id,im,iy)
I Returns the index correspondig to a 1-hour interval. index=1 corresponds to "Jan, 1 h: 00.00", index=2 corresponds to "Jan, 1 h: 01.00", index=8761=24*365+1 corresponds to the midnight of "Dec, 31" for non leap years.
index15m(im,ih,id,im,iy) or
index15ofyear(im,ih,id,im,iy)
I Returns the index correspondig to a 15-minutes interval. index=1 corresponds to "Jan, 1 h: 00.00", index=2 corresponds to "Jan, 1 h: 00.15", index=35041=365*24*4+1 corresponds to the midnight of "Dec, 31" for non leap years.
dayfromindex
(index,day,month,year)
S From the julian index passed as first argument, return the day and month (second and third argument); the year, passed as last argument is needed to take into account the leap year.
dayfromindex1h
(index,hour,day,month,year)
S From the one-hour index passed as first argument, return the hour, day and month (second, third and fourth argument); the year, passed as last argument is needed to take into account the leap year.
dayfromindex15
(index,min,hour,day,month,year)
S From the 15-minutes index passed as first argument, return the minutes, hour, day and month (second to 5th arguments); the year, passed as last argument is needed to take into account the leap year.
indexfrommm5index(index) I Returns the julian day from MM5 index passed as argument.
Other utilities
i4digityear(year) I Convert the format of the year passed as integer argument from two digits to four digits; as an example 10 will return 2010 and 98 will return 1998. The year is considered belonging to XXI century if it is in the range 0-50 and belonging to XX century otherwise; this default behaviuor change if the user explicitely set the MVLib internal parameter century. The format is unchanged if the argument is greater tan 1000.
iweekday(id,im,iy) I Returns an integer in the range 1-7, 1 stays for monday, 7 stays for sunday. The three input integer variables specify day, month and year respectively.
monthlen(im,iy) I Returns an integer corresponding to the number of days of the month passed as first argument. The second argument specify the year and it is important for february only. Please note: this function is also affected by the current value of Calendar internal flag, if this flag is set to 0 (default) the actual calendar is used; if this flag is set to 1 the leap years are not considered (february is always 28 days long); if this flag is set to 2 all the months are considered 30 days long.
ugt2localtime(hour,day,month,year) S Converts from UGT time to italian (CET) time. The routine ugt2localtime also take into account the daylight saving time.
localtime2ugt(hour,day,month,year) S Converts from italian (CET) time to UGT time. The routine localtime2ugt also take into account the daylight saving time.
tomorrow(day,month,year) S Increses the date by one day
whattimeisit(min,hour,day,month,year) or
cheorae(min,hour,day,month,year)
S Returns the current system time in the five integer arguments.
notteogiorno(lat,lon,hour,min,day,month) I The first two real arguments specify the latitude and longitudes, last 4 arguments specify UGT time. The function notteogiorno returns 0 for nighttime and 1 for daytime.