Ignore:
Timestamp:
Sep 2, 2010, 3:45:23 PM (14 years ago)
Author:
lguez
Message:

Replaced Numerical Recipes procedures for spline interpolation (not in
the public domain) by procedures from the Pchip package in the Slatec
library. This only affects the program "ce0l", not the program
"gcm". Tested on Brodie SX8 with "-debug" and "-prod", "-parallel
none" and "-parallel mpi". "start.nc" and "limit.nc" are
changed. "startphy.nc" is not changed. The relative change is of order
1e-7 or less. The revision makes the program faster (tested on Brodie
with "-prod -d 144x142x39", CPU time is 38 s, instead of 54
s). Procedures from Slatec are untouched, except for
"i1mach.F". Created procedures "pchfe_95" and "pchsp_95" which are
wrappers for "pchfe" and "pchsp" from Slatec. "pchfe_95" and
"pchsp_95" have a safer and simpler interface.

Replaced "make" by "sxgmake" in "arch-SX8_BRODIE.fcm". Added files for
compilation by FCM with "g95".

In "arch-linux-32bit.fcm", replaced "pgf90" by "pgf95". There was no
difference between "dev" and "debug" so added "-O1" to "dev". Added
debugging options. Removed "-Wl,-Bstatic
-L/usr/lib/gcc-lib/i386-linux/2.95.2", which usually produces an error
at link-time.

Bash is now ubiquitous while KornShell? is not so use Bash instead of
KornShell? in FCM.

Replaced some statements "write(6,*)" by "write(lunout,*)". Replaced
"stop" by "stop 1" in the case where "abort_gcm" is called with "ierr
/= 0". Removed "stop" statements at the end of procedures
"limit_netcdf" and main program "ce0l" (why not let the program end
normally?).

Made some arrays automatic instead of allocatable in "start_inter_3d".

