Changeset 4138
- Timestamp:
- Mar 17, 2026, 4:22:44 PM (4 weeks ago)
- Location:
- trunk/LMDZ.COMMON/libf
- Files:
-
- 1 deleted
- 11 edited
- 1 moved
-
evolution/allocation.F90 (modified) (3 diffs)
-
evolution/atmosphere.F90 (modified) (4 diffs)
-
evolution/changelog.txt (modified) (1 diff)
-
evolution/ice_table.F90 (modified) (4 diffs)
-
evolution/job.F90 (moved) (moved from trunk/LMDZ.COMMON/libf/misc/job_id_mod.F90) (1 diff)
-
evolution/maths.F90 (modified) (2 diffs)
-
evolution/orbit.F90 (modified) (1 diff)
-
evolution/pem.F90 (modified) (5 diffs)
-
evolution/soil_temp.F90 (modified) (2 diffs)
-
evolution/stoppage.F90 (modified) (1 diff)
-
evolution/xios_data.F90 (modified) (1 diff)
-
misc/job_timelimit_mod.F90 (deleted)
-
misc/parse_args_mod.F90 (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/allocation.F90
r4065 r4138 25 25 use frost, only: ini_frost, end_frost 26 26 use soil, only: ini_soil, end_soil 27 use ice_table, only: ini_ice_table, end_ice_table28 27 use surf_ice, only: ini_surf_ice, end_surf_ice 29 28 use orbit, only: ini_orbit, end_orbit … … 76 75 call ini_frost() 77 76 call ini_soil() 78 call ini_ice_table()79 77 call ini_surf_ice() 80 78 call ini_orbit() … … 109 107 call end_orbit() 110 108 call end_surf_ice() 111 call end_ice_table()112 109 call end_soil() 113 110 call end_frost() -
trunk/LMDZ.COMMON/libf/evolution/atmosphere.F90
r4134 r4138 408 408 409 409 !======================================================================= 410 SUBROUTINE compute_alt_coord(pa,preff,ap ,bp,aps,bps)410 SUBROUTINE compute_alt_coord(pa,preff,ap_l,bp_l,aps,bps) 411 411 !----------------------------------------------------------------------- 412 412 ! NAME … … 449 449 ! --------- 450 450 real(dp) :: pa, preff 451 real(dp), dimension(nlayer + 1), intent(out) :: ap , bp451 real(dp), dimension(nlayer + 1), intent(out) :: ap_l, bp_l 452 452 real(dp), dimension(nlayer), intent(out), optional :: aps, bps 453 453 454 ! LOCAL VA IRABLES454 ! LOCAL VARIABLES 455 455 ! --------------- 456 456 integer(di) :: i … … 471 471 call compute_hybrid_sig(sig(i),pa,preff,newsig) 472 472 bp(i) = exp(1._dp - 1._dp/(newsig**2)) 473 ap (i) = pa*(newsig - bp(i))473 ap_l(i) = pa*(newsig - bp(i)) 474 474 end do 475 ap (nlayer + 1) = 0._dp475 ap_l(nlayer + 1) = 0._dp 476 476 bp(nlayer + 1) = 0._dp 477 477 else 478 478 call print_msg('> Defining sigma altitude coordinates',LVL_NFO) 479 ap (:) = 0._dp479 ap_l(:) = 0._dp 480 480 bp(1:nlayer) = sig(1:nlayer) 481 481 bp(nlayer + 1) = 0._dp … … 487 487 488 488 do i = 1,nlayer - 1 489 aps(i) = 0.5_dp*(ap (i) + ap(i + 1))489 aps(i) = 0.5_dp*(ap_l(i) + ap_l(i + 1)) 490 490 bps(i) = 0.5_dp*(bp(i) + bp(i + 1)) 491 491 end do -
trunk/LMDZ.COMMON/libf/evolution/changelog.txt
r4136 r4138 918 918 - Temporary memory load reduced in "xios_data". 919 919 - Rename local variables in procedures to avoid masking variables in parent scope. 920 921 == 17/03/2026 == JBC 922 - Move ice table variables from "ice_table" to the main program. 923 - Merge "job_id_mod" and "job_timelimit_mod" into "job" which is relocated to the PEM folder. 924 - Rename local variables in procedures to avoid masking variables in parent scope. 925 - Few cleanings to delete remaining PEM-external "include" and "use". -
trunk/LMDZ.COMMON/libf/evolution/ice_table.F90
r4135 r4138 28 28 logical(k4), protected :: icetable_dynamic ! Flag to compute the icetable depth according to the dynamic method 29 29 30 ! VARIABLES31 ! ---------32 real(dp), allocatable, dimension(:,:) :: icetable_depth ! Depth of the ice table [m]33 real(dp), allocatable, dimension(:,:) :: icetable_thickness ! Thickness of the ice table [m]34 real(dp), allocatable, dimension(:,:,:) :: ice_porefilling ! Amount of porefilling in each layer in each grid [m^3/m^3]35 36 30 contains 37 31 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 38 39 !=======================================================================40 SUBROUTINE ini_ice_table()41 !-----------------------------------------------------------------------42 ! NAME43 ! ini_ice_table44 !45 ! DESCRIPTION46 ! Allocate module arrays for ice table fields.47 !48 ! AUTHORS & DATE49 ! L. Lange50 ! JB Clement, 2023-202551 !52 ! NOTES53 !54 !-----------------------------------------------------------------------55 56 ! DEPENDENCIES57 ! ------------58 use geometry, only: ngrid, nslope, nsoil59 60 ! DECLARATION61 ! -----------62 implicit none63 64 ! CODE65 ! ----66 allocate(icetable_depth(ngrid,nslope))67 allocate(icetable_thickness(ngrid,nslope))68 allocate(ice_porefilling(ngrid,nsoil,nslope))69 icetable_depth(:,:) = 0._dp70 icetable_thickness(:,:) = 0._dp71 ice_porefilling(:,:,:) = 0._dp72 73 END SUBROUTINE ini_ice_table74 !=======================================================================75 76 !=======================================================================77 SUBROUTINE end_ice_table78 !-----------------------------------------------------------------------79 ! NAME80 ! end_ice_table81 !82 ! DESCRIPTION83 ! Deallocate ice table arrays.84 !85 ! AUTHORS & DATE86 ! L. Lange87 ! JB Clement, 2023-202588 !89 ! NOTES90 !91 !-----------------------------------------------------------------------92 93 ! DECLARATION94 ! -----------95 implicit none96 97 ! CODE98 ! ----99 if (allocated(icetable_depth)) deallocate(icetable_depth)100 if (allocated(icetable_thickness)) deallocate(icetable_thickness)101 if (allocated(ice_porefilling)) deallocate(ice_porefilling)102 103 END SUBROUTINE end_ice_table104 !=======================================================================105 32 106 33 !======================================================================= … … 256 183 257 184 !======================================================================= 258 SUBROUTINE compute_deltam_icetable(icetable_ thickness_old,ice_porefilling_old,tsurf,tsoil,delta_icetable)185 SUBROUTINE compute_deltam_icetable(icetable_depth,icetable_thickness,ice_porefilling,icetable_thickness_old,ice_porefilling_old,tsurf,tsoil,delta_icetable) 259 186 !----------------------------------------------------------------------- 260 187 ! NAME … … 286 213 ! ARGUMENTS 287 214 ! --------- 288 real(dp), dimension(:,:), intent(in) :: icetable_thickness_old ! Ice table thickness at the previous iteration [m] 289 real(dp), dimension(:,:,:), intent(in) :: ice_porefilling_old ! Ice pore filling at the previous iteration [m] 290 real(dp), dimension(:,:), intent(in) :: tsurf ! Surface temperature [K] 291 real(dp), dimension(:,:,:), intent(in) :: tsoil ! Soil temperature [K] 292 real(dp), dimension(:), intent(out) :: delta_icetable ! Mass of H2O ice that has been condensed on the ice table / sublimates from the ice table [kg/m^2] 215 real(dp), dimension(:,:), intent(in) :: icetable_depth ! Ice table depth [m] 216 real(dp), dimension(:,:), intent(in) :: icetable_thickness ! Ice table thickness [m] 217 real(dp), dimension(:,:,:), intent(in) :: ice_porefilling ! Ice pore filling [m] 218 real(dp), dimension(:,:), intent(in) :: icetable_thickness_old ! Ice table thickness at the previous iteration [m] 219 real(dp), dimension(:,:,:), intent(in) :: ice_porefilling_old ! Ice pore filling at the previous iteration [m] 220 real(dp), dimension(:,:), intent(in) :: tsurf ! Surface temperature [K] 221 real(dp), dimension(:,:,:), intent(in) :: tsoil ! Soil temperature [K] 222 real(dp), dimension(:), intent(out) :: delta_icetable ! Mass of H2O ice that has been condensed on the ice table / sublimates from the ice table [kg/m^2] 293 223 294 224 ! LOCAL VARIABLES … … 674 604 675 605 ! Mass of H2O exchange between the ssi and the atmosphere 676 call compute_deltam_icetable(icetable_ thickness_old,ice_porefilling_old,tsurf_avg,tsoil_avg,delta_icetable)606 call compute_deltam_icetable(icetable_depth,icetable_thickness,ice_porefilling,icetable_thickness_old,ice_porefilling_old,tsurf_avg,tsoil_avg,delta_icetable) 677 607 678 608 END SUBROUTINE evolve_ice_table -
trunk/LMDZ.COMMON/libf/evolution/job.F90
r4137 r4138 1 MODULE job _id_mod1 MODULE job 2 2 3 !*********************************************************************** 4 ! DESCRIPTION: 5 ! Retrieves the ID for a given job ID via SLURM or PBS/TORQUE. 6 !*********************************************************************** 3 !----------------------------------------------------------------------- 4 ! NAME 5 ! job 6 ! 7 ! DESCRIPTION 8 ! Management of memory throughout the modules of the code. 9 ! 10 ! AUTHORS & DATE 11 ! JB Clement, 10/06/2024 12 ! 13 ! NOTES 14 ! 15 !----------------------------------------------------------------------- 7 16 17 ! DEPENDENCIES 18 ! ------------ 19 use numerics, only: dp, di, k4 20 21 ! DECLARATION 22 ! ----------- 8 23 implicit none 9 24 25 ! PARAMETERS 26 ! ---------- 27 real(dp) :: timelimit = 86400._dp ! Time limit for the job: 86400 s = 24 h by default 28 real(dp), parameter :: antetime = 3600._dp ! Anticipation time to prevent reaching the job time limit: 3600 s = 1 h by default 29 logical(k4) :: timewall = .false. ! Flag to enable the program self-termination before timeout 30 31 contains 32 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 33 10 34 !======================================================================= 11 contains 12 !======================================================================= 35 SUBROUTINE get_job_id(jobid) 36 !----------------------------------------------------------------------- 37 ! NAME 38 ! get_job_id 39 ! 40 ! DESCRIPTION 41 ! Retrieves the ID for a given job ID via SLURM or PBS/TORQUE. 42 ! 43 ! AUTHORS & DATE 44 ! JB Clement, 10/06/2024 45 ! 46 ! NOTES 47 ! 48 !----------------------------------------------------------------------- 13 49 14 SUBROUTINE get_job_id(jobid) 50 ! DEPENDENCIES 51 ! ------------ 52 use stoppage, only: stop_clean 15 53 54 ! DECLARATION 55 ! ----------- 16 56 implicit none 17 57 18 !---- Arguments 58 ! ARGUMENTS 59 ! --------- 19 60 character(256), intent(out) :: jobid 20 61 21 !---- Variables 22 integer :: stat 62 ! LOCAL VARIABLES 63 ! --------------- 64 integer(di) :: sts 23 65 character(256) :: tmp 24 66 25 !---- Code 67 ! CODE 68 ! ---- 26 69 ! Try SLURM 27 call get_environment_variable("SLURM_JOBID",tmp,status = st at)28 if (st at== 0 .and. len_trim(tmp) > 0) then70 call get_environment_variable("SLURM_JOBID",tmp,status = sts) 71 if (sts == 0 .and. len_trim(tmp) > 0) then 29 72 jobid = trim(adjustl(tmp)) 30 73 return 31 74 endif 32 75 33 76 ! Try PBS/TORQUE 34 call get_environment_variable("PBS_JOBID",tmp,status = st at)35 if (st at== 0 .and. len_trim(tmp) > 0) then77 call get_environment_variable("PBS_JOBID",tmp,status = sts) 78 if (sts == 0 .and. len_trim(tmp) > 0) then 36 79 ! Extract only the part before the point in '12345.master.cluster' to get the numeric job ID 37 80 jobid = trim(adjustl(tmp(1:index(tmp,'.') - 1))) 38 81 return 39 82 endif 40 41 error stop 'Error: neither SLURM_JOB_ID nor PBS_JOBID found in environment!' 83 84 call stop_clean(__FILE__,__LINE__,"neither SLURM_JOB_ID nor PBS_JOBID found in environment!",1) 42 85 43 86 END SUBROUTINE get_job_id 87 !======================================================================= 44 88 45 END MODULE job_id_mod 89 !======================================================================= 90 SUBROUTINE get_job_timelimit(jobid) 91 !----------------------------------------------------------------------- 92 ! NAME 93 ! get_job_timelimit 94 ! 95 ! DESCRIPTION 96 ! Retrieves the time limit (in seconds) for a given job ID via SLURM 97 ! or PBS/TORQUE. 98 ! 99 ! AUTHORS & DATE 100 ! JB Clement, 10/06/2024 101 ! 102 ! NOTES 103 ! 104 !----------------------------------------------------------------------- 105 106 ! DEPENDENCIES 107 ! ------------ 108 use stoppage, only: stop_clean 109 110 ! DECLARATION 111 ! ----------- 112 implicit none 113 114 ! ARGUMENTS 115 ! --------- 116 character(*), intent(in) :: jobid 117 118 ! LOCAL VARIABLES 119 ! --------------- 120 logical(k4) :: num_str 121 character(256) :: chtimelimit ! Time limit for the job outputted by the SLURM or PBS/TORQUE command 122 integer(di) :: i, ierr, funit, cstat, days, hours, minutes, seconds 123 character(1) :: sep 124 125 ! CODE 126 ! ---- 127 ! Check that the job ID is numeric 128 num_str = .true. 129 do i = 1,len_trim(jobid) 130 if (jobid(i:i) < '0' .or. jobid(i:i) > '9') then 131 num_str = .false. 132 exit 133 endif 134 enddo 135 if (.not. num_str) call stop_clean(__FILE__,__LINE__,"job ID must be numeric!",1) 136 137 ! Try SLURM (squeue) 138 call execute_command_line('squeue -j '//trim(adjustl(jobid))//' -h --Format TimeLimit > tmp_timelimit.txt',cmdstat = cstat) 139 if (cstat /= 0) then 140 ! On failure, try PBS/TORQUE (qstat) 141 call execute_command_line('qstat -f '//trim(adjustl(jobid))//' | grep "Walltime" | awk ''{print $3}'' > tmp_timelimit.txt',cmdstat = cstat) 142 if (cstat > 0) then 143 call stop_clean(__FILE__,__LINE__,'command execution failed!',1) 144 else if (cstat < 0) then 145 call stop_clean(__FILE__,__LINE__,'command execution not supported (neither SLURM nor PBS/TORQUE is installed)!',1) 146 endif 147 endif 148 149 ! Read the output 150 open(newunit = funit,file = 'tmp_timelimit.txt',status = 'old',form = 'formatted',action = 'read',iostat = ierr) 151 if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "tmp_timelimit.txt"!',ierr) 152 read(funit,'(a)') chtimelimit 153 close(funit) 154 chtimelimit = trim(adjustl(chtimelimit)) 155 156 ! Remove temporary file 157 call execute_command_line('rm tmp_timelimit.txt',cmdstat = cstat) 158 if (cstat > 0) then 159 call stop_clean(__FILE__,__LINE__,'command execution failed!',1) 160 else if (cstat < 0) then 161 call stop_clean(__FILE__,__LINE__,'command execution not supported!',1) 162 endif 163 164 ! Parse D-HH:MM:SS, HH:MM:SS or MM:SS 165 if (index(chtimelimit,'-') > 0) then ! Format "D-HH:MM:SS" 166 read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds 167 timelimit = real(days,dp)*86400._dp + real(hours,dp)*3600._dp + real(minutes,dp)*60._dp + real(seconds,dp) 168 else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! Format "HH:MM:SS" 169 read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds 170 timelimit = real(hours,dp)*3600._dp + real(minutes,dp)*60._dp + real(seconds,dp) 171 else ! Format "MM:SS" 172 read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds 173 timelimit = real(minutes,dp)*60._dp + real(seconds,dp) 174 endif 175 176 timewall = .true. 177 178 END SUBROUTINE get_job_timelimit 179 !======================================================================= 180 181 END MODULE job -
trunk/LMDZ.COMMON/libf/evolution/maths.F90
r4110 r4138 301 301 integer(di) :: i 302 302 real(dp) :: m 303 real(dp), dimension(n) :: c p, dp303 real(dp), dimension(n) :: c_p, d_p 304 304 305 305 ! CODE … … 323 323 324 324 ! Initialization 325 c p(1) = c(1)/b(1)326 d p(1) = d(1)/b(1)325 c_p(1) = c(1)/b(1) 326 d_p(1) = d(1)/b(1) 327 327 328 328 ! Forward sweep 329 329 do i = 2,n - 1 330 m = b(i) - a(i - 1)*c p(i - 1)331 c p(i) = c(i)/m332 d p(i) = (d(i) - a(i - 1)*dp(i - 1))/m333 end do 334 m = b(n) - a(n - 1)*c p(n - 1)335 d p(n) = (d(n) - a(n - 1)*dp(n - 1))/m330 m = b(i) - a(i - 1)*c_p(i - 1) 331 c_p(i) = c(i)/m 332 d_p(i) = (d(i) - a(i - 1)*d_p(i - 1))/m 333 end do 334 m = b(n) - a(n - 1)*c_p(n - 1) 335 d_p(n) = (d(n) - a(n - 1)*d_p(n - 1))/m 336 336 337 337 ! Backward substitution 338 x(n) = d p(n)338 x(n) = d_p(n) 339 339 do i = n - 1,1,-1 340 x(i) = d p(i) - cp(i)*x(i + 1)340 x(i) = d_p(i) - c_p(i)*x(i + 1) 341 341 end do 342 342 -
trunk/LMDZ.COMMON/libf/evolution/orbit.F90
r4134 r4138 578 578 !----------------------------------------------------------------------- 579 579 580 use evolution, only: pem_ini_date 581 use call_dayperi_mod, only: call_dayperi 582 use stoppage, only: stop_clean 583 use display, only: print_msg, LVL_NFO 584 use utility, only: real2str 580 use evolution, only: pem_ini_date 581 use stoppage, only: stop_clean 582 use display, only: print_msg, LVL_NFO 583 use utility, only: real2str 585 584 586 585 ! DECLARATION -
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r4134 r4138 19 19 ! ------------ 20 20 ! Common modules 21 use job_timelimit_mod, only: timelimit, antetime, timewall22 21 use parse_args_mod, only: parse_args 23 ! PEM modules 22 24 23 use allocation, only: ini_allocation, end_allocation 25 24 use atmosphere, only: ps_PCM, evolve_pressure, CO2cond_ps_PCM … … 31 30 use geometry, only: ngrid, nslope, nday, nsoil_PCM, nsoil, cell_area, total_surface, nlayer 32 31 use glaciers, only: h2oice_flow, co2ice_flow, flow_co2glaciers, flow_h2oglaciers 33 use ice_table, only: icetable_equilibrium, icetable_dynamic, icetable_depth, icetable_thickness, ice_porefilling, evolve_ice_table 32 use ice_table, only: icetable_equilibrium, icetable_dynamic, evolve_ice_table 33 use job, only: timelimit, antetime, timewall 34 34 use layered_deposits, only: layering, do_layering, del_layering, evolve_layering, ptrarray, layering2surfice, surfice2layering, print_layering 35 35 use maths, only: pi … … 103 103 real(dp), dimension(:,:,:), allocatable :: h2o_ads_reg ! H2O adsorbed in the regolith [kg/m^2] 104 104 real(dp), dimension(:,:,:), allocatable :: co2_ads_reg ! CO2 adsorbed in the regolith [kg/m^2] 105 real(dp), dimension(:,:), allocatable :: icetable_depth ! Depth of the ice table [m] 106 real(dp), dimension(:,:), allocatable :: icetable_thickness ! Thickness of the ice table [m] 107 real(dp), dimension(:,:,:), allocatable :: ice_porefilling ! Amount of porefilling [m^3/m^3] 105 108 real(dp), dimension(:,:), allocatable :: icetable_depth_old ! Old depth of the ice table [m] 106 109 real(dp), dimension(:), allocatable :: delta_icetable ! Total mass of the H2O that has sublimated / condenses from the ice table [kg] … … 191 194 ! Read the "startevo.nc" 192 195 allocate(h2o_ice(ngrid,nslope),co2_ice(ngrid,nslope)) 196 allocate(icetable_depth(ngrid,nslope),icetable_thickness(ngrid,nslope),ice_porefilling(ngrid,nsoil,nslope)) 193 197 allocate(h2o_ads_reg(ngrid,nsoil,nslope),co2_ads_reg(ngrid,nsoil,nslope),delta_h2o_ads(ngrid),delta_co2_ads(ngrid)) 194 198 allocate(layerings_map(ngrid,nslope)) 199 icetable_depth(:,:) = 0._dp 200 icetable_thickness(:,:) = 0._dp 201 ice_porefilling(:,:,:) = 0._dp 195 202 delta_h2o_ads(:) = 0._dp 196 203 delta_co2_ads(:) = 0._dp … … 485 492 deallocate(d_h2oice,d_co2ice,d_co2ice_ini) 486 493 deallocate(delta_h2o_ads,delta_co2_ads,delta_icetable,icetable_depth_old) 494 deallocate(icetable_depth,icetable_thickness,ice_porefilling) 487 495 call end_allocation() 488 496 -
trunk/LMDZ.COMMON/libf/evolution/soil_temp.F90
r4135 r4138 179 179 ! ----------- 180 180 implicit none 181 182 #include "dimensions.h"183 181 184 182 ! ARGUMENTS … … 297 295 ! ----------- 298 296 implicit none 299 300 #include "dimensions.h"301 297 302 298 ! ARGUMENTS -
trunk/LMDZ.COMMON/libf/evolution/stoppage.F90
r4110 r4138 55 55 implicit none 56 56 57 #include "iniprint.h"58 59 57 ! ARGUMENTS 60 58 ! --------- -
trunk/LMDZ.COMMON/libf/evolution/xios_data.F90
r4136 r4138 194 194 end do 195 195 end do 196 ! Keep deep layers consistent with PCM bottom layer when nsoil > nsoil_PCM. 197 h2o_soildensity_avg(:,nsoil_PCM + 1:nsoil,islope) = h2o_soildensity_avg(:,nsoil_PCM,islope) 196 do isoil = nsoil_PCM + 1,nsoil 197 h2o_soildensity_avg(:,isoil,islope) = h2o_soildensity_avg(:,nsoil_PCM,islope) ! Explicit initialization because dimension with size nsoil > nsoil_PCM 198 end do 198 199 end do 199 200 h2o_soildensity_avg(:,:,:) = h2o_soildensity_avg(:,:,:)/real(nday,dp) -
trunk/LMDZ.COMMON/libf/misc/parse_args_mod.F90
r4003 r4138 14 14 use pgrm_version_mod, only: print_pgrm_version 15 15 #endif 16 use job_id_mod, only: get_job_id 17 use job_timelimit_mod, only: get_job_timelimit 16 use job, only: get_job_id, get_job_timelimit 18 17 19 18 implicit none
Note: See TracChangeset
for help on using the changeset viewer.
