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,ngrid,nslope,def_slope,subslope_dist) |
---|
19 | |
---|
20 | ! create physics restart file and write time-independent variables |
---|
21 | use comsoil_h_PEM, only: mlayer_PEM |
---|
22 | use iostart_PEM, only: open_restartphy, close_restartphy, put_var, put_field, length |
---|
23 | |
---|
24 | implicit none |
---|
25 | |
---|
26 | character(*), intent(in) :: filename |
---|
27 | integer, intent(in) :: ngrid, nslope |
---|
28 | real, dimension(ngrid), intent(in) :: lonfi, latfi |
---|
29 | real, dimension(ngrid), intent(in) :: cell_area ! boundaries for bining of the slopes |
---|
30 | real, dimension(ngrid + 1), intent(in) :: def_slope ! boundaries for bining of the slopes |
---|
31 | real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! undermesh statistics |
---|
32 | |
---|
33 | ! Create physics start file |
---|
34 | call open_restartphy(filename) |
---|
35 | |
---|
36 | ! Write the mid-layer depths |
---|
37 | call put_var("soildepth","Soil mid-layer depth",mlayer_PEM) |
---|
38 | |
---|
39 | ! Write longitudes |
---|
40 | call put_field("longitude","Longitudes of physics grid",lonfi) |
---|
41 | |
---|
42 | ! Write latitudes |
---|
43 | call put_field("latitude","Latitudes of physics grid",latfi) |
---|
44 | |
---|
45 | ! Write mesh areas |
---|
46 | call put_field("area","Mesh area",cell_area) |
---|
47 | |
---|
48 | ! Multidimensionnal variables (nopcm undermesh slope statistics) |
---|
49 | call put_var("def_slope","slope criterium stages",def_slope) |
---|
50 | call put_field("subslope_dist","under mesh slope distribution",subslope_dist) |
---|
51 | |
---|
52 | ! Close file |
---|
53 | call close_restartphy |
---|
54 | |
---|
55 | END SUBROUTINE pemdem0 |
---|
56 | |
---|
57 | !======================================================================= |
---|
58 | |
---|
59 | SUBROUTINE pemdem1(filename,i_myear,nsoil_PEM,ngrid,nslope,tsoil_slope_PEM,inertiesoil_slope_PEM, & |
---|
60 | ice_table_depth,ice_table_thickness,m_co2_regolith,m_h2o_regolith,h2o_ice) |
---|
61 | |
---|
62 | ! write time-dependent variable to restart file |
---|
63 | use iostart_PEM, only: open_restartphy, close_restartphy, put_var, put_field |
---|
64 | use comsoil_h_PEM, only: inertiedat_PEM, soil_pem |
---|
65 | use time_evol_mod, only: year_bp_ini, convert_years |
---|
66 | |
---|
67 | implicit none |
---|
68 | |
---|
69 | #ifndef CPP_STD |
---|
70 | include "callkeys.h" |
---|
71 | #endif |
---|
72 | |
---|
73 | character(*), intent(in) :: filename |
---|
74 | integer, intent(in) :: nsoil_PEM, ngrid, nslope, i_myear |
---|
75 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_slope_PEM ! under mesh bining according to slope |
---|
76 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: inertiesoil_slope_PEM ! under mesh bining according to slope |
---|
77 | real, dimension(ngrid,nslope), intent(in) :: ice_table_depth ! under mesh bining according to slope |
---|
78 | real, dimension(ngrid,nslope), intent(in) :: ice_table_thickness ! under mesh bining according to slope |
---|
79 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: m_co2_regolith, m_h2o_regolith |
---|
80 | real, dimension(ngrid,nslope), intent(in) :: h2o_ice |
---|
81 | |
---|
82 | integer :: islope |
---|
83 | character(2) :: num |
---|
84 | real :: Year ! Year of the simulation |
---|
85 | |
---|
86 | ! Open file |
---|
87 | call open_restartphy(filename) |
---|
88 | |
---|
89 | ! First variable to write must be "Time", in order to correctly |
---|
90 | ! set time counter in file |
---|
91 | Year = (year_bp_ini + i_myear)*convert_years |
---|
92 | call put_var("Time","Year of simulation",Year) |
---|
93 | call put_field('h2o_ice','h2o_ice',h2o_ice,Year) |
---|
94 | |
---|
95 | if (soil_pem) then |
---|
96 | ! Multidimensionnal variables (undermesh slope statistics) |
---|
97 | do islope = 1,nslope |
---|
98 | write(num,fmt='(i2.2)') islope |
---|
99 | call put_field("tsoil_PEM_slope"//num,"Soil temperature by slope type",tsoil_slope_PEM(:,:,islope),Year) |
---|
100 | call put_field("TI_PEM_slope"//num,"Soil Thermal Inertia by slope type",inertiesoil_slope_PEM(:,:,islope),Year) |
---|
101 | call put_field("mco2_reg_ads_slope"//num, "Mass of co2 adsorbded in the regolith",m_co2_regolith(:,:,islope),Year) |
---|
102 | call put_field("mh2o_reg_ads_slope"//num, "Mass of h2o adsorbded in the regolith",m_h2o_regolith(:,:,islope),Year) |
---|
103 | enddo |
---|
104 | call put_field("ice_table_depth","Depth of ice table",ice_table_depth,Year) |
---|
105 | call put_field("ice_table_thickness","Depth of ice table",ice_table_thickness,Year) |
---|
106 | call put_field("inertiedat_PEM","Thermal inertie of PEM ",inertiedat_PEM,Year) |
---|
107 | endif ! soil_pem |
---|
108 | |
---|
109 | ! Close file |
---|
110 | call close_restartphy |
---|
111 | |
---|
112 | END SUBROUTINE pemdem1 |
---|
113 | |
---|
114 | END MODULE pemredem |
---|