| 1 | module phyredem |
|---|
| 2 | |
|---|
| 3 | implicit none |
|---|
| 4 | |
|---|
| 5 | INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file |
|---|
| 6 | |
|---|
| 7 | contains |
|---|
| 8 | |
|---|
| 9 | subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq, & |
|---|
| 10 | phystep,day_ini,time,airefi, & |
|---|
| 11 | alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe) |
|---|
| 12 | ! create physics restart file and write time-independent variables |
|---|
| 13 | use comsoil_h, only: volcapa, mlayer |
|---|
| 14 | use geometry_mod, only: cell_area |
|---|
| 15 | use surfdat_h, only: zmea, zstd, zsig, zgam, zthe, & |
|---|
| 16 | emisice, emissiv, & |
|---|
| 17 | iceradius, dtemisice, phisfi |
|---|
| 18 | use iostart, only : create_restartphy, close_restartphy, & |
|---|
| 19 | put_var, put_field, length, ldscrpt, ndscrpt |
|---|
| 20 | use mod_grid_phy_lmdz, only : klon_glo |
|---|
| 21 | use planete_mod, only: year_day, periastr, apoastr, peri_day, & |
|---|
| 22 | obliquit, z0 |
|---|
| 23 | use comcstfi_mod, only: rad, omeg, g, mugaz, rcp |
|---|
| 24 | use time_phylmdz_mod, only: daysec |
|---|
| 25 | |
|---|
| 26 | implicit none |
|---|
| 27 | |
|---|
| 28 | character(len=*), intent(in) :: filename |
|---|
| 29 | real,intent(in) :: lonfi(ngrid) |
|---|
| 30 | real,intent(in) :: latfi(ngrid) |
|---|
| 31 | integer,intent(in) :: nsoil |
|---|
| 32 | integer,intent(in) :: ngrid |
|---|
| 33 | integer,intent(in) :: nlay |
|---|
| 34 | integer,intent(in) :: nq |
|---|
| 35 | real,intent(in) :: phystep |
|---|
| 36 | real,intent(in) :: day_ini |
|---|
| 37 | real,intent(in) :: time |
|---|
| 38 | real,intent(in) :: airefi(ngrid) |
|---|
| 39 | real,intent(in) :: alb(ngrid) |
|---|
| 40 | real,intent(in) :: ith(ngrid,nsoil) |
|---|
| 41 | real,intent(in) :: pzmea(ngrid) |
|---|
| 42 | real,intent(in) :: pzstd(ngrid) |
|---|
| 43 | real,intent(in) :: pzsig(ngrid) |
|---|
| 44 | real,intent(in) :: pzgam(ngrid) |
|---|
| 45 | real,intent(in) :: pzthe(ngrid) |
|---|
| 46 | |
|---|
| 47 | character(ndscrpt), dimension(ldscrpt), parameter :: dscrpt_tab_cntrl = (/ & |
|---|
| 48 | "(1) Number of atmospheric columns in physics ", & |
|---|
| 49 | "(2) Number of atmospheric layers ", & |
|---|
| 50 | "(3) Final day ", & |
|---|
| 51 | "(4) Final time of day ", & |
|---|
| 52 | "(5) Planet radius (m) ", & |
|---|
| 53 | "(6) Rotation rate (rad.s-1) ", & |
|---|
| 54 | "(7) Gravity (m.s-2) ", & |
|---|
| 55 | "(8) Molar mass of the atmosphere (g.mol-1) ", & |
|---|
| 56 | "(9) = r/Cp (=kappa in the dynamics) ", & |
|---|
| 57 | "(10) Length of a solar day (s) ", & |
|---|
| 58 | "(11) Physics time step (s) ", & |
|---|
| 59 | "(12) - ", & |
|---|
| 60 | "(13) - ", & |
|---|
| 61 | "(14) Length of year (in solar days) ", & |
|---|
| 62 | "(15) Minimum star-planet distance (AU) ", & |
|---|
| 63 | "(16) Maximum star-planet distance (AU) ", & |
|---|
| 64 | "(17) Date of periastro (sols since N. spring) ", & |
|---|
| 65 | "(18) Obliquity of the planet (deg) ", & |
|---|
| 66 | "(19) Default surface roughness (m) ", & |
|---|
| 67 | "(20) - ", & |
|---|
| 68 | "(21) - ", & |
|---|
| 69 | "(22) - ", & |
|---|
| 70 | "(23) - ", & |
|---|
| 71 | "(24) Emissivity of northern cap ~0.95 ", & |
|---|
| 72 | "(25) Emissivity of southern cap ~0.95 ", & |
|---|
| 73 | "(26) Emissivity of martian soil ~.95 ", & |
|---|
| 74 | "(27) - ", & |
|---|
| 75 | "(28) - ", & |
|---|
| 76 | "(29) - ", & |
|---|
| 77 | "(30) - ", & |
|---|
| 78 | "(31) Mean scat radius of CO2 snow (north) ", & |
|---|
| 79 | "(32) Mean scat radius of CO2 snow (south) ", & |
|---|
| 80 | "(33) Time scale for snow metamorphism (north) ", & |
|---|
| 81 | "(34) Time scale for snow metamorphism (south) ", & |
|---|
| 82 | "(35) Soil volumetric heat capacity "/) |
|---|
| 83 | real :: tab_cntrl(length) ! nb "length=100" defined in iostart module |
|---|
| 84 | |
|---|
| 85 | ! Create physics start file |
|---|
| 86 | call create_restartphy(filename,nid_restart) |
|---|
| 87 | |
|---|
| 88 | ! tab_cntrl() contains run parameters |
|---|
| 89 | tab_cntrl(:)=0 ! initialization |
|---|
| 90 | !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
|---|
| 91 | ! Fill control array tab_cntrl(:) with paramleters for this run |
|---|
| 92 | !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
|---|
| 93 | ! Informations on the physics grid |
|---|
| 94 | tab_cntrl(1) = float(klon_glo) ! number of atmospheric columns in physics |
|---|
| 95 | tab_cntrl(2) = float(nlay) ! number of atmospheric layers |
|---|
| 96 | tab_cntrl(3) = day_ini + int(time) ! final day |
|---|
| 97 | tab_cntrl(4) = time -int(time) ! final time of day |
|---|
| 98 | |
|---|
| 99 | ! Informations about the planet, used by dynamics and physics |
|---|
| 100 | tab_cntrl(5) = rad ! planet radius (m) |
|---|
| 101 | tab_cntrl(6) = omeg ! rotation rate (rad.s-1) |
|---|
| 102 | tab_cntrl(7) = g ! gravity (m.s-2) |
|---|
| 103 | tab_cntrl(8) = mugaz ! Molar mass of the atmosphere (g.mol-1) |
|---|
| 104 | tab_cntrl(9) = rcp ! = r/cp (=kappa in the dynamics) |
|---|
| 105 | tab_cntrl(10) = daysec ! length of a solar day (s) |
|---|
| 106 | |
|---|
| 107 | tab_cntrl(11) = phystep ! physics time step (s) |
|---|
| 108 | tab_cntrl(12) = 0. |
|---|
| 109 | tab_cntrl(13) = 0. |
|---|
| 110 | |
|---|
| 111 | ! Informations about the planet, only for physics |
|---|
| 112 | tab_cntrl(14) = year_day ! length of year (in solar days) |
|---|
| 113 | tab_cntrl(15) = periastr ! minimum star-planet distance (AU) |
|---|
| 114 | tab_cntrl(16) = apoastr ! maximum star-planet distance (AU) |
|---|
| 115 | tab_cntrl(17) = peri_day ! date of periastron (sols since N. spring) |
|---|
| 116 | tab_cntrl(18) = obliquit ! Obliquity of the planet (deg) |
|---|
| 117 | |
|---|
| 118 | ! Boundary layer and turbulence |
|---|
| 119 | tab_cntrl(19) = z0 ! surface roughness (m) |
|---|
| 120 | ! tab_cntrl(20) = lmixmin ! mixing length (m) |
|---|
| 121 | ! tab_cntrl(21) = emin_turb ! minimal energy |
|---|
| 122 | |
|---|
| 123 | ! Optical properties of polar caps and ground emissivity |
|---|
| 124 | tab_cntrl(24) = emisice(1) ! Emissivity of northern cap ~0.95 |
|---|
| 125 | tab_cntrl(25) = emisice(2) ! Emissivity of southern cap ~0.95 |
|---|
| 126 | tab_cntrl(26) = emissiv ! Emissivity of martian soil ~.95 |
|---|
| 127 | tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north) |
|---|
| 128 | tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south) |
|---|
| 129 | tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north) |
|---|
| 130 | tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south) |
|---|
| 131 | |
|---|
| 132 | tab_cntrl(28) = 0. |
|---|
| 133 | tab_cntrl(29) = 0. |
|---|
| 134 | tab_cntrl(30) = 0. |
|---|
| 135 | ! Soil properties: |
|---|
| 136 | tab_cntrl(35) = volcapa ! soil volumetric heat capacity |
|---|
| 137 | |
|---|
| 138 | ! Write the controle array |
|---|
| 139 | call put_var(nid_restart,"controle","Control parameters",tab_cntrl) |
|---|
| 140 | |
|---|
| 141 | ! Write the controle array descriptor |
|---|
| 142 | call put_var(nid_restart,"controle_descriptor",& |
|---|
| 143 | "Description of control parameters",dscrpt_tab_cntrl) |
|---|
| 144 | |
|---|
| 145 | ! Write the mid-layer depths |
|---|
| 146 | call put_var(nid_restart,"soildepth","Soil mid-layer depth",mlayer) |
|---|
| 147 | |
|---|
| 148 | ! Write longitudes |
|---|
| 149 | call put_field(nid_restart,"longitude","Longitudes of physics grid",lonfi) |
|---|
| 150 | |
|---|
| 151 | ! Write latitudes |
|---|
| 152 | call put_field(nid_restart,"latitude","Latitudes of physics grid",latfi) |
|---|
| 153 | |
|---|
| 154 | ! Write mesh areas |
|---|
| 155 | call put_field(nid_restart,"area","Mesh area",cell_area) |
|---|
| 156 | |
|---|
| 157 | ! Write surface geopotential |
|---|
| 158 | call put_field(nid_restart,"phisfi","Geopotential at the surface",phisfi) |
|---|
| 159 | |
|---|
| 160 | ! Write surface albedo |
|---|
| 161 | call put_field(nid_restart,"albedodat","Albedo of bare ground",alb) |
|---|
| 162 | |
|---|
| 163 | ! Subgrid topogaphy variables |
|---|
| 164 | call put_field(nid_restart,"ZMEA","Relief: mean relief",zmea) |
|---|
| 165 | call put_field(nid_restart,"ZSTD","Relief: standard deviation",zstd) |
|---|
| 166 | call put_field(nid_restart,"ZSIG","Relief: sigma parameter",zsig) |
|---|
| 167 | call put_field(nid_restart,"ZGAM","Relief: gamma parameter",zgam) |
|---|
| 168 | call put_field(nid_restart,"ZTHE","Relief: theta parameter",zthe) |
|---|
| 169 | |
|---|
| 170 | ! Soil thermal inertia |
|---|
| 171 | call put_field(nid_restart,"inertiedat","Soil thermal inertia",ith) |
|---|
| 172 | |
|---|
| 173 | ! Close file |
|---|
| 174 | call close_restartphy(nid_restart) |
|---|
| 175 | |
|---|
| 176 | end subroutine physdem0 |
|---|
| 177 | |
|---|
| 178 | subroutine physdem1(filename,nsoil,ngrid,nlay,nq, & |
|---|
| 179 | phystep,time,tsurf,tsoil,emis,albedo,q2,qsurf, & |
|---|
| 180 | cloudfrac,totcloudfrac,hice, & |
|---|
| 181 | rnat,pctsrf_sic,tslab,tsea_ice,tice,sea_ice) |
|---|
| 182 | ! write time-dependent variable to restart file |
|---|
| 183 | use iostart, only : open_restartphy, close_restartphy, & |
|---|
| 184 | put_var, put_field |
|---|
| 185 | use tracer_h, only: noms |
|---|
| 186 | USE radinc_h, ONLY: L_NSPECTV |
|---|
| 187 | ! use slab_ice_h, only: noceanmx |
|---|
| 188 | USE ocean_slab_mod, ONLY: nslay |
|---|
| 189 | use callkeys_mod, only: ok_slab_ocean, calllott_nonoro |
|---|
| 190 | use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd, & |
|---|
| 191 | east_gwstress, west_gwstress |
|---|
| 192 | |
|---|
| 193 | implicit none |
|---|
| 194 | |
|---|
| 195 | character(len=*),intent(in) :: filename |
|---|
| 196 | integer,intent(in) :: nsoil |
|---|
| 197 | integer,intent(in) :: ngrid |
|---|
| 198 | integer,intent(in) :: nlay |
|---|
| 199 | integer,intent(in) :: nq |
|---|
| 200 | real,intent(in) :: phystep |
|---|
| 201 | real,intent(in) :: time |
|---|
| 202 | real,intent(in) :: tsurf(ngrid) |
|---|
| 203 | real,intent(in) :: tsoil(ngrid,nsoil) |
|---|
| 204 | real,intent(in) :: emis(ngrid) |
|---|
| 205 | real,intent(in) :: albedo(ngrid,L_NSPECTV) |
|---|
| 206 | real,intent(in) :: q2(ngrid,nlay+1) |
|---|
| 207 | real,intent(in) :: qsurf(ngrid,nq) |
|---|
| 208 | real,intent(in) :: cloudfrac(ngrid,nlay) |
|---|
| 209 | real,intent(in) :: totcloudfrac(ngrid) |
|---|
| 210 | real,intent(in) :: hice(ngrid) |
|---|
| 211 | real,intent(in) :: rnat(ngrid) |
|---|
| 212 | real,intent(in) :: pctsrf_sic(ngrid) |
|---|
| 213 | real,intent(in) :: tslab(ngrid,nslay) |
|---|
| 214 | real,intent(in) :: tsea_ice(ngrid) |
|---|
| 215 | real,intent(in) :: sea_ice(ngrid) |
|---|
| 216 | real,intent(in) :: tice(ngrid) |
|---|
| 217 | |
|---|
| 218 | integer :: iq |
|---|
| 219 | |
|---|
| 220 | ! Open file |
|---|
| 221 | call open_restartphy(filename,nid_restart) |
|---|
| 222 | |
|---|
| 223 | ! First variable to write must be "Time", in order to correctly |
|---|
| 224 | ! set time counter in file |
|---|
| 225 | !call put_var("Time","Temps de simulation",time) |
|---|
| 226 | |
|---|
| 227 | ! Surface temperature |
|---|
| 228 | call put_field(nid_restart,"tsurf","Surface temperature",tsurf) |
|---|
| 229 | |
|---|
| 230 | ! Soil temperature |
|---|
| 231 | call put_field(nid_restart,"tsoil","Soil temperature",tsoil) |
|---|
| 232 | |
|---|
| 233 | ! Emissivity of the surface |
|---|
| 234 | call put_field(nid_restart,"emis","Surface emissivity",emis) |
|---|
| 235 | |
|---|
| 236 | ! Surface albedo (assume homegeneous spectral albedo for now) |
|---|
| 237 | call put_field(nid_restart,"albedo","Surface albedo",albedo(:,1)) |
|---|
| 238 | |
|---|
| 239 | ! Planetary Boundary Layer |
|---|
| 240 | call put_field(nid_restart,"q2","pbl wind variance",q2) |
|---|
| 241 | |
|---|
| 242 | ! cloud fraction and sea ice (NB: these should be optional... to be improved) |
|---|
| 243 | call put_field(nid_restart,"cloudfrac","Cloud fraction",cloudfrac) |
|---|
| 244 | call put_field(nid_restart,"totcloudfrac","Total fraction",totcloudfrac) |
|---|
| 245 | call put_field(nid_restart,"hice","Height of oceanic ice",hice) |
|---|
| 246 | |
|---|
| 247 | !Slab ocean |
|---|
| 248 | if(ok_slab_ocean) then |
|---|
| 249 | call put_field(nid_restart,"rnat","Nature of surface",rnat) |
|---|
| 250 | call put_field(nid_restart,"pctsrf_sic","Pourcentage sea ice",pctsrf_sic) |
|---|
| 251 | call put_field(nid_restart,"tslab","Temperature slab ocean",tslab) |
|---|
| 252 | call put_field(nid_restart,"tsea_ice","Temperature of top layer (seaice or snow)",tsea_ice) |
|---|
| 253 | call put_field(nid_restart,"tice","Temperature of seaice",tice) |
|---|
| 254 | call put_field(nid_restart,"sea_ice","Sea ice mass",sea_ice) |
|---|
| 255 | endif!(ok_slab_ocean) |
|---|
| 256 | |
|---|
| 257 | ! tracers |
|---|
| 258 | if (nq>0) then |
|---|
| 259 | do iq=1,nq |
|---|
| 260 | call put_field(nid_restart,noms(iq),"tracer on surface",qsurf(:,iq)) |
|---|
| 261 | enddo |
|---|
| 262 | endif ! of if (nq>0) |
|---|
| 263 | |
|---|
| 264 | ! Non-orographic gavity waves |
|---|
| 265 | if (calllott_nonoro) then |
|---|
| 266 | call put_field(nid_restart,"du_nonoro_gwd","Zonal wind tendency due to GW",du_nonoro_gwd) |
|---|
| 267 | call put_field(nid_restart,"dv_nonoro_gwd","Meridional wind tendency due to GW",dv_nonoro_gwd) |
|---|
| 268 | call put_field(nid_restart,"east_gwstress","Eastward stress profile due to GW",east_gwstress) |
|---|
| 269 | call put_field(nid_restart,"west_gwstress","Westward stress profile due to GW",west_gwstress) |
|---|
| 270 | endif |
|---|
| 271 | |
|---|
| 272 | ! close file |
|---|
| 273 | CALL close_restartphy(nid_restart) |
|---|
| 274 | !$OMP BARRIER |
|---|
| 275 | |
|---|
| 276 | end subroutine physdem1 |
|---|
| 277 | |
|---|
| 278 | end module phyredem |
|---|