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 | call put_var("FluxGeo","Geothermal Flux (W/m^2)",fluxgeo) |
---|
67 | |
---|
68 | ! Close file |
---|
69 | call close_restartphy |
---|
70 | |
---|
71 | end subroutine pemdem0 |
---|
72 | |
---|
73 | subroutine pemdem1(filename,year_iter,nsoil_PEM,ngrid,nslope, & |
---|
74 | tsoil_slope_PEM,inertiesoil_slope_PEM,ice_table, & |
---|
75 | m_co2_regolith,m_h2o_regolith,water_reservoir) |
---|
76 | ! write time-dependent variable to restart file |
---|
77 | use iostart_PEM, only : open_restartphy, close_restartphy, & |
---|
78 | put_var, put_field |
---|
79 | |
---|
80 | use comsoil_h_PEM, only: mlayer_PEM,fluxgeo,inertiedat_PEM,soil_pem |
---|
81 | USE temps_mod_evol, ONLY: year_PEM |
---|
82 | |
---|
83 | implicit none |
---|
84 | |
---|
85 | #ifndef CPP_STD |
---|
86 | include "callkeys.h" |
---|
87 | #endif |
---|
88 | |
---|
89 | character(len=*),intent(in) :: filename |
---|
90 | integer,intent(in) :: nsoil_PEM |
---|
91 | integer,intent(in) :: ngrid |
---|
92 | real,intent(IN) :: tsoil_slope_PEM(ngrid,nsoil_PEM,nslope) !under mesh bining according to slope |
---|
93 | real,intent(IN) :: inertiesoil_slope_PEM(ngrid,nsoil_PEM,nslope) !under mesh bining according to slope |
---|
94 | real,intent(IN) :: ice_table(ngrid,nslope) !under mesh bining according to slope |
---|
95 | integer,intent(IN) :: nslope |
---|
96 | real,intent(in) :: m_co2_regolith(ngrid,nsoil_PEM,nslope) |
---|
97 | real,intent(in) :: m_h2o_regolith(ngrid,nsoil_PEM,nslope) |
---|
98 | real,intent(IN) :: water_reservoir(ngrid) |
---|
99 | integer :: islope |
---|
100 | CHARACTER*2 :: num |
---|
101 | integer, intent(IN) :: year_iter |
---|
102 | |
---|
103 | real :: year_tot |
---|
104 | |
---|
105 | integer :: iq |
---|
106 | character(len=30) :: txt ! to store some text |
---|
107 | ! indexes of water vapour & water ice tracers (if any): |
---|
108 | |
---|
109 | year_tot=real(year_iter+year_PEM) |
---|
110 | print *, "Year of simulation=", year_tot |
---|
111 | |
---|
112 | ! Open file |
---|
113 | call open_restartphy(filename) |
---|
114 | |
---|
115 | ! First variable to write must be "Time", in order to correctly |
---|
116 | ! set time counter in file |
---|
117 | call put_var("Time","Year of simulation",year_tot) |
---|
118 | |
---|
119 | call put_field("water_reservoir","water_reservoir", & |
---|
120 | water_reservoir,year_tot) |
---|
121 | |
---|
122 | if(soil_pem) then |
---|
123 | |
---|
124 | ! Multidimensionnal variables (undermesh slope statistics) |
---|
125 | DO islope=1,nslope |
---|
126 | write(num,fmt='(i2.2)') islope |
---|
127 | call put_field("tsoil_PEM_slope"//num,"Soil temperature by slope type", & |
---|
128 | tsoil_slope_PEM(:,:,islope),year_tot) |
---|
129 | call put_field("TI_PEM_slope"//num,"Soil Thermal Inertia by slope type", & |
---|
130 | inertiesoil_slope_PEM(:,:,islope),year_tot) |
---|
131 | |
---|
132 | call put_field("mco2_reg_ads_slope"//num, "Mass of co2 adsorbded in the regolith", & |
---|
133 | m_co2_regolith(:,:,islope), year_tot) |
---|
134 | call put_field("mh2o_reg_ads_slope"//num, "Mass of h2o adsorbded in the regolith", & |
---|
135 | m_h2o_regolith(:,:,islope), year_tot) |
---|
136 | |
---|
137 | ENDDO |
---|
138 | |
---|
139 | call put_field("ice_table","Depth of ice table", & |
---|
140 | ice_table,year_tot) |
---|
141 | |
---|
142 | call put_field("inertiedat_PEM","Thermal inertie of PEM ", & |
---|
143 | inertiedat_PEM,year_tot) |
---|
144 | |
---|
145 | endif !soil_pem |
---|
146 | |
---|
147 | ! Close file |
---|
148 | call close_restartphy |
---|
149 | |
---|
150 | end subroutine pemdem1 |
---|
151 | |
---|
152 | end module pemredem |
---|