source: trunk/LMDZ.GENERIC/libf/phystd/bilinearbig.F90 @ 873

Last change on this file since 873 was 873, checked in by aslmd, 12 years ago

LMDZ.GENERIC (and LMDZ.UNIVERSAL)

  • Optimized calculations for continuum (done for H2 and He, to be done for others)
    • new common bilinear interpolation routine (bilinearbig)
    • optimization: only one calculation is actually needed

to find indexes of wavelength for bilinear interpolation
... because this will not change with level and integration step!

  • optimization: use while loop in bilinearbig
  • completely similar results obtained (test case for a gas giant, many simulated days)

NB: those changes really improve gcm speed (factor 2.2 for whole model!)

continuum was very expensive, now very cheap
--> e.g. 1 day, 25 dyn ts, 5 phys ts
--> before: 243 seconds (including 120 seconds for continuum bilinear interpolation)
--> after: 108 seconds

  • Corrected a bug: Continuum in inifis instead of continuum

... until now, most users (unbeknownst to them) were running with the continuum by default!

  • Cosmetic changes in optcv (mostly spaces and line breaks)

... so that comparisons with optci are easy e.g. through vimdiff

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1      subroutine bilinearbig(x_arr,y_arr,f2d_arr,x_in,y_in,f,a)
2
3!     Necessary for interpolation of continuum data
4!     optimized by A. Spiga 01/2013
5
6      implicit none
7
8      integer nX,nY,i,j,a,b
9      parameter(nX=2428)
10      parameter(nY=10)
11
12      real*8 x_in,y_in,x1,x2,y1,y2
13      real*8 f,f11,f12,f21,f22,fA,fB
14      real*8 x_arr(nX)
15      real*8 y_arr(nY)
16      real*8 f2d_arr(nX,nY)
17      real*8,save :: x,y
18
19      integer strlen
20      character*100 label
21      label='subroutine bilinear'
22
23      x=x_in
24      y=y_in
25
26
27   !! AS: important to optimize here because the array is quite large
28   !! ... and actually calculations only need to be done once
29   !! --> Case 1 : we have not calculated yet
30   if ( a == -9999) then
31      !1st check we're within the wavenumber range
32      if ((x.lt.x_arr(2)).or.(x.gt.x_arr(nX-2))) then
33         f=0.0D+0
34         a=-1
35      else
36        i=1
37        x2=x_arr(i)
38        do while ( x2 .le. x )
39          x1=x2
40          i=i+1
41          x2=x_arr(i)
42          a=i-1
43        end do
44      endif
45   !! --> case 2 : we already saw we are out of wavenumber range
46   else if ( a == -1) then
47      f=0.0D+0
48      return
49   !! --> case 3 : we already determined a -- so we just proceed
50   else
51      x1=x_arr(a)
52      x2=x_arr(a+1)
53   endif
54
55!     ... and for y within the temperature range
56      if ((y.lt.y_arr(1)).or.(y.gt.y_arr(nY))) then
57         write(*,*) 'Warning from bilinearH2H2:'
58         write(*,*) 'Outside continuum temperature range!'
59         if(y.lt.y_arr(1))then
60            y=y_arr(1)+0.01
61         endif
62         if(y.gt.y_arr(nY))then
63            y=y_arr(nY)-0.01
64         endif
65      else
66        j=1
67        y2=y_arr(j)
68        do while ( y2 .le. y )
69          y1=y2
70          j=j+1
71          y2=y_arr(j)
72          b=j-1
73        end do
74      endif
75
76      f11=f2d_arr(a,b)
77      f21=f2d_arr(a+1,b)
78      f12=f2d_arr(a,b+1)
79      f22=f2d_arr(a+1,b+1)
80
81      call bilinear(f,f11,f21,f12,f22,x,x1,x2,y,y1,y2)
82
83      return
84    end subroutine bilinearbig
Note: See TracBrowser for help on using the repository browser.