regr_lint_m.f90 Source File


This file depends on

sourcefile~~regr_lint_m.f90~~EfferentGraph sourcefile~regr_lint_m.f90 regr_lint_m.f90 sourcefile~assert_eq_m.f90 assert_eq_m.f90 sourcefile~regr_lint_m.f90->sourcefile~assert_eq_m.f90 sourcefile~interpolation.f90 interpolation.f90 sourcefile~regr_lint_m.f90->sourcefile~interpolation.f90 sourcefile~assert_m.f90 assert_m.f90 sourcefile~regr_lint_m.f90->sourcefile~assert_m.f90

Files dependent on this one

sourcefile~~regr_lint_m.f90~~AfferentGraph sourcefile~regr_lint_m.f90 regr_lint_m.f90 sourcefile~regr_lat_time_coefoz_m.f90~2 regr_lat_time_coefoz_m.f90 sourcefile~regr_lat_time_coefoz_m.f90~2->sourcefile~regr_lint_m.f90 sourcefile~regr_lat_time_coefoz_m.f90 regr_lat_time_coefoz_m.f90 sourcefile~regr_lat_time_coefoz_m.f90->sourcefile~regr_lint_m.f90 sourcefile~regr_horiz_time_climoz_m.f90 regr_horiz_time_climoz_m.f90 sourcefile~regr_horiz_time_climoz_m.f90->sourcefile~regr_lint_m.f90 sourcefile~regr_pr_int_m.f90 regr_pr_int_m.f90 sourcefile~regr_pr_int_m.f90->sourcefile~regr_lint_m.f90 sourcefile~regr_pr_time_av_m.f90 regr_pr_time_av_m.f90 sourcefile~regr_pr_time_av_m.f90->sourcefile~regr_lint_m.f90 sourcefile~regr_pr_time_av_m.f90~2 regr_pr_time_av_m.f90 sourcefile~regr_pr_time_av_m.f90~2->sourcefile~regr_lint_m.f90 sourcefile~regr_pr_int_m.f90~2 regr_pr_int_m.f90 sourcefile~regr_pr_int_m.f90~2->sourcefile~regr_lint_m.f90 sourcefile~regr_horiz_time_climoz_m.f90~2 regr_horiz_time_climoz_m.f90 sourcefile~regr_horiz_time_climoz_m.f90~2->sourcefile~regr_lint_m.f90 sourcefile~etat0dyn_netcdf.f90 etat0dyn_netcdf.F90 sourcefile~etat0dyn_netcdf.f90->sourcefile~regr_lat_time_coefoz_m.f90 sourcefile~physiq_mod.f90 physiq_mod.F90 sourcefile~physiq_mod.f90->sourcefile~regr_horiz_time_climoz_m.f90 sourcefile~physiq_mod.f90->sourcefile~regr_pr_time_av_m.f90 sourcefile~phytrac_mod.f90 phytrac_mod.f90 sourcefile~physiq_mod.f90->sourcefile~phytrac_mod.f90 sourcefile~phyetat0_mod.f90 phyetat0_mod.F90 sourcefile~physiq_mod.f90->sourcefile~phyetat0_mod.f90 sourcefile~phys_output_write_mod.f90 phys_output_write_mod.F90 sourcefile~physiq_mod.f90->sourcefile~phys_output_write_mod.f90 sourcefile~physiqex_mod.f90 physiqex_mod.F90 sourcefile~physiq_mod.f90->sourcefile~physiqex_mod.f90 sourcefile~diag_slp.f90 diag_slp.f90 sourcefile~physiq_mod.f90->sourcefile~diag_slp.f90 sourcefile~phys_output_mod.f90 phys_output_mod.F90 sourcefile~physiq_mod.f90->sourcefile~phys_output_mod.f90 sourcefile~regr_pr_comb_coefoz_m.f90~2 regr_pr_comb_coefoz_m.f90 sourcefile~regr_pr_comb_coefoz_m.f90~2->sourcefile~regr_pr_int_m.f90 sourcefile~regr_pr_comb_coefoz_m.f90~2->sourcefile~regr_pr_time_av_m.f90 sourcefile~regr_pr_comb_coefoz_m.f90 regr_pr_comb_coefoz_m.f90 sourcefile~regr_pr_comb_coefoz_m.f90->sourcefile~regr_pr_int_m.f90 sourcefile~regr_pr_comb_coefoz_m.f90->sourcefile~regr_pr_time_av_m.f90 sourcefile~etat0phys_netcdf.f90 etat0phys_netcdf.f90 sourcefile~etat0phys_netcdf.f90->sourcefile~regr_horiz_time_climoz_m.f90 sourcefile~physiq_mod.f90~2 physiq_mod.F90 sourcefile~physiq_mod.f90~2->sourcefile~regr_horiz_time_climoz_m.f90 sourcefile~physiq_mod.f90~2->sourcefile~regr_pr_time_av_m.f90 sourcefile~physiq_mod.f90~2->sourcefile~phytrac_mod.f90 sourcefile~physiq_mod.f90~2->sourcefile~phyetat0_mod.f90 sourcefile~physiq_mod.f90~2->sourcefile~phys_output_write_mod.f90 sourcefile~physiq_mod.f90~2->sourcefile~physiqex_mod.f90 sourcefile~physiq_mod.f90~2->sourcefile~diag_slp.f90 sourcefile~physiq_mod.f90~2->sourcefile~phys_output_mod.f90 sourcefile~old_lmdz1d.f90 old_lmdz1d.f90 sourcefile~old_lmdz1d.f90->sourcefile~physiq_mod.f90 sourcefile~traclmdz_mod.f90 traclmdz_mod.f90 sourcefile~traclmdz_mod.f90->sourcefile~regr_pr_comb_coefoz_m.f90 sourcefile~o3_chem_m.f90 o3_chem_m.f90 sourcefile~traclmdz_mod.f90->sourcefile~o3_chem_m.f90 sourcefile~traclmdz_mod.f90~2 traclmdz_mod.f90 sourcefile~traclmdz_mod.f90~2->sourcefile~regr_pr_comb_coefoz_m.f90 sourcefile~traclmdz_mod.f90~2->sourcefile~o3_chem_m.f90 sourcefile~ce0l.f90 ce0l.F90 sourcefile~ce0l.f90->sourcefile~etat0dyn_netcdf.f90 sourcefile~ce0l.f90->sourcefile~etat0phys_netcdf.f90 sourcefile~callphysiq_mod.f90~2 callphysiq_mod.f90 sourcefile~callphysiq_mod.f90~2->sourcefile~physiq_mod.f90 sourcefile~o3_chem_m.f90->sourcefile~regr_pr_comb_coefoz_m.f90 sourcefile~o3_chem_m.f90~2 o3_chem_m.f90 sourcefile~o3_chem_m.f90~2->sourcefile~regr_pr_comb_coefoz_m.f90 sourcefile~scm.f90 scm.f90 sourcefile~scm.f90->sourcefile~physiq_mod.f90 sourcefile~callphysiq_mod.f90 callphysiq_mod.f90 sourcefile~callphysiq_mod.f90->sourcefile~physiq_mod.f90 sourcefile~lsc_scav.f90 lsc_scav.f90 sourcefile~lsc_scav.f90->sourcefile~traclmdz_mod.f90 sourcefile~lsc_scav_orig.f90~2 lsc_scav_orig.f90 sourcefile~lsc_scav_orig.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~calfis.f90 calfis.f90 sourcefile~calfis.f90->sourcefile~callphysiq_mod.f90 sourcefile~phytrac_mod.f90->sourcefile~traclmdz_mod.f90 sourcefile~cltracrn.f90~2 cltracrn.f90 sourcefile~cltracrn.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~phyredem.f90 phyredem.F90 sourcefile~phyredem.f90->sourcefile~traclmdz_mod.f90 sourcefile~initrrnpb.f90 initrrnpb.f90 sourcefile~initrrnpb.f90->sourcefile~traclmdz_mod.f90 sourcefile~lsc_scav_orig.f90 lsc_scav_orig.f90 sourcefile~lsc_scav_orig.f90->sourcefile~traclmdz_mod.f90 sourcefile~phyetat0_mod.f90->sourcefile~traclmdz_mod.f90 sourcefile~radio_decay.f90 radio_decay.f90 sourcefile~radio_decay.f90->sourcefile~traclmdz_mod.f90 sourcefile~initrrnpb.f90~2 initrrnpb.f90 sourcefile~initrrnpb.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~lsc_scav_spl.f90 lsc_scav_spl.f90 sourcefile~lsc_scav_spl.f90->sourcefile~traclmdz_mod.f90 sourcefile~phytrac_mod.f90~2 phytrac_mod.f90 sourcefile~phytrac_mod.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~radio_decay.f90~2 radio_decay.f90 sourcefile~radio_decay.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~lsc_scav_spl.f90~2 lsc_scav_spl.f90 sourcefile~lsc_scav_spl.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~lsc_scav.f90~2 lsc_scav.f90 sourcefile~lsc_scav.f90~2->sourcefile~traclmdz_mod.f90 sourcefile~cltracrn.f90 cltracrn.f90 sourcefile~cltracrn.f90->sourcefile~traclmdz_mod.f90 sourcefile~phys_output_write_mod.f90->sourcefile~phytrac_mod.f90 sourcefile~physiqex_mod.f90~2 physiqex_mod.F90 sourcefile~physiqex_mod.f90~2->sourcefile~phyetat0_mod.f90 sourcefile~phys_output_write_mod.f90~2 phys_output_write_mod.F90 sourcefile~phys_output_write_mod.f90~2->sourcefile~phytrac_mod.f90 sourcefile~physiqex_mod.f90->sourcefile~phyetat0_mod.f90 sourcefile~diag_slp.f90->sourcefile~phys_output_write_mod.f90 sourcefile~phys_output_mod.f90->sourcefile~phys_output_write_mod.f90 sourcefile~phys_output_mod.f90~2 phys_output_mod.F90 sourcefile~phys_output_mod.f90~2->sourcefile~phys_output_write_mod.f90 sourcefile~diag_slp.f90~2 diag_slp.f90 sourcefile~diag_slp.f90~2->sourcefile~phys_output_write_mod.f90 sourcefile~recmwf_aero.f90 recmwf_aero.F90 sourcefile~recmwf_aero.f90->sourcefile~phys_output_mod.f90 sourcefile~recmwf_aero.f90~2 recmwf_aero.F90 sourcefile~recmwf_aero.f90~2->sourcefile~phys_output_mod.f90 sourcefile~sw_aeroar4.f90 sw_aeroAR4.f90 sourcefile~sw_aeroar4.f90->sourcefile~phys_output_mod.f90 sourcefile~sw_aeroar4.f90~2 sw_aeroAR4.f90 sourcefile~sw_aeroar4.f90~2->sourcefile~phys_output_mod.f90

