Changeset 4068


Ignore:
Timestamp:
Feb 12, 2026, 12:32:15 PM (7 weeks ago)
Author:
jbclement
Message:

PEM:
Following r4065, some safeguards forgotten in "io_netcdf.F90" + 'tsurf' is not needed anymore in the "start1D.txt" + few forgotten small updates.
JBC

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

Legend:

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

    r4065 r4068  
    849849    - "numerics" defines numerical types and constants for reproducibility, portability across compilers and future transitions (e.g. quadruple precision experiments);
    850850    - "display" provides a single controlled interface for runtime messages, status output and diagnostics, avoiding direct 'print'/'write' to enable silent mode, log redirection, and MPI-safe output in the future.
    851     - "utility" (new module) hosts generic helpers used throughout the code (e.g. "int2str" or "real2str");
     851    - "utility" hosts generic helpers used throughout the code (e.g. "int2str" or "real2str");
    852852- Add modules "clim_state_init"/"clim_state_rec" which provide robust read/write logic for "start/startfi/startpem", including 1D fallbacks, mesh conversions and dimension checks. NetCDF file creation is centralized and explicit. Restart files are now self-consistent and future-proof, requiring changes only to affected variables;
    853853- Add module "atmosphere" which computes pressure fields, reconstructs potential temperature and air mass. It also holds the whole logic to define sigma or hybrid coordinates for altitudes;
     
    865865This revision is a structural milestone aiming to be behavior-preserving where possible. It has been tested via compilation and short integration runs. However, due to extensive renames, moves, and API changes, full validation is still ongoing.
    866866Note: the revision includes one (possibly two) easter egg hidden in the code for future archaeologists of the PEM. No physics were harmed.
     867
     868== 12/02/2026 == JBC
     869Following r4065, some safeguards forgotten in "io_netcdf.F90" + 'tsurf' is not needed anymore in the "start1D.txt" + few forgotten small updates.
  • trunk/LMDZ.COMMON/libf/evolution/clim_state_init.F90

    r4065 r4068  
    137137character(30)                   :: header
    138138real(dp), dimension(1,1)        :: tmp
    139 real(dp), dimension(nslope)     :: tmp_1d
    140139real(dp), dimension(1,1,nlayer) :: q_tmp, teta_tmp, wind_tmp
    141140real(dp), dimension(nlayer + 1) :: ap_tmp, bp_tmp
     
    157156
    158157do i = 1,nq
    159     read(funit,*,iostat = ierr) header, (tmp_1d(j),j = 1,nslope), (q_tmp(1,1,k),k = 1,nlayer)
     158    read(funit,*,iostat = ierr) header, (q_tmp(1,1,k),k = 1,nlayer)
    160159    if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'not enough atmospheric layers defined in the file "'//start1D_name//'" for the tracer "'//trim(header)//'"!',1)
    161160    call set_q_PCM(q_tmp,i)
     
    165164read(funit,*,iostat = ierr) header, (wind_tmp(1,1,k),k = 1,nlayer)
    166165call set_v_PCM(wind_tmp)
    167 read(funit,*,iostat = ierr) header, (tmp_1d(j),j = 1,nslope), (teta_tmp(1,1,k),k = 1,nlayer)
     166read(funit,*,iostat = ierr) header, (teta_tmp(1,1,k),k = 1,nlayer)
    168167call set_teta_PCM(teta_tmp)
    169168
  • trunk/LMDZ.COMMON/libf/evolution/clim_state_rec.F90

    r4065 r4068  
    3131
    3232!=======================================================================
    33 SUBROUTINE write_restart(ps4PCM,pa4PCM,preff4PCM,tsurf4PCM,q4PCM,teta4PCM,air_mass4PCM)
     33SUBROUTINE write_restart(ps4PCM,pa4PCM,preff4PCM,q4PCM,teta4PCM,air_mass4PCM)
    3434!-----------------------------------------------------------------------
    3535! NAME
     
    6161real(dp),                   intent(in) :: pa4PCM, preff4PCM
    6262real(dp), dimension(:),     intent(in) :: ps4PCM
    63 real(dp), dimension(:,:),   intent(in) :: tsurf4PCM, teta4PCM, air_mass4PCM
     63real(dp), dimension(:,:),   intent(in) :: teta4PCM, air_mass4PCM
    6464real(dp), dimension(:,:,:), intent(in) :: q4PCM
    6565
     
    7575! ~~~~~~~~~~~~~
    7676if (ngrid == 1) then
    77     call write_restart1D(ps4PCM,pa4PCM,preff4PCM,tsurf4PCM,q4PCM)
     77    call write_restart1D(ps4PCM,pa4PCM,preff4PCM,q4PCM)
    7878    return
    7979end if
     
    120120
    121121!=======================================================================
    122 SUBROUTINE write_restart1D(ps4PCM,pa4PCM,preff4PCM,tsurf4PCM,q4PCM)
     122SUBROUTINE write_restart1D(ps4PCM,pa4PCM,preff4PCM,q4PCM)
    123123!-----------------------------------------------------------------------
    124124! NAME
     
    151151real(dp),                   intent(in) :: pa4PCM, preff4PCM
    152152real(dp), dimension(:),     intent(in) :: ps4PCM
    153 real(dp), dimension(:,:),   intent(in) :: tsurf4PCM
    154153real(dp), dimension(:,:,:), intent(in) :: q4PCM
    155154
     
    170169write(funit,*) 'u', (u_PCM(1,l), l = 1,nlayer)
    171170write(funit,*) 'v', (v_PCM(1,l), l = 1,nlayer)
    172 write(funit,*) 'teta', (tsurf4PCM(1,j), j = 1,nslope), (teta_PCM(1,l), l = 1,nlayer)
     171write(funit,*) 'teta', (teta_PCM(1,l), l = 1,nlayer)
    173172close(funit)
    174173
  • trunk/LMDZ.COMMON/libf/evolution/config.F90

    r4065 r4068  
    7676! LOCAL VARIABLES
    7777! ---------------
    78 logical(k4) :: here, evol_orbit_l, evol_obl_l, evol_ecc_l, evol_lsp_l, do_soil_l, reg_thprop_dependp_l, do_sorption_l, hybrid_alt_coord_l
     78logical(k4) :: here, evol_orbit_l, evol_obl_l, evol_ecc_l, evol_lsp_l, do_soil_l, reg_thprop_dependp_l, do_sorption_l, hybrid
    7979logical(k4) :: icetable_equilibrium_l, icetable_dynamic_l, h2oice_flow_l, co2ice_flow_l, do_layering_l, impose_dust_ratio_l
    8080integer(di) :: output_rate_l
     
    204204
    205205! Read "run_PCM.def" parameters
    206 hybrid_alt_coord_l = .true. ! Default setting
    207 call get_hybrid(hybrid_alt_coord_l)
    208 call set_atmosphere_config(hybrid_alt_coord_l)
     206hybrid = .true. ! Default
     207call get_hybrid(hybrid)
     208call set_atmosphere_config(hybrid)
    209209
    210210! Check incompatibilities
  • trunk/LMDZ.COMMON/libf/evolution/deftank/run_PEM.def

    r4065 r4068  
    102102# dust2ice_ratio=0.1
    103103
    104 # Some definitions for the physics, in file 'callphys.def'
     104# Some definitions for the physics in file "run_PCM.def"
    105105INCLUDEDEF=run_PCM.def
  • trunk/LMDZ.COMMON/libf/evolution/io_netcdf.F90

    r4065 r4068  
    958958call check_nc(nf90_get_att(ncid,varid,"_FillValue",fill_value),'getting fill value',has_fill)
    959959if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    960 if (has_fill .and. var == fill_value) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     960if (has_fill) then
     961    if (var == fill_value) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     962end if
    961963
    962964! Valid range
     
    977979    end if
    978980end if
    979 if (has_range .and. (var < valid_min .or. var > valid_max)) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     981if (has_range) then
     982    if (var < valid_min .or. var > valid_max) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     983end if
    980984
    981985END SUBROUTINE check_valid_var0d_nc
     
    11241128call check_nc(nf90_get_att(ncid,varid,"_FillValue",fill_value),'getting fill value',has_fill)
    11251129if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    1126 if (has_fill .and. any(var == fill_value)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1130if (has_fill) then
     1131    if (any(var == fill_value)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1132end if
    11271133
    11281134! Valid range
     
    11431149    end if
    11441150end if
    1145 if (has_range .and. (any(var < valid_min) .or. any(var > valid_max))) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     1151if (has_range) then
     1152    if (any(var < valid_min) .or. any(var > valid_max)) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     1153end if
    11461154
    11471155END SUBROUTINE check_valid_var2d_nc
     
    12051213call check_nc(nf90_get_att(ncid,varid,"_FillValue",fill_value),'getting fill value',has_fill)
    12061214if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    1207 if (has_fill .and. any(var == fill_value)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1215if (has_fill) then
     1216    if (any(var == fill_value)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1217end if
    12081218
    12091219! Valid range
     
    12241234    end if
    12251235end if
    1226 if (has_range .and. (any(var < valid_min) .or. any(var > valid_max))) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     1236if (has_range) then
     1237    if (any(var < valid_min) .or. any(var > valid_max)) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     1238end if
    12271239
    12281240END SUBROUTINE check_valid_var3d_nc
     
    12861298call check_nc(nf90_get_att(ncid,varid,"_FillValue",fill_value),'getting fill value',has_fill)
    12871299if (.not. has_fill) call check_nc(nf90_get_att(ncid,varid,"missing_value",fill_value),'getting missing value',has_fill)
    1288 if (has_fill .and. any(var == fill_value)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1300if (has_fill) then
     1301    if (any(var == fill_value)) call stop_clean(__FILE__,__LINE__,'Fill values ('//real2str(fill_value)//') detected in '//var_name//'!',1)
     1302end if
    12891303
    12901304! Valid range
     
    13051319    end if
    13061320end if
    1307 if (has_range .and. (any(var < valid_min) .or. any(var > valid_max))) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     1321if (has_range) then
     1322    if(any(var < valid_min) .or. any(var > valid_max)) call stop_clean(__FILE__,__LINE__,'Values outside valid range ('//real2str(valid_min)//','//real2str(valid_max)//') detected in '//var_name//'!',1)
     1323end if
    13081324
    13091325END SUBROUTINE check_valid_var4d_nc
  • trunk/LMDZ.COMMON/libf/evolution/layered_deposits.F90

    r4065 r4068  
    117117d_dust = d_dust_in
    118118dust2ice_ratio = dust2ice_ratio_in
    119 call print_msg('do_layering     = '//bool2str(do_layering))
     119call print_msg('do_layering       = '//bool2str(do_layering))
    120120call print_msg('impose_dust_ratio = '//bool2str(impose_dust_ratio))
    121121call print_msg('d_dust            = '//real2str(d_dust))
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r4065 r4068  
    265265    allocate(character(8) :: num)
    266266end if
    267 allocate(delta_icetable(ngrid),icetable_depth_old(ngrid,nslope),is_co2ice_disappeared(ngrid,nslope))
     267allocate(delta_icetable(ngrid),icetable_depth_old(ngrid,nslope),is_co2ice_disappeared(ngrid,nslope),tsoil_ts_old(ngrid,nsoil,nslope,nday))
    268268is_co2ice_disappeared(:,:) = .false.
    269269delta_icetable(:) = 0._dp
     
    290290        ! Conversion to surface ice
    291291        call layering2surfice(layerings_map,h2o_ice,co2_ice,h2oice_depth)
    292 
    293292    else
    294293        zlag(:,:) = 0._dp
     
    324323
    325324        ! Evolve soil temperature
    326         allocate(tsoil_ts_old(ngrid,nsoil,nslope,nday))
    327325        call evolve_soil_temp(tsoil_avg,tsurf_avg,tsoil_ts,tsoil_ts_old,h2o_soildensity_avg)
    328326
     
    491489
    492490! Write the "start.nc"
    493 call write_restart(ps4PCM,pa4PCM,preff4PCM,tsurf4PCM,q4PCM,teta4PCM,air_mass4PCM)
     491call write_restart(ps4PCM,pa4PCM,preff4PCM,q4PCM,teta4PCM,air_mass4PCM)
    494492
    495493! Update the duration information of the simulation
Note: See TracChangeset for help on using the changeset viewer.