Changeset 3070


Ignore:
Timestamp:
Oct 5, 2023, 11:29:45 AM (14 months ago)
Author:
jbclement
Message:

PEM:
Correction of a bug: the variable 'g' was not correctly initialized in 1D. A little of code cleaning.
JBC

Location:
trunk/LMDZ.COMMON/libf/evolution
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/changelog.txt

    r3068 r3070  
    8686== 03/10/2023 == JBC
    8787Following the commits r3066 and r3067, the PEM initialization in 1D has been adapted.
     88
     89== 05/10/2023 == JBC
     90Correction of a bug: the variable 'g' was not correctly initialized in 1D. A little of code cleaning.
  • trunk/LMDZ.COMMON/libf/evolution/compute_tendencies_slope.F90

    r3039 r3070  
    1 !
    2 ! $Id $
    3 !
    4 SUBROUTINE compute_tendencies_slope(ngrid,nslope,min_ice_Y1,&
    5      min_ice_Y2,tendencies_ice)
     1SUBROUTINE compute_tendencies_slope(ngrid,nslope,min_ice_Y1,min_ice_Y2,tendencies_ice)
    62
    7       IMPLICIT NONE
     3implicit none
    84
    95!=======================================================================
     
    1511!   arguments:
    1612!   ----------
    17 
    1813!   INPUT
    19 
    20      INTEGER, intent(in) :: ngrid, nslope                           ! # of grid points along longitude/latitude/ total
    21      REAL, intent(in) , dimension(ngrid,nslope):: min_ice_Y1       ! LON x LAT field : minimum of water ice at each point for the first year
    22      REAL, intent(in) , dimension(ngrid,nslope):: min_ice_Y2       ! LON x LAT field : minimum of water ice at each point for the second year
     14integer,                       intent(in) :: ngrid, nslope ! # of grid points along longitude/latitude/ total
     15real, dimension(ngrid,nslope), intent(in) :: min_ice_Y1    ! LON x LAT field : minimum of water ice at each point for the first year
     16real, dimension(ngrid,nslope), intent(in) :: min_ice_Y2    ! LON x LAT field : minimum of water ice at each point for the second year
    2317
    2418!   OUTPUT
    25      REAL, intent(out) , dimension(ngrid,nslope)   :: tendencies_ice            ! physical point field : difference between the minima = evolution of perenial ice
    26 
    27 !   local:
    28 !   ------
    29      INTEGER :: ig,islope                                                           ! loop variable
     19real, dimension(ngrid,nslope), intent(out) :: tendencies_ice ! physical point field : difference between the minima = evolution of perenial ice
    3020
    3121!=======================================================================
    3222
    3323!  We compute the difference
    34 
    35   DO ig=1,ngrid
    36     DO islope = 1, nslope
    37       tendencies_ice(ig,islope)=min_ice_Y2(ig,islope)-min_ice_Y1(ig,islope)
    38     enddo
    39   ENDDO
     24tendencies_ice = min_ice_Y2 - min_ice_Y1
    4025
    4126!  If the difference is too small; there is no evolution
    42   DO ig=1,ngrid
    43     DO islope = 1, nslope
    44       if(abs(tendencies_ice(ig,islope)).LT.1.0E-10) then
    45         tendencies_ice(ig,islope)=0.
    46       endif
    47     enddo
    48   ENDDO
     27where (abs(tendencies_ice) < 1.e-10) tendencies_ice = 0.
    4928
    5029END SUBROUTINE compute_tendencies_slope
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3069 r3070  
    3434use logic_mod,                  only: iflag_phys
    3535use mod_const_mpi,              only: COMM_LMDZ
    36 use comconst_mod,               only: rad, g, cpp, pi
    3736use infotrac
    3837use geometry_mod,               only: latitude_deg
     
    7372    use mod_phys_lmdz_para, only: is_parallel, is_sequential, is_mpi_root, is_omp_root, is_master
    7473    use planete_h,          only: aphelie, periheli, year_day, peri_day, obliquit
    75     use comcstfi_h,         only: r, mugaz
     74    use comcstfi_h,         only: r, mugaz, g
    7675    use paleoclimate_mod,   only: albedo_perenialco2
    7776#else
     
    8887    use iniphysiq_mod,    only: iniphysiq
    8988    use control_mod,      only: iphysiq, day_step, nsplit_phys
     89    use comconst_mod,     only: rad, g, cpp, pi
    9090#else
    9191    use time_phylmdz_mod, only: iphysiq, day_step
     92    use comcstfi_h,       only: pi, rad, g, cpp
    9293#endif
    9394
     
    339340! In the gcm, these values are given to the physic by the dynamic.
    340341! Here we simply read them in the startfi_evol.nc file
    341 status =nf90_open(FILE_NAME, NF90_NOWRITE, ncid)
     342status = nf90_open(FILE_NAME, NF90_NOWRITE, ncid)
    342343
    343344status = nf90_inq_varid(ncid,"longitude",lonvarid)
     
    362363                  watercap,perenial_co2ice,def_slope,def_slope_mean,subslope_dist)
    363364
    364 ! Remove unphysical values of surface tracer
    365     do i = 1,ngrid
    366         do nnq = 1,nqtot
    367             do islope = 1,nslope
    368                 if (qsurf(i,nnq,islope) < 0) qsurf(i,nnq,islope) = 0.
    369             enddo
    370         enddo
    371     enddo
     365    ! Remove unphysical values of surface tracer
     366    where (qsurf < 0.) qsurf = 0.
    372367
    373368    call surfini(ngrid,qsurf)
     
    416411    endif
    417412
    418 ! Remove unphysical values of surface tracer
    419     do i = 1,ngrid
    420         do nnq = 1,nqtot
    421             qsurf(i,nnq,1) = qsurf_read_generic(i,nnq)
    422             if (qsurf(i,nnq,1) < 0) qsurf(i,nnq,1) = 0.
    423         enddo
    424     enddo
     413    ! Remove unphysical values of surface tracer
     414    qsurf(:,:,1) = qsurf_read_generic(:,:)
     415    where (qsurf < 0.) qsurf = 0.
    425416#endif
    426417
     
    517508if (soil_pem) then
    518509    call soil_settings_PEM(ngrid,nslope,nsoilmx_PEM,nsoilmx,inertiesoil,TI_PEM)
    519     do l=1,nsoilmx
    520         tsoil_PEM(:,l,:)=tsoil_ave(:,l,:)
    521         tsoil_phys_PEM_timeseries(:,l,:,:)=tsoil_GCM_timeseries(:,l,:,:)
    522         watersoil_density_PEM_timeseries(:,l,:,:)=watersoil_density_timeseries(:,l,:,:)
    523     enddo
    524     do l=nsoilmx+1,nsoilmx_PEM
    525         tsoil_PEM(:,l,:)=tsoil_ave(:,nsoilmx,:)
    526         watersoil_density_PEM_timeseries(:,l,:,:)=watersoil_density_timeseries(:,nsoilmx,:,:)
    527     enddo
    528     watersoil_density_PEM_ave(:,:,:) = SUM(watersoil_density_PEM_timeseries(:,:,:,:),4)/timelen
     510    do l = 1,nsoilmx
     511        tsoil_PEM(:,l,:) = tsoil_ave(:,l,:)
     512        tsoil_phys_PEM_timeseries(:,l,:,:) = tsoil_GCM_timeseries(:,l,:,:)
     513        watersoil_density_PEM_timeseries(:,l,:,:) = watersoil_density_timeseries(:,l,:,:)
     514    enddo
     515    do l = nsoilmx + 1,nsoilmx_PEM
     516        tsoil_PEM(:,l,:) = tsoil_ave(:,nsoilmx,:)
     517        watersoil_density_PEM_timeseries(:,l,:,:) = watersoil_density_timeseries(:,nsoilmx,:,:)
     518    enddo
     519    watersoil_density_PEM_ave(:,:,:) = sum(watersoil_density_PEM_timeseries(:,:,:,:),4)/timelen
    529520endif !soil_pem
    530521deallocate(tsoil_ave,tsoil_GCM_timeseries)
     
    559550Total_surface = 0.
    560551do i = 1,ngrid
    561     Total_surface = Total_surface+cell_area(i)
     552    Total_surface = Total_surface + cell_area(i)
    562553    do islope = 1,nslope
    563554        if (tendencies_co2_ice(i,islope) < 0) then
    564555            initial_co2_ice_sublim(i,islope) = 1.
    565             ini_surf_co2 = ini_surf_co2+cell_area(i)*subslope_dist(i,islope)
     556            ini_surf_co2 = ini_surf_co2 + cell_area(i)*subslope_dist(i,islope)
    566557        else
    567558            initial_co2_ice_sublim(i,islope) = 0.
     
    586577allocate(zplev_gcm(ngrid,nlayer + 1))
    587578
    588 do l = 1,nlayer + 1
    589     do ig = 1,ngrid
    590         zplev_gcm(ig,l) = ap(l) + bp(l)*ps_start_GCM(ig)
    591     enddo
     579do ig = 1,ngrid
     580    zplev_gcm(ig,:) = ap(:) + bp(:)*ps_start_GCM(ig)
    592581enddo
    593582
     
    623612    totmassh2o_adsorbded = 0.
    624613    do ig = 1,ngrid
    625         do islope = 1, nslope
     614        do islope = 1,nslope
    626615            do l = 1,nsoilmx_PEM - 1
    627616                totmassco2_adsorbded = totmassco2_adsorbded + co2_adsorbded_phys(ig,l,islope)*(layer_PEM(l+1) - layer_PEM(l))* &
     
    665654! II.a.1. Compute updated global pressure
    666655    write(*,*) "Recomputing the new pressure..."
    667 
    668656    do i = 1,ngrid
    669657        do islope = 1,nslope
     
    682670
    683671! II.a.2. Old pressure levels for the timeseries, this value is deleted when unused and recreated each time (big memory consuption)
    684     allocate(zplev_old_timeseries(ngrid,nlayer+1,timelen))
     672    allocate(zplev_old_timeseries(ngrid,nlayer + 1,timelen))
    685673    write(*,*) "Recomputing the old pressure levels timeserie adapted to the old pressure..."
    686674    do l = 1,nlayer + 1
     
    721709        do t = 1,timelen
    722710            q_co2_PEM_phys(ig,t) = q_co2_PEM_phys(ig,t)*(zplev_old_timeseries(ig,l,t) - zplev_old_timeseries(ig,l + 1,t))/ &
    723                                    (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t))  &
    724                                 + ((zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t))  &
     711                                   (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t))   &
     712                                + ((zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t))   &
    725713                                -  (zplev_old_timeseries(ig,l,t) - zplev_old_timeseries(ig,l + 1,t)))/ &
    726714                                   (zplev_new_timeseries(ig,l,t) - zplev_new_timeseries(ig,l + 1,t))
     
    881869            enddo
    882870        enddo
    883         tsoil_PEM(:,:,:) = SUM(tsoil_phys_PEM_timeseries(:,:,:,:),4)/timelen
    884         watersoil_density_PEM_ave(:,:,:)= SUM(watersoil_density_PEM_timeseries(:,:,:,:),4)/timelen
     871        tsoil_PEM(:,:,:) = sum(tsoil_phys_PEM_timeseries(:,:,:,:),4)/timelen
     872        watersoil_density_PEM_ave(:,:,:) = sum(watersoil_density_PEM_timeseries(:,:,:,:),4)/timelen
    885873
    886874        write(*,*) "Update of soil temperature done"
     
    893881        call computeice_table_equilibrium(ngrid,nslope,nsoilmx_PEM,watercaptag,watersurf_density_ave,watersoil_density_PEM_ave,TI_PEM(:,1,:),porefillingice_depth,porefillingice_thickness)
    894882
    895         call compute_massh2o_exchange_ssi(ngrid,nslope,nsoilmx_PEM,porefillingice_thickness_prev_iter,porefillingice_thickness,porefillingice_depth,tsoil_PEM, &
    896                                           delta_h2o_icetablesublim)        ! Mass of H2O exchange between the ssi and the atmosphere
     883        call compute_massh2o_exchange_ssi(ngrid,nslope,nsoilmx_PEM,porefillingice_thickness_prev_iter,porefillingice_thickness,porefillingice_depth,tsoil_PEM,delta_h2o_icetablesublim) ! Mass of H2O exchange between the ssi and the atmosphere
    897884
    898885        write(*,*) "Update soil propreties"
    899886
    900887! II_d.4 Update the soil thermal properties
    901         call update_soil_thermalproperties(ngrid,nslope,nsoilmx_PEM,tendencies_h2o_ice,qsurf(:,igcm_h2o_ice,:),global_ave_press_new, &
    902                                            porefillingice_depth,porefillingice_thickness,TI_PEM)
     888        call update_soil_thermalproperties(ngrid,nslope,nsoilmx_PEM,tendencies_h2o_ice,qsurf(:,igcm_h2o_ice,:),global_ave_press_new,porefillingice_depth,porefillingice_thickness,TI_PEM)
    903889
    904890! II_d.5 Update the mass of the regolith adsorbded
     
    914900                    do l = 1,nsoilmx_PEM - 1
    915901                        totmassco2_adsorbded = totmassco2_adsorbded + co2_adsorbded_phys(ig,l,islope)*(layer_PEM(l+1) - layer_PEM(l))* &
    916                         subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.) * &
    917                         cell_area(ig)
     902                        subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    918903                        totmassh2o_adsorbded = totmassh2o_adsorbded + h2o_adsorbded_phys(ig,l,islope)*(layer_PEM(l+1) - layer_PEM(l))* &
    919                         subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.) * &
    920                         cell_area(ig)
     904                        subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    921905                    enddo
    922906                enddo
     
    10771061            do ig = 1,ngrid
    10781062                q(ig,l,nnq) = q(ig,l,nnq)*(zplev_gcm(ig,l) - zplev_gcm(ig,l + 1))/(zplev_new(ig,l) - zplev_new(ig,l + 1)) &
    1079                               + ((zplev_new(ig,l) - zplev_new(ig,l + 1)) - (zplev_gcm(ig,l) - zplev_gcm(ig,l + 1)))/      &
    1080                               (zplev_new(ig,l) - zplev_new(ig,l + 1))
     1063                              + ((zplev_new(ig,l) - zplev_new(ig,l + 1)) - (zplev_gcm(ig,l) - zplev_gcm(ig,l + 1)))/(zplev_new(ig,l) - zplev_new(ig,l + 1))
    10811064            enddo
    10821065            q(:,llm,nnq) = q(:,llm - 1,nnq)
Note: See TracChangeset for help on using the changeset viewer.