[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 | |
---|
[3206] | 18 | SUBROUTINE pemdem0(filename,lonfi,latfi,cell_area,ngrid,nslope,def_slope,subslope_dist) |
---|
[3149] | 19 | |
---|
[2794] | 20 | ! create physics restart file and write time-independent variables |
---|
[3206] | 21 | use comsoil_h_PEM, only: mlayer_PEM |
---|
| 22 | use iostart_PEM, only: open_restartphy, close_restartphy, put_var, put_field, length |
---|
[3149] | 23 | |
---|
| 24 | implicit none |
---|
[2794] | 25 | |
---|
[3149] | 26 | character(*), intent(in) :: filename |
---|
[3206] | 27 | integer, intent(in) :: ngrid, nslope |
---|
[3149] | 28 | real, dimension(ngrid), intent(in) :: lonfi, latfi |
---|
| 29 | real, dimension(ngrid), intent(in) :: cell_area ! boundaries for bining of the slopes |
---|
[3313] | 30 | real, dimension(nslope + 1), intent(in) :: def_slope ! boundaries for bining of the slopes |
---|
[3149] | 31 | real, dimension(ngrid,nslope), intent(in) :: subslope_dist ! undermesh statistics |
---|
[2794] | 32 | |
---|
[3149] | 33 | ! Create physics start file |
---|
| 34 | call open_restartphy(filename) |
---|
[2794] | 35 | |
---|
[3149] | 36 | ! Write the mid-layer depths |
---|
| 37 | call put_var("soildepth","Soil mid-layer depth",mlayer_PEM) |
---|
[2888] | 38 | |
---|
[3149] | 39 | ! Write longitudes |
---|
| 40 | call put_field("longitude","Longitudes of physics grid",lonfi) |
---|
[2888] | 41 | |
---|
[3149] | 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, & |
---|
[3493] | 60 | ice_table_depth,ice_table_thickness,ice_porefilling,m_co2_regolith,m_h2o_regolith,h2o_ice,stratif) |
---|
[3149] | 61 | |
---|
| 62 | ! write time-dependent variable to restart file |
---|
| 63 | use iostart_PEM, only: open_restartphy, close_restartphy, put_var, put_field |
---|
[3206] | 64 | use comsoil_h_PEM, only: inertiedat_PEM, soil_pem |
---|
[3149] | 65 | use time_evol_mod, only: year_bp_ini, convert_years |
---|
[3319] | 66 | use layering_mod, only: layering, nb_str_max, stratif2array, print_layering, layering_algo |
---|
[3149] | 67 | |
---|
| 68 | implicit none |
---|
| 69 | |
---|
[2842] | 70 | #ifndef CPP_STD |
---|
[3149] | 71 | include "callkeys.h" |
---|
[2842] | 72 | #endif |
---|
[2794] | 73 | |
---|
[3149] | 74 | character(*), intent(in) :: filename |
---|
| 75 | integer, intent(in) :: nsoil_PEM, ngrid, nslope, i_myear |
---|
| 76 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: tsoil_slope_PEM ! under mesh bining according to slope |
---|
| 77 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: inertiesoil_slope_PEM ! under mesh bining according to slope |
---|
| 78 | real, dimension(ngrid,nslope), intent(in) :: ice_table_depth ! under mesh bining according to slope |
---|
| 79 | real, dimension(ngrid,nslope), intent(in) :: ice_table_thickness ! under mesh bining according to slope |
---|
[3493] | 80 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: ice_porefilling ! under mesh bining according to slope |
---|
[3149] | 81 | real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: m_co2_regolith, m_h2o_regolith |
---|
| 82 | real, dimension(ngrid,nslope), intent(in) :: h2o_ice |
---|
[3297] | 83 | type(layering), dimension(ngrid,nslope), intent(in) :: stratif ! Stratification (layerings) |
---|
[2794] | 84 | |
---|
[3297] | 85 | integer :: islope |
---|
| 86 | character(2) :: num |
---|
| 87 | real :: Year ! Year of the simulation |
---|
| 88 | real, dimension(:,:,:,:), allocatable :: stratif_array ! Array for stratification (layerings) |
---|
[3039] | 89 | |
---|
[3149] | 90 | ! Open file |
---|
| 91 | call open_restartphy(filename) |
---|
[2794] | 92 | |
---|
[3149] | 93 | ! First variable to write must be "Time", in order to correctly |
---|
| 94 | ! set time counter in file |
---|
| 95 | Year = (year_bp_ini + i_myear)*convert_years |
---|
| 96 | call put_var("Time","Year of simulation",Year) |
---|
| 97 | call put_field('h2o_ice','h2o_ice',h2o_ice,Year) |
---|
[2794] | 98 | |
---|
[3319] | 99 | if (layering_algo) then |
---|
| 100 | allocate(stratif_array(ngrid,nslope,nb_str_max,6)) |
---|
| 101 | call stratif2array(stratif,ngrid,nslope,stratif_array) |
---|
| 102 | do islope = 1,nslope |
---|
| 103 | write(num,fmt='(i2.2)') islope |
---|
| 104 | call put_field('stratif_slope'//num//'_thickness','Layering thickness',stratif_array(:,islope,:,1),Year) |
---|
| 105 | call put_field('stratif_slope'//num//'_top_elevation','Layering top elevation',stratif_array(:,islope,:,2),Year) |
---|
| 106 | call put_field('stratif_slope'//num//'_co2ice_volfrac','Layering CO2 ice volume fraction',stratif_array(:,islope,:,3),Year) |
---|
| 107 | call put_field('stratif_slope'//num//'_h2oice_volfrac','Layering H2O ice volume fraction',stratif_array(:,islope,:,4),Year) |
---|
| 108 | call put_field('stratif_slope'//num//'_dust_volfrac','Layering dust volume fraction',stratif_array(:,islope,:,5),Year) |
---|
| 109 | call put_field('stratif_slope'//num//'_air_volfrac','Layering air volume fraction',stratif_array(:,islope,:,6),Year) |
---|
| 110 | enddo |
---|
| 111 | deallocate(stratif_array) |
---|
| 112 | endif |
---|
[3297] | 113 | |
---|
[3149] | 114 | if (soil_pem) then |
---|
| 115 | ! Multidimensionnal variables (undermesh slope statistics) |
---|
| 116 | do islope = 1,nslope |
---|
| 117 | write(num,fmt='(i2.2)') islope |
---|
| 118 | call put_field("tsoil_PEM_slope"//num,"Soil temperature by slope type",tsoil_slope_PEM(:,:,islope),Year) |
---|
| 119 | call put_field("TI_PEM_slope"//num,"Soil Thermal Inertia by slope type",inertiesoil_slope_PEM(:,:,islope),Year) |
---|
| 120 | call put_field("mco2_reg_ads_slope"//num, "Mass of co2 adsorbded in the regolith",m_co2_regolith(:,:,islope),Year) |
---|
| 121 | call put_field("mh2o_reg_ads_slope"//num, "Mass of h2o adsorbded in the regolith",m_h2o_regolith(:,:,islope),Year) |
---|
| 122 | enddo |
---|
| 123 | call put_field("ice_table_depth","Depth of ice table",ice_table_depth,Year) |
---|
| 124 | call put_field("ice_table_thickness","Depth of ice table",ice_table_thickness,Year) |
---|
[3493] | 125 | call put_field("ice_porefilling","Subsurface ice pore filling",ice_porefilling,Year) |
---|
[3149] | 126 | call put_field("inertiedat_PEM","Thermal inertie of PEM ",inertiedat_PEM,Year) |
---|
| 127 | endif ! soil_pem |
---|
[2794] | 128 | |
---|
[3149] | 129 | ! Close file |
---|
| 130 | call close_restartphy |
---|
[2794] | 131 | |
---|
[3149] | 132 | END SUBROUTINE pemdem1 |
---|
[2961] | 133 | |
---|
[3149] | 134 | END MODULE pemredem |
---|