Contents

Source Code


Source Code

MODULE regr_lint_m

  USE assert_eq_m,   ONLY: assert_eq
  USE assert_m,      ONLY: assert
  USE interpolation, ONLY: hunt

  IMPLICIT NONE

! Purpose: Each procedure regrids by linear interpolation along dimension "ix"
!          the input field "vs" to the output field "vt".
! Remark:
!   * "vs" and "vt" have the same dimensions except Nr. ix (ns for vs, nt for vt)

! Argument                         Type         Description
!-------------------------------------------------------------------------------
!  INTEGER, INTENT(IN)  :: ix      Scalar       dimension regridded <=rank(vs)
!  REAL,    INTENT(IN)  :: vs(*)   Rank>=1      source grid field values
!  REAL,    INTENT(IN)  :: xs(:)   Vector(ns)   centers of source grid, asc. order
!  REAL,    INTENT(IN)  :: xt(:)   Vector(nt)   centers of target grid, asc. order
!  REAL,    INTENT(OUT) :: vt(*)   Rank>=1      regridded field

  INTERFACE regr_lint
    ! The procedures differ only from the rank of the input/output fields.
    MODULE PROCEDURE regr1_lint, regr2_lint, regr3_lint, &
                     regr4_lint, regr5_lint
  END INTERFACE

  PRIVATE
  PUBLIC :: regr_lint

