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