[cig-commits] r18215 - seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Sat Apr 9 17:33:13 PDT 2011


Author: dkomati1
Date: 2011-04-09 17:33:12 -0700 (Sat, 09 Apr 2011)
New Revision: 18215

Modified:
   seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/Makefile.in
   seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/convert_time.f90
Log:
extended routines convtime() and invtime() to work beyond the year 2020, up to the year 3000.
Also hardwired -O1 to the Makefile for routine compute_arrays_source.f90 otherwise it takes forever to compile with some versions of Intel ifort.


Modified: seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/Makefile.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/Makefile.in	2011-04-09 23:00:32 UTC (rev 18214)
+++ seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/Makefile.in	2011-04-10 00:33:12 UTC (rev 18215)
@@ -374,7 +374,8 @@
 	${FCCOMPILE_CHECK} -c -o $O/compute_adj_source_frechet.o ${FCFLAGS_f90} $S/compute_adj_source_frechet.f90
 
 $O/compute_arrays_source.o: ${SETUP}/constants.h $S/compute_arrays_source.f90
-	${FCCOMPILE_CHECK} -c -o $O/compute_arrays_source.o ${FCFLAGS_f90} $S/compute_arrays_source.f90
+## DK DK hardwired -O1 for that particular routine, otherwise it takes forever to compile with some versions of Intel ifort
+	${FCCOMPILE_CHECK} -c -o $O/compute_arrays_source.o ${FCFLAGS_f90} -O1 $S/compute_arrays_source.f90
 
 $O/convert_time.o: $S/convert_time.f90
 	${FCCOMPILE_CHECK} -c -o $O/convert_time.o ${FCFLAGS_f90} $S/convert_time.f90

Modified: seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/convert_time.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/convert_time.f90	2011-04-09 23:00:32 UTC (rev 18214)
+++ seismo/3D/SPECFEM3D_GLOBE/trunk/src/specfem3D/convert_time.f90	2011-04-10 00:33:12 UTC (rev 18215)
@@ -2,11 +2,13 @@
 ! open-source subroutines taken from the World Ocean Circulation Experiment (WOCE)
 ! web site at http://www.coaps.fsu.edu/woce/html/wcdtools.htm
 
-! converted to Fortran90 by Dimitri Komatitsch,
-! University of Pau, France, January 2008.
+! converted to Fortran90 by Dimitri Komatitsch, University of Pau, France, January 2008.
 ! Also converted "convtime" from a function to a subroutine.
 ! Also used a more complete test to detect leap years (the original version was incomplete).
 
+! extended by Dimitri Komatitsch, University of Toulouse, France, April 2011,
+! to go beyond the year 2020; I extended that to the year 3000 and thus had to write a loop to fill array "year()".
+
   subroutine convtime(timestamp,yr,mon,day,hr,min)
 
 ! Originally written by Shawn Smith (ssmith AT coaps.fsu.edu)
@@ -17,26 +19,19 @@
 
   implicit none
 
+  integer, parameter :: MAX_YEAR = 3000
+
   integer, intent(out) :: timestamp
 
   integer, intent(in) :: yr,mon,day,hr,min
 
-  integer :: year(1980:2020),month(12),leap_mon(12)
+  integer :: year(1980:MAX_YEAR),month(12),leap_mon(12)
 
-  integer ::  min_day,min_hr
+  integer ::  min_day,min_hr,iyr
 
 ! function to determine if year is a leap year
   logical, external :: is_leap_year
 
-  data year /0, 527040, 1052640, 1578240, 2103840, 2630880, 3156480, &
-               3682080, 4207680, 4734720, 5260320, 5785920, 6311520, &
-               6838560, 7364160, 7889760,  8415360, 8942400, 9468000, &
-               9993600, 10519200, 11046240, 11571840, 12097440, &
-              12623040, 13150080, 13675680, 14201280, 14726880, &
-              15253920, 15779520, 16305120, 16830720, 17357760, &
-              17883360, 18408960, 18934560, 19461600, 19987200, &
-              20512800, 21038400/
-
   data month /0, 44640, 84960, 129600, 172800, 217440, 260640, &
               305280, 349920, 393120, 437760, 480960/
 
@@ -45,8 +40,18 @@
 
   data min_day, min_hr /1440, 60/
 