CONTAINS


!-------------------------------------------------------------------------------
!
SUBROUTINE regr1_lint(ix, vs, xs, xt, vt)
!
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER, INTENT(IN)  :: ix
  REAL,    INTENT(IN)  :: vs(:)
  REAL,    INTENT(IN)  :: xs(:)
  REAL,    INTENT(IN)  :: xt(:)
  REAL,    INTENT(OUT) :: vt(:)
!-------------------------------------------------------------------------------
! Local variables:
  INTEGER :: is, it, ns, nt, isb ! "is" bound between 1 and "ns - 1"
  REAL    :: r
!-------------------------------------------------------------------------------
  CALL check_size(ix,SHAPE(vs),SHAPE(vt),SIZE(xs),SIZE(xt),ns,nt)
  is = -1 ! go immediately to bisection on first call to "hunt"
  DO it=1,SIZE(xt)
    CALL hunt(xs,xt(it),is); isb=MIN(MAX(is,1),ns-1)
    r=(xs(isb+1)-xt(it))/(xs(isb+1)-xs(isb))
    vt(it)=r*vs(isb)+(1.-r)*vs(isb+1)
  END DO

END SUBROUTINE regr1_lint
!
!-------------------------------------------------------------------------------


!-------------------------------------------------------------------------------
!
SUBROUTINE regr2_lint(ix, vs, xs, xt, vt)
!
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER, INTENT(IN)  :: ix
  REAL,    INTENT(IN)  :: vs(:,:)
  REAL,    INTENT(IN)  :: xs(:)
  REAL,    INTENT(IN)  :: xt(:)
  REAL,    INTENT(OUT) :: vt(:,:)
