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