+! loop added by Dimitri Komatitsch to fill array "year()" automatically
+  year(:) = 0
+  do iyr = 1981,MAX_YEAR
+    if(is_leap_year(iyr-1)) then
+      year(iyr) = year(iyr-1) + 366*24*60 ! number of minutes in a year if leap year
+    else
+      year(iyr) = year(iyr-1) + 365*24*60 ! number of minutes in a year if not leap year
+    endif
+  enddo
+
 ! Test values to see if they fit valid ranges
-  if (yr < 1980 .or. yr > 2020) stop 'Error in convtime: year out of range (1980-2020)'
+  if (yr < 1980) stop 'Error in convtime: year out of range, must be >= 1980'
 
   if (mon < 1 .or. mon > 12) stop 'Error in convtime: month out of range (1-12)'
 
@@ -91,42 +96,45 @@
 ! Shyam Lakshmin (lakshmin AT coaps.fsu.edu)
 !
 ! This code returns correct results for the range of 01 Jan 1980 00:00
-! thru 31 Dec 2020 23:59. I know it does, because I tried each minute of that range.
+! through 31 Dec 2020 23:59. I know it does, because I tried each minute of that range.
 
   implicit none
 
+  integer, parameter :: MAX_YEAR = 3000
+
   integer, intent(in) :: timestamp
 
   integer, intent(out) :: yr,mon,day,hr,min
 
-  integer :: year(1980:2021),month(13),leap_mon(13)
+  integer :: year(1980:MAX_YEAR),month(13),leap_mon(13)
 
   integer :: min_day,min_hr,itime,tmon,ttime,thour,iyr,imon,iday,ihour
 
 ! function to determine if year is a leap year
   logical, external :: is_leap_year
 
-  data year /0, 527040, 1052640, 1578240, 2103840, 2630880, 3156480, &
-               3682080, 4207680, 4734720, 5260320, 5785920, 6311520, &
-               6838560, 7364160, 7889760, 8415360, 8942400, 9468000, &
-               9993600, 10519200, 11046240, 11571840, 12097440, &
-              12623040, 13150080, 13675680, 14201280, 14726880, &
-              15253920, 15779520, 16305120, 16830720, 17357760, &
-              17883360, 18408960, 18934560, 19461600, 19987200, &
-              20512800, 21038400, 21565440/
-
   data month /0,  44640, 84960, 129600, 172800, 217440, 260640, &
-            305280, 349920, 393120, 437760, 480960,525600/
+            305280, 349920, 393120, 437760, 480960, 525600/
 
   data leap_mon /0,  44640,  86400, 131040, 174240, 218880, 262080, &
-            306720, 351360, 394560, 439200, 482400,527040/
+            306720, 351360, 394560, 439200, 482400, 527040/
 
   data min_day, min_hr /1440, 60/
 
-! ok, let us invert the effects of the years: subtract off the
+! loop added by Dimitri Komatitsch to fill array "year()" automatically
+  year(:) = 0
+  do iyr = 1981,MAX_YEAR
+    if(is_leap_year(iyr-1)) then
+      year(iyr) = year(iyr-1) + 366*24*60 ! number of minutes in a year if leap year
+    else
+      year(iyr) = year(iyr-1) + 365*24*60 ! number of minutes in a year if not leap year
+    endif
+  enddo
+
+! OK, let us invert the effects of the years: subtract off the
 ! number of minutes per year until it goes negative
 ! iyr then gives the year that the time (in minutes) occurs
-  if (timestamp >= year(2021)) stop 'year too high in invtime'
+  if (timestamp >= year(MAX_YEAR)) stop 'year too high in invtime'
 
   iyr=1979
   itime=timestamp
@@ -144,7 +152,7 @@
 ! assign the return variable
   yr=iyr
 
-! ok, the remaining time is less than one full year, so convert
+! OK, the remaining time is less than one full year, so convert
 ! by the same method as above into months
   imon=0
 
@@ -200,7 +208,7 @@
   mon=imon
 
 ! any remaining minutes will belong to day/hour/minutes
-! ok, let us get the days
+! OK, let us get the days
   iday=0
  40 iday=iday+1
   ttime=itime-min_day



More information about the CIG-COMMITS mailing list