!-------------------------------------------------------------------------------
! Local variables:
  INTEGER :: is, it, ns, nt, isb ! "is" bound between 1 and "ns - 1"
  REAL    :: r
!-------------------------------------------------------------------------------
  CALL check_size(ix,SHAPE(vs),SHAPE(vt),SIZE(xs),SIZE(xt),ns,nt)
  is = -1 ! go immediately to bisection on first call to "hunt"
  DO it=1,SIZE(xt)
    CALL hunt(xs,xt(it),is); isb=MIN(MAX(is,1),ns-1)
    r=(xs(isb+1)-xt(it))/(xs(isb+1)-xs(isb))
    IF(ix==1) vt(it,:)=r*vs(isb,:)+(1.-r)*vs(isb+1,:)
    IF(ix==2) vt(:,it)=r*vs(:,isb)+(1.-r)*vs(:,isb+1)
  END DO

END SUBROUTINE regr2_lint
!
!-------------------------------------------------------------------------------


!-------------------------------------------------------------------------------
!
SUBROUTINE regr3_lint(ix, vs, xs, xt, vt)
!
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER, INTENT(IN)  :: ix
  REAL,    INTENT(IN)  :: vs(:,:,:)
  REAL,    INTENT(IN)  :: xs(:)
  REAL,    INTENT(IN)  :: xt(:)
  REAL,    INTENT(OUT) :: vt(:,:,:)
!-------------------------------------------------------------------------------
! Local variables:
  INTEGER :: is, it, ns, nt, isb ! "is" bound between 1 and "ns - 1"
  REAL    :: r
!-------------------------------------------------------------------------------
  CALL check_size(ix,SHAPE(vs),SHAPE(vt),SIZE(xs),SIZE(xt),ns,nt)
  is = -1 ! go immediately to bisection on first call to "hunt"
  DO it=1,SIZE(xt)
    CALL hunt(xs,xt(it),is); isb=MIN(MAX(is,1),ns-1)
    r=(xs(isb+1)-xt(it))/(xs(isb+1)-xs(isb))
    IF(ix==1) vt(it,:,:)=r*vs(isb,:,:)+(1.-r)*vs(isb+1,:,:)
    IF(ix==2) vt(:,it,:)=r*vs(:,isb,:)+(1.-r)*vs(:,isb+1,:)
    IF(ix==3) vt(:,:,it)=r*vs(:,:,isb)+(1.-r)*vs(:,:,isb+1)
  END DO

END SUBROUTINE regr3_lint
!
!-------------------------------------------------------------------------------


!-------------------------------------------------------------------------------
!
SUBROUTINE regr4_lint(ix, vs, xs, xt, vt)
!
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER, INTENT(IN)  :: ix
  REAL,    INTENT(IN)  :: vs(:,:,:,:)
  REAL,    INTENT(IN)  :: xs(:)
  REAL,    INTENT(IN)  :: xt(:)
  REAL,    INTENT(OUT) :: vt(:,:,:,:)
!-------------------------------------------------------------------------------
! Local variables:
  INTEGER :: is, it, ns, nt, isb ! "is" bound between 1 and "ns - 1"
  REAL    :: r
