[2794] | 1 | module pemredem |
---|
[2855] | 2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 3 | !!! |
---|
| 4 | !!! Purpose: Write specific netcdf restart for the PEM |
---|
| 5 | !!! |
---|
| 6 | !!! |
---|
| 7 | !!! Author: LL, inspired by phyredem from the GCM |
---|
| 8 | !!! |
---|
| 9 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2794] | 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 |
---|
[2855] | 18 | use comsoil_h_PEM, only: soil_pem,mlayer_PEM,fluxgeo,inertiedat_PEM |
---|
[2794] | 19 | use iostart_PEM, only : open_restartphy, close_restartphy, & |
---|
| 20 | put_var, put_field, length |
---|
| 21 | use mod_grid_phy_lmdz, only : klon_glo |
---|
[2842] | 22 | #ifndef CPP_STD |
---|
[2794] | 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 |
---|
[2842] | 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 |
---|
[2794] | 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 | |
---|
[2835] | 72 | subroutine pemdem1(filename,year_iter,nsoil_PEM,ngrid,nslope, & |
---|
[2863] | 73 | tsoil_slope_PEM,inertiesoil_slope_PEM,ice_table, & |
---|
[2885] | 74 | m_co2_regolith,m_h2o_regolith,water_reservoir) |
---|
[2888] | 75 | |
---|
| 76 | |
---|
[2794] | 77 | ! write time-dependent variable to restart file |
---|
| 78 | use iostart_PEM, only : open_restartphy, close_restartphy, & |
---|
| 79 | put_var, put_field |
---|
| 80 | |
---|
[2855] | 81 | use comsoil_h_PEM, only: mlayer_PEM,fluxgeo,inertiedat_PEM,soil_pem |
---|
[2835] | 82 | USE temps_mod_evol, ONLY: year_PEM |
---|
[2794] | 83 | |
---|
| 84 | implicit none |
---|
| 85 | |
---|
[2842] | 86 | #ifndef CPP_STD |
---|
[2794] | 87 | include "callkeys.h" |
---|
[2842] | 88 | #endif |
---|
[2794] | 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) |
---|
[2863] | 98 | real,intent(in) :: m_h2o_regolith(ngrid,nsoil_PEM,nslope) |
---|
[2888] | 99 | real,intent(in) :: water_reservoir(ngrid) |
---|
[2794] | 100 | integer :: islope |
---|
| 101 | CHARACTER*2 :: num |
---|
[2835] | 102 | integer, intent(IN) :: year_iter |
---|
[2794] | 103 | |
---|
[2835] | 104 | real :: year_tot |
---|
[2794] | 105 | |
---|
| 106 | integer :: iq |
---|
| 107 | character(len=30) :: txt ! to store some text |
---|
| 108 | ! indexes of water vapour & water ice tracers (if any): |
---|
| 109 | |
---|
[2835] | 110 | year_tot=real(year_iter+year_PEM) |
---|
| 111 | print *, "Year of simulation=", year_tot |
---|
[2794] | 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 |
---|
[2835] | 118 | call put_var("Time","Year of simulation",year_tot) |
---|
[2888] | 119 | call put_field('water_reservoir','water_reservoir', & |
---|
| 120 | water_reservoir,year_tot) |
---|
[2885] | 121 | call put_field("water_reservoir","water_reservoir", & |
---|
| 122 | water_reservoir,year_tot) |
---|
| 123 | |
---|
[2835] | 124 | if(soil_pem) then |
---|
[2794] | 125 | |
---|
| 126 | ! Multidimensionnal variables (undermesh slope statistics) |
---|
| 127 | DO islope=1,nslope |
---|
| 128 | write(num,fmt='(i2.2)') islope |
---|
| 129 | call put_field("tsoil_PEM_slope"//num,"Soil temperature by slope type", & |
---|
[2835] | 130 | tsoil_slope_PEM(:,:,islope),year_tot) |
---|
[2794] | 131 | call put_field("TI_PEM_slope"//num,"Soil Thermal Inertia by slope type", & |
---|
[2835] | 132 | inertiesoil_slope_PEM(:,:,islope),year_tot) |
---|
[2794] | 133 | |
---|
[2863] | 134 | call put_field("mco2_reg_ads_slope"//num, "Mass of co2 adsorbded in the regolith", & |
---|
[2835] | 135 | m_co2_regolith(:,:,islope), year_tot) |
---|
[2863] | 136 | call put_field("mh2o_reg_ads_slope"//num, "Mass of h2o adsorbded in the regolith", & |
---|
| 137 | m_h2o_regolith(:,:,islope), year_tot) |
---|
[2794] | 138 | |
---|
| 139 | ENDDO |
---|
| 140 | |
---|
| 141 | call put_field("ice_table","Depth of ice table", & |
---|
[2835] | 142 | ice_table,year_tot) |
---|
[2794] | 143 | |
---|
| 144 | call put_field("inertiedat_PEM","Thermal inertie of PEM ", & |
---|
[2835] | 145 | inertiedat_PEM,year_tot) |
---|
[2794] | 146 | |
---|
[2835] | 147 | endif !soil_pem |
---|
[2794] | 148 | |
---|
| 149 | ! Close file |
---|
| 150 | call close_restartphy |
---|
| 151 | |
---|
| 152 | end subroutine pemdem1 |
---|
| 153 | |
---|
| 154 | end module pemredem |
---|