Ignore:
Timestamp:
Oct 23, 2023, 4:10:10 PM (14 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/LMDZ.COMMON/libf/evolution
Files:
4 edited
3 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
Note: See TracChangeset for help on using the changeset viewer.