!-------------------------------------------------------------------------------
  CALL check_size(ix,SHAPE(vs),SHAPE(vt),SIZE(xs),SIZE(xt),ns,nt)
  is = -1 ! go immediately to bisection on first call to "hunt"
  DO it=1,SIZE(xt)
    CALL hunt(xs,xt(it),is); isb=MIN(MAX(is,1),ns-1)
    r=(xs(isb+1)-xt(it))/(xs(isb+1)-xs(isb))
    IF(ix==1) vt(it,:,:,:)=r*vs(isb,:,:,:)+(1.-r)*vs(isb+1,:,:,:)
    IF(ix==2) vt(:,it,:,:)=r*vs(:,isb,:,:)+(1.-r)*vs(:,isb+1,:,:)
    IF(ix==3) vt(:,:,it,:)=r*vs(:,:,isb,:)+(1.-r)*vs(:,:,isb+1,:)
    IF(ix==4) vt(:,:,:,it)=r*vs(:,:,:,isb)+(1.-r)*vs(:,:,:,isb+1)
  END DO

END SUBROUTINE regr4_lint
!
!-------------------------------------------------------------------------------


!-------------------------------------------------------------------------------
!
SUBROUTINE regr5_lint(ix, vs, xs, xt, vt)
!
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER, INTENT(IN)  :: ix
  REAL,    INTENT(IN)  :: vs(:,:,:,:,:)
  REAL,    INTENT(IN)  :: xs(:)
  REAL,    INTENT(IN)  :: xt(:)
  REAL,    INTENT(OUT) :: vt(:,:,:,:,:)
!-------------------------------------------------------------------------------
! Local variables:
  INTEGER :: is, it, ns, nt, isb ! "is" bound between 1 and "ns - 1"
  REAL    :: r
!-------------------------------------------------------------------------------
  CALL check_size(ix,SHAPE(vs),SHAPE(vt),SIZE(xs),SIZE(xt),ns,nt)
  is = -1 ! go immediately to bisection on first call to "hunt"
  DO it=1,SIZE(xt)
    CALL hunt(xs,xt(it),is); isb=MIN(MAX(is,1),ns-1)
    r=(xs(isb+1)-xt(it))/(xs(isb+1)-xs(isb))
    IF(ix==1) vt(it,:,:,:,:)=r*vs(isb,:,:,:,:)+(1.-r)*vs(isb+1,:,:,:,:)
    IF(ix==2) vt(:,it,:,:,:)=r*vs(:,isb,:,:,:)+(1.-r)*vs(:,isb+1,:,:,:)
    IF(ix==3) vt(:,:,it,:,:)=r*vs(:,:,isb,:,:)+(1.-r)*vs(:,:,isb+1,:,:)
    IF(ix==4) vt(:,:,:,it,:)=r*vs(:,:,:,isb,:)+(1.-r)*vs(:,:,:,isb+1,:)
    IF(ix==5) vt(:,:,:,:,it)=r*vs(:,:,:,:,isb)+(1.-r)*vs(:,:,:,:,isb+1)
  END DO

END SUBROUTINE regr5_lint
!
!-------------------------------------------------------------------------------


!-------------------------------------------------------------------------------
!
SUBROUTINE check_size(ix,svs,svt,nxs,nxt,ns,nt)
!
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER, INTENT(IN)  :: ix, svs(:), svt(:), nxs, nxt
  INTEGER, INTENT(OUT) :: ns, nt
!-------------------------------------------------------------------------------
! Local variables:
  INTEGER :: rk, is
  CHARACTER(LEN=80) :: sub, msg
!-------------------------------------------------------------------------------
  rk=SIZE(svs)
  WRITE(sub,'(a,2i0,a)')"regr",rk,ix,"_lint"
  CALL assert(ix>=1.AND.ix<=rk,TRIM(sub)//": ix exceeds fields rank")
  DO is=1,rk; IF(is==ix) CYCLE
    WRITE(msg,'(a,i1)')TRIM(sub)//" n",is
    CALL assert(svs(is)==svt(is),msg)
  END DO
  ns=assert_eq(svs(ix),nxs,TRIM(sub)//" ns")
  nt=assert_eq(svt(ix),nxt,TRIM(sub)//" nt")

END SUBROUTINE check_size
!
!-------------------------------------------------------------------------------

END MODULE regr_lint_m
!
!-------------------------------------------------------------------------------