Ignore:
Timestamp:
Nov 19, 2024, 5:54:18 PM (2 days ago)
Author:
jbclement
Message:

PEM:
Removing unused or redundant Norbert Schorghofer's subroutines (follow-up of r3493) + cleaning and some modifications of related subroutines.
JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/NS_fast_subs_univ.F90

    r3493 r3526  
    5555!***********************************************************************
    5656  use allinterfaces, except_this_one => depths_avmeth
     57  use math_mod, only: deriv2_simple, deriv1_onesided, deriv1, colint
    5758  implicit none
    5859  integer, intent(IN) :: nz, typeT
     
    118119  call deriv1(z,nz,eta(:),1.d0,eta(nz-1),ap)
    119120  if (typeP>0 .and. typeP<nz-2) then
    120      ap_one=deriv1_onesided(typeP,z,nz,eta(:))
     121     call deriv1_onesided(typeP,z,nz,eta(:),ap_one)
    121122     ! print *,typeP,ap(typeP),ap_one
    122123     ap(typeP)=ap_one
     
    151152  endif
    152153  if (typeG>0 .and. typeT<0) then
    153      cumfillabove = colint(porefill(:)/eta(:),z,nz,typeG-1,nz)
     154     call colint(porefill(:)/eta(:),z,nz,typeG-1,nz,cumfillabove)
    154155     newtypeG = -9
    155156     do i=typeG,nz
    156157        if (minval(eta(i:nz))<=0.) cycle  ! eta=0 means completely full
    157         cumfill=colint(porefill(:)/eta(:),z,nz,i,nz)
     158        call colint(porefill(:)/eta(:),z,nz,i,nz,cumfill)
    158159        if (cumfill<yp(i)*18./8314.*B) then  ! usually executes on i=typeG
    159160           if (i>typeG) then
     
    194195
    195196
    196 pure subroutine icechanges_poreonly(nz,z,typeF,typeG,avdrhoP,ypp,B,porefill)
    197   use allinterfaces, except_this_one => icechanges_poreonly
    198   implicit none
    199   integer, intent(IN) :: nz, typeF, typeG
    200   real(8), intent(IN) :: z(nz), ypp(nz), avdrhoP, B
    201   real(8), intent(INOUT) :: porefill(nz)
    202   integer j, erase, newtypeP, ub
    203   real(8) integ
    204  
    205   !----retreat
    206   ! avdrhoP>0 is outward loss from zdepthP
    207   ! avdrhoP<0 means gain at zdepthP or no ice anywhere
    208   if (avdrhoP>0.) then
    209      erase=0
    210      do j=1,nz
    211         if (typeF>0 .and. j>=typeF) exit ! don't retreat beyond typeF
    212         integ = colint(porefill(1:nz)*z(1:nz),z(1:nz),nz,1,j)
    213         erase = j
    214         if (integ>B*avdrhoP*18./8314.) exit
    215      end do
    216      if (erase>0) porefill(1:erase)=0.
    217   endif
    218 
    219   ! new depth
    220   newtypeP = -9
    221   do j=1,nz
    222      if (porefill(j)>0.) then
    223         newtypeP = j  ! first point with ice
    224         exit
    225      endif
    226   enddo
    227 
    228   !----diffusive filling
    229   ub = typeF
    230   if (newtypeP>0 .and. typeF>0 .and. newtypeP<ub) ub=newtypeP
    231   if (ub>0) then 
    232      do j=ub,nz
    233         ! B=Diff/(porosity*icedensity)*86400*365.24*bigstep
    234         porefill(j) = porefill(j) + B*ypp(j)
    235         if (porefill(j)<0.) porefill(j)=0.
    236         if (porefill(j)>1.) porefill(j)=1.
    237      enddo
    238   end if
    239  
    240   !----enact bottom boundary
    241   if (typeG>0) porefill(typeG:nz)=0.
    242  
    243 end subroutine icechanges_poreonly
    244 
    245 
    246 
    247197pure subroutine icechanges(nz,z,typeF,avdrho,avdrhoP,ypp, &
    248198     & Diff,porosity,icefrac,bigstep,zdepthT,porefill,typeG)
     
    254204  use miscparameters, only : icedensity
    255205  use allinterfaces, except_this_one => icechanges
     206  use math_mod, only: colint
    256207  implicit none
    257208  integer, intent(IN) :: nz, typeF, typeG
     
    293244        if (typeF>0 .and. j>=typeF) exit ! don't retreat beyond typeF
    294245        if (zdepthT>=0. .and. z(j)>zdepthT) exit
    295         integ = colint(porefill(1:nz)*z(1:nz),z(1:nz),nz,1,j)
     246        call colint(porefill(1:nz)*z(1:nz),z(1:nz),nz,1,j,integ)
    296247        erase = j
    297248        if (integ>B*avdrhoP*18./8314.) exit
     
    332283  end if
    333284end subroutine icechanges
    334 
    335 
    336 subroutine assignthermalproperties(nz,thIn,rhoc, &
    337      &    ti,rhocv,typeT,icefrac,porosity,porefill)
    338 !*********************************************************
    339 ! assign thermal properties of soil
    340 !*********************************************************
    341   implicit none
    342   integer, intent(IN) :: nz
    343   integer, intent(IN), optional :: typeT
    344   real(8), intent(IN), optional :: icefrac
    345   real(8), intent(IN) :: thIn, rhoc
    346   real(8), intent(IN), optional :: porosity, porefill(nz)
    347   real(8), intent(OUT) :: ti(nz), rhocv(nz)
    348   integer j
    349   real(8) newrhoc, newti, fill
    350   real(8), parameter :: NULL=0.
    351 
    352   ti(1:nz) = thIn
    353   rhocv(1:nz) = rhoc
    354   if (typeT>0) then
    355      call soilthprop(porosity,NULL,rhoc,thIn,2,newrhoc,newti,icefrac)
    356      rhocv(typeT:nz) = newrhoc
    357      ti(typeT:nz) = newti
    358   endif
    359   do j=1,nz
    360      fill = porefill(j)   ! off by half point
    361      if (fill>0. .and. (typeT<0 .or. (typeT>0 .and. j<typeT))) then
    362         call soilthprop(porosity,fill,rhoc,thIn,1,rhocv(j),ti(j),NULL)
    363      endif
    364   enddo
    365 end subroutine assignthermalproperties
    366 
    367 
    368 
    369 subroutine compactoutput(unit,porefill,nz)
    370   implicit none
    371   integer, intent(IN) :: unit,nz
    372   real(8), intent(IN) :: porefill(nz)
    373   integer j
    374   do j=1,nz
    375      if (porefill(j)==0.) then
    376         write(unit,'(1x,f2.0)',advance='no') porefill(j)
    377      else
    378         write(unit,'(1x,f7.5)',advance='no') porefill(j)
    379      endif
    380   enddo
    381   write(unit,"('')")
    382 end subroutine compactoutput
    383 
Note: See TracChangeset for help on using the changeset viewer.