| 1 | MODULE pemredem |
|---|
| 2 | |
|---|
| 3 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 4 | !!! |
|---|
| 5 | !!! Purpose: Write specific netcdf restart for the PEM |
|---|
| 6 | !!! |
|---|
| 7 | !!! |
|---|
| 8 | !!! Author: LL, inspired by phyredem from the PCM |
|---|
| 9 | !!! |
|---|
| 10 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 11 | |
|---|
| 12 | implicit none |
|---|
| 13 | |
|---|
| 14 | !======================================================================= |
|---|
| 15 | contains |
|---|
| 16 | !======================================================================= |
|---|
| 17 | |
|---|
| 18 | SUBROUTINE pemdem0(filename,lonfi,latfi,cell_area,nsoil_PEM,ngrid,day_ini,time,nslope,def_slope,subslope_dist) |
|---|
| 19 | |
|---|
| 20 | ! create physics restart file and write time-independent variables |
|---|
| 21 | use comsoil_h_PEM, only: soil_pem,mlayer_PEM,fluxgeo,inertiedat_PEM |
|---|
| 22 | use iostart_PEM, only: open_restartphy, close_restartphy, put_var, put_field, length |
|---|
| 23 | use mod_grid_phy_lmdz, only: klon_glo |
|---|
| 24 | use time_phylmdz_mod, only: daysec |
|---|
| 25 | |
|---|
| 26 | #ifndef CPP_STD |
|---|
| 27 | use planete_h, only: aphelie, emin_turb, lmixmin, obliquit, peri_day, periheli, year_day |
|---|
| 28 | use comcstfi_h, only: g, mugaz, omeg, rad, rcp |
|---|
| 29 | #else |
|---|
| 30 | use planete_mod, only: apoastr, emin_turb, lmixmin, obliquit, peri_day, periastr, year_day |
|---|
| 31 | use comcstfi_mod, only: g, mugaz, omeg, rad, rcp |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
| 34 | implicit none |
|---|
| 35 | |
|---|
| 36 | character(*), intent(in) :: filename |
|---|
| 37 | integer, intent(in) :: nsoil_PEM, ngrid, nslope |
|---|
| 38 | real, dimension(ngrid), intent(in) :: lonfi, latfi |
|---|
| 39 | real, intent(in) :: day_ini, time |
|---|
| 40 | real, dimension(ngrid), intent(in) :: cell_area ! boundaries for bining of the slopes |
|---|
| 41 | real, dimension(ngrid + 1), intent(in) :: def_slope ! boundaries for bining of the slopes |
|---|
| 42 | real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! undermesh statistics |
|---|
| 43 | |
|---|
| 44 | ! Create physics start file |
|---|
| 45 | call open_restartphy(filename) |
|---|
| 46 | |
|---|
| 47 | ! Write the mid-layer depths |
|---|
| 48 | call put_var("soildepth","Soil mid-layer depth",mlayer_PEM) |
|---|
| 49 | |
|---|
| 50 | ! Write longitudes |
|---|
| 51 | call put_field("longitude","Longitudes of physics grid",lonfi) |
|---|
| 52 | |
|---|
| 53 | ! Write latitudes |
|---|
| 54 | call put_field("latitude","Latitudes of physics grid",latfi) |
|---|
| 55 | |
|---|
| 56 | ! Write mesh areas |
|---|
| 57 | call put_field("area","Mesh area",cell_area) |
|---|
| 58 | |
|---|
| 59 | ! Multidimensionnal variables (nopcm undermesh slope statistics) |
|---|
| 60 | call put_var("def_slope","slope criterium stages",def_slope) |
|---|
| 61 | call put_field("subslope_dist","under mesh slope distribution",subslope_dist) |
|---|
| 62 | |
|---|
| 63 | ! Close file |
|---|
| 64 | call close_restartphy |
|---|
| 65 | |
|---|
| 66 | END SUBROUTINE pemdem0 |
|---|
| 67 | |
|---|
| 68 | !======================================================================= |
|---|
| 69 | |
|---|
| 70 | SUBROUTINE pemdem1(filename,i_myear,nsoil_PEM,ngrid,nslope,tsoil_slope_PEM,inertiesoil_slope_PEM, & |
|---|
| 71 | ice_table_depth,ice_table_thickness,m_co2_regolith,m_h2o_regolith,h2o_ice) |
|---|
| 72 | |
|---|
| 73 | ! write time-dependent variable to restart file |
|---|
| 74 | use iostart_PEM, only: open_restartphy, close_restartphy, put_var, put_field |
|---|
| 75 | use comsoil_h_PEM, only: mlayer_PEM,fluxgeo, inertiedat_PEM, soil_pem |
|---|
| 76 | use time_evol_mod, only: year_bp_ini, convert_years |
|---|
| 77 | |
|---|
| 78 | implicit none |
|---|
| 79 | |
|---|
| 80 | #ifndef CPP_STD |
|---|
| 81 | include "callkeys.h" |
|---|
| 82 | #endif |
|---|
| 83 | |
|---|
| 84 | character(*), intent(in) :: filename |
|---|
| 85 | integer, intent(in) :: nsoil_PEM, ngrid, nslope, i_myear |
|---|
| 86 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_slope_PEM ! under mesh bining according to slope |
|---|
| 87 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: inertiesoil_slope_PEM ! under mesh bining according to slope |
|---|
| 88 | real, dimension(ngrid,nslope), intent(in) :: ice_table_depth ! under mesh bining according to slope |
|---|
| 89 | real, dimension(ngrid,nslope), intent(in) :: ice_table_thickness ! under mesh bining according to slope |
|---|
| 90 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: m_co2_regolith, m_h2o_regolith |
|---|
| 91 | real, dimension(ngrid,nslope), intent(in) :: h2o_ice |
|---|
| 92 | |
|---|
| 93 | integer :: islope |
|---|
| 94 | character(2) :: num |
|---|
| 95 | integer :: iq |
|---|
| 96 | character(30) :: txt ! To store some text |
|---|
| 97 | real :: Year ! Year of the simulation |
|---|
| 98 | |
|---|
| 99 | ! Open file |
|---|
| 100 | call open_restartphy(filename) |
|---|
| 101 | |
|---|
| 102 | ! First variable to write must be "Time", in order to correctly |
|---|
| 103 | ! set time counter in file |
|---|
| 104 | Year = (year_bp_ini + i_myear)*convert_years |
|---|
| 105 | call put_var("Time","Year of simulation",Year) |
|---|
| 106 | call put_field('h2o_ice','h2o_ice',h2o_ice,Year) |
|---|
| 107 | |
|---|
| 108 | if (soil_pem) then |
|---|
| 109 | ! Multidimensionnal variables (undermesh slope statistics) |
|---|
| 110 | do islope = 1,nslope |
|---|
| 111 | write(num,fmt='(i2.2)') islope |
|---|
| 112 | call put_field("tsoil_PEM_slope"//num,"Soil temperature by slope type",tsoil_slope_PEM(:,:,islope),Year) |
|---|
| 113 | call put_field("TI_PEM_slope"//num,"Soil Thermal Inertia by slope type",inertiesoil_slope_PEM(:,:,islope),Year) |
|---|
| 114 | call put_field("mco2_reg_ads_slope"//num, "Mass of co2 adsorbded in the regolith",m_co2_regolith(:,:,islope),Year) |
|---|
| 115 | call put_field("mh2o_reg_ads_slope"//num, "Mass of h2o adsorbded in the regolith",m_h2o_regolith(:,:,islope),Year) |
|---|
| 116 | enddo |
|---|
| 117 | call put_field("ice_table_depth","Depth of ice table",ice_table_depth,Year) |
|---|
| 118 | call put_field("ice_table_thickness","Depth of ice table",ice_table_thickness,Year) |
|---|
| 119 | call put_field("inertiedat_PEM","Thermal inertie of PEM ",inertiedat_PEM,Year) |
|---|
| 120 | endif ! soil_pem |
|---|
| 121 | |
|---|
| 122 | ! Close file |
|---|
| 123 | call close_restartphy |
|---|
| 124 | |
|---|
| 125 | END SUBROUTINE pemdem1 |
|---|
| 126 | |
|---|
| 127 | END MODULE pemredem |
|---|