Changeset 3666 for trunk/LMDZ.COMMON


Ignore:
Timestamp:
Feb 28, 2025, 5:51:32 PM (4 months ago)
Author:
jbclement
Message:

PEM:

  • Adjusments of few scripts to handle more situations.
  • Bug correction related to deallocation in case of "soil_pem = .false." or "layering_algo = .true.".

JBC

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

Legend:

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

    r3649 r3666  
    609609== 26/02/2025 == JBC
    610610Correction and simplification of the numbering of jobs/runs in the launching script.
     611
     612== 28/02/2025 == JBC
     613- Adjusments of few scripts to handle more situations.
     614- Bug correction related to deallocation in case of "soil_pem = .false." or "layering_algo = .true.".
  • trunk/LMDZ.COMMON/libf/evolution/compute_soiltemp_mod.F90

    r3610 r3666  
    246246real, dimension(ngrid,nsoil,nslope) :: tsoil_old
    247247
    248 write(*,*)"Shifting soil temperature to surface"
     248write(*,*) "> Shifting soil temperature profile to match surface evolution"
    249249tsoil_old = tsoil
    250250
  • trunk/LMDZ.COMMON/libf/evolution/deftank/inipem_orbit.sh

    r3579 r3666  
    1515# Name of the file containing the orbital data
    1616orb_data="obl_ecc_lsp.asc"
     17
     18# Name of the file containing the starting date (Earth years)
     19date_file="run_PEM.def"
    1720######################################################################
    1821
     
    2326    exit 1
    2427fi
    25 if [ ! -f "startfi.nc" ]; then
     28if [ ! -f "$name_file" ]; then
    2629    echo "Error: file \"$name_file\" not found!"
    2730    exit 1
    2831fi
    29 if [ ! -f "run_PEM.def" ]; then
    30     echo "Error: file \"run_PEM.def\" not found!"
     32if [ ! -f "$date_file" ]; then
     33    echo "Error: file \"$date_file\" not found!"
    3134    exit 1
    3235fi
    3336
    34 # Get the number of Earth years before present to start the PEM run from "run_PEM.def"
    35 eyears_bp_ini=$(grep 'year_earth_bp_ini=' run_PEM.def | cut -d '=' -f 2 | tr -d '[:space:]')
    36 echo "The starting date is $eyears_bp_ini Earth years according to \"run_PEM.def\"."
     37# Get the number of Earth years before present to start the PEM run
     38eyears_bp_ini=$(grep 'year_earth_bp_ini=' $date_file | cut -d '=' -f 2 | tr -d '[:space:]')
     39echo "In \"$date_file\":"
     40echo "The starting date is $eyears_bp_ini Earth years."
    3741
    3842# Get the new values for the orbital parameters
     
    5862        fi
    5963        new_Lsp=$(echo "($lsp2 - $lsp1)/($y2 - $y1)*($yearlask - $y1) + $lsp1" | bc -l)
    60         echo "New obliquity    = $new_obl"
    61         echo "New eccentricity = $new_ecc"
    62         echo "New Lsp          = $new_Lsp"
    63         echo "Done!"
     64        echo "In \"$orb_data\":"
     65        echo "Found obliquity    = $new_obl"
     66        echo "Found eccentricity = $new_ecc"
     67        echo "Found Lsp          = $new_Lsp"
    6468        break
    6569    fi
     
    9599peri_day=$(echo "$year_day*(1. - ($zx0 - $new_ecc*s($zx0))/(2.*$pi))" | bc -l)
    96100
    97 ztheta=$(echo "($new_iniLs - $new_Lsp)/$degrad" | bc -l)
    98 tan=$(echo "s(0.5*$ztheta)/c(0.5*$ztheta)" | bc -l)
    99 zx0=$(echo "2.*a($tan*sqrt((1. - $new_ecc)/(1. + $new_ecc)))" | bc -l)
    100 xref=$(echo "$zx0 - $new_ecc*s($zx0)" | bc -l)
    101 new_inisol=$(echo "$peri_day + $xref*$year_day/(2.*$pi)" | bc -l)
    102 if [ $(echo "$new_inisol < 0." | bc -l) -eq 1 ]; then
    103     new_inisol=$(echo "$new_inisol + $year_day" | bc -l)
    104 fi
    105 if [ $(echo "$new_inisol >= $year_day" | bc -l) -eq 1 ]; then
    106     new_inisol=$(echo "$new_inisol - $year_day" | bc -l)
    107 fi
    108 
    109101# Update the netCDF file
    110102# controle(15) = periheli ! min. Sun-Mars distance (Mkm)  ̃206.66
     
    117109         -s "controle(15)=$aphelie" \
    118110         -s "controle(16)=$peri_day" \
    119          -s "controle(2)=$new_inisol" \
    120111         $name_file $name_file
    121112
     
    123114echo "New obliquit     = $new_obl"
    124115echo "New eccentricity = $new_ecc -> new periheli = $periheli"
    125 echo "                              -> new aphelie  = $aphelie"
     116echo "                                         -> new aphelie  = $aphelie"
    126117echo "New Lsp          = $new_Lsp -> new peri_day = $peri_day"
    127 echo "New initial Ls   = $new_iniLs -> New initial sol = $new_inisol"
    128118echo "Done!"
  • trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh

    r3649 r3666  
    181181        else # Mode: submitting jobs
    182182            cp PCMrun.job PCMrun${iPCM}.job
    183             sed -i -E "s/($name_job[^0-9]*)[0-9]+([^0-9]*)$/\1${iPCM}\2/" PCMrun${iPCM}.job
     183            sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPCM}\3/" PCMrun${iPCM}.job
    184184            sed -i "s/^k=[0-9]\+$/k=$(echo "$ii - $3 + 2" | bc)/" PCMrun${iPCM}.job
    185185            jobID=$(eval "$submit_job PCMrun${iPCM}.job")
     
    208208            else # Mode: submitting jobs
    209209                cp PCMrun.job PCMrun${iPCM}.job
    210                 sed -i -E "s/($name_job[^0-9]*)[0-9]+([^0-9]*)$/\1${iPCM}\2/" PCMrun${iPCM}.job
     210                sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPCM}\3/" PCMrun${iPCM}.job
    211211                sed -i "s/^k=[0-9]\+$/k=$(echo "$i - $3 + 2" | bc)/" PCMrun${iPCM}.job
    212212                jobID=$(eval "$submit_dependjob=afterok:${jobID} PCMrun${iPCM}.job")
     
    234234            fi
    235235        else # Mode: submitting jobs
    236             sed -i -E "s/($name_job[^0-9]*)[0-9]+([^0-9]*)$/\1${iPEM}\2/" PEMrun.job
     236            sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPEM}\3/" PEMrun.job
    237237            jobID=$(eval "$submit_job PEMrun.job")
    238238            # Create a file to cancel the dependent jobs of the cycle
     
    264264            fi
    265265        else # Mode: submitting jobs
    266             sed -i -E "s/($name_job[^0-9]*)[0-9]+([^0-9]*)$/\1${iPEM}\2/" PEMrun.job
     266            sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPEM}\3/" PEMrun.job
    267267            jobID=$(eval "$submit_dependjob=afterok:${jobID} PEMrun.job")
    268268            echo $kill_job $jobID >> kill_launchPEM.sh
  • trunk/LMDZ.COMMON/libf/evolution/deftank/visu_evol_layering.py

    r3460 r3666  
    151151### Processing
    152152stratif_data, max_top_elevation, longitude, latitude = process_files(folder_path,base_name)
     153if dz > max_top_elevation:
     154    print('The discretization step is higher than the maximum top elevation: please provide a correct value!')
     155    exit()
    153156ref_grid, gridded_stratif_data = interpolate_data(stratif_data,max_top_elevation,dz)
    154157date_time = read_infofile(infofile)
  • trunk/LMDZ.COMMON/libf/evolution/layering_mod.F90

    r3638 r3666  
    125125
    126126! Verification of volume fraction
    127 if (abs(1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac + str%air_volfrac)) > tol) &
    128      error stop 'add_stratum: properties for the new stratum are not possible (sum of volumetric fraction /= 1)!'
     127if (abs(1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac + str%air_volfrac)) > tol) then
     128    call print_stratum(str)
     129    error stop 'add_stratum: properties for the new stratum are not possible (sum of volumetric fraction /= 1)!'
     130endif
    129131
    130132! Increment the number of strata
     
    178180
    179181    ! Verification of volume fraction
    180     if (abs(1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac + str%air_volfrac)) > tol) &
    181          error stop 'insert_stratum: properties for the new stratum are not possible (sum of volumetric fraction /= 1)!'
     182    if (abs(1. - (str%co2ice_volfrac + str%h2oice_volfrac + str%dust_volfrac + str%air_volfrac)) > tol) then
     183        call print_stratum(str)
     184        error stop 'add_stratum: properties for the new stratum are not possible (sum of volumetric fraction /= 1)!'
     185    endif
    182186
    183187    ! Increment the number of strata
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3649 r3666  
    893893    if (soil_pem) then
    894894! II_d.2 Shifting soil temperature to surface
    895         write(*,*) "> Shifting soil temperature profile to match surface evolution"
    896895        call shift_tsoil2surf(ngrid,nsoilmx_PEM,nslope,zshift_surf,zlag,tsurf_avg,tsoil_PEM)
    897         deallocate(zshift_surf,zlag)
    898896
    899897! II_d.3 Update soil temperature
     
    977975        endif
    978976    endif !soil_pem
     977    deallocate(zshift_surf,zlag)
    979978
    980979!------------------------
     
    10221021    !    enddo
    10231022    !enddo
    1024     deallocate(vmr_co2_PEM_phys,icetable_depth_old,tsoil_PEM_timeseries_old)
     1023    if (soil_pem) deallocate(icetable_depth_old,tsoil_PEM_timeseries_old)
     1024    deallocate(vmr_co2_PEM_phys)
    10251025
    10261026!------------------------
     
    10711071deallocate(d_co2ice,d_co2ice_ini,d_h2oice)
    10721072deallocate(is_co2ice_ini,is_co2ice_sublim_ini,is_h2oice_sublim_ini)
    1073 if (layering_algo) then
    1074     do islope = 1,nslope
    1075         do i = 1,ngrid
    1076             call del_layering(stratif(i,islope))
    1077         enddo
    1078     enddo
    1079     deallocate(new_str,new_lag1,new_lag2,current1,current2)
    1080 endif
     1073if (layering_algo) deallocate(new_str,new_lag1,new_lag2,current1,current2)
    10811074!------------------------------ END RUN --------------------------------
    10821075
  • trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90

    r3602 r3666  
    139139        if (.not. found) then
    140140            write(*,*) 'Pemetat0: failed loading <nb_str_max>!'
    141             write(*,*) '''nb_str_max'' is set to 3!'
     141            write(*,*) '''nb_str_max'' is set to 1!'
    142142        else
    143143            nb_str_max = int(inquire_dimension_length('nb_str_max'))
Note: See TracChangeset for help on using the changeset viewer.