Ignore:
Timestamp:
Nov 2, 2023, 4:28:39 PM (14 months ago)
Author:
llange
Message:

MARS PCM
Fixing a bug in soil_settings: oldinertiesoil and oldtsoil were not
allocated if the variables were not in the startfi and an interpolation
was needed
LL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/libf/phymars/soil_settings.F

    r3109 r3110  
    8787! -------------------
    8888
     89
    8990! 1.1 Start by reading how many layers of soil there are
    9091
     
    146147         do iloop=0,nsoil-1
    147148           mlayer(iloop)=lay1*(alpha**(iloop-0.5))
    148         enddo
     149        enddo
    149150      endif
    150151
     
    157158        layer(iloop)=lay1*(alpha**(iloop-1))
    158159      enddo
     160
     161
    159162
    160163! 2. Volumetric heat capacity (note: it is declared in comsoil_h)
     
    241244        write(*,*)' => Building <inertiesoil> from surface values'//
    242245     & ' <inertiedat>'
    243         do islope=1,nslope
    244                 inertiesoil(:,:,islope)=inertiedat(:,:)
    245         enddo
     246! Case 1: No interpolation needed, we just copy past inertiedat
     247        if(.not.(interpol)) then
     248           do islope=1,nslope
     249              inertiesoil(:,:,islope)=inertiedat(:,:)
     250           enddo
     251        else
     252! Case 2: Interpolation needed: we copy past old value from inertiedat
     253           if (.not.allocated(oldinertiesoil)) then
     254              allocate(oldinertiesoil(ngrid,dimlen,nslope),stat=ierr)
     255           endif
     256           do islope=1,nslope
     257              oldinertiesoil(:,:,islope)=oldinertiedat(:,:)
     258           enddo
     259        endif
    246260      else ! <inertiesoil> found
    247261       if (interpol) then ! put values in oldinertiesoil
     
    283297        write(*,*)'soil_settings: Field <tsoil> not found!'
    284298        write(*,*)' => Building <tsoil> from surface values <tsurf>'
    285         do iloop=1,nsoil
    286           do islope=1,nslope
    287             tsoil(:,iloop,islope)=tsurf(:,islope)
     299! Case 1: No interpolation needed, we just copy past inertiedat
     300        if(.not.(interpol)) then
     301          do iloop=1,nsoil
     302            do islope=1,nslope
     303              tsoil(:,iloop,islope)=tsurf(:,islope)
     304            enddo
    288305          enddo
    289         enddo
     306        else
     307! Case 2: Interpolation needed: we copy past old value from inertiedat
     308          if (.not.allocated(oldtsoil)) then
     309             allocate(oldtsoil(ngrid,dimlen,nslope),stat=ierr)
     310          endif
     311          do iloop=1,dimlen
     312            do islope=1,nslope
     313              oldtsoil(:,iloop,islope)=tsurf(:,islope)
     314            enddo
     315          enddo
     316        endif
    290317      else ! <tsoil> found
    291318       if (interpol) then ! put values in oldtsoil
     
    372399           enddo
    373400        enddo ! ig
    374 
    375401       
    376402      ! soil temperature
     
    391417       
    392418        !cleanup
    393          deallocate(oldgrid)
     419          deallocate(oldgrid)
    394420          deallocate(oldval)
    395421          deallocate(newval)
Note: See TracChangeset for help on using the changeset viewer.