Zeroed "wake_pe", "fm_therm", "entr_therm" and "detr_therm" in
"dyn3dpar/etat0_netcdf.F90". The parallel and sequential results of
"ce0l" are thus identical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ4/trunk/libf/dyn3d/startvar.F90

    r1323 r1425  
    643643!-------------------------------------------------------------------------------
    644644!
    645 SUBROUTINE start_inter_3d(varname, iml, jml, lml, lon_in, lat_in, jml2,lon_in2,&
    646                           lat_in2, pls_in, var3d, ibar)
    647 !
    648 !-------------------------------------------------------------------------------
     645SUBROUTINE start_inter_3d(varname, iml, jml, lml, lon_in, lat_in, jml2, &
     646     lon_in2, lat_in2, pls_in, var3d, ibar)
     647
     648  use pchsp_95_m, only: pchsp_95
     649  use pchfe_95_m, only: pchfe_95
     650
    649651! Arguments:
    650652  CHARACTER(LEN=*),             INTENT(IN)    :: varname
     
    655657  REAL, DIMENSION(iml),         INTENT(IN)    :: lon_in2
    656658  REAL, DIMENSION(jml2),        INTENT(IN)    :: lat_in2
    657   REAL, DIMENSION(iml,jml,lml), INTENT(IN)    :: pls_in
    658   REAL, DIMENSION(iml,jml,lml), INTENT(OUT)   :: var3d
     659  REAL, DIMENSION(iml, jml, lml), INTENT(IN)    :: pls_in
     660  REAL, DIMENSION(iml, jml, lml), INTENT(OUT)   :: var3d
    659661  LOGICAL,                      INTENT(IN)    :: ibar
    660 !-------------------------------------------------------------------------------
     662!----------------------------------------------------------------------------
    661663! Local variables:
    662664#include "iniprint.h"
    663   LOGICAL               :: check=.TRUE.
    664   REAL                  :: bx, by, chmin, chmax
    665   INTEGER               :: ii, ij, il
    666   REAL,    DIMENSION(:,:,:), ALLOCATABLE :: var_tmp3d
     665  LOGICAL:: check=.TRUE., skip
     666  REAL                  chmin, chmax
     667  INTEGER ii, ij, il, ierr
     668  integer n_extrap ! number of extrapolated points
     669  REAL, DIMENSION(iml, jml, llm_dyn):: var_tmp3d
    667670  REAL,    DIMENSION(:),     ALLOCATABLE :: lon_rad, lat_rad, lon_ini, lat_ini
    668   REAL,    DIMENSION(:),     ALLOCATABLE :: lev_dyn, ax, ay, yder
    669   INTEGER, DIMENSION(:),     ALLOCATABLE :: lind
    670 !-------------------------------------------------------------------------------
    671   IF(check) WRITE(lunout,*)'Going into flinget to extract the 3D  field.'
    672   IF(check) WRITE(lunout,*)fid_dyn, varname, iml_dyn, jml_dyn, llm_dyn, ttm_dyn
    673   IF(check) WRITE(lunout,*)'Allocating space for interpolation',iml,jml,llm_dyn
    674 
    675   IF(.NOT.ALLOCATED(var_ana3d)) ALLOCATE(var_ana3d(iml_dyn,jml_dyn,llm_dyn))
    676   CALL flinget(fid_dyn,varname,iml_dyn,jml_dyn,llm_dyn,ttm_dyn,1,1,var_ana3d)
     671  REAL, DIMENSION(llm_dyn):: lev_dyn, ax, ay, yder
     672
     673!---------------------------------------------------------------------------
     674  IF(check) WRITE(lunout, *)'Going into flinget to extract the 3D  field.'
     675  IF(check) WRITE(lunout, *) fid_dyn, varname, iml_dyn, jml_dyn, llm_dyn, &
     676       ttm_dyn
     677  IF(check) WRITE(lunout, *) 'Allocating space for interpolation', iml, jml, &
     678       llm_dyn
     679
     680  IF(.NOT.ALLOCATED(var_ana3d)) ALLOCATE(var_ana3d(iml_dyn, jml_dyn, llm_dyn))
     681  CALL flinget(fid_dyn, varname, iml_dyn, jml_dyn, llm_dyn, ttm_dyn, 1, 1, &
     682       var_ana3d)
    677683
    678684!--- IF ANGLES ARE IN DEGREES, THEY ARE CONVERTED INTO RADIANS
    679   ALLOCATE(lon_ini(iml_dyn),lat_ini(jml_dyn))
    680   lon_ini(:)=lon_dyn(:,1); IF(MAXVAL(lon_dyn)>pi) lon_ini=lon_ini*deg2rad
    681   lat_ini(:)=lat_dyn(1,:); IF(MAXVAL(lat_dyn)>pi) lat_ini=lat_ini*deg2rad
     685  ALLOCATE(lon_ini(iml_dyn), lat_ini(jml_dyn))
     686  lon_ini(:)=lon_dyn(:, 1); IF(MAXVAL(lon_dyn)>pi) lon_ini=lon_ini*deg2rad
     687  lat_ini(:)=lat_dyn(1, :); IF(MAXVAL(lat_dyn)>pi) lat_ini=lat_ini*deg2rad
    682688
    683689!--- FIELDS ARE PROCESSED TO BE ON STANDARD ANGULAR DOMAINS
    684   ALLOCATE(lon_rad(iml_dyn),lat_rad(jml_dyn),lev_dyn(llm_dyn))
    685   CALL conf_dat3d (varname, iml_dyn, jml_dyn, llm_dyn, lon_ini, lat_ini,       &
     690  ALLOCATE(lon_rad(iml_dyn), lat_rad(jml_dyn))
     691  CALL conf_dat3d (varname, iml_dyn, jml_dyn, llm_dyn, lon_ini, lat_ini,      &
    686692                   levdyn_ini, lon_rad, lat_rad, lev_dyn, var_ana3d, ibar)
    687   DEALLOCATE(lon_ini,lat_ini)
     693  DEALLOCATE(lon_ini, lat_ini)
    688694
    689695!--- COMPUTING THE REQUIRED FIELDS USING ROUTINE grid_noro
    690   ALLOCATE(var_tmp3d(iml,jml,llm_dyn))
    691   DO il=1,llm_dyn
    692     CALL interp_startvar(varname, ibar, il==1,                                 &
    693       iml_dyn, jml_dyn, lon_rad, lat_rad, var_ana3d(:,:,il), iml, jml, jml2,   &
    694       lon_in,  lat_in,  lon_in2, lat_in2, var_tmp3d(:,:,il))
     696  DO il=1, llm_dyn
     697    CALL interp_startvar(varname, ibar, il==1, iml_dyn, jml_dyn, lon_rad, &
     698         lat_rad, var_ana3d(:, :, il), iml, jml, jml2, lon_in, lat_in, &
     699         lon_in2, lat_in2, var_tmp3d(:, :, il))
    695700  END DO
    696   DEALLOCATE(lon_rad,lat_rad)
    697 
    698   ALLOCATE(lind(llm_dyn))
    699   DO il=1,llm_dyn
    700     lind(il) = llm_dyn-il+1
     701  DEALLOCATE(lon_rad, lat_rad)
     702
     703!--- VERTICAL INTERPOLATION IS PERFORMED FROM TOP OF ATMOSPHERE TO GROUND
     704  ax = lev_dyn(llm_dyn:1:-1)
     705  skip = .false.
     706  n_extrap = 0
     707  DO ij=1, jml
     708    DO ii=1, iml-1
     709      ay = var_tmp3d(ii, ij, llm_dyn:1:-1)
     710      yder = pchsp_95(ax, ay, ibeg=2, iend=2, vc_beg=0., vc_end=0.)
     711      CALL pchfe_95(ax, ay, yder, skip, pls_in(ii, ij, lml:1:-1), &
     712           var3d(ii, ij, lml:1:-1), ierr)
     713      if (ierr < 0) stop 1
     714      n_extrap = n_extrap + ierr
     715    END DO
    701716  END DO
    702 
    703 !--- VERTICAL INTERPOLATION IS PERFORMED FROM TOP OF ATMOSPHERE TO GROUND
    704   ALLOCATE(ax(llm_dyn),ay(llm_dyn),yder(llm_dyn))
    705   DO ij=1,jml
    706     DO ii=1,iml-1
    707       ax(:)=lev_dyn(lind(:))
    708       ay(:)=var_tmp3d(ii,ij,lind(:))
    709       CALL SPLINE(ax, ay, llm_dyn, 1.e30, 1.e30, yder)
    710       DO il=1,lml
    711         bx=pls_in(ii,ij,il)
    712         CALL SPLINT(ax, ay, yder, llm_dyn, bx, by)
    713         var3d(ii,ij,il) = by
    714       END DO
    715     END DO
    716     var3d(iml,ij,:) = var3d(1,ij,:)
     717  if (n_extrap /= 0) then
     718     print *, "start_inter_3d pchfe_95: n_extrap = ", n_extrap
     719  end if
     720  var3d(iml, :, :) = var3d(1, :, :)
     721
     722  DO il=1, lml
     723    CALL minmax(iml*jml, var3d(1, 1, il), chmin, chmax)
     724    WRITE(lunout, *)' '//TRIM(varname)//'  min max l ', il, chmin, chmax
    717725  END DO
    718   DEALLOCATE(var_tmp3d,lev_dyn,ax,ay,yder,lind)
    719 
    720   DO il=1,lml
    721     CALL minmax(iml*jml,var3d(1,1,il),chmin,chmax)
    722     WRITE(lunout,*)' '//TRIM(varname)//'  min max l ',il,chmin,chmax
    723   END DO
    724 
    725   RETURN
    726726
    727727END SUBROUTINE start_inter_3d
Note: See TracChangeset for help on using the changeset viewer.