Ignore:
Timestamp:
Feb 12, 2024, 5:37:25 PM (10 months ago)
Author:
jbclement
Message:

PEM:

  • It is now possible to set the number of initial PCM calls independently of the number of "inter-PEM" PCM calls. It is useful to get a stable situation for the start of the simulation.
  • Correction of a bug: 'reshape_XIOS_output' treated the first two PCM runs instead of the last two. The numbering has been adapted in "launch_pem.sh" to get it right.
  • PEM outputs ("diagpem.nc" and "diagsoil_pem.nc") has been improved: 'Time' now evolves according to 'dt_pem' (usually year by year) and 'ecritpem' is a full variable of "time_evol_mod.F90".

JBC

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

Legend:

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

    r3210 r3214  
    236236- Addition in the deftank of a bash script "modify_startfi_var.sh" to modify the value of a variable in a "startfi.nc".
    237237- Small corrections due to r3206.
     238
     239== 12/02/2024 == JBC
     240- It is now possible to set the number of initial PCM calls independently of the number of "inter-PEM" PCM calls. It is useful to get a stable situation for the start of the simulation.
     241- Correction of a bug: 'reshape_XIOS_output' treated the first two PCM runs instead of the last two. The numbering has been adapted in "launch_pem.sh" to get it right.
     242- PEM outputs ("diagpem.nc" and "diagsoil_pem.nc") has been improved: 'Time' now evolves according to 'dt_pem' (usually year by year) and 'ecritpem' is a full variable of "time_evol_mod.F90".
  • trunk/LMDZ.COMMON/libf/evolution/conf_pem.F90

    r3210 r3214  
    2424
    2525use time_evol_mod,         only: year_bp_ini, dt_pem, h2o_ice_crit, co2_ice_crit, ps_criterion, Max_iter_pem, &
    26                           evol_orbit_pem, var_obl, var_ecc, var_lsp, convert_years
     26                          evol_orbit_pem, var_obl, var_ecc, var_lsp, convert_years, ecritpem
    2727use comsoil_h_pem,         only: soil_pem, fluxgeo, ini_huge_h2oice, depth_breccia, depth_bedrock, reg_thprop_dependp
    2828use adsorption_mod,        only: adsorption_pem
    2929use glaciers_mod,          only: h2oice_flow, co2ice_flow, inf_h2oice_threshold, metam_co2ice_threshold, metam_h2oice_threshold, metam_h2oice, metam_co2ice
    3030use ice_table_mod,         only: icetable_equilibrium, icetable_dynamic
    31 use time_phylmdz_mod,      only: ecritphy
    3231
    3332implicit none
     
    5453!#---------- Output parameters ----------#
    5554! Frequency of outputs for the PEM
    56 ecritphy = 1 ! Default value: every year
    57 call getin('ecritpem',ecritphy)
     55ecritpem = 1 ! Default value: every year
     56call getin('ecritpem',ecritpem)
    5857
    5958!#---------- Orbital parameters ----------#
  • trunk/LMDZ.COMMON/libf/evolution/deftank/concat_diagpem.sh

    r3210 r3214  
    1010ecritpem=1
    1111
     12# Number of initial PCM calls
     13nPCM_ini=4
     14
    1215# Number of GCM calls between each PEM call
    13 nGCM=2
     16nPCM=2
    1417
    1518# List of NetCDF files to concatenate
     
    3437
    3538# Loop to concatenate the NetCDF files
    36 newTime=$((nGCM + 1))
     39newTime=$((nPCM_ini + 1))
    3740for file in "${files[@]}"; do
    3841    # Extract the 'Time' variable into a temporary file
     
    6164        ncrcat -O $output_file $file -o $output_file
    6265    fi
    63     newTime=$((newTime + nGCM))
     66    newTime=$((newTime + nPCM))
    6467done
    6568
  • trunk/LMDZ.COMMON/libf/evolution/deftank/launch_pem.sh

    r3210 r3214  
    2525#---------- Modify here the number of years to be simulated ------------
    2626## set the number of years, either Martian or Earth years:
    27 n_mars_years=1000000
    28 #n_earth_years=1000000
     27n_mars_years=1000
     28#n_earth_years=300
     29
     30#------------- Modify here the number of initial PCM calls -------------
     31## set the number of initial PCM calls between each PEM call:
     32nPCM_ini=4
    2933
    3034#---------------- Modify here the number of PCM calls ------------------
     
    130134echo $i_myear $n_myear $convert_years > info_PEM.txt
    131135
     136#-------------------------- Initial PCM runs ---------------------------
     137cp run_PCM.def run.def
     138for ((i = 1; i <= $nPCM_ini; i++)); do
     139    echo "Run PCM $iPCM (initial): call $i/$nPCM_ini..."
     140    sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
     141    sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
     142    sbatch -W exePCM.sh
     143    if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
     144        echo "Error: the run PCM $iPCM crashed!"
     145        exit 1
     146    fi
     147    # Copy data files and prepare the next run
     148    mv out_runPCM${iPCM} out_PCM/run${iPCM}
     149    mv diagfi.nc diags/diagfi${iPCM}.nc
     150    if [ -f "diagsoil.nc" ]; then
     151        mv diagsoil.nc diags/diagsoil${iPCM}.nc
     152    fi
     153    if [ -f "stats.nc" ]; then
     154        mv stats.nc diags/stats${iPCM}.nc
     155    fi
     156    k=$(echo "$i + 2 - $nPCM_ini" | bc -l)
     157    if [$(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
     158        mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     159    else
     160        cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     161        mv Xdiurnalave.nc data2reshape_Y${k}.nc
     162    fi
     163    cp restartfi.nc starts/startfi${iPCM}.nc
     164    mv restartfi.nc startfi.nc
     165    if [ -f "restart.nc" ]; then
     166        cp restart.nc starts/restart${iPCM}.nc
     167        mv restart.nc start.nc
     168    elif [ -f "restart1D.txt" ]; then
     169        cp restart1D.txt starts/restart1D${iPCM}.txt
     170        mv restart1D.txt start1D.txt
     171    fi
     172    ((iPCM++))
     173    ((i_myear++))
     174    echo "Done!"
     175done
     176sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
     177
    132178#---------------------- Main loop to call PEM/PCM ----------------------
    133179while [ $i_myear -lt $n_myear ]; do
    134     #--- Loop to run PCM year by year
    135     cp run_PCM.def run.def
    136     for ((i = 1; i <= $nPCM; i++)); do
    137         echo "Run PCM $iPCM: call $i/$nPCM..."
    138         sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
    139         sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
    140         sbatch -W exePCM.sh
    141         if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
    142             echo "Error: the run PCM $iPCM has crashed!"
    143             exit 1
    144         fi
    145         # Copy data files and prepare the next run
    146         mv out_runPCM${iPCM} out_PCM/run${iPCM}
    147         mv diagfi.nc diags/diagfi${iPCM}.nc
    148         if [ -f "diagsoil.nc" ]; then
    149             mv diagsoil.nc diags/diagsoil${iPCM}.nc
    150         fi
    151         if [ -f "stats.nc" ]; then
    152             mv stats.nc diags/stats${iPCM}.nc
    153         fi
    154         cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
    155         mv Xdiurnalave.nc data2reshape${i}.nc
    156         cp restartfi.nc starts/startfi${iPCM}.nc
    157         mv restartfi.nc startfi.nc
    158         if [ -f "restart.nc" ]; then
    159             cp restart.nc starts/restart${iPCM}.nc
    160             mv restart.nc start.nc
    161         elif [ -f "restart1D.txt" ]; then
    162             cp restart1D.txt starts/restart1D${iPCM}.txt
    163             mv restart1D.txt start1D.txt
    164         fi
    165         ((iPCM++))
    166         ((i_myear++))
    167         echo "Done!"
    168     done
    169     sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
    170 
    171180    #--- Reshaping PCM data with XIOS
    172181    echo "Reshaping PCM data with XIOS..."
     
    185194    ./$exePEM > out_runPEM${iPEM} 2>&1
    186195    if [ ! -f "restartfi_evol.nc" ]; then # Check if run ended abnormally
    187         echo "Error: the run PEM $iPEM has crashed!"
     196        echo "Error: the run PEM $iPEM crashed!"
    188197        exit 1
    189198    fi
     
    191200    mv out_runPEM${iPEM} out_PEM/run${iPEM}
    192201    mv diagpem.nc diags/diagpem${iPEM}.nc
    193     mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
     202    if [ -f "diagsoilpem.nc" ]; then
     203        mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
     204    fi
    194205    cp restartpem.nc starts/startpem${iPEM}.nc
    195206    mv restartpem.nc startpem.nc
     
    206217    read i_myear n_myear convert_years < info_PEM.txt
    207218    echo "Done!"
     219
     220    #--- Loop to run PCM year by year
     221    cp run_PCM.def run.def
     222    for ((i = 1; i <= $nPCM; i++)); do
     223        echo "Run PCM $iPCM: call $i/$nPCM..."
     224        sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
     225        sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
     226        sbatch -W exePCM.sh
     227        if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
     228            echo "Error: the run PCM $iPCM crashed!"
     229            exit 1
     230        fi
     231        # Copy data files and prepare the next run
     232        mv out_runPCM${iPCM} out_PCM/run${iPCM}
     233        mv diagfi.nc diags/diagfi${iPCM}.nc
     234        if [ -f "diagsoil.nc" ]; then
     235            mv diagsoil.nc diags/diagsoil${iPCM}.nc
     236        fi
     237        if [ -f "stats.nc" ]; then
     238            mv stats.nc diags/stats${iPCM}.nc
     239        fi
     240        k=$(echo "$i + 2 - $nPCM" | bc -l)
     241        if [$(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
     242            mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     243        else
     244            cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     245            mv Xdiurnalave.nc data2reshape_Y${k}.nc
     246        fi
     247        cp restartfi.nc starts/startfi${iPCM}.nc
     248        mv restartfi.nc startfi.nc
     249        if [ -f "restart.nc" ]; then
     250            cp restart.nc starts/restart${iPCM}.nc
     251            mv restart.nc start.nc
     252        elif [ -f "restart1D.txt" ]; then
     253            cp restart1D.txt starts/restart1D${iPCM}.txt
     254            mv restart1D.txt start1D.txt
     255        fi
     256        ((iPCM++))
     257        ((i_myear++))
     258        echo "Done!"
     259    done
     260    sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
    208261done
    209262
     
    212265
    213266date
    214 echo "The launching script has terminated."
     267echo "The launching script ended."
  • trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90

    r3206 r3214  
    109109!1. Run
    110110if (startpem_file) then
     111    write(*,*)'There is a "startpem.nc"!'
    111112    ! open pem initial state file:
    112113    call open_startphy(filename)
     
    321322    ! h2o ice
    322323    h2o_ice = 0.
    323     write(*,*)'There is no "startpem.nc" so ''h2o_ice'' is reconstructed from watercaptag with default value ''ini_huge_h2oice''.'
    324         do ig = 1,ngrid
    325             if (watercaptag(ig)) h2o_ice(ig,:) = ini_huge_h2oice/subslope_dist(ig,:)*cos(pi*def_slope_mean(:)*180.)
    326         enddo
     324    write(*,*)'There is no "startpem.nc"!'
     325    write(*,*)'So ''h2o_ice'' is initialized with default value ''ini_huge_h2oice'' where ''watercaptag'' is true.'
     326    do ig = 1,ngrid
     327        if (watercaptag(ig)) h2o_ice(ig,:) = ini_huge_h2oice/subslope_dist(ig,:)*cos(pi*def_slope_mean(:)*180.)
     328    enddo
    327329
    328330    ! co2 ice
     331    write(*,*)'So ''co2_ice'' is initialized with ''perennial_co2ice''.'
    329332    co2_ice = perennial_co2ice
    330333
  • trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90

    r3181 r3214  
    1414implicit none
    1515
    16 integer                               :: state, ncid, ncid1, ncid2, nDims, nVars, nGlobalAtts, unlimDimID
    17 integer                               :: i, j, include_parents, cstat
     16integer                               :: state, ncid1, ncid2, nDims, nVars, nGlobalAtts, unlimDimID
     17integer                               :: i, include_parents, cstat
    1818integer, dimension(:),    allocatable :: dimids, varids, dimids_2, varids_2, dimid_var
    1919real, dimension(:),       allocatable :: tempvalues_1d, values_1d
     
    3131    write(str(1:1),'(i1.1)') numyear
    3232
    33     state = nf90_open(path = "data2reshape"//str//".nc", mode = nf90_nowrite, ncid = ncid1)
     33    state = nf90_open(path = "data2reshape_Y"//str//".nc", mode = nf90_nowrite, ncid = ncid1)
    3434    if (state /= nf90_noerr) call handle_err(state)
    3535
  • trunk/LMDZ.COMMON/libf/evolution/time_evol_mod.F90

    r3159 r3214  
    1414logical :: var_ecc        ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for eccenticity
    1515logical :: var_lsp        ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for ls perihelie
     16integer :: ecritpem       ! For "diagpem.nc" outputs, writen every ecritpem
    1617
    1718END MODULE time_evol_mod
  • trunk/LMDZ.COMMON/libf/evolution/writediagpem.F90

    r3190 r3214  
    1616!  (ou encore 1d, dans le cas de testphys1d, pour sortir une colonne)
    1717!  La periode d'ecriture est donnee par
    18 !  "ecritphy " regle dans le fichier de controle de run :  run.def
     18!  "ecritpem " regle dans le fichier de controle de run :  run.def
    1919!
    2020!    writediagpem peut etre appele de n'importe quelle subroutine
     
    4949use surfdat_h,          only: phisfi
    5050use geometry_mod,       only: cell_area
    51 use time_phylmdz_mod,   only: ecritphy, day_step, iphysiq, day_ini
    5251use mod_phys_lmdz_para, only: is_parallel, is_mpi_root, is_master, gather
    5352use mod_grid_phy_lmdz,  only: klon_glo, Grid1Dto2D_glo, nbp_lon, nbp_lat, nbp_lev, grid_type, unstructured
     53use time_evol_mod,      only: ecritpem, dt_pem
    5454
    5555implicit none
     
    120120!***************************************************************
    121121!Sortie des variables au rythme voulu
    122 irythme = int(ecritphy) ! output rate set by ecritphy
     122irythme = int(ecritpem) ! output rate set by ecritpem
    123123
    124124!***************************************************************
     
    235235        ! write "header" of file (longitudes, latitudes, geopotential, ...)
    236236        IF (klon_glo>1) THEN ! general 3D case
    237             call iniwrite(nid,day_ini,phis,area,nbp_lon+1,nbp_lat)
     237            call iniwrite(nid,0,phis,area,nbp_lon+1,nbp_lat)
    238238        ELSE ! 1D model
    239             call iniwrite(nid,day_ini,phisfi_glo(1),areafi_glo(1),1,1)
     239            call iniwrite(nid,0,phisfi_glo(1),areafi_glo(1),1,1)
    240240        ENDIF
    241241
     
    255255! to writediagpem
    256256!------------------------------------------------------------------------
    257 if (nom == firstnom) zitau = zitau + iphysiq
     257if (nom == firstnom) zitau = zitau + dt_pem
    258258
    259259!--------------------------------------------------------
     
    271271            ntime=ntime+1 ! increment # of stored time steps
    272272            ! compute corresponding date (in days and fractions thereof)
    273             date=(zitau +1.)/day_step
     273            date = float(zitau + 1)
    274274            ! Get NetCDF ID of 'Time' variable
    275275            ierr= NF_INQ_VARID(nid,"Time",varid)
     
    580580END SUBROUTINE writediagpem
    581581
    582 subroutine writediagsoilpem(ngrid,name,title,units,dimpx,px)
     582!=================================================================
     583
     584SUBROUTINE writediagsoilpem(ngrid,name,title,units,dimpx,px)
    583585
    584586! Write variable 'name' to NetCDF file 'diagsoil.nc'.
     
    593595! Modifs: Aug.2010 Ehouarn: enforce outputs to be real*4
    594596
    595 use comsoil_h_PEM, only: nsoilmx_PEM, inertiedat_PEM
    596 use geometry_mod, only: cell_area
    597 use time_phylmdz_mod, only: ecritphy, day_step, iphysiq
    598 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
    599 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, nbp_lon, nbp_lat
    600 use mod_grid_phy_lmdz, only : grid_type, unstructured
     597use comsoil_h_PEM,      only: nsoilmx_PEM, inertiedat_PEM
     598use geometry_mod,       only: cell_area
     599use mod_phys_lmdz_para, only: is_mpi_root, is_master, gather
     600use mod_grid_phy_lmdz,  only: klon_glo, Grid1Dto2D_glo, nbp_lon, nbp_lat
     601use mod_grid_phy_lmdz,  only: grid_type, unstructured
     602use time_evol_mod,      only: ecritpem, dt_pem
    601603
    602604implicit none
     
    679681 
    680682  ! Set output sample rate
    681   isample=int(ecritphy) ! same as for diagfi outputs
    682   ! Note ecritphy is known from control.h
     683  isample = int(ecritpem) ! same as for diagpem outputs
    683684 
    684685  ! Create output NetCDF file
     
    745746if (name.eq.firstname) then
    746747  ! if we run across 'firstname', then it is a new time step
    747   zitau=zitau+iphysiq
    748   ! Note iphysiq is known from control.h
     748  zitau = zitau + dt_pem
    749749endif
    750750
     
    755755  if (name.eq.firstname) then
    756756    ntime=ntime+1
    757     date=float(zitau+1)/float(day_step)
    758     ! Note: day_step is known from control.h
     757    date = float(zitau + 1)
    759758   
    760759    if (is_master) then
     
    988987endif
    989988
    990 end subroutine writediagsoilpem
     989END SUBROUTINE writediagsoilpem
    991990
    992991
Note: See TracChangeset for help on using the changeset viewer.