Changeset 3096


Ignore:
Timestamp:
Oct 23, 2023, 4:10:10 PM (16 months ago)
Author:
jbclement
Message:

PEM:
The management of files during the chained simulation of PCM/PEM runs has been simplified:

  • "tmp_PEMyears.txt" and "info_run_PEM.txt" have been merged into one file called "info_PEM.txt";
  • "reshape_XIOS_output.F90" now creates directly the "data_PCM_Y*.nc" files needed by the PEM;
  • where it is relevant, 'GCM' has been replaced by 'PCM' in the files naming;
  • the files in deftank have been updated consequently.

Following r3095, 'iniorbit' is now a subroutine of "planete_h.F90".
JBC

Location:
trunk
Files:
6 edited
4 moved

Legend:

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

    r3093 r3096  
    111111== 18/10/2023 == JBC
    112112The optional file to define the wanted outputs in "diagpem.nc" is now "diagpem.def" (instead of "diagfi.def") + Some updates in the files of deftank.
     113
     114== 23/10/2023 == JBC
     115The management of files during the chained simulation of PCM/PEM runs has been simplified:
     116    - "tmp_PEMyears.txt" and "info_run_PEM.txt" have been merged into one file called "info_PEM.txt";
     117    - "reshape_XIOS_output.F90" now creates directly the "data_PCM_Y*.nc" files needed by the PEM;
     118    - where it is relevant, 'GCM' has been replaced by 'PCM' in the files naming;
     119    - the files in deftank have been updated consequently.
     120Following r3095, 'iniorbit' is now a subroutine of "planete_h.F90".
  • trunk/LMDZ.COMMON/libf/evolution/conf_pem.F90

    r3082 r3096  
    4242
    4343! #---------- Martian years parameters from launching script
    44 open(100,file = 'tmp_PEMyears.txt',status = 'old',form = 'formatted',iostat = ierr)
     44open(100,file = 'info_PEM.txt',status = 'old',form = 'formatted',iostat = ierr)
    4545if (ierr /= 0) then
    46     write(*,*) 'Cannot find required file "tmp_PEMyears.txt"!'
     46    write(*,*) 'Cannot find required file "info_PEM.txt"!'
    4747    write(*,*) 'It should be created by the launching script...'
    4848    stop
  • trunk/LMDZ.COMMON/libf/evolution/info_PEM_mod.F90

    r3095 r3096  
    1 MODULE info_run_PEM_mod
     1MODULE info_PEM_mod
    22
    33implicit none
     
    77!=======================================================================
    88
    9 SUBROUTINE info_run_PEM(year_iter,criterion_stop,i_myear,n_myear)
     9SUBROUTINE info_PEM(year_iter,criterion_stop,i_myear,n_myear)
    1010
    1111!=======================================================================
    1212!
    13 ! Purpose: Write in a file called info_run_PEM.txt the reason why the PEM did stop and the number of extrapolation year done
    14 !          Update the file tmp_PEMyears.txt to count the number of simulated Martian years
     13! Purpose: Update the first line of "info_PEM.txt" to count the number of simulated Martian years
     14!          Write in "info_PEM.txt" the reason why the PEM stopped and the number of simulated years
    1515!
    1616! Author: RV, JBC
     
    2626
    2727!----- Local variables
    28 logical :: ok
     28logical       :: ok
     29integer       :: cstat
     30character(10) :: ich1, ich2, fch
    2931
    3032!----- Code
    31 inquire(file = 'info_run_PEM.txt', exist = ok)
     33inquire(file = 'info_PEM.txt', exist = ok)
    3234if (ok) then
    33     open(12,file = 'info_run_PEM.txt',status = "old",position = "append",action = "write")
     35    write(ich1,'(i0)') i_myear
     36    write(ich2,'(i0)') n_myear
     37    write(fch,'(f0.4)') convert_years ! 4 digits afetr to the right of the decimal point to respect the precision of Martian year in "launch_pem.sh"
     38    call execute_command_line('sed -i "1s/.*/'//trim(ich1)//' '//trim(ich2)//' '//trim(fch)//'/" info_PEM.txt',cmdstat = cstat)
     39    if (cstat > 0) then
     40        error stop 'info_PEM: command exection failed!'
     41    else if (cstat < 0) then
     42        error stop 'info_PEM: command execution not supported!'
     43    endif
     44    open(1,file = 'info_PEM.txt',status = "old",position = "append",action = "write")
     45    write(1,*) year_iter, i_myear, criterion_stop
     46    close(1)
    3447else
    35     open(12,file = 'info_run_PEM.txt',status = "new",action = "write")
     48    error stop 'The file ''info_PEM.txt'' does not exist and cannot be updated!'
    3649endif
    37 write(12,*) year_iter, i_myear, criterion_stop
    38 close(12)
    3950
    40 open(100,file = 'tmp_PEMyears.txt',status = 'replace')
    41 write(100,*) i_myear, n_myear, convert_years
    42 close(100)
     51END SUBROUTINE info_PEM
    4352
    44 END SUBROUTINE info_run_PEM
    45 
    46 END MODULE info_run_PEM_mod
     53END MODULE info_PEM_mod
  • trunk/LMDZ.COMMON/libf/evolution/nb_time_step_PCM_mod.F90

    r3095 r3096  
    1 MODULE nb_time_step_GCM_mod
     1MODULE nb_time_step_PCM_mod
    22
    33use netcdf, only: nf90_open, NF90_NOWRITE, nf90_noerr, nf90_strerror, &
     
    1313!=======================================================================
    1414
    15 SUBROUTINE nb_time_step_GCM(fichnom,timelen)
     15SUBROUTINE nb_time_step_PCM(fichnom,timelen)
    1616
    1717implicit none
     
    1919!=======================================================================
    2020!
    21 ! Purpose: Read in the data_GCM_Yr*.nc the number of time step
     21! Purpose: Read in the data_PCM_Yr*.nc the number of time step
    2222!
    2323! Author: RV
     
    3434integer        :: timelen ! number of times stored in the file
    3535!-----------------------------------------------------------------------
    36 modname = "nb_time_step_GCM"
     36modname = "nb_time_step_PCM"
    3737
    3838!  Open initial state NetCDF file
     
    4242ierr = nf90_inq_varid (fID, "temps", vID)
    4343if (ierr /= nf90_noerr) then
    44     write(*,*)"read_data_GCM: Le champ <temps> est absent"
    45     write(*,*)"read_data_GCM: J essaie <time_counter>"
     44    write(*,*)"read_data_PCM: Le champ <temps> est absent"
     45    write(*,*)"read_data_PCM: J essaie <time_counter>"
    4646    ierr = nf90_inq_varid (fID, "time_counter", vID)
    4747    if (ierr /= nf90_noerr) then
    48         write(*,*)"read_data_GCM: Le champ <time_counter> est absent"
    49         write(*,*)"read_data_GCM: J essaie <Time>"
     48        write(*,*)"read_data_PCM: Le champ <time_counter> est absent"
     49        write(*,*)"read_data_PCM: J essaie <Time>"
    5050        ierr = nf90_inq_varid (fID, "Time", vID)
    5151        if (ierr /= nf90_noerr) then
    52             write(*,*)"read_data_GCM: Le champ <Time> est absent"
     52            write(*,*)"read_data_PCM: Le champ <Time> est absent"
    5353            write(*,*)trim(nf90_strerror(ierr))
    54             call abort_gcm("nb_time_step_GCM", "", 1)
     54            call abort_gcm("nb_time_step_PCM", "", 1)
    5555        endif
    5656        ! Get the length of the "Time" dimension
     
    7272write(*,*) "The number of timestep of the PCM run data=", timelen
    7373
    74 END SUBROUTINE nb_time_step_GCM
     74END SUBROUTINE nb_time_step_PCM
    7575
    7676!=======================================================================
     
    9898END SUBROUTINE error_msg
    9999
    100 END MODULE nb_time_step_GCM_mod
     100END MODULE nb_time_step_PCM_mod
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3088 r3096  
    44!    I_b READ of start_evol.nc and starfi_evol.nc
    55!    I_c Subslope parametrisation
    6 !    I_d READ GCM data and convert to the physical grid
     6!    I_d READ PCM data and convert to the physical grid
    77!    I_e Initialization of the PEM variable and soil
    88!    I_f Compute tendencies & Save initial situation
     
    4848                                        TI_PEM, inertiedat_PEM,           & ! soil thermal inertia
    4949                                        tsoil_PEM, mlayer_PEM, layer_PEM, & ! Soil temp, number of subsurface layers, soil mid layer depths
    50                                         fluxgeo,                          & ! Geothermal flux for the PEM and GCM
     50                                        fluxgeo,                          & ! Geothermal flux for the PEM and PCM
    5151                                        water_reservoir                     ! Water ressources
    5252use adsorption_mod,               only: regolith_adsorption, adsorption_pem,        & ! Bool to check if adsorption, main subroutine
     
    6363use soil_settings_PEM_mod,        only: soil_settings_PEM
    6464use compute_tendencies_slope_mod, only: compute_tendencies_slope
    65 use info_run_PEM_mod,             only: info_run_PEM
     65use info_PEM_mod,                 only: info_PEM
    6666use interpolate_TIPEM_TIGCM_mod,  only: interpolate_TIPEM_TIGCM
    67 use nb_time_step_GCM_mod,         only: nb_time_step_GCM
     67use nb_time_step_PCM_mod,         only: nb_time_step_PCM
    6868use pemetat0_mod,                 only: pemetat0
    69 use read_data_GCM_mod,            only: read_data_GCM
     69use read_data_PCM_mod,            only: read_data_PCM
    7070use recomp_tend_co2_slope_mod,    only: recomp_tend_co2_slope
    7171use soil_pem_compute_mod,         only: soil_pem_compute
     
    8383    use tracer_mod,         only: noms,igcm_h2o_ice, igcm_co2, mmol, igcm_h2o_vap ! Tracer names and molar masses
    8484    use mod_phys_lmdz_para, only: is_parallel, is_sequential, is_mpi_root, is_omp_root, is_master
    85     use planete_h,          only: aphelie, periheli, year_day, peri_day, obliquit
     85    use planete_h,          only: aphelie, periheli, year_day, peri_day, obliquit, iniorbit
    8686    use paleoclimate_mod,   only: albedo_perenialco2
    8787    use comcstfi_h,         only: pi, rad, g, cpp, mugaz, r
     
    120120parameter(ngridmx = 2 + (jjm - 1)*iim - 1/jjm)
    121121
    122 ! Same variable names as in the GCM
     122! Same variable names as in the PCM
    123123integer, parameter :: nlayer = llm ! Number of vertical layer
    124124integer            :: ngrid        ! Number of physical grid points
     
    126126integer            :: day_ini      ! First day of the simulation
    127127real               :: pday         ! Physical day
    128 real               :: time_phys    ! Same as GCM
    129 real               :: ptimestep    ! Same as GCM
    130 real               :: ztime_fin    ! Same as GCM
     128real               :: time_phys    ! Same as PCM
     129real               :: ptimestep    ! Same as PCM
     130real               :: ztime_fin    ! Same as PCM
    131131
    132132! Variables to read start.nc
     
    166166real                                :: global_ave_press_new ! constant: Global average pressure of current time step
    167167real, dimension(:,:),   allocatable :: zplev_new            ! Physical x Atmospheric field : mass of the atmospheric  layers in the pem at current time step [kg/m^2]
    168 real, dimension(:,:),   allocatable :: zplev_gcm            ! same but retrieved from the gcm [kg/m^2]
     168real, dimension(:,:),   allocatable :: zplev_gcm            ! same but retrieved from the PCM [kg/m^2]
    169169real, dimension(:,:,:), allocatable :: zplev_new_timeseries ! Physical x Atmospheric x Time: same as zplev_new, but in times series [kg/m ^2]
    170170real, dimension(:,:,:), allocatable :: zplev_old_timeseries ! same but with the time series, for oldest time step
     
    175175integer                             :: criterion_stop       ! which criterion is reached ? 1= h2o ice surf, 2 = co2 ice surf, 3 = ps, 4 = orb param
    176176real, save                          :: A, B, mmean          ! Molar mass: intermediate A, B for computations of the  mean molar mass of the layer [mol/kg]
    177 real, dimension(:,:),   allocatable :: vmr_co2_gcm          ! Physics x Times  co2 volume mixing ratio retrieve from the gcm [m^3/m^3]
     177real, dimension(:,:),   allocatable :: vmr_co2_gcm          ! Physics x Times  co2 volume mixing ratio retrieve from the PCM [m^3/m^3]
    178178real, dimension(:,:),   allocatable :: vmr_co2_pem_phys     ! Physics x Times  co2 volume mixing ratio used in the PEM
    179 real, dimension(:,:),   allocatable :: q_co2_PEM_phys       ! Physics x Times co2 mass mixing ratio in the first layer computed in the PEM, first value comes from GCM [kg/kg]
    180 real, dimension(:,:),   allocatable :: q_h2o_PEM_phys       ! Physics x Times: h2o mass mixing ratio computed in the PEM, first value comes from GCM [kg/kg]
     179real, dimension(:,:),   allocatable :: q_co2_PEM_phys       ! Physics x Times co2 mass mixing ratio in the first layer computed in the PEM, first value comes from PCM [kg/kg]
     180real, dimension(:,:),   allocatable :: q_h2o_PEM_phys       ! Physics x Times: h2o mass mixing ratio computed in the PEM, first value comes from PCM [kg/kg]
    181181integer                             :: timelen              ! # time samples
    182182real                                :: ave                  ! intermediate varibale to compute average
     
    189189real, dimension(:,:),   allocatable :: min_h2o_ice_1          ! ngrid field: minimum of water ice at each point for the first year [kg/m^2]
    190190real, dimension(:,:),   allocatable :: min_h2o_ice_2          ! ngrid field: minimum of water ice at each point for the second year [kg/m^2]
    191 real, dimension(:,:,:), allocatable :: co2_ice_GCM            ! Physics x NSLOPE x Times field: co2 ice given by the GCM  [kg/m^2]
     191real, dimension(:,:,:), allocatable :: co2_ice_GCM            ! Physics x NSLOPE x Times field: co2 ice given by the PCM  [kg/m^2]
    192192real, dimension(:,:),   allocatable :: initial_co2_ice_sublim ! physical point field: Logical array indicating sublimating point of co2 ice
    193193real, dimension(:,:),   allocatable :: initial_h2o_ice        ! physical point field: Logical array indicating if there is water ice at initial state
    194194real, dimension(:,:),   allocatable :: initial_co2_ice        ! physical point field: Logical array indicating if there is co2 ice at initial state
    195195real, dimension(:,:),   allocatable :: tendencies_co2_ice     ! physical point x slope field: Tendency of evolution of perenial co2 ice over a year
    196 real, dimension(:,:),   allocatable :: tendencies_co2_ice_ini ! physical point x slope field x nslope: Tendency of evolution of perenial co2 ice over a year in the GCM
     196real, dimension(:,:),   allocatable :: tendencies_co2_ice_ini ! physical point x slope field x nslope: Tendency of evolution of perenial co2 ice over a year in the PCM
    197197real, dimension(:,:),   allocatable :: tendencies_h2o_ice     ! physical point x slope  field: Tendency of evolution of perenial h2o ice
    198198real, dimension(:,:),   allocatable :: flag_co2flow           ! (ngrid,nslope): Flag where there is a CO2 glacier flow
     
    207207real, dimension(:,:,:,:), allocatable :: tsoil_phys_PEM_timeseries          ! IG x SLOPE XTULES field : NOn averaged Soil Temperature [K]
    208208real, dimension(:,:,:,:), allocatable :: tsoil_GCM_timeseries               ! IG x SLOPE XTULES field : NOn averaged Soil Temperature [K]
    209 real, dimension(:,:),     allocatable :: tsurf_ave_yr1                      ! Physic x SLOPE field : Averaged Surface Temperature of first call of the gcm [K]
     209real, dimension(:,:),     allocatable :: tsurf_ave_yr1                      ! Physic x SLOPE field : Averaged Surface Temperature of first call of the PCM [K]
    210210real, dimension(:,:),     allocatable :: TI_locslope                        ! Physic x Soil: Intermediate thermal inertia  to compute Tsoil [SI]
    211211real, dimension(:,:),     allocatable :: Tsoil_locslope                     ! Physic x Soil: intermediate when computing Tsoil [K]
     
    346346#endif
    347347
    348 ! In the gcm, these values are given to the physic by the dynamic.
     348! In the PCM, these values are given to the physic by the dynamic.
    349349! Here we simply read them in the startfi_evol.nc file
    350350status = nf90_open(FILE_NAME, NF90_NOWRITE, ncid)
     
    459459!------------------------
    460460! I   Initialization
    461 !    I_d READ GCM data and convert to the physical grid
    462 !------------------------
    463 ! First we read the evolution of water and co2 ice (and the mass mixing ratio) over the first year of the GCM run, saving only the minimum value
    464 call nb_time_step_GCM("data_GCM_Y1.nc",timelen)
     461!    I_d READ PCM data and convert to the physical grid
     462!------------------------
     463! First we read the evolution of water and co2 ice (and the mass mixing ratio) over the first year of the PCM run, saving only the minimum value
     464call nb_time_step_PCM("data_PCM_Y1.nc",timelen)
    465465
    466466allocate(tsoil_ave(ngrid,nsoilmx,nslope))
     
    491491
    492492write(*,*) "Downloading data Y1..."
    493 call read_data_GCM("data_GCM_Y1.nc",timelen, iim,jjm_value,ngrid,nslope,vmr_co2_gcm,ps_timeseries,min_co2_ice_1,min_h2o_ice_1, &
     493call read_data_PCM("data_PCM_Y1.nc",timelen, iim,jjm_value,ngrid,nslope,vmr_co2_gcm,ps_timeseries,min_co2_ice_1,min_h2o_ice_1, &
    494494                   tsurf_ave_yr1,tsoil_ave, tsurf_GCM_timeseries,tsoil_GCM_timeseries,q_co2_PEM_phys,q_h2o_PEM_phys,           &
    495495                   co2_ice_GCM,watersurf_density_ave,watersoil_density_timeseries)
    496496write(*,*) "Downloading data Y1 done"
    497497
    498 ! Then we read the evolution of water and co2 ice (and the mass mixing ratio) over the second year of the GCM run, saving only the minimum value
     498! Then we read the evolution of water and co2 ice (and the mass mixing ratio) over the second year of the PCM run, saving only the minimum value
    499499write(*,*) "Downloading data Y2"
    500 call read_data_GCM("data_GCM_Y2.nc",timelen,iim,jjm_value,ngrid,nslope,vmr_co2_gcm,ps_timeseries,min_co2_ice_2,min_h2o_ice_2, &
     500call read_data_PCM("data_PCM_Y2.nc",timelen,iim,jjm_value,ngrid,nslope,vmr_co2_gcm,ps_timeseries,min_co2_ice_2,min_h2o_ice_2, &
    501501                   tsurf_ave,tsoil_ave, tsurf_GCM_timeseries,tsoil_GCM_timeseries,q_co2_PEM_phys,q_h2o_PEM_phys,              &
    502502                   co2_ice_GCM,watersurf_density_ave,watersoil_density_timeseries)
     
    10681068enddo
    10691069
    1070 ! Conserving the tracers mass for GCM start files
     1070! Conserving the tracers mass for PCM start files
    10711071do nnq = 1,nqtot
    10721072    do ig = 1,ngrid
     
    11391139write(*,*) "restartpem.nc has been written"
    11401140
    1141 call info_run_PEM(year_iter,criterion_stop,i_myear,n_myear)
     1141call info_PEM(year_iter,criterion_stop,i_myear,n_myear)
    11421142
    11431143write(*,*) "The PEM has run for", year_iter, "Martian years."
  • trunk/LMDZ.COMMON/libf/evolution/read_data_PCM_mod.F90

    r3095 r3096  
    1 MODULE read_data_GCM_mod
     1MODULE read_data_PCM_mod
    22
    33use netcdf, only: nf90_open, NF90_NOWRITE, nf90_noerr, nf90_strerror, &
     
    1414!=======================================================================
    1515
    16 SUBROUTINE read_data_GCM(fichnom,timelen,iim_input,jjm_input,ngrid,nslope,vmr_co2_gcm_phys,ps_timeseries,           &
     16SUBROUTINE read_data_PCM(fichnom,timelen,iim_input,jjm_input,ngrid,nslope,vmr_co2_gcm_phys,ps_timeseries,           &
    1717                         min_co2_ice,min_h2o_ice,tsurf_ave,tsoil_ave,tsurf_gcm,tsoil_gcm,q_co2,q_h2o,co2_ice_slope, &
    1818                         watersurf_density_ave,watersoil_density)
     
    2525!=======================================================================
    2626!
    27 ! Purpose: Read initial confitions file from the GCM
     27! Purpose: Read initial confitions file from the PCM
    2828!
    2929! Authors: RV & LL
     
    4141real, dimension(ngrid,nslope),         intent(out) :: min_co2_ice      ! Minimum of co2 ice  per slope of the year [kg/m^2]
    4242real, dimension(ngrid,nslope),         intent(out) :: min_h2o_ice      ! Minimum of h2o ice per slope of the year [kg/m^2]
    43 real, dimension(ngrid,timelen),        intent(out) :: vmr_co2_gcm_phys ! Physics x Times  co2 volume mixing ratio retrieve from the gcm [m^3/m^3]
     43real, dimension(ngrid,timelen),        intent(out) :: vmr_co2_gcm_phys ! Physics x Times  co2 volume mixing ratio retrieve from the PCM [m^3/m^3]
    4444real, dimension(ngrid,timelen),        intent(out) :: ps_timeseries    ! Surface Pressure [Pa]
    4545real, dimension(ngrid,timelen),        intent(out) :: q_co2            ! CO2 mass mixing ratio in the first layer [kg/m^3]
     
    8181
    8282!-----------------------------------------------------------------------
    83 modname="read_data_gcm"
     83modname="read_data_PCM"
    8484
    8585A = (1/m_co2 - 1/m_noco2)
     
    280280#endif
    281281
    282 END SUBROUTINE read_data_gcm
     282END SUBROUTINE read_data_PCM
    283283
    284284SUBROUTINE check_dim(n1,n2,str1,str2)
     
    366366END SUBROUTINE error_msg
    367367
    368 END MODULE read_data_GCM_mod
     368END MODULE read_data_PCM_mod
  • trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90

    r3076 r3096  
    33!=======================================================================
    44!
    5 ! Purpose: Read XIOS files, and convert them into the correct GCM grid
     5! Purpose: Read XIOS files, and convert them into the correct PCM grid
    66!          XIOS  longitudes start at -180 but stop before -180 (not duplicated)
    77!          We basically add the last point, and complete the XIOS file. Looped
    8 !          over the two GCM runs
     8!          over the two PCM runs
    99!
    1010! Authors: RV & LL
     
    3535    if (state /= nf90_noerr) call handle_err(state)
    3636
    37     state = nf90_create(path = "datareshaped"//str2//".nc", cmode=or(nf90_noclobber,nf90_64bit_offset), ncid = ncid2)
     37    state = nf90_create(path = "data_PCM_Y"//str2//".nc", cmode=or(nf90_noclobber,nf90_64bit_offset), ncid = ncid2)
    3838    if (state /= nf90_noerr) call handle_err(state)
    3939
  • trunk/LMDZ.MARS/deftank/pem/README

    r3093 r3096  
    22
    33# launch_pem.sh:
    4   Bash script file to launch the chained simulation of PEM and GCM runs.
     4  Bash script file to launch the chained simulation of PEM and PCM runs.
    55  The user has to specify:
    66      (i)   n_earth_years -> the number of Earth years to be simulated in total;
    7       (ii)  nGCM -> the number of GCM calls between PEM runs (usually nGCM=2);
     7      (ii)  nPCM -> the number of PCM calls between PEM runs (usually nPCM=2);
    88      (iii) exePEM -> the name of executable file for the PEM run;
    99      (iv)  exeReshape -> the name of executable file for the data reshaping task with XIOS.
    1010  The path to source the arch file should be adapted to the machine.
    1111
    12 # exeGCM.sh:
    13   Bash script file to run the GCM with a SLURM job. The name of the GCM executable file should be adapted. The header corresponds to the ADASTRA supercomputer and should be changed for other machines.
     12# exePCM.sh:
     13  Bash script file to run the PCM with a SLURM job. The name of the PCM executable file should be adapted. The header corresponds to the ADASTRA supercomputer and should be changed for other machines.
    1414
    1515# run_PEM.def
    1616  All the possible parameters to define a PEM run (read in "conf_pem.F90").
    17   It needs to be included in "run_GCM.def" with "INCLUDEDEF=run_PEM.def".
     17  It needs to be included in "run_PCM.def" with "INCLUDEDEF=run_PEM.def".
    1818
    1919# obl_ecc_lsp.asc
     
    2929  To run the chained simulation, be careful to have:
    3030      (i)   the xml files for XIOS. There should be "iodef.xml", "context_lmdz_physics.xml", "file_def_physics_mars.xml" and "field_def_physics_mars.xml" which can be found in the deftank folder. In "context_lmdz_physics.xml", the line for Xdiurnalave should be activated (enabled=".true.");
    31       (ii)  the usual def files to run the GCM. "run.def" should be renamed in "run_GCM.def";
     31      (ii)  the usual def files to run the PCM. "run.def" should be renamed in "run_PCM.def";
    3232      (iii  the starting files ("startfi.nc" and "start.nc"). The former can be modified by "modify_startfi_orbit.sh";
    3333      (iv)  some optional files. For example, "diagfi.def" and "diagpem.def".
  • trunk/LMDZ.MARS/deftank/pem/exePCM.sh

    r3095 r3096  
    11#!/bin/bash
    22#SBATCH --account=cin0391
    3 #SBATCH --job-name=runGCM1
     3#SBATCH --job-name=runPCM1
    44#SBATCH --constraint=GENOA
    55### GENOA nodes accommodate 96 cores
     
    1212#SBATCH --threads-per-core=1
    1313###SBATCH --exclusive
    14 #SBATCH --output=run_gcm_%A.out
     14#SBATCH --output=run_PCM_%A.out
    1515#SBATCH --time=10:00:00
    1616
    17 srun testphys1d_29_phymars_para.e > out_runGCM1 2>&1
     17srun testphys1d_29_phymars_para.e > out_runPCM1 2>&1
  • trunk/LMDZ.MARS/deftank/pem/launch_pem.sh

    r3093 r3096  
    11#!/bin/bash
    22#####################################################################
    3 ### Launching script for a chained simulation of PEM and GCM runs ###
     3### Launching script for a chained simulation of PEM and PCM runs ###
    44#####################################################################
    55
     
    2525n_earth_years=1000000
    2626
    27 #---------------- Modify here the number of GCM calls ------------------
    28 ## set the number of GCM calls between each PEM call:
    29 nGCM=2
     27#---------------- Modify here the number of PCM calls ------------------
     28## set the number of PCM calls between each PEM call:
     29nPCM=2
    3030
    3131#------------------ Modify here the name of PEM exe --------------------
     
    4545machine=`hostname`
    4646address=`whoami`
    47 if [ ! -f "exeGCM.sh" ]; then
    48     echo "Error: file \"exeGCM.sh\" does not exist in $dir!"
     47if [ ! -f "exePCM.sh" ]; then
     48    echo "Error: file \"exePCM.sh\" does not exist in $dir!"
    4949    exit 1
    5050fi
     
    5353    exit 1
    5454fi
    55 if [ ! -f "run_GCM.def" ]; then
    56     echo "Error: file \"run_GCM.def\" does not exist in $dir!"
     55if [ ! -f "run_PCM.def" ]; then
     56    echo "Error: file \"run_PCM.def\" does not exist in $dir!"
    5757    exit 1
    5858fi
     
    7373    exit 1
    7474fi
    75 if [ ! -d "out_GCM" ]; then
    76     mkdir out_GCM
     75if [ ! -d "out_PCM" ]; then
     76    mkdir out_PCM
    7777fi
    7878if [ ! -d "out_PEM" ]; then
     
    9090machine=`hostname`
    9191address=`whoami`
    92 echo "This is a chained simulation for PEM and GCM runs in $dir on $machine."
     92echo "This is a chained simulation for PEM and PCM runs in $dir on $machine."
    9393convert_years=$(echo "$myear/$eyear" | bc -l)
    9494convert_years=$(printf "%.4f" $convert_years) # Rounding to the 4th decimal to respect the precision of Martian year
     
    9797i_myear=0
    9898iPEM=1
    99 ((iGCM = ($iPEM - 1)*$nGCM + 1))
     99((iPCM = ($iPEM - 1)*$nPCM + 1))
    100100cp startfi.nc starts/
    101101if [ -f "start.nc" ]; then
     
    103103fi
    104104
    105 # Create a temporary file to manage years of the chained simulation
    106 echo $i_myear $n_myear $convert_years > tmp_PEMyears.txt
     105# Create a file to manage years of the chained simulation and store some info from the PEM runs
     106if [ -f "info_PEM.txt" ]; then
     107    rm info_PEM.txt
     108fi
     109echo $i_myear $n_myear $convert_years > info_PEM.txt
    107110
    108 #---------------------- Main loop to call PEM/GCM ----------------------
     111#---------------------- Main loop to call PEM/PCM ----------------------
    109112while [ $i_myear -lt $n_myear ]; do
    110     #--- Loop to run GCM year by year
    111     cp run_GCM.def run.def
    112     for ((i = 1; i <= $nGCM; i++)); do
    113         echo "Run GCM $iGCM: call $i/$nGCM..."
    114         sed -i "s/#SBATCH --job-name=runGCM.*/#SBATCH --job-name=runGCM${iGCM}/" exeGCM.sh
    115         sed -i "s/out_runGCM[0-9]\+/out_runGCM${iGCM}/" exeGCM.sh
    116         sbatch -W exeGCM.sh
     113    #--- Loop to run PCM year by year
     114    cp run_PCM.def run.def
     115    for ((i = 1; i <= $nPCM; i++)); do
     116        echo "Run PCM $iPCM: call $i/$nPCM..."
     117        sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
     118        sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
     119        sbatch -W exePCM.sh
    117120        if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
    118             echo "Error: the run GCM $iGCM has crashed!"
     121            echo "Error: the run PCM $iPCM has crashed!"
    119122            exit 1
    120123        fi
    121124        # Copy data files and prepare the next run
    122         mv out_runGCM${iGCM} out_GCM/run${iGCM}
    123         mv diagfi.nc diags/diagfi${iGCM}.nc
     125        mv out_runPCM${iPCM} out_PCM/run${iPCM}
     126        mv diagfi.nc diags/diagfi${iPCM}.nc
    124127        if [ -f "diagsoil.nc" ]; then
    125             mv diagsoil.nc diags/diagsoil${iGCM}.nc
     128            mv diagsoil.nc diags/diagsoil${iPCM}.nc
    126129        fi
    127130        if [ -f "stats.nc" ]; then
    128             mv stats.nc diags/stats${iGCM}.nc
     131            mv stats.nc diags/stats${iPCM}.nc
    129132        fi
    130         cp Xdiurnalave.nc diags/data2reshape${iGCM}.nc
     133        cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
    131134        mv Xdiurnalave.nc data2reshape${i}.nc
    132         cp restartfi.nc starts/startfi${iGCM}.nc
     135        cp restartfi.nc starts/startfi${iPCM}.nc
    133136        mv restartfi.nc startfi.nc
    134137        if [ -f "restart.nc" ]; then
    135             cp restart.nc starts/restart${iGCM}.nc
     138            cp restart.nc starts/restart${iPCM}.nc
    136139            mv restart.nc start.nc
    137140        elif [ -f "restart1D.txt" ]; then
    138             cp restart1D.txt starts/restart1D${iGCM}.txt
     141            cp restart1D.txt starts/restart1D${iPCM}.txt
    139142            mv restart1D.txt start1D.txt
    140143        fi
    141         ((iGCM++))
     144        ((iPCM++))
    142145        ((i_myear++))
    143146        echo "Done!"
    144147    done
    145     echo $i_myear $n_myear $convert_years > tmp_PEMyears.txt
    146     #--- Reshaping GCM data with XIOS
    147     echo "Reshaping GCM data with XIOS..."
     148    sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
     149    #--- Reshaping PCM data with XIOS
     150    echo "Reshaping PCM data with XIOS..."
    148151    ./$exeReshape
    149     for file in datareshaped*; do
    150         mv $file ${file/reshaped/_GCM_Y}
    151     done
    152152    echo "Done!"
    153153    #--- Running PEM
     
    180180    fi
    181181    ((iPEM++))
    182     read i_myear n_myear convert_years < tmp_PEMyears.txt
     182    read i_myear n_myear convert_years < info_PEM.txt
    183183    echo "Done!"
    184184done
    185 
    186 # Delete the temporary file to manage years of the chained simulation
    187 rm tmp_PEMyears.txt
    188185
    189186# Restore the previous value of LC_NUMERIC
    190187LC_NUMERIC=$OLD_LC_NUMERIC
    191188
    192 #----------------- Preparation for relaunch if needed ------------------
    193 #echo "Reinitializing starting files..."
    194 #cp starts/startfi.nc .
    195 #for file in profiles/*_0; do
    196 #    cp $file ${file/_0/}
    197 #done
    198 #echo "Done!"
    199 
    200189date
    201190echo "The launching script has terminated."
Note: See TracChangeset for help on using the changeset viewer.