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